From 45c7a57fe0b04a6ad0bae4748c72b4fba402cd55 Mon Sep 17 00:00:00 2001 From: Alix Date: Mon, 18 Apr 2022 04:05:38 +0000 Subject: Deleted clang property in Android.bp files Deleted deprecated clang property in Android.bp files using bpmodify. Bug: 208980553 Test: treehugger Change-Id: Ia6fef78af0555dd7346adbb29c4bb14ad31918a8 --- tests/c2_comp_intf/Android.bp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/c2_comp_intf/Android.bp b/tests/c2_comp_intf/Android.bp index 1d08f6b..6937dee 100644 --- a/tests/c2_comp_intf/Android.bp +++ b/tests/c2_comp_intf/Android.bp @@ -39,5 +39,5 @@ cc_test { "-Wall", ], ldflags: ["-Wl,-Bsymbolic"], - clang: true, + } -- cgit v1.2.3 From 58a3054b25f4fbcbb27747cdcc87b883038fb82a Mon Sep 17 00:00:00 2001 From: Jeffrey Kardatzke Date: Mon, 23 May 2022 14:19:40 -0700 Subject: v4l2_codec2: Add support for HEVC/H265 to the V4L2 decoder. This adds support for the HEVC/H265 codec to the Android codec2 V4L2 decode component. Bug: 215043150 Bug: 183217901 Test: ExoPlayer works with HEVC on guybrush w/ codecs added and corresponding ChromeOS CLs for crosvm/libvda Change-Id: I3707e9730d245871b74982527edfebe81b484e8a (cherry picked from commit 05bacef7fa53541f21c85f26f6f8351dcdfd7f0e) --- common/V4L2ComponentCommon.cpp | 5 +++- common/V4L2Device.cpp | 35 ++++++++++++++++++++++ common/VideoTypes.cpp | 2 ++ .../v4l2_codec2/common/V4L2ComponentCommon.h | 2 ++ common/include/v4l2_codec2/common/VideoTypes.h | 3 +- components/V4L2ComponentStore.cpp | 5 ++++ components/V4L2DecodeInterface.cpp | 33 ++++++++++++++++++++ components/V4L2Decoder.cpp | 2 ++ 8 files changed, 85 insertions(+), 2 deletions(-) diff --git a/common/V4L2ComponentCommon.cpp b/common/V4L2ComponentCommon.cpp index 518b489..f67a516 100644 --- a/common/V4L2ComponentCommon.cpp +++ b/common/V4L2ComponentCommon.cpp @@ -18,15 +18,18 @@ const std::string V4L2ComponentName::kVP9Encoder = "c2.v4l2.vp9.encoder"; const std::string V4L2ComponentName::kH264Decoder = "c2.v4l2.avc.decoder"; const std::string V4L2ComponentName::kVP8Decoder = "c2.v4l2.vp8.decoder"; const std::string V4L2ComponentName::kVP9Decoder = "c2.v4l2.vp9.decoder"; +const std::string V4L2ComponentName::kHEVCDecoder = "c2.v4l2.hevc.decoder"; const std::string V4L2ComponentName::kH264SecureDecoder = "c2.v4l2.avc.decoder.secure"; const std::string V4L2ComponentName::kVP8SecureDecoder = "c2.v4l2.vp8.decoder.secure"; const std::string V4L2ComponentName::kVP9SecureDecoder = "c2.v4l2.vp9.decoder.secure"; +const std::string V4L2ComponentName::kHEVCSecureDecoder = "c2.v4l2.hevc.decoder.secure"; // static bool V4L2ComponentName::isValid(const char* name) { return name == kH264Encoder || name == kVP8Encoder || name == kVP9Encoder || name == kH264Decoder || name == kVP8Decoder || name == kVP9Decoder || - name == kH264SecureDecoder || name == kVP8SecureDecoder || name == kVP9SecureDecoder; + name == kHEVCDecoder || name == kH264SecureDecoder || name == kVP8SecureDecoder || + name == kVP9SecureDecoder || name == kHEVCSecureDecoder; } // static diff --git a/common/V4L2Device.cpp b/common/V4L2Device.cpp index 68a9dca..4e44fed 100644 --- a/common/V4L2Device.cpp +++ b/common/V4L2Device.cpp @@ -50,6 +50,11 @@ #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') #endif +// HEVC parsed slices +#ifndef V4L2_PIX_FMT_HEVC_SLICE +#define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5') +#endif + namespace android { struct v4l2_format buildV4L2Format(const enum v4l2_buf_type type, uint32_t fourcc, @@ -1237,6 +1242,13 @@ uint32_t V4L2Device::C2ProfileToV4L2PixFmt(C2Config::profile_t profile, bool sli } else { return V4L2_PIX_FMT_VP9; } + } else if (profile >= C2Config::PROFILE_HEVC_MAIN && + profile <= C2Config::PROFILE_HEVC_3D_MAIN) { + if (sliceBased) { + return V4L2_PIX_FMT_HEVC_SLICE; + } else { + return V4L2_PIX_FMT_HEVC; + } } else { ALOGE("Unknown profile: %s", profileToString(profile)); return 0; @@ -1283,6 +1295,16 @@ C2Config::profile_t V4L2Device::v4L2ProfileToC2Profile(VideoCodec codec, uint32_ return C2Config::PROFILE_VP9_3; } break; + case VideoCodec::HEVC: + switch (profile) { + case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN: + return C2Config::PROFILE_HEVC_MAIN; + case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE: + return C2Config::PROFILE_HEVC_MAIN_STILL; + case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10: + return C2Config::PROFILE_HEVC_MAIN_10; + } + break; default: ALOGE("Unknown codec: %u", codec); } @@ -1305,6 +1327,9 @@ std::vector V4L2Device::v4L2PixFmtToC2Profiles(uint32_t pix case VideoCodec::VP9: queryId = V4L2_CID_MPEG_VIDEO_VP9_PROFILE; break; + case VideoCodec::HEVC: + queryId = V4L2_CID_MPEG_VIDEO_HEVC_PROFILE; + break; default: return false; } @@ -1355,6 +1380,16 @@ std::vector V4L2Device::v4L2PixFmtToC2Profiles(uint32_t pix profiles = {C2Config::PROFILE_VP9_0}; } break; + case V4L2_PIX_FMT_HEVC: + case V4L2_PIX_FMT_HEVC_SLICE: + if (!getSupportedProfiles(VideoCodec::HEVC, &profiles)) { + ALOGW("Driver doesn't support QUERY HEVC profiles, " + "use default values, Main"); + profiles = { + C2Config::PROFILE_HEVC_MAIN, + }; + } + break; default: ALOGE("Unhandled pixelformat %s", fourccToString(pixFmt).c_str()); return {}; diff --git a/common/VideoTypes.cpp b/common/VideoTypes.cpp index c123ad1..18ebfc9 100644 --- a/common/VideoTypes.cpp +++ b/common/VideoTypes.cpp @@ -19,6 +19,8 @@ const char* VideoCodecToString(VideoCodec codec) { return "VP8"; case VideoCodec::VP9: return "VP9"; + case VideoCodec::HEVC: + return "HEVC"; } } diff --git a/common/include/v4l2_codec2/common/V4L2ComponentCommon.h b/common/include/v4l2_codec2/common/V4L2ComponentCommon.h index b8cf031..a5fbdaf 100644 --- a/common/include/v4l2_codec2/common/V4L2ComponentCommon.h +++ b/common/include/v4l2_codec2/common/V4L2ComponentCommon.h @@ -18,9 +18,11 @@ struct V4L2ComponentName { static const std::string kH264Decoder; static const std::string kVP8Decoder; static const std::string kVP9Decoder; + static const std::string kHEVCDecoder; static const std::string kH264SecureDecoder; static const std::string kVP8SecureDecoder; static const std::string kVP9SecureDecoder; + static const std::string kHEVCSecureDecoder; // Return true if |name| is a valid component name. static bool isValid(const char* name); diff --git a/common/include/v4l2_codec2/common/VideoTypes.h b/common/include/v4l2_codec2/common/VideoTypes.h index 076f096..54786e8 100644 --- a/common/include/v4l2_codec2/common/VideoTypes.h +++ b/common/include/v4l2_codec2/common/VideoTypes.h @@ -18,10 +18,11 @@ enum class VideoCodec { H264, VP8, VP9, + HEVC, }; constexpr std::initializer_list kAllCodecs = {VideoCodec::H264, VideoCodec::VP8, - VideoCodec::VP9}; + VideoCodec::VP9, VideoCodec::HEVC}; const char* VideoCodecToString(VideoCodec codec); const char* profileToString(C2Config::profile_t profile); diff --git a/components/V4L2ComponentStore.cpp b/components/V4L2ComponentStore.cpp index 4004ce5..feb5799 100644 --- a/components/V4L2ComponentStore.cpp +++ b/components/V4L2ComponentStore.cpp @@ -37,6 +37,9 @@ std::string getMediaTypeFromComponentName(const std::string& name) { name == V4L2ComponentName::kVP9Encoder) { return MEDIA_MIMETYPE_VIDEO_VP9; } + if (name == V4L2ComponentName::kHEVCDecoder || name == V4L2ComponentName::kHEVCSecureDecoder) { + return MEDIA_MIMETYPE_VIDEO_HEVC; + } return ""; } @@ -118,6 +121,8 @@ std::vector> V4L2ComponentStore::list ret.push_back(GetTraits(V4L2ComponentName::kVP9Encoder)); ret.push_back(GetTraits(V4L2ComponentName::kVP9Decoder)); ret.push_back(GetTraits(V4L2ComponentName::kVP9SecureDecoder)); + ret.push_back(GetTraits(V4L2ComponentName::kHEVCDecoder)); + ret.push_back(GetTraits(V4L2ComponentName::kHEVCSecureDecoder)); return ret; } diff --git a/components/V4L2DecodeInterface.cpp b/components/V4L2DecodeInterface.cpp index 4bc4121..d22f77b 100644 --- a/components/V4L2DecodeInterface.cpp +++ b/components/V4L2DecodeInterface.cpp @@ -34,6 +34,8 @@ std::optional getCodecFromComponentName(const std::string& name) { return VideoCodec::VP8; if (name == V4L2ComponentName::kVP9Decoder || name == V4L2ComponentName::kVP9SecureDecoder) return VideoCodec::VP9; + if (name == V4L2ComponentName::kHEVCDecoder || name == V4L2ComponentName::kHEVCSecureDecoder) + return VideoCodec::HEVC; ALOGE("Unknown name: %s", name.c_str()); return std::nullopt; @@ -179,6 +181,35 @@ V4L2DecodeInterface::V4L2DecodeInterface(const std::string& name, .withSetter(ProfileLevelSetter) .build()); break; + + case VideoCodec::HEVC: + inputMime = MEDIA_MIMETYPE_VIDEO_HEVC; + addParameter( + DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL) + .withDefault(new C2StreamProfileLevelInfo::input( + 0u, C2Config::PROFILE_HEVC_MAIN, C2Config::LEVEL_HEVC_MAIN_5_1)) + .withFields({C2F(mProfileLevel, profile) + .oneOf({C2Config::PROFILE_HEVC_MAIN, + C2Config::PROFILE_HEVC_MAIN_STILL}), + C2F(mProfileLevel, level) + .oneOf({C2Config::LEVEL_HEVC_MAIN_1, + C2Config::LEVEL_HEVC_MAIN_2, + C2Config::LEVEL_HEVC_MAIN_2_1, + C2Config::LEVEL_HEVC_MAIN_3, + C2Config::LEVEL_HEVC_MAIN_3_1, + C2Config::LEVEL_HEVC_MAIN_4, + C2Config::LEVEL_HEVC_MAIN_4_1, + C2Config::LEVEL_HEVC_MAIN_5, + C2Config::LEVEL_HEVC_MAIN_5_1, + C2Config::LEVEL_HEVC_MAIN_5_2, + C2Config::LEVEL_HEVC_HIGH_4, + C2Config::LEVEL_HEVC_HIGH_4_1, + C2Config::LEVEL_HEVC_HIGH_5, + C2Config::LEVEL_HEVC_HIGH_5_1, + C2Config::LEVEL_HEVC_HIGH_5_2})}) + .withSetter(ProfileLevelSetter) + .build()); + break; } addParameter( @@ -346,6 +377,8 @@ uint32_t V4L2DecodeInterface::getOutputDelay(VideoCodec codec) { // codec2 framework that it should not stop queuing new work items until the maximum number // of frame reordering is reached, to avoid stalling the decoder. return 16; + case VideoCodec::HEVC: + return 16; case VideoCodec::VP8: return 0; case VideoCodec::VP9: diff --git a/components/V4L2Decoder.cpp b/components/V4L2Decoder.cpp index aa59e91..cc2c1d1 100644 --- a/components/V4L2Decoder.cpp +++ b/components/V4L2Decoder.cpp @@ -42,6 +42,8 @@ uint32_t VideoCodecToV4L2PixFmt(VideoCodec codec) { return V4L2_PIX_FMT_VP8; case VideoCodec::VP9: return V4L2_PIX_FMT_VP9; + case VideoCodec::HEVC: + return V4L2_PIX_FMT_HEVC; } } -- cgit v1.2.3 From 215d6b168ce68492cb3448ad06f9cf98e8d13532 Mon Sep 17 00:00:00 2001 From: Jeffrey Kardatzke Date: Tue, 24 May 2022 14:49:13 -0700 Subject: v4l2_codec2: Add support for HEVC to the video decoder tests. This adds support for the HEVC codec to the e2e video decoder tests. Bug: 215043150 Bug: 183217901 Test: c2_e2e_test APK works for HEVC on guybrush w/ codecs added and corresponding crosvm/libvda changes Change-Id: I7b3351cede200f9be406960e2d6507d58acac55c (cherry picked from commit e43cc425ce63d39c8ba9bdb6bb60fd08c5a3b02a) --- tests/c2_e2e_test/jni/common.cpp | 3 ++ tests/c2_e2e_test/jni/common.h | 6 +++ tests/c2_e2e_test/jni/encoded_data_helper.cpp | 53 +++++++++++++++--------- tests/c2_e2e_test/jni/encoded_data_helper.h | 14 +++++-- tests/c2_e2e_test/jni/mediacodec_decoder.cpp | 4 +- tests/c2_e2e_test/jni/video_decoder_e2e_test.cpp | 4 +- 6 files changed, 59 insertions(+), 25 deletions(-) diff --git a/tests/c2_e2e_test/jni/common.cpp b/tests/c2_e2e_test/jni/common.cpp index 50f4cdf..673e36c 100644 --- a/tests/c2_e2e_test/jni/common.cpp +++ b/tests/c2_e2e_test/jni/common.cpp @@ -257,6 +257,7 @@ VideoCodecType VideoCodecProfileToType(VideoCodecProfile profile) { if (profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX) return VideoCodecType::H264; if (profile >= VP8PROFILE_MIN && profile <= VP8PROFILE_MAX) return VideoCodecType::VP8; if (profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX) return VideoCodecType::VP9; + if (profile >= HEVCPROFILE_MIN && profile <= HEVCPROFILE_MAX) return VideoCodecType::HEVC; return VideoCodecType::UNKNOWN; } @@ -286,6 +287,8 @@ const char* GetMimeType(VideoCodecType type) { return "video/x-vnd.on2.vp8"; case VideoCodecType::VP9: return "video/x-vnd.on2.vp9"; + case VideoCodecType::HEVC: + return "video/hevc"; default: // unknown type return nullptr; } diff --git a/tests/c2_e2e_test/jni/common.h b/tests/c2_e2e_test/jni/common.h index ea8d212..b28fd3a 100644 --- a/tests/c2_e2e_test/jni/common.h +++ b/tests/c2_e2e_test/jni/common.h @@ -41,6 +41,11 @@ enum VideoCodecProfile { VP9PROFILE_PROFILE2 = 14, VP9PROFILE_PROFILE3 = 15, VP9PROFILE_MAX = VP9PROFILE_PROFILE3, + HEVCPROFILE_MIN = 16, + HEVCPROFILE_MAIN = HEVCPROFILE_MIN, + HEVCPROFILE_MAIN10 = 17, + HEVCPROFILE_MAIN_STILL_PICTURE = 18, + HEVCPROFILE_MAX = HEVCPROFILE_MAIN_STILL_PICTURE, }; // The enum class of video codec type. @@ -49,6 +54,7 @@ enum class VideoCodecType { H264, VP8, VP9, + HEVC, }; // Structure to store resolution. diff --git a/tests/c2_e2e_test/jni/encoded_data_helper.cpp b/tests/c2_e2e_test/jni/encoded_data_helper.cpp index 0ced022..54e4382 100644 --- a/tests/c2_e2e_test/jni/encoded_data_helper.cpp +++ b/tests/c2_e2e_test/jni/encoded_data_helper.cpp @@ -43,12 +43,12 @@ bool GetPosForNextNALUHeader(const std::string& data, size_t* next_header_pos) { } if (pos + 3 >= data.size()) return false; // No more NALUs - // NALU header is the first byte after Annex-B start code. + // NALU header is the first byte after Annex-B start code for H264/HEVC. *next_header_pos = pos + 3; return true; } -// For H264, return data bytes of next AU fragment in |data| from |next_pos|, +// For H264/HEVC, return data bytes of next AU fragment in |data| from |next_pos|, // and update the position to |next_pos|. std::string GetBytesForNextAU(const std::string& data, size_t* next_pos) { // Helpful description: @@ -144,6 +144,7 @@ void EncodedDataHelper::SliceToFragments(const std::string& data) { std::unique_ptr fragment(new Fragment()); switch (type_) { case VideoCodecType::H264: + case VideoCodecType::HEVC: fragment->data = GetBytesForNextAU(data, &next_pos); if (!ParseAUFragmentType(fragment.get())) continue; if (!seen_csd && !fragment->csd_flag) @@ -178,23 +179,37 @@ bool EncodedDataHelper::ParseAUFragmentType(Fragment* fragment) { return false; } - // Check NALU type ([3:7], 5-bit). - uint8_t nalu_type = nalu_header & 0x1f; - switch (nalu_type) { - case NON_IDR_SLICE: - case IDR_SLICE: - // If AU contains both CSD and VCL NALUs (e.g. PPS + IDR_SLICE), don't - // raise csd_flag, treat this fragment as VCL one. - fragment->csd_flag = false; - return true; // fragment in interest as VCL. - case SPS: - case PPS: - fragment->csd_flag = true; - // Continue on finding the subsequent NALUs, it may have VCL data. - break; - default: - // Skip uninterested NALU type. - break; + if (type_ == VideoCodecType::H264) { + // Check NALU type ([3:7], 5-bit). + uint8_t nalu_type = nalu_header & 0x1f; + switch (nalu_type) { + case NON_IDR_SLICE: + case IDR_SLICE: + // If AU contains both CSD and VCL NALUs (e.g. PPS + IDR_SLICE), don't + // raise csd_flag, treat this fragment as VCL one. + fragment->csd_flag = false; + return true; // fragment in interest as VCL. + case SPS: + case PPS: + fragment->csd_flag = true; + // Continue on finding the subsequent NALUs, it may have VCL data. + break; + default: + // Skip uninterested NALU type. + break; + } + } else if (type_ == VideoCodecType::HEVC) { + // Check NALU type ([1:7], 6-bit). + uint8_t nalu_type = (nalu_header & 0x7e) >> 1; + if (nalu_type >= VCL_NALU_MIN && nalu_type <= VCL_NALU_MAX) { + // If AU contains both CSD and VCL NALUs (e.g. PPS + IDR_SLICE), don't + // raise csd_flag, treat this fragment as VCL one. + fragment->csd_flag = false; + return true; // fragment in interest as VCL. + } else if (nalu_type >= CSD_NALU_MIN && nalu_type <= CSD_NALU_MAX) { + fragment->csd_flag = true; + // Continue on finding the subsequent NALUs, it may have VCL data. + } } } return fragment->csd_flag; // fragment in interest as CSD. diff --git a/tests/c2_e2e_test/jni/encoded_data_helper.h b/tests/c2_e2e_test/jni/encoded_data_helper.h index cf107c2..9ec5086 100644 --- a/tests/c2_e2e_test/jni/encoded_data_helper.h +++ b/tests/c2_e2e_test/jni/encoded_data_helper.h @@ -21,7 +21,7 @@ public: EncodedDataHelper(const std::string& file_path, VideoCodecType type); ~EncodedDataHelper(); - // A fragment will contain the bytes of one AU (H264) or frame (VP8/9) in + // A fragment will contain the bytes of one AU (H264/HEVC) or frame (VP8/9) in // |data|, and |csd_flag| indicator for input buffer flag CODEC_CONFIG. struct Fragment { std::string data; @@ -41,17 +41,25 @@ public: private: // NALU type enumeration as defined in H264 Annex-B. Only interested ones are // listed here. - enum NALUType : uint8_t { + enum H264NALUType : uint8_t { NON_IDR_SLICE = 0x1, IDR_SLICE = 0x5, SPS = 0x7, PPS = 0x8, }; + // NALU type enumeration for ranges for VCL and CSD NALUs for HEVC. + enum HEVCNALUType : uint8_t { + VCL_NALU_MIN = 0, + VCL_NALU_MAX = 31, + CSD_NALU_MIN = 32, // VPS, SPS, PPS + CSD_NALU_MAX = 34, + }; + // Slice input stream into fragments. This should be done in constructor. void SliceToFragments(const std::string& data); - // For H264, parse csd_flag from |fragment| data and store inside. Return true + // For H264/HEVC, parse csd_flag from |fragment| data and store inside. Return true // if this fragment is in interest; false otherwise (fragment will be // discarded.) bool ParseAUFragmentType(Fragment* fragment); diff --git a/tests/c2_e2e_test/jni/mediacodec_decoder.cpp b/tests/c2_e2e_test/jni/mediacodec_decoder.cpp index b14a841..cbebfdd 100644 --- a/tests/c2_e2e_test/jni/mediacodec_decoder.cpp +++ b/tests/c2_e2e_test/jni/mediacodec_decoder.cpp @@ -32,7 +32,7 @@ constexpr size_t kTimeoutMaxRetries = 500; // Helper function to get possible C2 hardware decoder names from |type|. // Note: A single test APK is built for both ARC++ and ARCVM, so both the VDA decoder and the new -// V4L2 decoder names need to be specified here. +// V4L2 decoder names need to be specified here (except for HEVC, which is only on ARCVM). std::vector GetC2VideoDecoderNames(VideoCodecType type) { switch (type) { case VideoCodecType::H264: @@ -41,6 +41,8 @@ std::vector GetC2VideoDecoderNames(VideoCodecType type) { return {"c2.v4l2.vp8.decoder", "c2.vda.vp8.decoder"}; case VideoCodecType::VP9: return {"c2.v4l2.vp9.decoder", "c2.vda.vp9.decoder"}; + case VideoCodecType::HEVC: + return {"c2.v4l2.hevc.decoder"}; default: // unknown type return {}; } diff --git a/tests/c2_e2e_test/jni/video_decoder_e2e_test.cpp b/tests/c2_e2e_test/jni/video_decoder_e2e_test.cpp index 46b497f..62589c2 100644 --- a/tests/c2_e2e_test/jni/video_decoder_e2e_test.cpp +++ b/tests/c2_e2e_test/jni/video_decoder_e2e_test.cpp @@ -50,10 +50,10 @@ public: // "input_file_path:width:height:num_frames:num_fragments:min_fps_render: // min_fps_no_render:video_codec_profile[:output_file_path]" // - |input_file_path| is compressed video stream in H264 Annex B (NAL) format - // (H264) or IVF (VP8/9). + // (H264/HEVC) or IVF (VP8/9). // - |width| and |height| are visible frame size in pixels. // - |num_frames| is the number of picture frames for the input stream. - // - |num_fragments| is the number of AU (H264) or frame (VP8/9) in the input + // - |num_fragments| is the number of AU (H264/HEVC) or frame (VP8/9) in the input // stream. (Unused. Test will automatically parse the number.) // - |min_fps_render| and |min_fps_no_render| are minimum frames/second speeds // expected to be achieved with and without rendering respective. -- cgit v1.2.3 From 001a09bd31df7b48095344ea657165a1d420c441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Grzesik?= Date: Wed, 29 Jun 2022 09:51:27 +0000 Subject: V4L2EncodeComponent: allow user to disable VBR This patch adds a Android system property persist.vendor.v4l2_codec2.disable_vbr. The property allows user to disable option to encode with variable bitrate in runtime. This change is required for a temporary workaround for b/235771157. Bug: 235771157, 238835187 Test: android.video.cts.VideoEncoderDecoderTest#testVp8Other0Perf0640x0360 Change-Id: I4a9931431354193968f8255d0d501aed02ee3508 (cherry picked from commit f9f4b5681ff4fc22cd83192b17693d90922134c7) --- components/V4L2EncodeComponent.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/V4L2EncodeComponent.cpp b/components/V4L2EncodeComponent.cpp index c2a2679..f9d735d 100644 --- a/components/V4L2EncodeComponent.cpp +++ b/components/V4L2EncodeComponent.cpp @@ -652,6 +652,12 @@ bool V4L2EncodeComponent::initializeEncoder() { // Get the requested bitrate mode and bitrate. The C2 framework doesn't offer a parameter to // configure the peak bitrate, so we use a multiple of the target bitrate. mBitrateMode = mInterface->getBitrateMode(); + if (property_get_bool("persist.vendor.v4l2_codec2.disable_vbr", false)) { + // NOTE: This is a workaround for b/235771157. + ALOGW("VBR is disabled on this device"); + mBitrateMode = C2Config::BITRATE_CONST; + } + mBitrate = mInterface->getBitrate(); mEncoder = V4L2Encoder::create( -- cgit v1.2.3