webrtc_libyuv: Raise warnings for unhandled types at compile time

Bug: webrtc:14830
Change-Id: Ib5141e585f673098bbedd2872dbd6e6ed9df4864
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291528
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39408}
This commit is contained in:
Andreas Pehrson 2023-01-27 15:10:22 +01:00 committed by WebRTC LUCI CQ
parent 832ce5eae6
commit 7e5d9edfdf

View File

@ -22,7 +22,6 @@ namespace webrtc {
size_t CalcBufferSize(VideoType type, int width, int height) { size_t CalcBufferSize(VideoType type, int width, int height) {
RTC_DCHECK_GE(width, 0); RTC_DCHECK_GE(width, 0);
RTC_DCHECK_GE(height, 0); RTC_DCHECK_GE(height, 0);
size_t buffer_size = 0;
switch (type) { switch (type) {
case VideoType::kI420: case VideoType::kI420:
case VideoType::kIYUV: case VideoType::kIYUV:
@ -30,26 +29,23 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
case VideoType::kNV12: { case VideoType::kNV12: {
int half_width = (width + 1) >> 1; int half_width = (width + 1) >> 1;
int half_height = (height + 1) >> 1; int half_height = (height + 1) >> 1;
buffer_size = width * height + half_width * half_height * 2; return width * height + half_width * half_height * 2;
break;
} }
case VideoType::kRGB565: case VideoType::kRGB565:
case VideoType::kYUY2: case VideoType::kYUY2:
case VideoType::kUYVY: case VideoType::kUYVY:
buffer_size = width * height * 2; return width * height * 2;
break;
case VideoType::kRGB24: case VideoType::kRGB24:
buffer_size = width * height * 3; return width * height * 3;
break;
case VideoType::kBGRA: case VideoType::kBGRA:
case VideoType::kARGB: case VideoType::kARGB:
buffer_size = width * height * 4; return width * height * 4;
break; case VideoType::kMJPEG:
default: case VideoType::kUnknown:
RTC_DCHECK_NOTREACHED();
break; break;
} }
return buffer_size; RTC_DCHECK_NOTREACHED() << "Unexpected pixel format " << type;
return 0;
} }
int ExtractBuffer(const rtc::scoped_refptr<I420BufferInterface>& input_frame, int ExtractBuffer(const rtc::scoped_refptr<I420BufferInterface>& input_frame,
@ -109,7 +105,7 @@ int ConvertVideoType(VideoType video_type) {
case VideoType::kNV12: case VideoType::kNV12:
return libyuv::FOURCC_NV12; return libyuv::FOURCC_NV12;
} }
RTC_DCHECK_NOTREACHED(); RTC_DCHECK_NOTREACHED() << "Unexpected pixel format " << video_type;
return libyuv::FOURCC_ANY; return libyuv::FOURCC_ANY;
} }