static int nuv_header(AVFormatContext *s)

{

    NUVContext *ctx = s->priv_data;

    AVIOContext *pb = s->pb;

    char id_string[12];

    double aspect, fps;

    int is_mythtv, width, height, v_packs, a_packs;

    AVStream *vst = NULL, *ast = NULL;



    avio_read(pb, id_string, 12);

    is_mythtv = !memcmp(id_string, "MythTVVideo", 12);

    avio_skip(pb, 5);       // version string

    avio_skip(pb, 3);       // padding

    width  = avio_rl32(pb);

    height = avio_rl32(pb);

    avio_rl32(pb);          // unused, "desiredwidth"

    avio_rl32(pb);          // unused, "desiredheight"

    avio_r8(pb);            // 'P' == progressive, 'I' == interlaced

    avio_skip(pb, 3);       // padding

    aspect = av_int2double(avio_rl64(pb));

    if (aspect > 0.9999 && aspect < 1.0001)

        aspect = 4.0 / 3.0;

    fps = av_int2double(avio_rl64(pb));



    // number of packets per stream type, -1 means unknown, e.g. streaming

    v_packs = avio_rl32(pb);

    a_packs = avio_rl32(pb);

    avio_rl32(pb); // text



    avio_rl32(pb); // keyframe distance (?)



    if (v_packs) {

        vst = avformat_new_stream(s, NULL);

        if (!vst)

            return AVERROR(ENOMEM);

        ctx->v_id = vst->index;



        vst->codec->codec_type            = AVMEDIA_TYPE_VIDEO;

        vst->codec->codec_id              = AV_CODEC_ID_NUV;

        vst->codec->width                 = width;

        vst->codec->height                = height;

        vst->codec->bits_per_coded_sample = 10;

        vst->sample_aspect_ratio          = av_d2q(aspect * height / width,

                                                   10000);

#if FF_API_R_FRAME_RATE

        vst->r_frame_rate =

#endif

        vst->avg_frame_rate = av_d2q(fps, 60000);

        avpriv_set_pts_info(vst, 32, 1, 1000);

    } else

        ctx->v_id = -1;



    if (a_packs) {

        ast = avformat_new_stream(s, NULL);

        if (!ast)

            return AVERROR(ENOMEM);

        ctx->a_id = ast->index;



        ast->codec->codec_type            = AVMEDIA_TYPE_AUDIO;

        ast->codec->codec_id              = AV_CODEC_ID_PCM_S16LE;

        ast->codec->channels              = 2;

        ast->codec->channel_layout        = AV_CH_LAYOUT_STEREO;

        ast->codec->sample_rate           = 44100;

        ast->codec->bit_rate              = 2 * 2 * 44100 * 8;

        ast->codec->block_align           = 2 * 2;

        ast->codec->bits_per_coded_sample = 16;

        avpriv_set_pts_info(ast, 32, 1, 1000);

    } else

        ctx->a_id = -1;



    get_codec_data(pb, vst, ast, is_mythtv);

    ctx->rtjpg_video = vst && vst->codec->codec_id == AV_CODEC_ID_NUV;



    return 0;

}

static int nuv_header(AVFormatContext *s)

