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

Commit ad949cd4 authored by Lajos Molnar's avatar Lajos Molnar Committed by Android (Google) Code Review
Browse files

Merge "stagefright: ask for flex-YUV camera buffers for software encoders" into mnc-dev

parents 29b7cec9 c93a1366
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -108,6 +108,9 @@ private:
    bool mStarted;
    bool mStopping;
    bool mDoMoreWorkPending;
    bool mSetEncoderFormat;
    int mEncoderFormat;
    int mEncoderDataSpace;
    sp<AMessage> mEncoderActivityNotify;
    sp<IGraphicBufferProducer> mGraphicBufferProducer;
    sp<IGraphicBufferConsumer> mGraphicBufferConsumer;
+3 −1
Original line number Diff line number Diff line
@@ -70,7 +70,9 @@ enum {
    kKeyDriftTime         = 'dftT',  // int64_t (usecs)
    kKeyAnchorTime        = 'ancT',  // int64_t (usecs)
    kKeyDuration          = 'dura',  // int64_t (usecs)
    kKeyColorFormat       = 'colf',
    kKeyPixelFormat       = 'pixf',  // int32_t
    kKeyColorFormat       = 'colf',  // int32_t
    kKeyColorSpace        = 'cols',  // int32_t
    kKeyPlatformPrivate   = 'priv',  // pointer
    kKeyDecoderComponent  = 'decC',  // cstring
    kKeyBufferID          = 'bfID',
+16 −0
Original line number Diff line number Diff line
@@ -1639,6 +1639,14 @@ status_t ACodec::configureCodec(
        if (mInputMetadataType == kMetadataBufferTypeGrallocSource) {
            mInputMetadataType = kMetadataBufferTypeCameraSource;
        }

        uint32_t usageBits;
        if (mOMX->getParameter(
                mNode, (OMX_INDEXTYPE)OMX_IndexParamConsumerUsageBits,
                &usageBits, sizeof(usageBits)) == OK) {
            inputFormat->setInt32(
                    "using-sw-read-often", !!(usageBits & GRALLOC_USAGE_SW_READ_OFTEN));
        }
    }

    int32_t prependSPSPPS = 0;
@@ -5748,6 +5756,14 @@ status_t ACodec::LoadedState::setupInputSurface() {
        }
    }

    uint32_t usageBits;
    if (mCodec->mOMX->getParameter(
            mCodec->mNode, (OMX_INDEXTYPE)OMX_IndexParamConsumerUsageBits,
            &usageBits, sizeof(usageBits)) == OK) {
        mCodec->mInputFormat->setInt32(
                "using-sw-read-often", !!(usageBits & GRALLOC_USAGE_SW_READ_OFTEN));
    }

    return OK;
}

+7 −3
Original line number Diff line number Diff line
@@ -670,9 +670,13 @@ status_t CameraSource::start(MetaData *meta) {
            mNumInputBuffers = nBuffers;
        }

        // TODO: Read in format/dataspace from somewhere
        // Uncomment to test SW encoders until TODO is resolved
        // mEncoderFormat = HAL_PIXEL_FORMAT_YCbCr_420_888;
        // apply encoder color format if specified
        if (meta->findInt32(kKeyPixelFormat, &mEncoderFormat)) {
            ALOGV("Using encoder format: %#x", mEncoderFormat);
        }
        if (meta->findInt32(kKeyColorSpace, &mEncoderDataSpace)) {
            ALOGV("Using encoder data space: %#x", mEncoderDataSpace);
        }
    }

    status_t err;
+28 −1
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@

namespace android {

const int kDefaultSwVideoEncoderFormat = HAL_PIXEL_FORMAT_YCbCr_420_888;
const int kDefaultSwVideoEncoderDataSpace = HAL_DATASPACE_BT709;

struct MediaCodecSource::Puller : public AHandler {
    Puller(const sp<MediaSource> &source);

@@ -341,6 +344,9 @@ MediaCodecSource::MediaCodecSource(
      mStarted(false),
      mStopping(false),
      mDoMoreWorkPending(false),
      mSetEncoderFormat(false),
      mEncoderFormat(0),
      mEncoderDataSpace(0),
      mGraphicBufferConsumer(consumer),
      mFirstSampleTimeUs(-1ll),
      mEncoderReachedEOS(false),
@@ -438,6 +444,18 @@ status_t MediaCodecSource::initEncoder() {
        }
    }

    sp<AMessage> inputFormat;
    int32_t usingSwReadOften;
    mSetEncoderFormat = false;
    if (mEncoder->getInputFormat(&inputFormat) == OK
            && inputFormat->findInt32("using-sw-read-often", &usingSwReadOften)
            && usingSwReadOften) {
        // this is a SW encoder; signal source to allocate SW readable buffers
        mSetEncoderFormat = true;
        mEncoderFormat = kDefaultSwVideoEncoderFormat;
        mEncoderDataSpace = kDefaultSwVideoEncoderDataSpace;
    }

    err = mEncoder->start();

    if (err != OK) {
@@ -632,8 +650,17 @@ status_t MediaCodecSource::onStart(MetaData *params) {
        resume(startTimeUs);
    } else {
        CHECK(mPuller != NULL);
        sp<MetaData> meta = params;
        if (mSetEncoderFormat) {
            if (meta == NULL) {
                meta = new MetaData;
            }
            meta->setInt32(kKeyPixelFormat, mEncoderFormat);
            meta->setInt32(kKeyColorSpace, mEncoderDataSpace);
        }

        sp<AMessage> notify = new AMessage(kWhatPullerNotify, mReflector);
        err = mPuller->start(params, notify);
        err = mPuller->start(meta.get(), notify);
        if (err != OK) {
            return err;
        }
Loading