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

Commit da25dec2 authored by Steve Kondik's avatar Steve Kondik
Browse files

av: Cleanup a lot of QCOM cruft

 * Remove some legacy code to bring us closer to kk_3.5

Change-Id: I5c2ec1b7da9281adfcb1eb6ff9ca71d423a2e07b
parent 16590077
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -67,6 +67,9 @@
#include "ARTPWriter.h"
#include <cutils/properties.h>

#define RES_720P (720*1280)
#define DUR_30MIN (30*60*1000*1000)
#define DUR_10MIN (10*60*1000*1000)
namespace android {

// To collect the encoder usage for the battery app
@@ -793,17 +796,16 @@ status_t StagefrightRecorder::setClientName(const String16& clientName) {
}

status_t StagefrightRecorder::prepare() {
  ALOGV(" %s E", __func__ );

  if(mVideoSource != VIDEO_SOURCE_LIST_END && mVideoEncoder != VIDEO_ENCODER_LIST_END && mVideoHeight && mVideoWidth &&             /*Video recording*/
  if (mVideoSource != VIDEO_SOURCE_LIST_END && mVideoEncoder != VIDEO_ENCODER_LIST_END &&
        mVideoHeight && mVideoWidth &&  /*Video recording*/
        (mMaxFileDurationUs <=0 ||      /*Max duration is not set*/
         (mVideoHeight * mVideoWidth < 720 * 1280 && mMaxFileDurationUs > 30*60*1000*1000) ||
         (mVideoHeight * mVideoWidth >= 720 * 1280 && mMaxFileDurationUs > 10*60*1000*1000))) {
        (mVideoHeight * mVideoWidth < RES_720P && mMaxFileDurationUs > DUR_30MIN) ||
        (mVideoHeight * mVideoWidth >= RES_720P && mMaxFileDurationUs > DUR_10MIN))) {
        /*Above Check can be further optimized for lower resolutions to reduce file size*/
        ALOGV("File is huge so setting 64 bit file offsets");
        setParam64BitFileOffset(true);
  }
  ALOGV(" %s X", __func__ );
  return OK;
}

+0 −40
Original line number Diff line number Diff line
@@ -516,38 +516,6 @@ bool ExtendedUtils::checkIsThumbNailMode(const uint32_t flags, char* componentNa
    return isInThumbnailMode;
}

void ExtendedUtils::setArbitraryModeIfInterlaced(
        const uint8_t *ptr, const sp<MetaData> &meta) {

    if (ptr == NULL) {
        return;
    }
    uint16_t spsSize = (((uint16_t)ptr[6]) << 8) + (uint16_t)(ptr[7]);
    int32_t width = 0, height = 0, isInterlaced = 0;
    const uint8_t *spsStart = &ptr[8];

    sp<ABuffer> seqParamSet = new ABuffer(spsSize);
    memcpy(seqParamSet->data(), spsStart, spsSize);
    FindAVCDimensions(seqParamSet, &width, &height, NULL, NULL, &isInterlaced);

    ALOGV("height is %d, width is %d, isInterlaced is %d\n", height, width, isInterlaced);
    if (isInterlaced) {
        meta->setInt32(kKeyUseArbitraryMode, 1);
        meta->setInt32(kKeyInterlace, 1);
    }
    return;
}

int32_t ExtendedUtils::checkIsInterlace(sp<MetaData> &meta) {
    int32_t isInterlaceFormat = 0;

    if(meta->findInt32(kKeyInterlace, &isInterlaceFormat)) {
        ALOGI("interlace format detected");
    }

    return isInterlaceFormat;
}

}
#else //ENABLE_AV_ENHANCEMENTS

@@ -639,13 +607,5 @@ bool ExtendedUtils::checkIsThumbNailMode(const uint32_t flags, char* componentNa
    return false;
}

void ExtendedUtils::setArbitraryModeIfInterlaced(
        const uint8_t *ptr, const sp<MetaData> &meta) {
}

int32_t ExtendedUtils::checkIsInterlace(sp<MetaData> &meta) {
    return false;
}

}
#endif //ENABLE_AV_ENHANCEMENTS
+18 −101
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
 * limitations under the License.
 */

//#define LOG_NDEBUG 0
#define LOG_NDEBUG 0
#define LOG_TAG "OMXCodec"
#include <utils/Log.h>

@@ -484,26 +484,22 @@ sp<MediaSource> OMXCodec::Create(
            componentName = tmp.c_str();
        }

        sp<MediaSource> softwareCodec;
        if (createEncoder) {
            softwareCodec = InstantiateSoftwareEncoder(componentName, source, meta);
#ifdef QCOM_HARDWARE
        } else {
            softwareCodec = InstantiateSoftwareDecoder(componentName, source);
        }
