Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1af2cc5a authored by Ray Essick's avatar Ray Essick
Browse files

AV1 and HEVC SW codecs min input buffer size

AV1 and HEVC plugins were not imposing a minimum input buffer size,
leading to some test failures where the calculated size was smaller than
some NALs from the extractor.

Bug: 215297028
Test: mts -m CtsMediaTestCases -t android.media.cts.AdaptivePlaybackTest#testAV1_adaptiveSmallDrc
Test: mts -m CtsMediaTestCases -t android.media.cts.AdaptivePlaybackTest#testHEVC_adaptiveSmallDrc
Change-Id: I7f5c8746f085b5f88b1a61f0a37d4d00f3e3e777
parent 2eec25de
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ constexpr uint8_t NEUTRAL_UV_VALUE = 128;
// codecname set and passed in as a compile flag from Android.bp
constexpr char COMPONENT_NAME[] = CODECNAME;

constexpr size_t kMinInputBufferSize = 2 * 1024 * 1024;

class C2SoftGav1Dec::IntfImpl : public SimpleInterface<void>::BaseParams {
 public:
  explicit IntfImpl(const std::shared_ptr<C2ReflectorHelper> &helper)
@@ -114,8 +116,7 @@ class C2SoftGav1Dec::IntfImpl : public SimpleInterface<void>::BaseParams {
            .build());

    addParameter(DefineParam(mMaxInputSize, C2_PARAMKEY_INPUT_MAX_BUFFER_SIZE)
                     .withDefault(new C2StreamMaxBufferSizeInfo::input(
                         0u, 320 * 240 * 3 / 4))
                     .withDefault(new C2StreamMaxBufferSizeInfo::input(0u, kMinInputBufferSize))
                     .withFields({
                         C2F(mMaxInputSize, value).any(),
                     })
@@ -231,9 +232,9 @@ class C2SoftGav1Dec::IntfImpl : public SimpleInterface<void>::BaseParams {
      bool mayBlock, C2P<C2StreamMaxBufferSizeInfo::input> &me,
      const C2P<C2StreamMaxPictureSizeTuning::output> &maxSize) {
    (void)mayBlock;
    // assume compression ratio of 2
    me.set().value =
        (((maxSize.v.width + 63) / 64) * ((maxSize.v.height + 63) / 64) * 3072);
    // assume compression ratio of 2, but enforce a floor
    me.set().value = c2_max((((maxSize.v.width + 63) / 64)
                * ((maxSize.v.height + 63) / 64) * 3072), kMinInputBufferSize);
    return C2R::Ok();
  }

+5 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ namespace {
constexpr char COMPONENT_NAME[] = "c2.android.hevc.decoder";
constexpr uint32_t kDefaultOutputDelay = 8;
constexpr uint32_t kMaxOutputDelay = 16;
constexpr size_t kMinInputBufferSize = 2 * 1024 * 1024;
}  // namespace

class C2SoftHevcDec::IntfImpl : public SimpleInterface<void>::BaseParams {
@@ -108,7 +109,7 @@ public:

        addParameter(
                DefineParam(mMaxInputSize, C2_PARAMKEY_INPUT_MAX_BUFFER_SIZE)
                .withDefault(new C2StreamMaxBufferSizeInfo::input(0u, 320 * 240 * 3 / 4))
                .withDefault(new C2StreamMaxBufferSizeInfo::input(0u, kMinInputBufferSize))
                .withFields({
                    C2F(mMaxInputSize, value).any(),
                })
@@ -220,8 +221,9 @@ public:
    static C2R MaxInputSizeSetter(bool mayBlock, C2P<C2StreamMaxBufferSizeInfo::input> &me,
                                  const C2P<C2StreamMaxPictureSizeTuning::output> &maxSize) {
        (void)mayBlock;
        // assume compression ratio of 2
        me.set().value = (((maxSize.v.width + 63) / 64) * ((maxSize.v.height + 63) / 64) * 3072);
        // assume compression ratio of 2, but enforce a floor
        me.set().value = c2_max((((maxSize.v.width + 63) / 64)
                    * ((maxSize.v.height + 63) / 64) * 3072), kMinInputBufferSize);
        return C2R::Ok();
    }