Updated openh264 patch to use keyframes from contained for openh264 only

This commit is contained in:
Martin Stransky 2020-10-19 21:01:34 +02:00
parent a16c031836
commit 8e3365440a
2 changed files with 66 additions and 8 deletions

View File

@ -618,7 +618,9 @@ echo "ac_add_options MOZ_PGO=1" >> .mozconfig
# Temporary disabled due to GCC bug
# Fixed by https://bugzilla.mozilla.org/show_bug.cgi?id=1671345
# Should be in Firefox 83
# echo "ac_add_options --enable-lto" >> .mozconfig
%if 0%{?fedora} > 33
echo "ac_add_options --enable-lto" >> .mozconfig
%endif
# PGO build doesn't work with ccache
export CCACHE_DISABLE=1

View File

@ -1,12 +1,68 @@
diff -up firefox-81.0.2/dom/media/mp4/MP4Demuxer.cpp.old firefox-81.0.2/dom/media/mp4/MP4Demuxer.cpp
--- firefox-81.0.2/dom/media/mp4/MP4Demuxer.cpp.old 2020-10-14 17:06:31.424309071 +0200
+++ firefox-81.0.2/dom/media/mp4/MP4Demuxer.cpp 2020-10-14 17:07:31.029533759 +0200
@@ -394,7 +394,7 @@ already_AddRefed<MediaRawData> MP4TrackD
diff -up firefox-82.0/dom/media/mp4/MP4Demuxer.cpp.1670333 firefox-82.0/dom/media/mp4/MP4Demuxer.cpp
--- firefox-82.0/dom/media/mp4/MP4Demuxer.cpp.1670333 2020-10-14 19:20:18.000000000 +0200
+++ firefox-82.0/dom/media/mp4/MP4Demuxer.cpp 2020-10-19 20:56:38.362039524 +0200
@@ -31,6 +31,8 @@ mozilla::LogModule* GetDemuxerLog() { re
DDMOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, "::%s: " arg, \
__func__, ##__VA_ARGS__)
+extern bool gUseKeyframeFromContainer;
+
namespace mozilla {
DDLoggedTypeDeclNameAndBase(MP4TrackDemuxer, MediaTrackDemuxer);
@@ -394,6 +396,12 @@ already_AddRefed<MediaRawData> MP4TrackD
[[fallthrough]];
case H264::FrameType::OTHER: {
bool keyframe = type == H264::FrameType::I_FRAME;
- if (sample->mKeyframe != keyframe) {
+ if (sample->mKeyframe && sample->mKeyframe != keyframe) {
+ if (gUseKeyframeFromContainer) {
+ if (sample->mKeyframe && sample->mKeyframe != keyframe) {
+ sample->mKeyframe = keyframe;
+ }
+ break;
+ }
if (sample->mKeyframe != keyframe) {
NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe "
"@ pts:%" PRId64 " dur:%" PRId64
" dts:%" PRId64,
diff -up firefox-82.0/dom/media/platforms/PDMFactory.cpp.1670333 firefox-82.0/dom/media/platforms/PDMFactory.cpp
--- firefox-82.0/dom/media/platforms/PDMFactory.cpp.1670333 2020-10-14 19:20:18.000000000 +0200
+++ firefox-82.0/dom/media/platforms/PDMFactory.cpp 2020-10-19 20:53:14.631214334 +0200
@@ -49,6 +49,8 @@
#include <functional>
+bool gUseKeyframeFromContainer = false;
+
namespace mozilla {
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
@@ -380,7 +382,8 @@ void PDMFactory::CreatePDMs() {
#ifdef MOZ_FFMPEG
if (StaticPrefs::media_ffmpeg_enabled()) {
m = FFmpegRuntimeLinker::CreateDecoderModule();
- mFFmpegFailedToLoad = !StartupPDM(m);
+ mFFmpegUsed = StartupPDM(m);
+ mFFmpegFailedToLoad = !mFFmpegUsed;
} else {
mFFmpegFailedToLoad = false;
}
@@ -395,7 +398,8 @@ void PDMFactory::CreatePDMs() {
m = new AgnosticDecoderModule();
StartupPDM(m);
- if (StaticPrefs::media_gmp_decoder_enabled()) {
+ if (StaticPrefs::media_gmp_decoder_enabled() && !mFFmpegUsed) {
+ gUseKeyframeFromContainer = true;
m = new GMPDecoderModule();
mGMPPDMFailedToStartup = !StartupPDM(m);
} else {
diff -up firefox-82.0/dom/media/platforms/PDMFactory.h.1670333 firefox-82.0/dom/media/platforms/PDMFactory.h
--- firefox-82.0/dom/media/platforms/PDMFactory.h.1670333 2020-10-14 19:20:18.000000000 +0200
+++ firefox-82.0/dom/media/platforms/PDMFactory.h 2020-10-19 20:53:14.631214334 +0200
@@ -70,6 +70,7 @@ class PDMFactory final {
bool mWMFFailedToLoad = false;
bool mFFmpegFailedToLoad = false;
+ bool mFFmpegUsed = false;
bool mGMPPDMFailedToStartup = false;
friend class RemoteVideoDecoderParent;