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

Commit 0615ac24 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12896565 from 72974519 to 25Q2-release

Change-Id: I72b0c74cd7393e912021435b0eb02ea87d481d2b
parents 642d4388 72974519
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ aidl_interface {
    double_loadable: true,
    local_include_dir: "aidl",
    srcs: [
        "aidl/android/media/IAudioManagerNative.aidl",
        "aidl/android/media/InterpolatorConfig.aidl",
        "aidl/android/media/InterpolatorType.aidl",
        "aidl/android/media/MicrophoneInfoFw.aidl",
+48 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 The Android Open Source Project
 * Copyright (C) 2024 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.
@@ -13,52 +13,36 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.media;

#ifndef SOFT_G711_H_

#define SOFT_G711_H_

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

namespace android {

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

protected:
    virtual ~SoftG711();

    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);

private:
    enum {
        kNumBuffers = 4,
        kMaxNumSamplesPerFrame = 16384,
    };

    bool mIsMLaw;
    bool mSignalledError;
    OMX_U32 mNumChannels;
    int32_t mSamplingRate;

    void initPorts();

    static void DecodeALaw(int16_t *out, const uint8_t *in, size_t inSize);
    static void DecodeMLaw(int16_t *out, const uint8_t *in, size_t inSize);

    DISALLOW_EVIL_CONSTRUCTORS(SoftG711);
};

}  // namespace android

#endif  // SOFT_G711_H_
/**
 * Native accessible interface for AudioService.
 * Note this interface has a mix of oneway and non-oneway methods. This is intentional for certain
 * calls intended to come from audioserver.
 * {@hide}
 */
interface IAudioManagerNative {
    enum HardeningType {
        // Restricted due to OP_CONTROL_AUDIO_PARTIAL
        // This OP is more permissive than OP_CONTROL_AUDIO, which allows apps in a foreground state
        // not associated with FGS to access audio
        PARTIAL,
        // Restricted due to OP_CONTROL_AUDIO
        FULL,
    }

    /**
     * audioserver is muting playback due to hardening.
     * Calls which aren't from uid 1041 are dropped.
     * @param uid - the uid whose playback is restricted
     * @param type - the level of playback restriction which was hit (full or partial)
     * @param bypassed - true if the client should be muted but was exempted (for example due to a
     * certain audio usage to prevent regressions)
     */
    oneway void playbackHardeningEvent(in int uid, in HardeningType type, in boolean bypassed);

