- track_type = get_byte(pb);
- track_id = get_byte(pb);
- 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.
+ track_type = avio_r8(pb);
+ track_id = avio_r8(pb);
+ stream_index = get_sindex(s, track_id, track_type);
+ if (stream_index < 0)
+ return stream_index;
+ st = s->streams[stream_index];
+ field_nr = avio_rb32(pb);
+ field_info = avio_rb32(pb);
+ avio_rb32(pb); // "timeline" field number
+ avio_r8(pb); // flags
+ avio_r8(pb); // reserved
+ if (st->codec->codec_id == AV_CODEC_ID_PCM_S24LE ||
+ st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
+ int first = field_info >> 16;
+ int last = field_info & 0xffff; // last is exclusive
+ int bps = av_get_bits_per_sample(st->codec->codec_id)>>3;
+ if (first <= last && last*bps <= pkt_len) {
+ avio_skip(pb, first*bps);
+ skip = pkt_len - last*bps;
+ pkt_len = (last-first)*bps;
+ } else
+ av_log(s, AV_LOG_ERROR, "invalid first and last sample values\n");
+ }