1 From 0b53fcfa8ee76ccc2d77abb947810f631efaecd9 Mon Sep 17 00:00:00 2001
2 From: Thomas Deutschmann <whissi@gentoo.org>
3 Date: Fri, 11 Dec 2020 15:37:38 +0100
4 Subject: [PATCH 29/30] bmo#1670333: OpenH264: Fix decoding if it starts on non
5 IDR I-frame
6
7 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
8 ---
9 dom/media/mp4/MP4Demuxer.cpp | 8 ++++++++
10 dom/media/platforms/PDMFactory.cpp | 15 ++++++++++-----
11 dom/media/platforms/PDMFactory.h | 2 ++
12 3 files changed, 20 insertions(+), 5 deletions(-)
13
14 diff --git a/dom/media/mp4/MP4Demuxer.cpp b/dom/media/mp4/MP4Demuxer.cpp
15 index 59bba16577..0304e3e89f 100644
16 --- a/dom/media/mp4/MP4Demuxer.cpp
17 +++ b/dom/media/mp4/MP4Demuxer.cpp
18 @@ -31,6 +31,8 @@ mozilla::LogModule* GetDemuxerLog() { return gMediaDemuxerLog; }
19 DDMOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, "::%s: " arg, \
20 __func__, ##__VA_ARGS__)
21
22 +extern bool gUseKeyframeFromContainer;
23 +
24 namespace mozilla {
25
26 DDLoggedTypeDeclNameAndBase(MP4TrackDemuxer, MediaTrackDemuxer);
27 @@ -394,6 +396,12 @@ already_AddRefed<MediaRawData> MP4TrackDemuxer::GetNextSample() {
28 [[fallthrough]];
29 case H264::FrameType::OTHER: {
30 bool keyframe = type == H264::FrameType::I_FRAME;
31 + if (gUseKeyframeFromContainer) {
32 + if (sample->mKeyframe && sample->mKeyframe != keyframe) {
33 + sample->mKeyframe = keyframe;
34 + }
35 + break;
36 + }
37 if (sample->mKeyframe != keyframe) {
38 NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe "
39 "@ pts:%" PRId64 " dur:%" PRId64
40 diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp
41 index 4e377082ae..e778eb9948 100644
42 --- a/dom/media/platforms/PDMFactory.cpp
43 +++ b/dom/media/platforms/PDMFactory.cpp
44 @@ -58,6 +58,8 @@
45
46 #include <functional>
47
48 +bool gUseKeyframeFromContainer = false;
49 +
50 namespace mozilla {
51
52 #define PDM_INIT_LOG(msg, ...) \
53 @@ -536,10 +538,12 @@ void PDMFactory::CreateContentPDMs() {
54 }
55 #endif
56 #ifdef MOZ_FFMPEG
57 - if (StaticPrefs::media_ffmpeg_enabled() &&
58 - !CreateAndStartupPDM<FFmpegRuntimeLinker>()) {
59 - mFailureFlags += GetFailureFlagBasedOnFFmpegStatus(
60 - FFmpegRuntimeLinker::LinkStatusCode());
61 + if (StaticPrefs::media_ffmpeg_enabled()) {
62 + mFFmpegUsed = CreateAndStartupPDM<FFmpegRuntimeLinker>();
63 + if (!mFFmpegUsed) {
64 + mFailureFlags += GetFailureFlagBasedOnFFmpegStatus(
65 + FFmpegRuntimeLinker::LinkStatusCode());
66 + }
67 }
68 #endif
69 #ifdef MOZ_FFVPX
70 @@ -556,8 +560,9 @@ void PDMFactory::CreateContentPDMs() {
71
72 CreateAndStartupPDM<AgnosticDecoderModule>();
73
74 - if (StaticPrefs::media_gmp_decoder_enabled() &&
75 + if (StaticPrefs::media_gmp_decoder_enabled() && !mFFmpegUsed &&
76 !CreateAndStartupPDM<GMPDecoderModule>()) {
77 + gUseKeyframeFromContainer = true;
78 mFailureFlags += DecoderDoctorDiagnostics::Flags::GMPPDMFailedToStartup;
79 }
80 }
81 diff --git a/dom/media/platforms/PDMFactory.h b/dom/media/platforms/PDMFactory.h
82 index 4fc81c0b37..72f3255b6f 100644
83 --- a/dom/media/platforms/PDMFactory.h
84 +++ b/dom/media/platforms/PDMFactory.h
85 @@ -122,6 +122,8 @@ class PDMFactory final {
86
87 DecoderDoctorDiagnostics::FlagsSet mFailureFlags;
88
89 + bool mFFmpegUsed = false;
90 +
91 friend class RemoteVideoDecoderParent;
92 static void EnsureInit();
93 };
94 --
95 2.34.1
|