aboutsummaryrefslogtreecommitdiff
path: root/libavformat/nut.c
diff options
context:
space:
mode:
authorMichael Niedermayer2005-01-22 13:36:02 +0000
committerMichael Niedermayer2005-01-22 13:36:02 +0000
commitb9866ebcc7d9891fb6b07cab70319fe1742a100a (patch)
tree3e74ec233cd2ef881ee097956e7a8ca3e6b215cf /libavformat/nut.c
parente19456e3ee263ae1c46b623c8394394710721ff4 (diff)
support discarding uninterresting packets
Originally committed as revision 3860 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/nut.c')
-rw-r--r--libavformat/nut.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libavformat/nut.c b/libavformat/nut.c
index 010e09c3bf..46fbee8aee 100644
--- a/libavformat/nut.c
+++ b/libavformat/nut.c
@@ -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);