support 7.1 channel mode added on FDK 3.4.12
[fdkaac.git] / src / aacenc.c
index bf975d0778c67ce71cfbee8b97415a6e0782461c..00c37f333da6b5d5a916326ca428b55f44f80c0f 100644 (file)
@@ -93,10 +93,10 @@ int aacenc_channel_mode(const pcm_sample_description_t *format)
 {
     uint32_t chanmask = format->channel_mask;
 
-    if (format->channels_per_frame > 6)
+    if (format->channels_per_frame > 8)
         return 0;
     if (!chanmask) {
-        static uint32_t defaults[] = { 0x4, 0x3, 0x7, 0, 0x37, 0x3f };
+        static uint32_t defaults[] = { 0x4, 0x3, 0x7, 0, 0x37, 0x3f, 0, 0x63f };
         chanmask = defaults[format->channels_per_frame - 1];
     }
     switch (chanmask) {
@@ -108,6 +108,10 @@ int aacenc_channel_mode(const pcm_sample_description_t *format)
     case 0x107: return MODE_1_2_1;
     case 0x607: return MODE_1_2_2;
     case 0x60f: return MODE_1_2_2_1;
+#if AACENCODER_LIB_VL0 > 3 || (AACENCODER_LIB_VL0==3 && AACENCODER_LIB_VL1>=4)
+    case 0xff:  return MODE_1_2_2_2_1;
+    case 0x63f: return MODE_7_1_REAR_SURROUND;
+#endif
     }
     return 0;
 }
@@ -187,7 +191,7 @@ FAIL:
 int aac_encode_frame(HANDLE_AACENCODER encoder,
                      const pcm_sample_description_t *format,
                      const int16_t *input, unsigned iframes,
-                     uint8_t **output, uint32_t *olen, uint32_t *osize)
+                     aacenc_frame_t *output)
 {
     uint32_t ilen = iframes * format->channels_per_frame;
     AACENC_BufDesc ibdesc = { 0 }, obdesc = { 0 };
@@ -205,12 +209,14 @@ int aac_encode_frame(HANDLE_AACENCODER encoder,
     unsigned channel_mode, obytes;
 
     channel_mode = aacEncoder_GetParam(encoder, AACENC_CHANNELMODE);
-    obytes = 6144 / 8 * channel_mode + 7;
-    if (!*output || *osize < obytes) {
-        *osize = obytes;
-        *output = realloc(*output, obytes);
+    obytes = 6144 / 8 * channel_mode;
+    if (!output->data || output->capacity < obytes) {
+        uint8_t *p = realloc(output->data, obytes);
+        if (!p) return -1;
+        output->capacity = obytes;
+        output->data = p;
     }
-    obufs[0] = *output;
+    obufs[0] = output->data;
     obuf_sizes[0] = obytes;
 
     iargs.numInSamples = ilen ? ilen : -1; /* -1 for signaling EOF */
@@ -230,6 +236,6 @@ int aac_encode_frame(HANDLE_AACENCODER encoder,
         fprintf(stderr, "ERROR: aacEncEncode() failed\n");
         return -1;
     }
-    *olen = oargs.numOutBytes;
+    output->size = oargs.numOutBytes;
     return oargs.numInSamples / format->channels_per_frame;
 }
This page took 0.010261 seconds and 4 git commands to generate.