Originally committed as revision 3737 to svn://svn.ffmpeg.org/ffmpeg/trunk
Michael Niedermayer authored on 2004/12/07 07:44:03... | ... |
@@ -400,20 +400,28 @@ static int rv20_decode_picture_header(MpegEncContext *s) |
400 | 400 |
} |
401 | 401 |
|
402 | 402 |
if(s->avctx->has_b_frames){ |
403 |
+ int f1=9; |
|
404 |
+ int f2=9; |
|
405 |
+ int f3=9; |
|
406 |
+ |
|
403 | 407 |
if (get_bits(&s->gb, 1)){ |
404 |
-// av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n"); |
|
408 |
+ av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n"); |
|
405 | 409 |
// return -1; |
406 | 410 |
} |
407 | 411 |
seq= get_bits(&s->gb, 14)<<1; |
408 | 412 |
|
409 | 413 |
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&1){ |
410 |
- get_bits(&s->gb, 1); |
|
414 |
+ f1= get_bits(&s->gb, 1); |
|
411 | 415 |
} |
412 | 416 |
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&2){ |
413 |
- get_bits(&s->gb, 1); |
|
417 |
+ f2= get_bits(&s->gb, 1); |
|
414 | 418 |
} |
415 | 419 |
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&4){ |
416 |
- get_bits(&s->gb, 2); |
|
420 |
+ f3= get_bits(&s->gb, 2); |
|
421 |
+ } |
|
422 |
+ |
|
423 |
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO){ |
|
424 |
+ av_log(s->avctx, AV_LOG_DEBUG, "F %d %d %d\n", f1,f2,f3); |
|
417 | 425 |
} |
418 | 426 |
|
419 | 427 |
mb_pos= get_bits(&s->gb, av_log2(s->mb_num-1)+1); |
... | ... |
@@ -733,6 +741,7 @@ AVCodec rv20_decoder = { |
733 | 733 |
NULL, |
734 | 734 |
rv10_decode_end, |
735 | 735 |
rv10_decode_frame, |
736 |
- CODEC_CAP_DR1 |
|
736 |
+ CODEC_CAP_DR1, |
|
737 |
+ .flush= ff_mpeg_flush, |
|
737 | 738 |
}; |
738 | 739 |
|
... | ... |
@@ -720,15 +720,62 @@ static int get_num(ByteIOContext *pb, int *len) |
720 | 720 |
/* multiple of 20 bytes for ra144 (ugly) */ |
721 | 721 |
#define RAW_PACKET_SIZE 1000 |
722 | 722 |
|
723 |
+static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index){ |
|
724 |
+ RMContext *rm = s->priv_data; |
|
725 |
+ ByteIOContext *pb = &s->pb; |
|
726 |
+ int len, num, res, i; |
|
727 |
+ AVStream *st; |
|
728 |
+ |
|
729 |
+ while(!url_feof(pb)){ |
|
730 |
+ if(rm->remaining_len > 0){ |
|
731 |
+ num= rm->current_stream; |
|
732 |
+ len= rm->remaining_len; |
|
733 |
+ *timestamp = AV_NOPTS_VALUE; |
|
734 |
+ *flags= 0; |
|
735 |
+ }else{ |
|
736 |
+ if(get_byte(pb)) |
|
737 |
+ continue; |
|
738 |
+ if(get_byte(pb)) |
|
739 |
+ continue; |
|
740 |
+ len = get_be16(pb); |
|
741 |
+ if (len < 12) |
|
742 |
+ continue; |
|
743 |
+ num = get_be16(pb); |
|
744 |
+ *timestamp = get_be32(pb); |
|
745 |
+ res= get_byte(pb); /* reserved */ |
|
746 |
+ *flags = get_byte(pb); /* flags */ |
|
747 |
+ |
|
748 |
+// av_log(s, AV_LOG_DEBUG, "%d %Ld %X %X\n", num, *timestamp, *flags, res); |
|
749 |
+ |
|
750 |
+ len -= 12; |
|
751 |
+ } |
|
752 |
+ for(i=0;i<s->nb_streams;i++) { |
|
753 |
+ st = s->streams[i]; |
|
754 |
+ if (num == st->id) |
|
755 |
+ break; |
|
756 |
+ } |
|
757 |
+ if (i == s->nb_streams) { |
|
758 |
+ /* skip packet if unknown number */ |
|
759 |
+ url_fskip(pb, len); |
|
760 |
+ rm->remaining_len -= len; |
|
761 |
+ continue; |
|
762 |
+ } |
|
763 |
+ *stream_index= i; |
|
764 |
+ |
|
765 |
+ return len; |
|
766 |
+ } |
|
767 |
+ return -1; |
|
768 |
+} |
|
769 |
+ |
|
723 | 770 |
static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) |
724 | 771 |
{ |
725 | 772 |
RMContext *rm = s->priv_data; |
726 | 773 |
ByteIOContext *pb = &s->pb; |
727 | 774 |
AVStream *st; |
728 |
- int num, i, len, tmp, j; |
|
775 |
+ int i, len, tmp, j; |
|
729 | 776 |
int64_t timestamp; |
730 | 777 |
uint8_t *ptr; |
731 |
- int flags, res; |
|
778 |
+ int flags; |
|
732 | 779 |
|
733 | 780 |
if (rm->old_format) { |
734 | 781 |
/* just read raw bytes */ |
... | ... |
@@ -743,44 +790,11 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) |
743 | 743 |
pkt->size = len; |
744 | 744 |
st = s->streams[0]; |
745 | 745 |
} else { |
746 |
- redo: |
|
747 |
- if (url_feof(pb)) |
|
746 |
+ len=sync(s, ×tamp, &flags, &i); |
|
747 |
+ if(len<0) |
|
748 | 748 |
return AVERROR_IO; |
749 |
- if(rm->remaining_len > 0){ |
|
750 |
- num= rm->current_stream; |
|
751 |
- len= rm->remaining_len; |
|
752 |
- timestamp = AV_NOPTS_VALUE; |
|
753 |
- flags= 0; |
|
754 |
- }else{ |
|
755 |
- if(get_byte(pb)) |
|
756 |
- goto redo; |
|
757 |
- if(get_byte(pb)) |
|
758 |
- goto redo; |
|
759 |
- len = get_be16(pb); |
|
760 |
- if (len < 12) |
|
761 |
- goto redo; |
|
762 |
- num = get_be16(pb); |
|
763 |
- timestamp = get_be32(pb); |
|
764 |
- res= get_byte(pb); /* reserved */ |
|
765 |
- flags = get_byte(pb); /* flags */ |
|
766 |
- |
|
767 |
-// av_log(s, AV_LOG_DEBUG, "%d %d %X %d\n", num, timestamp, flags, res); |
|
768 |
- |
|
769 |
- len -= 12; |
|
770 |
- } |
|
771 |
- |
|
772 |
- st = NULL; |
|
773 |
- for(i=0;i<s->nb_streams;i++) { |
|
774 |
- st = s->streams[i]; |
|
775 |
- if (num == st->id) |
|
776 |
- break; |
|
777 |
- } |
|
778 |
- if (i == s->nb_streams) { |
|
779 |
- /* skip packet if unknown number */ |
|
780 |
- url_fskip(pb, len); |
|
781 |
- goto redo; |
|
782 |
- } |
|
783 |
- |
|
749 |
+ st = s->streams[i]; |
|
750 |
+ |
|
784 | 751 |
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { |
785 | 752 |
int h, pic_num, len2, pos; |
786 | 753 |
|
... | ... |
@@ -861,6 +875,39 @@ static int rm_probe(AVProbeData *p) |
861 | 861 |
return 0; |
862 | 862 |
} |
863 | 863 |
|
864 |
+static int64_t rm_read_dts(AVFormatContext *s, int stream_index, |
|
865 |
+ int64_t *ppos, int64_t pos_limit) |
|
866 |
+{ |
|
867 |
+ RMContext *rm = s->priv_data; |
|
868 |
+ int64_t pos, dts; |
|
869 |
+ int stream_index2, flags, len; |
|
870 |
+ |
|
871 |
+ pos = *ppos; |
|
872 |
+ |
|
873 |
+ if(rm->old_format) |
|
874 |
+ return AV_NOPTS_VALUE; |
|
875 |
+ |
|
876 |
+ url_fseek(&s->pb, pos, SEEK_SET); |
|
877 |
+ rm->remaining_len=0; |
|
878 |
+ for(;;){ |
|
879 |
+ pos= url_ftell(&s->pb); |
|
880 |
+ len=sync(s, &dts, &flags, &stream_index2); |
|
881 |
+ if(len<0) |
|
882 |
+ return AV_NOPTS_VALUE; |
|
883 |
+ av_log(s, AV_LOG_DEBUG, "%d %d-%d %Ld\n", flags, stream_index2, stream_index, dts); |
|
884 |
+ if(flags&2){ |
|
885 |
+ av_add_index_entry(s->streams[stream_index2], pos, dts, 0, AVINDEX_KEYFRAME); |
|
886 |
+ if(stream_index2 == stream_index){ |
|
887 |
+ break; |
|
888 |
+ } |
|
889 |
+ } |
|
890 |
+ |
|
891 |
+ url_fskip(&s->pb, len); |
|
892 |
+ } |
|
893 |
+ *ppos = pos; |
|
894 |
+ return dts; |
|
895 |
+} |
|
896 |
+ |
|
864 | 897 |
static AVInputFormat rm_iformat = { |
865 | 898 |
"rm", |
866 | 899 |
"rm format", |
... | ... |
@@ -869,6 +916,8 @@ static AVInputFormat rm_iformat = { |
869 | 869 |
rm_read_header, |
870 | 870 |
rm_read_packet, |
871 | 871 |
rm_read_close, |
872 |
+ NULL, |
|
873 |
+ rm_read_dts, |
|
872 | 874 |
}; |
873 | 875 |
|
874 | 876 |
#ifdef CONFIG_ENCODERS |