Skip to content

Commit

Permalink
Merge branch 'ffmpeg-5' into 'develop'
Browse files Browse the repository at this point in the history
ffmpeg: update to 5.1.4

See merge request Scientific-IT-Systems/gr!1292
  • Loading branch information
danielkaiser committed Jun 19, 2024
2 parents 5f59b58 + b0b7004 commit a354d57
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 94 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/ffmpeg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ifeq ($(strip $(PREFIX)),)
override PREFIX = $(abspath $(CURDIR)/../build)
endif

VERSION = 4.2.1
VERSION = 5.1.4
FFMPEG_EXTRA_CONFIGURE_FLAGS ?=
ifeq ($(shell uname),Darwin)
FFMPEG_EXTRA_CONFIGURE_FLAGS += --extra-cflags=-mmacosx-version-min=10.15
Expand Down
188 changes: 97 additions & 91 deletions 3rdparty/ffmpeg/mov_pixeldensity.patch
Original file line number Diff line number Diff line change
@@ -1,91 +1,97 @@
diff --git a/movenc.c b/movenc.c
index a961390..c5eb12d 100644
--- a/movenc.c
+++ b/movenc.c
@@ -76,6 +76,7 @@ static const AVOption options[] = {
{ "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "write_pixeldensity", "Write pixeldensity metdata for HiDPI videos in QT", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_PIXELDENSITY}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
@@ -3118,6 +3119,56 @@ static int mov_write_track_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
return 0;
}

+static int mov_write_pixeldensity_meta_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, AVFormatContext *s)
+{
+ int size = 0;
+ int64_t pos = avio_tell(pb);
+ avio_wb32(pb, 0); /* meta atom size */
+ ffio_wfourcc(pb, "meta");
+
+ /* Metadata atom information as described in
+ * https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW9
+ */
+ avio_wb32(pb, 33); /* hdlr atom size: size (4) + 'hdlr' (4) + version/flags (4) + predefined (4) + 'mdta' (4) +
+ reserved (3*4) + name (1) = 33 */
+ ffio_wfourcc(pb, "hdlr");
+ avio_wb32(pb, 0); /* version (1 Byte) and flags (3 Bytes), must be zero */
+ avio_wb32(pb, 0); /* "predefined", must be zero */
+ ffio_wfourcc(pb, "mdta");
+ avio_wb32(pb, 0); /* Reseverved, uint32_t[3] */
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_w8(pb, 0); /* Empty name (NULL-terminated) */
+
+ avio_wb32(pb, 56); /* keys atom size: size (4) + 'keys' (4) + version/flasgs (4) + entry_count (4) +
+ keys (32+8) = 56 */
+ ffio_wfourcc(pb, "keys");
+ avio_wb32(pb, 0); /* version (1 Byte) and flags (3 Bytes), must be zero */
+ avio_wb32(pb, 1); /* entry count */
+ avio_wb32(pb, 32 + 8); /* key size: size (4) + 'mdta' (4) + strlen(key) */
+ ffio_wfourcc(pb, "mdta");
+ avio_write(pb, "com.apple.quicktime.pixeldensity", 32);
+
+ avio_wb32(pb, 48); /* ilst atom size: size (4) + 'ilst' (4) + value atom size (40) = 48 */
+ ffio_wfourcc(pb, "ilst");
+ avio_wb32(pb, 40); /* value atom size: size (4) + key (4) + data atom (32) = 40 */
+ avio_wb32(pb, 1); /* metadata key index */
+
+ avio_wb32(pb, 32); /* data atom size: size (4) + 'data' (4) + data_type (4) + locale (4) + value (4 * 4) = 32 */
+ ffio_wfourcc(pb, "data");
+ avio_wb32(pb, 0x1e); /* data type */
+ avio_wb32(pb, 0); /* locale */
+
+ /* actual data (value): consisting of 4 uint32_t: pixel width, pixel height, display width, display height */
+ avio_wb32(pb, track->par->width);
+ avio_wb32(pb, track->par->height);
+ avio_wb32(pb, track->par->width / 2);
+ avio_wb32(pb, track->par->height / 2);
+
+ size = update_size(pb, pos);
+ return size;
+}
+
static int mov_write_trak_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov,
MOVTrack *track, AVStream *st)
{
@@ -3165,6 +3216,9 @@ static int mov_write_trak_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext
mov_write_tapt_tag(pb, track);
}
}
+ if (mov->flags & FF_MOV_FLAG_PIXELDENSITY) {
+ mov_write_pixeldensity_meta_tag(pb, mov, track, st);
+ }
mov_write_track_udta_tag(pb, mov, st);
track->entry = entry_backup;
track->chunkCount = chunk_backup;
diff --git a/movenc.h b/movenc.h
index 68d6f23..ed7ea41 100644
--- a/movenc.h
+++ b/movenc.h
@@ -258,6 +258,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19)
#define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20)
#define FF_MOV_FLAG_SKIP_SIDX (1 << 21)
+#define FF_MOV_FLAG_PIXELDENSITY (1 << 22)

int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);

diff --color -crB a/movenc.c b/movenc.c
*** a/movenc.c Fri Nov 10 00:38:51 2023
--- b/movenc.c Wed Jun 12 15:36:00 2024
***************
*** 89,94 ****
--- 89,95 ----
{ "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_colr", "Write colr atom even if the color info is unspecified (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "write_pixeldensity", "Write pixeldensity metdata for HiDPI videos in QT", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_PIXELDENSITY}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "prefer_icc", "If writing colr atom prioritise usage of ICC profile if it exists in stream packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_PREFER_ICC}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
***************
*** 3638,3643 ****
--- 3639,3694 ----
return 0;
}

