summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Negyokru <negyokru@inf.u-szeged.hu>2023-02-01 10:50:05 +0100
committerMartin Negyokru <negyokru@inf.u-szeged.hu>2023-02-13 13:38:02 +0000
commit35c2ba645dd4f643e3621e78f15842807b3600d9 (patch)
tree2cba2b06d4ef5e86e647508061b5899f842e2e6b
parente3f25da075cdcb0d7be140df2249c46e68e33869 (diff)
downloadqtwebengine-chromium-35c2ba645dd4f643e3621e78f15842807b3600d9.tar.gz
FIXUP: Fix building with system ffmpeg 4.4 or 5.1
Revert the change made in ffmpeg_demuxer.cc as it messing up timestamp calculations that makes some mp4s unplayable. This fix breaks the compatibility with system ffmpeg 5.0 and above as chromium tries to use the 'first_dts' value, that has been moved out from public api and it is only available from bundled ffmpeg. See: https://github.com/FFmpeg/FFmpeg/commit/591b88e6787c Fixes: QTBUG-110749 Change-Id: I5786b1a40939d7c9e490ad51ae2e910b8498c71c Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/457644 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 0efb774616745b2e103efbca814b45fa1da0626c) Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/460039 Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--chromium/media/filters/ffmpeg_demuxer.cc20
-rw-r--r--chromium/media/filters/ffmpeg_demuxer.h3
2 files changed, 7 insertions, 16 deletions
diff --git a/chromium/media/filters/ffmpeg_demuxer.cc b/chromium/media/filters/ffmpeg_demuxer.cc
index 1a478f713fe..7b709d70d78 100644
--- a/chromium/media/filters/ffmpeg_demuxer.cc
+++ b/chromium/media/filters/ffmpeg_demuxer.cc
@@ -58,7 +58,7 @@ namespace media {
namespace {
-constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
+constexpr int64_t kInvalidPTSMarker = static_cast<int64_t>(0x8000000000000000);
void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
DCHECK(stream);
@@ -101,7 +101,7 @@ static base::TimeDelta FramesToTimeDelta(int frames, double sample_rate) {
sample_rate);
}
-static base::TimeDelta ExtractStartTime(AVStream* stream, int64_t first_dts) {
+static base::TimeDelta ExtractStartTime(AVStream* stream) {
// The default start time is zero.
base::TimeDelta start_time;
@@ -111,12 +111,12 @@ static base::TimeDelta ExtractStartTime(AVStream* stream, int64_t first_dts) {
// 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 (first_dts != AV_NOPTS_VALUE &&
+ if (av_stream_get_first_dts(stream) != kInvalidPTSMarker &&
stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
const base::TimeDelta first_pts =
- ConvertFromTimeBase(stream->time_base, first_dts);
+ ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
if (first_pts < start_time)
start_time = first_pts;
}
@@ -285,7 +285,6 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(
fixup_negative_timestamps_(false),
fixup_chained_ogg_(false),
num_discarded_packet_warnings_(0),
- first_dts_(AV_NOPTS_VALUE),
last_packet_pos_(AV_NOPTS_VALUE),
last_packet_dts_(AV_NOPTS_VALUE) {
DCHECK(demuxer_);
@@ -352,11 +351,6 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
int64_t packet_dts =
packet->dts == AV_NOPTS_VALUE ? packet->pts : packet->dts;
- if (first_dts_ == AV_NOPTS_VALUE && packet->dts != AV_NOPTS_VALUE &&
- last_packet_dts_ != AV_NOPTS_VALUE) {
- first_dts_ = packet->dts - (last_packet_dts_ + kRelativeTsBase);
- }
-
// Chained ogg files have non-monotonically increasing position and time stamp
// values, which prevents us from using them to determine if a packet should
// be dropped. Since chained ogg is only allowed on single track audio only
@@ -1455,7 +1449,7 @@ void FFmpegDemuxer::OnFindStreamInfoDone(int result) {
max_duration = std::max(max_duration, streams_[i]->duration());
- base::TimeDelta start_time = ExtractStartTime(stream, streams_[i]->first_dts());
+ base::TimeDelta start_time = ExtractStartTime(stream);
// Note: This value is used for seeking, so we must take the true value and
// not the one possibly clamped to zero below.
@@ -1612,7 +1606,7 @@ FFmpegDemuxerStream* FFmpegDemuxer::FindStreamWithLowestStartTimestamp(
for (const auto& stream : streams_) {
if (!stream || stream->IsEnabled() != enabled)
continue;
- if (stream->first_dts() == AV_NOPTS_VALUE)
+ if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
continue;
if (!lowest_start_time_stream ||
stream->start_time() < lowest_start_time_stream->start_time()) {
@@ -1633,7 +1627,7 @@ FFmpegDemuxerStream* FFmpegDemuxer::FindPreferredStreamForSeeking(
if (stream->type() != DemuxerStream::VIDEO)
continue;
- if (stream->first_dts() == AV_NOPTS_VALUE)
+ if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
continue;
if (!stream->IsEnabled())
diff --git a/chromium/media/filters/ffmpeg_demuxer.h b/chromium/media/filters/ffmpeg_demuxer.h
index 6b093318f36..45ab0f348ad 100644
--- a/chromium/media/filters/ffmpeg_demuxer.h
+++ b/chromium/media/filters/ffmpeg_demuxer.h
@@ -152,8 +152,6 @@ class MEDIA_EXPORT FFmpegDemuxerStream : public DemuxerStream {
base::TimeDelta start_time() const { return start_time_; }
void set_start_time(base::TimeDelta time) { start_time_ = time; }
- int64_t first_dts() const { return first_dts_; }
-
private:
friend class FFmpegDemuxerTest;
@@ -211,7 +209,6 @@ class MEDIA_EXPORT FFmpegDemuxerStream : public DemuxerStream {
bool fixup_chained_ogg_;
int num_discarded_packet_warnings_;
- int64_t first_dts_;
int64_t last_packet_pos_;
int64_t last_packet_dts_;
};