[FFmpeg-devel] [PATCH 2/4] mov: fix tref count for multiple trefs

Clément Bœsch ubitux at gmail.com
Sat Aug 25 17:13:20 CEST 2012


On Sat, Aug 25, 2012 at 11:44:12AM +0200, Jean First wrote:
> Signed-off-by: Jean First <jeanfirst at gmail.com>
> ---
>  libavformat/mov.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index cb8307f..e128e51 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2521,7 +2521,7 @@ static int mov_read_tref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>      if (size < 12)
>          return 0;
>  
> -    sc->trefs_count = (size - 4) / 8;
> +    sc->trefs_count = (size + 4) / 8;
>      sc->trefs = av_malloc(sc->trefs_count * sizeof(*sc->trefs));
>      if (!sc->trefs)
>          return AVERROR(ENOMEM);

Mmh are you sure of this?

Looking again at the code, that tref count indeed looks wrong, but I think
the correct expression should be (size - 8) / 4:

IIRC, and looking at the code, I think the atom is such as

   [size(4)]["tref" (4)]
            [subsize(4)][tag(4)] N*[ids(4)]
                         ^
                       "tmcd" or something

In the code, size corresponds to subsize which is the size of
subsize+tag+N*ids, and thus
N = (subsize - sizeof(subsize) - sizeof(tag)) / sizeof(ids)
  = (subsize -               4           - 4) / 4
  = (subsize - 8) / 4;

No?

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120825/3a5b5140/attachment.asc>


More information about the ffmpeg-devel mailing list