Commit 37e85dac authored by Michael Niedermayer's avatar Michael Niedermayer

seeking in rm 2nd try

Originally committed as revision 3738 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent bc17df09
...@@ -720,13 +720,14 @@ static int get_num(ByteIOContext *pb, int *len) ...@@ -720,13 +720,14 @@ static int get_num(ByteIOContext *pb, int *len)
/* multiple of 20 bytes for ra144 (ugly) */ /* multiple of 20 bytes for ra144 (ugly) */
#define RAW_PACKET_SIZE 1000 #define RAW_PACKET_SIZE 1000
static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index){ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){
RMContext *rm = s->priv_data; RMContext *rm = s->priv_data;
ByteIOContext *pb = &s->pb; ByteIOContext *pb = &s->pb;
int len, num, res, i; int len, num, res, i;
AVStream *st; AVStream *st;
while(!url_feof(pb)){ while(!url_feof(pb)){
*pos= url_ftell(pb);
if(rm->remaining_len > 0){ if(rm->remaining_len > 0){
num= rm->current_stream; num= rm->current_stream;
len= rm->remaining_len; len= rm->remaining_len;
...@@ -745,7 +746,6 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_ ...@@ -745,7 +746,6 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
res= get_byte(pb); /* reserved */ res= get_byte(pb); /* reserved */
*flags = get_byte(pb); /* flags */ *flags = get_byte(pb); /* flags */
// av_log(s, AV_LOG_DEBUG, "%d %Ld %X %X\n", num, *timestamp, *flags, res);
len -= 12; len -= 12;
} }
...@@ -773,7 +773,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -773,7 +773,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
ByteIOContext *pb = &s->pb; ByteIOContext *pb = &s->pb;
AVStream *st; AVStream *st;
int i, len, tmp, j; int i, len, tmp, j;
int64_t timestamp; int64_t timestamp, pos;
uint8_t *ptr; uint8_t *ptr;
int flags; int flags;
...@@ -790,7 +790,9 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -790,7 +790,9 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->size = len; pkt->size = len;
st = s->streams[0]; st = s->streams[0];
} else { } else {
len=sync(s, &timestamp, &flags, &i); int seq=1;
len=sync(s, &timestamp, &flags, &i, &pos);
if(len<0) if(len<0)
return AVERROR_IO; return AVERROR_IO;
st = s->streams[i]; st = s->streams[i];
...@@ -800,8 +802,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -800,8 +802,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
h= get_byte(pb); len--; h= get_byte(pb); len--;
if(!(h & 0x40)){ if(!(h & 0x40)){
int seq = get_byte(pb); seq = get_byte(pb); len--;
len--;
} }
if((h & 0xc0) == 0x40){ if((h & 0xc0) == 0x40){
...@@ -838,8 +839,11 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -838,8 +839,11 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
} }
#endif #endif
pkt->pts= timestamp; pkt->pts= timestamp;
if(flags&2) if(flags&2){
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
if((seq&0x7F) == 1)
av_add_index_entry(st, pos, timestamp, 0, AVINDEX_KEYFRAME);
}
} }
/* for AC3, needs to swap bytes */ /* for AC3, needs to swap bytes */
...@@ -880,7 +884,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, ...@@ -880,7 +884,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
{ {
RMContext *rm = s->priv_data; RMContext *rm = s->priv_data;
int64_t pos, dts; int64_t pos, dts;
int stream_index2, flags, len; int stream_index2, flags, len, h;
pos = *ppos; pos = *ppos;
...@@ -890,18 +894,28 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, ...@@ -890,18 +894,28 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
url_fseek(&s->pb, pos, SEEK_SET); url_fseek(&s->pb, pos, SEEK_SET);
rm->remaining_len=0; rm->remaining_len=0;
for(;;){ for(;;){
pos= url_ftell(&s->pb); int seq=1;
len=sync(s, &dts, &flags, &stream_index2); AVStream *st;
len=sync(s, &dts, &flags, &stream_index2, &pos);
if(len<0) if(len<0)
return AV_NOPTS_VALUE; return AV_NOPTS_VALUE;
av_log(s, AV_LOG_DEBUG, "%d %d-%d %Ld\n", flags, stream_index2, stream_index, dts);
if(flags&2){ st = s->streams[stream_index2];
av_add_index_entry(s->streams[stream_index2], pos, dts, 0, AVINDEX_KEYFRAME); if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
if(stream_index2 == stream_index){ h= get_byte(&s->pb); len--;
break; if(!(h & 0x40)){
seq = get_byte(&s->pb); len--;
} }
} }
if((flags&2) && (seq&0x7F) == 1){
// av_log(s, AV_LOG_DEBUG, "%d %d-%d %Ld %d\n", flags, stream_index2, stream_index, dts, seq);
av_add_index_entry(st, pos, dts, 0, AVINDEX_KEYFRAME);
if(stream_index2 == stream_index)
break;
}
url_fskip(&s->pb, len); url_fskip(&s->pb, len);
} }
*ppos = pos; *ppos = pos;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment