[FFmpeg-devel] [PATCH 11/28] fixed: Modify ffmpeg's AVI demuxer to handle VBR audio with a/v offset and padding at beginning of stream, also known as DirectShow emulation. (mplayer has been doing this since 2002, vlc since 2004, and xine since 2005...)
Mans Rullgard
mans
Wed Jun 30 11:09:39 CEST 2010
From: Cory Fields <theuni-nospam- at xbmc.org>
---
libavformat/avidec.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 390d42f..928f3fa 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -175,6 +175,8 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
if(ast->sample_size)
ast->cum_len += len;
+ else if (st->codec->block_align)
+ ast->cum_len += (len + st->codec->block_align - 1)/st->codec->block_align;
else
ast->cum_len ++;
last_pos= pos;
@@ -820,6 +822,8 @@ resync:
}
if(ast->sample_size)
ast->frame_offset += pkt->size;
+ else if (st->codec->block_align)
+ ast->frame_offset += (size + st->codec->block_align - 1)/st->codec->block_align;
else
ast->frame_offset++;
}
@@ -904,6 +908,7 @@ resync:
/*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering
|| st->discard >= AVDISCARD_ALL){
if(ast->sample_size) ast->frame_offset += size;
+ else if (st->codec->block_align) ast->frame_offset += (pkt->size + st->codec->block_align - 1)/st->codec->block_align;
else ast->frame_offset++;
url_fskip(pb, size);
goto resync;
@@ -999,6 +1004,8 @@ static int avi_read_idx1(AVFormatContext *s, int size)
av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
if(ast->sample_size)
ast->cum_len += len;
+ else if (st->codec->block_align)
+ ast->cum_len += (len + st->codec->block_align - 1)/st->codec->block_align;
else
ast->cum_len ++;
last_pos= pos;
--
1.7.1.1
More information about the ffmpeg-devel
mailing list