+ static int mov_write_pixeldensity_meta_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, AVFormatContext *s)
+ {
+ int size = 0;
+ int64_t pos = avio_tell(pb);
+ avio_wb32(pb, 0); /* meta atom size */
+ ffio_wfourcc(pb, "meta");
+
+ /* Metadata atom information as described in
+ * https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW9
+ */
+ avio_wb32(pb, 33); /* hdlr atom size: size (4) + 'hdlr' (4) + version/flags (4) + predefined (4) + 'mdta' (4) +
+ reserved (3*4) + name (1) = 33 */
+ ffio_wfourcc(pb, "hdlr");
+ avio_wb32(pb, 0); /* version (1 Byte) and flags (3 Bytes), must be zero */
+ avio_wb32(pb, 0); /* "predefined", must be zero */
+ ffio_wfourcc(pb, "mdta");
+ avio_wb32(pb, 0); /* Reseverved, uint32_t[3] */
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_w8(pb, 0); /* Empty name (NULL-terminated) */
+
+ avio_wb32(pb, 56); /* keys atom size: size (4) + 'keys' (4) + version/flasgs (4) + entry_count (4) +
+ keys (32+8) = 56 */
+ ffio_wfourcc(pb, "keys");
+ avio_wb32(pb, 0); /* version (1 Byte) and flags (3 Bytes), must be zero */
+ avio_wb32(pb, 1); /* entry count */
+ avio_wb32(pb, 32 + 8); /* key size: size (4) + 'mdta' (4) + strlen(key) */
+ ffio_wfourcc(pb, "mdta");
+ avio_write(pb, "com.apple.quicktime.pixeldensity", 32);
+
+ avio_wb32(pb, 48); /* ilst atom size: size (4) + 'ilst' (4) + value atom size (40) = 48 */
+ ffio_wfourcc(pb, "ilst");
+ avio_wb32(pb, 40); /* value atom size: size (4) + key (4) + data atom (32) = 40 */
+ avio_wb32(pb, 1); /* metadata key index */
+
+ avio_wb32(pb, 32); /* data atom size: size (4) + 'data' (4) + data_type (4) + locale (4) + value (4 * 4) = 32 */
+ ffio_wfourcc(pb, "data");
+ avio_wb32(pb, 0x1e); /* data type */
+ avio_wb32(pb, 0); /* locale */
+
+ /* actual data (value): consisting of 4 uint32_t: pixel width, pixel height, display width, display height */
+ avio_wb32(pb, track->par->width);
+ avio_wb32(pb, track->par->height);
+ avio_wb32(pb, track->par->width / 2);
+ avio_wb32(pb, track->par->height / 2);
+
+ size = update_size(pb, pos);
+ return size;
+ }
+
static int mov_write_trak_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov,
MOVTrack *track, AVStream *st)
{
***************
*** 3684,3689 ****
--- 3735,3743 ----
if (is_clcp_track(track) && st->sample_aspect_ratio.num) {
mov_write_tapt_tag(pb, track);
}
+ }
+ if (mov->flags & FF_MOV_FLAG_PIXELDENSITY) {
+ mov_write_pixeldensity_meta_tag(pb, mov, track, st);
}
mov_write_track_udta_tag(pb, mov, st);
track->entry = entry_backup;
diff --color -crB a/movenc.h b/movenc.h
*** a/movenc.h Wed Jun 12 15:40:11 2024
--- b/movenc.h Wed Jun 12 15:36:54 2024
***************
*** 275,280 ****
--- 275,281 ----
#define FF_MOV_FLAG_SKIP_SIDX (1 << 21)
#define FF_MOV_FLAG_CMAF (1 << 22)
#define FF_MOV_FLAG_PREFER_ICC (1 << 23)
+ #define FF_MOV_FLAG_PIXELDENSITY (1 << 24)

int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);

2 changes: 1 addition & 1 deletion packaging/debian/debian.rules
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ override_dh_auto_configure:
cp ../SOURCES/libogg-1.3.2.tar.gz ${THIRDPARTY_SRC}
cp ../SOURCES/libtheora-1.1.1.tar.gz ${THIRDPARTY_SRC}
cp ../SOURCES/libvpx-1.4.0.tar.bz2 ${THIRDPARTY_SRC}
cp ../SOURCES/ffmpeg-4.2.1.tar.gz ${THIRDPARTY_SRC}
cp ../SOURCES/ffmpeg-5.1.4.tar.gz ${THIRDPARTY_SRC}
cp ../SOURCES/glfw-3.3.3.tar.gz ${THIRDPARTY_SRC}
cp ../SOURCES/zeromq-4.3.4.tar.gz ${THIRDPARTY_SRC}
cp ../SOURCES/cairo-1.16.0.tar.xz ${THIRDPARTY_SRC}
Expand Down
2 changes: 1 addition & 1 deletion packaging/redhat/gr.spec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Source: gr-%{fixedversion}.tar%{?compression:.%{compression}}
Source1: https://gr-framework.org/downloads/3rdparty/libogg-1.3.2.tar.gz
Source2: https://gr-framework.org/downloads/3rdparty/libtheora-1.1.1.tar.gz
Source3: https://gr-framework.org/downloads/3rdparty/libvpx-1.4.0.tar.bz2
Source4: https://gr-framework.org/downloads/3rdparty/ffmpeg-4.2.1.tar.gz
Source4: https://gr-framework.org/downloads/3rdparty/ffmpeg-5.1.4.tar.gz
Source5: https://gr-framework.org/downloads/3rdparty/glfw-3.3.3.tar.gz
Source6: https://gr-framework.org/downloads/3rdparty/zeromq-4.3.4.tar.gz
Source7: https://gr-framework.org/downloads/3rdparty/cmake-3.6.3-Linux-x86_64.tar.gz
Expand Down

0 comments on commit a354d57

Please sign in to comment.