1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef INTERFACES_INNER_API_VPE_VIDEO_REFRESHRATE_PREDICTION_H 17 #define INTERFACES_INNER_API_VPE_VIDEO_REFRESHRATE_PREDICTION_H 18 19 #include <memory> 20 21 #include "algorithm_errors.h" 22 #include "external_window.h" 23 #include "refbase.h" 24 #include "surface_buffer.h" 25 26 namespace OHOS { 27 namespace Media { 28 namespace VideoProcessingEngine { 29 30 enum MotionVectorType : int32_t { 31 MOTIONVECTOR_TYPE_NONE = 0, 32 MOTIONVECTOR_TYPE_AVC = 1, 33 MOTIONVECTOR_TYPE_HEVC = 2 34 }; 35 36 class __attribute__((visibility("default"))) VideoRefreshRatePrediction { 37 public: 38 /** 39 * @brief Create a VideoRefreshRatePrediction object. 40 * @syscap 41 * @return pointer of the VideoRefreshRatePrediction object. 42 * @since 13 43 */ 44 static std::shared_ptr<VideoRefreshRatePrediction> Create(); 45 46 /** 47 * @brief 硬件LTPO支持校验,调用方检查返回值 48 * @syscap 49 * @return 返回错误码VPEAlgoErrCode 50 * @since 13 51 */ 52 virtual VPEAlgoErrCode CheckVRRSupport(std::string processName) = 0; 53 54 /** 55 * @brief 执行视频可变帧率算法 56 * @syscap 57 * @param input 输入的解码帧,算法将决策的帧率信息写入SurfaceBuffer的ExtraData中 58 * @param videoFps 输入视频帧的帧率 59 * @param codecType 输入视频帧编码格式 MotionVectorType 60 * @return 返回错误码VPEAlgoErrCode 61 * @since 13 62 */ 63 virtual VPEAlgoErrCode Process(const sptr<SurfaceBuffer>& input, int videoFps, int codecType) = 0; 64 protected: 65 virtual ~VideoRefreshRatePrediction() = default; 66 }; 67 68 #ifdef __cplusplus 69 extern "C" { 70 #endif 71 72 using VideoRefreshRatePredictionHandle = void; 73 74 VideoRefreshRatePredictionHandle *VideoRefreshRatePredictionCreate(); 75 void VideoRefreshRatePredictionDestroy(VideoRefreshRatePredictionHandle *handle); 76 int32_t VideoRefreshRatePredictionCheckSupport(VideoRefreshRatePredictionHandle *handle, const char *processName); 77 void VideoRefreshRatePredictionProcess(VideoRefreshRatePredictionHandle *handle, 78 OH_NativeBuffer* inputImageNativeBuffer, int videoFps, int codecType); 79 80 #ifdef __cplusplus 81 } 82 #endif 83 84 } // namespace VideoProcessingEngine 85 } // namespace Media 86 } // namespace OHOS 87 88 #endif // INTERFACES_INNER_API_VPE_VIDEO_REFRESHRATE_PREDICTION_H 89