File vlc-MR5593-ffmpeg7-channels.patch of Package vlc
From 99d1644e5b1434d76db8d09dca311c81322dbbb1 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Thu, 20 Jun 2024 14:33:46 +0200
Subject: [PATCH 1/8] avcodec: remove local AV_VERSION_INT
It was added in libavutil 49.6.0 [1]. Even in 3.0 we require 52.0.0.
[1] https://github.com/FFmpeg/FFmpeg/commit/e97ac1e6f5dc3a8ba2e7dc7519a6f8fb356b8a4d
---
modules/codec/avcodec/avcodec.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index 0cc22b7363f4..4211030eee87 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -217,8 +217,3 @@ int ffmpeg_OpenCodec( decoder_t *p_dec, AVCodecContext *, const AVCodec * );
"for encoding the audio bitstream. It takes the following options: " \
"main, low, ssr (not supported),ltp, hev1, hev2 (default: low). " \
"hev1 and hev2 are currently supported only with libfdk-aac enabled libavcodec" )
-
-#ifndef AV_VERSION_INT
-# define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c))
-#endif
-
--
GitLab
From 644049eb96158cd75e24c91be07c9d4630247c54 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Thu, 20 Jun 2024 14:20:06 +0200
Subject: [PATCH 2/8] avcodec: use LIBAVCODEC_VERSION_CHECK instead version
value
This is how it used to be when libav was also supported.
We don't check for FFmpeg LIBAVCODEC_VERSION_INT values
since 8cf02acd84a1e099e15037d7c1e4dce6e8888df9.
---
modules/codec/avcodec/directx_va.c | 2 +-
modules/codec/avcodec/fourcc.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 2d9ef34e2f67..610af40b5eb7 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -305,7 +305,7 @@ static const directx_va_mode_t DXVA_MODES[] = {
{ "VP9 profile Intel", &DXVA_ModeVP9_VLD_Intel, 8, {1, 1}, 0, NULL, 0 },
/* AV1 */
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 58, 112, 103 )
+#if LIBAVCODEC_VERSION_CHECK( 58, 112, 103 )
{ "AV1 Main profile 8", &DXVA_ModeAV1_VLD_Profile0, 8, {1, 1}, AV_CODEC_ID_AV1, PROF_AV1_MAIN, 0 },
{ "AV1 Main profile 10", &DXVA_ModeAV1_VLD_Profile0, 10, {1, 1}, AV_CODEC_ID_AV1, PROF_AV1_MAIN, 0 },
{ "AV1 High profile 8", &DXVA_ModeAV1_VLD_Profile1, 8, {1, 1}, AV_CODEC_ID_AV1, PROF_AV1_HIGH, 0 },
diff --git a/modules/codec/avcodec/fourcc.c b/modules/codec/avcodec/fourcc.c
index 9d1ea245a0d5..981709068992 100644
--- a/modules/codec/avcodec/fourcc.c
+++ b/modules/codec/avcodec/fourcc.c
@@ -344,11 +344,11 @@ static const struct vlc_avcodec_fourcc video_codecs[] =
{ VLC_CODEC_AGM, AV_CODEC_ID_AGM },
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 58, 56, 100 )
+#if LIBAVCODEC_VERSION_CHECK( 58, 56, 100 )
{ VLC_CODEC_IMM5, AV_CODEC_ID_IMM5 },
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 58, 85, 100 )
+#if LIBAVCODEC_VERSION_CHECK( 58, 85, 100 )
{ VLC_CODEC_NOTCHLC, AV_CODEC_ID_NOTCHLC },
#endif
--
GitLab
From f504ce6c4f7e9326c7904d332032a413085cef30 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Thu, 20 Jun 2024 14:21:34 +0200
Subject: [PATCH 3/8] avcodec: use LIBAVUTIL_VERSION_CHECK instead version
value
This is how it used to be when libav was also supported.
---
modules/codec/avcodec/chroma.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/modules/codec/avcodec/chroma.c b/modules/codec/avcodec/chroma.c
index f9b4a2f19898..09e86ab320d3 100644
--- a/modules/codec/avcodec/chroma.c
+++ b/modules/codec/avcodec/chroma.c
@@ -33,6 +33,7 @@
* Only libavutil can be depended on here.
*/
#include "chroma.h"
+#include "avcommon_compat.h"
/*****************************************************************************
* Chroma fourcc -> libavutil pixfmt mapping
@@ -121,7 +122,7 @@ static const struct
{VLC_CODEC_UYVY, AV_PIX_FMT_UYVY422, COLOR_RANGE_UNDEF },
{VLC_CODEC_YVYU, AV_PIX_FMT_YVYU422, COLOR_RANGE_UNDEF },
-#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 34, 100)
+#if LIBAVUTIL_VERSION_CHECK(57, 34, 100)
{VLC_CODEC_VUYA, AV_PIX_FMT_VUYX, COLOR_RANGE_UNDEF },
#endif
--
GitLab
From 195f0c98599b55950c49a62f98d9d3495be310df Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 18 Jun 2024 15:34:10 +0200
Subject: [PATCH 4/8] avcodec: fix libavutil version check for
av_channel_layout_default()
It was added in c41899a3770cb4510e15b223fa34d129305b1589 which
was libavutil 57.23.100 at the time but the minor version was not updated in
that commit so we check 57.24.100.
The same check applies for av_channel_layout_copy() added in the same commit.
This is part of FFmpeg 5.1.
https://github.com/FFmpeg/FFmpeg/commit/086a8048061bf9fb4c63943f6962db48175f655c
---
modules/codec/avcodec/encoder.c | 8 ++++----
modules/demux/avformat/mux.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index d7f5a9658e9e..f77422213a89 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -778,7 +778,7 @@ int InitVideoEnc( vlc_object_t *p_this )
int i_channels_src = 0;
msg_Dbg( p_enc, "Creating channel order for reordering");
-#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_default( &p_context->ch_layout, p_enc->fmt_out.audio.i_channels );
uint64_t channel_mask = p_context->ch_layout.u.mask;
#else
@@ -933,7 +933,7 @@ errmsg:
if( p_enc->fmt_out.audio.i_channels > 2 )
{
-#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_default( &p_context->ch_layout, 2 );
#else
p_context->channels = 2;
@@ -1298,7 +1298,7 @@ static block_t *handle_delay_buffer( encoder_t *p_enc, encoder_sys_t *p_sys, uns
av_frame_unref( p_sys->frame );
p_sys->frame->format = p_sys->p_context->sample_fmt;
p_sys->frame->nb_samples = leftover_samples + p_sys->i_samples_delay;
-#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout);
#else
p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
@@ -1432,7 +1432,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
else
p_sys->frame->nb_samples = p_sys->i_frame_size;
p_sys->frame->format = p_sys->p_context->sample_fmt;
-#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout);
#else
p_sys->frame->channel_layout = p_sys->p_context->channel_layout;
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 0da8cf9b4baa..6e0a8183fffc 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -271,7 +271,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
case AUDIO_ES:
codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
-#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
+#if LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_default( &codecpar->ch_layout, fmt->audio.i_channels );
#else
codecpar->channels = fmt->audio.i_channels;
--
GitLab
From 597bdb8e0784101b5f412feba3309558ad5b8862 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 18 Jun 2024 16:04:41 +0200
Subject: [PATCH 5/8] avcodec: fix libavcodec version check for
AVCodecParameters.ch_layout
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It was added in 276c06726fbd2f784d51189870bd834e9284812f which
was libavcodec 59.23.100 at the time but the minor version was not updated in
that commit so we check 59.24.100.
This is part of FFmpeg 5.1.
It was erroneously removed in a55ec32ab3760d9edb6f05481cd3a981aa42878d.
https://github.com/FFmpeg/FFmpeg/commit/276c06726fbd2f784d51189870bd834e9284812f
Co-authored-by: François Cartegnie <fcvlcdev@free.fr>
---
modules/demux/avformat/mux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 6e0a8183fffc..f233e1fd03d9 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -271,7 +271,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
case AUDIO_ES:
codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
-#if LIBAVUTIL_VERSION_CHECK(57, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_default( &codecpar->ch_layout, fmt->audio.i_channels );
#else
codecpar->channels = fmt->audio.i_channels;
--
GitLab
From 8fd918b8787b8d077decf1a2b955ab0c7b964bf3 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Wed, 19 Jun 2024 13:41:04 +0200
Subject: [PATCH 6/8] avcodec: fix libavcodec version check for
AVCodecContext.ch_layout
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It was added in 548aeb93834b8425c86d1ce60fddc1d41805724d which
was libavcodec 59.23.100 at the time but the minor version was not updated in
that commit so we check 59.24.100.
This is part of FFmpeg 5.1.
https://github.com/FFmpeg/FFmpeg/commit/548aeb93834b8425c86d1ce60fddc1d41805724d
Co-authored-by: François Cartegnie <fcvlcdev@free.fr>
---
modules/codec/avcodec/audio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 4f64d4754538..9e48f5b43ff6 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -138,7 +138,7 @@ static int OpenAudioCodec( decoder_t *p_dec )
}
ctx->sample_rate = p_dec->fmt_in->audio.i_rate;
-#if LIBAVUTIL_VERSION_CHECK(57, 24, 100)
+#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) && LIBAVUTIL_VERSION_CHECK(57, 24, 100)
av_channel_layout_default( &ctx->ch_layout, p_dec->fmt_in->audio.i_channels );
#else
ctx->channels = p_dec->fmt_in->audio.i_channels;
--
GitLab
From f237155887f049f8befef2fdfadae7b60f697b0d Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Wed, 19 Jun 2024 08:36:40 +0200
Subject: [PATCH 7/8] avcodec: fix libavutil version check for
AVFrame.ch_layout
It was added in db6efa1815e217ed76f39aee8b15ee5c64698537 which
was libavutil 57.23.100 at the time but the minor version was not updated in
that commit so we check 57.24.100.
This is part of FFmpeg 5.1.
https://github.com/FFmpeg/FFmpeg/commit/db6efa1815e217ed76f39aee8b15ee5c64698537
---
modules/codec/avcodec/audio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 9e48f5b43ff6..5fcc80eeaada 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -407,7 +407,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
ret = avcodec_receive_frame( ctx, frame );
if( ret == 0 )
{
-#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
+#if LIBAVUTIL_VERSION_CHECK(57, 24, 100)
int channels = frame->ch_layout.nb_channels;
#else
int channels = ctx->channels;
--
GitLab
From 3ae93ce884fa8b4bea879bb05b17a554ac888234 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Thu, 20 Jun 2024 15:34:45 +0200
Subject: [PATCH 8/8] configure: enable VDPAU if libavcodec has been found
`enable_avcodec` is set to "no" if the pkg-config check above fails.
And the version we check is higher than the previous requirement
(57.37.100 vs 56.19.100)
---
configure.ac | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/configure.ac b/configure.ac
index 02fd1efd4fdf..50bd28f9208c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3437,16 +3437,8 @@ AM_CONDITIONAL([HAVE_VDPAU], [test "${have_vdpau}" = "yes"])
have_avcodec_vdpau="no"
AS_IF([test "${have_vdpau}" = "yes" -a "${enable_avcodec}" != "no"], [
- PKG_CHECK_EXISTS([libavcodec >= 56.19.100], [
- have_avcodec_vdpau="yes"
- AC_MSG_NOTICE([VDPAU decoding acceleration activated])
- ], [
- AS_IF([test -n "${enable_vdpau}"], [
- AC_MSG_ERROR([libavcodec >= 56.10.0 is required for VDPAU decoding.])
- ], [
- AC_MSG_WARN([libavcodec >= 56.10.0 are required for VDPAU decoding.])
- ])
- ])
+ have_avcodec_vdpau="yes"
+ AC_MSG_NOTICE([VDPAU decoding acceleration activated])
])
AM_CONDITIONAL([HAVE_AVCODEC_VDPAU], [test "${have_avcodec_vdpau}" = "yes"])
--
GitLab