static int yuv4_read_header(AVFormatContext *s)

{

    char header[MAX_YUV4_HEADER + 10];  // Include headroom for

                                        // the longest option

    char *tokstart, *tokend, *header_end;

    int i;

    AVIOContext *pb = s->pb;

    int width = -1, height  = -1, raten   = 0,

        rated =  0, aspectn =  0, aspectd = 0;

    enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE, alt_pix_fmt = AV_PIX_FMT_NONE;

    enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED;

    AVStream *st;

    enum AVFieldOrder field_order;



    for (i = 0; i < MAX_YUV4_HEADER; i++) {

        header[i] = avio_r8(pb);

        if (header[i] == '\n') {

            header[i + 1] = 0x20;  // Add a space after last option.

                                   // Makes parsing "444" vs "444alpha" easier.

            header[i + 2] = 0;

            break;

        }

    }

    if (i == MAX_YUV4_HEADER)

        return -1;

    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC)))

        return -1;



    header_end = &header[i + 1]; // Include space

    for (tokstart = &header[strlen(Y4M_MAGIC) + 1];

         tokstart < header_end; tokstart++) {

        if (*tokstart == 0x20)

            continue;

        switch (*tokstart++) {

        case 'W': // Width. Required.

            width    = strtol(tokstart, &tokend, 10);

            tokstart = tokend;

            break;

        case 'H': // Height. Required.

            height   = strtol(tokstart, &tokend, 10);

            tokstart = tokend;

            break;

        case 'C': // Color space

            if (strncmp("420jpeg", tokstart, 7) == 0) {

                pix_fmt = AV_PIX_FMT_YUV420P;

                chroma_sample_location = AVCHROMA_LOC_CENTER;

            } else if (strncmp("420mpeg2", tokstart, 8) == 0) {

                pix_fmt = AV_PIX_FMT_YUV420P;

                chroma_sample_location = AVCHROMA_LOC_LEFT;

            } else if (strncmp("420paldv", tokstart, 8) == 0) {

                pix_fmt = AV_PIX_FMT_YUV420P;

                chroma_sample_location = AVCHROMA_LOC_TOPLEFT;

            } else if (strncmp("420", tokstart, 3) == 0) {

                pix_fmt = AV_PIX_FMT_YUV420P;

                chroma_sample_location = AVCHROMA_LOC_CENTER;

            } else if (strncmp("411", tokstart, 3) == 0)

                pix_fmt = AV_PIX_FMT_YUV411P;

            else if (strncmp("422", tokstart, 3) == 0)

                pix_fmt = AV_PIX_FMT_YUV422P;

            else if (strncmp("444alpha", tokstart, 8) == 0 ) {

                av_log(s, AV_LOG_ERROR, "Cannot handle 4:4:4:4 "

                       "YUV4MPEG stream.\n");

                return -1;

            } else if (strncmp("444", tokstart, 3) == 0)

                pix_fmt = AV_PIX_FMT_YUV444P;

            else if (strncmp("mono", tokstart, 4) == 0) {

                pix_fmt = AV_PIX_FMT_GRAY8;

            } else {

                av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown "

                       "pixel format.\n");

                return -1;

            }

            while (tokstart < header_end && *tokstart != 0x20)

                tokstart++;

            break;

        case 'I': // Interlace type

            switch (*tokstart++){

            case '?':

                field_order = AV_FIELD_UNKNOWN;

                break;

            case 'p':

                field_order = AV_FIELD_PROGRESSIVE;

                break;

            case 't':

                field_order = AV_FIELD_TT;

                break;

            case 'b':

                field_order = AV_FIELD_BB;

                break;

            case 'm':

                av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed "

                       "interlaced and non-interlaced frames.\n");

                return -1;

            default:

                av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");

                return -1;

            }

            break;

        case 'F': // Frame rate

            sscanf(tokstart, "%d:%d", &raten, &rated); // 0:0 if unknown

            while (tokstart < header_end && *tokstart != 0x20)

                tokstart++;

            break;

        case 'A': // Pixel aspect

            sscanf(tokstart, "%d:%d", &aspectn, &aspectd); // 0:0 if unknown

            while (tokstart < header_end && *tokstart != 0x20)

                tokstart++;

            break;

        case 'X': // Vendor extensions

            if (strncmp("YSCSS=", tokstart, 6) == 0) {

                // Older nonstandard pixel format representation

                tokstart += 6;

                if (strncmp("420JPEG", tokstart, 7) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV420P;

                else if (strncmp("420MPEG2", tokstart, 8) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV420P;

                else if (strncmp("420PALDV", tokstart, 8) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV420P;

                else if (strncmp("411", tokstart, 3) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV411P;

                else if (strncmp("422", tokstart, 3) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV422P;

                else if (strncmp("444", tokstart, 3) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV444P;

            }

            while (tokstart < header_end && *tokstart != 0x20)

                tokstart++;

            break;

        }

    }



    if (width == -1 || height == -1) {

        av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");

        return -1;

    }



    if (pix_fmt == AV_PIX_FMT_NONE) {

        if (alt_pix_fmt == AV_PIX_FMT_NONE)

            pix_fmt = AV_PIX_FMT_YUV420P;

        else

            pix_fmt = alt_pix_fmt;

    }



    if (raten <= 0 || rated <= 0) {

        // Frame rate unknown

        raten = 25;

        rated = 1;

    }



    if (aspectn == 0 && aspectd == 0) {

        // Pixel aspect unknown

        aspectd = 1;

    }



    st = avformat_new_stream(s, NULL);

    if (!st)

        return AVERROR(ENOMEM);

    st->codec->width  = width;

    st->codec->height = height;

    av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);

    avpriv_set_pts_info(st, 64, rated, raten);

    st->avg_frame_rate                = av_inv_q(st->time_base);

    st->codec->pix_fmt                = pix_fmt;

    st->codec->codec_type             = AVMEDIA_TYPE_VIDEO;

    st->codec->codec_id               = AV_CODEC_ID_RAWVIDEO;

    st->sample_aspect_ratio           = (AVRational){ aspectn, aspectd };

    st->codec->chroma_sample_location = chroma_sample_location;

    st->codec->field_order            = field_order;



    return 0;

}

static int yuv4_read_header(AVFormatContext *s)

{

    char header[MAX_YUV4_HEADER + 10];  

                                        

    char *tokstart, *tokend, *header_end;

    int i;

    AVIOContext *pb = s->pb;

    int width = -1, height  = -1, raten   = 0,

        rated =  0, aspectn =  0, aspectd = 0;

    enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE, alt_pix_fmt = AV_PIX_FMT_NONE;

    enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED;

    AVStream *st;

    enum AVFieldOrder field_order;



    for (i = 0; i < MAX_YUV4_HEADER; i++) {

        header[i] = avio_r8(pb);

        if (header[i] == '\n') {

            header[i + 1] = 0x20;  

                                   

            header[i + 2] = 0;

            break;

        }

    }

    if (i == MAX_YUV4_HEADER)

        return -1;

    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC)))

        return -1;



    header_end = &header[i + 1]; 

    for (tokstart = &header[strlen(Y4M_MAGIC) + 1];

         tokstart < header_end; tokstart++) {

        if (*tokstart == 0x20)

            continue;

        switch (*tokstart++) {

        case 'W': 

            width    = strtol(tokstart, &tokend, 10);

            tokstart = tokend;

            break;

        case 'H': 

            height   = strtol(tokstart, &tokend, 10);

            tokstart = tokend;

            break;

        case 'C': 

            if (strncmp("420jpeg", tokstart, 7) == 0) {

                pix_fmt = AV_PIX_FMT_YUV420P;

                chroma_sample_location = AVCHROMA_LOC_CENTER;

            } else if (strncmp("420mpeg2", tokstart, 8) == 0) {

                pix_fmt = AV_PIX_FMT_YUV420P;

                chroma_sample_location = AVCHROMA_LOC_LEFT;

            } else if (strncmp("420paldv", tokstart, 8) == 0) {

                pix_fmt = AV_PIX_FMT_YUV420P;

                chroma_sample_location = AVCHROMA_LOC_TOPLEFT;

            } else if (strncmp("420", tokstart, 3) == 0) {

                pix_fmt = AV_PIX_FMT_YUV420P;

                chroma_sample_location = AVCHROMA_LOC_CENTER;

            } else if (strncmp("411", tokstart, 3) == 0)

                pix_fmt = AV_PIX_FMT_YUV411P;

            else if (strncmp("422", tokstart, 3) == 0)

                pix_fmt = AV_PIX_FMT_YUV422P;

            else if (strncmp("444alpha", tokstart, 8) == 0 ) {

                av_log(s, AV_LOG_ERROR, "Cannot handle 4:4:4:4 "

                       "YUV4MPEG stream.\n");

                return -1;

            } else if (strncmp("444", tokstart, 3) == 0)

                pix_fmt = AV_PIX_FMT_YUV444P;

            else if (strncmp("mono", tokstart, 4) == 0) {

                pix_fmt = AV_PIX_FMT_GRAY8;

            } else {

                av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown "

                       "pixel format.\n");

                return -1;

            }

            while (tokstart < header_end && *tokstart != 0x20)

                tokstart++;

            break;

        case 'I': 

            switch (*tokstart++){

            case '?':

                field_order = AV_FIELD_UNKNOWN;

                break;

            case 'p':

                field_order = AV_FIELD_PROGRESSIVE;

                break;

            case 't':

                field_order = AV_FIELD_TT;

                break;

            case 'b':

                field_order = AV_FIELD_BB;

                break;

            case 'm':

                av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed "

                       "interlaced and non-interlaced frames.\n");

                return -1;

            default:

                av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");

                return -1;

            }

            break;

        case 'F': 

            sscanf(tokstart, "%d:%d", &raten, &rated); 

            while (tokstart < header_end && *tokstart != 0x20)

                tokstart++;

            break;

        case 'A': 

            sscanf(tokstart, "%d:%d", &aspectn, &aspectd); 

            while (tokstart < header_end && *tokstart != 0x20)

                tokstart++;

            break;

        case 'X': 

            if (strncmp("YSCSS=", tokstart, 6) == 0) {

                

                tokstart += 6;

                if (strncmp("420JPEG", tokstart, 7) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV420P;

                else if (strncmp("420MPEG2", tokstart, 8) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV420P;

                else if (strncmp("420PALDV", tokstart, 8) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV420P;

                else if (strncmp("411", tokstart, 3) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV411P;

                else if (strncmp("422", tokstart, 3) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV422P;

                else if (strncmp("444", tokstart, 3) == 0)

                    alt_pix_fmt = AV_PIX_FMT_YUV444P;

            }

            while (tokstart < header_end && *tokstart != 0x20)

                tokstart++;

            break;

        }

    }



    if (width == -1 || height == -1) {

        av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");

        return -1;

    }



    if (pix_fmt == AV_PIX_FMT_NONE) {

        if (alt_pix_fmt == AV_PIX_FMT_NONE)

            pix_fmt = AV_PIX_FMT_YUV420P;

        else

            pix_fmt = alt_pix_fmt;

    }



    if (raten <= 0 || rated <= 0) {

         unknown

        raten = 25;

        rated = 1;

    }



    if (aspectn == 0 && aspectd == 0) {

         unknown

        aspectd = 1;

    }



    st = avformat_new_stream(s, NULL);

    if (!st)

        return AVERROR(ENOMEM);

    st->codec->width  = width;

    st->codec->height = height;

    av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);

    avpriv_set_pts_info(st, 64, rated, raten);

    st->avg_frame_rate                = av_inv_q(st->time_base);

    st->codec->pix_fmt                = pix_fmt;

    st->codec->codec_type             = AVMEDIA_TYPE_VIDEO;

    st->codec->codec_id               = AV_CODEC_ID_RAWVIDEO;

    st->sample_aspect_ratio           = (AVRational){ aspectn, aspectd };

    st->codec->chroma_sample_location = chroma_sample_location;

    st->codec->field_order            = field_order;



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)

{

    char VAR_1[MAX_YUV4_HEADER + 10];  

                                        

    char *VAR_2, *VAR_3, *VAR_4;

    int VAR_5;

    AVIOContext *pb = VAR_0->pb;

    int VAR_6 = -1, VAR_7  = -1, VAR_8   = 0,

        VAR_9 =  0, VAR_10 =  0, VAR_11 = 0;

    enum AVPixelFormat VAR_12 = AV_PIX_FMT_NONE, VAR_13 = AV_PIX_FMT_NONE;

    enum AVChromaLocation VAR_14 = AVCHROMA_LOC_UNSPECIFIED;

    AVStream *st;

    enum AVFieldOrder VAR_15;



    for (VAR_5 = 0; VAR_5 < MAX_YUV4_HEADER; VAR_5++) {

        VAR_1[VAR_5] = avio_r8(pb);

        if (VAR_1[VAR_5] == '\n') {

            VAR_1[VAR_5 + 1] = 0x20;  

                                   

            VAR_1[VAR_5 + 2] = 0;

            break;

        }

    }

    if (VAR_5 == MAX_YUV4_HEADER)

        return -1;

    if (strncmp(VAR_1, Y4M_MAGIC, strlen(Y4M_MAGIC)))

        return -1;



    VAR_4 = &VAR_1[VAR_5 + 1]; 

    for (VAR_2 = &VAR_1[strlen(Y4M_MAGIC) + 1];

         VAR_2 < VAR_4; VAR_2++) {

        if (*VAR_2 == 0x20)

            continue;

        switch (*VAR_2++) {

        case 'W': 

            VAR_6    = strtol(VAR_2, &VAR_3, 10);

            VAR_2 = VAR_3;

            break;

        case 'H': 

            VAR_7   = strtol(VAR_2, &VAR_3, 10);

            VAR_2 = VAR_3;

            break;

        case 'C': 

            if (strncmp("420jpeg", VAR_2, 7) == 0) {

                VAR_12 = AV_PIX_FMT_YUV420P;

                VAR_14 = AVCHROMA_LOC_CENTER;

            } else if (strncmp("420mpeg2", VAR_2, 8) == 0) {

                VAR_12 = AV_PIX_FMT_YUV420P;

                VAR_14 = AVCHROMA_LOC_LEFT;

            } else if (strncmp("420paldv", VAR_2, 8) == 0) {

                VAR_12 = AV_PIX_FMT_YUV420P;

                VAR_14 = AVCHROMA_LOC_TOPLEFT;

            } else if (strncmp("420", VAR_2, 3) == 0) {

                VAR_12 = AV_PIX_FMT_YUV420P;

                VAR_14 = AVCHROMA_LOC_CENTER;

            } else if (strncmp("411", VAR_2, 3) == 0)

                VAR_12 = AV_PIX_FMT_YUV411P;

            else if (strncmp("422", VAR_2, 3) == 0)

                VAR_12 = AV_PIX_FMT_YUV422P;

            else if (strncmp("444alpha", VAR_2, 8) == 0 ) {

                av_log(VAR_0, AV_LOG_ERROR, "Cannot handle 4:4:4:4 "

                       "YUV4MPEG stream.\n");

                return -1;

            } else if (strncmp("444", VAR_2, 3) == 0)

                VAR_12 = AV_PIX_FMT_YUV444P;

            else if (strncmp("mono", VAR_2, 4) == 0) {

                VAR_12 = AV_PIX_FMT_GRAY8;

            } else {

                av_log(VAR_0, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown "

                       "pixel format.\n");

                return -1;

            }

            while (VAR_2 < VAR_4 && *VAR_2 != 0x20)

                VAR_2++;

            break;

        case 'I': 

            switch (*VAR_2++){

            case '?':

                VAR_15 = AV_FIELD_UNKNOWN;

                break;

            case 'p':

                VAR_15 = AV_FIELD_PROGRESSIVE;

                break;

            case 't':

                VAR_15 = AV_FIELD_TT;

                break;

            case 'b':

                VAR_15 = AV_FIELD_BB;

                break;

            case 'm':

                av_log(VAR_0, AV_LOG_ERROR, "YUV4MPEG stream contains mixed "

                       "interlaced and non-interlaced frames.\n");

                return -1;

            default:

                av_log(VAR_0, AV_LOG_ERROR, "YUV4MPEG has invalid VAR_1.\n");

                return -1;

            }

            break;

        case 'F': 

            sscanf(VAR_2, "%d:%d", &VAR_8, &VAR_9); 

            while (VAR_2 < VAR_4 && *VAR_2 != 0x20)

                VAR_2++;

            break;

        case 'A': 

            sscanf(VAR_2, "%d:%d", &VAR_10, &VAR_11); 

            while (VAR_2 < VAR_4 && *VAR_2 != 0x20)

                VAR_2++;

            break;

        case 'X': 

            if (strncmp("YSCSS=", VAR_2, 6) == 0) {

                

                VAR_2 += 6;

                if (strncmp("420JPEG", VAR_2, 7) == 0)

                    VAR_13 = AV_PIX_FMT_YUV420P;

                else if (strncmp("420MPEG2", VAR_2, 8) == 0)

                    VAR_13 = AV_PIX_FMT_YUV420P;

                else if (strncmp("420PALDV", VAR_2, 8) == 0)

                    VAR_13 = AV_PIX_FMT_YUV420P;

                else if (strncmp("411", VAR_2, 3) == 0)

                    VAR_13 = AV_PIX_FMT_YUV411P;

                else if (strncmp("422", VAR_2, 3) == 0)

                    VAR_13 = AV_PIX_FMT_YUV422P;

                else if (strncmp("444", VAR_2, 3) == 0)

                    VAR_13 = AV_PIX_FMT_YUV444P;

            }

            while (VAR_2 < VAR_4 && *VAR_2 != 0x20)

                VAR_2++;

            break;

        }

    }



    if (VAR_6 == -1 || VAR_7 == -1) {

        av_log(VAR_0, AV_LOG_ERROR, "YUV4MPEG has invalid VAR_1.\n");

        return -1;

    }



    if (VAR_12 == AV_PIX_FMT_NONE) {

        if (VAR_13 == AV_PIX_FMT_NONE)

            VAR_12 = AV_PIX_FMT_YUV420P;

        else

            VAR_12 = VAR_13;

    }



    if (VAR_8 <= 0 || VAR_9 <= 0) {

         unknown

        VAR_8 = 25;

        VAR_9 = 1;

    }



    if (VAR_10 == 0 && VAR_11 == 0) {

         unknown

        VAR_11 = 1;

    }



    st = avformat_new_stream(VAR_0, NULL);

    if (!st)

        return AVERROR(ENOMEM);

    st->codec->VAR_6  = VAR_6;

    st->codec->VAR_7 = VAR_7;

    av_reduce(&VAR_8, &VAR_9, VAR_8, VAR_9, (1UL << 31) - 1);

    avpriv_set_pts_info(st, 64, VAR_9, VAR_8);

    st->avg_frame_rate                = av_inv_q(st->time_base);

    st->codec->VAR_12                = VAR_12;

    st->codec->codec_type             = AVMEDIA_TYPE_VIDEO;

    st->codec->codec_id               = AV_CODEC_ID_RAWVIDEO;

    st->sample_aspect_ratio           = (AVRational){ VAR_10, VAR_11 };

    st->codec->VAR_14 = VAR_14;

    st->codec->VAR_15            = VAR_15;



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ char VAR_1[MAX_YUV4_HEADER + 10]; char *VAR_2, *VAR_3, *VAR_4; int VAR_5; AVIOContext *pb = VAR_0->pb; int VAR_6 = -1, VAR_7  = -1, VAR_8   = 0,
VAR_9 =  0, VAR_10 =  0, VAR_11 = 0; enum AVPixelFormat VAR_12 = AV_PIX_FMT_NONE, VAR_13 = AV_PIX_FMT_NONE; enum AVChromaLocation VAR_14 = AVCHROMA_LOC_UNSPECIFIED; AVStream *st; enum AVFieldOrder VAR_15; for (VAR_5 = 0; VAR_5 < MAX_YUV4_HEADER; VAR_5++) { VAR_1[VAR_5] = avio_r8(pb); if (VAR_1[VAR_5] == '\n') { VAR_1[VAR_5 + 1] = 0x20; VAR_1[VAR_5 + 2] = 0; break; } } if (VAR_5 == MAX_YUV4_HEADER)
return -1; if (strncmp(VAR_1, Y4M_MAGIC, strlen(Y4M_MAGIC)))
return -1; VAR_4 = &VAR_1[VAR_5 + 1]; for (VAR_2 = &VAR_1[strlen(Y4M_MAGIC) + 1]; VAR_2 < VAR_4; VAR_2++) { if (*VAR_2 == 0x20)
continue; switch (*VAR_2++) { case 'W':
VAR_6    = strtol(VAR_2, &VAR_3, 10); VAR_2 = VAR_3; break; case 'H':
VAR_7   = strtol(VAR_2, &VAR_3, 10); VAR_2 = VAR_3; break; case 'C':
if (strncmp("420jpeg", VAR_2, 7) == 0) { VAR_12 = AV_PIX_FMT_YUV420P; VAR_14 = AVCHROMA_LOC_CENTER; } else if (strncmp("420mpeg2", VAR_2, 8) == 0) { VAR_12 = AV_PIX_FMT_YUV420P; VAR_14 = AVCHROMA_LOC_LEFT; } else if (strncmp("420paldv", VAR_2, 8) == 0) { VAR_12 = AV_PIX_FMT_YUV420P; VAR_14 = AVCHROMA_LOC_TOPLEFT; } else if (strncmp("420", VAR_2, 3) == 0) { VAR_12 = AV_PIX_FMT_YUV420P; VAR_14 = AVCHROMA_LOC_CENTER; } else if (strncmp("411", VAR_2, 3) == 0) VAR_12 = AV_PIX_FMT_YUV411P; else if (strncmp("422", VAR_2, 3) == 0)
VAR_12 = AV_PIX_FMT_YUV422P; else if (strncmp("444alpha", VAR_2, 8) == 0 ) { av_log(VAR_0, AV_LOG_ERROR, "Cannot handle 4:4:4:4 "
"YUV4MPEG stream.\n"); return -1; } else if (strncmp("444", VAR_2, 3) == 0) VAR_12 = AV_PIX_FMT_YUV444P; else if (strncmp("mono", VAR_2, 4) == 0) { VAR_12 = AV_PIX_FMT_GRAY8; } else { av_log(VAR_0, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown "
"pixel format.\n"); return -1; } while (VAR_2 < VAR_4 && *VAR_2 != 0x20)
VAR_2++; break; case 'I':
switch (*VAR_2++){ case '?':
VAR_15 = AV_FIELD_UNKNOWN; break; case 'p':
VAR_15 = AV_FIELD_PROGRESSIVE; break; case 't':
VAR_15 = AV_FIELD_TT; break; case 'b':
VAR_15 = AV_FIELD_BB; break; case 'm':
av_log(VAR_0, AV_LOG_ERROR, "YUV4MPEG stream contains mixed "
"interlaced and non-interlaced frames.\n"); return -1; default:
av_log(VAR_0, AV_LOG_ERROR, "YUV4MPEG has invalid VAR_1.\n"); return -1; } break; case 'F':
sscanf(VAR_2, "%d:%d", &VAR_8, &VAR_9); while (VAR_2 < VAR_4 && *VAR_2 != 0x20)
VAR_2++; break; case 'A':
sscanf(VAR_2, "%d:%d", &VAR_10, &VAR_11); while (VAR_2 < VAR_4 && *VAR_2 != 0x20)
VAR_2++; break; case 'X':
if (strncmp("YSCSS=", VAR_2, 6) == 0) { VAR_2 += 6; if (strncmp("420JPEG", VAR_2, 7) == 0)
VAR_13 = AV_PIX_FMT_YUV420P; else if (strncmp("420MPEG2", VAR_2, 8) == 0)
VAR_13 = AV_PIX_FMT_YUV420P; else if (strncmp("420PALDV", VAR_2, 8) == 0)
VAR_13 = AV_PIX_FMT_YUV420P; else if (strncmp("411", VAR_2, 3) == 0)
VAR_13 = AV_PIX_FMT_YUV411P; else if (strncmp("422", VAR_2, 3) == 0)
VAR_13 = AV_PIX_FMT_YUV422P; else if (strncmp("444", VAR_2, 3) == 0)
VAR_13 = AV_PIX_FMT_YUV444P; } while (VAR_2 < VAR_4 && *VAR_2 != 0x20)
VAR_2++; break; } } if (VAR_6 == -1 || VAR_7 == -1) { av_log(VAR_0, AV_LOG_ERROR, "YUV4MPEG has invalid VAR_1.\n"); return -1; } if (VAR_12 == AV_PIX_FMT_NONE) { if (VAR_13 == AV_PIX_FMT_NONE)
VAR_12 = AV_PIX_FMT_YUV420P; else
VAR_12 = VAR_13; } if (VAR_8 <= 0 || VAR_9 <= 0) { unknown
VAR_8 = 25; VAR_9 = 1; } if (VAR_10 == 0 && VAR_11 == 0) { unknown
VAR_11 = 1; } st = avformat_new_stream(VAR_0, NULL); if (!st)
return AVERROR(ENOMEM); st->codec->VAR_6  = VAR_6; st->codec->VAR_7 = VAR_7; av_reduce(&VAR_8, &VAR_9, VAR_8, VAR_9, (1UL << 31) - 1); avpriv_set_pts_info(st, 64, VAR_9, VAR_8); st->avg_frame_rate                = av_inv_q(st->time_base); st->codec->VAR_12                = VAR_12; st->codec->codec_type             = AVMEDIA_TYPE_VIDEO; st->codec->codec_id               = AV_CODEC_ID_RAWVIDEO; st->sample_aspect_ratio           = (AVRational){ VAR_10, VAR_11 }; st->codec->VAR_14 = VAR_14; st->codec->VAR_15            = VAR_15; return 0; }