[FFmpeg-devel] [PATCH] avidec: handle 0-size packets that exist only in index.

Michael Niedermayer michaelni at gmx.at
Sat Apr 14 15:39:29 CEST 2012


On Fri, Apr 13, 2012 at 11:37:29PM +0200, Reimar Döffinger wrote:
> 0-sized packets are used to implement variable fps.
> However there seems to be a variation where these are not
> even stored in the main file but as 0-size index entries
> only.
> This fixes the sample in trac issue #957, it now plays both
> the same ways as in MPlayer and in a way that looks correct.
> 
> Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> ---
>  libavformat/avidec.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> index 0067ff9..d9c6164 100644
> --- a/libavformat/avidec.c
> +++ b/libavformat/avidec.c
> @@ -1235,6 +1235,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
>      AVIStream *ast;
>      unsigned int index, tag, flags, pos, len, first_packet = 1;
>      unsigned last_pos= -1;
> +    unsigned last_len= 0;
>      int64_t idx1_pos, first_packet_pos = 0, data_offset = 0;
>  
>      nb_index_entries = size / 16;
> @@ -1277,12 +1278,16 @@ static int avi_read_idx1(AVFormatContext *s, int size)
>          av_dlog(s, "%d cum_len=%"PRId64"\n", len, ast->cum_len);
>  
>  
> +        // even if we have only a single stream, we should
> +        // switch to non-interleaved to get correct timestamps
>          if(last_pos == pos)
>              avi->non_interleaved= 1;
> -        else if(len || !ast->sample_size)
> +        if((last_pos != pos || !last_len) && (len || !ast->sample_size)) {
>              av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
> +        }
>          ast->cum_len += get_duration(ast, len);

LGTM

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120414/fcf5b295/attachment.asc>


More information about the ffmpeg-devel mailing list