diff options
author | pbu <pbu@semihalf.com> | 2022-07-26 13:34:40 +0200 |
---|---|---|
committer | Marcin Wojtas <mwojtas@google.com> | 2023-01-29 19:57:31 +0000 |
commit | 716f4f7dd10829504064cf52aa3e6df6a1abe797 (patch) | |
tree | c14545acf48b2de3d3211d35e60921f28309342e | |
parent | 2505e1b9012401e071076eb42cd613c7364f3f94 (diff) | |
download | v4l2_codec2-716f4f7dd10829504064cf52aa3e6df6a1abe797.tar.gz |
V4L2Device: Replace arguments from table to vector
Argument numFormats is not needed because vector can return it's size.
Operating on vector is more convenient and allows to avoid problems with
incorrect size and exceeding array boundaries.
Bug: 251420501
Test: android.media.cts.DecoderTest
Change-Id: I059cdf60741c39c8a6de4428420d17cbdec3c223
(cherry picked from commit f16288b60b880e314722a795fd32e5ca4f34631c)
-rw-r--r-- | common/V4L2Device.cpp | 9 | ||||
-rw-r--r-- | common/include/v4l2_codec2/common/V4L2Device.h | 7 |
2 files changed, 7 insertions, 9 deletions
diff --git a/common/V4L2Device.cpp b/common/V4L2Device.cpp index bff6e62..380c548 100644 --- a/common/V4L2Device.cpp +++ b/common/V4L2Device.cpp @@ -1881,7 +1881,7 @@ std::vector<uint32_t> V4L2Device::enumerateSupportedPixelformats(v4l2_buf_type b } V4L2Device::SupportedDecodeProfiles V4L2Device::getSupportedDecodeProfiles( - const size_t numFormats, const uint32_t pixelFormats[]) { + const std::vector<uint32_t>& pixelFormats) { SupportedDecodeProfiles supportedProfiles; Type type = Type::kDecoder; @@ -1892,7 +1892,7 @@ V4L2Device::SupportedDecodeProfiles V4L2Device::getSupportedDecodeProfiles( continue; } - const auto& profiles = enumerateSupportedDecodeProfiles(numFormats, pixelFormats); + const auto& profiles = enumerateSupportedDecodeProfiles(pixelFormats); supportedProfiles.insert(supportedProfiles.end(), profiles.begin(), profiles.end()); closeDevice(); } @@ -1920,15 +1920,14 @@ V4L2Device::SupportedEncodeProfiles V4L2Device::getSupportedEncodeProfiles() { } V4L2Device::SupportedDecodeProfiles V4L2Device::enumerateSupportedDecodeProfiles( - const size_t numFormats, const uint32_t pixelFormats[]) { + const std::vector<uint32_t>& pixelFormats) { SupportedDecodeProfiles profiles; const auto& supportedPixelformats = enumerateSupportedPixelformats(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); for (uint32_t pixelFormat : supportedPixelformats) { - if (std::find(pixelFormats, pixelFormats + numFormats, pixelFormat) == - pixelFormats + numFormats) + if (std::find(pixelFormats.begin(), pixelFormats.end(), pixelFormat) == pixelFormats.end()) continue; SupportedDecodeProfile profile; diff --git a/common/include/v4l2_codec2/common/V4L2Device.h b/common/include/v4l2_codec2/common/V4L2Device.h index 9897954..07b271e 100644 --- a/common/include/v4l2_codec2/common/V4L2Device.h +++ b/common/include/v4l2_codec2/common/V4L2Device.h @@ -437,8 +437,7 @@ public: // Return supported profiles for decoder, including only profiles for given fourcc // |pixelFormats|. - SupportedDecodeProfiles getSupportedDecodeProfiles(const size_t numFormats, - const uint32_t pixelFormats[]); + SupportedDecodeProfiles getSupportedDecodeProfiles(const std::vector<uint32_t>& pixelFormats); // Return supported profiles for encoder. SupportedEncodeProfiles getSupportedEncodeProfiles(); @@ -481,8 +480,8 @@ private: V4L2Device(const V4L2Device&) = delete; V4L2Device& operator=(const V4L2Device&) = delete; - SupportedDecodeProfiles enumerateSupportedDecodeProfiles(const size_t numFormats, - const uint32_t pixelFormats[]); + SupportedDecodeProfiles enumerateSupportedDecodeProfiles( + const std::vector<uint32_t>& pixelFormats); SupportedEncodeProfiles enumerateSupportedEncodeProfiles(); |