diff --git a/entry/src/main/cpp/capbilities/Muxer.cpp b/entry/src/main/cpp/capbilities/Muxer.cpp index fec20da8fda31170c9b9b1d102b1e9749caf51a9..1bcd8b362798ee13a9ff609aebdc1f0600394504 100644 --- a/entry/src/main/cpp/capbilities/Muxer.cpp +++ b/entry/src/main/cpp/capbilities/Muxer.cpp @@ -20,8 +20,7 @@ #define LOG_TAG "Muxer" namespace { -constexpr int32_t VERTICAL_ANGLE = 90; -constexpr int32_t HORIZONTAL_ANGLE = 0; +constexpr int32_t CAMERA_ANGLE = 90; } Muxer::~Muxer() @@ -59,7 +58,7 @@ int32_t Muxer::Config(SampleInfo &sampleInfo) int32_t ret = OH_AVMuxer_AddTrack(muxer_, &videoTrackId_, formatVideo); OH_AVFormat_Destroy(formatVideo); formatVideo = nullptr; - OH_AVMuxer_SetRotation(muxer_, sampleInfo.videoHeight > sampleInfo.videoWidth ? VERTICAL_ANGLE : HORIZONTAL_ANGLE); + OH_AVMuxer_SetRotation(muxer_, CAMERA_ANGLE); CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, AVCODEC_SAMPLE_ERR_ERROR, "AddTrack failed"); return AVCODEC_SAMPLE_ERR_OK; } diff --git a/entry/src/main/cpp/capbilities/VideoDecoder.cpp b/entry/src/main/cpp/capbilities/VideoDecoder.cpp index 5ae314b2b83885d4f99394cf4c314beb768c02fe..7cfd1672bfe966c586e7e6ed244fba6bd5a8671c 100644 --- a/entry/src/main/cpp/capbilities/VideoDecoder.cpp +++ b/entry/src/main/cpp/capbilities/VideoDecoder.cpp @@ -20,7 +20,6 @@ namespace { constexpr int LIMIT_LOGD_FREQUENCY = 50; -constexpr int ROTATION_ANGLE = 90; } // namespace VideoDecoder::~VideoDecoder() @@ -55,9 +54,7 @@ int32_t VideoDecoder::Configure(const SampleInfo &sampleInfo) OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, sampleInfo.videoHeight); OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, sampleInfo.frameRate); OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, sampleInfo.pixelFormat); - if (sampleInfo.videoHeight > sampleInfo.videoWidth) { - OH_AVFormat_SetIntValue(format, OH_MD_KEY_ROTATION, sampleInfo.rotation + ROTATION_ANGLE); - } + OH_AVFormat_SetIntValue(format, OH_MD_KEY_ROTATION, sampleInfo.rotation); AVCODEC_SAMPLE_LOGI("====== VideoDecoder config ======"); AVCODEC_SAMPLE_LOGI("%{public}d*%{public}d, %{public}.1ffps", sampleInfo.videoWidth, sampleInfo.videoHeight, diff --git a/entry/src/main/cpp/capbilities/VideoEncoder.cpp b/entry/src/main/cpp/capbilities/VideoEncoder.cpp index 734270237f417964e69cc77d13085d71649c3e86..cd1c5f242d18a4c80b829120fef336e8923d74bb 100644 --- a/entry/src/main/cpp/capbilities/VideoEncoder.cpp +++ b/entry/src/main/cpp/capbilities/VideoEncoder.cpp @@ -18,26 +18,6 @@ #undef LOG_TAG #define LOG_TAG "VideoEncoder" -namespace { - -int32_t ToGraphicPixelFormat(int32_t avPixelFormat, bool isHDRVivid) -{ - if (isHDRVivid) { - return NATIVEBUFFER_PIXEL_FMT_YCBCR_P010; - } - switch (avPixelFormat) { - case AV_PIXEL_FORMAT_RGBA: - return NATIVEBUFFER_PIXEL_FMT_RGBA_8888; - case AV_PIXEL_FORMAT_YUVI420: - return NATIVEBUFFER_PIXEL_FMT_YCBCR_420_P; - case AV_PIXEL_FORMAT_NV21: - return NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP; - default: // NV12 and others - return NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP; - } -} -} // namespace - VideoEncoder::~VideoEncoder() { Release(); @@ -175,18 +155,5 @@ int32_t VideoEncoder::GetSurface(SampleInfo &sampleInfo) int32_t ret = OH_VideoEncoder_GetSurface(encoder_, &sampleInfo.window); CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK && sampleInfo.window, AVCODEC_SAMPLE_ERR_ERROR, "Get surface failed, ret: %{public}d", ret); - (void)OH_NativeWindow_NativeWindowHandleOpt(sampleInfo.window, SET_BUFFER_GEOMETRY, sampleInfo.videoWidth, - sampleInfo.videoHeight); - (void)OH_NativeWindow_NativeWindowHandleOpt(sampleInfo.window, SET_USAGE, 16425); // 16425: Window usage - (void)OH_NativeWindow_NativeWindowHandleOpt(sampleInfo.window, SET_FORMAT, - ToGraphicPixelFormat(sampleInfo.pixelFormat, sampleInfo.isHDRVivid)); - if(sampleInfo.isHDRVivid) { - uint8_t metadataType = OH_VIDEO_HDR_HLG; - (void)OH_NativeWindow_SetMetadataValue(sampleInfo.window, OH_HDR_METADATA_TYPE, sizeof(uint8_t), &metadataType); - (void)OH_NativeWindow_NativeWindowHandleOpt(sampleInfo.window, SET_COLOR_GAMUT, - NATIVEBUFFER_COLOR_GAMUT_BT2020); - OH_NativeBuffer_ColorSpace colorSpace = OH_COLORSPACE_BT2020_HLG_LIMIT; - (void)OH_NativeWindow_SetColorSpace(sampleInfo.window, colorSpace); - } return AVCODEC_SAMPLE_ERR_OK; } \ No newline at end of file diff --git a/entry/src/main/cpp/render/PluginRender.cpp b/entry/src/main/cpp/render/PluginRender.cpp index 6d8a4799e205c131cde944fad39978f66ba7b659..415003d78737082608f786da161d1048ee375ee0 100644 --- a/entry/src/main/cpp/render/PluginRender.cpp +++ b/entry/src/main/cpp/render/PluginRender.cpp @@ -54,6 +54,7 @@ void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window) { if (render->eglCore_->EglContextInit(window, width, height)) { auto context = PluginManager::GetInstance(); context->pluginWindow_ = (OHNativeWindow *)window; + OH_NativeWindow_NativeWindowSetScalingModeV2(context->pluginWindow_, OH_SCALING_MODE_SCALE_FIT_V2); } } }