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 IDENTITY_YUVCOLORSPACE, // maps Y->R, U->G, V->B 39 LASTENUM_YUVCOLORSPACE = IDENTITY_YUVCOLORSPACE // last valid value 40 }; 41 42 YUVInfo() = default; YUVInfo(int width,int height,PlaneConfig config,SubSampling sampling,YUVColorSpace colorSpace)43 YUVInfo(int width, int height, PlaneConfig config, SubSampling sampling, YUVColorSpace colorSpace) 44 : width_(width), height_(height), planeConfig_(config), subSampling_(sampling), yuvColorSpace_(colorSpace) {} 45 ~YUVInfo() = default; 46 GetWidth()47 int GetWidth() const 48 { 49 return width_; 50 } 51 GetHeight()52 int GetHeight() const 53 { 54 return height_; 55 } 56 GetConfig()57 PlaneConfig GetConfig() const 58 { 59 return planeConfig_; 60 } 61 GetSampling()62 SubSampling GetSampling() const 63 { 64 return subSampling_; 65 } 66 GetColorSpace()67 YUVColorSpace GetColorSpace() const 68 { 69 return yuvColorSpace_; 70 } 71 72 private: 73 int width_ = 0; 74 int height_ = 0; 75 PlaneConfig planeConfig_ = PlaneConfig::UNKNOWN; 76 SubSampling subSampling_ = SubSampling::UNKNOWN; 77 YUVColorSpace yuvColorSpace_ = YUVColorSpace::IDENTITY_YUVCOLORSPACE; 78 }; 79 } // namespace Drawing 80 } // namespace Rosen 81 } // namespace OHOS 82 #endif