1 /* 2 * Copyright (C) 2021 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_CONVERTER_INCLUDE_SCAN_LINE_FILTER_H 17 #define FRAMEWORKS_INNERKITSIMPL_CONVERTER_INCLUDE_SCAN_LINE_FILTER_H 18 19 #include "image_type.h" 20 #include "pixel_convert.h" 21 22 namespace OHOS { 23 namespace Media { 24 enum class FilterRowType : int32_t { NON_REFERENCE_ROW = 0, NORMAL_REFERENCE_ROW = 1, LAST_REFERENCE_ROW = 2 }; 25 class ScanlineFilter { 26 public: 27 ScanlineFilter() = default; 28 ScanlineFilter(const ScanlineFilter &) = delete; 29 ScanlineFilter &operator=(const ScanlineFilter &) = delete; 30 explicit ScanlineFilter(const PixelFormat &srcPixelFormat); 31 ~ScanlineFilter() = default; 32 FilterRowType GetFilterRowType(const int32_t rowNum); 33 void SetSrcPixelFormat(const PixelFormat &srcPixelFormat); 34 void SetSrcRegion(const Rect ®ion); 35 void SetPixelConvert(const ImageInfo &srcImageInfo, const ImageInfo &dstImageInfo); 36 uint32_t FilterLine(void *destRowPixels, uint32_t destRowBytes, const void *srcRowPixels); 37 38 private: 39 bool ConvertPixels(void *destRowPixels, const uint8_t *startPixel, uint32_t reqPixelNum); 40 int32_t srcBpp_ = 0; // Bytes per pixel of source image. 41 Rect srcRegion_; 42 std::unique_ptr<PixelConvert> pixelConverter_ = nullptr; 43 bool needPixelConvert_ = false; 44 }; 45 } // namespace Media 46 } // namespace OHOS 47 48 #endif // FRAMEWORKS_INNERKITSIMPL_CONVERTER_INCLUDE_SCAN_LINE_FILTER_H 49