summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPale Moon <git-repo@palemoon.org>2018-04-02 16:33:49 +0200
committerPale Moon <git-repo@palemoon.org>2018-04-02 16:33:49 +0200
commit0214272da2cb0b9ffa253ddfa5f0c4eaf2c7bde8 (patch)
tree1820bd12b88bf9442225b889b8a87f7a57244f8e
parent6932e60489da56dcc4524ad9abf0173ff2352c66 (diff)
downloadpalemoon-gre-0214272da2cb0b9ffa253ddfa5f0c4eaf2c7bde8.tar.gz
Make JXELIB bug workaround a pref.
There's still a risk for crashes with this enabled, so preffed off by default for now. Live pref, so can be toggled on-the-fly if needed. Tag #1659.
-rw-r--r--gfx/thebes/gfxPrefs.h3
-rw-r--r--image/decoders/nsJXRDecoder.cpp46
-rw-r--r--modules/libpref/init/all.js3
3 files changed, 34 insertions, 18 deletions
diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h
index 750cb2b5d..638e929b9 100644
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -250,7 +250,7 @@ private:
DECL_GFX_PREF(Live, "image.mozsamplesize.enabled", ImageMozSampleSizeEnabled, bool, false);
DECL_GFX_PREF(Once, "image.multithreaded_decoding.limit", ImageMTDecodingLimit, int32_t, -1);
DECL_GFX_PREF(Live, "image.single-color-optimization.enabled", ImageSingleColorOptimizationEnabled, bool, true);
-
+
DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabled, bool, false);
DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, false);
DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.print-histogram", FPSPrintHistogram, bool, false);
@@ -330,6 +330,7 @@ private:
DECL_GFX_PREF(Once, "layout.paint_rects_separately", LayoutPaintRectsSeparately, bool, true);
#ifdef MOZ_JXR
DECL_GFX_PREF(Live, "media.jxr.enabled", MediaJXREnabled, bool, false);
+ DECL_GFX_PREF(Live, "media.jxr.workaround_alphaplane_bug", MediaJXRWorkaroundAlphaplaneBug, bool, false);
#endif
DECL_GFX_PREF(Live, "nglayout.debug.widget_update_flashing", WidgetUpdateFlashing, bool, false);
diff --git a/image/decoders/nsJXRDecoder.cpp b/image/decoders/nsJXRDecoder.cpp
index 16a6f78c7..0ab12aa63 100644
--- a/image/decoders/nsJXRDecoder.cpp
+++ b/image/decoders/nsJXRDecoder.cpp
@@ -88,6 +88,7 @@
#include "gfxColor.h"
#include "gfxPlatform.h"
#include "qcms.h" // icSigRgbData, icSigGrayData
+#include "gfxPrefs.h" // to control workarounds
//////////////////// Mozilla JPEG-XR decoder ///////////////////////////
@@ -2673,17 +2674,23 @@ void nsJXRDecoder::FinishInternal()
// Circumvent the bug in JXELIB's JPEG-XR encoder that writes wrong alpha plane byte count.
if (m_pDecoder->WMP.wmiDEMisc.uAlphaOffset + m_pDecoder->WMP.wmiI_Alpha.uImageByteCount > GetTotalNumBytesReceived())
{
- // Make sure we're not having incomplete data and avoid Bad Things(tm) [Moonchild]
- if (GetTotalNumBytesReceived() <= m_pDecoder->WMP.wmiDEMisc.uAlphaOffset) {
+ if (gfxPrefs::MediaJXRWorkaroundAlphaplaneBug()) {
+ // Make sure we're not having incomplete data and avoid Bad Things(tm) [Moonchild]
+ if (GetTotalNumBytesReceived() <= m_pDecoder->WMP.wmiDEMisc.uAlphaOffset) {
+ PostDataError();
+ return;
+ }
+
+ // Adjust the alpha plane byte count if the value is wrong.
+ // If received data is still incomplete but cut off in the alpha plane data,
+ // the alpha plane size will be wrong but should still be an acceptable value
+ // for the decoder. [Moonchild]
+ m_pDecoder->WMP.wmiI_Alpha.uImageByteCount = GetTotalNumBytesReceived() - m_pDecoder->WMP.wmiDEMisc.uAlphaOffset;
+ } else {
+ // Don't hack around this encoder bug, report an encoding error instead.
PostDataError();
return;
}
-
- // Adjust the alpha plane byte count if the value is wrong.
- // If received data is still incomplete but cut off in the alpha plane data,
- // the alpha plane size will be wrong but will should be an acceptable value
- // for the decoder. [Moonchild]
- m_pDecoder->WMP.wmiI_Alpha.uImageByteCount = GetTotalNumBytesReceived() - m_pDecoder->WMP.wmiDEMisc.uAlphaOffset;
}
StartDecodingMBRows_Alpha();
@@ -2727,20 +2734,25 @@ void nsJXRDecoder::FinishInternal()
m_pStream->DiscardHead(m_pStream, m_pDecoder->WMP.wmiDEMisc.uAlphaOffset, &discarded);
// Circumvent the bug in JXELIB's JPEG-XR encoder that writes wrong alpha plane byte count.
- // Adjust the alpha plane byte count if the value is wrong.
if (m_pDecoder->WMP.wmiDEMisc.uAlphaOffset + m_pDecoder->WMP.wmiI_Alpha.uImageByteCount > GetTotalNumBytesReceived())
{
- // Make sure we're not having incomplete data and avoid Bad Things(tm) [Moonchild]
- if (GetTotalNumBytesReceived() <= m_pDecoder->WMP.wmiDEMisc.uAlphaOffset) {
+ if (gfxPrefs::MediaJXRWorkaroundAlphaplaneBug()) {
+ // Make sure we're not having incomplete data and avoid Bad Things(tm) [Moonchild]
+ if (GetTotalNumBytesReceived() <= m_pDecoder->WMP.wmiDEMisc.uAlphaOffset) {
+ PostDataError();
+ return;
+ }
+
+ // Adjust the alpha plane byte count if the value is wrong.
+ // If received data is still incomplete but cut off in the alpha plane data,
+ // the alpha plane size will be wrong but should still be an acceptable value
+ // for the decoder. [Moonchild]
+ m_pDecoder->WMP.wmiI_Alpha.uImageByteCount = GetTotalNumBytesReceived() - m_pDecoder->WMP.wmiDEMisc.uAlphaOffset;
+ } else {
+ // Don't hack around this encoder bug, report an encoding error instead.
PostDataError();
return;
}
-
- // Adjust the alpha plane byte count if the value is wrong.
- // If received data is still incomplete but cut off in the alpha plane data,
- // the alpha plane size will be wrong but should still be an acceptable value
- // for the decoder. [Moonchild]
- m_pDecoder->WMP.wmiI_Alpha.uImageByteCount = GetTotalNumBytesReceived() - m_pDecoder->WMP.wmiDEMisc.uAlphaOffset;
}
StartDecodingMBRows_Alpha();
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index df91f87c7..554179fe6 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -316,6 +316,9 @@ pref("media.jxr.autoaccept", true);
// updated with the new type. This pref is mainly for testing and should be
// removed once the preferred type (most likely "image/jxr") has been chosen.
pref("media.jxr.advertised_mime_type", "image/jxr");
+// Work around the JXELIB encoding bug for incorrect bytecounts.
+// Enabling this -may- lead to crashes in rare circumstances.
+pref("media.jxr.workaround_alphaplane_bug", false);
#endif
#ifdef MOZ_DIRECTSHOW
pref("media.directshow.enabled", true);