static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {

    ByteIOContext *pb = s->pb;

    pkt_type_t pkt_type;

    int pkt_len;

    while (!url_feof(pb)) {

        int track_type, track_id, ret;

        int field_nr;

        int stream_index;

        if (!parse_packet_header(pb, &pkt_type, &pkt_len)) {

            if (!url_feof(pb))

                av_log(s, AV_LOG_ERROR, "GXF: sync lost\n");

            return -1;

        }

        if (pkt_type == PKT_FLT) {

            gxf_read_index(s, pkt_len);

            continue;

        }

        if (pkt_type != PKT_MEDIA) {

            url_fskip(pb, pkt_len);

            continue;

        }

        if (pkt_len < 16) {

            av_log(s, AV_LOG_ERROR, "GXF: invalid media packet length\n");

            continue;

        }

        pkt_len -= 16;

        track_type = get_byte(pb);

        track_id = get_byte(pb);

        stream_index = get_sindex(s, track_id, track_type);

        if (stream_index < 0)

            return stream_index;

        field_nr = get_be32(pb);

        get_be32(pb); // field information

        get_be32(pb); // "timeline" field number

        get_byte(pb); // flags

        get_byte(pb); // reserved

        // NOTE: there is also data length information in the

        // field information, it might be better to take this into account

        // as well.

        ret = av_get_packet(pb, pkt, pkt_len);

        pkt->stream_index = stream_index;

        pkt->dts = field_nr;

        return ret;

    }

    return AVERROR(EIO);

}

static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {

    ByteIOContext *pb = s->pb;

    pkt_type_t pkt_type;

    int pkt_len;

    while (!url_feof(pb)) {

        int track_type, track_id, ret;

        int field_nr;

        int stream_index;

        if (!parse_packet_header(pb, &pkt_type, &pkt_len)) {

            if (!url_feof(pb))

                av_log(s, AV_LOG_ERROR, "GXF: sync lost\n");

            return -1;

        }

        if (pkt_type == PKT_FLT) {

            gxf_read_index(s, pkt_len);

            continue;

        }

        if (pkt_type != PKT_MEDIA) {

            url_fskip(pb, pkt_len);

            continue;

        }

        if (pkt_len < 16) {

            av_log(s, AV_LOG_ERROR, "GXF: invalid media packet length\n");

            continue;

        }

        pkt_len -= 16;

        track_type = get_byte(pb);

        track_id = get_byte(pb);

        stream_index = get_sindex(s, track_id, track_type);

        if (stream_index < 0)

            return stream_index;

        field_nr = get_be32(pb);

        get_be32(pb); 

        get_be32(pb); 

        get_byte(pb); 

        get_byte(pb); 

        

        , it might be better to take this into account

        

        ret = av_get_packet(pb, pkt, pkt_len);

        pkt->stream_index = stream_index;

        pkt->dts = field_nr;

        return ret;

    }

    return AVERROR(EIO);

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) {

    ByteIOContext *pb = VAR_0->pb;

    pkt_type_t pkt_type;

    int VAR_2;

    while (!url_feof(pb)) {

        int VAR_3, VAR_4, VAR_5;

        int VAR_6;

        int VAR_7;

        if (!parse_packet_header(pb, &pkt_type, &VAR_2)) {

            if (!url_feof(pb))

                av_log(VAR_0, AV_LOG_ERROR, "GXF: sync lost\n");

            return -1;

        }

        if (pkt_type == PKT_FLT) {

            gxf_read_index(VAR_0, VAR_2);

            continue;

        }

        if (pkt_type != PKT_MEDIA) {

            url_fskip(pb, VAR_2);

            continue;

        }

        if (VAR_2 < 16) {

            av_log(VAR_0, AV_LOG_ERROR, "GXF: invalid media packet length\n");

            continue;

        }

        VAR_2 -= 16;

        VAR_3 = get_byte(pb);

        VAR_4 = get_byte(pb);

        VAR_7 = get_sindex(VAR_0, VAR_4, VAR_3);

        if (VAR_7 < 0)

            return VAR_7;

        VAR_6 = get_be32(pb);

        get_be32(pb); 

        get_be32(pb); 

        get_byte(pb); 

        get_byte(pb); 

        

        , it might be better to take this into account

        

        VAR_5 = av_get_packet(pb, VAR_1, VAR_2);

        VAR_1->VAR_7 = VAR_7;

        VAR_1->dts = VAR_6;

        return VAR_5;

    }

    return AVERROR(EIO);

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { ByteIOContext *pb = VAR_0->pb; pkt_type_t pkt_type; int VAR_2; while (!url_feof(pb)) { int VAR_3, VAR_4, VAR_5; int VAR_6; int VAR_7; if (!parse_packet_header(pb, &pkt_type, &VAR_2)) { if (!url_feof(pb))
av_log(VAR_0, AV_LOG_ERROR, "GXF: sync lost\n"); return -1; } if (pkt_type == PKT_FLT) { gxf_read_index(VAR_0, VAR_2); continue; } if (pkt_type != PKT_MEDIA) { url_fskip(pb, VAR_2); continue; } if (VAR_2 < 16) { av_log(VAR_0, AV_LOG_ERROR, "GXF: invalid media packet length\n"); continue; } VAR_2 -= 16; VAR_3 = get_byte(pb); VAR_4 = get_byte(pb); VAR_7 = get_sindex(VAR_0, VAR_4, VAR_3); if (VAR_7 < 0)
return VAR_7; VAR_6 = get_be32(pb); get_be32(pb); get_be32(pb); get_byte(pb); get_byte(pb); , it might be better to take this into account
VAR_5 = av_get_packet(pb, VAR_1, VAR_2); VAR_1->VAR_7 = VAR_7; VAR_1->dts = VAR_6; return VAR_5; } return AVERROR(EIO); }