support discarding uninterresting packets
Originally committed as revision 3860 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
e19456e3ee
commit
b9866ebcc7
@ -545,12 +545,13 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
asf->packet_size_left -= rsize;
|
||||
//printf("___objsize____ %d %d rs:%d\n", asf->packet_obj_size, asf->packet_frag_offset, rsize);
|
||||
|
||||
if (asf->stream_index < 0) {
|
||||
if (asf->stream_index < 0 || s->streams[asf->stream_index]->discard) {
|
||||
asf->packet_time_start = 0;
|
||||
/* unhandled packet (should not happen) */
|
||||
url_fskip(pb, asf->packet_frag_size);
|
||||
asf->packet_size_left -= asf->packet_frag_size;
|
||||
av_log(s, AV_LOG_ERROR, "ff asf skip %d %d\n", asf->packet_frag_size, num & 0x7f);
|
||||
if(asf->stream_index < 0)
|
||||
av_log(s, AV_LOG_ERROR, "ff asf skip %d %d\n", asf->packet_frag_size, num & 0x7f);
|
||||
continue;
|
||||
}
|
||||
asf->asf_st = s->streams[asf->stream_index]->priv_data;
|
||||
|
@ -106,6 +106,10 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
st->codec.frame_rate_base= 1;
|
||||
st->codec.frame_rate= 1000;
|
||||
}
|
||||
if(st->discard){
|
||||
url_fskip(&s->pb, size);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2364,6 +2364,10 @@ matroska_parse_blockgroup (MatroskaDemuxContext *matroska,
|
||||
av_free(origdata);
|
||||
break;
|
||||
}
|
||||
if(matroska->ctx->streams[ matroska->tracks[track]->stream_index ]->discard){
|
||||
av_free(origdata);
|
||||
break;
|
||||
}
|
||||
|
||||
/* time (relative to cluster time) */
|
||||
time = ((data[0] << 8) | data[1]) * matroska->time_scale;
|
||||
|
@ -1766,7 +1766,7 @@ again:
|
||||
}
|
||||
|
||||
//av_log(NULL, AV_LOG_DEBUG, "chunk: [%i] %lli -> %lli\n", st_id, mov->next_chunk_offset, offset);
|
||||
if(!sc->is_ff_stream) {
|
||||
if(!sc->is_ff_stream || s->streams[sc->ffindex]->discard) {
|
||||
url_fskip(&s->pb, (offset - mov->next_chunk_offset));
|
||||
mov->next_chunk_offset = offset;
|
||||
offset = 0x0FFFFFFFFFFFFFFFLL;
|
||||
|
@ -1533,6 +1533,8 @@ static int mpegps_read_packet(AVFormatContext *s,
|
||||
if (codec_id != CODEC_ID_PCM_S16BE)
|
||||
st->need_parsing = 1;
|
||||
found:
|
||||
if(st->discard)
|
||||
goto skip;
|
||||
if (startcode >= 0xa0 && startcode <= 0xbf) {
|
||||
int b1, freq;
|
||||
|
||||
@ -1555,8 +1557,8 @@ static int mpegps_read_packet(AVFormatContext *s,
|
||||
pkt->dts = dts;
|
||||
pkt->stream_index = st->index;
|
||||
#if 0
|
||||
av_log(s, AV_LOG_DEBUG, "%d: pts=%0.3f dts=%0.3f\n",
|
||||
pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0);
|
||||
av_log(s, AV_LOG_DEBUG, "%d: pts=%0.3f dts=%0.3f size=%d\n",
|
||||
pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0, pkt->size);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -1229,6 +1229,11 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code, int fram
|
||||
if(size < 0)
|
||||
return -1;
|
||||
|
||||
if(s->streams[ stream_id ]->discard){
|
||||
url_fskip(bc, size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
av_new_packet(pkt, size);
|
||||
get_buffer(bc, pkt->data, size);
|
||||
pkt->stream_index = stream_id;
|
||||
@ -1243,7 +1248,7 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
NUTContext *nut = s->priv_data;
|
||||
ByteIOContext *bc = &s->pb;
|
||||
int i, frame_code=0;
|
||||
int i, frame_code=0, ret;
|
||||
|
||||
for(;;){
|
||||
int64_t pos= url_ftell(bc);
|
||||
@ -1281,8 +1286,11 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
reset(s, get_v(bc));
|
||||
frame_code = get_byte(bc);
|
||||
case 0:
|
||||
if(decode_frame(nut, pkt, frame_code, frame_type, pos)>=0)
|
||||
ret= decode_frame(nut, pkt, frame_code, frame_type, pos);
|
||||
if(ret==0)
|
||||
return 0;
|
||||
else if(ret==1) //ok but discard packet
|
||||
break;
|
||||
default:
|
||||
resync:
|
||||
av_log(s, AV_LOG_DEBUG, "syncing from %lld\n", nut->packet_start[2]+1);
|
||||
|
@ -811,7 +811,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
st = s->streams[0];
|
||||
} else {
|
||||
int seq=1;
|
||||
|
||||
resync:
|
||||
len=sync(s, ×tamp, &flags, &i, &pos);
|
||||
if(len<0)
|
||||
return AVERROR_IO;
|
||||
@ -841,6 +841,11 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
len=len2;
|
||||
rm->remaining_len-= len;
|
||||
}
|
||||
|
||||
if(st->discard){
|
||||
url_fskip(pb, len);
|
||||
goto resync;
|
||||
}
|
||||
|
||||
av_new_packet(pkt, len);
|
||||
pkt->stream_index = i;
|
||||
|
@ -821,7 +821,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
|
||||
compute_pkt_fields(s, st, NULL, pkt);
|
||||
s->cur_st = NULL;
|
||||
return 0;
|
||||
} else if (s->cur_len > 0) {
|
||||
} else if (s->cur_len > 0 && !st->discard) {
|
||||
len = av_parser_parse(st->parser, &st->codec, &pkt->data, &pkt->size,
|
||||
s->cur_ptr, s->cur_len,
|
||||
s->cur_pkt.pts, s->cur_pkt.dts);
|
||||
|
Loading…
Reference in New Issue
Block a user