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

Commit 234b6925 authored by Ray Essick's avatar Ray Essick
Browse files

DO NOT MERGE Provide OMX/xaac Interface

Provides the interfacing between the codec process through OMX into the
new xHE-AAC implementation.

Bug: 77287124
Bug: 72386934
Test: CTS DecoderTest
Change-Id: Ic2ef0cb2ca54969673753938bab1f1456fe045c6
parent 9c2b764d
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
cc_library_shared {
    name: "libstagefright_soft_xaacdec",
    vendor_available: true,

    srcs: [
        "SoftXAAC.cpp",
    ],

    include_dirs: [
        "frameworks/av/media/libstagefright/include",
        "frameworks/native/include/media/openmax",
    ],

    cflags: [
        "-Werror",
    ],

    sanitize: {
        // integer_overflow: true,
        misc_undefined: [ "signed-integer-overflow", "unsigned-integer-overflow", ],
        cfi: true,
    },

    static_libs: ["libxaacdec"],

    shared_libs: [
        "libstagefright_omx",
        "libstagefright_foundation",
        "libutils",
        "libcutils",
        "liblog",
    ],

    compile_multilib: "32",
}
+1329 −0

File added.

Preview size limit exceeded, changes collapsed.

+127 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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 SOFTXAAC_H_
#define SOFTXAAC_H_

#include <media/stagefright/omx/SimpleSoftOMXComponent.h>

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include "ixheaacd_type_def.h"
#include "ixheaacd_error_standards.h"
#include "ixheaacd_error_handler.h"
#include "ixheaacd_apicmd_standards.h"
#include "ixheaacd_memory_standards.h"
#include "ixheaacd_aac_config.h"
//#include "ixheaacd_aac_dec_error.h"

#define MAX_MEM_ALLOCS 100

extern "C" IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_module_obj,
                        WORD32 i_cmd, WORD32 i_idx, pVOID pv_value);

namespace android {

struct SoftXAAC : public SimpleSoftOMXComponent {
    SoftXAAC(const char *name,
            const OMX_CALLBACKTYPE *callbacks,
            OMX_PTR appData,
            OMX_COMPONENTTYPE **component);

protected:
    virtual ~SoftXAAC();

    virtual OMX_ERRORTYPE internalGetParameter(
            OMX_INDEXTYPE index, OMX_PTR params);

    virtual OMX_ERRORTYPE internalSetParameter(
            OMX_INDEXTYPE index, const OMX_PTR params);

    virtual void onQueueFilled(OMX_U32 portIndex);
    virtual void onPortFlushCompleted(OMX_U32 portIndex);
    virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
    virtual void onReset();

private:
    enum {
        kNumInputBuffers        = 4,
        kNumOutputBuffers       = 4,
        kNumDelayBlocksMax      = 8,
    };

    bool mIsADTS;
    size_t mInputBufferCount;
    size_t mOutputBufferCount;
    bool mSignalledError;
    OMX_BUFFERHEADERTYPE *mLastInHeader;
    int64_t mPrevTimestamp;
    int64_t mCurrentTimestamp;
    uint32_t mBufSize;

    enum {
        NONE,
        AWAITING_DISABLED,
        AWAITING_ENABLED
    } mOutputPortSettingsChange;

    void initPorts();
    status_t initDecoder();
    bool isConfigured() const;
    int drainDecoder();
    int initXAACDecoder();
    int deInitXAACDecoder();

    int configXAACDecoder(uint8_t* inBuffer, uint32_t inBufferLength);
    int decodeXAACStream(uint8_t* inBuffer,
                         uint32_t inBufferLength,
                         int32_t *bytesConsumed,
                         int32_t *outBytes);

    void configflushDecode();
    IA_ERRORCODE getXAACStreamInfo();
    IA_ERRORCODE setXAACDRCInfo(int32_t drcCut,
                                int32_t drcBoost,
                                int32_t drcRefLevel,
                                int32_t drcHeavyCompression);

    bool mEndOfInput;
    bool mEndOfOutput;

    void*       mXheaacCodecHandle;
    uint32_t    mInputBufferSize;
    uint32_t    mOutputFrameLength;
    int8_t*     mInputBuffer;
    int8_t*     mOutputBuffer;
    int32_t     mSampFreq;
    int32_t     mNumChannels;
    int32_t     mPcmWdSz;
    int32_t     mChannelMask;
    bool        mIsCodecInitialized;
    bool        mIsCodecConfigFlushRequired;

    void*       mMemoryArray[MAX_MEM_ALLOCS];
    int32_t     mMallocCount;

    DISALLOW_EVIL_CONSTRUCTORS(SoftXAAC);

};

}  // namespace android

#endif  // SOFTXAAC_H_
+5 −0
Original line number Diff line number Diff line
@@ -34,7 +34,12 @@ static const struct {
    const char *mRole;

} kComponents[] = {
    // two choices for aac decoding.
    // configurable in media/libstagefright/data/media_codecs_google_audio.xml
    // default implementation
    { "OMX.google.aac.decoder", "aacdec", "audio_decoder.aac" },
    // alternate implementation
    { "OMX.google.xaac.decoder", "xaacdec", "audio_decoder.aac" },
    { "OMX.google.aac.encoder", "aacenc", "audio_encoder.aac" },
    { "OMX.google.amrnb.decoder", "amrdec", "audio_decoder.amrnb" },
    { "OMX.google.amrnb.encoder", "amrnbenc", "audio_encoder.amrnb" },