0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-01-31 21:22:27 +00:00
termux-packages/packages/vlc/0006-avcodec-encoder-fix-channel_layout-conditionals.patch
2024-12-16 08:35:23 +01:00

66 lines
2.1 KiB
Diff

Copied from https://salsa.debian.org/multimedia-team/vlc/-/commit/f0ead348a0d2739c6e097938e7fd20db39c6fc59
From: Francois Cartegnie <fcvlcdev@free.fr>
Date: Thu, 13 Jun 2024 12:21:58 +0700
Subject: avcodec: encoder: fix channel_layout conditionals
---
modules/codec/avcodec/encoder.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 52848de..6bd58f5 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -43,12 +43,13 @@
#include <vlc_cpu.h>
#include <libavcodec/avcodec.h>
-#include <libavutil/channel_layout.h>
#include "avcodec.h"
#include "avcommon.h"
-#if LIBAVUTIL_VERSION_CHECK( 52,2,6,0,0 )
+#define API_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_CHECK( 52, 2, 6, 0, 100))
+
+#if API_CHANNEL_LAYOUT
# include <libavutil/channel_layout.h>
#endif
@@ -157,6 +158,7 @@ struct encoder_sys_t
/* Taken from audio.c*/
+#if API_CHANNEL_LAYOUT
static const uint64_t pi_channels_map[][2] =
{
{ AV_CH_FRONT_LEFT, AOUT_CHAN_LEFT },
@@ -193,6 +195,7 @@ static const uint32_t channel_mask[][2] = {
{AOUT_CHANS_7_1, AV_CH_LAYOUT_7POINT1},
{AOUT_CHANS_8_1, AV_CH_LAYOUT_OCTAGONAL},
};
+#endif
static const char *const ppsz_enc_options[] = {
"keyint", "bframes", "vt", "qmin", "qmax", "codec", "hq",
@@ -746,7 +749,7 @@ int InitVideoEnc( vlc_object_t *p_this )
p_context->time_base.num = 1;
p_context->time_base.den = p_context->sample_rate;
p_context->channels = p_enc->fmt_out.audio.i_channels;
-#if LIBAVUTIL_VERSION_CHECK( 52, 2, 6, 0, 0)
+#if API_CHANNEL_LAYOUT
p_context->channel_layout = channel_mask[p_context->channels][1];
/* Setup Channel ordering for multichannel audio
@@ -925,7 +928,9 @@ errmsg:
if( p_enc->fmt_out.audio.i_channels > 2 )
{
p_context->channels = 2;
+#if API_CHANNEL_LAYOUT
p_context->channel_layout = channel_mask[p_context->channels][1];
+#endif
/* Change fmt_in in order to ask for a channels conversion */
p_enc->fmt_in.audio.i_channels =