Loading media/codec2/components/avc/C2SoftAvcEnc.cpp +11 −60 Original line number Diff line number Diff line Loading @@ -454,19 +454,11 @@ static size_t GetCPUCoreCount() { } // namespace static IV_COLOR_FORMAT_T GetIvColorFormat() { static IV_COLOR_FORMAT_T sColorFormat = (GetYuv420FlexibleLayout() == FLEX_LAYOUT_SEMIPLANAR_UV) ? IV_YUV_420SP_UV : (GetYuv420FlexibleLayout() == FLEX_LAYOUT_SEMIPLANAR_VU) ? IV_YUV_420SP_VU : IV_YUV_420P; return sColorFormat; } C2SoftAvcEnc::C2SoftAvcEnc( const char *name, c2_node_id_t id, const std::shared_ptr<IntfImpl> &intfImpl) : SimpleC2Component(std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)), mIntf(intfImpl), mIvVideoColorFormat(GetIvColorFormat()), mIvVideoColorFormat(IV_YUV_420P), mAVCEncProfile(IV_PROFILE_BASE), mAVCEncLevel(41), mStarted(false), Loading Loading @@ -1034,7 +1026,8 @@ c2_status_t C2SoftAvcEnc::initEncoder() { // Assume worst case output buffer size to be equal to number of bytes in input mOutBufferSize = std::max(width * height * 3 / 2, kMinOutBufferSize); mIvVideoColorFormat = GetIvColorFormat(); // TODO mIvVideoColorFormat = IV_YUV_420P; ALOGD("Params width %d height %d level %d colorFormat %d bframes %d", width, height, mAVCEncLevel, mIvVideoColorFormat, mBframes); Loading Loading @@ -1332,6 +1325,7 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( mSize->width, input->height(), mSize->height); return C2_BAD_VALUE; } ALOGV("width = %d, height = %d", input->width(), input->height()); const C2PlanarLayout &layout = input->layout(); uint8_t *yPlane = const_cast<uint8_t *>(input->data()[C2PlanarLayout::PLANE_Y]); uint8_t *uPlane = const_cast<uint8_t *>(input->data()[C2PlanarLayout::PLANE_U]); Loading Loading @@ -1368,8 +1362,7 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( return C2_BAD_VALUE; } if (mIvVideoColorFormat == IV_YUV_420P && layout.planes[layout.PLANE_Y].colInc == 1 if (layout.planes[layout.PLANE_Y].colInc == 1 && layout.planes[layout.PLANE_U].colInc == 1 && layout.planes[layout.PLANE_V].colInc == 1 && uStride == vStride Loading @@ -1377,61 +1370,21 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( // I420 compatible - already set up above break; } if (mIvVideoColorFormat == IV_YUV_420SP_UV && layout.planes[layout.PLANE_Y].colInc == 1 && layout.planes[layout.PLANE_U].colInc == 2 && layout.planes[layout.PLANE_V].colInc == 2 && uStride == vStride && yStride == vStride && uPlane + 1 == vPlane) { // NV12 compatible - already set up above break; } if (mIvVideoColorFormat == IV_YUV_420SP_VU && layout.planes[layout.PLANE_Y].colInc == 1 && layout.planes[layout.PLANE_U].colInc == 2 && layout.planes[layout.PLANE_V].colInc == 2 && uStride == vStride && yStride == vStride && uPlane == vPlane + 1) { // NV21 compatible - already set up above break; } // copy to I420 yStride = width; uStride = vStride = yStride / 2; MemoryBlock conversionBuffer = mConversionBuffers.fetch(yPlaneSize * 3 / 2); mConversionBuffersInUse.emplace(conversionBuffer.data(), conversionBuffer); MediaImage2 img; switch (mIvVideoColorFormat) { case IV_YUV_420P: img = CreateYUV420PlanarMediaImage2(width, height, yStride, height); yPlane = conversionBuffer.data(); uPlane = yPlane + yPlaneSize; vPlane = uPlane + yPlaneSize / 4; break; case IV_YUV_420SP_VU: img = CreateYUV420SemiPlanarMediaImage2(width, height, yStride, height); img.mPlane[MediaImage2::U].mOffset++; img.mPlane[MediaImage2::V].mOffset--; yPlane = conversionBuffer.data(); vPlane = yPlane + yPlaneSize; uPlane = vPlane + 1; break; case IV_YUV_420SP_UV: default: img = CreateYUV420SemiPlanarMediaImage2(width, height, yStride, height); yPlane = conversionBuffer.data(); uPlane = yPlane + yPlaneSize; vPlane = uPlane + 1; break; } MediaImage2 img = CreateYUV420PlanarMediaImage2(width, height, yStride, height); status_t err = ImageCopy(conversionBuffer.data(), &img, *input); if (err != OK) { ALOGE("Buffer conversion failed: %d", err); return C2_BAD_VALUE; } yPlane = conversionBuffer.data(); uPlane = yPlane + yPlaneSize; vPlane = uPlane + yPlaneSize / 4; break; } Loading Loading @@ -1477,17 +1430,15 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( break; } case IV_YUV_420SP_VU: uPlane = vPlane; [[fallthrough]]; case IV_YUV_420SP_UV: case IV_YUV_420SP_VU: default: { ps_inp_raw_buf->apv_bufs[0] = yPlane; ps_inp_raw_buf->apv_bufs[1] = uPlane; ps_inp_raw_buf->au4_wd[0] = mSize->width; ps_inp_raw_buf->au4_wd[1] = mSize->width / 2; ps_inp_raw_buf->au4_wd[1] = mSize->width; ps_inp_raw_buf->au4_ht[0] = mSize->height; ps_inp_raw_buf->au4_ht[1] = mSize->height / 2; Loading media/codec2/components/base/SimpleC2Component.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -110,17 +110,20 @@ void SimpleC2Component::WorkHandler::onMessageReceived(const sp<AMessage> &msg) } case kWhatStop: { int32_t err = thiz->onStop(); thiz->mOutputBlockPool.reset(); Reply(msg, &err); break; } case kWhatReset: { thiz->onReset(); thiz->mOutputBlockPool.reset(); mRunning = false; Reply(msg); break; } case kWhatRelease: { thiz->onRelease(); thiz->mOutputBlockPool.reset(); mRunning = false; Reply(msg); break; Loading media/codec2/hidl/services/seccomp_policy/android.hardware.media.c2@1.2-default-arm64.policy +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ ftruncate: 1 # on ARM is statically loaded at 0xffff 0000. See # http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211h/Babfeega.html # for more details. mremap: arg3 == 3 mremap: arg3 == 3 || arg3 == MREMAP_MAYMOVE munmap: 1 prctl: 1 writev: 1 Loading media/codec2/sfplugin/CCodec.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -2151,7 +2151,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { } // handle configuration changes in work done const C2StreamInitDataInfo::output *initData = nullptr; std::unique_ptr<C2Param> initData; sp<AMessage> outputFormat = nullptr; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -2229,10 +2229,14 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { if (config->mInputSurface) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } initData = initDataWatcher.hasChanged() ? initDataWatcher.update().get() : nullptr; if (initDataWatcher.hasChanged()) { initData = C2Param::Copy(*initDataWatcher.update().get()); } outputFormat = config->mOutputFormat; } mChannel->onWorkDone(std::move(work), outputFormat, initData); mChannel->onWorkDone( std::move(work), outputFormat, initData ? (C2StreamInitDataInfo::output *)initData.get() : nullptr); break; } case kWhatWatch: { Loading media/codec2/sfplugin/utils/Codec2BufferUtils.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -346,7 +346,7 @@ bool IsNV12(const MediaImage2 *img) { } return (img->mPlane[1].mColInc == 2 && img->mPlane[2].mColInc == 2 && (img->mPlane[2].mOffset - img->mPlane[1].mOffset == 1)); && (img->mPlane[2].mOffset == img->mPlane[1].mOffset + 1)); } bool IsNV21(const MediaImage2 *img) { Loading @@ -355,7 +355,7 @@ bool IsNV21(const MediaImage2 *img) { } return (img->mPlane[1].mColInc == 2 && img->mPlane[2].mColInc == 2 && (img->mPlane[1].mOffset - img->mPlane[2].mOffset == 1)); && (img->mPlane[1].mOffset == img->mPlane[2].mOffset + 1)); } bool IsI420(const MediaImage2 *img) { Loading Loading
media/codec2/components/avc/C2SoftAvcEnc.cpp +11 −60 Original line number Diff line number Diff line Loading @@ -454,19 +454,11 @@ static size_t GetCPUCoreCount() { } // namespace static IV_COLOR_FORMAT_T GetIvColorFormat() { static IV_COLOR_FORMAT_T sColorFormat = (GetYuv420FlexibleLayout() == FLEX_LAYOUT_SEMIPLANAR_UV) ? IV_YUV_420SP_UV : (GetYuv420FlexibleLayout() == FLEX_LAYOUT_SEMIPLANAR_VU) ? IV_YUV_420SP_VU : IV_YUV_420P; return sColorFormat; } C2SoftAvcEnc::C2SoftAvcEnc( const char *name, c2_node_id_t id, const std::shared_ptr<IntfImpl> &intfImpl) : SimpleC2Component(std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)), mIntf(intfImpl), mIvVideoColorFormat(GetIvColorFormat()), mIvVideoColorFormat(IV_YUV_420P), mAVCEncProfile(IV_PROFILE_BASE), mAVCEncLevel(41), mStarted(false), Loading Loading @@ -1034,7 +1026,8 @@ c2_status_t C2SoftAvcEnc::initEncoder() { // Assume worst case output buffer size to be equal to number of bytes in input mOutBufferSize = std::max(width * height * 3 / 2, kMinOutBufferSize); mIvVideoColorFormat = GetIvColorFormat(); // TODO mIvVideoColorFormat = IV_YUV_420P; ALOGD("Params width %d height %d level %d colorFormat %d bframes %d", width, height, mAVCEncLevel, mIvVideoColorFormat, mBframes); Loading Loading @@ -1332,6 +1325,7 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( mSize->width, input->height(), mSize->height); return C2_BAD_VALUE; } ALOGV("width = %d, height = %d", input->width(), input->height()); const C2PlanarLayout &layout = input->layout(); uint8_t *yPlane = const_cast<uint8_t *>(input->data()[C2PlanarLayout::PLANE_Y]); uint8_t *uPlane = const_cast<uint8_t *>(input->data()[C2PlanarLayout::PLANE_U]); Loading Loading @@ -1368,8 +1362,7 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( return C2_BAD_VALUE; } if (mIvVideoColorFormat == IV_YUV_420P && layout.planes[layout.PLANE_Y].colInc == 1 if (layout.planes[layout.PLANE_Y].colInc == 1 && layout.planes[layout.PLANE_U].colInc == 1 && layout.planes[layout.PLANE_V].colInc == 1 && uStride == vStride Loading @@ -1377,61 +1370,21 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( // I420 compatible - already set up above break; } if (mIvVideoColorFormat == IV_YUV_420SP_UV && layout.planes[layout.PLANE_Y].colInc == 1 && layout.planes[layout.PLANE_U].colInc == 2 && layout.planes[layout.PLANE_V].colInc == 2 && uStride == vStride && yStride == vStride && uPlane + 1 == vPlane) { // NV12 compatible - already set up above break; } if (mIvVideoColorFormat == IV_YUV_420SP_VU && layout.planes[layout.PLANE_Y].colInc == 1 && layout.planes[layout.PLANE_U].colInc == 2 && layout.planes[layout.PLANE_V].colInc == 2 && uStride == vStride && yStride == vStride && uPlane == vPlane + 1) { // NV21 compatible - already set up above break; } // copy to I420 yStride = width; uStride = vStride = yStride / 2; MemoryBlock conversionBuffer = mConversionBuffers.fetch(yPlaneSize * 3 / 2); mConversionBuffersInUse.emplace(conversionBuffer.data(), conversionBuffer); MediaImage2 img; switch (mIvVideoColorFormat) { case IV_YUV_420P: img = CreateYUV420PlanarMediaImage2(width, height, yStride, height); yPlane = conversionBuffer.data(); uPlane = yPlane + yPlaneSize; vPlane = uPlane + yPlaneSize / 4; break; case IV_YUV_420SP_VU: img = CreateYUV420SemiPlanarMediaImage2(width, height, yStride, height); img.mPlane[MediaImage2::U].mOffset++; img.mPlane[MediaImage2::V].mOffset--; yPlane = conversionBuffer.data(); vPlane = yPlane + yPlaneSize; uPlane = vPlane + 1; break; case IV_YUV_420SP_UV: default: img = CreateYUV420SemiPlanarMediaImage2(width, height, yStride, height); yPlane = conversionBuffer.data(); uPlane = yPlane + yPlaneSize; vPlane = uPlane + 1; break; } MediaImage2 img = CreateYUV420PlanarMediaImage2(width, height, yStride, height); status_t err = ImageCopy(conversionBuffer.data(), &img, *input); if (err != OK) { ALOGE("Buffer conversion failed: %d", err); return C2_BAD_VALUE; } yPlane = conversionBuffer.data(); uPlane = yPlane + yPlaneSize; vPlane = uPlane + yPlaneSize / 4; break; } Loading Loading @@ -1477,17 +1430,15 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( break; } case IV_YUV_420SP_VU: uPlane = vPlane; [[fallthrough]]; case IV_YUV_420SP_UV: case IV_YUV_420SP_VU: default: { ps_inp_raw_buf->apv_bufs[0] = yPlane; ps_inp_raw_buf->apv_bufs[1] = uPlane; ps_inp_raw_buf->au4_wd[0] = mSize->width; ps_inp_raw_buf->au4_wd[1] = mSize->width / 2; ps_inp_raw_buf->au4_wd[1] = mSize->width; ps_inp_raw_buf->au4_ht[0] = mSize->height; ps_inp_raw_buf->au4_ht[1] = mSize->height / 2; Loading
media/codec2/components/base/SimpleC2Component.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -110,17 +110,20 @@ void SimpleC2Component::WorkHandler::onMessageReceived(const sp<AMessage> &msg) } case kWhatStop: { int32_t err = thiz->onStop(); thiz->mOutputBlockPool.reset(); Reply(msg, &err); break; } case kWhatReset: { thiz->onReset(); thiz->mOutputBlockPool.reset(); mRunning = false; Reply(msg); break; } case kWhatRelease: { thiz->onRelease(); thiz->mOutputBlockPool.reset(); mRunning = false; Reply(msg); break; Loading
media/codec2/hidl/services/seccomp_policy/android.hardware.media.c2@1.2-default-arm64.policy +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ ftruncate: 1 # on ARM is statically loaded at 0xffff 0000. See # http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211h/Babfeega.html # for more details. mremap: arg3 == 3 mremap: arg3 == 3 || arg3 == MREMAP_MAYMOVE munmap: 1 prctl: 1 writev: 1 Loading
media/codec2/sfplugin/CCodec.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -2151,7 +2151,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { } // handle configuration changes in work done const C2StreamInitDataInfo::output *initData = nullptr; std::unique_ptr<C2Param> initData; sp<AMessage> outputFormat = nullptr; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -2229,10 +2229,14 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { if (config->mInputSurface) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } initData = initDataWatcher.hasChanged() ? initDataWatcher.update().get() : nullptr; if (initDataWatcher.hasChanged()) { initData = C2Param::Copy(*initDataWatcher.update().get()); } outputFormat = config->mOutputFormat; } mChannel->onWorkDone(std::move(work), outputFormat, initData); mChannel->onWorkDone( std::move(work), outputFormat, initData ? (C2StreamInitDataInfo::output *)initData.get() : nullptr); break; } case kWhatWatch: { Loading
media/codec2/sfplugin/utils/Codec2BufferUtils.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -346,7 +346,7 @@ bool IsNV12(const MediaImage2 *img) { } return (img->mPlane[1].mColInc == 2 && img->mPlane[2].mColInc == 2 && (img->mPlane[2].mOffset - img->mPlane[1].mOffset == 1)); && (img->mPlane[2].mOffset == img->mPlane[1].mOffset + 1)); } bool IsNV21(const MediaImage2 *img) { Loading @@ -355,7 +355,7 @@ bool IsNV21(const MediaImage2 *img) { } return (img->mPlane[1].mColInc == 2 && img->mPlane[2].mColInc == 2 && (img->mPlane[1].mOffset - img->mPlane[2].mOffset == 1)); && (img->mPlane[1].mOffset == img->mPlane[2].mOffset + 1)); } bool IsI420(const MediaImage2 *img) { Loading