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

Commit b2eb3852 authored by Paras Nagda's avatar Paras Nagda Committed by Ethan Chen
Browse files

Acodec: Add interlaced video support

- When interlace is present, because of the presence of
extradata the buffersize is larger than width*height*1.5
but display is unaware of this.So add call to set output
buffer size on the native window.

- For interlace, set decoder in arbitrary mode
In arbitrary mode, frame parsers sends individual fields
to core. Once both the field is decoded, output done (FBD)
is sent back to client.
Default frame by frame mode will send both the fields in
a single buffer to core, which might decode only one field
or will throw up error.

Change-Id: Id1e90b2cebacaf3aaaa9cc69b1cc2f6787468476
parent 1a4c727b
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/AUtils.h>
#ifdef QCOM_BSP_LEGACY
#include <media/stagefright/MetaData.h>
#endif

#include <media/stagefright/BufferProducerWrapper.h>
#include <media/stagefright/MediaCodecList.h>
@@ -104,6 +107,10 @@
#include "include/OMX_Audio_DTS.h"
#endif

#ifdef QCOM_BSP_LEGACY
#include <stagefright/Utils.h>
#endif

namespace android {

// OMX errors are directly mapped into status_t range if
@@ -890,6 +897,16 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
        return err;
    }

#ifdef QCOM_BSP_LEGACY
    err = mNativeWindow.get()->perform(mNativeWindow.get(),
            NATIVE_WINDOW_SET_BUFFERS_SIZE, def.nBufferSize);
    if (err != 0) {
        ALOGE("mNativeWindow.get()->perform() faild: %s (%d)", strerror(-err),
                -err);
        return err;
    }
#endif

    *bufferCount = def.nBufferCountActual;
    *bufferSize =  def.nBufferSize;
    return err;
@@ -1642,6 +1659,19 @@ status_t ACodec::configureCodec(
        if (encoder) {
            err = setupVideoEncoder(mime, msg);
        } else {
#ifdef QCOM_BSP_LEGACY
            if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) {
                sp<MetaData> meta = new MetaData;
                const void *data;
                size_t size;
                uint32_t type;
                convertMessageToMetaData(msg, meta);

                if (meta->findData(kKeyAVCC, &type, &data, &size)) {
                    ExtendedUtils::setArbitraryModeIfInterlaced((const uint8_t *)data, meta);
                }
            }
#endif
            err = setupVideoDecoder(mime, msg, haveNativeWindow);
#ifdef ENABLE_AV_ENHANCEMENTS
            if (err == OK) {
@@ -6324,6 +6354,21 @@ void ACodec::ExecutingToIdleState::changeStateIfWeOwnAllBuffers() {
        CHECK_EQ(mCodec->freeBuffersOnPort(kPortIndexInput), (status_t)OK);
        CHECK_EQ(mCodec->freeBuffersOnPort(kPortIndexOutput), (status_t)OK);

#ifdef QCOM_BSP_LEGACY
        if(mCodec->mNativeWindow != NULL) {
            /*
             * reset buffer size field with SurfaceTexture
             * back to 0. This wil ensure proper size
             * buffers are allocated if the same SurfaceTexture
             * is re-used in a different decode session
             */
            int err = mCodec->mNativeWindow.get()->perform(mCodec->mNativeWindow.get(),
                                                            NATIVE_WINDOW_SET_BUFFERS_SIZE, 0);
            if (err != 0) {
                ALOGE("mNativeWindow.get()->Perform() failed: %s (%d)", strerror(-err),-err);
            }
#endif

        if ((mCodec->mFlags & kFlagPushBlankBuffersToNativeWindowOnShutdown)
                && mCodec->mNativeWindow != NULL) {
            // We push enough 1x1 blank buffers to ensure that one of
@@ -6332,6 +6377,9 @@ void ACodec::ExecutingToIdleState::changeStateIfWeOwnAllBuffers() {
            // without the risk of scanning out one of those buffers.
            mCodec->pushBlankBuffersToNativeWindow();
        }
#ifdef QCOM_BSP_LEGACY
       }
#endif

        mCodec->changeState(mCodec->mIdleToLoadedState);
    }