From c4a5ae9891dccb06cc70656e8cd7747bb9973b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B5=E4=BF=8A=E6=9D=B0?= Date: Tue, 29 Apr 2025 07:55:15 +0000 Subject: [PATCH 1/2] add setspeed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邵俊杰 --- .../filters/decoder_surface_filter.cpp | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/services/media_engine/filters/decoder_surface_filter.cpp b/services/media_engine/filters/decoder_surface_filter.cpp index e13d25a01..667347fe1 100644 --- a/services/media_engine/filters/decoder_surface_filter.cpp +++ b/services/media_engine/filters/decoder_surface_filter.cpp @@ -48,6 +48,7 @@ static const uint32_t TASK_DELAY_TOLERANCE = 5 * 1000 * 1000; // task delay tole static const int64_t MAX_DEBUG_LOG = 10; static const int32_t MAX_ADVANCE_US = 80000; // max advance us at render time static const int64_t OVERTIME_WARNING_MS = 50; +static const double DEFAULT_FRAME_RATE = 30.0; // 30.0 is the hisi default frame rate. static AutoRegisterFilter g_registerDecoderSurfaceFilter("builtin.player.videodecoder", FilterType::FILTERTYPE_VDEC, [](const std::string& name, const FilterType type) { @@ -629,7 +630,7 @@ void DecoderSurfaceFilter::SetParameter(const std::shared_ptr ¶meter) } } if (rate <= 0) { - rate = 30.0; // 30.0 is the hisi default frame rate. + rate = DEFAULT_FRAME_RATE; } format.PutDoubleValue(Tag::VIDEO_FRAME_RATE, rate); } @@ -1361,6 +1362,25 @@ Status DecoderSurfaceFilter::SetVideoWindowSize(int32_t width, int32_t height) return postProcessor_->SetVideoWindowSize(width, height); } + +Status DecoderSurfaceFilter::SetSpeed(float speed) +{ + FALSE_RETURN_V(videoDecoder_ != nullptr, Status::ERROR_INVALID_OPERATION); + MEDIA_LOG_D("SetSpeed in"); + double frameRate = 0.0; + configFormat_.GetDoubleValue(Tag::VIDEO_FRAME_RATE, frameRate); + if (frameRate <= 0) { + frameRate = DEFAULT_FRAME_RATE; + } + double frameRateWithSpeed = speed >= 1.0 ? frameRate * speed : frameRate; + MEDIA_LOG_I("frameRate: %{public}f, speed: %{public}f, frameRateWithSpeed: %{public}f", + frameRate, speed, frameRateWithSpeed); + + Format format; + format.PutDoubleValue(Tag::VIDEO_FRAME_RATE, frameRateWithSpeed); + videoDecoder_->SetParameter(format); + return Status::OK; +} } // namespace Pipeline } // namespace MEDIA } // namespace OHOS -- Gitee From cf72dbc2881142b06a1b990ad6cdff8b58df847a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B5=E4=BF=8A=E6=9D=B0?= Date: Tue, 29 Apr 2025 08:52:55 +0000 Subject: [PATCH 2/2] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邵俊杰 --- interfaces/inner_api/native/decoder_surface_filter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/inner_api/native/decoder_surface_filter.h b/interfaces/inner_api/native/decoder_surface_filter.h index 6b4c9c490..5cac71ea2 100644 --- a/interfaces/inner_api/native/decoder_surface_filter.h +++ b/interfaces/inner_api/native/decoder_surface_filter.h @@ -116,6 +116,7 @@ public: Status SetPostProcessorOn(bool isSuperResolutionOn); Status SetVideoWindowSize(int32_t width, int32_t height); void NotifyAudioComplete(); + Status SetSpeed(float speed); protected: Status OnLinked(StreamType inType, const std::shared_ptr &meta, -- Gitee