Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FFmpeg] chromium patch #38683

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index cd7b0d941c..b4a6dce885 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1010,7 +1010,11 @@ struct AVCodecParserContext *av_stream_get_parser(const AVStream *s);
attribute_deprecated
int64_t av_stream_get_end_pts(const AVStream *st);
#endif

+// Chromium: We use the internal field first_dts vvv
+int64_t av_stream_get_first_dts(const AVStream *st);
+// Chromium: We use the internal field first_dts ^^^
+
#define AV_PROGRAM_RUNNING 1

/**
diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c
index de7580c32d..0ef0fe530e 100644
--- a/libavformat/mux_utils.c
+++ b/libavformat/mux_utils.c
@@ -33,7 +33,14 @@ int64_t av_stream_get_end_pts(const AVStream *st)
return AV_NOPTS_VALUE;
}
#endif

+// Chromium: We use the internal field first_dts vvv
+int64_t av_stream_get_first_dts(const AVStream *st)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this fix been synced upstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No and it wont be. FFMPEG removed previously available API without giving a migration guide, so chromium struggles to remove the usage of this symbol. Please read the discussion in https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://issues.chromium.org/issues/40218408&ved=2ahUKEwjAiNSG5oSGAxVmc_EDHQCIC1IQFnoECA4QAQ&usg=AOvVaw0ZS9B5G7XW78802cwojWfv

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this patch from? Has it been accepted in chromium or elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original the patch was from https://aur.archlinux.org/cgit/aur.git/tree/040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch?h=ffmpeg-intel-full-git but I had to adjust it to the ffmpeg version vcpkg has.

After a bit of googling you can also find it here https://chromium.googlesource.com/chromium/third_party/ffmpeg/+/95aab0fd83619408995720ce53d7a74790580220%5E%21/
However this also seems to be for a different ffmpeg version

I mean you can scan the chromium repo:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/ffmpeg/libavformat/avformat.h;l=1174

https://source.chromium.org/chromium/chromium/src/+/main:third_party/ffmpeg/libavformat/utils.c;l=61?q=av_stream_get_first_dts&sq=&ss=chromium%2Fchromium%2Fsrc

I moved the patch into mux_utils.c since the patch did not apply cleanly and I was looking for where av_stream_get_end_pts from the original patch went. At least it made sense for me to move it there. I can adjust the patch to move it back into utils.c but I don't think it makes any difference for the final library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also av_stream_get_end_pts compared to av_stream_get_first_dts felt kind of related by name.

+{
+ return cffstream(st)->first_dts;
+}
+// Chromium: We use the internal field first_dts ^^^
+
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,
int std_compliance)
{
1 change: 1 addition & 0 deletions ports/ffmpeg/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ vcpkg_from_github(
0015-Fix-xml2-detection.patch
0020-fix-aarch64-libswscale.patch
0022-fix-iconv.patch
0040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch # Do not remove this patch. It is required by chromium
)

if(SOURCE_PATH MATCHES " ")
Expand Down
2 changes: 1 addition & 1 deletion ports/ffmpeg/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ffmpeg",
"version": "6.1.1",
"port-version": 3,
"port-version": 4,
"description": [
"a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.",
"FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations."
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2682,7 +2682,7 @@
},
"ffmpeg": {
"baseline": "6.1.1",
"port-version": 3
"port-version": 4
},
"ffnvcodec": {
"baseline": "12.1.14.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/f-/ffmpeg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "7397470052111240d798a30281927bba3547a29b",
"version": "6.1.1",
"port-version": 4
},
{
"git-tree": "ae4cdc508093fc27af3254a179ec568e0f7f2add",
"version": "6.1.1",
Expand Down