Commit 0679ab58 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/v4l2VEA: Fix natural_size check condition

Original V4L2VideoEncodeAccelerator checks that the natural size
of every VideoFrame with the dimension to be encoded. They must
be the same in single cast case, but can be different in
multicast case. The correct check is to compare it with the
natural size of the first VideoFrame. In other words, the
natural_size must be unchanged during encoding in the same
VideoEncodeAccelerator instance.

Bug: b:172223525
Test: meet.google.com on trogdor
Change-Id: I3c21782b86cddaa788d4daf785793f73ec49db9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2541942Reviewed-by: default avatarFritz Koenig <frkoenig@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828641}
parent 6bdc389d
...@@ -768,6 +768,13 @@ void V4L2VideoEncodeAccelerator::EncodeTask(scoped_refptr<VideoFrame> frame, ...@@ -768,6 +768,13 @@ void V4L2VideoEncodeAccelerator::EncodeTask(scoped_refptr<VideoFrame> frame,
bool V4L2VideoEncodeAccelerator::ReconfigureFormatIfNeeded( bool V4L2VideoEncodeAccelerator::ReconfigureFormatIfNeeded(
const VideoFrame& frame) { const VideoFrame& frame) {
DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_);
if (input_buffer_map_.empty()) {
// Updates |input_natural_size_| on the first VideoFrame.
// |input_natural_size_| is a dimension to be encoded (i.e.
// |encoder_input_visible_rect_.size()|), but can be different from it
// in simulcast case.
input_natural_size_ = frame.natural_size();
}
if (!native_input_mode_) { if (!native_input_mode_) {
// frame.coded_size() must be the size specified in // frame.coded_size() must be the size specified in
...@@ -779,14 +786,13 @@ bool V4L2VideoEncodeAccelerator::ReconfigureFormatIfNeeded( ...@@ -779,14 +786,13 @@ bool V4L2VideoEncodeAccelerator::ReconfigureFormatIfNeeded(
// ReconfigureFormatIfNeeded() has been called with the first VideoFrame. // ReconfigureFormatIfNeeded() has been called with the first VideoFrame.
// We checks here we need to (re)create ImageProcessor because the visible // We checks here we need to (re)create ImageProcessor because the visible
// rectangle of |frame| differs from the first VideoFrame. // rectangle of |frame| differs from the first VideoFrame.
// |frame.natural_size()| is the size to be encoded. It must be the same as // |frame.natural_size()| must be unchanged during encoding in the same
// |encoder_input_visible_rect_.size()|, otherwise VEA client must recreate // VideoEncodeAccelerator instance. When it is changed, a client has to
// VEA with the new encoder resolution. // recreate VideoEncodeAccelerator.
if (frame.natural_size() != encoder_input_visible_rect_.size()) { if (frame.natural_size() != input_natural_size_) {
VLOGF(1) << "Encoder resolution is changed during encoding" VLOGF(1) << "Encoder resolution is changed during encoding"
<< ", frame.natural_size()=" << frame.natural_size().ToString() << ", frame.natural_size()=" << frame.natural_size().ToString()
<< ", encoder_input_visible_rect_=" << ", input_natural_size_=" << input_natural_size_.ToString();
<< encoder_input_visible_rect_.ToString();
return false; return false;
} }
if (frame.coded_size() == input_frame_size_) { if (frame.coded_size() == input_frame_size_) {
......
...@@ -262,6 +262,10 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator ...@@ -262,6 +262,10 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator
// time Encode() if the coded size is different from the expected one by VEA. // time Encode() if the coded size is different from the expected one by VEA.
// For example, it happens in WebRTC simulcast case. // For example, it happens in WebRTC simulcast case.
gfx::Size input_frame_size_; gfx::Size input_frame_size_;
// A natural_size() of VideoFrame on VEA::Encode(). This is updated on the
// first time Encode() always. The natural_size() of VideoFrames fed by
// VEA::Encode() must be the same as |input_natural_size_|.
gfx::Size input_natural_size_;
// Visible rectangle of VideoFrame to be fed to an encoder driver, in other // Visible rectangle of VideoFrame to be fed to an encoder driver, in other
// words, a visible rectangle that output encoded bitstream buffers represent. // words, a visible rectangle that output encoded bitstream buffers represent.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment