Re: [libav-devel] [PATCH 22/25] aac: Allow pass-through transcoding of ambisonic audio

2017-06-29 Thread Diego Biurrun
On Wed, Jun 28, 2017 at 06:11:06PM -0400, Vittorio Giovara wrote:
> The defacto mov standard mandates support for PCM and AAC: only the

de facto MOV

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 22/25] aac: Allow pass-through transcoding of ambisonic audio

2017-06-28 Thread Vittorio Giovara
The defacto mov standard mandates support for PCM and AAC: only the
latter decoder overrides the channel layout passed by the container,
so let this happen only when the layout order is native (or unspecified).

On the encoding side, until full ambisonic channel layout conversion
is implemented, add a temporary layout to allow pass-through transcoding
of files tagged with this specification.

Signed-off-by: Vittorio Giovara 
---
 libavcodec/aacdec.c| 13 -
 libavcodec/libfdk-aacdec.c |  6 --
 libavcodec/libfdk-aacenc.c |  3 ++-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index ab184b8634..33b6e3a40a 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -494,11 +494,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 
-av_channel_layout_uninit(&ac->oc[1].ch_layout);
-av_channel_layout_from_mask(&ac->oc[1].ch_layout, layout);
-ret = av_channel_layout_copy(&avctx->ch_layout, &ac->oc[1].ch_layout);
-if (ret < 0)
-return ret;
+if (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ||
+avctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
+av_channel_layout_uninit(&ac->oc[1].ch_layout);
+av_channel_layout_from_mask(&ac->oc[1].ch_layout, layout);
+ret = av_channel_layout_copy(&avctx->ch_layout, &ac->oc[1].ch_layout);
+if (ret < 0)
+return ret;
+}
 #if FF_API_OLD_CHANNEL_LAYOUT
 FF_DISABLE_DEPRECATION_WARNINGS
 avctx->channels   = avctx->ch_layout.nb_channels;
diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index 6a77e90392..a8eeb6a1c9 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -184,8 +184,10 @@ static int get_stream_info(AVCodecContext *avctx)
 }
 }
 
-av_channel_layout_uninit(&avctx->ch_layout);
-av_channel_layout_from_mask(&avctx->ch_layout, ch_layout);
+if (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) {
+av_channel_layout_uninit(&avctx->ch_layout);
+av_channel_layout_from_mask(&avctx->ch_layout, ch_layout);
+}
 if (!ch_error && avctx->ch_layout.nb_channels != info->numChannels) {
 av_log(avctx, AV_LOG_WARNING, "unsupported channel configuration\n");
 ch_error = 1;
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index f92c14d65f..ec29e1c6ad 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -410,7 +410,7 @@ static const uint64_t aac_channel_layout[] = {
 };
 #endif /* FF_API_OLD_CHANNEL_LAYOUT */
 
-static const AVChannelLayout aac_ch_layouts[16] = {
+static const AVChannelLayout aac_ch_layouts[17] = {
 AV_CHANNEL_LAYOUT_MONO,
 AV_CHANNEL_LAYOUT_STEREO,
 AV_CHANNEL_LAYOUT_SURROUND,
@@ -421,6 +421,7 @@ static const AVChannelLayout aac_ch_layouts[16] = {
 AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK,
 AV_CHANNEL_LAYOUT_7POINT1,
 #endif
+AV_CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER,
 { 0 },
 };
 
-- 
2.13.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel