Loading media/libstagefright/codecs/avcdec/SoftAVCDec.cpp +81 −283 Original line number Original line Diff line number Diff line Loading @@ -38,10 +38,10 @@ namespace android { /** Function and structure definitions to keep code similar for each codec */ /** Function and structure definitions to keep code similar for each codec */ #define ivdec_api_function ih264d_api_function #define ivdec_api_function ih264d_api_function #define ivdext_init_ip_t ih264d_init_ip_t #define ivdext_create_ip_t ih264d_create_ip_t #define ivdext_init_op_t ih264d_init_op_t #define ivdext_create_op_t ih264d_create_op_t #define ivdext_fill_mem_rec_ip_t ih264d_fill_mem_rec_ip_t #define ivdext_delete_ip_t ih264d_delete_ip_t #define ivdext_fill_mem_rec_op_t ih264d_fill_mem_rec_op_t #define ivdext_delete_op_t ih264d_delete_op_t #define ivdext_ctl_set_num_cores_ip_t ih264d_ctl_set_num_cores_ip_t #define ivdext_ctl_set_num_cores_ip_t ih264d_ctl_set_num_cores_ip_t #define ivdext_ctl_set_num_cores_op_t ih264d_ctl_set_num_cores_op_t #define ivdext_ctl_set_num_cores_op_t ih264d_ctl_set_num_cores_op_t Loading Loading @@ -115,15 +115,12 @@ SoftAVC::SoftAVC( 320 /* width */, 240 /* height */, callbacks, 320 /* width */, 240 /* height */, callbacks, appData, component), appData, component), mCodecCtx(NULL), mCodecCtx(NULL), mMemRecords(NULL), mFlushOutBuffer(NULL), mFlushOutBuffer(NULL), mOmxColorFormat(OMX_COLOR_FormatYUV420Planar), mOmxColorFormat(OMX_COLOR_FormatYUV420Planar), mIvColorFormat(IV_YUV_420P), mIvColorFormat(IV_YUV_420P), mNewWidth(mWidth), mNewHeight(mHeight), mNewLevel(0), mChangingResolution(false), mChangingResolution(false), mSignalledError(false) { mSignalledError(false), mStride(mWidth){ initPorts( initPorts( kNumBuffers, INPUT_BUF_SIZE, kNumBuffers, CODEC_MIME_TYPE); kNumBuffers, INPUT_BUF_SIZE, kNumBuffers, CODEC_MIME_TYPE); Loading @@ -132,14 +129,23 @@ SoftAVC::SoftAVC( // If input dump is enabled, then open create an empty file // If input dump is enabled, then open create an empty file GENERATE_FILE_NAMES(); GENERATE_FILE_NAMES(); CREATE_DUMP_FILE(mInFile); CREATE_DUMP_FILE(mInFile); CHECK_EQ(initDecoder(mWidth, mHeight), (status_t)OK); } } SoftAVC::~SoftAVC() { SoftAVC::~SoftAVC() { CHECK_EQ(deInitDecoder(), (status_t)OK); CHECK_EQ(deInitDecoder(), (status_t)OK); } } static void *ivd_aligned_malloc(void *ctxt, WORD32 alignment, WORD32 size) { UNUSED(ctxt); return memalign(alignment, size); } static void ivd_aligned_free(void *ctxt, void *buf) { UNUSED(ctxt); free(buf); return; } static size_t GetCPUCoreCount() { static size_t GetCPUCoreCount() { long cpuCoreCount = 1; long cpuCoreCount = 1; #if defined(_SC_NPROCESSORS_ONLN) #if defined(_SC_NPROCESSORS_ONLN) Loading @@ -149,7 +155,7 @@ static size_t GetCPUCoreCount() { cpuCoreCount = sysconf(_SC_NPROC_ONLN); cpuCoreCount = sysconf(_SC_NPROC_ONLN); #endif #endif CHECK(cpuCoreCount >= 1); CHECK(cpuCoreCount >= 1); ALOGD("Number of CPU cores: %ld", cpuCoreCount); ALOGV("Number of CPU cores: %ld", cpuCoreCount); return (size_t)cpuCoreCount; return (size_t)cpuCoreCount; } } Loading Loading @@ -235,12 +241,10 @@ status_t SoftAVC::resetDecoder() { } } mSignalledError = false; mSignalledError = false; /* Set the run-time (dynamic) parameters */ setParams(outputBufferWidth()); /* Set number of cores/threads to be used by the codec */ /* Set number of cores/threads to be used by the codec */ setNumCores(); setNumCores(); mStride = 0; return OK; return OK; } } Loading Loading @@ -287,160 +291,41 @@ status_t SoftAVC::setFlushMode() { return OK; return OK; } } status_t SoftAVC::initDecoder(uint32_t width, uint32_t height) { status_t SoftAVC::initDecoder() { IV_API_CALL_STATUS_T status; IV_API_CALL_STATUS_T status; UWORD32 u4_num_reorder_frames; UWORD32 u4_num_ref_frames; UWORD32 u4_share_disp_buf; WORD32 i4_level; mNumCores = GetCPUCoreCount(); mNumCores = GetCPUCoreCount(); mCodecCtx = NULL; mCodecCtx = NULL; /* Initialize number of ref and reorder modes (for H264) */ mStride = outputBufferWidth(); u4_num_reorder_frames = 16; u4_num_ref_frames = 16; u4_share_disp_buf = 0; uint32_t displayStride = mIsAdaptive ? mAdaptiveMaxWidth : width; uint32_t displayHeight = mIsAdaptive ? mAdaptiveMaxHeight : height; uint32_t displaySizeY = displayStride * displayHeight; if(mNewLevel == 0){ if (displaySizeY > (1920 * 1088)) { i4_level = 50; } else if (displaySizeY > (1280 * 720)) { i4_level = 40; } else if (displaySizeY > (720 * 576)) { i4_level = 31; } else if (displaySizeY > (624 * 320)) { i4_level = 30; } else if (displaySizeY > (352 * 288)) { i4_level = 21; } else { i4_level = 20; } } else { i4_level = mNewLevel; } { iv_num_mem_rec_ip_t s_num_mem_rec_ip; iv_num_mem_rec_op_t s_num_mem_rec_op; s_num_mem_rec_ip.u4_size = sizeof(s_num_mem_rec_ip); s_num_mem_rec_op.u4_size = sizeof(s_num_mem_rec_op); s_num_mem_rec_ip.e_cmd = IV_CMD_GET_NUM_MEM_REC; ALOGV("Get number of mem records"); status = ivdec_api_function( mCodecCtx, (void *)&s_num_mem_rec_ip, (void *)&s_num_mem_rec_op); if (IV_SUCCESS != status) { ALOGE("Error in getting mem records: 0x%x", s_num_mem_rec_op.u4_error_code); return UNKNOWN_ERROR; } mNumMemRecords = s_num_mem_rec_op.u4_num_mem_rec; } mMemRecords = (iv_mem_rec_t *)ivd_aligned_malloc( 128, mNumMemRecords * sizeof(iv_mem_rec_t)); if (mMemRecords == NULL) { ALOGE("Allocation failure"); return NO_MEMORY; } memset(mMemRecords, 0, mNumMemRecords * sizeof(iv_mem_rec_t)); { size_t i; ivdext_fill_mem_rec_ip_t s_fill_mem_ip; ivdext_fill_mem_rec_op_t s_fill_mem_op; iv_mem_rec_t *ps_mem_rec; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.u4_size = sizeof(ivdext_fill_mem_rec_ip_t); s_fill_mem_ip.i4_level = i4_level; s_fill_mem_ip.u4_num_reorder_frames = u4_num_reorder_frames; s_fill_mem_ip.u4_num_ref_frames = u4_num_ref_frames; s_fill_mem_ip.u4_share_disp_buf = u4_share_disp_buf; s_fill_mem_ip.u4_num_extra_disp_buf = 0; s_fill_mem_ip.e_output_format = mIvColorFormat; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.e_cmd = IV_CMD_FILL_NUM_MEM_REC; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.pv_mem_rec_location = mMemRecords; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.u4_max_frm_wd = displayStride; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.u4_max_frm_ht = displayHeight; s_fill_mem_op.s_ivd_fill_mem_rec_op_t.u4_size = sizeof(ivdext_fill_mem_rec_op_t); ps_mem_rec = mMemRecords; for (i = 0; i < mNumMemRecords; i++) { ps_mem_rec[i].u4_size = sizeof(iv_mem_rec_t); } status = ivdec_api_function( mCodecCtx, (void *)&s_fill_mem_ip, (void *)&s_fill_mem_op); if (IV_SUCCESS != status) { ALOGE("Error in filling mem records: 0x%x", s_fill_mem_op.s_ivd_fill_mem_rec_op_t.u4_error_code); return UNKNOWN_ERROR; } mNumMemRecords = s_fill_mem_op.s_ivd_fill_mem_rec_op_t.u4_num_mem_rec_filled; ps_mem_rec = mMemRecords; for (i = 0; i < mNumMemRecords; i++) { ps_mem_rec->pv_base = ivd_aligned_malloc( ps_mem_rec->u4_mem_alignment, ps_mem_rec->u4_mem_size); if (ps_mem_rec->pv_base == NULL) { ALOGE("Allocation failure for memory record #%zu of size %u", i, ps_mem_rec->u4_mem_size); status = IV_FAIL; return NO_MEMORY; } ps_mem_rec++; } } /* Initialize the decoder */ /* Initialize the decoder */ { { ivdext_init_ip_t s_init_ip; ivdext_create_ip_t s_create_ip; ivdext_init_op_t s_init_op; ivdext_create_op_t s_create_op; void *dec_fxns = (void *)ivdec_api_function; void *dec_fxns = (void *)ivdec_api_function; s_init_ip.s_ivd_init_ip_t.u4_size = sizeof(ivdext_init_ip_t); s_create_ip.s_ivd_create_ip_t.u4_size = sizeof(ivdext_create_ip_t); s_init_ip.s_ivd_init_ip_t.e_cmd = (IVD_API_COMMAND_TYPE_T)IV_CMD_INIT; s_create_ip.s_ivd_create_ip_t.e_cmd = IVD_CMD_CREATE; s_init_ip.s_ivd_init_ip_t.pv_mem_rec_location = mMemRecords; s_create_ip.s_ivd_create_ip_t.u4_share_disp_buf = 0; s_init_ip.s_ivd_init_ip_t.u4_frm_max_wd = displayStride; s_create_op.s_ivd_create_op_t.u4_size = sizeof(ivdext_create_op_t); s_init_ip.s_ivd_init_ip_t.u4_frm_max_ht = displayHeight; s_create_ip.s_ivd_create_ip_t.e_output_format = mIvColorFormat; s_create_ip.s_ivd_create_ip_t.pf_aligned_alloc = ivd_aligned_malloc; s_init_ip.i4_level = i4_level; s_create_ip.s_ivd_create_ip_t.pf_aligned_free = ivd_aligned_free; s_init_ip.u4_num_reorder_frames = u4_num_reorder_frames; s_create_ip.s_ivd_create_ip_t.pv_mem_ctxt = NULL; s_init_ip.u4_num_ref_frames = u4_num_ref_frames; s_init_ip.u4_share_disp_buf = u4_share_disp_buf; s_init_ip.u4_num_extra_disp_buf = 0; s_init_op.s_ivd_init_op_t.u4_size = sizeof(s_init_op); s_init_ip.s_ivd_init_ip_t.u4_num_mem_rec = mNumMemRecords; status = ivdec_api_function(mCodecCtx, (void *)&s_create_ip, (void *)&s_create_op); s_init_ip.s_ivd_init_ip_t.e_output_format = mIvColorFormat; mCodecCtx = (iv_obj_t *)mMemRecords[0].pv_base; mCodecCtx = (iv_obj_t*)s_create_op.s_ivd_create_op_t.pv_handle; mCodecCtx->pv_fxns = dec_fxns; mCodecCtx->pv_fxns = dec_fxns; mCodecCtx->u4_size = sizeof(iv_obj_t); mCodecCtx->u4_size = sizeof(iv_obj_t); status = ivdec_api_function(mCodecCtx, (void *)&s_init_ip, (void *)&s_init_op); if (status != IV_SUCCESS) { if (status != IV_SUCCESS) { ALOGE("Error in create: 0x%x", s_create_op.s_ivd_create_op_t.u4_error_code); deInitDecoder(); mCodecCtx = NULL; mCodecCtx = NULL; ALOGE("Error in init: 0x%x", s_init_op.s_ivd_init_op_t.u4_error_code); return UNKNOWN_ERROR; return UNKNOWN_ERROR; } } } } Loading @@ -449,7 +334,7 @@ status_t SoftAVC::initDecoder(uint32_t width, uint32_t height) { resetPlugin(); resetPlugin(); /* Set the run time (dynamic) parameters */ /* Set the run time (dynamic) parameters */ setParams(displayStride); setParams(mStride); /* Set number of cores/threads to be used by the codec */ /* Set number of cores/threads to be used by the codec */ setNumCores(); setNumCores(); Loading @@ -457,61 +342,37 @@ status_t SoftAVC::initDecoder(uint32_t width, uint32_t height) { /* Get codec version */ /* Get codec version */ logVersion(); logVersion(); /* Allocate internal picture buffer */ uint32_t bufferSize = displaySizeY * 3 / 2; mFlushOutBuffer = (uint8_t *)ivd_aligned_malloc(128, bufferSize); if (NULL == mFlushOutBuffer) { ALOGE("Could not allocate flushOutputBuffer of size %zu", bufferSize); return NO_MEMORY; } mInitNeeded = false; mFlushNeeded = false; mFlushNeeded = false; return OK; return OK; } } status_t SoftAVC::deInitDecoder() { status_t SoftAVC::deInitDecoder() { size_t i; size_t i; IV_API_CALL_STATUS_T status; if (mMemRecords) { if (mCodecCtx) { iv_mem_rec_t *ps_mem_rec; ivdext_delete_ip_t s_delete_ip; ivdext_delete_op_t s_delete_op; ps_mem_rec = mMemRecords; s_delete_ip.s_ivd_delete_ip_t.u4_size = sizeof(ivdext_delete_ip_t); for (i = 0; i < mNumMemRecords; i++) { s_delete_ip.s_ivd_delete_ip_t.e_cmd = IVD_CMD_DELETE; if (ps_mem_rec->pv_base) { ivd_aligned_free(ps_mem_rec->pv_base); s_delete_op.s_ivd_delete_op_t.u4_size = sizeof(ivdext_delete_op_t); } ps_mem_rec++; status = ivdec_api_function(mCodecCtx, (void *)&s_delete_ip, (void *)&s_delete_op); if (status != IV_SUCCESS) { ALOGE("Error in delete: 0x%x", s_delete_op.s_ivd_delete_op_t.u4_error_code); return UNKNOWN_ERROR; } } ivd_aligned_free(mMemRecords); mMemRecords = NULL; } } if (mFlushOutBuffer) { ivd_aligned_free(mFlushOutBuffer); mFlushOutBuffer = NULL; } mInitNeeded = true; mChangingResolution = false; mChangingResolution = false; return OK; return OK; } } status_t SoftAVC::reInitDecoder(uint32_t width, uint32_t height) { status_t ret; deInitDecoder(); ret = initDecoder(width, height); if (OK != ret) { ALOGE("Create failure"); deInitDecoder(); return NO_MEMORY; } return OK; } void SoftAVC::onReset() { void SoftAVC::onReset() { SoftVideoDecoderOMXComponent::onReset(); SoftVideoDecoderOMXComponent::onReset(); Loading @@ -520,21 +381,6 @@ void SoftAVC::onReset() { resetPlugin(); resetPlugin(); } } OMX_ERRORTYPE SoftAVC::internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR params) { const uint32_t oldWidth = mWidth; const uint32_t oldHeight = mHeight; OMX_ERRORTYPE ret = SoftVideoDecoderOMXComponent::internalSetParameter(index, params); if (mWidth != oldWidth || mHeight != oldHeight) { status_t err = reInitDecoder(mNewWidth, mNewHeight); if (err != OK) { notify(OMX_EventError, OMX_ErrorUnsupportedSetting, err, NULL); mSignalledError = true; return OMX_ErrorUnsupportedSetting; } } return ret; } void SoftAVC::setDecodeArgs( void SoftAVC::setDecodeArgs( ivd_video_decode_ip_t *ps_dec_ip, ivd_video_decode_ip_t *ps_dec_ip, ivd_video_decode_op_t *ps_dec_op, ivd_video_decode_op_t *ps_dec_op, Loading Loading @@ -585,6 +431,17 @@ void SoftAVC::onPortFlushCompleted(OMX_U32 portIndex) { if (kOutputPortIndex == portIndex) { if (kOutputPortIndex == portIndex) { setFlushMode(); setFlushMode(); /* Allocate a picture buffer to flushed data */ uint32_t displayStride = outputBufferWidth(); uint32_t displayHeight = outputBufferHeight(); uint32_t bufferSize = displayStride * displayHeight * 3 / 2; mFlushOutBuffer = (uint8_t *)memalign(128, bufferSize); if (NULL == mFlushOutBuffer) { ALOGE("Could not allocate flushOutputBuffer of size %zu", bufferSize); return; } while (true) { while (true) { ivd_video_decode_ip_t s_dec_ip; ivd_video_decode_ip_t s_dec_ip; ivd_video_decode_op_t s_dec_op; ivd_video_decode_op_t s_dec_op; Loading @@ -599,6 +456,12 @@ void SoftAVC::onPortFlushCompleted(OMX_U32 portIndex) { break; break; } } } } if (mFlushOutBuffer) { free(mFlushOutBuffer); mFlushOutBuffer = NULL; } } } } } Loading @@ -612,6 +475,17 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { return; return; } } if (NULL == mCodecCtx) { if (OK != initDecoder()) { return; } } if (outputBufferWidth() != mStride) { /* Set the run-time (dynamic) parameters */ mStride = outputBufferWidth(); setParams(mStride); } List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex); List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex); List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex); List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex); Loading Loading @@ -662,22 +536,6 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { } } } } // When there is an init required and the decoder is not in flush mode, // update output port's definition and reinitialize decoder. if (mInitNeeded && !mIsInFlush) { bool portWillReset = false; status_t err = reInitDecoder(mNewWidth, mNewHeight); if (err != OK) { notify(OMX_EventError, OMX_ErrorUnsupportedSetting, err, NULL); mSignalledError = true; return; } handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight); return; } /* Get a free slot in timestamp array to hold input timestamp */ /* Get a free slot in timestamp array to hold input timestamp */ { { size_t i; size_t i; Loading Loading @@ -712,10 +570,7 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { IV_API_CALL_STATUS_T status; IV_API_CALL_STATUS_T status; status = ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); status = ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); bool unsupportedDimensions = (IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED == (s_dec_op.u4_error_code & 0xFF)); bool resChanged = (IVD_RES_CHANGED == (s_dec_op.u4_error_code & 0xFF)); bool resChanged = (IVD_RES_CHANGED == (s_dec_op.u4_error_code & 0xFF)); bool unsupportedLevel = (IH264D_UNSUPPORTED_LEVEL == (s_dec_op.u4_error_code & 0xFF)); GETTIME(&mTimeEnd, NULL); GETTIME(&mTimeEnd, NULL); /* Compute time taken for decode() */ /* Compute time taken for decode() */ Loading @@ -733,46 +588,6 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { mTimeStampsValid[timeStampIx] = false; mTimeStampsValid[timeStampIx] = false; } } // This is needed to handle CTS DecoderTest testCodecResetsH264WithoutSurface, // which is not sending SPS/PPS after port reconfiguration and flush to the codec. if (unsupportedDimensions && !mFlushNeeded) { bool portWillReset = false; mNewWidth = s_dec_op.u4_pic_wd; mNewHeight = s_dec_op.u4_pic_ht; status_t err = reInitDecoder(mNewWidth, mNewHeight); if (err != OK) { notify(OMX_EventError, OMX_ErrorUnsupportedSetting, err, NULL); mSignalledError = true; return; } handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight); setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx); ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); return; } if (unsupportedLevel && !mFlushNeeded) { mNewLevel = 51; status_t err = reInitDecoder(mNewWidth, mNewHeight); if (err != OK) { notify(OMX_EventError, OMX_ErrorUnsupportedSetting, err, NULL); mSignalledError = true; return; } setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx); ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); return; } // If the decoder is in the changing resolution mode and there is no output present, // If the decoder is in the changing resolution mode and there is no output present, // that means the switching is done and it's ready to reset the decoder and the plugin. // that means the switching is done and it's ready to reset the decoder and the plugin. if (mChangingResolution && !s_dec_op.u4_output_present) { if (mChangingResolution && !s_dec_op.u4_output_present) { Loading @@ -782,28 +597,11 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { continue; continue; } } if (unsupportedDimensions || resChanged) { if (resChanged) { mChangingResolution = true; mChangingResolution = true; if (mFlushNeeded) { if (mFlushNeeded) { setFlushMode(); setFlushMode(); } } if (unsupportedDimensions) { mNewWidth = s_dec_op.u4_pic_wd; mNewHeight = s_dec_op.u4_pic_ht; mInitNeeded = true; } continue; } if (unsupportedLevel) { if (mFlushNeeded) { setFlushMode(); } mNewLevel = 51; mInitNeeded = true; continue; continue; } } Loading @@ -820,7 +618,7 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { } } if (s_dec_op.u4_output_present) { if (s_dec_op.u4_output_present) { outHeader->nFilledLen = (mWidth * mHeight * 3) / 2; outHeader->nFilledLen = (outputBufferWidth() * outputBufferHeight() * 3) / 2; outHeader->nTimeStamp = mTimeStamps[s_dec_op.u4_ts]; outHeader->nTimeStamp = mTimeStamps[s_dec_op.u4_ts]; mTimeStampsValid[s_dec_op.u4_ts] = false; mTimeStampsValid[s_dec_op.u4_ts] = false; Loading media/libstagefright/codecs/avcdec/SoftAVCDec.h +4 −12 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,6 @@ namespace android { namespace android { #define ivd_aligned_malloc(alignment, size) memalign(alignment, size) #define ivd_aligned_free(buf) free(buf) /** Number of entries in the time-stamp array */ /** Number of entries in the time-stamp array */ #define MAX_TIME_STAMPS 64 #define MAX_TIME_STAMPS 64 Loading Loading @@ -62,7 +59,6 @@ protected: virtual void onQueueFilled(OMX_U32 portIndex); virtual void onQueueFilled(OMX_U32 portIndex); virtual void onPortFlushCompleted(OMX_U32 portIndex); virtual void onPortFlushCompleted(OMX_U32 portIndex); virtual void onReset(); virtual void onReset(); virtual OMX_ERRORTYPE internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR params); private: private: // Number of input and output buffers // Number of input and output buffers enum { enum { Loading @@ -70,8 +66,6 @@ private: }; }; iv_obj_t *mCodecCtx; // Codec context iv_obj_t *mCodecCtx; // Codec context iv_mem_rec_t *mMemRecords; // Memory records requested by the codec size_t mNumMemRecords; // Number of memory records requested by the codec size_t mNumCores; // Number of cores to be uesd by the codec size_t mNumCores; // Number of cores to be uesd by the codec Loading @@ -97,17 +91,15 @@ private: bool mIsInFlush; // codec is flush mode bool mIsInFlush; // codec is flush mode bool mReceivedEOS; // EOS is receieved on input port bool mReceivedEOS; // EOS is receieved on input port bool mInitNeeded; uint32_t mNewWidth; uint32_t mNewHeight; uint32_t mNewLevel; // The input stream has changed to a different resolution, which is still supported by the // The input stream has changed to a different resolution, which is still supported by the // codec. So the codec is switching to decode the new resolution. // codec. So the codec is switching to decode the new resolution. bool mChangingResolution; bool mChangingResolution; bool mFlushNeeded; bool mFlushNeeded; bool mSignalledError; bool mSignalledError; size_t mStride; status_t initDecoder(uint32_t width, uint32_t height); status_t initDecoder(); status_t deInitDecoder(); status_t deInitDecoder(); status_t setFlushMode(); status_t setFlushMode(); status_t setParams(size_t stride); status_t setParams(size_t stride); Loading @@ -115,7 +107,7 @@ private: status_t setNumCores(); status_t setNumCores(); status_t resetDecoder(); status_t resetDecoder(); status_t resetPlugin(); status_t resetPlugin(); status_t reInitDecoder(uint32_t width, uint32_t height); void setDecodeArgs( void setDecodeArgs( ivd_video_decode_ip_t *ps_dec_ip, ivd_video_decode_ip_t *ps_dec_ip, Loading Loading
media/libstagefright/codecs/avcdec/SoftAVCDec.cpp +81 −283 Original line number Original line Diff line number Diff line Loading @@ -38,10 +38,10 @@ namespace android { /** Function and structure definitions to keep code similar for each codec */ /** Function and structure definitions to keep code similar for each codec */ #define ivdec_api_function ih264d_api_function #define ivdec_api_function ih264d_api_function #define ivdext_init_ip_t ih264d_init_ip_t #define ivdext_create_ip_t ih264d_create_ip_t #define ivdext_init_op_t ih264d_init_op_t #define ivdext_create_op_t ih264d_create_op_t #define ivdext_fill_mem_rec_ip_t ih264d_fill_mem_rec_ip_t #define ivdext_delete_ip_t ih264d_delete_ip_t #define ivdext_fill_mem_rec_op_t ih264d_fill_mem_rec_op_t #define ivdext_delete_op_t ih264d_delete_op_t #define ivdext_ctl_set_num_cores_ip_t ih264d_ctl_set_num_cores_ip_t #define ivdext_ctl_set_num_cores_ip_t ih264d_ctl_set_num_cores_ip_t #define ivdext_ctl_set_num_cores_op_t ih264d_ctl_set_num_cores_op_t #define ivdext_ctl_set_num_cores_op_t ih264d_ctl_set_num_cores_op_t Loading Loading @@ -115,15 +115,12 @@ SoftAVC::SoftAVC( 320 /* width */, 240 /* height */, callbacks, 320 /* width */, 240 /* height */, callbacks, appData, component), appData, component), mCodecCtx(NULL), mCodecCtx(NULL), mMemRecords(NULL), mFlushOutBuffer(NULL), mFlushOutBuffer(NULL), mOmxColorFormat(OMX_COLOR_FormatYUV420Planar), mOmxColorFormat(OMX_COLOR_FormatYUV420Planar), mIvColorFormat(IV_YUV_420P), mIvColorFormat(IV_YUV_420P), mNewWidth(mWidth), mNewHeight(mHeight), mNewLevel(0), mChangingResolution(false), mChangingResolution(false), mSignalledError(false) { mSignalledError(false), mStride(mWidth){ initPorts( initPorts( kNumBuffers, INPUT_BUF_SIZE, kNumBuffers, CODEC_MIME_TYPE); kNumBuffers, INPUT_BUF_SIZE, kNumBuffers, CODEC_MIME_TYPE); Loading @@ -132,14 +129,23 @@ SoftAVC::SoftAVC( // If input dump is enabled, then open create an empty file // If input dump is enabled, then open create an empty file GENERATE_FILE_NAMES(); GENERATE_FILE_NAMES(); CREATE_DUMP_FILE(mInFile); CREATE_DUMP_FILE(mInFile); CHECK_EQ(initDecoder(mWidth, mHeight), (status_t)OK); } } SoftAVC::~SoftAVC() { SoftAVC::~SoftAVC() { CHECK_EQ(deInitDecoder(), (status_t)OK); CHECK_EQ(deInitDecoder(), (status_t)OK); } } static void *ivd_aligned_malloc(void *ctxt, WORD32 alignment, WORD32 size) { UNUSED(ctxt); return memalign(alignment, size); } static void ivd_aligned_free(void *ctxt, void *buf) { UNUSED(ctxt); free(buf); return; } static size_t GetCPUCoreCount() { static size_t GetCPUCoreCount() { long cpuCoreCount = 1; long cpuCoreCount = 1; #if defined(_SC_NPROCESSORS_ONLN) #if defined(_SC_NPROCESSORS_ONLN) Loading @@ -149,7 +155,7 @@ static size_t GetCPUCoreCount() { cpuCoreCount = sysconf(_SC_NPROC_ONLN); cpuCoreCount = sysconf(_SC_NPROC_ONLN); #endif #endif CHECK(cpuCoreCount >= 1); CHECK(cpuCoreCount >= 1); ALOGD("Number of CPU cores: %ld", cpuCoreCount); ALOGV("Number of CPU cores: %ld", cpuCoreCount); return (size_t)cpuCoreCount; return (size_t)cpuCoreCount; } } Loading Loading @@ -235,12 +241,10 @@ status_t SoftAVC::resetDecoder() { } } mSignalledError = false; mSignalledError = false; /* Set the run-time (dynamic) parameters */ setParams(outputBufferWidth()); /* Set number of cores/threads to be used by the codec */ /* Set number of cores/threads to be used by the codec */ setNumCores(); setNumCores(); mStride = 0; return OK; return OK; } } Loading Loading @@ -287,160 +291,41 @@ status_t SoftAVC::setFlushMode() { return OK; return OK; } } status_t SoftAVC::initDecoder(uint32_t width, uint32_t height) { status_t SoftAVC::initDecoder() { IV_API_CALL_STATUS_T status; IV_API_CALL_STATUS_T status; UWORD32 u4_num_reorder_frames; UWORD32 u4_num_ref_frames; UWORD32 u4_share_disp_buf; WORD32 i4_level; mNumCores = GetCPUCoreCount(); mNumCores = GetCPUCoreCount(); mCodecCtx = NULL; mCodecCtx = NULL; /* Initialize number of ref and reorder modes (for H264) */ mStride = outputBufferWidth(); u4_num_reorder_frames = 16; u4_num_ref_frames = 16; u4_share_disp_buf = 0; uint32_t displayStride = mIsAdaptive ? mAdaptiveMaxWidth : width; uint32_t displayHeight = mIsAdaptive ? mAdaptiveMaxHeight : height; uint32_t displaySizeY = displayStride * displayHeight; if(mNewLevel == 0){ if (displaySizeY > (1920 * 1088)) { i4_level = 50; } else if (displaySizeY > (1280 * 720)) { i4_level = 40; } else if (displaySizeY > (720 * 576)) { i4_level = 31; } else if (displaySizeY > (624 * 320)) { i4_level = 30; } else if (displaySizeY > (352 * 288)) { i4_level = 21; } else { i4_level = 20; } } else { i4_level = mNewLevel; } { iv_num_mem_rec_ip_t s_num_mem_rec_ip; iv_num_mem_rec_op_t s_num_mem_rec_op; s_num_mem_rec_ip.u4_size = sizeof(s_num_mem_rec_ip); s_num_mem_rec_op.u4_size = sizeof(s_num_mem_rec_op); s_num_mem_rec_ip.e_cmd = IV_CMD_GET_NUM_MEM_REC; ALOGV("Get number of mem records"); status = ivdec_api_function( mCodecCtx, (void *)&s_num_mem_rec_ip, (void *)&s_num_mem_rec_op); if (IV_SUCCESS != status) { ALOGE("Error in getting mem records: 0x%x", s_num_mem_rec_op.u4_error_code); return UNKNOWN_ERROR; } mNumMemRecords = s_num_mem_rec_op.u4_num_mem_rec; } mMemRecords = (iv_mem_rec_t *)ivd_aligned_malloc( 128, mNumMemRecords * sizeof(iv_mem_rec_t)); if (mMemRecords == NULL) { ALOGE("Allocation failure"); return NO_MEMORY; } memset(mMemRecords, 0, mNumMemRecords * sizeof(iv_mem_rec_t)); { size_t i; ivdext_fill_mem_rec_ip_t s_fill_mem_ip; ivdext_fill_mem_rec_op_t s_fill_mem_op; iv_mem_rec_t *ps_mem_rec; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.u4_size = sizeof(ivdext_fill_mem_rec_ip_t); s_fill_mem_ip.i4_level = i4_level; s_fill_mem_ip.u4_num_reorder_frames = u4_num_reorder_frames; s_fill_mem_ip.u4_num_ref_frames = u4_num_ref_frames; s_fill_mem_ip.u4_share_disp_buf = u4_share_disp_buf; s_fill_mem_ip.u4_num_extra_disp_buf = 0; s_fill_mem_ip.e_output_format = mIvColorFormat; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.e_cmd = IV_CMD_FILL_NUM_MEM_REC; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.pv_mem_rec_location = mMemRecords; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.u4_max_frm_wd = displayStride; s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.u4_max_frm_ht = displayHeight; s_fill_mem_op.s_ivd_fill_mem_rec_op_t.u4_size = sizeof(ivdext_fill_mem_rec_op_t); ps_mem_rec = mMemRecords; for (i = 0; i < mNumMemRecords; i++) { ps_mem_rec[i].u4_size = sizeof(iv_mem_rec_t); } status = ivdec_api_function( mCodecCtx, (void *)&s_fill_mem_ip, (void *)&s_fill_mem_op); if (IV_SUCCESS != status) { ALOGE("Error in filling mem records: 0x%x", s_fill_mem_op.s_ivd_fill_mem_rec_op_t.u4_error_code); return UNKNOWN_ERROR; } mNumMemRecords = s_fill_mem_op.s_ivd_fill_mem_rec_op_t.u4_num_mem_rec_filled; ps_mem_rec = mMemRecords; for (i = 0; i < mNumMemRecords; i++) { ps_mem_rec->pv_base = ivd_aligned_malloc( ps_mem_rec->u4_mem_alignment, ps_mem_rec->u4_mem_size); if (ps_mem_rec->pv_base == NULL) { ALOGE("Allocation failure for memory record #%zu of size %u", i, ps_mem_rec->u4_mem_size); status = IV_FAIL; return NO_MEMORY; } ps_mem_rec++; } } /* Initialize the decoder */ /* Initialize the decoder */ { { ivdext_init_ip_t s_init_ip; ivdext_create_ip_t s_create_ip; ivdext_init_op_t s_init_op; ivdext_create_op_t s_create_op; void *dec_fxns = (void *)ivdec_api_function; void *dec_fxns = (void *)ivdec_api_function; s_init_ip.s_ivd_init_ip_t.u4_size = sizeof(ivdext_init_ip_t); s_create_ip.s_ivd_create_ip_t.u4_size = sizeof(ivdext_create_ip_t); s_init_ip.s_ivd_init_ip_t.e_cmd = (IVD_API_COMMAND_TYPE_T)IV_CMD_INIT; s_create_ip.s_ivd_create_ip_t.e_cmd = IVD_CMD_CREATE; s_init_ip.s_ivd_init_ip_t.pv_mem_rec_location = mMemRecords; s_create_ip.s_ivd_create_ip_t.u4_share_disp_buf = 0; s_init_ip.s_ivd_init_ip_t.u4_frm_max_wd = displayStride; s_create_op.s_ivd_create_op_t.u4_size = sizeof(ivdext_create_op_t); s_init_ip.s_ivd_init_ip_t.u4_frm_max_ht = displayHeight; s_create_ip.s_ivd_create_ip_t.e_output_format = mIvColorFormat; s_create_ip.s_ivd_create_ip_t.pf_aligned_alloc = ivd_aligned_malloc; s_init_ip.i4_level = i4_level; s_create_ip.s_ivd_create_ip_t.pf_aligned_free = ivd_aligned_free; s_init_ip.u4_num_reorder_frames = u4_num_reorder_frames; s_create_ip.s_ivd_create_ip_t.pv_mem_ctxt = NULL; s_init_ip.u4_num_ref_frames = u4_num_ref_frames; s_init_ip.u4_share_disp_buf = u4_share_disp_buf; s_init_ip.u4_num_extra_disp_buf = 0; s_init_op.s_ivd_init_op_t.u4_size = sizeof(s_init_op); s_init_ip.s_ivd_init_ip_t.u4_num_mem_rec = mNumMemRecords; status = ivdec_api_function(mCodecCtx, (void *)&s_create_ip, (void *)&s_create_op); s_init_ip.s_ivd_init_ip_t.e_output_format = mIvColorFormat; mCodecCtx = (iv_obj_t *)mMemRecords[0].pv_base; mCodecCtx = (iv_obj_t*)s_create_op.s_ivd_create_op_t.pv_handle; mCodecCtx->pv_fxns = dec_fxns; mCodecCtx->pv_fxns = dec_fxns; mCodecCtx->u4_size = sizeof(iv_obj_t); mCodecCtx->u4_size = sizeof(iv_obj_t); status = ivdec_api_function(mCodecCtx, (void *)&s_init_ip, (void *)&s_init_op); if (status != IV_SUCCESS) { if (status != IV_SUCCESS) { ALOGE("Error in create: 0x%x", s_create_op.s_ivd_create_op_t.u4_error_code); deInitDecoder(); mCodecCtx = NULL; mCodecCtx = NULL; ALOGE("Error in init: 0x%x", s_init_op.s_ivd_init_op_t.u4_error_code); return UNKNOWN_ERROR; return UNKNOWN_ERROR; } } } } Loading @@ -449,7 +334,7 @@ status_t SoftAVC::initDecoder(uint32_t width, uint32_t height) { resetPlugin(); resetPlugin(); /* Set the run time (dynamic) parameters */ /* Set the run time (dynamic) parameters */ setParams(displayStride); setParams(mStride); /* Set number of cores/threads to be used by the codec */ /* Set number of cores/threads to be used by the codec */ setNumCores(); setNumCores(); Loading @@ -457,61 +342,37 @@ status_t SoftAVC::initDecoder(uint32_t width, uint32_t height) { /* Get codec version */ /* Get codec version */ logVersion(); logVersion(); /* Allocate internal picture buffer */ uint32_t bufferSize = displaySizeY * 3 / 2; mFlushOutBuffer = (uint8_t *)ivd_aligned_malloc(128, bufferSize); if (NULL == mFlushOutBuffer) { ALOGE("Could not allocate flushOutputBuffer of size %zu", bufferSize); return NO_MEMORY; } mInitNeeded = false; mFlushNeeded = false; mFlushNeeded = false; return OK; return OK; } } status_t SoftAVC::deInitDecoder() { status_t SoftAVC::deInitDecoder() { size_t i; size_t i; IV_API_CALL_STATUS_T status; if (mMemRecords) { if (mCodecCtx) { iv_mem_rec_t *ps_mem_rec; ivdext_delete_ip_t s_delete_ip; ivdext_delete_op_t s_delete_op; ps_mem_rec = mMemRecords; s_delete_ip.s_ivd_delete_ip_t.u4_size = sizeof(ivdext_delete_ip_t); for (i = 0; i < mNumMemRecords; i++) { s_delete_ip.s_ivd_delete_ip_t.e_cmd = IVD_CMD_DELETE; if (ps_mem_rec->pv_base) { ivd_aligned_free(ps_mem_rec->pv_base); s_delete_op.s_ivd_delete_op_t.u4_size = sizeof(ivdext_delete_op_t); } ps_mem_rec++; status = ivdec_api_function(mCodecCtx, (void *)&s_delete_ip, (void *)&s_delete_op); if (status != IV_SUCCESS) { ALOGE("Error in delete: 0x%x", s_delete_op.s_ivd_delete_op_t.u4_error_code); return UNKNOWN_ERROR; } } ivd_aligned_free(mMemRecords); mMemRecords = NULL; } } if (mFlushOutBuffer) { ivd_aligned_free(mFlushOutBuffer); mFlushOutBuffer = NULL; } mInitNeeded = true; mChangingResolution = false; mChangingResolution = false; return OK; return OK; } } status_t SoftAVC::reInitDecoder(uint32_t width, uint32_t height) { status_t ret; deInitDecoder(); ret = initDecoder(width, height); if (OK != ret) { ALOGE("Create failure"); deInitDecoder(); return NO_MEMORY; } return OK; } void SoftAVC::onReset() { void SoftAVC::onReset() { SoftVideoDecoderOMXComponent::onReset(); SoftVideoDecoderOMXComponent::onReset(); Loading @@ -520,21 +381,6 @@ void SoftAVC::onReset() { resetPlugin(); resetPlugin(); } } OMX_ERRORTYPE SoftAVC::internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR params) { const uint32_t oldWidth = mWidth; const uint32_t oldHeight = mHeight; OMX_ERRORTYPE ret = SoftVideoDecoderOMXComponent::internalSetParameter(index, params); if (mWidth != oldWidth || mHeight != oldHeight) { status_t err = reInitDecoder(mNewWidth, mNewHeight); if (err != OK) { notify(OMX_EventError, OMX_ErrorUnsupportedSetting, err, NULL); mSignalledError = true; return OMX_ErrorUnsupportedSetting; } } return ret; } void SoftAVC::setDecodeArgs( void SoftAVC::setDecodeArgs( ivd_video_decode_ip_t *ps_dec_ip, ivd_video_decode_ip_t *ps_dec_ip, ivd_video_decode_op_t *ps_dec_op, ivd_video_decode_op_t *ps_dec_op, Loading Loading @@ -585,6 +431,17 @@ void SoftAVC::onPortFlushCompleted(OMX_U32 portIndex) { if (kOutputPortIndex == portIndex) { if (kOutputPortIndex == portIndex) { setFlushMode(); setFlushMode(); /* Allocate a picture buffer to flushed data */ uint32_t displayStride = outputBufferWidth(); uint32_t displayHeight = outputBufferHeight(); uint32_t bufferSize = displayStride * displayHeight * 3 / 2; mFlushOutBuffer = (uint8_t *)memalign(128, bufferSize); if (NULL == mFlushOutBuffer) { ALOGE("Could not allocate flushOutputBuffer of size %zu", bufferSize); return; } while (true) { while (true) { ivd_video_decode_ip_t s_dec_ip; ivd_video_decode_ip_t s_dec_ip; ivd_video_decode_op_t s_dec_op; ivd_video_decode_op_t s_dec_op; Loading @@ -599,6 +456,12 @@ void SoftAVC::onPortFlushCompleted(OMX_U32 portIndex) { break; break; } } } } if (mFlushOutBuffer) { free(mFlushOutBuffer); mFlushOutBuffer = NULL; } } } } } Loading @@ -612,6 +475,17 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { return; return; } } if (NULL == mCodecCtx) { if (OK != initDecoder()) { return; } } if (outputBufferWidth() != mStride) { /* Set the run-time (dynamic) parameters */ mStride = outputBufferWidth(); setParams(mStride); } List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex); List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex); List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex); List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex); Loading Loading @@ -662,22 +536,6 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { } } } } // When there is an init required and the decoder is not in flush mode, // update output port's definition and reinitialize decoder. if (mInitNeeded && !mIsInFlush) { bool portWillReset = false; status_t err = reInitDecoder(mNewWidth, mNewHeight); if (err != OK) { notify(OMX_EventError, OMX_ErrorUnsupportedSetting, err, NULL); mSignalledError = true; return; } handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight); return; } /* Get a free slot in timestamp array to hold input timestamp */ /* Get a free slot in timestamp array to hold input timestamp */ { { size_t i; size_t i; Loading Loading @@ -712,10 +570,7 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { IV_API_CALL_STATUS_T status; IV_API_CALL_STATUS_T status; status = ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); status = ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); bool unsupportedDimensions = (IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED == (s_dec_op.u4_error_code & 0xFF)); bool resChanged = (IVD_RES_CHANGED == (s_dec_op.u4_error_code & 0xFF)); bool resChanged = (IVD_RES_CHANGED == (s_dec_op.u4_error_code & 0xFF)); bool unsupportedLevel = (IH264D_UNSUPPORTED_LEVEL == (s_dec_op.u4_error_code & 0xFF)); GETTIME(&mTimeEnd, NULL); GETTIME(&mTimeEnd, NULL); /* Compute time taken for decode() */ /* Compute time taken for decode() */ Loading @@ -733,46 +588,6 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { mTimeStampsValid[timeStampIx] = false; mTimeStampsValid[timeStampIx] = false; } } // This is needed to handle CTS DecoderTest testCodecResetsH264WithoutSurface, // which is not sending SPS/PPS after port reconfiguration and flush to the codec. if (unsupportedDimensions && !mFlushNeeded) { bool portWillReset = false; mNewWidth = s_dec_op.u4_pic_wd; mNewHeight = s_dec_op.u4_pic_ht; status_t err = reInitDecoder(mNewWidth, mNewHeight); if (err != OK) { notify(OMX_EventError, OMX_ErrorUnsupportedSetting, err, NULL); mSignalledError = true; return; } handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight); setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx); ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); return; } if (unsupportedLevel && !mFlushNeeded) { mNewLevel = 51; status_t err = reInitDecoder(mNewWidth, mNewHeight); if (err != OK) { notify(OMX_EventError, OMX_ErrorUnsupportedSetting, err, NULL); mSignalledError = true; return; } setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx); ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); return; } // If the decoder is in the changing resolution mode and there is no output present, // If the decoder is in the changing resolution mode and there is no output present, // that means the switching is done and it's ready to reset the decoder and the plugin. // that means the switching is done and it's ready to reset the decoder and the plugin. if (mChangingResolution && !s_dec_op.u4_output_present) { if (mChangingResolution && !s_dec_op.u4_output_present) { Loading @@ -782,28 +597,11 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { continue; continue; } } if (unsupportedDimensions || resChanged) { if (resChanged) { mChangingResolution = true; mChangingResolution = true; if (mFlushNeeded) { if (mFlushNeeded) { setFlushMode(); setFlushMode(); } } if (unsupportedDimensions) { mNewWidth = s_dec_op.u4_pic_wd; mNewHeight = s_dec_op.u4_pic_ht; mInitNeeded = true; } continue; } if (unsupportedLevel) { if (mFlushNeeded) { setFlushMode(); } mNewLevel = 51; mInitNeeded = true; continue; continue; } } Loading @@ -820,7 +618,7 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) { } } if (s_dec_op.u4_output_present) { if (s_dec_op.u4_output_present) { outHeader->nFilledLen = (mWidth * mHeight * 3) / 2; outHeader->nFilledLen = (outputBufferWidth() * outputBufferHeight() * 3) / 2; outHeader->nTimeStamp = mTimeStamps[s_dec_op.u4_ts]; outHeader->nTimeStamp = mTimeStamps[s_dec_op.u4_ts]; mTimeStampsValid[s_dec_op.u4_ts] = false; mTimeStampsValid[s_dec_op.u4_ts] = false; Loading
media/libstagefright/codecs/avcdec/SoftAVCDec.h +4 −12 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,6 @@ namespace android { namespace android { #define ivd_aligned_malloc(alignment, size) memalign(alignment, size) #define ivd_aligned_free(buf) free(buf) /** Number of entries in the time-stamp array */ /** Number of entries in the time-stamp array */ #define MAX_TIME_STAMPS 64 #define MAX_TIME_STAMPS 64 Loading Loading @@ -62,7 +59,6 @@ protected: virtual void onQueueFilled(OMX_U32 portIndex); virtual void onQueueFilled(OMX_U32 portIndex); virtual void onPortFlushCompleted(OMX_U32 portIndex); virtual void onPortFlushCompleted(OMX_U32 portIndex); virtual void onReset(); virtual void onReset(); virtual OMX_ERRORTYPE internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR params); private: private: // Number of input and output buffers // Number of input and output buffers enum { enum { Loading @@ -70,8 +66,6 @@ private: }; }; iv_obj_t *mCodecCtx; // Codec context iv_obj_t *mCodecCtx; // Codec context iv_mem_rec_t *mMemRecords; // Memory records requested by the codec size_t mNumMemRecords; // Number of memory records requested by the codec size_t mNumCores; // Number of cores to be uesd by the codec size_t mNumCores; // Number of cores to be uesd by the codec Loading @@ -97,17 +91,15 @@ private: bool mIsInFlush; // codec is flush mode bool mIsInFlush; // codec is flush mode bool mReceivedEOS; // EOS is receieved on input port bool mReceivedEOS; // EOS is receieved on input port bool mInitNeeded; uint32_t mNewWidth; uint32_t mNewHeight; uint32_t mNewLevel; // The input stream has changed to a different resolution, which is still supported by the // The input stream has changed to a different resolution, which is still supported by the // codec. So the codec is switching to decode the new resolution. // codec. So the codec is switching to decode the new resolution. bool mChangingResolution; bool mChangingResolution; bool mFlushNeeded; bool mFlushNeeded; bool mSignalledError; bool mSignalledError; size_t mStride; status_t initDecoder(uint32_t width, uint32_t height); status_t initDecoder(); status_t deInitDecoder(); status_t deInitDecoder(); status_t setFlushMode(); status_t setFlushMode(); status_t setParams(size_t stride); status_t setParams(size_t stride); Loading @@ -115,7 +107,7 @@ private: status_t setNumCores(); status_t setNumCores(); status_t resetDecoder(); status_t resetDecoder(); status_t resetPlugin(); status_t resetPlugin(); status_t reInitDecoder(uint32_t width, uint32_t height); void setDecodeArgs( void setDecodeArgs( ivd_video_decode_ip_t *ps_dec_ip, ivd_video_decode_ip_t *ps_dec_ip, Loading