| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_ | 7 #ifndef CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_ |
| 8 #define CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_ | 8 #define CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_ |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 int32_t GetBPC() const { return m_SrcBPC; } | 57 int32_t GetBPC() const { return m_SrcBPC; } |
| 58 void SetClipBox(FX_RECT* clip); | 58 void SetClipBox(FX_RECT* clip); |
| 59 | 59 |
| 60 FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause = nullptr); | 60 FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause = nullptr); |
| 61 FXCODEC_STATUS StartDecode(CFX_DIBitmap* pDIBitmap, | 61 FXCODEC_STATUS StartDecode(CFX_DIBitmap* pDIBitmap, |
| 62 int start_x, | 62 int start_x, |
| 63 int start_y, | 63 int start_y, |
| 64 int size_x, | 64 int size_x, |
| 65 int size_y, | 65 int size_y, |
| 66 int32_t frames = 0, | 66 int32_t frames = 0, |
| 67 FX_BOOL bInterpol = TRUE); | 67 bool bInterpol = true); |
| 68 | 68 |
| 69 FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = nullptr); | 69 FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = nullptr); |
| 70 | 70 |
| 71 struct PixelWeight { | 71 struct PixelWeight { |
| 72 int m_SrcStart; | 72 int m_SrcStart; |
| 73 int m_SrcEnd; | 73 int m_SrcEnd; |
| 74 int m_Weights[1]; | 74 int m_Weights[1]; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 class CFXCODEC_WeightTable { | 77 class CFXCODEC_WeightTable { |
| 78 public: | 78 public: |
| 79 CFXCODEC_WeightTable(); | 79 CFXCODEC_WeightTable(); |
| 80 ~CFXCODEC_WeightTable(); | 80 ~CFXCODEC_WeightTable(); |
| 81 | 81 |
| 82 void Calc(int dest_len, | 82 void Calc(int dest_len, |
| 83 int dest_min, | 83 int dest_min, |
| 84 int dest_max, | 84 int dest_max, |
| 85 int src_len, | 85 int src_len, |
| 86 int src_min, | 86 int src_min, |
| 87 int src_max, | 87 int src_max, |
| 88 FX_BOOL bInterpol); | 88 bool bInterpol); |
| 89 PixelWeight* GetPixelWeight(int pixel) { | 89 PixelWeight* GetPixelWeight(int pixel) { |
| 90 return reinterpret_cast<PixelWeight*>(m_pWeightTables.data() + | 90 return reinterpret_cast<PixelWeight*>(m_pWeightTables.data() + |
| 91 (pixel - m_DestMin) * m_ItemSize); | 91 (pixel - m_DestMin) * m_ItemSize); |
| 92 } | 92 } |
| 93 | 93 |
| 94 int m_DestMin; | 94 int m_DestMin; |
| 95 int m_ItemSize; | 95 int m_ItemSize; |
| 96 std::vector<uint8_t> m_pWeightTables; | 96 std::vector<uint8_t> m_pWeightTables; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 class CFXCODEC_HorzTable { | 99 class CFXCODEC_HorzTable { |
| 100 public: | 100 public: |
| 101 CFXCODEC_HorzTable(); | 101 CFXCODEC_HorzTable(); |
| 102 ~CFXCODEC_HorzTable(); | 102 ~CFXCODEC_HorzTable(); |
| 103 | 103 |
| 104 void Calc(int dest_len, int src_len, FX_BOOL bInterpol); | 104 void Calc(int dest_len, int src_len, bool bInterpol); |
| 105 PixelWeight* GetPixelWeight(int pixel) { | 105 PixelWeight* GetPixelWeight(int pixel) { |
| 106 return reinterpret_cast<PixelWeight*>(m_pWeightTables.data() + | 106 return reinterpret_cast<PixelWeight*>(m_pWeightTables.data() + |
| 107 pixel * m_ItemSize); | 107 pixel * m_ItemSize); |
| 108 } | 108 } |
| 109 | 109 |
| 110 int m_ItemSize; | 110 int m_ItemSize; |
| 111 std::vector<uint8_t> m_pWeightTables; | 111 std::vector<uint8_t> m_pWeightTables; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 class CFXCODEC_VertTable { | 114 class CFXCODEC_VertTable { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 132 FXGIF_Context* m_pGifContext; | 132 FXGIF_Context* m_pGifContext; |
| 133 FXBMP_Context* m_pBmpContext; | 133 FXBMP_Context* m_pBmpContext; |
| 134 CCodec_TiffContext* m_pTiffContext; | 134 CCodec_TiffContext* m_pTiffContext; |
| 135 FXCODEC_IMAGE_TYPE m_imagType; | 135 FXCODEC_IMAGE_TYPE m_imagType; |
| 136 uint32_t m_offSet; | 136 uint32_t m_offSet; |
| 137 uint8_t* m_pSrcBuf; | 137 uint8_t* m_pSrcBuf; |
| 138 uint32_t m_SrcSize; | 138 uint32_t m_SrcSize; |
| 139 uint8_t* m_pDecodeBuf; | 139 uint8_t* m_pDecodeBuf; |
| 140 int m_ScanlineSize; | 140 int m_ScanlineSize; |
| 141 CFX_DIBitmap* m_pDeviceBitmap; | 141 CFX_DIBitmap* m_pDeviceBitmap; |
| 142 FX_BOOL m_bInterpol; | 142 bool m_bInterpol; |
| 143 CFXCODEC_WeightTable m_WeightHorz; | 143 CFXCODEC_WeightTable m_WeightHorz; |
| 144 CFXCODEC_VertTable m_WeightVert; | 144 CFXCODEC_VertTable m_WeightVert; |
| 145 CFXCODEC_HorzTable m_WeightHorzOO; | 145 CFXCODEC_HorzTable m_WeightHorzOO; |
| 146 int m_SrcWidth; | 146 int m_SrcWidth; |
| 147 int m_SrcHeight; | 147 int m_SrcHeight; |
| 148 int m_SrcComponents; | 148 int m_SrcComponents; |
| 149 int m_SrcBPC; | 149 int m_SrcBPC; |
| 150 FX_RECT m_clipBox; | 150 FX_RECT m_clipBox; |
| 151 int m_startX; | 151 int m_startX; |
| 152 int m_startY; | 152 int m_startY; |
| 153 int m_sizeX; | 153 int m_sizeX; |
| 154 int m_sizeY; | 154 int m_sizeY; |
| 155 int m_TransMethod; | 155 int m_TransMethod; |
| 156 FX_ARGB* m_pSrcPalette; | 156 FX_ARGB* m_pSrcPalette; |
| 157 int m_SrcPaletteNumber; | 157 int m_SrcPaletteNumber; |
| 158 int m_SrcRow; | 158 int m_SrcRow; |
| 159 FXCodec_Format m_SrcFormat; | 159 FXCodec_Format m_SrcFormat; |
| 160 int m_SrcPassNumber; | 160 int m_SrcPassNumber; |
| 161 int m_FrameNumber; | 161 int m_FrameNumber; |
| 162 int m_FrameCur; | 162 int m_FrameCur; |
| 163 int m_GifBgIndex; | 163 int m_GifBgIndex; |
| 164 uint8_t* m_pGifPalette; | 164 uint8_t* m_pGifPalette; |
| 165 int32_t m_GifPltNumber; | 165 int32_t m_GifPltNumber; |
| 166 int m_GifTransIndex; | 166 int m_GifTransIndex; |
| 167 FX_RECT m_GifFrameRect; | 167 FX_RECT m_GifFrameRect; |
| 168 FX_BOOL m_BmpIsTopBottom; | 168 bool m_BmpIsTopBottom; |
| 169 FXCODEC_STATUS m_status; | 169 FXCODEC_STATUS m_status; |
| 170 | 170 |
| 171 protected: | 171 protected: |
| 172 static FX_BOOL PngReadHeaderFunc(void* pModule, | 172 static bool PngReadHeaderFunc(void* pModule, |
| 173 int width, | 173 int width, |
| 174 int height, | 174 int height, |
| 175 int bpc, | 175 int bpc, |
| 176 int pass, | 176 int pass, |
| 177 int* color_type, | 177 int* color_type, |
| 178 double* gamma); | 178 double* gamma); |
| 179 static FX_BOOL PngAskScanlineBufFunc(void* pModule, | 179 static bool PngAskScanlineBufFunc(void* pModule, int line, uint8_t*& src_buf); |
| 180 int line, | |
| 181 uint8_t*& src_buf); | |
| 182 static void PngFillScanlineBufCompletedFunc(void* pModule, | 180 static void PngFillScanlineBufCompletedFunc(void* pModule, |
| 183 int pass, | 181 int pass, |
| 184 int line); | 182 int line); |
| 185 static void GifRecordCurrentPositionCallback(void* pModule, | 183 static void GifRecordCurrentPositionCallback(void* pModule, |
| 186 uint32_t& cur_pos); | 184 uint32_t& cur_pos); |
| 187 static uint8_t* GifAskLocalPaletteBufCallback(void* pModule, | 185 static uint8_t* GifAskLocalPaletteBufCallback(void* pModule, |
| 188 int32_t frame_num, | 186 int32_t frame_num, |
| 189 int32_t pal_size); | 187 int32_t pal_size); |
| 190 static FX_BOOL GifInputRecordPositionBufCallback(void* pModule, | 188 static bool GifInputRecordPositionBufCallback(void* pModule, |
| 191 uint32_t rcd_pos, | 189 uint32_t rcd_pos, |
| 192 const FX_RECT& img_rc, | 190 const FX_RECT& img_rc, |
| 193 int32_t pal_num, | 191 int32_t pal_num, |
| 194 void* pal_ptr, | 192 void* pal_ptr, |
| 195 int32_t delay_time, | 193 int32_t delay_time, |
| 196 FX_BOOL user_input, | 194 bool user_input, |
| 197 int32_t trans_index, | 195 int32_t trans_index, |
| 198 int32_t disposal_method, | 196 int32_t disposal_method, |
| 199 FX_BOOL interlace); | 197 bool interlace); |
| 200 static void GifReadScanlineCallback(void* pModule, | 198 static void GifReadScanlineCallback(void* pModule, |
| 201 int32_t row_num, | 199 int32_t row_num, |
| 202 uint8_t* row_buf); | 200 uint8_t* row_buf); |
| 203 static FX_BOOL BmpInputImagePositionBufCallback(void* pModule, | 201 static bool BmpInputImagePositionBufCallback(void* pModule, uint32_t rcd_pos); |
| 204 uint32_t rcd_pos); | |
| 205 static void BmpReadScanlineCallback(void* pModule, | 202 static void BmpReadScanlineCallback(void* pModule, |
| 206 int32_t row_num, | 203 int32_t row_num, |
| 207 uint8_t* row_buf); | 204 uint8_t* row_buf); |
| 208 | 205 |
| 209 FX_BOOL DetectImageType(FXCODEC_IMAGE_TYPE imageType, | 206 bool DetectImageType(FXCODEC_IMAGE_TYPE imageType, |
| 210 CFX_DIBAttribute* pAttribute); | 207 CFX_DIBAttribute* pAttribute); |
| 211 void GetDownScale(int& down_scale); | 208 void GetDownScale(int& down_scale); |
| 212 void GetTransMethod(FXDIB_Format des_format, FXCodec_Format src_format); | 209 void GetTransMethod(FXDIB_Format des_format, FXCodec_Format src_format); |
| 213 void ReSampleScanline(CFX_DIBitmap* pDeviceBitmap, | 210 void ReSampleScanline(CFX_DIBitmap* pDeviceBitmap, |
| 214 int32_t des_line, | 211 int32_t des_line, |
| 215 uint8_t* src_scan, | 212 uint8_t* src_scan, |
| 216 FXCodec_Format src_format); | 213 FXCodec_Format src_format); |
| 217 void Resample(CFX_DIBitmap* pDeviceBitmap, | 214 void Resample(CFX_DIBitmap* pDeviceBitmap, |
| 218 int32_t src_line, | 215 int32_t src_line, |
| 219 uint8_t* src_scan, | 216 uint8_t* src_scan, |
| 220 FXCodec_Format src_format); | 217 FXCodec_Format src_format); |
| 221 void ResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); | 218 void ResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); |
| 222 FX_BOOL JpegReadMoreData(CCodec_JpegModule* pJpegModule, | 219 bool JpegReadMoreData(CCodec_JpegModule* pJpegModule, |
| 223 FXCODEC_STATUS& err_status); | 220 FXCODEC_STATUS& err_status); |
| 224 void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap, | 221 void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap, |
| 225 int32_t des_line, | 222 int32_t des_line, |
| 226 uint8_t* src_scan, | 223 uint8_t* src_scan, |
| 227 FXCodec_Format src_format); | 224 FXCodec_Format src_format); |
| 228 FX_BOOL GifReadMoreData(CCodec_GifModule* pGifModule, | 225 bool GifReadMoreData(CCodec_GifModule* pGifModule, |
| 229 FXCODEC_STATUS& err_status); | 226 FXCODEC_STATUS& err_status); |
| 230 void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap, | 227 void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap, |
| 231 double scale_y, | 228 double scale_y, |
| 232 int des_row); | 229 int des_row); |
| 233 FX_BOOL BmpReadMoreData(CCodec_BmpModule* pBmpModule, | 230 bool BmpReadMoreData(CCodec_BmpModule* pBmpModule, |
| 234 FXCODEC_STATUS& err_status); | 231 FXCODEC_STATUS& err_status); |
| 235 void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); | 232 void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); |
| 236 }; | 233 }; |
| 237 | 234 |
| 238 #endif // CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_ | 235 #endif // CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_ |
| OLD | NEW |