• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 AVC_ENCODER_CONVERT_H
17 #define AVC_ENCODER_CONVERT_H
18 
19 #include <cstdint>
20 
21 namespace OHOS {
22 namespace MediaAVCodec {
23 namespace Codec {
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 constexpr int32_t RGB_COLINC = 3;
30 constexpr int32_t RGBA_COLINC = 4;
31 
32 typedef enum {
33     RANGE_UNSPECIFIED = 0,
34     RANGE_FULL,
35     RANGE_LIMITED,
36 } COLOR_RANGE;
37 
38 typedef enum {
39     MATRIX_UNSPECIFIED = 0,
40     MATRIX_BT709,
41     MATRIX_FCC47_73_682,
42     MATRIX_BT601,
43     MATRIX_240M,
44     MATRIX_BT2020,
45     MATRIX_BT2020_CONSTANT,
46 } COLOR_MATRIX;
47 
48 struct RgbImageData {
49     uint8_t *data = nullptr;
50     int32_t stride = 0;
51     COLOR_MATRIX matrix = MATRIX_UNSPECIFIED;
52     COLOR_RANGE range = RANGE_UNSPECIFIED;
53     int32_t bytesPerPixel = 0;
54 };
55 
56 struct YuvImageData {
57     uint8_t *data = nullptr;
58     int32_t stride = 0;
59     int32_t uvOffset = 0;
60 };
61 
62 #if defined(ARMV8)
63 int32_t ConvertRgbToNv21Neon(uint8_t *dstData, int32_t width, int32_t height,
64     int32_t bufferSize, RgbImageData &rgbData);
65 #endif
66 
67 int32_t ConvertRgbToNv21(uint8_t *dstData, int32_t width, int32_t height,
68     int32_t bufferSize, RgbImageData &rgbData);
69 
70 int32_t ConvertNv12ToNv21(uint8_t *dstData, int32_t width, int32_t height,
71     int32_t bufferSize, YuvImageData &yuvData);
72 
73 #ifdef __cplusplus
74 };
75 #endif
76 } // namespace Codec
77 } // namespace MediaAVCodec
78 } // namespace OHOS
79 #endif // AVC_ENCODER_CONVERT_H