{

    NUVContext *ctx = s->priv_data;

    AVIOContext *pb = s->pb;

    char id_string[12];

    double aspect, fps;

    int is_mythtv, width, height, v_packs, a_packs;

    AVStream *vst = NULL, *ast = NULL;



    avio_read(pb, id_string, 12);

    is_mythtv = !memcmp(id_string, "MythTVVideo", 12);

    avio_skip(pb, 5);       

    avio_skip(pb, 3);       

    width  = avio_rl32(pb);

    height = avio_rl32(pb);

    avio_rl32(pb);          

    avio_rl32(pb);          

    avio_r8(pb);            

    avio_skip(pb, 3);       

    aspect = av_int2double(avio_rl64(pb));

    if (aspect > 0.9999 && aspect < 1.0001)

        aspect = 4.0 / 3.0;

    fps = av_int2double(avio_rl64(pb));



    

    v_packs = avio_rl32(pb);

    a_packs = avio_rl32(pb);

    avio_rl32(pb); 



    avio_rl32(pb); 



    if (v_packs) {

        vst = avformat_new_stream(s, NULL);

        if (!vst)

            return AVERROR(ENOMEM);

        ctx->v_id = vst->index;



        vst->codec->codec_type            = AVMEDIA_TYPE_VIDEO;

        vst->codec->codec_id              = AV_CODEC_ID_NUV;

        vst->codec->width                 = width;

        vst->codec->height                = height;

        vst->codec->bits_per_coded_sample = 10;

        vst->sample_aspect_ratio          = av_d2q(aspect * height / width,

                                                   10000);

#if FF_API_R_FRAME_RATE

        vst->r_frame_rate =

#endif

        vst->avg_frame_rate = av_d2q(fps, 60000);

        avpriv_set_pts_info(vst, 32, 1, 1000);

    } else

        ctx->v_id = -1;



    if (a_packs) {

        ast = avformat_new_stream(s, NULL);

        if (!ast)

            return AVERROR(ENOMEM);

        ctx->a_id = ast->index;



        ast->codec->codec_type            = AVMEDIA_TYPE_AUDIO;

        ast->codec->codec_id              = AV_CODEC_ID_PCM_S16LE;

        ast->codec->channels              = 2;

        ast->codec->channel_layout        = AV_CH_LAYOUT_STEREO;

        ast->codec->sample_rate           = 44100;

        ast->codec->bit_rate              = 2 * 2 * 44100 * 8;

        ast->codec->block_align           = 2 * 2;

        ast->codec->bits_per_coded_sample = 16;

        avpriv_set_pts_info(ast, 32, 1, 1000);

    } else

        ctx->a_id = -1;



    get_codec_data(pb, vst, ast, is_mythtv);

    ctx->rtjpg_video = vst && vst->codec->codec_id == AV_CODEC_ID_NUV;



    return 0;

}

    int is_mythtv, width, height, v_packs, a_packs;     get_codec_data(pb, vst, ast, is_mythtv);
static int FUNC_0(AVFormatContext *VAR_0)

