v4l2_codec2: Update output buffer size after configuring input format.

When configuring the input format the output buffer size might be
adjusted. This CL makes changes to properly update the output buffer
size.

Bug: 162804477
Test: tast run DUT arc.VideoEncodeAccel.h264_1080p_i420_vm on hatch
Change-Id: I60de6b451eda93c1a68315b9f4dd0e7bb40a6251
diff --git a/components/V4L2EncodeComponent.cpp b/components/V4L2EncodeComponent.cpp
index 5f5760a..ad26fe9 100644
--- a/components/V4L2EncodeComponent.cpp
+++ b/components/V4L2EncodeComponent.cpp
@@ -686,6 +686,18 @@
     // TODO(dstaessens): How is this different from mInputLayout->coded_size()?
     mInputCodedSize = media::V4L2Device::AllocatedSizeFromV4L2Format(*format);
 
+    // Configuring the input format might cause the output buffer size to change.
+    auto outputFormat = mOutputQueue->GetFormat();
+    if (!outputFormat.first) {
+        ALOGE("Failed to get output format (errno: %i)", outputFormat.second);
+        return false;
+    }
+    uint32_t AdjustedOutputBufferSize = outputFormat.first->fmt.pix_mp.plane_fmt[0].sizeimage;
+    if (mOutputBufferSize != AdjustedOutputBufferSize) {
+        mOutputBufferSize = AdjustedOutputBufferSize;
+        ALOGV("Output buffer size adjusted to: %u", mOutputBufferSize);
+    }
+
     // Add an input format convertor if the device doesn't support the requested input format.
     // Note: The amount of input buffers in the convertor should match the amount of buffers on the
     // device input queue, to simplify logic.
@@ -765,7 +777,7 @@
     }
 
     // The device might adjust the requested output buffer size to match hardware requirements.
-    mOutputBufferSize = ::base::checked_cast<size_t>(format->fmt.pix_mp.plane_fmt[0].sizeimage);
+    mOutputBufferSize = format->fmt.pix_mp.plane_fmt[0].sizeimage;
 
     ALOGV("Output format set to %s (buffer size: %u)", media::GetProfileName(outputProfile).c_str(),
           mOutputBufferSize);