1 /* 2 * Copyright (C) 2023 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 PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_TEXTURE_ENCODE_ASTC_ENCODE_H 17 #define PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_TEXTURE_ENCODE_ASTC_ENCODE_H 18 #include "abs_image_encoder.h" 19 #include "texture_type.h" 20 21 namespace OHOS { 22 namespace ImagePlugin { 23 class AstcCodec { 24 public: AstcCodec()25 AstcCodec() {}; ~AstcCodec()26 ~AstcCodec() {}; 27 uint32_t SetAstcEncode(OutputDataStream* outputStream, PlEncodeOptions &option, Media::PixelMap* pixelMap); 28 uint32_t ASTCEncode(); 29 uint32_t AstcSoftwareEncode(TextureEncodeOptions ¶m, bool enableQualityCheck, 30 int32_t blocksNum, uint8_t *outBuffer, int32_t outSize); 31 static bool AstcSoftwareEncodeCore(TextureEncodeOptions ¶m, uint8_t *pixmapIn, uint8_t *astcBuffer); 32 #ifdef ENABLE_ASTC_ENCODE_BASED_GPU 33 static bool TryAstcEncBasedOnCl(TextureEncodeOptions ¶m, uint8_t *inData, 34 uint8_t *buffer, const std::string &clBinPath); 35 #endif 36 #ifdef SUT_ENCODE_ENABLE 37 static bool TryTextureSuperCompress(TextureEncodeOptions ¶m, uint8_t *astcBuffer); 38 #endif 39 bool InitAstcExtendInfo(AstcExtendInfo &extendInfo); 40 void ReleaseExtendInfoMemory(AstcExtendInfo &extendInfo); 41 void WriteAstcExtendInfo(uint8_t* outBuffer, uint32_t offset, AstcExtendInfo &extendInfo); 42 private: 43 DISALLOW_COPY_AND_MOVE(AstcCodec); 44 OutputDataStream* astcOutput_ = nullptr; 45 PlEncodeOptions astcOpts_; 46 Media::PixelMap* astcPixelMap_ = nullptr; 47 }; 48 } // namespace ImagePlugin 49 } // namespace OHOS 50 #endif // PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_TEXTURE_ENCODE_ASTC_ENCODE_H