| 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 |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 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 | |
| 13 | namespace mozilla { |
| 14 | |
| 15 | nsCString 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 | |
| 65 | const 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 | |
| 76 | const 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 | |
| 91 | const 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 | |
| 110 | const 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 | |
| 128 | nsCString 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 | |
| 140 | nsCString EncoderConfig::SampleFormat::ToString() const { |
| 141 | return nsPrintfCString("SampleFormat - [PixelFormat: %s, %s]", |
| 142 | dom::GetEnumString(mPixelFormat).get(), |
| 143 | mColorSpace.ToString().get()); |
| 144 | } |
| 145 | |
| 146 | Result<EncoderConfig::SampleFormat, MediaResult> |
| 147 | EncoderConfig::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 |