00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVCODEC_PNG_H
00023 #define AVCODEC_PNG_H
00024
00025 #include <stdint.h>
00026 #include <zlib.h>
00027
00028 #include "avcodec.h"
00029
00030 #define PNG_COLOR_MASK_PALETTE 1
00031 #define PNG_COLOR_MASK_COLOR 2
00032 #define PNG_COLOR_MASK_ALPHA 4
00033
00034 #define PNG_COLOR_TYPE_GRAY 0
00035 #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
00036 #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
00037 #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
00038 #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
00039
00040 #define PNG_FILTER_TYPE_LOCO 64
00041 #define PNG_FILTER_VALUE_NONE 0
00042 #define PNG_FILTER_VALUE_SUB 1
00043 #define PNG_FILTER_VALUE_UP 2
00044 #define PNG_FILTER_VALUE_AVG 3
00045 #define PNG_FILTER_VALUE_PAETH 4
00046 #define PNG_FILTER_VALUE_MIXED 5
00047
00048 #define PNG_IHDR 0x0001
00049 #define PNG_IDAT 0x0002
00050 #define PNG_ALLIMAGE 0x0004
00051 #define PNG_PLTE 0x0008
00052
00053 #define NB_PASSES 7
00054
00055 extern const uint8_t ff_pngsig[8];
00056 extern const uint8_t ff_mngsig[8];
00057
00058
00059 extern const uint8_t ff_png_pass_ymask[NB_PASSES];
00060
00061
00062 extern const uint8_t ff_png_pass_mask[NB_PASSES];
00063
00064 void *ff_png_zalloc(void *opaque, unsigned int items, unsigned int size);
00065
00066 void ff_png_zfree(void *opaque, void *ptr);
00067
00068 int ff_png_get_nb_channels(int color_type);
00069
00070
00071 int ff_png_pass_row_size(int pass, int bits_per_pixel, int width);
00072
00073 void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
00074
00075 typedef struct PNGDecContext {
00076 const uint8_t *bytestream;
00077 const uint8_t *bytestream_start;
00078 const uint8_t *bytestream_end;
00079 AVFrame picture1, picture2;
00080 AVFrame *current_picture, *last_picture;
00081
00082 int state;
00083 int width, height;
00084 int bit_depth;
00085 int color_type;
00086 int compression_type;
00087 int interlace_type;
00088 int filter_type;
00089 int channels;
00090 int bits_per_pixel;
00091 int bpp;
00092
00093 uint8_t *image_buf;
00094 int image_linesize;
00095 uint32_t palette[256];
00096 uint8_t *crow_buf;
00097 uint8_t *last_row;
00098 uint8_t *tmp_row;
00099 int pass;
00100 int crow_size;
00101 int row_size;
00102 int pass_row_size;
00103 int y;
00104 z_stream zstream;
00105
00106 void (*add_bytes_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w);
00107 void (*add_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
00108 } PNGDecContext;
00109
00110 void ff_png_init_mmx(PNGDecContext *s);
00111
00112 #endif