Commit 8a472821 authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

Factorize get_duration() out of 4 places of the avi demuxer.

Originally committed as revision 23934 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 2cbd734a
...@@ -89,6 +89,13 @@ static void print_tag(const char *str, unsigned int tag, int size) ...@@ -89,6 +89,13 @@ static void print_tag(const char *str, unsigned int tag, int size)
} }
#endif #endif
static inline int get_duration(AVIStream *ast, int len){
if(ast->sample_size){
return len;
}else
return 1;
}
static int get_riff(AVFormatContext *s, ByteIOContext *pb) static int get_riff(AVFormatContext *s, ByteIOContext *pb)
{ {
AVIContext *avi = s->priv_data; AVIContext *avi = s->priv_data;
...@@ -175,10 +182,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ ...@@ -175,10 +182,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
if(last_pos != pos && (len || !ast->sample_size)) if(last_pos != pos && (len || !ast->sample_size))
av_add_index_entry(st, pos, ast->cum_len, len, 0, key ? AVINDEX_KEYFRAME : 0); av_add_index_entry(st, pos, ast->cum_len, len, 0, key ? AVINDEX_KEYFRAME : 0);
if(ast->sample_size) ast->cum_len += get_duration(ast, len);
ast->cum_len += len;
else
ast->cum_len ++;
last_pos= pos; last_pos= pos;
}else{ }else{
int64_t offset, pos; int64_t offset, pos;
...@@ -821,10 +825,7 @@ resync: ...@@ -821,10 +825,7 @@ resync:
} else { } else {
pkt->flags |= AV_PKT_FLAG_KEY; pkt->flags |= AV_PKT_FLAG_KEY;
} }
if(ast->sample_size) ast->frame_offset += get_duration(ast, pkt->size);
ast->frame_offset += pkt->size;
else
ast->frame_offset++;
} }
ast->remaining -= size; ast->remaining -= size;
if(!ast->remaining){ if(!ast->remaining){
...@@ -906,8 +907,7 @@ resync: ...@@ -906,8 +907,7 @@ resync:
if( (st->discard >= AVDISCARD_DEFAULT && size==0) if( (st->discard >= AVDISCARD_DEFAULT && size==0)
/*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering
|| st->discard >= AVDISCARD_ALL){ || st->discard >= AVDISCARD_ALL){
if(ast->sample_size) ast->frame_offset += size; ast->frame_offset += get_duration(ast, size);
else ast->frame_offset++;
url_fskip(pb, size); url_fskip(pb, size);
goto resync; goto resync;
} }
...@@ -1000,10 +1000,7 @@ static int avi_read_idx1(AVFormatContext *s, int size) ...@@ -1000,10 +1000,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
avi->non_interleaved= 1; avi->non_interleaved= 1;
else if(len || !ast->sample_size) else if(len || !ast->sample_size)
av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0); av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
if(ast->sample_size) ast->cum_len += get_duration(ast, len);
ast->cum_len += len;
else
ast->cum_len ++;
last_pos= pos; last_pos= pos;
} }
return 0; return 0;
......
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