From 9e737aef397ea17b52375390cb44b1b9114c2a13 Mon Sep 17 00:00:00 2001 From: misaka00251 Date: Fri, 7 Mar 2025 22:36:38 +0800 Subject: [PATCH] Fix build on riscv64 --- qt5-qtwebengine.spec | 15 +- ...engine-everywhere-5.15.5-use-python2.patch | 35 -- ...patch => riscv-Fix-build-with-ffmpeg.patch | 55 ++- riscv-qt5-webengine-ffmpeg7.patch | 427 ++++++++++++++++++ 4 files changed, 465 insertions(+), 67 deletions(-) delete mode 100644 qtwebengine-everywhere-5.15.5-use-python2.patch rename qtwebengine-ffmpeg5.patch => riscv-Fix-build-with-ffmpeg.patch (92%) create mode 100644 riscv-qt5-webengine-ffmpeg7.patch diff --git a/qt5-qtwebengine.spec b/qt5-qtwebengine.spec index 770e788..9cdca8c 100644 --- a/qt5-qtwebengine.spec +++ b/qt5-qtwebengine.spec @@ -52,7 +52,7 @@ Summary: Qt5 - QtWebEngine components Name: qt5-qtwebengine Version: 5.15.10 -Release: 6 +Release: 7 # See LICENSE.GPL LICENSE.LGPL LGPL_EXCEPTION.txt, for details # See also http://qt-project.org/doc/qt-5.0/qtdoc/licensing.html @@ -123,12 +123,11 @@ Patch53: fix-build-tools-to-run-with-python3.11.patch # bit-field.h:43:29: error: integer value 7 is outside the valid range of values [0, 3] for the enumeration type 'Kind' Patch54: fix-qt5-qtwebengine-build-with-clang-17.patch -%ifarch riscv64 # riscv64 support patch from Arch Linux Patch1000: riscv-v8.patch Patch1001: riscv-qt5-qtwebengine.patch -Patch1002: qtwebengine-ffmpeg5.patch -%endif +Patch1002: riscv-Fix-build-with-ffmpeg.patch +Patch1003: riscv-qt5-webengine-ffmpeg7.patch BuildRequires: make BuildRequires: qt5-qtbase-devel @@ -224,8 +223,6 @@ BuildRequires: libnsl2 BuildRequires: python-rpm-macros %ifarch riscv64 -# collect2: fatal error: cannot find 'ld' -BuildRequires: lld # We don't use bundled ffmpeg BuildRequires: pkgconfig(libavcodec) BuildRequires: pkgconfig(libavformat) @@ -444,7 +441,8 @@ popd %ifarch riscv64 %patch1000 -p1 -b .riscv-v8 %patch1001 -p1 -b .riscv-qt5-qtwebengine -%patch1002 -p1 -b .qtwebengine-ffmpeg5 +%patch -P1002 -p1 -b .riscv-qt5-webengine-ffmpeg7 +%patch -P1003 -p1 -b .riscv-Fix-build-with-ffmpeg %endif # delete all "toolprefix = " lines from build/toolchain/linux/BUILD.gn, as we @@ -665,6 +663,9 @@ done %changelog +* Fri Mar 07 2025 misaka00251 - 5.15.10-7 +- Fix build on riscv64 + * Wed Apr 03 2024 misaka00251 - 5.15.10-6 - Migrate python 2 to python 3 & Fix build on riscv64 diff --git a/qtwebengine-everywhere-5.15.5-use-python2.patch b/qtwebengine-everywhere-5.15.5-use-python2.patch deleted file mode 100644 index 9626d27..0000000 --- a/qtwebengine-everywhere-5.15.5-use-python2.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/generate.py b/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/generate.py -index 8af373102..b551c0fe2 100644 ---- a/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/generate.py -+++ b/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/generate.py -@@ -83,7 +83,7 @@ def _MinifyJS(input_js): - - with tempfile.NamedTemporaryFile() as _: - args = [ -- 'python', -+ 'python2', - rjsmin_path - ] - p = subprocess.Popen(args, -@@ -203,7 +203,7 @@ def _MinifyCSS(css_text): - os.path.join(py_vulcanize_path, 'third_party', 'rcssmin', 'rcssmin.py')) - - with tempfile.NamedTemporaryFile() as _: -- rcssmin_args = ['python', rcssmin_path] -+ rcssmin_args = ['python2', rcssmin_path] - p = subprocess.Popen(rcssmin_args, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, -diff --git a/src/webengine/module.pro b/src/webengine/module.pro -index 49a1086b2..afc89d49e 100644 ---- a/src/webengine/module.pro -+++ b/src/webengine/module.pro -@@ -76,7 +76,7 @@ qtConfig(webengine-testsupport) { - python = $$pythonPathForShell() - chromium_attributions.commands = \ - cd $$shell_quote($$shell_path($$PWD/../3rdparty)) && \ -- $$python chromium/tools/licenses.py \ -+ python2 chromium/tools/licenses.py \ - --file-template ../../tools/about_credits.tmpl \ - --entry-template ../../tools/about_credits_entry.tmpl credits \ - $$shell_quote($$shell_path($$OUT_PWD/chromium_attributions.qdoc)) diff --git a/qtwebengine-ffmpeg5.patch b/riscv-Fix-build-with-ffmpeg.patch similarity index 92% rename from qtwebengine-ffmpeg5.patch rename to riscv-Fix-build-with-ffmpeg.patch index 87f259e..1c8f3a0 100644 --- a/qtwebengine-ffmpeg5.patch +++ b/riscv-Fix-build-with-ffmpeg.patch @@ -1,8 +1,12 @@ -Allow building qtwebengine using ffmpeg 5 -Origin: ArchLinux, https://github.com/archlinux/svntogit-packages/tree/packages/qt5-webengine/trunk +From 08bb68ad429cb7b30fb676a27ee7ac0c75f4fb8f Mon Sep 17 00:00:00 2001 +From: Antonio Rojas +Date: Thu, 6 Mar 2025 15:51:18 +0800 +Subject: [PATCH] Fix build with ffmpeg 5 + +Signed-off-by: Xin Liu diff --git a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h -index 2734a48..70b1877 100644 +index 2734a485c..70b1877a4 100644 --- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h +++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h @@ -29,6 +29,7 @@ extern "C" { @@ -14,12 +18,12 @@ index 2734a48..70b1877 100644 #include #include diff --git a/src/3rdparty/chromium/media/filters/audio_file_reader.cc b/src/3rdparty/chromium/media/filters/audio_file_reader.cc -index cb81d92..bd73908 100644 +index 6261ee988..2b3abba8b 100644 --- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc +++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc @@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() { } - + bool AudioFileReader::OpenDecoder() { - AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); + const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); @@ -27,24 +31,24 @@ index cb81d92..bd73908 100644 // MP3 decodes to S16P which we don't support, tell it to use S16 instead. if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P) diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc -index 0d825ed..72fac61 100644 +index acf91d81e..0d198c091 100644 --- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc +++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc @@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecoder(const AudioDecoderConfig& config) { } } - + - AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); + const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); if (!codec || avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) { DLOG(ERROR) << "Could not initialize audio decoder: " diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc -index d34db63..427565b 100644 +index d34db63f3..427565b00 100644 --- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc +++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc @@ -98,12 +98,12 @@ static base::TimeDelta ExtractStartTime(AVStream* stream) { - + // Next try to use the first DTS value, for codecs where we know PTS == DTS // (excludes all H26x codecs). The start time must be returned in PTS. - if (stream->first_dts != kNoFFmpegTimestamp && @@ -60,18 +64,18 @@ index d34db63..427565b 100644 } @@ -408,11 +408,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) { scoped_refptr buffer; - + if (type() == DemuxerStream::TEXT) { - int id_size = 0; + size_t id_size = 0; uint8_t* id_data = av_packet_get_side_data( packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size); - + - int settings_size = 0; + size_t settings_size = 0; uint8_t* settings_data = av_packet_get_side_data( packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size); - + @@ -424,7 +424,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) { buffer = DecoderBuffer::CopyFrom(packet->data, packet->size, side_data.data(), side_data.size()); @@ -80,32 +84,32 @@ index d34db63..427565b 100644 + size_t side_data_size = 0; uint8_t* side_data = av_packet_get_side_data( packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); - + @@ -485,7 +485,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) { packet->size - data_offset); } - + - int skip_samples_size = 0; + size_t skip_samples_size = 0; const uint32_t* skip_samples_ptr = reinterpret_cast(av_packet_get_side_data( packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size)); diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc -index 0ef3521..8483ecc 100644 +index 0ef352147..8483ecc34 100644 --- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc +++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc @@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* opaque, int64_t offset, int whence) { } - + void FFmpegGlue::InitializeFFmpeg() { - av_register_all(); } - + static void LogContainer(bool is_local_file, @@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol* protocol) { // Enable fast, but inaccurate seeks for MP3. format_context_->flags |= AVFMT_FLAG_FAST_SEEK; - + - // Ensures we can read out various metadata bits like vp8 alpha. - format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA; - @@ -113,20 +117,20 @@ index 0ef3521..8483ecc 100644 // instances were real failures. Solves bugs like http://crbug.com/710791. format_context_->error_recognition |= AV_EF_EXPLODE; diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc -index ef12477..7996606 100644 +index 45c30a02e..712fe6271 100644 --- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc +++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc -@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config, +@@ -398,7 +398,7 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config, if (decode_nalus_) codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS; - + - AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); + const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { ReleaseFFmpegResources(); return false; diff --git a/src/3rdparty/chromium/media/filters/media_file_checker.cc b/src/3rdparty/chromium/media/filters/media_file_checker.cc -index 59c2a2f..1a9872c 100644 +index 59c2a2fc6..1a9872c7a 100644 --- a/src/3rdparty/chromium/media/filters/media_file_checker.cc +++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc @@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeDelta check_time) { @@ -139,16 +143,17 @@ index 59c2a2f..1a9872c 100644 auto loop = std::make_unique(context.get()); stream_contexts[i] = {std::move(context), std::move(loop)}; diff --git a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc -index 9002b87..d12fade 100644 +index 9002b8746..d12fade8b 100644 --- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc +++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc @@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(const VideoCodec* codec_settings, // a pointer |this|. av_context_->opaque = this; - + - AVCodec* codec = avcodec_find_decoder(av_context_->codec_id); + const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id); if (!codec) { // This is an indication that FFmpeg has not been initialized or it has not // been compiled/initialized with the correct set of codecs. - +-- +2.48.1 diff --git a/riscv-qt5-webengine-ffmpeg7.patch b/riscv-qt5-webengine-ffmpeg7.patch new file mode 100644 index 0000000..9d4de35 --- /dev/null +++ b/riscv-qt5-webengine-ffmpeg7.patch @@ -0,0 +1,427 @@ +From 9b649e1c49617fba134be6ef50aac03bcd7a506a Mon Sep 17 00:00:00 2001 +From: Dale Curtis +Date: Thu, 6 Mar 2025 13:03:29 +0800 +Subject: [PATCH] Roll src/3rdparty/chromium/third_party/ffmpeg/ + 574c39cce..32b2d1d526 (1125 commits) + +https://chromium.googlesource.com/chromium/third_party/ffmpeg.git/+log/574c39cce323..32b2d1d526 + +Created with: + roll-dep src/3rdparty/chromium/third_party/ffmpeg + +Fixed: 1293918 +Cq-Include-Trybots: luci.chromium.try:mac_chromium_asan_rel_ng,linux_chromium_asan_rel_ng,linux_chromium_chromeos_asan_rel_ng +Change-Id: I41945d0f963e3d1f65940067bac22f63b68e37d2 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/3rdparty/chromium/+/3565647 +Auto-Submit: Dale Curtis +Reviewed-by: Dan Sanders +Commit-Queue: Dale Curtis +Cr-Commit-Position: refs/heads/main@{#988253} +Signed-off-by: Xin Liu + +diff --git a/src/3rdparty/chromium/media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.cc b/src/3rdparty/chromium/media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.cc +index a043005d5..69ef5ccaa 100644 +--- a/src/3rdparty/chromium/media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.cc ++++ b/src/3rdparty/chromium/media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.cc +@@ -73,7 +73,7 @@ void CdmAudioDecoderConfigToAVCodecContext( + codec_context->sample_fmt = AV_SAMPLE_FMT_NONE; + } + +- codec_context->channels = config.channel_count; ++ codec_context->ch_layout.nb_channels = config.channel_count; + codec_context->sample_rate = config.samples_per_second; + + if (config.extra_data) { +@@ -123,8 +123,8 @@ void CopySamples(cdm::AudioFormat cdm_format, + case cdm::kAudioFormatPlanarS16: + case cdm::kAudioFormatPlanarF32: { + const int decoded_size_per_channel = +- decoded_audio_size / av_frame.channels; +- for (int i = 0; i < av_frame.channels; ++i) { ++ decoded_audio_size / av_frame.ch_layout.nb_channels; ++ for (int i = 0; i < av_frame.ch_layout.nb_channels; ++i) { + memcpy(output_buffer, av_frame.extended_data[i], + decoded_size_per_channel); + output_buffer += decoded_size_per_channel; +@@ -184,13 +184,14 @@ bool FFmpegCdmAudioDecoder::Initialize( + // Success! + decoding_loop_.reset(new FFmpegDecodingLoop(codec_context_.get())); + samples_per_second_ = config.samples_per_second; +- bytes_per_frame_ = codec_context_->channels * config.bits_per_channel / 8; ++ bytes_per_frame_ = ++ codec_context_->ch_layout.nb_channels * config.bits_per_channel / 8; + output_timestamp_helper_.reset( + new AudioTimestampHelper(config.samples_per_second)); + is_initialized_ = true; + + // Store initial values to guard against midstream configuration changes. +- channels_ = codec_context_->channels; ++ channels_ = codec_context_->ch_layout.nb_channels; + av_sample_format_ = codec_context_->sample_fmt; + + return true; +@@ -290,17 +291,18 @@ cdm::Status FFmpegCdmAudioDecoder::DecodeBuffer( + for (auto& frame : audio_frames) { + int decoded_audio_size = 0; + if (frame->sample_rate != samples_per_second_ || +- frame->channels != channels_ || frame->format != av_sample_format_) { ++ frame->ch_layout.nb_channels != channels_ || ++ frame->format != av_sample_format_) { + DLOG(ERROR) << "Unsupported midstream configuration change!" + << " Sample Rate: " << frame->sample_rate << " vs " + << samples_per_second_ << ", Channels: " << frame->channels +- << " vs " << channels_ << ", Sample Format: " << frame->format ++ << samples_per_second_ << ", Channels: " << frame->ch_layout.nb_channels + << " vs " << av_sample_format_; + return cdm::kDecodeError; + } + + decoded_audio_size = av_samples_get_buffer_size( +- nullptr, codec_context_->channels, frame->nb_samples, ++ nullptr, codec_context_->ch_layout.nb_channels, frame->nb_samples, + codec_context_->sample_fmt, 1); + if (!decoded_audio_size) + continue; +@@ -319,7 +321,7 @@ bool FFmpegCdmAudioDecoder::OnNewFrame( + size_t* total_size, + std::vector>* audio_frames, + AVFrame* frame) { +- *total_size += av_samples_get_buffer_size(nullptr, codec_context_->channels, ++ *total_size += av_samples_get_buffer_size(nullptr, codec_context_->ch_layout.nb_channels, + frame->nb_samples, + codec_context_->sample_fmt, 1); + audio_frames->emplace_back(av_frame_clone(frame)); +diff --git a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc +index c17dd9f83..c47791bda 100644 +--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc ++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc +@@ -341,10 +341,11 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, + codec_context->sample_fmt, codec_context->codec_id); + + ChannelLayout channel_layout = +- codec_context->channels > 8 ++ codec_context->ch_layout.nb_channels > 88 + ? CHANNEL_LAYOUT_DISCRETE +- : ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, +- codec_context->channels); ++ : ChannelLayoutToChromeChannelLayout( ++ codec_context->ch_layout.u.mask, ++ codec_context->ch_layout.nb_channels); + + int sample_rate = codec_context->sample_rate; + switch (codec) { +@@ -397,7 +398,7 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, + extra_data, encryption_scheme, seek_preroll, + codec_context->delay); + if (channel_layout == CHANNEL_LAYOUT_DISCRETE) +- config->SetChannelsForDiscrete(codec_context->channels); ++ config->SetChannelsForDiscrete(codec_context->ch_layout.nb_channels); + + #if BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO) + // These are bitstream formats unknown to ffmpeg, so they don't have +@@ -413,7 +414,9 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, + #if BUILDFLAG(USE_PROPRIETARY_CODECS) + // TODO(dalecurtis): Just use the profile from the codec context if ffmpeg + // ever starts supporting xHE-AAC. +- if (codec == kCodecAAC && codec_context->profile == FF_PROFILE_UNKNOWN) { ++ constexpr uint8_t kXHEAAc = 41; ++ if (codec == kCodecAAC && codec_context->profile == FF_PROFILE_UNKNOWN || ++ codec_context->profile == kXHEAAc) { + // Errors aren't fatal here, so just drop any MediaLog messages. + NullMediaLog media_log; + mp4::AAC aac_parser; +@@ -462,7 +465,7 @@ void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config, + + // TODO(scherkus): should we set |channel_layout|? I'm not sure if FFmpeg uses + // said information to decode. +- codec_context->channels = config.channels(); ++ codec_context->ch_layout.nb_channels = config.channels(); + codec_context->sample_rate = config.samples_per_second(); + + if (config.extra_data().empty()) { +diff --git a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_regression_tests.cc b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_regression_tests.cc +index ebd1babb4..04d5eccf6 100644 +--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_regression_tests.cc ++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_regression_tests.cc +@@ -86,16 +86,16 @@ FFMPEG_TEST_CASE(Cr47761, "crbug47761.ogg", PIPELINE_OK, PIPELINE_OK); + FFMPEG_TEST_CASE(Cr50045, "crbug50045.mp4", PIPELINE_OK, PIPELINE_OK); + FFMPEG_TEST_CASE(Cr62127, "crbug62127.webm", PIPELINE_OK, PIPELINE_OK); + FFMPEG_TEST_CASE(Cr93620, "security/93620.ogg", PIPELINE_OK, PIPELINE_OK); +-FFMPEG_TEST_CASE(Cr100492, +- "security/100492.webm", +- DECODER_ERROR_NOT_SUPPORTED, +- DECODER_ERROR_NOT_SUPPORTED); ++FFMPEG_TEST_CASE(Cr100492, "security/100492.webm", PIPELINE_OK, PIPELINE_OK); + FFMPEG_TEST_CASE(Cr100543, "security/100543.webm", PIPELINE_OK, PIPELINE_OK); + FFMPEG_TEST_CASE(Cr101458, + "security/101458.webm", + PIPELINE_ERROR_DECODE, + PIPELINE_ERROR_DECODE); +-FFMPEG_TEST_CASE(Cr108416, "security/108416.webm", PIPELINE_OK, PIPELINE_OK); ++FFMPEG_TEST_CASE(Cr108416, ++ "security/108416.webm", ++ PIPELINE_ERROR_DECODE, ++ PIPELINE_ERROR_DECODE); + FFMPEG_TEST_CASE(Cr110849, + "security/110849.mkv", + DEMUXER_ERROR_COULD_NOT_OPEN, +@@ -150,7 +150,10 @@ FFMPEG_TEST_CASE(Cr234630b, + "security/234630b.mov", + DEMUXER_ERROR_NO_SUPPORTED_STREAMS, + DEMUXER_ERROR_NO_SUPPORTED_STREAMS); +-FFMPEG_TEST_CASE(Cr242786, "security/242786.webm", PIPELINE_OK, PIPELINE_OK); ++FFMPEG_TEST_CASE(Cr242786, ++ "security/242786.webm", ++ PIPELINE_OK, ++ PIPELINE_ERROR_DECODE); + // Test for out-of-bounds access with slightly corrupt file (detection logic + // thinks it's a MONO file, but actually contains STEREO audio). + FFMPEG_TEST_CASE(Cr275590, +@@ -371,8 +374,8 @@ FFMPEG_TEST_CASE(WEBM_2, + DEMUXER_ERROR_NO_SUPPORTED_STREAMS); + FFMPEG_TEST_CASE(WEBM_4, + "security/out.webm.68798.1929", +- DECODER_ERROR_NOT_SUPPORTED, +- DECODER_ERROR_NOT_SUPPORTED); ++ PIPELINE_OK, ++ PIPELINE_OK); + FFMPEG_TEST_CASE(WEBM_5, "frame_size_change.webm", PIPELINE_OK, PIPELINE_OK); + + // General MKV test cases. +diff --git a/src/3rdparty/chromium/media/filters/audio_file_reader.cc b/src/3rdparty/chromium/media/filters/audio_file_reader.cc +index cb81d920d..6261ee988 100644 +--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc ++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc +@@ -112,14 +112,15 @@ bool AudioFileReader::OpenDecoder() { + + // Verify the channel layout is supported by Chrome. Acts as a sanity check + // against invalid files. See http://crbug.com/171962 +- if (ChannelLayoutToChromeChannelLayout(codec_context_->channel_layout, +- codec_context_->channels) == ++ if (ChannelLayoutToChromeChannelLayout( ++ codec_context_->ch_layout.u.mask, ++ codec_context_->ch_layout.nb_channels) == + CHANNEL_LAYOUT_UNSUPPORTED) { + return false; + } + + // Store initial values to guard against midstream configuration changes. +- channels_ = codec_context_->channels; ++ channels_ = codec_context_->ch_layout.nb_channels; + audio_codec_ = CodecIDToAudioCodec(codec_context_->codec_id); + sample_rate_ = codec_context_->sample_rate; + av_sample_format_ = codec_context_->sample_fmt; +@@ -222,7 +223,7 @@ bool AudioFileReader::OnNewFrame( + if (frames_read < 0) + return false; + +- const int channels = frame->channels; ++ const int channels = frame->ch_layout.nb_channels; + if (frame->sample_rate != sample_rate_ || channels != channels_ || + frame->format != av_sample_format_) { + DLOG(ERROR) << "Unsupported midstream configuration change!" +@@ -241,10 +242,10 @@ bool AudioFileReader::OnNewFrame( + // silence from being output. In the case where we are also discarding some + // portion of the packet (as indicated by a negative pts), we further want to + // adjust the duration downward by however much exists before zero. +- if (audio_codec_ == kCodecAAC && frame->pkt_duration) { ++ if (audio_codec_ == kCodecAAC && frame->duration) { + const base::TimeDelta pkt_duration = ConvertFromTimeBase( + glue_->format_context()->streams[stream_index_]->time_base, +- frame->pkt_duration + std::min(static_cast(0), frame->pts)); ++ frame->duration + std::min(static_cast(0), frame->pts)); + const base::TimeDelta frame_duration = base::TimeDelta::FromSecondsD( + frames_read / static_cast(sample_rate_)); + +diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_aac_bitstream_converter.cc b/src/3rdparty/chromium/media/filters/ffmpeg_aac_bitstream_converter.cc +index 6f231c857..ca5e5fb92 100644 +--- a/src/3rdparty/chromium/media/filters/ffmpeg_aac_bitstream_converter.cc ++++ b/src/3rdparty/chromium/media/filters/ffmpeg_aac_bitstream_converter.cc +@@ -195,14 +195,15 @@ bool FFmpegAACBitstreamConverter::ConvertPacket(AVPacket* packet) { + if (!header_generated_ || codec_ != stream_codec_parameters_->codec_id || + audio_profile_ != stream_codec_parameters_->profile || + sample_rate_index_ != sample_rate_index || +- channel_configuration_ != stream_codec_parameters_->channels || ++ channel_configuration_ != ++ stream_codec_parameters_->ch_layout.nb_channels || + frame_length_ != header_plus_packet_size) { + header_generated_ = + GenerateAdtsHeader(stream_codec_parameters_->codec_id, + 0, // layer + stream_codec_parameters_->profile, sample_rate_index, + 0, // private stream +- stream_codec_parameters_->channels, ++ stream_codec_parameters_->ch_layout.nb_channels, + 0, // originality + 0, // home + 0, // copyrighted_stream +@@ -214,7 +215,7 @@ bool FFmpegAACBitstreamConverter::ConvertPacket(AVPacket* packet) { + codec_ = stream_codec_parameters_->codec_id; + audio_profile_ = stream_codec_parameters_->profile; + sample_rate_index_ = sample_rate_index; +- channel_configuration_ = stream_codec_parameters_->channels; ++ channel_configuration_ = stream_codec_parameters_->ch_layout.nb_channels; + frame_length_ = header_plus_packet_size; + } + +diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_aac_bitstream_converter_unittest.cc b/src/3rdparty/chromium/media/filters/ffmpeg_aac_bitstream_converter_unittest.cc +index ac8bb1357..3e4e3f6ca 100644 +--- a/src/3rdparty/chromium/media/filters/ffmpeg_aac_bitstream_converter_unittest.cc ++++ b/src/3rdparty/chromium/media/filters/ffmpeg_aac_bitstream_converter_unittest.cc +@@ -29,7 +29,7 @@ class FFmpegAACBitstreamConverterTest : public testing::Test { + memset(&test_parameters_, 0, sizeof(AVCodecParameters)); + test_parameters_.codec_id = AV_CODEC_ID_AAC; + test_parameters_.profile = FF_PROFILE_AAC_MAIN; +- test_parameters_.channels = 2; ++ test_parameters_.ch_layout.nb_channels = 2; + test_parameters_.extradata = extradata_header_; + test_parameters_.extradata_size = sizeof(extradata_header_); + } +diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc +index 0d825ed79..acf91d81e 100644 +--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc ++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc +@@ -27,7 +27,7 @@ namespace media { + + // Return the number of channels from the data in |frame|. + static inline int DetermineChannels(AVFrame* frame) { +- return frame->channels; ++ return frame->ch_layout.nb_channels; + } + + // Called by FFmpeg's allocation routine to allocate a buffer. Uses +@@ -227,7 +227,7 @@ bool FFmpegAudioDecoder::OnNewFrame(const DecoderBuffer& buffer, + // Translate unsupported into discrete layouts for discrete configurations; + // ffmpeg does not have a labeled discrete configuration internally. + ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout( +- codec_context_->channel_layout, codec_context_->channels); ++ codec_context_->ch_layout.u.mask, codec_context_->ch_layout.nb_channels); + if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED && + config_.channel_layout() == CHANNEL_LAYOUT_DISCRETE) { + channel_layout = CHANNEL_LAYOUT_DISCRETE; +@@ -344,11 +344,11 @@ bool FFmpegAudioDecoder::ConfigureDecoder(const AudioDecoderConfig& config) { + // Success! + av_sample_format_ = codec_context_->sample_fmt; + +- if (codec_context_->channels != config.channels()) { ++ if (codec_context_->ch_layout.nb_channels != config.channels()) { + MEDIA_LOG(ERROR, media_log_) + << "Audio configuration specified " << config.channels() + << " channels, but FFmpeg thinks the file contains " +- << codec_context_->channels << " channels"; ++ << codec_context_->ch_layout.nb_channels << " channels"; + ReleaseFFmpegResources(); + state_ = kUninitialized; + return false; +@@ -398,7 +398,7 @@ int FFmpegAudioDecoder::GetAudioBuffer(struct AVCodecContext* s, + if (frame->nb_samples <= 0) + return AVERROR(EINVAL); + +- if (s->channels != channels) { ++ if (s->ch_layout.nb_channels != channels) { + DLOG(ERROR) << "AVCodecContext and AVFrame disagree on channel count."; + return AVERROR(EINVAL); + } +@@ -431,7 +431,8 @@ int FFmpegAudioDecoder::GetAudioBuffer(struct AVCodecContext* s, + ChannelLayout channel_layout = + config_.channel_layout() == CHANNEL_LAYOUT_DISCRETE + ? CHANNEL_LAYOUT_DISCRETE +- : ChannelLayoutToChromeChannelLayout(s->channel_layout, s->channels); ++ : ChannelLayoutToChromeChannelLayout(s->ch_layout.u.mask, ++ s->ch_layout.nb_channels); + + if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED) { + DLOG(ERROR) << "Unsupported channel layout."; +diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc +index ef12477ee..45c30a02e 100644 +--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc ++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc +@@ -86,7 +86,7 @@ bool FFmpegVideoDecoder::IsCodecSupported(VideoCodec codec) { + } + + FFmpegVideoDecoder::FFmpegVideoDecoder(MediaLog* media_log) +- : media_log_(media_log), state_(kUninitialized), decode_nalus_(false) { ++ : media_log_(media_log), state_(kUninitialized), decode_nalus_(false), timestamp_map_(128) { + DVLOG(1) << __func__; + thread_checker_.DetachFromThread(); + } +@@ -183,7 +183,6 @@ int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context, + frame->width = coded_size.width(); + frame->height = coded_size.height(); + frame->format = codec_context->pix_fmt; +- frame->reordered_opaque = codec_context->reordered_opaque; + + // Now create an AVBufferRef for the data just allocated. It will own the + // reference to the VideoFrame object. +@@ -318,8 +317,10 @@ bool FFmpegVideoDecoder::FFmpegDecode(const DecoderBuffer& buffer) { + DCHECK(packet.data); + DCHECK_GT(packet.size, 0); + +- // Let FFmpeg handle presentation timestamp reordering. +- codec_context_->reordered_opaque = buffer.timestamp().InMicroseconds(); ++ const int64_t timestamp = buffer.timestamp().InMicroseconds(); ++ const TimestampId timestamp_id = timestamp_id_generator_.GenerateNextId(); ++ timestamp_map_.Put(timestamp_id, timestamp); ++ packet.opaque = reinterpret_cast(timestamp_id.GetUnsafeValue()); + } + + switch (decoding_loop_->DecodePacket( +@@ -358,8 +359,13 @@ bool FFmpegVideoDecoder::OnNewFrame(AVFrame* frame) { + + scoped_refptr video_frame = + reinterpret_cast(av_buffer_get_opaque(frame->buf[0])); ++ const auto ts_id = TimestampId(reinterpret_cast(frame->opaque)); ++ const auto ts_lookup = timestamp_map_.Get(ts_id); ++ if (ts_lookup == timestamp_map_.end()) { ++ return false; ++ } + video_frame->set_timestamp( +- base::TimeDelta::FromMicroseconds(frame->reordered_opaque)); ++ base::TimeDelta::FromMicroseconds(std::get<1>(*ts_lookup))); + video_frame->metadata()->power_efficient = false; + output_cb_.Run(video_frame); + return true; +@@ -387,6 +393,7 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config, + FF_THREAD_SLICE | (low_delay ? 0 : FF_THREAD_FRAME); + codec_context_->opaque = this; + codec_context_->get_buffer2 = GetVideoBufferImpl; ++ codec_context_->flags |= AV_CODEC_FLAG_COPY_OPAQUE; + + if (decode_nalus_) + codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS; +diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.h b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.h +index f13ce417f..ee2444b0f 100644 +--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.h ++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.h +@@ -8,6 +8,8 @@ + #include + #include + ++#include "base/containers/mru_cache.h" ++#include "base/util/type_safety/id_type.h" + #include "base/callback.h" + #include "base/macros.h" + #include "base/memory/ref_counted.h" +@@ -85,6 +87,20 @@ class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { + // FFmpeg structures owned by this object. + std::unique_ptr codec_context_; + ++ // The gist here is that timestamps need to be 64 bits to store microsecond ++ // precision. A 32 bit integer would overflow at ~35 minutes at this level of ++ // precision. We can't cast the timestamp to the void ptr object used by the ++ // opaque field in ffmpeg then, because it would lose data on a 32 bit build. ++ // However, we don't actually have 2^31 timestamped frames in a single ++ // playback, so it's fine to use the 32 bit value as a key in a map which ++ // contains the actual timestamps. Additionally, we've in the past set 128 ++ // outstanding frames for re-ordering as a limit for cross-thread decoding ++ // tasks, so we'll do that here too with the LRU cache. ++ using TimestampId = util::IdType; ++ ++ TimestampId::Generator timestamp_id_generator_; ++ base::MRUCache timestamp_map_; ++ + VideoDecoderConfig config_; + + VideoFramePool frame_pool_; +-- +2.48.1 -- Gitee