| File: | root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/media/platforms/./../../../../dom/media/platforms/EncoderConfig.cpp |
| Warning: | line 47, 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/ToString.h" |
| 11 | #include "mozilla/dom/BindingUtils.h" |
| 12 | #include "mozilla/dom/ImageUtils.h" |
| 13 | |
| 14 | namespace mozilla { |
| 15 | |
| 16 | nsCString EncoderConfig::ToString() const { |
| 17 | nsCString rv(EnumValueToString(mCodec)); |
| 18 | rv.AppendLiteral(mBitrateMode == BitrateMode::Constant ? " (CBR)" : " (VBR)"); |
| 19 | rv.AppendPrintf("%" PRIu32"u" "bps", mBitrate); |
| 20 | if (mUsage == Usage::Realtime) { |
| 21 | rv.AppendLiteral(", realtime"); |
| 22 | } else { |
| 23 | rv.AppendLiteral(", record"); |
| 24 | } |
| 25 | if (IsVideo()) { |
| 26 | rv.AppendPrintf(" [%dx%d]", mSize.Width(), mSize.Height()); |
| 27 | if (mHardwarePreference == HardwarePreference::RequireHardware) { |
| 28 | rv.AppendLiteral(", hw required"); |
| 29 | } else if (mHardwarePreference == HardwarePreference::RequireSoftware) { |
| 30 | rv.AppendLiteral(", sw required"); |
| 31 | } else { |
| 32 | rv.AppendLiteral(", hw: no preference"); |
| 33 | } |
| 34 | rv.AppendPrintf(", %s", mFormat.ToString().get()); |
| 35 | if (mScalabilityMode == ScalabilityMode::L1T2) { |
| 36 | rv.AppendLiteral(", L1T2"); |
| 37 | } else if (mScalabilityMode == ScalabilityMode::L1T3) { |
| 38 | rv.AppendLiteral(", L1T3"); |
| 39 | } |
| 40 | rv.AppendPrintf(", %" PRIu8"hhu" " fps", mFramerate); |
| 41 | rv.AppendPrintf(", kf interval: %zu", mKeyframeInterval); |
| 42 | } else { |
| 43 | 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" , 43); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsAudio()" ")" ); do { MOZ_CrashSequence(__null, 43); __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 44 | rv.AppendPrintf(", ch: %" PRIu32"u" ", %" PRIu32"u" "Hz", mNumberOfChannels, |
| 45 | mSampleRate); |
| 46 | } |
| 47 | const char* specificStr = ""; |
Value stored to 'specificStr' during its initialization is never read | |
| 48 | if (mCodecSpecific.is<void_t>()) { |
| 49 | specificStr = "o"; |
| 50 | } else if (mCodecSpecific.is<H264Specific>()) { |
| 51 | specificStr = " H264"; |
| 52 | } else if (mCodecSpecific.is<OpusSpecific>()) { |
| 53 | specificStr = " Opus"; |
| 54 | } else if (mCodecSpecific.is<VP8Specific>()) { |
| 55 | specificStr = " VP8"; |
| 56 | } else if (mCodecSpecific.is<VP9Specific>()) { |
| 57 | specificStr = " VP9"; |
| 58 | } else { |
| 59 | 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" , 59); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Unexpected codec specific type" ")"); do { MOZ_CrashSequence (__null, 59); __attribute__((nomerge)) ::abort(); } while (false ); } } while (false); |
| 60 | specificStr = " unknown"; |
| 61 | } |
| 62 | rv.AppendPrintf(" (w/%s codec specific)", specificStr); |
| 63 | return rv; |
| 64 | }; |
| 65 | |
| 66 | nsCString EncoderConfig::VideoColorSpace::ToString() const { |
| 67 | nsCString ret; |
| 68 | ret.AppendFmt( |
| 69 | "VideoColorSpace {{ range={}, matrix={}, primaries={}, transfer={} }}", |
| 70 | mRange ? mozilla::ToString(mRange.value()) : "none", |
| 71 | mMatrix ? mozilla::ToString(mMatrix.value()) : "none", |
| 72 | mPrimaries ? mozilla::ToString(mPrimaries.value()) : "none", |
| 73 | mTransferFunction ? mozilla::ToString(mTransferFunction.value()) |
| 74 | : "none"); |
| 75 | return ret; |
| 76 | } |
| 77 | |
| 78 | nsCString EncoderConfig::SampleFormat::ToString() const { |
| 79 | return nsPrintfCString("SampleFormat - [PixelFormat: %s, %s]", |
| 80 | dom::GetEnumString(mPixelFormat).get(), |
| 81 | mColorSpace.ToString().get()); |
| 82 | } |
| 83 | |
| 84 | Result<EncoderConfig::SampleFormat, MediaResult> |
| 85 | EncoderConfig::SampleFormat::FromImage(layers::Image* aImage) { |
| 86 | if (!aImage) { |
| 87 | return Err(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, "No image")); |
| 88 | } |
| 89 | |
| 90 | const dom::ImageUtils imageUtils(aImage); |
| 91 | Maybe<dom::ImageBitmapFormat> format = imageUtils.GetFormat(); |
| 92 | if (format.isNothing()) { |
| 93 | return Err( |
| 94 | MediaResult(NS_ERROR_NOT_IMPLEMENTED, |
| 95 | nsPrintfCString("unsupported image format: %d", |
| 96 | static_cast<int>(aImage->GetFormat())))); |
| 97 | } |
| 98 | |
| 99 | if (layers::PlanarYCbCrImage* image = aImage->AsPlanarYCbCrImage()) { |
| 100 | if (const layers::PlanarYCbCrImage::Data* yuv = image->GetData()) { |
| 101 | return EncoderConfig::SampleFormat( |
| 102 | format.ref(), EncoderConfig::VideoColorSpace( |
| 103 | yuv->mColorRange, yuv->mYUVColorSpace, |
| 104 | yuv->mColorPrimaries, yuv->mTransferFunction)); |
| 105 | } |
| 106 | return Err(MediaResult(NS_ERROR_UNEXPECTED, |
| 107 | "failed to get YUV data from a YUV image")); |
| 108 | } |
| 109 | |
| 110 | return EncoderConfig::SampleFormat(format.ref()); |
| 111 | } |
| 112 | |
| 113 | } // namespace mozilla |