-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance(main/ffmpeg): Use debian patches
ffmpeg is a large and complex code base that has occasional security and functionality issues, while being not that frequently released. This PR proposes syncing patches from debian, replacing our single handpicked backported commit. Run ./packages/ffmpeg/sync-debian-patches.sh to regenerate the patchset from debian.
- Loading branch information
Showing
17 changed files
with
846 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/ffmpeg/debian-0001-avformat-mov-don-t-return-the-latest-stream-when-an-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
From: James Almer <jamrial@gmail.com> | ||
Date: Mon, 30 Sep 2024 10:59:02 -0300 | ||
Subject: avformat/mov: don't return the latest stream when an item stream is | ||
expected | ||
|
||
Otherwise, things like ICC profiles as read from the colr box meant for an item | ||
with no stream (like a grid) may end up being added to the wrong stream. | ||
|
||
Signed-off-by: James Almer <jamrial@gmail.com> | ||
(cherry picked from commit 04182b55494b44152146e6a6bcd5eb9403f00625) | ||
--- | ||
libavformat/mov.c | 6 +++++- | ||
1 file changed, 5 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/libavformat/mov.c b/libavformat/mov.c | ||
index a2333ac..5b0b23f 100644 | ||
--- a/libavformat/mov.c | ||
+++ b/libavformat/mov.c | ||
@@ -188,6 +188,10 @@ static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, | ||
return p - dst; | ||
} | ||
|
||
+/** | ||
+ * Get the current stream in the parsing process. This can either be the | ||
+ * latest stream added to the context, or the stream referenced by an item. | ||
+ */ | ||
static AVStream *get_curr_st(MOVContext *c) | ||
{ | ||
AVStream *st = NULL; | ||
@@ -206,7 +210,7 @@ static AVStream *get_curr_st(MOVContext *c) | ||
st = item->st; | ||
break; | ||
} | ||
- if (!st) | ||
+ if (!st && c->cur_item_id == -1) | ||
st = c->fc->streams[c->fc->nb_streams-1]; | ||
|
||
return st; |
84 changes: 84 additions & 0 deletions
84
packages/ffmpeg/debian-0002-avformat-internal-Add-ff_get_frame_filename.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
From: Zhao Zhili <zhilizhao@tencent.com> | ||
Date: Mon, 23 Sep 2024 23:14:19 +0800 | ||
Subject: avformat/internal: Add ff_get_frame_filename | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset="utf-8" | ||
Content-Transfer-Encoding: 8bit | ||
|
||
It's similar to av_get_frame_filename2 but with int64_t number | ||
support. Make av_get_frame_filename* a wrapper over | ||
ff_get_frame_filename. | ||
|
||
Co-authored-by: Filip Mašić <shoutplenty@gmail.com> | ||
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> | ||
(cherry picked from commit a2d9663241908d6f558b8e6b24bd42f2aaebc144) | ||
--- | ||
libavformat/internal.h | 16 ++++++++++++++++ | ||
libavformat/utils.c | 11 ++++++++--- | ||
2 files changed, 24 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/libavformat/internal.h b/libavformat/internal.h | ||
index 8e8971b..6c026f0 100644 | ||
--- a/libavformat/internal.h | ||
+++ b/libavformat/internal.h | ||
@@ -745,6 +745,22 @@ void ff_format_set_url(AVFormatContext *s, char *url); | ||
*/ | ||
int ff_match_url_ext(const char *url, const char *extensions); | ||
|
||
+/** | ||
+ * Return in 'buf' the path with '%d' replaced by a number. | ||
+ * | ||
+ * Also handles the '%0nd' format where 'n' is the total number | ||
+ * of digits and '%%'. | ||
+ * | ||
+ * @param buf destination buffer | ||
+ * @param buf_size destination buffer size | ||
+ * @param path path with substitution template | ||
+ * @param number the number to substitute | ||
+ * @param flags AV_FRAME_FILENAME_FLAGS_* | ||
+ * @return 0 if OK, -1 on format error | ||
+ */ | ||
+int ff_get_frame_filename(char *buf, int buf_size, const char *path, | ||
+ int64_t number, int flags); | ||
+ | ||
struct FFOutputFormat; | ||
struct FFInputFormat; | ||
void avpriv_register_devices(const struct FFOutputFormat * const o[], | ||
diff --git a/libavformat/utils.c b/libavformat/utils.c | ||
index e9ded62..e892e8b 100644 | ||
--- a/libavformat/utils.c | ||
+++ b/libavformat/utils.c | ||
@@ -280,7 +280,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts) | ||
return (sec * 1000000) + usec; | ||
} | ||
|
||
-int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) | ||
+int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags) | ||
{ | ||
const char *p; | ||
char *q, buf1[20], c; | ||
@@ -313,7 +313,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number | ||
percentd_found = 1; | ||
if (number < 0) | ||
nd += 1; | ||
- snprintf(buf1, sizeof(buf1), "%0*d", nd, number); | ||
+ snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number); | ||
len = strlen(buf1); | ||
if ((q - buf + len) > buf_size - 1) | ||
goto fail; | ||
@@ -338,9 +338,14 @@ fail: | ||
return -1; | ||
} | ||
|
||
+int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) | ||
+{ | ||
+ return ff_get_frame_filename(buf, buf_size, path, number, flags); | ||
+} | ||
+ | ||
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number) | ||
{ | ||
- return av_get_frame_filename2(buf, buf_size, path, number, 0); | ||
+ return ff_get_frame_filename(buf, buf_size, path, number, 0); | ||
} | ||
|
||
void av_url_split(char *proto, int proto_size, |
34 changes: 34 additions & 0 deletions
34
packages/ffmpeg/debian-0003-avformat-img2enc-Fix-integer-truncation-when-frame_p.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
From: Zhao Zhili <zhilizhao@tencent.com> | ||
Date: Tue, 24 Sep 2024 00:16:13 +0800 | ||
Subject: avformat/img2enc: Fix integer truncation when frame_pts is enabled | ||
|
||
Fix #11194 | ||
|
||
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> | ||
(cherry picked from commit f56a54387b9cea884ca139e9cb993ff6989b8def) | ||
--- | ||
libavformat/img2enc.c | 8 ++++---- | ||
1 file changed, 4 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c | ||
index 526a11e..41638d9 100644 | ||
--- a/libavformat/img2enc.c | ||
+++ b/libavformat/img2enc.c | ||
@@ -160,13 +160,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) | ||
return AVERROR(EINVAL); | ||
} | ||
} else if (img->frame_pts) { | ||
- if (av_get_frame_filename2(filename, sizeof(filename), s->url, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { | ||
+ if (ff_get_frame_filename(filename, sizeof(filename), s->url, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { | ||
av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames."); | ||
return AVERROR(EINVAL); | ||
} | ||
- } else if (av_get_frame_filename2(filename, sizeof(filename), s->url, | ||
- img->img_number, | ||
- AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { | ||
+ } else if (ff_get_frame_filename(filename, sizeof(filename), s->url, | ||
+ img->img_number, | ||
+ AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { | ||
if (img->img_number == img->start_img_number) { | ||
av_log(s, AV_LOG_WARNING, "The specified filename '%s' does not contain an image sequence pattern or a pattern is invalid.\n", s->url); | ||
av_log(s, AV_LOG_WARNING, |
26 changes: 26 additions & 0 deletions
26
packages/ffmpeg/debian-0004-avcodec-mediacodecenc-Fix-access-of-uninitialized-va.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From: Zhao Zhili <zhilizhao@tencent.com> | ||
Date: Fri, 4 Oct 2024 01:30:57 +0800 | ||
Subject: avcodec/mediacodecenc: Fix access of uninitialized value | ||
|
||
When crop is skipped, av_strlcatf will access `str` which isn't | ||
initialized properly. | ||
|
||
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> | ||
(cherry picked from commit eff9ed7bff45998ea370e3d6f627529ad47e2e74) | ||
--- | ||
libavcodec/mediacodecenc.c | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c | ||
index 6ca3968..e76ea81 100644 | ||
--- a/libavcodec/mediacodecenc.c | ||
+++ b/libavcodec/mediacodecenc.c | ||
@@ -134,7 +134,7 @@ static int extract_extradata_support(AVCodecContext *avctx) | ||
static int mediacodec_init_bsf(AVCodecContext *avctx) | ||
{ | ||
MediaCodecEncContext *s = avctx->priv_data; | ||
- char str[128]; | ||
+ char str[128] = {0}; | ||
int ret; | ||
int crop_right = s->width - avctx->width; | ||
int crop_bottom = s->height - avctx->height; |
28 changes: 28 additions & 0 deletions
28
packages/ffmpeg/debian-0005-fftools-do-not-access-out-of-bounds-filtergraph.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
From: Marvin Scholz <epirat07@gmail.com> | ||
Date: Tue, 1 Oct 2024 02:57:11 +0200 | ||
Subject: fftools: do not access out of bounds filtergraph | ||
|
||
The log message was logged for `filtergraphs[j]` which would cause a | ||
heap buffer overflow in certain circumstances. | ||
|
||
Correctly it should be logged for the current filtergraph, so just | ||
use `fg` here. | ||
|
||
(cherry picked from commit 5beeb3a1f97d8f6d4076fe83aaf5e2e5871f945e) | ||
--- | ||
fftools/ffmpeg_filter.c | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c | ||
index 7ec328e..2f2b297 100644 | ||
--- a/fftools/ffmpeg_filter.c | ||
+++ b/fftools/ffmpeg_filter.c | ||
@@ -1408,7 +1408,7 @@ int fg_finalise_bindings(void) | ||
for (int j = 0; j < fg->nb_outputs; j++) { | ||
OutputFilter *output = fg->outputs[j]; | ||
if (!output->bound) { | ||
- av_log(filtergraphs[j], AV_LOG_FATAL, | ||
+ av_log(fg, AV_LOG_FATAL, | ||
"Filter %s has an unconnected output\n", output->name); | ||
return AVERROR(EINVAL); | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/ffmpeg/debian-0006-fftools-log-unconnected-filter-output-label.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
From: Marvin Scholz <epirat07@gmail.com> | ||
Date: Tue, 1 Oct 2024 03:20:04 +0200 | ||
Subject: fftools: log unconnected filter output label | ||
|
||
(cherry picked from commit f25c9cc213c7e3eb585d3339eb775b16921c4d98) | ||
--- | ||
fftools/ffmpeg_filter.c | 4 +++- | ||
1 file changed, 3 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c | ||
index 2f2b297..4e3a47e 100644 | ||
--- a/fftools/ffmpeg_filter.c | ||
+++ b/fftools/ffmpeg_filter.c | ||
@@ -1409,7 +1409,9 @@ int fg_finalise_bindings(void) | ||
OutputFilter *output = fg->outputs[j]; | ||
if (!output->bound) { | ||
av_log(fg, AV_LOG_FATAL, | ||
- "Filter %s has an unconnected output\n", output->name); | ||
+ "Filter '%s' has output %d (%s) unconnected\n", | ||
+ output->name, j, | ||
+ output->linklabel ? (const char *)output->linklabel : "unlabeled"); | ||
return AVERROR(EINVAL); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
packages/ffmpeg/debian-0007-avcodec-libx265-unbreak-build-for-X265_BUILD-213.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
From: Gyan Doshi <ffmpeg@gyani.pro> | ||
Date: Sat, 5 Oct 2024 10:08:31 +0530 | ||
Subject: avcodec/libx265: unbreak build for X265_BUILD >= 213 | ||
|
||
Earlier, x265 made an API change to support alpha and | ||
other multiple layer pictures. We added guards to accommodate | ||
that in 1f801dfdb5 | ||
|
||
They have now reverted that API change in | ||
https://bitbucket.org/multicoreware/x265_git/commits/78e5b703b1 | ||
|
||
Updated our wrapper guards to unbreak build again. | ||
--- | ||
libavcodec/libx265.c | 6 +++--- | ||
1 file changed, 3 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c | ||
index 513f473..63cc497 100644 | ||
--- a/libavcodec/libx265.c | ||
+++ b/libavcodec/libx265.c | ||
@@ -661,7 +661,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | ||
{ | ||
libx265Context *ctx = avctx->priv_data; | ||
x265_picture x265pic; | ||
-#if X265_BUILD >= 210 | ||
+#if (X265_BUILD >= 210) && (X265_BUILD < 213) | ||
x265_picture x265pic_layers_out[MAX_SCALABLE_LAYERS]; | ||
x265_picture* x265pic_lyrptr_out[MAX_SCALABLE_LAYERS]; | ||
#else | ||
@@ -805,7 +805,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | ||
#endif | ||
} | ||
|
||
-#if X265_BUILD >= 210 | ||
+#if (X265_BUILD >= 210) && (X265_BUILD < 213) | ||
for (i = 0; i < MAX_SCALABLE_LAYERS; i++) | ||
x265pic_lyrptr_out[i] = &x265pic_layers_out[i]; | ||
|
||
@@ -844,7 +844,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | ||
pkt->flags |= AV_PKT_FLAG_KEY; | ||
} | ||
|
||
-#if X265_BUILD >= 210 | ||
+#if (X265_BUILD >= 210) && (X265_BUILD < 213) | ||
x265pic_out = x265pic_lyrptr_out[0]; | ||
#else | ||
x265pic_out = &x265pic_solo_out; |
Oops, something went wrong.