ffmpeg: add libatomic dependency

Some platforms lack builtin atomics and use libatomic. Add it.

Backport various patches to fix some warnings.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2025-05-02 16:04:46 -07:00 committed by Robert Marko
parent b3b67527c5
commit e64ca4a0dc
13 changed files with 341 additions and 13 deletions

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=ffmpeg PKG_NAME:=ffmpeg
PKG_VERSION:=6.1.2 PKG_VERSION:=6.1.2
PKG_RELEASE:=2 PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://ffmpeg.org/releases/ PKG_SOURCE_URL:=https://ffmpeg.org/releases/
@ -231,7 +231,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/ffmpeg/Default define Package/ffmpeg/Default
TITLE:=FFmpeg TITLE:=FFmpeg
URL:=https://ffmpeg.org/ URL:=https://ffmpeg.org/
DEPENDS+= +libpthread DEPENDS+= +libatomic
endef endef
define Package/ffmpeg/Default/description define Package/ffmpeg/Default/description

View File

@ -0,0 +1,31 @@
From cb9c98da16e8412046835ebc0d167a4e09909df0 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <zhilizhao@tencent.com>
Date: Sun, 30 Jun 2024 18:33:19 +0800
Subject: [PATCH] avformat/file: guard fd_dup by FD_PROTOCOL or PIPE_PROTOCOL
fd_dup is unused when fd and pipe have been disabled. This also
fix build error with wasi since 'dup' isn't available.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
libavformat/file.c | 2 ++
1 file changed, 2 insertions(+)
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -192,6 +192,7 @@ static int file_check(URLContext *h, int
return ret;
}
+#if CONFIG_FD_PROTOCOL || CONFIG_PIPE_PROTOCOL
static int fd_dup(URLContext *h, int oldfd)
{
int newfd;
@@ -214,6 +215,7 @@ static int fd_dup(URLContext *h, int old
#endif
return newfd;
}
+#endif
static int file_close(URLContext *h)
{

View File

@ -0,0 +1,24 @@
From c961ac4b0ca27d451c430553793b3fff88fc78e5 Mon Sep 17 00:00:00 2001
From: Jun Zhao <mypopydev@gmail.com>
Date: Sun, 12 Nov 2023 18:25:29 +0800
Subject: [PATCH] vulkan_decode: fix the print format of VkDeviceSize
VkDeviceSize represents device memory size and offset
values as uint64_t in Spec.
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
libavcodec/vulkan_video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/libavcodec/vulkan_video.c
+++ b/libavcodec/vulkan_video.c
@@ -384,7 +384,7 @@ av_cold int ff_vk_video_common_init(void
.memorySize = mem[i].memoryRequirements.size,
};
- av_log(log, AV_LOG_VERBOSE, "Allocating %"SIZE_SPECIFIER" bytes in bind index %i for video session\n",
+ av_log(log, AV_LOG_VERBOSE, "Allocating %"PRIu64" bytes in bind index %i for video session\n",
bind_mem[i].memorySize, bind_mem[i].memoryBindIndex);
}

View File

@ -0,0 +1,58 @@
From 2204efc2a656ae60d77a4d01c6cf8e7d6baaf030 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 30 Mar 2025 12:49:07 +0200
Subject: [PATCH] avcodec/dct: Make declarations and definitions match
GCC considers declarations using a parameter of pointer
type (or equivalently a parameter using an array of unspecified
dimensions) to be inconsistent with a declaration using
a known-length array type and emits a -Warray-parameter warning
for several ff_j_rev_dct* functions for this.
This patch makes the declarations match the actual definitions
to suppress these (IMO nonsensical) warnings.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/dct.h | 12 ++++++------
libavcodec/jrevdct.c | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
--- a/libavcodec/dct.h
+++ b/libavcodec/dct.h
@@ -27,11 +27,11 @@
#include <stddef.h>
#include <stdint.h>
-void ff_j_rev_dct(int16_t *data);
-void ff_j_rev_dct4(int16_t *data);
-void ff_j_rev_dct2(int16_t *data);
-void ff_j_rev_dct1(int16_t *data);
-void ff_jref_idct_put(uint8_t *dest, ptrdiff_t line_size, int16_t *block);
-void ff_jref_idct_add(uint8_t *dest, ptrdiff_t line_size, int16_t *block);
+void ff_j_rev_dct(int16_t data[64]);
+void ff_j_rev_dct4(int16_t data[64]);
+void ff_j_rev_dct2(int16_t data[64]);
+void ff_j_rev_dct1(int16_t data[64]);
+void ff_jref_idct_put(uint8_t *dest, ptrdiff_t line_size, int16_t block[64]);
+void ff_jref_idct_add(uint8_t *dest, ptrdiff_t line_size, int16_t block[64]);
#endif /* AVCODEC_DCT_H */
--- a/libavcodec/jrevdct.c
+++ b/libavcodec/jrevdct.c
@@ -1159,13 +1159,13 @@ void ff_j_rev_dct1(DCTBLOCK data){
#undef FIX
#undef CONST_BITS
-void ff_jref_idct_put(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
+void ff_jref_idct_put(uint8_t *dest, ptrdiff_t line_size, int16_t block[64])
{
ff_j_rev_dct(block);
ff_put_pixels_clamped_c(block, dest, line_size);
}
-void ff_jref_idct_add(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
+void ff_jref_idct_add(uint8_t *dest, ptrdiff_t line_size, int16_t block[64])
{
ff_j_rev_dct(block);
ff_add_pixels_clamped_c(block, dest, line_size);

View File

@ -1,11 +0,0 @@
--- a/libavcodec/wmv2dsp.c
+++ b/libavcodec/wmv2dsp.c
@@ -264,7 +264,7 @@ av_cold void ff_wmv2dsp_init(WMV2DSPCont
c->put_mspel_pixels_tab[6] = put_mspel8_mc22_c;
c->put_mspel_pixels_tab[7] = put_mspel8_mc32_c;
-#if ARCH_MIPS
+#if ARCH_MIPS64
ff_wmv2dsp_init_mips(c);
#endif
}

View File

@ -0,0 +1,23 @@
From 9a670636c0ee7c24b70591d315524e61c709ea5a Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Fri, 2 May 2025 15:15:25 -0700
Subject: [PATCH] avutil/tx: fix GCC memset warning
The warning is that the whole array is not being cleared.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
libavutil/tx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -283,7 +283,7 @@ static void reset_ctx(AVTXContext *s, in
* ff_tx_init_subtx() call is made. */
s->nb_sub = 0;
s->opaque = NULL;
- memset(s->fn, 0, sizeof(*s->fn));
+ memset(s->fn, 0, sizeof(s->fn));
}
void ff_tx_clear_ctx(AVTXContext *s)

View File

@ -0,0 +1,30 @@
From 22baff53be0f830a1607af2b60e50605eb732ec4 Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Fri, 2 May 2025 15:21:13 -0700
Subject: [PATCH] avformat/rawdec: guard by CONFIG_DATA_DEMUXER
Otherwise raw_data_read_header becomes an unused static function.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
libavformat/rawdec.c | 2 ++
1 file changed, 2 insertions(+)
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -102,6 +102,7 @@ int ff_raw_subtitle_read_header(AVFormat
return 0;
}
+#if CONFIG_DATA_DEMUXER
static int raw_data_read_header(AVFormatContext *s)
{
AVStream *st = avformat_new_stream(s, NULL);
@@ -112,6 +113,7 @@ static int raw_data_read_header(AVFormat
st->start_time = 0;
return 0;
}
+#endif
/* Note: Do not forget to add new entries to the Makefile as well. */

View File

@ -0,0 +1,43 @@
From 347a70f101be28f8d78e8fd62ffc3a78324f49e9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 28 Mar 2024 05:35:36 +0100
Subject: [PATCH] avcodec/pcm-bluray/dvd: Use correct pointer types on BE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/pcm-bluray.c | 5 +++--
libavcodec/pcm-dvd.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
--- a/libavcodec/pcm-bluray.c
+++ b/libavcodec/pcm-bluray.c
@@ -167,7 +167,7 @@ static int pcm_bluray_decode_frame(AVCod
samples *= num_source_channels;
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
#if HAVE_BIGENDIAN
- bytestream2_get_buffer(&gb, dst16, buf_size);
+ bytestream2_get_buffer(&gb, (uint8_t*)dst16, buf_size);
#else
do {
*dst16++ = bytestream2_get_be16u(&gb);
@@ -187,7 +187,8 @@ static int pcm_bluray_decode_frame(AVCod
if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
#if HAVE_BIGENDIAN
- bytestream2_get_buffer(&gb, dst16, avctx->ch_layout.nb_channels * 2);
+ bytestream2_get_buffer(&gb, (uint8_t*)dst16,
+ avctx->ch_layout.nb_channels * 2);
dst16 += avctx->ch_layout.nb_channels;
#else
channel = avctx->ch_layout.nb_channels;
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -157,7 +157,7 @@ static void *pcm_dvd_decode_samples(AVCo
switch (avctx->bits_per_coded_sample) {
case 16: {
#if HAVE_BIGENDIAN
- bytestream2_get_buffer(&gb, dst16, blocks * s->block_size);
+ bytestream2_get_buffer(&gb, (uint8_t*)dst16, blocks * s->block_size);
dst16 += blocks * s->block_size / 2;
#else
int samples = blocks * avctx->ch_layout.nb_channels;

View File

@ -0,0 +1,30 @@
From bb3c50b46d50b8bf4f45d7ae8f24607aaf23acea Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 2 Jun 2024 06:11:46 +0200
Subject: [PATCH] avcodec/tiff: Suppress unused variable warnings
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/tiff.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -427,7 +427,7 @@ static void av_always_inline horizontal_
uint8_t shift = is_dng ? 0 : 16 - bpp;
GetBitContext gb;
- int ret = init_get_bits8(&gb, src, width);
+ av_unused int ret = init_get_bits8(&gb, src, width);
av_assert1(ret >= 0);
for (int i = 0; i < s->width; i++) {
dst16[i] = get_bits(&gb, bpp) << shift;
@@ -462,7 +462,7 @@ static void unpack_gray(TiffContext *s,
GetBitContext gb;
uint16_t *dst = (uint16_t *)(p->data[0] + lnum * p->linesize[0]);
- int ret = init_get_bits8(&gb, src, width);
+ av_unused int ret = init_get_bits8(&gb, src, width);
av_assert1(ret >= 0);
for (int i = 0; i < s->width; i++) {

View File

@ -0,0 +1,29 @@
From 7405f1ad5351cc24b91a0227aeeaf24ff9d12278 Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Wed, 3 Jul 2024 00:30:08 +0200
Subject: [PATCH] configure: restore autodetection of v4l2 and fbdev
The detection logic for v4l2 and fbdev was accidentally modified to
depend on v4l2-m2m in 43b3412.
---
configure | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--- a/configure
+++ b/configure
@@ -6985,11 +6985,12 @@ pod2man --help > /dev/null 2>&1 && e
rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
xmllint --version > /dev/null 2>&1 && enable xmllint || disable xmllint
+check_headers linux/fb.h
+check_headers linux/videodev2.h
+test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+
# check V4L2 codecs available in the API
if enabled v4l2_m2m; then
- check_headers linux/fb.h
- check_headers linux/videodev2.h
- test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;"
check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;"
check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;"

View File

@ -0,0 +1,41 @@
From 00b64fca55a3a009c9d0e391c85f4fd3291e5d12 Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Thu, 29 Aug 2024 15:40:00 +0200
Subject: [PATCH] configure: improve check for POSIX ioctl
Instead of relying on system #ifdefs which may or may not be correct,
detect the POSIX ioctl signature at configure time.
---
configure | 2 ++
libavdevice/v4l2.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
--- a/configure
+++ b/configure
@@ -2450,6 +2450,7 @@ HAVE_LIST="
opencl_vaapi_intel_media
perl
pod2man
+ posix_ioctl
texi2html
xmllint
zlib_gzip
@@ -6988,6 +6989,7 @@ xmllint --version > /dev/null 2>&1 && e
check_headers linux/fb.h
check_headers linux/videodev2.h
test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+test_code cc sys/ioctl.h "int ioctl(int, int, ...)" && enable posix_ioctl
# check V4L2 codecs available in the API
if enabled v4l2_m2m; then
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -107,7 +107,7 @@ struct video_data {
int (*open_f)(const char *file, int oflag, ...);
int (*close_f)(int fd);
int (*dup_f)(int fd);
-#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
+#if HAVE_POSIX_IOCTL
int (*ioctl_f)(int fd, int request, ...);
#else
int (*ioctl_f)(int fd, unsigned long int request, ...);

View File

@ -0,0 +1,30 @@
From 613c85a8f5b296c2b79fc0abfd98fccf962bb334 Mon Sep 17 00:00:00 2001
From: Marvin Scholz <epirat07@gmail.com>
Date: Fri, 12 Jul 2024 17:47:14 +0200
Subject: [PATCH] avfilter/af_channelsplit: fix mixed declaration and code
Fix a "mixing declarations and code is incompatible with standards
before C99" warning.
---
libavfilter/af_channelsplit.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/libavfilter/af_channelsplit.c
+++ b/libavfilter/af_channelsplit.c
@@ -156,6 +156,7 @@ static int query_formats(AVFilterContext
static int filter_frame(AVFilterLink *outlink, AVFrame *buf)
{
+ AVFrame *buf_out;
AVFilterContext *ctx = outlink->src;
ChannelSplitContext *s = ctx->priv;
const int i = FF_OUTLINK_IDX(outlink);
@@ -164,7 +165,7 @@ static int filter_frame(AVFilterLink *ou
av_assert1(channel >= 0);
- AVFrame *buf_out = av_frame_clone(buf);
+ buf_out = av_frame_clone(buf);
if (!buf_out)
return AVERROR(ENOMEM);