Skip to content

Commit

Permalink
contrib: update to FFmpeg snapshot 20240322 rev 114301.
Browse files Browse the repository at this point in the history
  • Loading branch information
galad87 committed Mar 22, 2024
1 parent aeaf3b2 commit ec38623
Show file tree
Hide file tree
Showing 25 changed files with 177 additions and 530 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
From 228b17a1f5f4d3d82c5beca4fc57016c3d582c64 Mon Sep 17 00:00:00 2001
From db9aacd530340e44e3202c2aeba0ee18f6b09fe5 Mon Sep 17 00:00:00 2001
From: John Stebbins <[email protected]>
Date: Fri, 21 May 2021 14:12:07 +0200
Subject: [PATCH 1/5] [PATCH 1/3] mov: read 'name' track tag written by movenc
Date: Wed, 20 Mar 2024 09:07:15 +0100
Subject: [PATCH 01/16] mov: read 'name' track tag written by movenc.

---
libavformat/mov.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 38a7058..1546867 100644
index 8d1135270c..e91da339ee 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -308,6 +308,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@@ -336,6 +336,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL;
int raw = 0;
int num = 0;
+ AVDictionary *metadata;

switch (atom.type) {
case MKTAG( '@','P','R','M'): key = "premiere_version"; raw = 1; break;
@@ -340,6 +341,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@@ -368,6 +369,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return mov_metadata_loci(c, pb, atom.size);
case MKTAG( 'm','a','n','u'): key = "make"; break;
case MKTAG( 'm','o','d','l'): key = "model"; break;
+ case MKTAG( 'n','a','m','e'): key = "title"; raw = 1; break;
case MKTAG( 'p','c','s','t'): key = "podcast";
parse = mov_metadata_int8_no_padding; break;
case MKTAG( 'p','g','a','p'): key = "gapless_playback";
@@ -515,17 +517,23 @@ retry:
@@ -553,17 +555,23 @@ retry:
}
str[str_size] = 0;
}
Expand Down Expand Up @@ -61,5 +61,5 @@ index 38a7058..1546867 100644
}

--
2.30.1 (Apple Git-130)
2.39.3 (Apple Git-146)

26 changes: 11 additions & 15 deletions contrib/ffmpeg/A02-movenc-write-3gpp-track-titl-tag.patch
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
From 95a64ac34f4273b32f2eeabbdf28b40bf0bf6391 Mon Sep 17 00:00:00 2001
From: Damiano galassi <damiog@gmail.com>
Date: Tue, 28 Feb 2023 11:20:07 +0100
Subject: [PATCH 1/3] movenc: write 3gpp track 'titl' tag
From fbd97ecdb9e6f58770768355635c5ffda64b4a2b Mon Sep 17 00:00:00 2001
From: John Stebbins <jstebbins@jetheaddev.com>
Date: Wed, 20 Mar 2024 09:08:52 +0100
Subject: [PATCH 02/16] movenc: write 3gpp track 'titl' tag

Apple software used to use 'name' raw tag for track titles. When they
rewrote everything with AVFoundation, they switched to using 3gpp 'titl'
tag for track titles and 'name' no longer works.

Original patch by John Stebbins <[email protected]>
Apple software used to use 'name' raw tag for track titles. When they rewrote everything with AVFoundation, they switched to using 3gpp 'titl' tag for track titles and 'name' no longer works.
---
libavformat/movenc.c | 77 ++++++++++++++++++++++----------------------
1 file changed, 39 insertions(+), 38 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 319f02b..cba6ce1 100644
index 724a1eb673..f7192002f1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3567,6 +3567,34 @@ static int mov_write_udta_sdp(AVIOContext *pb, MOVTrack *track)
@@ -3761,6 +3761,34 @@ static int mov_write_udta_sdp(AVIOContext *pb, MOVTrack *track)
return len + 24;
}

