From df5be4b969430c7d933b1bd9d01be3d4836a589d Mon Sep 17 00:00:00 2001 From: David Staessens Date: Mon, 7 Jun 2021 14:54:53 +0900 Subject: v4l2_codec2 encoder: Add support for configuring the bitrate mode. This CL adds support for the C2_PARAMKEY_BITRATE_MODE parameter to the v4l2 encoder. This parameter allows configuring the bitrate mode used to encode a video. The supported bitrate modes are: - C2Config::BITRATE_VARIABLE - C2Config::BITRATE_CONST Note: Currently the C2 framework does not support configuring the peak bitrate, which is used when the bitrate mode is set to VBR. Instead we set the peak bitrate to a multiple of the target bitrate. Note: Submit after support for V4L2_CID_MPEG_VIDEO_BITRATE_PEAK and V4L2_CID_MPEG_VIDEO_BITRATE_MODE has been added to the virto encoder in crrev.com/c/2944506. BUG: 190336806 BUG: 181514834 Test: arc.VideoEncodeAccel.h264_192p_i420_vm Change-Id: I95d8f9921c1ba475ea8c65760d3c18e5e2818d5e --- components/V4L2EncodeInterface.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'components/V4L2EncodeInterface.cpp') diff --git a/components/V4L2EncodeInterface.cpp b/components/V4L2EncodeInterface.cpp index 7f0fb39..2bdf11b 100644 --- a/components/V4L2EncodeInterface.cpp +++ b/components/V4L2EncodeInterface.cpp @@ -310,6 +310,15 @@ void V4L2EncodeInterface::Initialize(const C2String& name) { .withSetter(Setter::StrictValueWithNoDeps) .build()); + addParameter( + DefineParam(mBitrateMode, C2_PARAMKEY_BITRATE_MODE) + .withDefault(new C2StreamBitrateModeTuning::output(0u, C2Config::BITRATE_CONST)) + .withFields( + {C2F(mBitrateMode, value) + .oneOf({C2Config::BITRATE_CONST, C2Config::BITRATE_VARIABLE})}) + .withSetter(Setter::StrictValueWithNoDeps) + .build()); + std::string outputMime; if (getCodecFromComponentName(name) == VideoCodec::H264) { outputMime = MEDIA_MIMETYPE_VIDEO_AVC; -- cgit v1.2.3