RTC_CHECK frame buffer has expected width & height

The width and height of mapped_buffer must match the d_w and d_h members
of frame_to_encode_, which is passed to aom_codec_encode().

Bug: b:330482827
Change-Id: I85d8c82133768685565f165eafc893c42dc40b12
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/345807
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Cr-Commit-Position: refs/heads/main@{#42036}
This commit is contained in:
Wan-Teh Chang 2024-04-05 20:25:25 -07:00 committed by WebRTC LUCI CQ
parent 0bb59b4edd
commit ef16abac3e

View File

@ -626,6 +626,8 @@ int32_t LibaomAv1Encoder::Encode(
MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420); MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420);
auto i420_buffer = mapped_buffer->GetI420(); auto i420_buffer = mapped_buffer->GetI420();
RTC_DCHECK(i420_buffer); RTC_DCHECK(i420_buffer);
RTC_CHECK_EQ(i420_buffer->width(), frame_for_encode_->d_w);
RTC_CHECK_EQ(i420_buffer->height(), frame_for_encode_->d_h);
frame_for_encode_->planes[AOM_PLANE_Y] = frame_for_encode_->planes[AOM_PLANE_Y] =
const_cast<unsigned char*>(i420_buffer->DataY()); const_cast<unsigned char*>(i420_buffer->DataY());
frame_for_encode_->planes[AOM_PLANE_U] = frame_for_encode_->planes[AOM_PLANE_U] =
@ -641,6 +643,8 @@ int32_t LibaomAv1Encoder::Encode(
MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12); MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12);
const NV12BufferInterface* nv12_buffer = mapped_buffer->GetNV12(); const NV12BufferInterface* nv12_buffer = mapped_buffer->GetNV12();
RTC_DCHECK(nv12_buffer); RTC_DCHECK(nv12_buffer);
RTC_CHECK_EQ(nv12_buffer->width(), frame_for_encode_->d_w);
RTC_CHECK_EQ(nv12_buffer->height(), frame_for_encode_->d_h);
frame_for_encode_->planes[AOM_PLANE_Y] = frame_for_encode_->planes[AOM_PLANE_Y] =
const_cast<unsigned char*>(nv12_buffer->DataY()); const_cast<unsigned char*>(nv12_buffer->DataY());
frame_for_encode_->planes[AOM_PLANE_U] = frame_for_encode_->planes[AOM_PLANE_U] =