    /**
     * Block until AudioService synchronizes pending permission state with audioserver.
     */
    void permissionUpdateBarrier();
}
+2 −4
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ void C2SoftAmrNbEnc::process(
        mProcessedSamples * 1000000ll / mIntf->getSampleRate();
    size_t inPos = 0;
    size_t outPos = 0;
    while (inPos < inSize) {
    while (inPos < inSize || eos) {
        const uint8_t *inPtr = rView.data() + inOffset;
        int validSamples = mFilledLen / sizeof(int16_t);
        if ((inPos + (kNumBytesPerInputFrame - mFilledLen)) <= inSize) {
@@ -240,11 +240,10 @@ void C2SoftAmrNbEnc::process(
            memcpy(mInputFrame + validSamples, inPtr + inPos, (inSize - inPos));
            mFilledLen += (inSize - inPos);
            inPos += (inSize - inPos);
            if (eos) {
            if (eos && (mFilledLen > 0)) {
                validSamples = mFilledLen / sizeof(int16_t);
                memset(mInputFrame + validSamples, 0, (kNumBytesPerInputFrame - mFilledLen));
            } else break;

        }
        Frame_Type_3GPP frameType;
        int numEncBytes = AMREncode(mEncState, mSidState, mMode, mInputFrame,
@@ -278,7 +277,6 @@ void C2SoftAmrNbEnc::process(
    if (eos) {
        mSignalledOutputEos = true;
        ALOGV("signalled EOS");
        if (mFilledLen) ALOGV("Discarding trailing %d bytes", mFilledLen);
    }
}

+2 −3
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ void C2SoftAmrWbEnc::process(
        mProcessedSamples * 1000000ll / mIntf->getSampleRate();
    size_t inPos = 0;
    size_t outPos = 0;
    while (inPos < inSize) {
    while (inPos < inSize || eos) {
        const uint8_t *inPtr = rView.data() + inOffset;
        int validSamples = mFilledLen / sizeof(int16_t);
        if ((inPos + (kNumBytesPerInputFrame - mFilledLen)) <= inSize) {
@@ -322,7 +322,7 @@ void C2SoftAmrWbEnc::process(
            memcpy(mInputFrame + validSamples, inPtr + inPos, (inSize - inPos));
            mFilledLen += (inSize - inPos);
            inPos += (inSize - inPos);
            if (eos) {
            if (eos && (mFilledLen > 0)) {
                validSamples = mFilledLen / sizeof(int16_t);
                memset(mInputFrame + validSamples, 0, (kNumBytesPerInputFrame - mFilledLen));
            } else break;
@@ -352,7 +352,6 @@ void C2SoftAmrWbEnc::process(
    if (eos) {
        mSignalledOutputEos = true;
        ALOGV("signalled EOS");
        if (mFilledLen) ALOGV("Discarding trailing %d bytes", mFilledLen);
    }
}

+78 −58
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ const char* MEDIA_MIMETYPE_VIDEO_APV = "video/apv";
#define IS_AUX_FRM(frm) (!(IS_NON_AUX_FRM(frm)))
#define OUTPUT_CSP_NATIVE (0)
#define OUTPUT_CSP_P210 (1)
#define CLIP3(min, v, max) (((v) < (min)) ? (min) : (((max) > (v)) ? (v) : (max)))

namespace android {
namespace {
@@ -881,14 +882,17 @@ static void copyBufferFromP210ToYV12(uint8_t* dstY, uint8_t* dstU, uint8_t* dstV
                                     size_t dstVStride, size_t width, size_t height) {
    for (size_t i = 0; i < height; ++i) {
        for (size_t j = 0; j < width; ++j) {
            dstY[i * dstYStride + j] = (srcY[i * srcYStride + j] >> 8) & 0xFF;
            dstY[i * dstYStride + j] = (uint8_t)CLIP3(0, 255,
                            ((((int)srcY[i * srcYStride + j] >> 6) * 255.0) / 1023.0 + 0.5));
        }
    }

    for (size_t i = 0; i < height / 2; ++i) {
        for (size_t j = 0; j < width / 2; ++j) {
            dstV[i * dstVStride + j] = (srcUV[i * srcUVStride * 2 + j * 2] >> 8) & 0xFF;
            dstU[i * dstUStride + j] = (srcUV[i * srcUVStride * 2 + j * 2 + 1] >> 8) & 0xFF;
            dstU[i * dstVStride + j] = (uint8_t)CLIP3(0, 255,
                ((((int)srcUV[i * srcUVStride * 2 + j * 2] >> 6) * 255.0) / 1023.0 + 0.5));
            dstV[i * dstUStride + j] = (uint8_t)CLIP3(0, 255,
                ((((int)srcUV[i * srcUVStride * 2 + j * 2 + 1] >> 6) * 255.0) / 1023.0 + 0.5));
        }
    }
}
@@ -1370,6 +1374,9 @@ status_t C2SoftApvDec::outputBuffer(const std::shared_ptr<C2BlockPool>& pool,
                                     : (format == HAL_PIXEL_FORMAT_YV12 ? "YV12" : "UNKNOWN")));
        }
    } else {  // HAL_PIXEL_FORMAT_YV12
        if (!IsI420(wView)) {
            ALOGE("Only P210 to I420 conversion is supported.");
        } else {
            if (OAPV_CS_GET_BIT_DEPTH(imgbOutput->cs) == 10) {
                const uint16_t* srcY = (const uint16_t*)imgbOutput->a[0];
                const uint16_t* srcV = (const uint16_t*)imgbOutput->a[1];
@@ -1379,20 +1386,24 @@ status_t C2SoftApvDec::outputBuffer(const std::shared_ptr<C2BlockPool>& pool,
                size_t srcUStride = imgbOutput->s[2] / 2;
                if (OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CF_YCBCR420) {
                    ALOGV("OAPV_CS_YUV420 10bit to YV12");
                copyBufferFromYUV42010bitToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride,
                                                srcUStride, srcVStride, dstYStride, dstUStride,
                                                dstVStride, mWidth, mHeight);
                    copyBufferFromYUV42010bitToYV12(
                        dstY, dstU, dstV, srcY, srcU, srcV, srcYStride, srcUStride,
                        srcVStride, dstYStride, dstUStride, dstVStride, mWidth,
                        mHeight);
                } else if (OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CF_YCBCR422) {
                    ALOGV("OAPV_CS_YUV422 10bit to YV12");
                copyBufferFromYUV42210bitToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride,
                                                srcUStride, srcVStride, dstYStride, dstUStride,
                                                dstVStride, mWidth, mHeight);
                    copyBufferFromYUV42210bitToYV12(
                        dstY, dstU, dstV, srcY, srcU, srcV, srcYStride, srcUStride,
                        srcVStride, dstYStride, dstUStride, dstVStride, mWidth,
                        mHeight);
                } else if (OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CF_PLANAR2) {
                    ALOGV("OAPV_CS_P210 to YV12");
                copyBufferFromP210ToYV12(dstY, dstU, dstV, srcY, srcV, srcYStride, srcVStride,
                                         dstYStride, dstUStride, dstVStride, mWidth, mHeight);
                    copyBufferFromP210ToYV12(dstY, dstU, dstV, srcY, srcV, srcYStride,
                                       srcVStride, dstYStride, dstUStride,
                                       dstVStride, mWidth, mHeight);
                } else {
                ALOGE("Not supported convert format : %d", OAPV_CS_GET_FORMAT(imgbOutput->cs));
                    ALOGE("Not supported convert format : %d",
                            OAPV_CS_GET_FORMAT(imgbOutput->cs));
                }
            } else if (OAPV_CS_GET_BIT_DEPTH(imgbOutput->cs) == 8) {
                const uint8_t* srcY = (const uint8_t*)imgbOutput->a[0];
@@ -1403,30 +1414,39 @@ status_t C2SoftApvDec::outputBuffer(const std::shared_ptr<C2BlockPool>& pool,
                size_t srcUStride = imgbOutput->s[2];
                if (OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CF_YCBCR420) {
                    ALOGV("OAPV_CS_YUV420 to YV12");
                copyBufferFromYUV420ToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride,
                                           srcUStride, srcVStride, dstYStride, dstUStride,
                                           dstVStride, mWidth, mHeight);
                    copyBufferFromYUV420ToYV12(dstY, dstU, dstV, srcY, srcU, srcV,
                                         srcYStride, srcUStride, srcVStride,
                                         dstYStride, dstUStride, dstVStride,
                                         mWidth, mHeight);
                } else if (OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CF_YCBCR422) {
                    ALOGV("OAPV_CS_YUV422 to YV12");
                copyBufferFromYUV422ToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride,
                                           srcUStride, srcVStride, dstYStride, dstUStride,
                                           dstVStride, mWidth, mHeight);
                    copyBufferFromYUV422ToYV12(dstY, dstU, dstV, srcY, srcU, srcV,
                                         srcYStride, srcUStride, srcVStride,
                                         dstYStride, dstUStride, dstVStride,
                                         mWidth, mHeight);
                } else {
                ALOGE("Not supported convert format : %d", OAPV_CS_GET_FORMAT(imgbOutput->cs));
                    ALOGE("Not supported convert format : %d",
                        OAPV_CS_GET_FORMAT(imgbOutput->cs));
                }
            } else {
            ALOGE("Not supported convert from bd:%d, format: %d(%s), to format: %d(%s)",
                  OAPV_CS_GET_BIT_DEPTH(imgbOutput->cs), OAPV_CS_GET_FORMAT(imgbOutput->cs),
                ALOGE(
                "Not supported convert from bd:%d, format: %d(%s), to format: "
                    "%d(%s)",
                    OAPV_CS_GET_BIT_DEPTH(imgbOutput->cs),
                    OAPV_CS_GET_FORMAT(imgbOutput->cs),
                    OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CF_YCBCR420
                        ? "YUV420"
                          : (OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CF_YCBCR422 ? "YUV422"
                        : (OAPV_CS_GET_FORMAT(imgbOutput->cs) == OAPV_CF_YCBCR422
                           ? "YUV422"
                           : "UNKNOWN"),
                    format,
                    format == HAL_PIXEL_FORMAT_YCBCR_P010
                        ? "P010"
                        : (format == HAL_PIXEL_FORMAT_YCBCR_420_888
                           ? "YUV420"
                                     : (format == HAL_PIXEL_FORMAT_YV12 ? "YV12" : "UNKNOWN")));
                           : (format == HAL_PIXEL_FORMAT_YV12 ? "YV12"
                                                              : "UNKNOWN")));
            }
        }
    }

Loading