[FFmpeg-devel] [PATCH] latmenc: fix muxing of byte-aligned DSE.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Apr 9 00:11:35 CEST 2012


This will only work for DSEs that are first in a packet, but
that is enough to fix handling of the reference files in
fate-suite/aac (though most of them still have other issues).

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavformat/latmenc.c    |    8 +++++++-
 tests/lavf-regression.sh |    4 ++++
 tests/ref/lavf-fate/latm |    3 +++
 3 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/lavf-fate/latm

diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c
index c8d7715..4ca4237 100644
--- a/libavformat/latmenc.c
+++ b/libavformat/latmenc.c
@@ -161,8 +161,14 @@ static int latm_write_packet(AVFormatContext *s, AVPacket *pkt)
 
     /* The LATM payload is written unaligned */
 
+    i = 0;
+    if (pkt->size && (pkt->data[0] & 0xe1) == 0x81) {
+        // convert byte-aligned DSE to non-aligned
+        put_bits(&bs, 8, pkt->data[0] & 0xfe);
+        i++;
+    }
     /* PayloadMux() */
-    for (i = 0; i < pkt->size; i++)
+    for (; i < pkt->size; i++)
         put_bits(&bs, 8, pkt->data[i]);
 
     avpriv_align_put_bits(&bs);
diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
index 97fdd3f..1998a58 100755
--- a/tests/lavf-regression.sh
+++ b/tests/lavf-regression.sh
@@ -139,6 +139,10 @@ if [ -n "$do_mp3" ] ; then
 do_lavf_fate mp3 "mp3-conformance/he_32khz.bit" "-acodec copy"
 fi
 
+if [ -n "$do_latm" ] ; then
+do_lavf_fate latm "aac/al04_44.mp4" "-acodec copy"
+fi
+
 if [ -n "$do_ogg_vp3" ] ; then
 # -idct simple causes different results on different systems
 DEC_OPTS="$DEC_OPTS -idct auto"
diff --git a/tests/ref/lavf-fate/latm b/tests/ref/lavf-fate/latm
new file mode 100644
index 0000000..dc18099
--- /dev/null
+++ b/tests/ref/lavf-fate/latm
@@ -0,0 +1,3 @@
+175e87b46bacd91f0ba891e412d01b25 *./tests/data/lavf-fate/lavf.latm
+65536 ./tests/data/lavf-fate/lavf.latm
+./tests/data/lavf-fate/lavf.latm CRC=0xc3a18f90
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list