diff mbox

[FFmpeg-devel] avcodec/aacenc: Treat single channel as mono and bypass PCE

Message ID 46f5bafa-e262-0af1-8a48-9bd4d509df9a@gmail.com
State New
Headers show

Commit Message

pkv.stream Oct. 22, 2018, 12:11 a.m. UTC
A single channel is normally interpreted as mono.
However if channelsplit filter is used, the individual
channels are given their channel mask (ex: FL) as channel layout.
This can cause issue with the native encoder since PCE was added
because only channel layouts in spec will be encoded without PCE.
(they are listed in aac_normal_chan_layouts[]).
To avoid that, the layout for a single channel is set to mono and
therefore its encoding is achieved without PCE.
This fixes ticket 7266.
From 8c4932f25f7dced818721f292fc4ba8eb26d799a Mon Sep 17 00:00:00 2001
From: pkviet <pkv.stream@gmail.com>
Date: Mon, 22 Oct 2018 01:57:36 +0200
Subject: [PATCH] avcodec/aacenc: Treat single channel as mono and bypass PCE

A single channel is normally interpreted as mono.
However if channelsplit filter is used, the individual
channels are given their channel mask (ex: FL) as channel layout.
This can cause issue with the native encoder since PCE was added
because only channel layouts in spec will be encoded without PCE.
(they are listed in aac_normal_chan_layouts[]).
To avoid that, the layout for a single channel is set to mono and
therefore its encoding is achieved without PCE.
This fixes ticket 7266.

Signed-off-by: pkviet <pkv.stream@gmail.com>
---
 libavcodec/aacenc.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 4d0abb107f..1ee12ee669 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -972,6 +972,8 @@  static av_cold int aac_encode_init(AVCodecContext *avctx)
 
     /* Channel map and unspecified bitrate guessing */
     s->channels = avctx->channels;
+    if (s->channels == 1)
+        avctx->channel_layout = AV_CH_LAYOUT_MONO;
 
     s->needs_pce = 1;
     for (i = 0; i < FF_ARRAY_ELEMS(aac_normal_chan_layouts); i++) {