diff mbox

[FFmpeg-devel] avformat/movenc: fix size calculation in mov_write_eac3_tag()

Message ID 20181121104610.4255-1-onemda@gmail.com
State Accepted
Commit 027f032bbce9bdf7bbec40665b98590cade33416
Headers show

Commit Message

Paul B Mahol Nov. 21, 2018, 10:46 a.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tomas Härdin Nov. 21, 2018, 10:57 a.m. UTC | #1
ons 2018-11-21 klockan 11:46 +0100 skrev Paul B Mahol:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/movenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 33978ee1b0..bee8e89760 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -541,7 +541,7 @@ static int mov_write_eac3_tag(AVIOContext *pb,
> MOVTrack *track)
>          return AVERROR(EINVAL);
>  
>      info = track->eac3_priv;
> -    size = 2 + 4 * (info->num_ind_sub + 1);
> +    size = 2 + ((34 * (info->num_ind_sub + 1) + 7) >> 3);

Having to round like this looks like something the put_bits stuff could
maybe take care of. Not that that needs to hold this patch back of
course

I took a look at the surrounding code, and this patch looks OK. The
info->substream[i].num_dep_sub stuff modifying size looks a bit hacky
compared to computing the proper size

/Tomas
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 33978ee1b0..bee8e89760 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -541,7 +541,7 @@  static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track)
         return AVERROR(EINVAL);
 
     info = track->eac3_priv;
-    size = 2 + 4 * (info->num_ind_sub + 1);
+    size = 2 + ((34 * (info->num_ind_sub + 1) + 7) >> 3);
     buf = av_malloc(size);
     if (!buf) {
         size = AVERROR(ENOMEM);