|
|
@ -90,12 +90,14 @@ static unsigned int get32(uint8_t **b){ |
|
|
|
return ((*b)[-4]<<24) + ((*b)[-3]<<16) + ((*b)[-2]<<8) + (*b)[-1]; |
|
|
|
return ((*b)[-4]<<24) + ((*b)[-3]<<16) + ((*b)[-2]<<8) + (*b)[-1]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ENCODERS |
|
|
|
static void put32(uint8_t **b, unsigned int v){ |
|
|
|
static void put32(uint8_t **b, unsigned int v){ |
|
|
|
*(*b)++= v>>24; |
|
|
|
*(*b)++= v>>24; |
|
|
|
*(*b)++= v>>16; |
|
|
|
*(*b)++= v>>16; |
|
|
|
*(*b)++= v>>8; |
|
|
|
*(*b)++= v>>8; |
|
|
|
*(*b)++= v; |
|
|
|
*(*b)++= v; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static const uint8_t pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; |
|
|
|
static const uint8_t pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; |
|
|
|
|
|
|
|
|
|
|
@ -233,6 +235,7 @@ static void png_put_interlaced_row(uint8_t *dst, int width, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ENCODERS |
|
|
|
static void png_get_interlaced_row(uint8_t *dst, int row_size, |
|
|
|
static void png_get_interlaced_row(uint8_t *dst, int row_size, |
|
|
|
int bits_per_pixel, int pass, |
|
|
|
int bits_per_pixel, int pass, |
|
|
|
const uint8_t *src, int width) |
|
|
|
const uint8_t *src, int width) |
|
|
@ -270,6 +273,7 @@ static void png_get_interlaced_row(uint8_t *dst, int row_size, |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/* XXX: optimize */ |
|
|
|
/* XXX: optimize */ |
|
|
|
/* NOTE: 'dst' can be equal to 'last' */ |
|
|
|
/* NOTE: 'dst' can be equal to 'last' */ |
|
|
@ -338,6 +342,7 @@ static void png_filter_row(uint8_t *dst, int filter_type, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ENCODERS |
|
|
|
static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width) |
|
|
|
static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t *d; |
|
|
|
uint8_t *d; |
|
|
@ -354,7 +359,9 @@ static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width) |
|
|
|
d += 4; |
|
|
|
d += 4; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_DECODERS |
|
|
|
static void convert_to_rgba32(uint8_t *dst, const uint8_t *src, int width) |
|
|
|
static void convert_to_rgba32(uint8_t *dst, const uint8_t *src, int width) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int j; |
|
|
|
int j; |
|
|
@ -684,7 +691,9 @@ static int decode_frame(AVCodecContext *avctx, |
|
|
|
ret = -1; |
|
|
|
ret = -1; |
|
|
|
goto the_end; |
|
|
|
goto the_end; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ENCODERS |
|
|
|
static void png_write_chunk(uint8_t **f, uint32_t tag, |
|
|
|
static void png_write_chunk(uint8_t **f, uint32_t tag, |
|
|
|
const uint8_t *buf, int length) |
|
|
|
const uint8_t *buf, int length) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -736,6 +745,7 @@ static int png_write_row(PNGContext *s, const uint8_t *data, int size) |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif /* CONFIG_ENCODERS */ |
|
|
|
|
|
|
|
|
|
|
|
static int common_init(AVCodecContext *avctx){ |
|
|
|
static int common_init(AVCodecContext *avctx){ |
|
|
|
PNGContext *s = avctx->priv_data; |
|
|
|
PNGContext *s = avctx->priv_data; |
|
|
@ -747,6 +757,7 @@ static int common_init(AVCodecContext *avctx){ |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ENCODERS |
|
|
|
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ |
|
|
|
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ |
|
|
|
PNGContext *s = avctx->priv_data; |
|
|
|
PNGContext *s = avctx->priv_data; |
|
|
|
AVFrame *pict = data; |
|
|
|
AVFrame *pict = data; |
|
|
@ -920,7 +931,9 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, |
|
|
|
ret = -1; |
|
|
|
ret = -1; |
|
|
|
goto the_end; |
|
|
|
goto the_end; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_PNG_DECODER |
|
|
|
AVCodec png_decoder = { |
|
|
|
AVCodec png_decoder = { |
|
|
|
"png", |
|
|
|
"png", |
|
|
|
CODEC_TYPE_VIDEO, |
|
|
|
CODEC_TYPE_VIDEO, |
|
|
@ -933,6 +946,7 @@ AVCodec png_decoder = { |
|
|
|
0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/, |
|
|
|
0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/, |
|
|
|
NULL |
|
|
|
NULL |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_PNG_ENCODER |
|
|
|
#ifdef CONFIG_PNG_ENCODER |
|
|
|
AVCodec png_encoder = { |
|
|
|
AVCodec png_encoder = { |
|
|
|