{

    NUVContext *ctx = VAR_0->priv_data;

    AVIOContext *pb = VAR_0->pb;

    char VAR_1[12];

    double VAR_2, VAR_3;

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;

    AVStream *vst = NULL, *ast = NULL;



    avio_read(pb, VAR_1, 12);

    VAR_4 = !memcmp(VAR_1, "MythTVVideo", 12);

    avio_skip(pb, 5);       

    avio_skip(pb, 3);       

    VAR_5  = avio_rl32(pb);

    VAR_6 = avio_rl32(pb);

    avio_rl32(pb);          

    avio_rl32(pb);          

    avio_r8(pb);            

    avio_skip(pb, 3);       

    VAR_2 = av_int2double(avio_rl64(pb));

    if (VAR_2 > 0.9999 && VAR_2 < 1.0001)

        VAR_2 = 4.0 / 3.0;

    VAR_3 = av_int2double(avio_rl64(pb));



    

    VAR_7 = avio_rl32(pb);

    VAR_8 = avio_rl32(pb);

    avio_rl32(pb); 



    avio_rl32(pb); 



    if (VAR_7) {

        vst = avformat_new_stream(VAR_0, NULL);

        if (!vst)

            return AVERROR(ENOMEM);

        ctx->v_id = vst->index;



        vst->codec->codec_type            = AVMEDIA_TYPE_VIDEO;

        vst->codec->codec_id              = AV_CODEC_ID_NUV;

        vst->codec->VAR_5                 = VAR_5;

        vst->codec->VAR_6                = VAR_6;

        vst->codec->bits_per_coded_sample = 10;

        vst->sample_aspect_ratio          = av_d2q(VAR_2 * VAR_6 / VAR_5,

                                                   10000);

#if FF_API_R_FRAME_RATE

        vst->r_frame_rate =

#endif

        vst->avg_frame_rate = av_d2q(VAR_3, 60000);

        avpriv_set_pts_info(vst, 32, 1, 1000);

    } else

        ctx->v_id = -1;



    if (VAR_8) {

        ast = avformat_new_stream(VAR_0, NULL);

        if (!ast)

            return AVERROR(ENOMEM);

        ctx->a_id = ast->index;



        ast->codec->codec_type            = AVMEDIA_TYPE_AUDIO;

        ast->codec->codec_id              = AV_CODEC_ID_PCM_S16LE;

        ast->codec->channels              = 2;

        ast->codec->channel_layout        = AV_CH_LAYOUT_STEREO;

        ast->codec->sample_rate           = 44100;

        ast->codec->bit_rate              = 2 * 2 * 44100 * 8;

        ast->codec->block_align           = 2 * 2;

        ast->codec->bits_per_coded_sample = 16;

        avpriv_set_pts_info(ast, 32, 1, 1000);

    } else

        ctx->a_id = -1;



    get_codec_data(pb, vst, ast, VAR_4);

    ctx->rtjpg_video = vst && vst->codec->codec_id == AV_CODEC_ID_NUV;



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ NUVContext *ctx = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; char VAR_1[12]; double VAR_2, VAR_3; int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8; AVStream *vst = NULL, *ast = NULL; avio_read(pb, VAR_1, 12); VAR_4 = !memcmp(VAR_1, "MythTVVideo", 12); avio_skip(pb, 5); avio_skip(pb, 3); VAR_5  = avio_rl32(pb); VAR_6 = avio_rl32(pb); avio_rl32(pb); avio_rl32(pb); avio_r8(pb); avio_skip(pb, 3); VAR_2 = av_int2double(avio_rl64(pb)); if (VAR_2 > 0.9999 && VAR_2 < 1.0001)
VAR_2 = 4.0 / 3.0; VAR_3 = av_int2double(avio_rl64(pb)); VAR_7 = avio_rl32(pb); VAR_8 = avio_rl32(pb); avio_rl32(pb); avio_rl32(pb); if (VAR_7) { vst = avformat_new_stream(VAR_0, NULL); if (!vst)
return AVERROR(ENOMEM); ctx->v_id = vst->index; vst->codec->codec_type            = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id              = AV_CODEC_ID_NUV; vst->codec->VAR_5                 = VAR_5; vst->codec->VAR_6                = VAR_6; vst->codec->bits_per_coded_sample = 10; vst->sample_aspect_ratio          = av_d2q(VAR_2 * VAR_6 / VAR_5,
10000); #if FF_API_R_FRAME_RATE
vst->r_frame_rate =
#endif
vst->avg_frame_rate = av_d2q(VAR_3, 60000); avpriv_set_pts_info(vst, 32, 1, 1000); } else ctx->v_id = -1; if (VAR_8) { ast = avformat_new_stream(VAR_0, NULL); if (!ast)
return AVERROR(ENOMEM); ctx->a_id = ast->index; ast->codec->codec_type            = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id              = AV_CODEC_ID_PCM_S16LE; ast->codec->channels              = 2; ast->codec->channel_layout        = AV_CH_LAYOUT_STEREO; ast->codec->sample_rate           = 44100; ast->codec->bit_rate              = 2 * 2 * 44100 * 8; ast->codec->block_align           = 2 * 2; ast->codec->bits_per_coded_sample = 16; avpriv_set_pts_info(ast, 32, 1, 1000); } else ctx->a_id = -1; get_codec_data(pb, vst, ast, VAR_4); ctx->rtjpg_video = vst && vst->codec->codec_id == AV_CODEC_ID_NUV; return 0; }