aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-12-06 22:44:03 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-12-06 22:44:03 +0000
commitbc17df09d4d8cef550b1af99923d204f31b91dc6 (patch)
treeb0ce0f6c2dbef0f007dad12b2e5b1847b932941a
parent80016c48b07fac94f0bf3470a7322c2a022256a0 (diff)
downloadffmpeg-bc17df09d4d8cef550b1af99923d204f31b91dc6.tar.gz
seeking in rm
Originally committed as revision 3737 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/rv10.c19
-rw-r--r--libavformat/rm.c127
2 files changed, 102 insertions, 44 deletions
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 7dc3ea21f6..c544438dde 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -400,20 +400,28 @@ static int rv20_decode_picture_header(MpegEncContext *s)
}
if(s->avctx->has_b_frames){
+ int f1=9;
+ int f2=9;
+ int f3=9;
+
if (get_bits(&s->gb, 1)){
-// av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n");
+ av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n");
// return -1;
}
seq= get_bits(&s->gb, 14)<<1;
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&1){
- get_bits(&s->gb, 1);
+ f1= get_bits(&s->gb, 1);
}
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&2){
- get_bits(&s->gb, 1);
+ f2= get_bits(&s->gb, 1);
}
if(s->avctx->extradata_size >= 4 && ((uint8_t*)s->avctx->extradata)[1]&4){
- get_bits(&s->gb, 2);
+ f3= get_bits(&s->gb, 2);
+ }
+
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO){
+ av_log(s->avctx, AV_LOG_DEBUG, "F %d %d %d\n", f1,f2,f3);
}
mb_pos= get_bits(&s->gb, av_log2(s->mb_num-1)+1);
@@ -733,6 +741,7 @@ AVCodec rv20_decoder = {
NULL,
rv10_decode_end,
rv10_decode_frame,
- CODEC_CAP_DR1
+ CODEC_CAP_DR1,
+ .flush= ff_mpeg_flush,
};
diff --git a/libavformat/rm.c b/libavformat/rm.c
index 6dea24ce9f..6f63fd4a69 100644
--- a/libavformat/rm.c
+++ b/libavformat/rm.c
@@ -720,15 +720,62 @@ static int get_num(ByteIOContext *pb, int *len)
/* multiple of 20 bytes for ra144 (ugly) */
#define RAW_PACKET_SIZE 1000
+static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index){
+ RMContext *rm = s->priv_data;
+ ByteIOContext *pb = &s->pb;
+ int len, num, res, i;
+ AVStream *st;
+
+ while(!url_feof(pb)){
+ if(rm->remaining_len > 0){
+ num= rm->current_stream;
+ len= rm->remaining_len;
+ *timestamp = AV_NOPTS_VALUE;
+ *flags= 0;
+ }else{
+ if(get_byte(pb))
+ continue;
+ if(get_byte(pb))
+ continue;
+ len = get_be16(pb);
+ if (len < 12)
+ continue;
+ num = get_be16(pb);
+ *timestamp = get_be32(pb);
+ res= get_byte(pb); /* reserved */
+ *flags = get_byte(pb); /* flags */
+
+// av_log(s, AV_LOG_DEBUG, "%d %Ld %X %X\n", num, *timestamp, *flags, res);
+
+ len -= 12;
+ }
+ for(i=0;i<s->nb_streams;i++) {
+ st = s->streams[i];
+ if (num == st->id)
+ break;
+ }
+ if (i == s->nb_streams) {
+ /* skip packet if unknown number */
+ url_fskip(pb, len);
+ rm->remaining_len -= len;
+ continue;
+ }
+ *stream_index= i;
+
+ return len;
+ }
+ return -1;
+}
+
static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
RMContext *rm = s->priv_data;
ByteIOContext *pb = &s->pb;
AVStream *st;
- int num, i, len, tmp, j;
+ int i, len, tmp, j;
int64_t timestamp;
uint8_t *ptr;
- int flags, res;
+ int flags;
if (rm->old_format) {
/* just read raw bytes */
@@ -743,44 +790,11 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->size = len;
st = s->streams[0];
} else {
- redo:
- if (url_feof(pb))
+ len=sync(s, &timestamp, &flags, &i);
+ if(len<0)
return AVERROR_IO;
- if(rm->remaining_len > 0){
- num= rm->current_stream;
- len= rm->remaining_len;
- timestamp = AV_NOPTS_VALUE;
- flags= 0;
- }else{
- if(get_byte(pb))
- goto redo;
- if(get_byte(pb))
- goto redo;
- len = get_be16(pb);
- if (len < 12)
- goto redo;
- num = get_be16(pb);
- timestamp = get_be32(pb);
- res= get_byte(pb); /* reserved */
- flags = get_byte(pb); /* flags */
-
-// av_log(s, AV_LOG_DEBUG, "%d %d %X %d\n", num, timestamp, flags, res);
-
- len -= 12;
- }
-
- st = NULL;
- for(i=0;i<s->nb_streams;i++) {
- st = s->streams[i];
- if (num == st->id)
- break;
- }
- if (i == s->nb_streams) {
- /* skip packet if unknown number */
- url_fskip(pb, len);
- goto redo;
- }
-
+ st = s->streams[i];
+
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
int h, pic_num, len2, pos;
@@ -861,6 +875,39 @@ static int rm_probe(AVProbeData *p)
return 0;
}
+static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
+ int64_t *ppos, int64_t pos_limit)
+{
+ RMContext *rm = s->priv_data;
+ int64_t pos, dts;
+ int stream_index2, flags, len;
+
+ pos = *ppos;
+
+ if(rm->old_format)
+ return AV_NOPTS_VALUE;
+
+ url_fseek(&s->pb, pos, SEEK_SET);
+ rm->remaining_len=0;
+ for(;;){
+ pos= url_ftell(&s->pb);
+ len=sync(s, &dts, &flags, &stream_index2);
+ if(len<0)
+ return AV_NOPTS_VALUE;
+ av_log(s, AV_LOG_DEBUG, "%d %d-%d %Ld\n", flags, stream_index2, stream_index, dts);
+ if(flags&2){
+ av_add_index_entry(s->streams[stream_index2], pos, dts, 0, AVINDEX_KEYFRAME);
+ if(stream_index2 == stream_index){
+ break;
+ }
+ }
+
+ url_fskip(&s->pb, len);
+ }
+ *ppos = pos;
+ return dts;
+}
+
static AVInputFormat rm_iformat = {
"rm",
"rm format",
@@ -869,6 +916,8 @@ static AVInputFormat rm_iformat = {
rm_read_header,
rm_read_packet,
rm_read_close,
+ NULL,
+ rm_read_dts,
};
#ifdef CONFIG_ENCODERS