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

pkv.stream pkv.stream at gmail.com
Mon Oct 22 03:11:01 EEST 2018


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.

-------------- next part --------------
From 8c4932f25f7dced818721f292fc4ba8eb26d799a Mon Sep 17 00:00:00 2001
From: pkviet <pkv.stream at 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 at gmail.com>
---
 libavcodec/aacenc.c | 2 ++
 1 file changed, 2 insertions(+)

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++) {
-- 
2.16.2.windows.1



More information about the ffmpeg-devel mailing list