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

Commit 51a39039 authored by Ray Essick's avatar Ray Essick Committed by Android (Google) Code Review
Browse files

Merge changes from topic "gav1_to_qpr1" into qt-qpr1-dev

* changes:
  Switch av1 implementations from aom to gav1
  stagefright: Use libgav1 for AV1 decoding
  codec2: Add log message for the AV1 decoder
  codec2: Implement gav1 decoder component
  codec2: libgav1 integration part 1
parents 6c2b3146 c2cc437a
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
cc_library_shared {
    name: "libcodec2_soft_av1dec",
    name: "libcodec2_soft_av1dec_aom",
    defaults: [
        "libcodec2_soft-defaults",
        "libcodec2_soft_sanitize_all-defaults",
    ],

    // coordinated with frameworks/av/media/codec2/components/gav1/Android.bp
    // so only 1 of them has the official c2.android.av1.decoder name
    cflags: [
        "-DCODECNAME=\"c2.android.av1-aom.decoder\"",
    ],

    srcs: ["C2SoftAomDec.cpp"],
    static_libs: ["libaom"],

+3 −1
Original line number Diff line number Diff line
@@ -29,7 +29,8 @@

namespace android {

constexpr char COMPONENT_NAME[] = "c2.android.av1.decoder";
// codecname set and passed in as a compile flag from Android.bp
constexpr char COMPONENT_NAME[] = CODECNAME;

class C2SoftAomDec::IntfImpl : public SimpleInterface<void>::BaseParams {
  public:
@@ -340,6 +341,7 @@ status_t C2SoftAomDec::initDecoder() {
    aom_codec_flags_t flags;
    memset(&flags, 0, sizeof(aom_codec_flags_t));

    ALOGV("Using libaom AV1 software decoder.");
    aom_codec_err_t err;
    if ((err = aom_codec_dec_init(mCodecCtx, aom_codec_av1_dx(), &cfg, 0))) {
        ALOGE("av1 decoder failed to initialize. (%d)", err);
+20 −0
Original line number Diff line number Diff line
cc_library_shared {
    name: "libcodec2_soft_av1dec_gav1",
    defaults: [
        "libcodec2_soft-defaults",
        "libcodec2_soft_sanitize_all-defaults",
    ],

    // coordinated with frameworks/av/media/codec2/components/aom/Android.bp
    // so only 1 of them has the official c2.android.av1.decoder name
    cflags: [
        "-DCODECNAME=\"c2.android.av1.decoder\"",
    ],

    srcs: ["C2SoftGav1Dec.cpp"],
    static_libs: ["libgav1"],

    include_dirs: [
        "external/libgav1/libgav1/",
    ],
}
+792 −0

File added.

Preview size limit exceeded, changes collapsed.

+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_C2_SOFT_GAV1_DEC_H_
#define ANDROID_C2_SOFT_GAV1_DEC_H_

#include <SimpleC2Component.h>
#include "libgav1/src/decoder.h"
#include "libgav1/src/decoder_settings.h"

#define GETTIME(a, b) gettimeofday(a, b);
#define TIME_DIFF(start, end, diff)     \
    diff = (((end).tv_sec - (start).tv_sec) * 1000000) + \
            ((end).tv_usec - (start).tv_usec);

namespace android {

struct C2SoftGav1Dec : public SimpleC2Component {
  class IntfImpl;

  C2SoftGav1Dec(const char* name, c2_node_id_t id,
                const std::shared_ptr<IntfImpl>& intfImpl);
  ~C2SoftGav1Dec();

  // Begin SimpleC2Component overrides.
  c2_status_t onInit() override;
  c2_status_t onStop() override;
  void onReset() override;
  void onRelease() override;
  c2_status_t onFlush_sm() override;
  void process(const std::unique_ptr<C2Work>& work,
               const std::shared_ptr<C2BlockPool>& pool) override;
  c2_status_t drain(uint32_t drainMode,
                    const std::shared_ptr<C2BlockPool>& pool) override;
  // End SimpleC2Component overrides.

 private:
  std::shared_ptr<IntfImpl> mIntf;
  std::unique_ptr<libgav1::Decoder> mCodecCtx;

  uint32_t mWidth;
  uint32_t mHeight;
  bool mSignalledOutputEos;
  bool mSignalledError;

  struct timeval mTimeStart;  // Time at the start of decode()
  struct timeval mTimeEnd;    // Time at the end of decode()

  bool initDecoder();
  void destroyDecoder();
  void finishWork(uint64_t index, const std::unique_ptr<C2Work>& work,
                  const std::shared_ptr<C2GraphicBlock>& block);
  bool outputBuffer(const std::shared_ptr<C2BlockPool>& pool,
                    const std::unique_ptr<C2Work>& work);
  c2_status_t drainInternal(uint32_t drainMode,
                            const std::shared_ptr<C2BlockPool>& pool,
                            const std::unique_ptr<C2Work>& work);

  C2_DO_NOT_COPY(C2SoftGav1Dec);
};

}  // namespace android

#endif  // ANDROID_C2_SOFT_GAV1_DEC_H_
Loading