prepend 1 sample zero padding in case of SBR and enc_delay is odd
authornu774 <honeycomb77@gmail.com>
Tue, 29 Oct 2013 16:32:52 +0000 (01:32 +0900)
committernu774 <honeycomb77@gmail.com>
Tue, 29 Oct 2013 17:09:23 +0000 (02:09 +0900)
This is required because odd enc_delay cannot be exactly expressed in
downsampled scale, and HE-AACv2 FDK encoder actually has odd enc_delay.

src/main.c

index d06c6830fefdc69a11c99440422247886aba008b..7d1a68fc885fb1abbe95b878b3161063eac15f98 100644 (file)
@@ -823,6 +823,16 @@ int main(int argc, char **argv)
         m4af_set_priming_mode(m4af, params.gapless_mode + 1);
         m4af_begin_write(m4af);
     }
+    if (sbr_mode && (aacinfo.encoderDelay & 1)) {
+        /*
+         * Since odd delay cannot be exactly expressed in downsampled scale,
+         * we push one zero frame to the encoder here, to make delay even
+         */
+        int16_t zero[8] = { 0 };
+        aacenc_result_t obuf = { 0 };
+        aac_encode_frame(encoder, sample_format, zero, 1, &obuf);
+        free(obuf.data);
+    }
     frame_count = encode(&params, reader, encoder, aacinfo.frameLength, m4af);
     if (frame_count < 0)
         goto END;
This page took 0.01168 seconds and 4 git commands to generate.