diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-12-06 18:57:59 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-12-06 18:57:59 +0000 |
commit | a8b81ec199c047c7534eafb22cdfdcfdf650f319 (patch) | |
tree | 9b06f724c3374ea55afc01328a0691984be96b10 /libavformat/rm.c | |
parent | 18ade9543fe07620ad429747a6f1266b09627c18 (diff) | |
download | ffmpeg-a8b81ec199c047c7534eafb22cdfdcfdf650f319.tar.gz |
various demuxer fixes
Originally committed as revision 3734 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rm.c')
-rw-r--r-- | libavformat/rm.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/libavformat/rm.c b/libavformat/rm.c index ba73a337bd..462b0bd7f5 100644 --- a/libavformat/rm.c +++ b/libavformat/rm.c @@ -40,6 +40,8 @@ typedef struct { int data_pos; /* position of the data after the header */ int nb_packets; int old_format; + int current_stream; + int remaining_len; } RMContext; #ifdef CONFIG_ENCODERS @@ -723,7 +725,8 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) RMContext *rm = s->priv_data; ByteIOContext *pb = &s->pb; AVStream *st; - int len, num, timestamp, i, tmp, j; + int num, i, len, tmp, j; + int64_t timestamp; uint8_t *ptr; int flags, res; @@ -741,6 +744,12 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) st = s->streams[0]; } else { redo: + if(rm->remaining_len){ + num= rm->current_stream; + len= rm->remaining_len; + timestamp = AV_NOPTS_VALUE; + flags= 0; + }else{ if (rm->nb_packets == 0) return AVERROR_IO; get_be16(pb); @@ -756,6 +765,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) rm->nb_packets--; len -= 12; + } st = NULL; for(i=0;i<s->nb_streams;i++) { @@ -770,28 +780,29 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) } if (st->codec.codec_type == CODEC_TYPE_VIDEO) { - int full_frame, h, pic_num; - - h= get_byte(pb); - if ((h & 0xc0) == 0xc0) { - int len2, pos; - full_frame = 1; - len2= get_num(pb, &len); - pos = get_num(pb, &len); - //printf("pos:%d\n",len); - len -= 2; - } else { - int seq, frame_size, pos; - full_frame = 0; - seq = get_byte(pb); - frame_size = get_num(pb, &len); + int h, pic_num, len2, pos; + + h= get_byte(pb); len--; + if(!(h & 0x40)){ + int seq = get_byte(pb); + len--; + } + + if((h & 0xc0) == 0x40){ + len2= pos= 0; + }else{ + len2 = get_num(pb, &len); pos = get_num(pb, &len); - //printf("seq:%d, size:%d, pos:%d\n",seq,frame_size,pos); - len -= 3; } /* picture number */ - pic_num= get_byte(pb); -// av_log(NULL, AV_LOG_DEBUG, "%X %d\n", h, pic_num); + pic_num= get_byte(pb); len--; + rm->remaining_len= len; + rm->current_stream= st->id; + +// av_log(NULL, AV_LOG_DEBUG, "%X len:%d pos:%d len2:%d pic_num:%d\n",h, len, pos, len2, pic_num); + if(len2 && len2<len) + len=len2; + rm->remaining_len-= len; } av_new_packet(pkt, len); |