[FFmpeg-cvslog] latmenc: Fix ALS in LATM.

Reimar Döffinger git at videolan.org
Wed Apr 11 22:31:44 CEST 2012


ffmpeg | branch: master | Reimar Döffinger <Reimar.Doeffinger at gmx.de> | Tue Apr 10 20:59:05 2012 +0200| [a736eb4a605f46d5ff96c7b32e55710ecd9cce89] | committer: Reimar Döffinger

latmenc: Fix ALS in LATM.

"Fix" in so far as at least it will no longer overread and possibly
crash and makes somewhat sense, but no idea whether there is anything
that can play the resulting files (FFmpeg can't).

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a736eb4a605f46d5ff96c7b32e55710ecd9cce89
---

 libavformat/latmenc.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c
index 27810f9..3eadfe0 100644
--- a/libavformat/latmenc.c
+++ b/libavformat/latmenc.c
@@ -57,6 +57,11 @@ static int latm_decode_extradata(LATMContext *ctx, uint8_t *buf, int size)
     if (ctx->off < 0)
         return ctx->off;
 
+    if (ctx->object_type == AOT_ALS && (ctx->off & 7)) {
+        // as long as avpriv_mpeg4audio_get_config works correctly this is impossible
+        av_log(ctx, AV_LOG_ERROR, "BUG: ALS offset is not byte-aligned\n");
+        return AVERROR_INVALIDDATA;
+    }
     /* FIXME: are any formats not allowed in LATM? */
 
     if (m4ac.object_type > AOT_SBR && m4ac.object_type != AOT_ALS) {
@@ -106,8 +111,8 @@ static void latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
 
         /* AudioSpecificConfig */
         if (ctx->object_type == AOT_ALS) {
-            header_size = avctx->extradata_size-(ctx->off + 7) >> 3;
-            avpriv_copy_bits(bs, &avctx->extradata[ctx->off], header_size);
+            header_size = avctx->extradata_size-(ctx->off >> 3);
+            avpriv_copy_bits(bs, &avctx->extradata[ctx->off >> 3], header_size);
         } else {
             avpriv_copy_bits(bs, avctx->extradata, ctx->off + 3);
 



More information about the ffmpeg-cvslog mailing list