1 /* 2 * Copyright 2021, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Emmanuel Gil Peyrot 7 */ 8 #ifndef AVIF_TRANSLATOR_H 9 #define AVIF_TRANSLATOR_H 10 11 12 #include <ByteOrder.h> 13 #include <DataIO.h> 14 #include <File.h> 15 #include <fs_attr.h> 16 #include <GraphicsDefs.h> 17 #include <InterfaceDefs.h> 18 #include <TranslationDefs.h> 19 #include <Translator.h> 20 #include <TranslatorFormats.h> 21 22 #include "BaseTranslator.h" 23 24 #define AVIF_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(0,1,0) 25 #define AVIF_IMAGE_FORMAT 'AVIF' 26 27 #define AVIF_SETTING_LOSSLESS "lossless" 28 #define AVIF_SETTING_PIXEL_FORMAT "pixfmt" 29 #define AVIF_SETTING_QUALITY "quality" 30 #define AVIF_SETTING_SPEED "speed" 31 #define AVIF_SETTING_TILES_HORIZONTAL "htiles" 32 #define AVIF_SETTING_TILES_VERTICAL "vtiles" 33 34 35 #define AVIF_IN_QUALITY 0.90 36 #define AVIF_IN_CAPABILITY 0.90 37 38 #define AVIF_OUT_QUALITY 0.90 39 #define AVIF_OUT_CAPABILITY 0.5 40 41 #define BITS_IN_QUALITY 0.8 42 #define BITS_IN_CAPABILITY 0.6 43 44 #define BITS_OUT_QUALITY 0.5 45 #define BITS_OUT_CAPABILITY 0.4 46 47 48 struct AVIFPicture; 49 50 51 class AVIFTranslator : public BaseTranslator { 52 public: 53 AVIFTranslator(); 54 55 virtual status_t DerivedIdentify(BPositionIO* stream, 56 const translation_format* format, 57 BMessage* settings, translator_info* info, 58 uint32 outType); 59 60 virtual status_t DerivedTranslate(BPositionIO* stream, 61 const translator_info* info, 62 BMessage* settings, uint32 outType, 63 BPositionIO* target, int32 baseType); 64 65 virtual BView* NewConfigView(TranslatorSettings* settings); 66 67 protected: 68 virtual ~AVIFTranslator(); 69 // this is protected because the object is deleted by the 70 // Release() function instead of being deleted directly by 71 // the user 72 73 private: 74 status_t _TranslateFromBits(BPositionIO* stream, 75 BMessage* settings, uint32 outType, 76 BPositionIO* target); 77 78 status_t _TranslateFromAVIF(BPositionIO* stream, 79 BMessage* settings, uint32 outType, 80 BPositionIO* target); 81 }; 82 83 84 #endif // #ifndef AVIF_TRANSLATOR_H 85