summaryrefslogtreecommitdiffstats
path: root/dom/media/webcodecs/VideoFrame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/webcodecs/VideoFrame.cpp')
-rw-r--r--dom/media/webcodecs/VideoFrame.cpp41
1 files changed, 9 insertions, 32 deletions
diff --git a/dom/media/webcodecs/VideoFrame.cpp b/dom/media/webcodecs/VideoFrame.cpp
index 602bc95c29..bea5611e39 100644
--- a/dom/media/webcodecs/VideoFrame.cpp
+++ b/dom/media/webcodecs/VideoFrame.cpp
@@ -598,8 +598,6 @@ static bool IsYUVFormat(const VideoPixelFormat& aFormat) {
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
return false;
- case VideoPixelFormat::EndGuard_:
- MOZ_ASSERT_UNREACHABLE("unsupported format");
}
return false;
}
@@ -641,8 +639,6 @@ static VideoColorSpaceInit PickColorSpace(
colorSpace.mPrimaries.SetValue(VideoColorPrimaries::Bt709);
colorSpace.mTransfer.SetValue(VideoTransferCharacteristics::Iec61966_2_1);
break;
- case VideoPixelFormat::EndGuard_:
- MOZ_ASSERT_UNREACHABLE("unsupported format");
}
return colorSpace;
@@ -881,8 +877,6 @@ static Result<RefPtr<layers::Image>, nsCString> CreateImageFromBuffer(
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
return CreateRGBAImageFromBuffer(aFormat, aSize, aBuffer);
- case VideoPixelFormat::EndGuard_:
- MOZ_ASSERT_UNREACHABLE("unsupported format");
}
return Err(nsCString("Invalid image format"));
}
@@ -1390,8 +1384,9 @@ already_AddRefed<VideoFrame> VideoFrame::Constructor(
}
const ImageUtils imageUtils(image);
+ Maybe<dom::ImageBitmapFormat> f = imageUtils.GetFormat();
Maybe<VideoPixelFormat> format =
- ImageBitmapFormatToVideoPixelFormat(imageUtils.GetFormat());
+ f.isSome() ? ImageBitmapFormatToVideoPixelFormat(f.value()) : Nothing();
// TODO: Retrive/infer the duration, and colorspace.
auto r = InitializeFrameFromOtherFrame(
@@ -1789,15 +1784,13 @@ nsCString VideoFrame::ToString() const {
return rv;
}
- rv.AppendPrintf(
- "VideoFrame ts: %" PRId64
- ", %s, coded[%dx%d] visible[%dx%d], display[%dx%d] color: %s",
- mTimestamp,
- dom::VideoPixelFormatValues::GetString(mResource->mFormat->PixelFormat())
- .data(),
- mCodedSize.width, mCodedSize.height, mVisibleRect.width,
- mVisibleRect.height, mDisplaySize.width, mDisplaySize.height,
- ColorSpaceInitToString(mColorSpace).get());
+ rv.AppendPrintf("VideoFrame ts: %" PRId64
+ ", %s, coded[%dx%d] visible[%dx%d], display[%dx%d] color: %s",
+ mTimestamp,
+ dom::GetEnumString(mResource->mFormat->PixelFormat()).get(),
+ mCodedSize.width, mCodedSize.height, mVisibleRect.width,
+ mVisibleRect.height, mDisplaySize.width, mDisplaySize.height,
+ ColorSpaceInitToString(mColorSpace).get());
if (mDuration) {
rv.AppendPrintf(" dur: %" PRId64, mDuration.value());
@@ -2032,8 +2025,6 @@ gfx::SurfaceFormat VideoFrame::Format::ToSurfaceFormat() const {
case VideoPixelFormat::BGRX:
format = gfx::SurfaceFormat::B8G8R8X8;
break;
- case VideoPixelFormat::EndGuard_:
- MOZ_ASSERT_UNREACHABLE("unsupported format");
}
return format;
}
@@ -2056,8 +2047,6 @@ void VideoFrame::Format::MakeOpaque() {
case VideoPixelFormat::RGBX:
case VideoPixelFormat::BGRX:
return;
- case VideoPixelFormat::EndGuard_:
- break;
}
MOZ_ASSERT_UNREACHABLE("unsupported format");
}
@@ -2077,8 +2066,6 @@ nsTArray<VideoFrame::Format::Plane> VideoFrame::Format::Planes() const {
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
return {Plane::RGBA};
- case VideoPixelFormat::EndGuard_:
- break;
}
MOZ_ASSERT_UNREACHABLE("unsupported format");
return {};
@@ -2125,8 +2112,6 @@ uint32_t VideoFrame::Format::SampleBytes(const Plane& aPlane) const {
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
return 4; // 8 bits/sample, 32 bits/pixel
- case VideoPixelFormat::EndGuard_:
- break;
}
MOZ_ASSERT_UNREACHABLE("unsupported format");
return 0;
@@ -2154,7 +2139,6 @@ gfx::IntSize VideoFrame::Format::SampleSize(const Plane& aPlane) const {
case VideoPixelFormat::RGBX:
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
- case VideoPixelFormat::EndGuard_:
MOZ_ASSERT_UNREACHABLE("invalid format");
return {0, 0};
}
@@ -2177,8 +2161,6 @@ bool VideoFrame::Format::IsValidSize(const gfx::IntSize& aSize) const {
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
return true;
- case VideoPixelFormat::EndGuard_:
- break;
}
MOZ_ASSERT_UNREACHABLE("unsupported format");
return false;
@@ -2205,8 +2187,6 @@ size_t VideoFrame::Format::SampleCount(const gfx::IntSize& aSize) const {
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
return (count * 4).value();
- case VideoPixelFormat::EndGuard_:
- break;
}
MOZ_ASSERT_UNREACHABLE("unsupported format");
@@ -2252,8 +2232,6 @@ uint32_t VideoFrame::Resource::Stride(const Format::Plane& aPlane) const {
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
return (width * mFormat->SampleBytes(aPlane)).value();
- case VideoPixelFormat::EndGuard_:
- MOZ_ASSERT_UNREACHABLE("invalid format");
}
return 0;
case Format::Plane::U: // and UV
@@ -2269,7 +2247,6 @@ uint32_t VideoFrame::Resource::Stride(const Format::Plane& aPlane) const {
case VideoPixelFormat::RGBX:
case VideoPixelFormat::BGRA:
case VideoPixelFormat::BGRX:
- case VideoPixelFormat::EndGuard_:
MOZ_ASSERT_UNREACHABLE("invalid format");
}
return 0;