Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/media/platforms/./../../../../dom/media/platforms/EncoderConfig.cpp
Warning:line 46, column 15
Value stored to 'specificStr' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_dom_media_platforms0.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/media/platforms -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/media/platforms -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/dom/media/platforms -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/media/platforms -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/toolkit/components/telemetry -I /root/firefox-clang/xpcom/base -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-09-01-224014-2642839-1 -x c++ Unified_cpp_dom_media_platforms0.cpp
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#include "EncoderConfig.h"
6
7#include "ImageContainer.h"
8#include "MP4Decoder.h"
9#include "VPXDecoder.h"
10#include "mozilla/dom/BindingUtils.h"
11#include "mozilla/dom/ImageUtils.h"
12
13namespace mozilla {
14
15nsCString EncoderConfig::ToString() const {
16 nsCString rv(EnumValueToString(mCodec));
17 rv.AppendLiteral(mBitrateMode == BitrateMode::Constant ? " (CBR)" : " (VBR)");
18 rv.AppendPrintf("%" PRIu32"u" "bps", mBitrate);
19 if (mUsage == Usage::Realtime) {
20 rv.AppendLiteral(", realtime");
21 } else {
22 rv.AppendLiteral(", record");
23 }
24 if (IsVideo()) {
25 rv.AppendPrintf(" [%dx%d]", mSize.Width(), mSize.Height());
26 if (mHardwarePreference == HardwarePreference::RequireHardware) {
27 rv.AppendLiteral(", hw required");
28 } else if (mHardwarePreference == HardwarePreference::RequireSoftware) {
29 rv.AppendLiteral(", sw required");
30 } else {
31 rv.AppendLiteral(", hw: no preference");
32 }
33 rv.AppendPrintf(", %s", mFormat.ToString().get());
34 if (mScalabilityMode == ScalabilityMode::L1T2) {
35 rv.AppendLiteral(", L1T2");
36 } else if (mScalabilityMode == ScalabilityMode::L1T3) {
37 rv.AppendLiteral(", L1T3");
38 }
39 rv.AppendPrintf(", %" PRIu8"hhu" " fps", mFramerate);
40 rv.AppendPrintf(", kf interval: %zu", mKeyframeInterval);
41 } else {
42 MOZ_ASSERT(IsAudio())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsAudio())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsAudio()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("IsAudio()", "./../../../../dom/media/platforms/EncoderConfig.cpp"
, 42); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsAudio()" ")"
); do { MOZ_CrashSequence(__null, 42); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
43 rv.AppendPrintf(", ch: %" PRIu32"u" ", %" PRIu32"u" "Hz", mNumberOfChannels,
44 mSampleRate);
45 }
46 const char* specificStr = "";
Value stored to 'specificStr' during its initialization is never read
47 if (mCodecSpecific.is<void_t>()) {
48 specificStr = "o";
49 } else if (mCodecSpecific.is<H264Specific>()) {
50 specificStr = " H264";
51 } else if (mCodecSpecific.is<OpusSpecific>()) {
52 specificStr = " Opus";
53 } else if (mCodecSpecific.is<VP8Specific>()) {
54 specificStr = " VP8";
55 } else if (mCodecSpecific.is<VP9Specific>()) {
56 specificStr = " VP9";
57 } else {
58 MOZ_ASSERT_UNREACHABLE("Unexpected codec specific type")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: "
"Unexpected codec specific type" ")", "./../../../../dom/media/platforms/EncoderConfig.cpp"
, 58); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: "
"Unexpected codec specific type" ")"); do { MOZ_CrashSequence
(__null, 58); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
59 specificStr = " unknown";
60 }
61 rv.AppendPrintf(" (w/%s codec specific)", specificStr);
62 return rv;
63};
64
65const char* ColorRangeToString(const gfx::ColorRange& aColorRange) {
66 switch (aColorRange) {
67 case gfx::ColorRange::FULL:
68 return "FULL";
69 case gfx::ColorRange::LIMITED:
70 return "LIMITED";
71 }
72 MOZ_ASSERT_UNREACHABLE("unknown ColorRange")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: "
"unknown ColorRange" ")", "./../../../../dom/media/platforms/EncoderConfig.cpp"
, 72); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: "
"unknown ColorRange" ")"); do { MOZ_CrashSequence(__null, 72
); __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
;
73 return "unknown";
74}
75
76const char* YUVColorSpaceToString(const gfx::YUVColorSpace& aYUVColorSpace) {
77 switch (aYUVColorSpace) {
78 case gfx::YUVColorSpace::BT601:
79 return "BT601";
80 case gfx::YUVColorSpace::BT709:
81 return "BT709";
82 case gfx::YUVColorSpace::BT2020:
83 return "BT2020";
84 case gfx::YUVColorSpace::Identity:
85 return "Identity";
86 }
87 MOZ_ASSERT_UNREACHABLE("unknown YUVColorSpace")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: "
"unknown YUVColorSpace" ")", "./../../../../dom/media/platforms/EncoderConfig.cpp"
, 87); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: "
"unknown YUVColorSpace" ")"); do { MOZ_CrashSequence(__null,
87); __attribute__((nomerge)) ::abort(); } while (false); } }
while (false)
;
88 return "unknown";
89}
90
91const char* ColorSpace2ToString(const gfx::ColorSpace2& aColorSpace2) {
92 switch (aColorSpace2) {
93 case gfx::ColorSpace2::Display:
94 return "Display";
95 case gfx::ColorSpace2::SRGB:
96 return "SRGB";
97 case gfx::ColorSpace2::DISPLAY_P3:
98 return "DISPLAY_P3";
99 case gfx::ColorSpace2::BT601_525:
100 return "BT601_525";
101 case gfx::ColorSpace2::BT709:
102 return "BT709";
103 case gfx::ColorSpace2::BT2020:
104 return "BT2020";
105 }
106 MOZ_ASSERT_UNREACHABLE("unknown ColorSpace2")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: "
"unknown ColorSpace2" ")", "./../../../../dom/media/platforms/EncoderConfig.cpp"
, 106); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
"MOZ_ASSERT_UNREACHABLE: " "unknown ColorSpace2" ")"); do { MOZ_CrashSequence
(__null, 106); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
107 return "unknown";
108}
109
110const char* TransferFunctionToString(
111 const gfx::TransferFunction& aTransferFunction) {
112 switch (aTransferFunction) {
113 case gfx::TransferFunction::BT709:
114 return "BT709";
115 case gfx::TransferFunction::SRGB:
116 return "SRGB";
117 case gfx::TransferFunction::PQ:
118 return "PQ";
119 case gfx::TransferFunction::HLG:
120 return "HLG";
121 case gfx::TransferFunction::LINEAR:
122 return "LINEAR";
123 }
124 MOZ_ASSERT_UNREACHABLE("unknown TransferFunction")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: "
"unknown TransferFunction" ")", "./../../../../dom/media/platforms/EncoderConfig.cpp"
, 124); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
"MOZ_ASSERT_UNREACHABLE: " "unknown TransferFunction" ")"); do
{ MOZ_CrashSequence(__null, 124); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
125 return "unknown";
126}
127
128nsCString EncoderConfig::VideoColorSpace::ToString() const {
129 nsCString ret;
130 ret.AppendFmt(
131 "VideoColorSpace: [range: {}, matrix: {}, primaries: {}, transfer: {}]",
132 mRange ? ColorRangeToString(mRange.value()) : "none",
133 mMatrix ? YUVColorSpaceToString(mMatrix.value()) : "none",
134 mPrimaries ? ColorSpace2ToString(mPrimaries.value()) : "none",
135 mTransferFunction ? TransferFunctionToString(mTransferFunction.value())
136 : "none");
137 return ret;
138}
139
140nsCString EncoderConfig::SampleFormat::ToString() const {
141 return nsPrintfCString("SampleFormat - [PixelFormat: %s, %s]",
142 dom::GetEnumString(mPixelFormat).get(),
143 mColorSpace.ToString().get());
144}
145
146Result<EncoderConfig::SampleFormat, MediaResult>
147EncoderConfig::SampleFormat::FromImage(layers::Image* aImage) {
148 if (!aImage) {
149 return Err(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, "No image"));
150 }
151
152 const dom::ImageUtils imageUtils(aImage);
153 Maybe<dom::ImageBitmapFormat> format = imageUtils.GetFormat();
154 if (format.isNothing()) {
155 return Err(
156 MediaResult(NS_ERROR_NOT_IMPLEMENTED,
157 nsPrintfCString("unsupported image format: %d",
158 static_cast<int>(aImage->GetFormat()))));
159 }
160
161 if (layers::PlanarYCbCrImage* image = aImage->AsPlanarYCbCrImage()) {
162 if (const layers::PlanarYCbCrImage::Data* yuv = image->GetData()) {
163 return EncoderConfig::SampleFormat(
164 format.ref(), EncoderConfig::VideoColorSpace(
165 yuv->mColorRange, yuv->mYUVColorSpace,
166 yuv->mColorPrimaries, yuv->mTransferFunction));
167 }
168 return Err(MediaResult(NS_ERROR_UNEXPECTED,
169 "failed to get YUV data from a YUV image"));
170 }
171
172 return EncoderConfig::SampleFormat(format.ref());
173}
174
175} // namespace mozilla