diff --git a/0001-qtwebengine-fix-building-with-system-ffmpeg7.1.patch b/0001-qtwebengine-fix-building-with-system-ffmpeg7.1.patch new file mode 100644 index 0000000000000000000000000000000000000000..822b15906d7fa8a6236ee65ba185aaaeab3283e9 --- /dev/null +++ b/0001-qtwebengine-fix-building-with-system-ffmpeg7.1.patch @@ -0,0 +1,537 @@ +From 3cf7fbed8c99818a54c2fd052a55dbe2e1969131 Mon Sep 17 00:00:00 2001 +From: peijiankang +Date: Fri, 14 Feb 2025 17:13:09 +0800 +Subject: [PATCH] qtwebengine-fix-building-with-system-ffmpeg7.1 + +--- + .../clear_key_cdm/ffmpeg_cdm_audio_decoder.cc | 18 ++++++++++-------- + .../chromium/media/ffmpeg/ffmpeg_common.cc | 15 +++++++++------ + .../media/ffmpeg/ffmpeg_regression_tests.cc | 19 +++++++++++-------- + .../media/filters/audio_decoder_unittest.cc | 2 +- + .../media/filters/audio_file_reader.cc | 17 +++++------------ + .../filters/audio_file_reader_unittest.cc | 14 +++++++------- + .../filters/ffmpeg_aac_bitstream_converter.cc | 7 ++++--- + ...ffmpeg_aac_bitstream_converter_unittest.cc | 2 +- + .../media/filters/ffmpeg_audio_decoder.cc | 13 +++++++------ + .../media/filters/ffmpeg_video_decoder.cc | 17 +++++++++++++---- + .../media/filters/ffmpeg_video_decoder.h | 16 ++++++++++++++++ + .../codecs/h264/h264_decoder_impl.cc | 7 ------- + 12 files changed, 84 insertions(+), 63 deletions(-) + +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 dffdbcfa3..c3e9dcf16 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 +@@ -74,7 +74,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) { +@@ -124,8 +124,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; +@@ -185,13 +185,14 @@ bool FFmpegCdmAudioDecoder::Initialize( + // Success! + decoding_loop_ = std::make_unique(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_ = + std::make_unique(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; +@@ -291,7 +292,8 @@ 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_ +@@ -302,7 +304,7 @@ cdm::Status FFmpegCdmAudioDecoder::DecodeBuffer( + } + + 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; +@@ -322,7 +324,7 @@ bool FFmpegCdmAudioDecoder::OnNewFrame( + std::vector>* audio_frames, + AVFrame* frame) { + *total_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); + audio_frames->emplace_back(av_frame_clone(frame)); + return true; +diff --git a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc +index 281d716cb..9c106e16d 100644 +--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc ++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc +@@ -353,10 +353,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 > CHANNEL_LAYOUT_QUAD + ? CHANNEL_LAYOUT_DISCRETE +- : ChannelLayoutToChromeChannelLayout(codec_context->channel_layout, +- codec_context->channels); ++ : ChannelLayoutToChromeChannelLayout( ++ codec_context->ch_layout.u.mask, ++ codec_context->ch_layout.nb_channels); + + switch (codec) { + // For AC3/EAC3 we enable only demuxing, but not decoding, so FFmpeg does +@@ -408,7 +409,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 +@@ -427,7 +428,9 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context, + + // TODO(dalecurtis): Just use the profile from the codec context if ffmpeg + // ever starts supporting xHE-AAC. +- if (codec_context->profile == FF_PROFILE_UNKNOWN) { ++ constexpr uint8_t kXHEAAc = 41; ++ if (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; +@@ -477,7 +480,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 ba7180908..47d2f0d03 100644 +--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_regression_tests.cc ++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_regression_tests.cc +@@ -90,16 +90,16 @@ FFMPEG_TEST_CASE(Cr62127, + PIPELINE_ERROR_DECODE, + PIPELINE_ERROR_DECODE); + 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, +@@ -154,7 +154,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, +@@ -372,8 +375,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_decoder_unittest.cc b/src/3rdparty/chromium/media/filters/audio_decoder_unittest.cc +index e7f422a37..adfd09415 100644 +--- a/src/3rdparty/chromium/media/filters/audio_decoder_unittest.cc ++++ b/src/3rdparty/chromium/media/filters/audio_decoder_unittest.cc +@@ -461,7 +461,7 @@ const TestParams kAudioToolboxTestParams[] = { + {AudioCodec::kAAC, "noise-xhe-aac.mp4", kNoiseXheAAcExpectations, 0, 48000, + CHANNEL_LAYOUT_STEREO}, + {AudioCodec::kAAC, "noise-xhe-aac-mono.mp4", kNoiseMonoXheAAcExpectations, +- 0, 29400, CHANNEL_LAYOUT_MONO}, ++ 0, 29400, CHANNEL_LAYOUT_UNSUPPORTED}, + }; + #endif // BUILDFLAG(IS_MAC) && BUILDFLAG(USE_PROPRIETARY_CODECS) + +diff --git a/src/3rdparty/chromium/media/filters/audio_file_reader.cc b/src/3rdparty/chromium/media/filters/audio_file_reader.cc +index 39ec7b240..200788edc 100644 +--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc ++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc +@@ -113,14 +113,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; +@@ -223,7 +224,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!" +@@ -242,18 +243,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 BUILDFLAG(USE_SYSTEM_FFMPEG) +- if (audio_codec_ == AudioCodec::kAAC && frame->pkt_duration) { +-#else + if (audio_codec_ == AudioCodec::kAAC && frame->duration) { +-#endif // BUILDFLAG(USE_SYSTEM_FFMPEG) + const base::TimeDelta pkt_duration = ConvertFromTimeBase( + glue_->format_context()->streams[stream_index_]->time_base, +-#if BUILDFLAG(USE_SYSTEM_FFMPEG) +- frame->pkt_duration + std::min(static_cast(0), frame->pts)); +-#else + frame->duration + std::min(static_cast(0), frame->pts)); +-#endif // BUILDFLAG(USE_SYSTEM_FFMPEG) + const base::TimeDelta frame_duration = + base::Seconds(frames_read / static_cast(sample_rate_)); + +diff --git a/src/3rdparty/chromium/media/filters/audio_file_reader_unittest.cc b/src/3rdparty/chromium/media/filters/audio_file_reader_unittest.cc +index a1c633d40..5784fe146 100644 +--- a/src/3rdparty/chromium/media/filters/audio_file_reader_unittest.cc ++++ b/src/3rdparty/chromium/media/filters/audio_file_reader_unittest.cc +@@ -61,15 +61,14 @@ class AudioFileReaderTest : public testing::Test { + // Verify packets are consistent across demuxer runs. Reads the first few + // packets and then seeks back to the start timestamp and verifies that the + // hashes match on the packets just read. +- void VerifyPackets() { +- const int kReads = 3; ++ void VerifyPackets(int packet_reads) { + const int kTestPasses = 2; + + AVPacket packet; + base::TimeDelta start_timestamp; + std::vector packet_md5_hashes_; + for (int i = 0; i < kTestPasses; ++i) { +- for (int j = 0; j < kReads; ++j) { ++ for (int j = 0; j < packet_reads; ++j) { + ASSERT_TRUE(reader_->ReadPacketForTesting(&packet)); + + // On the first pass save the MD5 hash of each packet, on subsequent +@@ -98,7 +97,8 @@ class AudioFileReaderTest : public testing::Test { + int sample_rate, + base::TimeDelta duration, + int frames, +- int expected_frames) { ++ int expected_frames, ++ int packet_reads = 3) { + Initialize(fn); + ASSERT_TRUE(reader_->Open()); + EXPECT_EQ(channels, reader_->channels()); +@@ -112,7 +112,7 @@ class AudioFileReaderTest : public testing::Test { + EXPECT_EQ(reader_->HasKnownDuration(), false); + } + if (!packet_verification_disabled_) +- ASSERT_NO_FATAL_FAILURE(VerifyPackets()); ++ ASSERT_NO_FATAL_FAILURE(VerifyPackets(packet_reads)); + ReadAndVerify(hash, expected_frames); + } + +@@ -219,7 +219,7 @@ TEST_F(AudioFileReaderTest, AAC_ADTS) { + } + + TEST_F(AudioFileReaderTest, MidStreamConfigChangesFail) { +- RunTestFailingDecode("midstream_config_change.mp3", 42624); ++ RunTestFailingDecode("midstream_config_change.mp3", 0); + } + #endif + +@@ -229,7 +229,7 @@ TEST_F(AudioFileReaderTest, VorbisInvalidChannelLayout) { + + TEST_F(AudioFileReaderTest, WaveValidFourChannelLayout) { + RunTest("4ch.wav", "131.71,38.02,130.31,44.89,135.98,42.52,", 4, 44100, +- base::Microseconds(100001), 4411, 4410); ++ base::Microseconds(100001), 4411, 4410, /*packet_reads=*/2); + } + + TEST_F(AudioFileReaderTest, ReadPartialMP3) { +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 76b41aa6a..e26b6cd19 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 3b46f7f6b..1897eb098 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 +@@ -34,7 +34,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 46a481de5..be6500139 100644 +--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc ++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc +@@ -28,7 +28,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 +@@ -233,7 +233,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; +@@ -350,11 +350,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_ = DecoderState::kUninitialized; + return false; +@@ -405,7 +405,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); + } +@@ -438,7 +438,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 78195a324..b1c5835ff 100644 +--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc ++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc +@@ -110,7 +110,7 @@ SupportedVideoDecoderConfigs FFmpegVideoDecoder::SupportedConfigsForWebRTC() { + } + + FFmpegVideoDecoder::FFmpegVideoDecoder(MediaLog* media_log) +- : media_log_(media_log) { ++ : media_log_(media_log), timestamp_map_(128) { + DVLOG(1) << __func__; + DETACH_FROM_SEQUENCE(sequence_checker_); + } +@@ -215,7 +215,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. +@@ -354,7 +353,10 @@ bool FFmpegVideoDecoder::FFmpegDecode(const DecoderBuffer& buffer) { + 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(std::make_pair(timestamp_id, timestamp)); ++ packet->opaque = reinterpret_cast(timestamp_id.GetUnsafeValue()); + } + FFmpegDecodingLoop::DecodeStatus decode_status = decoding_loop_->DecodePacket( + packet, base::BindRepeating(&FFmpegVideoDecoder::OnNewFrame, +@@ -394,7 +396,13 @@ bool FFmpegVideoDecoder::OnNewFrame(AVFrame* frame) { + + scoped_refptr video_frame = + reinterpret_cast(av_buffer_get_opaque(frame->buf[0])); +- video_frame->set_timestamp(base::Microseconds(frame->reordered_opaque)); ++ 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; ++ } ++ const auto pts = base::Microseconds(std::get<1>(*ts_lookup)); ++ video_frame->set_timestamp(pts); + video_frame->metadata().power_efficient = false; + output_cb_.Run(video_frame); + return true; +@@ -422,6 +430,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 753651166..0dfd66e61 100644 +--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.h ++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.h +@@ -7,10 +7,12 @@ + + #include + ++#include "base/containers/lru_cache.h" + #include "base/callback.h" + #include "base/memory/raw_ptr.h" + #include "base/memory/ref_counted.h" + #include "base/sequence_checker.h" ++#include "base/types/id_type.h" + #include "media/base/supported_video_decoder_config.h" + #include "media/base/video_decoder.h" + #include "media/base/video_decoder_config.h" +@@ -88,6 +90,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 = base::IdType; ++ ++ TimestampId::Generator timestamp_id_generator_; ++ base::LRUCache timestamp_map_; ++ + VideoDecoderConfig config_; + + VideoFramePool frame_pool_; +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 c96a1c80c..0c6b49ef8 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 +@@ -212,7 +212,6 @@ int H264DecoderImpl::AVGetBuffer2(AVCodecContext* context, + int total_size = y_size + 2 * uv_size; + + av_frame->format = context->pix_fmt; +- av_frame->reordered_opaque = context->reordered_opaque; + + // Create a VideoFrame object, to keep a reference to the buffer. + // TODO(nisse): The VideoFrame's timestamp and rotation info is not used. +@@ -360,8 +359,6 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image, + return WEBRTC_VIDEO_CODEC_ERROR; + } + packet->size = static_cast(input_image.size()); +- int64_t frame_timestamp_us = input_image.ntp_time_ms_ * 1000; // ms -> μs +- av_context_->reordered_opaque = frame_timestamp_us; + + int result = avcodec_send_packet(av_context_.get(), packet.get()); + +@@ -378,10 +375,6 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image, + return WEBRTC_VIDEO_CODEC_ERROR; + } + +- // We don't expect reordering. Decoded frame timestamp should match +- // the input one. +- RTC_DCHECK_EQ(av_frame_->reordered_opaque, frame_timestamp_us); +- + // TODO(sakal): Maybe it is possible to get QP directly from FFmpeg. + h264_bitstream_parser_.ParseBitstream(input_image); + absl::optional qp = h264_bitstream_parser_.GetLastSliceQp(); +-- +2.25.1 + diff --git a/qt6-qtwebengine.spec b/qt6-qtwebengine.spec index 7ce432a4da5c6fefa131d3a84937b622b7a1298a..372b908b5d776625eaf60b53d369402bd0e63d9a 100644 --- a/qt6-qtwebengine.spec +++ b/qt6-qtwebengine.spec @@ -39,7 +39,7 @@ Summary: Qt6 - QtWebEngine components Name: qt6-qtwebengine Version: 6.5.2 -Release: 3 +Release: 4 # See LICENSE.GPL LICENSE.LGPL LGPL_EXCEPTION.txt, for details # See also http://qt-project.org/doc/qt-5.0/qtdoc/licensing.html @@ -89,6 +89,7 @@ Patch111: CVE-2023-6112.patch ExclusiveArch: aarch64 x86_64 riscv64 Patch120: qtwebengine-icu-74.patch +Patch121: 0001-qtwebengine-fix-building-with-system-ffmpeg7.1.patch ## Add riscv64 patches Patch1000: riscv-angle.patch @@ -378,6 +379,7 @@ popd %patch -P111 -p1 %patch -P120 -p1 +%patch -P121 -p1 ## Add riscv64 patches %patch -P1000 -p0 -d src/3rdparty @@ -664,6 +666,9 @@ done %changelog +* Mon Feb 17 2025 peijiankang - 6.5.2-4 +- qtwebengine fix build error with ffmpeg-7.1 + * Wed Nov 20 2024 Funda Wang - 6.5.2-3 - adopt to new cmake macro