#endif
            sp<MediaSource> softwareCodec =
                InstantiateSoftwareEncoder(componentName, source, meta);
            if (softwareCodec != NULL) {
                ALOGV("Successfully allocated software codec '%s'", componentName);

                return softwareCodec;
            }
        }

#ifdef QCOM_HARDWARE
        const char* ext_componentName = ExtendedCodec::overrideComponentName(quirks, meta);
        if(ext_componentName != NULL) {
          componentName = ext_componentName;
#endif
        }
#endif

        ALOGV("Attempting to allocate OMX node '%s'", componentName);

@@ -664,10 +660,6 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
                return err;
            }

#ifdef QCOM_HARDWARE
            ExtendedUtils::setArbitraryModeIfInterlaced((const uint8_t *)data, meta);
#endif

            CODEC_LOGI(
                    "AVC profile = %u (%s), level = %u",
                    profile, AVCProfileToString(profile), level);
@@ -779,6 +771,10 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
                return err;
            }
        } else {
#ifdef QCOM_HARDWARE
            ExtendedCodec::configureVideoDecoder(
                    meta, mMIME, mOMX, mFlags, mNode, mComponentName);
#endif
            status_t err = setVideoOutputFormat(
                    mMIME, meta);

@@ -787,8 +783,6 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
            }

#ifdef QCOM_HARDWARE
            ExtendedCodec::configureVideoDecoder(
                    meta, mMIME, mOMX, mFlags, mNode, mComponentName);
            ExtendedCodec::configureFramePackingFormat(
                    meta, mOMX, mNode, mComponentName);
            ExtendedCodec::enableSmoothStreaming(
@@ -2235,15 +2229,6 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
        return err;
    }

#ifdef QCOM_HARDWARE
    err = mNativeWindow.get()->perform(mNativeWindow.get(),
                             NATIVE_WINDOW_SET_BUFFERS_SIZE, def.nBufferSize);
    if (err != 0) {
        ALOGE("native_window_set_buffers_size failed: %s (%d)", strerror(-err),
                -err);
        return err;
    }
#endif
    CODEC_LOGV("allocating %lu buffers from a native window of size %lu on "
            "output port", def.nBufferCountActual, def.nBufferSize);

@@ -3131,34 +3116,14 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) {
                mPortStatus[kPortIndexInput] = ENABLED;
                mPortStatus[kPortIndexOutput] = ENABLED;

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

                    if (mFlags & kEnableGrallocUsageProtected) {
                if ((mFlags & kEnableGrallocUsageProtected) &&
                        mNativeWindow != NULL) {
                    // We push enough 1x1 blank buffers to ensure that one of
                    // them has made it to the display.  This allows the OMX
                    // component teardown to zero out any protected buffers
                    // without the risk of scanning out one of those buffers.
                    pushBlankBuffersToNativeWindow();
                }
#ifdef QCOM_HARDWARE
                }
#endif

                setState(IDLE_TO_LOADED);
            }
