diff --git a/media/codec2/components/avc/C2SoftAvcDec.cpp b/media/codec2/components/avc/C2SoftAvcDec.cpp index d686eb1a0b..c1edb981f9 100644 --- a/media/codec2/components/avc/C2SoftAvcDec.cpp +++ b/media/codec2/components/avc/C2SoftAvcDec.cpp @@ -502,7 +502,7 @@ void C2SoftAvcDec::getVersion() { status_t C2SoftAvcDec::initDecoder() { if (OK != createDecoder()) return UNKNOWN_ERROR; mNumCores = MIN(getCpuCoreCount(), MAX_NUM_CORES); - mStride = ALIGN128(mWidth); + mStride = ALIGN32(mWidth); mSignalledError = false; resetPlugin(); (void) setNumCores(); @@ -520,10 +520,20 @@ bool C2SoftAvcDec::setDecodeArgs(ivd_video_decode_ip_t *ps_decode_ip, size_t inSize, uint32_t tsMarker) { uint32_t displayStride = mStride; + if (outBuffer) { + C2PlanarLayout layout; + layout = outBuffer->layout(); + displayStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc; + } uint32_t displayHeight = mHeight; size_t lumaSize = displayStride * displayHeight; size_t chromaSize = lumaSize >> 2; + if (mStride != displayStride) { + mStride = displayStride; + if (OK != setParams(mStride, IVD_DECODE_FRAME)) return false; + } + ps_decode_ip->u4_size = sizeof(ivd_video_decode_ip_t); ps_decode_ip->e_cmd = IVD_CMD_VIDEO_DECODE; if (inBuffer) { @@ -757,24 +767,21 @@ c2_status_t C2SoftAvcDec::ensureDecoderState(const std::shared_ptr ALOGE("not supposed to be here, invalid decoder context"); return C2_CORRUPTED; } - if (mStride != ALIGN128(mWidth)) { - mStride = ALIGN128(mWidth); - if (OK != setParams(mStride, IVD_DECODE_FRAME)) return C2_CORRUPTED; - } if (mOutBlock && - (mOutBlock->width() != mStride || mOutBlock->height() != mHeight)) { + (mOutBlock->width() != ALIGN32(mWidth) || mOutBlock->height() != mHeight)) { mOutBlock.reset(); } if (!mOutBlock) { uint32_t format = HAL_PIXEL_FORMAT_YV12; C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE }; - c2_status_t err = pool->fetchGraphicBlock(mStride, mHeight, format, usage, &mOutBlock); + c2_status_t err = + pool->fetchGraphicBlock(ALIGN32(mWidth), mHeight, format, usage, &mOutBlock); if (err != C2_OK) { ALOGE("fetchGraphicBlock for Output failed with status %d", err); return err; } ALOGV("provided (%dx%d) required (%dx%d)", - mOutBlock->width(), mOutBlock->height(), mStride, mHeight); + mOutBlock->width(), mOutBlock->height(), ALIGN32(mWidth), mHeight); } return C2_OK; @@ -909,7 +916,8 @@ void C2SoftAvcDec::process( if (0 < s_decode_op.u4_pic_wd && 0 < s_decode_op.u4_pic_ht) { if (mHeaderDecoded == false) { mHeaderDecoded = true; - setParams(ALIGN128(s_decode_op.u4_pic_wd), IVD_DECODE_FRAME); + mStride = ALIGN32(s_decode_op.u4_pic_wd); + setParams(mStride, IVD_DECODE_FRAME); } if (s_decode_op.u4_pic_wd != mWidth || s_decode_op.u4_pic_ht != mHeight) { mWidth = s_decode_op.u4_pic_wd; diff --git a/media/codec2/components/avc/C2SoftAvcDec.h b/media/codec2/components/avc/C2SoftAvcDec.h index ed27493f32..bd84de08ea 100644 --- a/media/codec2/components/avc/C2SoftAvcDec.h +++ b/media/codec2/components/avc/C2SoftAvcDec.h @@ -39,8 +39,7 @@ namespace android { #define ivdext_ctl_set_num_cores_op_t ih264d_ctl_set_num_cores_op_t #define ivdext_ctl_get_vui_params_ip_t ih264d_ctl_get_vui_params_ip_t #define ivdext_ctl_get_vui_params_op_t ih264d_ctl_get_vui_params_op_t -#define ALIGN64(x) ((((x) + 63) >> 6) << 6) -#define ALIGN128(x) ((((x) + 127) >> 7) << 7) +#define ALIGN32(x) ((((x) + 31) >> 5) << 5) #define MAX_NUM_CORES 4 #define IVDEXT_CMD_CTL_SET_NUM_CORES \ (IVD_CONTROL_API_COMMAND_TYPE_T)IH264D_CMD_CTL_SET_NUM_CORES diff --git a/media/codec2/components/hevc/C2SoftHevcDec.cpp b/media/codec2/components/hevc/C2SoftHevcDec.cpp index 6db4387272..e4b911d542 100644 --- a/media/codec2/components/hevc/C2SoftHevcDec.cpp +++ b/media/codec2/components/hevc/C2SoftHevcDec.cpp @@ -497,7 +497,7 @@ status_t C2SoftHevcDec::getVersion() { status_t C2SoftHevcDec::initDecoder() { if (OK != createDecoder()) return UNKNOWN_ERROR; mNumCores = MIN(getCpuCoreCount(), MAX_NUM_CORES); - mStride = ALIGN128(mWidth); + mStride = ALIGN32(mWidth); mSignalledError = false; resetPlugin(); (void) setNumCores(); @@ -515,10 +515,20 @@ bool C2SoftHevcDec::setDecodeArgs(ivd_video_decode_ip_t *ps_decode_ip, size_t inSize, uint32_t tsMarker) { uint32_t displayStride = mStride; + if (outBuffer) { + C2PlanarLayout layout; + layout = outBuffer->layout(); + displayStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc; + } uint32_t displayHeight = mHeight; size_t lumaSize = displayStride * displayHeight; size_t chromaSize = lumaSize >> 2; + if (mStride != displayStride) { + mStride = displayStride; + if (OK != setParams(mStride, IVD_DECODE_FRAME)) return false; + } + ps_decode_ip->u4_size = sizeof(ivd_video_decode_ip_t); ps_decode_ip->e_cmd = IVD_CMD_VIDEO_DECODE; if (inBuffer) { @@ -752,24 +762,21 @@ c2_status_t C2SoftHevcDec::ensureDecoderState(const std::shared_ptr ALOGE("not supposed to be here, invalid decoder context"); return C2_CORRUPTED; } - if (mStride != ALIGN128(mWidth)) { - mStride = ALIGN128(mWidth); - if (OK != setParams(mStride, IVD_DECODE_FRAME)) return C2_CORRUPTED; - } if (mOutBlock && - (mOutBlock->width() != mStride || mOutBlock->height() != mHeight)) { + (mOutBlock->width() != ALIGN32(mWidth) || mOutBlock->height() != mHeight)) { mOutBlock.reset(); } if (!mOutBlock) { uint32_t format = HAL_PIXEL_FORMAT_YV12; C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE }; - c2_status_t err = pool->fetchGraphicBlock(mStride, mHeight, format, usage, &mOutBlock); + c2_status_t err = + pool->fetchGraphicBlock(ALIGN32(mWidth), mHeight, format, usage, &mOutBlock); if (err != C2_OK) { ALOGE("fetchGraphicBlock for Output failed with status %d", err); return err; } ALOGV("provided (%dx%d) required (%dx%d)", - mOutBlock->width(), mOutBlock->height(), mStride, mHeight); + mOutBlock->width(), mOutBlock->height(), ALIGN32(mWidth), mHeight); } return C2_OK; @@ -904,7 +911,7 @@ void C2SoftHevcDec::process( if (0 < s_decode_op.u4_pic_wd && 0 < s_decode_op.u4_pic_ht) { if (mHeaderDecoded == false) { mHeaderDecoded = true; - setParams(ALIGN128(s_decode_op.u4_pic_wd), IVD_DECODE_FRAME); + setParams(ALIGN32(s_decode_op.u4_pic_wd), IVD_DECODE_FRAME); } if (s_decode_op.u4_pic_wd != mWidth || s_decode_op.u4_pic_ht != mHeight) { mWidth = s_decode_op.u4_pic_wd; diff --git a/media/codec2/components/hevc/C2SoftHevcDec.h b/media/codec2/components/hevc/C2SoftHevcDec.h index aecd1011de..600d7c1953 100644 --- a/media/codec2/components/hevc/C2SoftHevcDec.h +++ b/media/codec2/components/hevc/C2SoftHevcDec.h @@ -37,8 +37,7 @@ namespace android { #define ivdext_ctl_set_num_cores_op_t ihevcd_cxa_ctl_set_num_cores_op_t #define ivdext_ctl_get_vui_params_ip_t ihevcd_cxa_ctl_get_vui_params_ip_t #define ivdext_ctl_get_vui_params_op_t ihevcd_cxa_ctl_get_vui_params_op_t -#define ALIGN64(x) ((((x) + 63) >> 6) << 6) -#define ALIGN128(x) ((((x) + 127) >> 7) << 7) +#define ALIGN32(x) ((((x) + 31) >> 5) << 5) #define MAX_NUM_CORES 4 #define IVDEXT_CMD_CTL_SET_NUM_CORES \ (IVD_CONTROL_API_COMMAND_TYPE_T)IHEVCD_CXA_CMD_CTL_SET_NUM_CORES diff --git a/media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp b/media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp index e0365fc28f..c7ca18c4dd 100644 --- a/media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp +++ b/media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp @@ -571,7 +571,7 @@ status_t C2SoftMpeg2Dec::initDecoder() { if (OK != createDecoder()) return UNKNOWN_ERROR; mNumCores = MIN(getCpuCoreCount(), MAX_NUM_CORES); - mStride = ALIGN64(mWidth); + mStride = ALIGN32(mWidth); mSignalledError = false; resetPlugin(); (void) setNumCores(); @@ -589,10 +589,20 @@ bool C2SoftMpeg2Dec::setDecodeArgs(ivd_video_decode_ip_t *ps_decode_ip, size_t inSize, uint32_t tsMarker) { uint32_t displayStride = mStride; + if (outBuffer) { + C2PlanarLayout layout; + layout = outBuffer->layout(); + displayStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc; + } uint32_t displayHeight = mHeight; size_t lumaSize = displayStride * displayHeight; size_t chromaSize = lumaSize >> 2; + if (mStride != displayStride) { + mStride = displayStride; + if (OK != setParams(mStride)) return false; + } + ps_decode_ip->u4_size = sizeof(ivd_video_decode_ip_t); ps_decode_ip->e_cmd = IVD_CMD_VIDEO_DECODE; if (inBuffer) { @@ -833,24 +843,21 @@ c2_status_t C2SoftMpeg2Dec::ensureDecoderState(const std::shared_ptrwidth() != mStride || mOutBlock->height() != mHeight)) { + (mOutBlock->width() != ALIGN32(mWidth) || mOutBlock->height() != mHeight)) { mOutBlock.reset(); } if (!mOutBlock) { uint32_t format = HAL_PIXEL_FORMAT_YV12; C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE }; - c2_status_t err = pool->fetchGraphicBlock(mStride, mHeight, format, usage, &mOutBlock); + c2_status_t err = + pool->fetchGraphicBlock(ALIGN32(mWidth), mHeight, format, usage, &mOutBlock); if (err != C2_OK) { ALOGE("fetchGraphicBlock for Output failed with status %d", err); return err; } ALOGV("provided (%dx%d) required (%dx%d)", - mOutBlock->width(), mOutBlock->height(), mStride, mHeight); + mOutBlock->width(), mOutBlock->height(), ALIGN32(mWidth), mHeight); } return C2_OK; diff --git a/media/codec2/components/mpeg2/C2SoftMpeg2Dec.h b/media/codec2/components/mpeg2/C2SoftMpeg2Dec.h index 65d3b87fcd..fd66304ad0 100644 --- a/media/codec2/components/mpeg2/C2SoftMpeg2Dec.h +++ b/media/codec2/components/mpeg2/C2SoftMpeg2Dec.h @@ -37,7 +37,7 @@ namespace android { #define ivdext_ctl_set_num_cores_op_t impeg2d_ctl_set_num_cores_op_t #define ivdext_ctl_get_seq_info_ip_t impeg2d_ctl_get_seq_info_ip_t #define ivdext_ctl_get_seq_info_op_t impeg2d_ctl_get_seq_info_op_t -#define ALIGN64(x) ((((x) + 63) >> 6) << 6) +#define ALIGN32(x) ((((x) + 31) >> 5) << 5) #define MAX_NUM_CORES 4 #define IVDEXT_CMD_CTL_SET_NUM_CORES \ (IVD_CONTROL_API_COMMAND_TYPE_T)IMPEG2D_CMD_CTL_SET_NUM_CORES