latmenc: fix muxing of byte-aligned DSE.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sun, 8 Apr 2012 22:10:07 +0000 (00:10 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 12 Apr 2012 18:27:47 +0000 (20:27 +0200)
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@gmx.de>
libavformat/latmenc.c
tests/lavf-regression.sh
tests/ref/lavf-fate/latm [new file with mode: 0644]

index 3ee277d..c296a1b 100644 (file)
@@ -166,8 +166,21 @@ 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.
+        // Due to the input format encoding we know that
+        // it is naturally byte-aligned in the input stream,
+        // so there are no padding bits to account for.
+        // To avoid having to add padding bits and rearrange
+        // the whole stream we just remove the byte-align flag.
+        // This allows us to remux our FATE AAC samples into latm
+        // files that are still playable with minimal effort.
+        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);
index 66e394c..24a0c64 100755 (executable)
@@ -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 (file)
index 0000000..3679277
--- /dev/null
@@ -0,0 +1,3 @@
+9c8d1afdb2d336976102f175ba577471 *./tests/data/lavf-fate/lavf.latm
+71926 ./tests/data/lavf-fate/lavf.latm
+./tests/data/lavf-fate/lavf.latm CRC=0xd846c4b3