diff options
author | David Staessens <dstaessens@google.com> | 2020-07-30 12:11:32 +0900 |
---|---|---|
committer | David Staessens <dstaessens@google.com> | 2020-08-06 11:50:57 +0900 |
commit | d36ce4f62d087f9c8c16106433bd7414c8eacddd (patch) | |
tree | a5e6ed5b46a8bc48bee2145f711a51e3271a3af7 /components | |
parent | 1da573c72d2642c56aae5577b4fe37d7e4727071 (diff) | |
download | v4l2_codec2-d36ce4f62d087f9c8c16106433bd7414c8eacddd.tar.gz |
v4l2_codec2: Move BitstreamBuffer class to BitstreamBuffer.h.
This CL extracts and moves the BitstreamBuffer class into
BitstreamBuffer.h, to allow it to be reused.
Bug: 143333813
Test: tast run $HOST arc.VideoEncodeAccel.h264_vm on hatch-arc-r
Change-Id: I3c8e1054929878bd5a0a3d3a894c0e766874a532
Diffstat (limited to 'components')
-rw-r--r-- | components/V4L2DecodeComponent.cpp | 9 | ||||
-rw-r--r-- | components/V4L2Decoder.cpp | 1 | ||||
-rw-r--r-- | components/include/v4l2_codec2/components/BitstreamBuffer.h | 28 | ||||
-rw-r--r-- | components/include/v4l2_codec2/components/V4L2Decoder.h | 1 | ||||
-rw-r--r-- | components/include/v4l2_codec2/components/VideoDecoder.h | 13 |
5 files changed, 35 insertions, 17 deletions
diff --git a/components/V4L2DecodeComponent.cpp b/components/V4L2DecodeComponent.cpp index 8a86466..1b996d6 100644 --- a/components/V4L2DecodeComponent.cpp +++ b/components/V4L2DecodeComponent.cpp @@ -24,6 +24,7 @@ #include <media/stagefright/foundation/ColorUtils.h> #include <h264_parser.h> +#include <v4l2_codec2/components/BitstreamBuffer.h> #include <v4l2_codec2/components/V4L2Decoder.h> #include <v4l2_codec2/components/VideoFramePool.h> #include <v4l2_codec2/components/VideoTypes.h> @@ -39,8 +40,8 @@ int32_t frameIndexToBitstreamId(c2_cntr64_t frameIndex) { return static_cast<int32_t>(frameIndex.peeku() & 0x3FFFFFFF); } -std::unique_ptr<VideoDecoder::BitstreamBuffer> C2BlockToBitstreamBuffer( - const C2ConstLinearBlock& block, const int32_t bitstreamId) { +std::unique_ptr<BitstreamBuffer> C2BlockToBitstreamBuffer(const C2ConstLinearBlock& block, + const int32_t bitstreamId) { const int fd = block.handle()->data[0]; auto dupFd = ::base::ScopedFD(dup(fd)); if (!dupFd.is_valid()) { @@ -48,8 +49,8 @@ std::unique_ptr<VideoDecoder::BitstreamBuffer> C2BlockToBitstreamBuffer( return nullptr; } - return std::make_unique<VideoDecoder::BitstreamBuffer>(bitstreamId, std::move(dupFd), - block.offset(), block.size()); + return std::make_unique<BitstreamBuffer>(bitstreamId, std::move(dupFd), block.offset(), + block.size()); } bool parseCodedColorAspects(const C2ConstLinearBlock& input, diff --git a/components/V4L2Decoder.cpp b/components/V4L2Decoder.cpp index 275357e..8d0238a 100644 --- a/components/V4L2Decoder.cpp +++ b/components/V4L2Decoder.cpp @@ -10,6 +10,7 @@ #include <stdint.h> #include <base/bind.h> +#include <base/files/scoped_file.h> #include <base/memory/ptr_util.h> #include <log/log.h> diff --git a/components/include/v4l2_codec2/components/BitstreamBuffer.h b/components/include/v4l2_codec2/components/BitstreamBuffer.h new file mode 100644 index 0000000..cc8d3f6 --- /dev/null +++ b/components/include/v4l2_codec2/components/BitstreamBuffer.h @@ -0,0 +1,28 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ANDROID_V4L2_CODEC2_COMPONENTS_BITSTREAMBUFFER_H +#define ANDROID_V4L2_CODEC2_COMPONENTS_BITSTREAMBUFFER_H + +#include <stdint.h> + +#include <base/files/scoped_file.h> + +namespace android { + +struct BitstreamBuffer { + BitstreamBuffer(const int32_t id, base::ScopedFD dmabuf_fd, const size_t offset, + const size_t size) + : id(id), dmabuf_fd(std::move(dmabuf_fd)), offset(offset), size(size) {} + ~BitstreamBuffer() = default; + + const int32_t id; + base::ScopedFD dmabuf_fd; + const size_t offset; + const size_t size; +}; + +} // namespace android + +#endif // ANDROID_V4L2_CODEC2_COMPONENTS_BITSTREAMBUFFER_H diff --git a/components/include/v4l2_codec2/components/V4L2Decoder.h b/components/include/v4l2_codec2/components/V4L2Decoder.h index 9cf0532..cff7bfd 100644 --- a/components/include/v4l2_codec2/components/V4L2Decoder.h +++ b/components/include/v4l2_codec2/components/V4L2Decoder.h @@ -11,7 +11,6 @@ #include <optional> #include <base/callback.h> -#include <base/files/scoped_file.h> #include <base/memory/weak_ptr.h> #include <rect.h> diff --git a/components/include/v4l2_codec2/components/VideoDecoder.h b/components/include/v4l2_codec2/components/VideoDecoder.h index 41517b3..99d16b3 100644 --- a/components/include/v4l2_codec2/components/VideoDecoder.h +++ b/components/include/v4l2_codec2/components/VideoDecoder.h @@ -11,6 +11,7 @@ #include <base/callback.h> #include <base/files/scoped_file.h> +#include <v4l2_codec2/components/BitstreamBuffer.h> #include <v4l2_codec2/components/VideoFrame.h> #include <v4l2_codec2/components/VideoFramePool.h> #include <v4l2_codec2/components/VideoTypes.h> @@ -26,18 +27,6 @@ public: }; static const char* DecodeStatusToString(DecodeStatus status); - struct BitstreamBuffer { - BitstreamBuffer(const int32_t id, base::ScopedFD dmabuf_fd, const size_t offset, - const size_t size) - : id(id), dmabuf_fd(std::move(dmabuf_fd)), offset(offset), size(size) {} - ~BitstreamBuffer() = default; - - const int32_t id; - base::ScopedFD dmabuf_fd; - const size_t offset; - const size_t size; - }; - using GetPoolCB = base::RepeatingCallback<void(std::unique_ptr<VideoFramePool>*, const media::Size& size, HalPixelFormat pixelFormat, size_t numOutputBuffers)>; |