• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_PIXEL_YUV_EXT_UTILS_H
17 #define FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_PIXEL_YUV_EXT_UTILS_H
18 
19 #include <cstdlib>
20 #include <cstdio>
21 #include <string>
22 #include "image_type.h"
23 #include "iosfwd"
24 
25 #include "image_convert_tools.h"
26 #include "image_converter.h"
27 #include "pixel_yuv_utils.h"
28 
29 namespace OHOS {
30 namespace Media {
31 enum YuvSizeType {
32     FLOAT,
33     INT,
34 };
35 
36 struct YuvPixels {
37     uint8_t *srcPixels;
38     uint8_t *dstPixels;
39     float xAxis;
40     float yAxis;
41     int32_t dstWidth;
42     int32_t dstHeight;
43     YuvSizeType sizeType = YuvSizeType::FLOAT;
44 };
45 
46 class PixelYuvExtUtils {
47 public:
48     static bool BGRAToYuv420(const uint8_t *src, uint8_t *dst, int srcW, int srcH,
49         PixelFormat pixelFormat, YUVDataInfo &yuvDataInfo);
50     static bool Yuv420ToBGRA(const uint8_t *sample, uint8_t *dst_argb, Size &size,
51         PixelFormat pixelFormat, YUVDataInfo &info);
52     static bool Yuv420ToARGB(const uint8_t *sample, uint8_t *dst_argb, Size &size,
53         PixelFormat pixelFormat, YUVDataInfo &info);
54     static bool YuvRotate(uint8_t* srcPixels, const PixelFormat& format, YUVDataInfo& info, Size& dstSize,
55         uint8_t* dstPixels, YUVStrideInfo& dstStrides, OpenSourceLibyuv::RotationMode &rotateNum);
56     static void ConvertYuvMode(OpenSourceLibyuv ::FilterMode &filterMode, const AntiAliasingOption &option);
57     static void ScaleYuv420(float xAxis, float yAxis, const AntiAliasingOption &option,
58         YuvImageInfo &yuvInfo, uint8_t *src, uint8_t *dst, YUVStrideInfo &dstStrides);
59     static void ScaleYuv420(int32_t dstWidth, int32_t dstHeight, const AntiAliasingOption &option,
60         YuvImageInfo &yuvInfo, uint8_t *src, uint8_t *dst, YUVStrideInfo &dstStrides);
61     static bool Mirror(uint8_t *src, uint8_t *dst, Size &size, PixelFormat format, YUVDataInfo &info,
62         YUVStrideInfo &dstStrides, bool isReversed);
63     static bool FlipXaxis(uint8_t *src, uint8_t *dst, Size &size, PixelFormat format, YUVDataInfo &info,
64         YUVStrideInfo &dstStrides);
65     static bool NV12Rotate(uint8_t *src, PixelSize &size, YUVDataInfo &info,
66         OpenSourceLibyuv::RotationMode &rotateNum, uint8_t* dst, YUVStrideInfo &dstStrides);
67 };
68 } // namespace Media
69 } // namespace OHOS
70 #endif // RAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_PIXEL_YUV_EXT_UTILS_H