summaryrefslogtreecommitdiff
path: root/chromium/media/video/vpx_video_encoder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/media/video/vpx_video_encoder.cc')
-rw-r--r--chromium/media/video/vpx_video_encoder.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/chromium/media/video/vpx_video_encoder.cc b/chromium/media/video/vpx_video_encoder.cc
index 5397f6a54b6..0d0dc479b76 100644
--- a/chromium/media/video/vpx_video_encoder.cc
+++ b/chromium/media/video/vpx_video_encoder.cc
@@ -427,12 +427,20 @@ void VpxVideoEncoder::Encode(scoped_refptr<VideoFrame> frame,
}
}
- const bool is_yuv = IsYuvPlanar(frame->format());
- if (frame->visible_rect().size() != options_.frame_size || !is_yuv) {
+ // Unfortunately libyuv lacks direct NV12 to I010 conversion, and we
+ // have to do an extra conversion to I420.
+ // TODO(https://crbug.com/libyuv/954) Use NV12ToI010() when implemented
+ const bool vp9_p2_needs_nv12_to_i420 =
+ frame->format() == PIXEL_FORMAT_NV12 && profile_ == VP9PROFILE_PROFILE2;
+ const bool needs_conversion_to_i420 =
+ !IsYuvPlanar(frame->format()) || vp9_p2_needs_nv12_to_i420;
+ if (frame->visible_rect().size() != options_.frame_size ||
+ needs_conversion_to_i420) {
+ auto new_pixel_format =
+ needs_conversion_to_i420 ? PIXEL_FORMAT_I420 : frame->format();
auto resized_frame = frame_pool_.CreateFrame(
- is_yuv ? frame->format() : PIXEL_FORMAT_I420, options_.frame_size,
- gfx::Rect(options_.frame_size), options_.frame_size,
- frame->timestamp());
+ new_pixel_format, options_.frame_size, gfx::Rect(options_.frame_size),
+ options_.frame_size, frame->timestamp());
if (!resized_frame) {
std::move(done_cb).Run(
@@ -454,6 +462,7 @@ void VpxVideoEncoder::Encode(scoped_refptr<VideoFrame> frame,
switch (profile_) {
case VP9PROFILE_PROFILE2:
+ DCHECK_EQ(frame->format(), PIXEL_FORMAT_I420);
// Profile 2 uses 10bit color,
libyuv::I420ToI010(
frame->visible_data(VideoFrame::kYPlane),