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 YUV_INFO_H 17 #define YUV_INFO_H 18 19 namespace OHOS { 20 namespace Rosen { 21 namespace Drawing { 22 23 class YUVInfo { 24 public: 25 enum class PlaneConfig { 26 UNKNOWN, 27 Y_UV, // Plane 0: Y, Plane 1: UV 28 Y_VU, // Plane 0: Y, Plane 1: VU 29 }; 30 31 enum class SubSampling { 32 UNKNOWN, 33 K420, // 1 set of UV values for each 2x2 block of Y values. 34 }; 35 36 enum YUVColorSpace : int { 37 JPEG_FULL_YUVCOLORSPACE, // describes full range 38 BT2020_10BIT_LIMITED_YUVCOLORSPACE, 39 IDENTITY_YUVCOLORSPACE, // maps Y->R, U->G, V->B 40 LASTENUM_YUVCOLORSPACE = IDENTITY_YUVCOLORSPACE // last valid value 41 }; 42 43 enum class YUVDataType { 44 UNORM_8, 45 UNORM_16, 46 }; 47 48 YUVInfo() = default; YUVInfo(int width, int height, PlaneConfig config, SubSampling sampling, YUVColorSpace colorSpace, YUVDataType type)49 YUVInfo(int width, int height, PlaneConfig config, SubSampling sampling, YUVColorSpace colorSpace, YUVDataType type) 50 : width_(width), height_(height), planeConfig_(config), subSampling_(sampling), 51 yuvColorSpace_(colorSpace), type_(type) {} 52 ~YUVInfo() = default; 53 GetWidth() const54 int GetWidth() const 55 { 56 return width_; 57 } 58 GetHeight() const59 int GetHeight() const 60 { 61 return height_; 62 } 63 GetConfig() const64 PlaneConfig GetConfig() const 65 { 66 return planeConfig_; 67 } 68 GetSampling() const69 SubSampling GetSampling() const 70 { 71 return subSampling_; 72 } 73 GetColorSpace() const74 YUVColorSpace GetColorSpace() const 75 { 76 return yuvColorSpace_; 77 } 78 GetDataType() const79 YUVDataType GetDataType() const 80 { 81 return type_; 82 } 83 84 private: 85 int width_ = 0; 86 int height_ = 0; 87 PlaneConfig planeConfig_ = PlaneConfig::UNKNOWN; 88 SubSampling subSampling_ = SubSampling::UNKNOWN; 89 YUVColorSpace yuvColorSpace_ = YUVColorSpace::IDENTITY_YUVCOLORSPACE; 90 YUVDataType type_ = YUVDataType::UNORM_8; 91 }; 92 } // namespace Drawing 93 } // namespace Rosen 94 } // namespace OHOS 95 #endif