static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)

{

    int i;

    char header[MAX_FRAME_HEADER+1];

    int ret;

    int64_t off = avio_tell(s->pb);



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

        header[i] = avio_r8(s->pb);

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

            header[i + 1] = 0;

            break;

        }

    }

    if (s->pb->error)

        return s->pb->error;

    else if (s->pb->eof_reached)

        return AVERROR_EOF;

    else if (i == MAX_FRAME_HEADER)

        return AVERROR_INVALIDDATA;



    if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))

        return AVERROR_INVALIDDATA;



    ret = av_get_packet(s->pb, pkt, s->packet_size - Y4M_FRAME_MAGIC_LEN);

    if (ret < 0)

        return ret;

    else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)

        return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);



    pkt->stream_index = 0;

    pkt->pts = (off - s->internal->data_offset) / s->packet_size;

    pkt->duration = 1;

    return 0;

}

static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)

{

    int i;

    char header[MAX_FRAME_HEADER+1];

    int ret;

    int64_t off = avio_tell(s->pb);



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

        header[i] = avio_r8(s->pb);

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

            header[i + 1] = 0;

            break;

        }

    }

    if (s->pb->error)

        return s->pb->error;

    else if (s->pb->eof_reached)

        return AVERROR_EOF;

    else if (i == MAX_FRAME_HEADER)

        return AVERROR_INVALIDDATA;



    if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))

        return AVERROR_INVALIDDATA;



    ret = av_get_packet(s->pb, pkt, s->packet_size - Y4M_FRAME_MAGIC_LEN);

    if (ret < 0)

        return ret;

    else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)

        return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);



    pkt->stream_index = 0;

    pkt->pts = (off - s->internal->data_offset) / s->packet_size;

    pkt->duration = 1;

    return 0;

}

    else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)

{

    int VAR_2;

    char VAR_3[MAX_FRAME_HEADER+1];

    int VAR_4;

    int64_t off = avio_tell(VAR_0->pb);



    for (VAR_2 = 0; VAR_2 < MAX_FRAME_HEADER; VAR_2++) {

        VAR_3[VAR_2] = avio_r8(VAR_0->pb);

        if (VAR_3[VAR_2] == '\n') {

            VAR_3[VAR_2 + 1] = 0;

            break;

        }

    }

    if (VAR_0->pb->error)

        return VAR_0->pb->error;

    else if (VAR_0->pb->eof_reached)

        return AVERROR_EOF;

    else if (VAR_2 == MAX_FRAME_HEADER)

        return AVERROR_INVALIDDATA;



    if (strncmp(VAR_3, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))

        return AVERROR_INVALIDDATA;



    VAR_4 = av_get_packet(VAR_0->pb, VAR_1, VAR_0->packet_size - Y4M_FRAME_MAGIC_LEN);

    if (VAR_4 < 0)

        return VAR_4;

    else if (VAR_4 != VAR_0->packet_size - Y4M_FRAME_MAGIC_LEN)

        return VAR_0->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);



    VAR_1->stream_index = 0;

    VAR_1->pts = (off - VAR_0->internal->data_offset) / VAR_0->packet_size;

    VAR_1->duration = 1;

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ int VAR_2; char VAR_3[MAX_FRAME_HEADER+1]; int VAR_4; int64_t off = avio_tell(VAR_0->pb); for (VAR_2 = 0; VAR_2 < MAX_FRAME_HEADER; VAR_2++) { VAR_3[VAR_2] = avio_r8(VAR_0->pb); if (VAR_3[VAR_2] == '\n') { VAR_3[VAR_2 + 1] = 0; break; } } if (VAR_0->pb->error)
return VAR_0->pb->error; else if (VAR_0->pb->eof_reached)
return AVERROR_EOF; else if (VAR_2 == MAX_FRAME_HEADER)
return AVERROR_INVALIDDATA; if (strncmp(VAR_3, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
return AVERROR_INVALIDDATA; VAR_4 = av_get_packet(VAR_0->pb, VAR_1, VAR_0->packet_size - Y4M_FRAME_MAGIC_LEN); if (VAR_4 < 0)
return VAR_4; else if (VAR_4 != VAR_0->packet_size - Y4M_FRAME_MAGIC_LEN)
return VAR_0->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO); VAR_1->stream_index = 0; VAR_1->pts = (off - VAR_0->internal->data_offset) / VAR_0->packet_size; VAR_1->duration = 1; return 0; }