Expand Down Expand Up @@ -51,7 +47,7 @@ index 319f02b..cba6ce1 100644
static int mov_write_track_metadata(AVIOContext *pb, AVStream *st,
const char *tag, const char *str)
{
@@ -3641,8 +3669,10 @@ static int mov_write_track_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
@@ -3835,8 +3863,10 @@ static int mov_write_track_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
if (ret < 0)
return ret;

Expand All @@ -63,7 +59,7 @@ index 319f02b..cba6ce1 100644

if (mov->mode & MODE_MP4) {
if ((ret = mov_write_track_kinds(pb_buf, st)) < 0)
@@ -4240,35 +4270,6 @@ static int ascii_to_wc(AVIOContext *pb, const uint8_t *b)
@@ -4433,35 +4463,6 @@ static int ascii_to_wc(AVIOContext *pb, const uint8_t *b)
return 0;
}

Expand Down Expand Up @@ -99,7 +95,7 @@ index 319f02b..cba6ce1 100644
static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
{
int64_t pos = avio_tell(pb);
@@ -4307,14 +4308,14 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
@@ -4500,14 +4501,14 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
return ret;

if (mov->mode & MODE_3GP) {
Expand All @@ -123,5 +119,5 @@ index 319f02b..cba6ce1 100644
} else if (mov->mode == MODE_MOV && !(mov->flags & FF_MOV_FLAG_USE_MDTA)) { // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4
mov_write_string_metadata(s, pb_buf, "\251ART", "artist", 0);
--
2.37.1 (Apple Git-137.1)
2.39.3 (Apple Git-146)

19 changes: 9 additions & 10 deletions contrib/ffmpeg/A03-mov-read-3gpp-udta-tags.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
From 69339799f416dfb95866d3ab50d4adbf0b7c1871 Mon Sep 17 00:00:00 2001
From: Damiano galassi <damiog@gmail.com>
Date: Tue, 28 Feb 2023 11:20:25 +0100
Subject: [PATCH 2/3] mov: read 3gpp udta tags.
From b7e3621fdc939b60aae1dbea1a48c7274d7e494a Mon Sep 17 00:00:00 2001
From: John Stebbins <jstebbins@jetheaddev.com>
Date: Wed, 20 Mar 2024 09:09:41 +0100
Subject: [PATCH 03/16] mov: read 3gpp udta tags.

Original patch by John Stebbins <[email protected]>.
---
libavformat/mov.c | 101 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 98 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 978d995..4bffdac 100644
index e91da339ee..f9012db994 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -55,6 +55,7 @@
Expand All @@ -20,7 +19,7 @@ index 978d995..4bffdac 100644
#include "internal.h"
#include "avio_internal.h"
#include "demux.h"
@@ -296,6 +297,73 @@ static int mov_metadata_hmmt(MOVContext *c, AVIOContext *pb, unsigned len)
@@ -325,6 +326,73 @@ static int mov_metadata_hmmt(MOVContext *c, AVIOContext *pb, unsigned len)
return 0;
}

Expand Down Expand Up @@ -94,7 +93,7 @@ index 978d995..4bffdac 100644
static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
char tmp_key[AV_FOURCC_MAX_STRING_SIZE] = {0};
@@ -321,15 +389,33 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@@ -350,15 +418,33 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
case MKTAG( 'c','a','t','g'): key = "category"; break;
case MKTAG( 'c','p','i','l'): key = "compilation";
parse = mov_metadata_int8_no_padding; break;
Expand Down Expand Up @@ -131,7 +130,7 @@ index 978d995..4bffdac 100644
case MKTAG( 'h','d','v','d'): key = "hd_video";
parse = mov_metadata_int8_no_padding; break;
case MKTAG( 'H','M','M','T'):
@@ -400,6 +486,15 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@@ -429,6 +515,15 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
case MKTAG(0xa9,'w','r','n'): key = "warning"; break;
case MKTAG(0xa9,'w','r','t'): key = "composer"; break;
case MKTAG(0xa9,'x','y','z'): key = "location"; break;
Expand All @@ -148,5 +147,5 @@ index 978d995..4bffdac 100644
retry:
if (c->itunes_metadata && atom.size > 8) {
--
2.37.1 (Apple Git-137.1)
2.39.3 (Apple Git-146)

Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
From 7662ce6bcda9f153b164ef57fdadcc5ce6a21088 Mon Sep 17 00:00:00 2001
From: Damiano galassi <damiog@gmail.com>
Date: Tue, 28 Feb 2023 11:23:18 +0100
Subject: [PATCH 3/3] movenc: write 3gpp track names tags for all available
From e918e84253888fdefb68191e7da20c840ccf13f6 Mon Sep 17 00:00:00 2001
From: John Stebbins <jstebbins@jetheaddev.com>
Date: Wed, 20 Mar 2024 09:10:27 +0100
Subject: [PATCH 04/16] movenc: write 3gpp track names tags for all available
languages

Metadata keys can have a language suffix. Iterate through all language
variations of the metadata key.

Original patch by John Stebbins <[email protected]>.
Metadata keys can have a language suffix. Iterate through all language variations of the metadata key.
---
libavformat/movenc.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index cba6ce1..3e680c4 100644
index f7192002f1..167536de75 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -28,6 +28,7 @@
Expand All @@ -24,7 +21,7 @@ index cba6ce1..3e680c4 100644
#include "avio_internal.h"
#include "dovi_isom.h"
#include "riff.h"
@@ -3586,7 +3587,14 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVDictionary *metadata,
@@ -3780,7 +3781,14 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVDictionary *metadata,
if (!strcmp(tag, "yrrc"))
avio_wb16(pb, atoi(t->value));
else {
Expand All @@ -40,7 +37,7 @@ index cba6ce1..3e680c4 100644
avio_write(pb, t->value, strlen(t->value) + 1); /* UTF8 string value */
if (!strcmp(tag, "albm") &&
(t = av_dict_get(metadata, "track", NULL, 0)))
@@ -3670,8 +3678,21 @@ static int mov_write_track_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
@@ -3864,8 +3872,21 @@ static int mov_write_track_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
return ret;

if (mov->mode & (MODE_MP4|MODE_MOV)) {
Expand All @@ -64,5 +61,5 @@ index cba6ce1..3e680c4 100644

if (mov->mode & MODE_MP4) {
--
2.37.1 (Apple Git-137.1)
2.39.3 (Apple Git-146)

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
From 263190a74a245423833bd6e1bc10726577e5502d Mon Sep 17 00:00:00 2001
From: Damiano Galassi <damiog@gmail.com>
Date: Sun, 25 Feb 2024 16:52:20 +0100
Subject: [PATCH] dvdsubdec: fix processing of partial packets
From 839a13d816cf1d499d3f93100124dcc609a55f2f Mon Sep 17 00:00:00 2001
From: John Stebbins <jstebbins@jetheaddev.com>
Date: Wed, 20 Mar 2024 09:11:09 +0100
Subject: [PATCH 05/16] dvdsubdec: fix processing of partial packets

Wait for a complete dvd subtitle before processing.

If the input packet is large enough to start processing, but does not contain complete data, unfinished results are emitted and the following input packet causes an error because the stream is no longer in sync with the decoder.

Original patch by John Stebbins.
---
libavcodec/dvdsubdec.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
Expand Down
18 changes: 8 additions & 10 deletions contrib/ffmpeg/A06-dvdsubdec-return-number-of-bytes-used.patch
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
From bc5a0e48b2e2c2b896c109e1641433460b4b0422 Mon Sep 17 00:00:00 2001
From: Damiano Galassi <damiog@gmail.com>
Date: Sat, 16 Jul 2022 09:59:56 +0200
Subject: [PATCH 1/2] dvdsubdec: return number of bytes used
From 100a46bdaee1d399d47099eafa917e381c208573 Mon Sep 17 00:00:00 2001
From: John Stebbins <jstebbins@jetheaddev.com>
Date: Wed, 20 Mar 2024 09:11:51 +0100
Subject: [PATCH 06/16] dvdsubdec: return number of bytes used

Documentation says avcodec_decode_subtitle2 returns the number of bytes
used.
Original patch by John Stebbins.
Documentation says avcodec_decode_subtitle2 returns the number of bytes used.
---
libavcodec/dvdsubdec.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 97f366cc74..fdeead372b 100644
index bee42e3c61..146996bc23 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -536,7 +536,11 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
@@ -547,7 +547,11 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
if (is_menu == AVERROR(EAGAIN)) {
*data_size = 0;
Expand All @@ -28,5 +26,5 @@ index 97f366cc74..fdeead372b 100644

if (is_menu < 0) {
--
2.32.1 (Apple Git-133)
2.39.3 (Apple Git-146)

27 changes: 13 additions & 14 deletions contrib/ffmpeg/A07-dvdsubdec-use-pts-of-initial-packet.patch
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
From 1c4f9fafaa17df4e1eddea06329f34537af1ef50 Mon Sep 17 00:00:00 2001
From: Damiano Galassi <damiog@gmail.com>
Date: Sat, 16 Jul 2022 10:02:27 +0200
Subject: [PATCH 2/2] dvdsubdec: use pts of initial packet
From 2bae41702e2a558ebea370b888e040875ac16779 Mon Sep 17 00:00:00 2001
From: John Stebbins <jstebbins@jetheaddev.com>
Date: Wed, 20 Mar 2024 09:12:27 +0100
Subject: [PATCH 07/16] dvdsubdec: use pts of initial packet

When the source is DVD, only the initial packet of a subtitle that spans
multiple packets will have a pts value. Original patch by John Stebbins.
When the source is DVD, only the initial packet of a subtitle that spans multiple packets will have a pts value.
---
libavcodec/dvdsubdec.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index fdeead372b..13e7ccad9d 100644
index 146996bc23..2dd10b4d8b 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -43,6 +43,7 @@ typedef struct DVDSubContext
@@ -44,6 +44,7 @@ typedef struct DVDSubContext
int buf_size;
int forced_subs_only;
uint8_t used_color[256];
+ int64_t pts;
} DVDSubContext;

static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values)
@@ -522,10 +523,13 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
@@ -533,10 +534,13 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
int appended = 0;
int is_menu;

Expand All @@ -35,23 +34,23 @@ index fdeead372b..13e7ccad9d 100644
return ret;
}
buf = ctx->buf;
@@ -538,6 +542,7 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
@@ -549,6 +553,7 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
*data_size = 0;
int ret = appended ? 0 : append_to_cached_buf(avctx, buf, buf_size);
if (ret < 0) {
+ ctx->pts = AV_NOPTS_VALUE;
return ret;
}
return buf_size;
@@ -549,6 +554,7 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
@@ -560,6 +565,7 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
reset_rects(sub);
*data_size = 0;

+ ctx->pts = AV_NOPTS_VALUE;
return buf_size;
}
if (!is_menu && find_smallest_bounding_rectangle(ctx, sub) == 0)
@@ -559,6 +565,8 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
@@ -570,6 +576,8 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,

ctx->buf_size = 0;
*data_size = 1;
Expand All @@ -60,7 +59,7 @@ index fdeead372b..13e7ccad9d 100644
return buf_size;
}

@@ -684,6 +692,7 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
@@ -695,6 +703,7 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_DEBUG, " 0x%06"PRIx32, ctx->palette[i]);
av_log(avctx, AV_LOG_DEBUG, "\n");
}
Expand All @@ -69,5 +68,5 @@ index fdeead372b..13e7ccad9d 100644
return 1;
}
--
2.32.1 (Apple Git-133)
2.39.3 (Apple Git-146)

Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
From 78b2d7bf731c6be284fc16c93012eb84eac867fe Mon Sep 17 00:00:00 2001
From 86431df08fe51ebf123305714939d0495fe1044b Mon Sep 17 00:00:00 2001
From: Damiano Galassi <[email protected]>
Date: Fri, 8 Mar 2024 08:40:08 +0100
Subject: [PATCH] dvdsubdec: add an option to output subtitles with empty or
fully transparent rects.
Date: Wed, 20 Mar 2024 09:14:19 +0100
Subject: [PATCH 08/16] dvdsubdec: add an option to output subtitles with
empty or fully transparent rects.

---
libavcodec/dvdsubdec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index bee42e3c61..b3ce026d16 100644
index 2dd10b4d8b..aa4b1367d2 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -43,6 +43,7 @@ typedef struct DVDSubContext
uint8_t buf[0x10000];
int buf_size;
@@ -45,6 +45,7 @@ typedef struct DVDSubContext
int forced_subs_only;
+ int output_empty_rects;
uint8_t used_color[256];
int64_t pts;
+ int output_empty_rects;
} DVDSubContext;

@@ -558,7 +559,7 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,

static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values)
@@ -568,7 +569,7 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
ctx->pts = AV_NOPTS_VALUE;
return buf_size;
}
- if (!is_menu && find_smallest_bounding_rectangle(ctx, sub) == 0)
+ if (!is_menu && !ctx->output_empty_rects && find_smallest_bounding_rectangle(ctx, sub) == 0)
goto no_subtitle;

if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
@@ -707,6 +708,7 @@ static const AVOption options[] = {
@@ -720,6 +721,7 @@ static const AVOption options[] = {
{ "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD },
{ "ifo_palette", "obtain the global palette from .IFO file", OFFSET(ifo_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD },
{ "forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, SD},
Expand Down
Loading

0 comments on commit ec38623

Please sign in to comment.