@@ -3391,14 +3356,6 @@ void OMXCodec::fillOutputBuffers() {
    // all output buffers and we already signalled end-of-input-stream,
    // the end-of-output-stream is implied.

    // NOTE: Thumbnail mode needs a call to fillOutputBuffer in order
    // to get the decoded frame from the component. Currently,
    // thumbnail mode calls emptyBuffer with an EOS flag on its first
    // frame and sets mSignalledEOS to true, so without the check for
    // !mThumbnailMode, fillOutputBuffer will never be called.
#ifdef QCOM_HARDWARE
    if(!ExtendedUtils::checkIsThumbNailMode(mFlags, mComponentName)) {
#endif
    if (mSignalledEOS
            && countBuffersWeOwn(mPortBuffers[kPortIndexInput])
                == mPortBuffers[kPortIndexInput].size()
@@ -3409,9 +3366,6 @@ void OMXCodec::fillOutputBuffers() {

            return;
    }
#ifdef QCOM_HARDWARE
    }
#endif

    Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexOutput];
    for (size_t i = 0; i < buffers->size(); ++i) {
@@ -3450,12 +3404,7 @@ void OMXCodec::drainInputBuffers() {
                break;
            }

#ifdef QCOM_HARDWARE
            if ((mFlags & kOnlySubmitOneInputBufferAtOneTime)
                    && (i == mNumBFrames)) {
#else
            if (mFlags & kOnlySubmitOneInputBufferAtOneTime) {
#endif
                break;
            }
        }
@@ -3558,11 +3507,6 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) {

    size_t offset = 0;
    int32_t n = 0;
#ifdef QCOM_HARDWARE
    int32_t InterlaceFormatDetected = false;
    int32_t InterlaceFrameCount = 0;
#endif


    for (;;) {
        MediaBuffer *srcBuffer;
@@ -3609,11 +3553,6 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) {
            break;
        }

#ifdef QCOM_HARDWARE
        sp<MetaData> metaData = mSource->getFormat();
        InterlaceFormatDetected = ExtendedUtils::checkIsInterlace(metaData);
#endif

        if (mFlags & kUseSecureInputBuffers) {
            info = findInputBufferByDataPointer(srcBuffer->data());
            CHECK(info != NULL);
@@ -3772,29 +3711,8 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) {

    OMX_U32 flags = OMX_BUFFERFLAG_ENDOFFRAME;

#ifdef QCOM_HARDWARE
    if(InterlaceFormatDetected) {
        InterlaceFrameCount++;
    }
#endif

    if (signalEOS) {
        flags |= OMX_BUFFERFLAG_EOS;
#ifdef QCOM_HARDWARE
    } else if(ExtendedUtils::checkIsThumbNailMode(mFlags, mComponentName)
                   && (!InterlaceFormatDetected || InterlaceFrameCount>= 2)) {
        // Because we don't get an EOS after getting the first frame, we
        // need to notify the component with OMX_BUFFERFLAG_EOS, set
        // mNoMoreOutputData to false so fillOutputBuffer gets called on
        // the first output buffer (see comment in fillOutputBuffer), and
        // mSignalledEOS must be true so drainInputBuffer is not executed
        // on extra frames. Setting mFinalStatus to ERROR_END_OF_STREAM as
        // we dont want to return OK and NULL buffer in read.
        flags |= OMX_BUFFERFLAG_EOS;
        mNoMoreOutputData = false;
        mSignalledEOS = true;
        mFinalStatus = ERROR_END_OF_STREAM;
#endif
    } else {
        mNoMoreOutputData = false;
    }
@@ -5406,8 +5324,7 @@ status_t QueryCodec(
#else
    portFormat.nPortIndex = !isEncoder ? 1 : 0;
#endif
    for (OMX_U32 index = 0;;index++)  {
        portFormat.nIndex = index;
    for (portFormat.nIndex = 0;; ++portFormat.nIndex) {
        err = omx->getParameter(
                node, OMX_IndexParamVideoPortFormat,
                &portFormat, sizeof(portFormat));
+1 −17
Original line number Diff line number Diff line
@@ -44,11 +44,7 @@ unsigned parseUE(ABitReader *br) {
void FindAVCDimensions(
        const sp<ABuffer> &seqParamSet,
        int32_t *width, int32_t *height,
#ifdef QCOM_HARDWARE
        int32_t *sarWidth, int32_t *sarHeight, int32_t *isInterlaced) {
#else
        int32_t *sarWidth, int32_t *sarHeight) {
#endif
    ABitReader br(seqParamSet->data() + 1, seqParamSet->size() - 1);

    unsigned profile_idc = br.getBits(8);
@@ -67,13 +63,7 @@ void FindAVCDimensions(
        parseUE(&br);  // bit_depth_luma_minus8
        parseUE(&br);  // bit_depth_chroma_minus8
        br.skipBits(1);  // qpprime_y_zero_transform_bypass_flag
#ifdef QCOM_HARDWARE
        bool seq_scaling_matrix_present = (br.getBits(1) != 0u);
        if (isInterlaced != NULL && seq_scaling_matrix_present) {
            return;
        }
        CHECK_EQ(seq_scaling_matrix_present, false);  // seq_scaling_matrix_present_flag
#endif
        CHECK_EQ(br.getBits(1), 0u);  // seq_scaling_matrix_present_flag
    }

    parseUE(&br);  // log2_max_frame_num_minus4
@@ -143,12 +133,6 @@ void FindAVCDimensions(
            (frame_crop_top_offset + frame_crop_bottom_offset) * cropUnitY;
    }

#ifdef QCOM_HARDWARE
    if (isInterlaced != NULL) {
        *isInterlaced = !frame_mbs_only_flag;
    }
#endif

    if (sarWidth != NULL) {
        *sarWidth = 0;
    }
+0 −4
Original line number Diff line number Diff line
@@ -141,10 +141,6 @@ struct ExtendedUtils {

    static bool checkIsThumbNailMode(const uint32_t flags, char* componentName);

    static void setArbitraryModeIfInterlaced(
            const uint8_t *ptr, const sp<MetaData> &meta);

    static int32_t checkIsInterlace(sp<MetaData> &meta);
};

}
Loading