Mercurial > libavcodec.hg
comparison png.c @ 3777:20545fbb6f7c libavcodec
add some #ifdef CONFIG_ENCODERS/DECODERS
author | mru |
---|---|
date | Wed, 27 Sep 2006 19:54:07 +0000 |
parents | 82277c821113 |
children | c8c591fe26f8 |
comparison
equal
deleted
inserted
replaced
3776:1843a85123b7 | 3777:20545fbb6f7c |
---|---|
88 static unsigned int get32(uint8_t **b){ | 88 static unsigned int get32(uint8_t **b){ |
89 (*b) += 4; | 89 (*b) += 4; |
90 return ((*b)[-4]<<24) + ((*b)[-3]<<16) + ((*b)[-2]<<8) + (*b)[-1]; | 90 return ((*b)[-4]<<24) + ((*b)[-3]<<16) + ((*b)[-2]<<8) + (*b)[-1]; |
91 } | 91 } |
92 | 92 |
93 #ifdef CONFIG_ENCODERS | |
93 static void put32(uint8_t **b, unsigned int v){ | 94 static void put32(uint8_t **b, unsigned int v){ |
94 *(*b)++= v>>24; | 95 *(*b)++= v>>24; |
95 *(*b)++= v>>16; | 96 *(*b)++= v>>16; |
96 *(*b)++= v>>8; | 97 *(*b)++= v>>8; |
97 *(*b)++= v; | 98 *(*b)++= v; |
98 } | 99 } |
100 #endif | |
99 | 101 |
100 static const uint8_t pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; | 102 static const uint8_t pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; |
101 | 103 |
102 /* Mask to determine which y pixels are valid in a pass */ | 104 /* Mask to determine which y pixels are valid in a pass */ |
103 static const uint8_t png_pass_ymask[NB_PASSES] = { | 105 static const uint8_t png_pass_ymask[NB_PASSES] = { |
231 } | 233 } |
232 break; | 234 break; |
233 } | 235 } |
234 } | 236 } |
235 | 237 |
238 #ifdef CONFIG_ENCODERS | |
236 static void png_get_interlaced_row(uint8_t *dst, int row_size, | 239 static void png_get_interlaced_row(uint8_t *dst, int row_size, |
237 int bits_per_pixel, int pass, | 240 int bits_per_pixel, int pass, |
238 const uint8_t *src, int width) | 241 const uint8_t *src, int width) |
239 { | 242 { |
240 int x, mask, dst_x, j, b, bpp; | 243 int x, mask, dst_x, j, b, bpp; |
268 s += bpp; | 271 s += bpp; |
269 } | 272 } |
270 break; | 273 break; |
271 } | 274 } |
272 } | 275 } |
276 #endif | |
273 | 277 |
274 /* XXX: optimize */ | 278 /* XXX: optimize */ |
275 /* NOTE: 'dst' can be equal to 'last' */ | 279 /* NOTE: 'dst' can be equal to 'last' */ |
276 static void png_filter_row(uint8_t *dst, int filter_type, | 280 static void png_filter_row(uint8_t *dst, int filter_type, |
277 uint8_t *src, uint8_t *last, int size, int bpp) | 281 uint8_t *src, uint8_t *last, int size, int bpp) |
336 } | 340 } |
337 break; | 341 break; |
338 } | 342 } |
339 } | 343 } |
340 | 344 |
345 #ifdef CONFIG_ENCODERS | |
341 static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width) | 346 static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width) |
342 { | 347 { |
343 uint8_t *d; | 348 uint8_t *d; |
344 int j; | 349 int j; |
345 unsigned int v; | 350 unsigned int v; |
352 d[2] = v; | 357 d[2] = v; |
353 d[3] = v >> 24; | 358 d[3] = v >> 24; |
354 d += 4; | 359 d += 4; |
355 } | 360 } |
356 } | 361 } |
357 | 362 #endif |
363 | |
364 #ifdef CONFIG_DECODERS | |
358 static void convert_to_rgba32(uint8_t *dst, const uint8_t *src, int width) | 365 static void convert_to_rgba32(uint8_t *dst, const uint8_t *src, int width) |
359 { | 366 { |
360 int j; | 367 int j; |
361 unsigned int r, g, b, a; | 368 unsigned int r, g, b, a; |
362 | 369 |
682 return ret; | 689 return ret; |
683 fail: | 690 fail: |
684 ret = -1; | 691 ret = -1; |
685 goto the_end; | 692 goto the_end; |
686 } | 693 } |
687 | 694 #endif |
695 | |
696 #ifdef CONFIG_ENCODERS | |
688 static void png_write_chunk(uint8_t **f, uint32_t tag, | 697 static void png_write_chunk(uint8_t **f, uint32_t tag, |
689 const uint8_t *buf, int length) | 698 const uint8_t *buf, int length) |
690 { | 699 { |
691 uint32_t crc; | 700 uint32_t crc; |
692 uint8_t tagbuf[4]; | 701 uint8_t tagbuf[4]; |
734 s->zstream.next_out = s->buf; | 743 s->zstream.next_out = s->buf; |
735 } | 744 } |
736 } | 745 } |
737 return 0; | 746 return 0; |
738 } | 747 } |
748 #endif /* CONFIG_ENCODERS */ | |
739 | 749 |
740 static int common_init(AVCodecContext *avctx){ | 750 static int common_init(AVCodecContext *avctx){ |
741 PNGContext *s = avctx->priv_data; | 751 PNGContext *s = avctx->priv_data; |
742 | 752 |
743 avcodec_get_frame_defaults((AVFrame*)&s->picture); | 753 avcodec_get_frame_defaults((AVFrame*)&s->picture); |
745 // s->avctx= avctx; | 755 // s->avctx= avctx; |
746 | 756 |
747 return 0; | 757 return 0; |
748 } | 758 } |
749 | 759 |
760 #ifdef CONFIG_ENCODERS | |
750 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ | 761 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ |
751 PNGContext *s = avctx->priv_data; | 762 PNGContext *s = avctx->priv_data; |
752 AVFrame *pict = data; | 763 AVFrame *pict = data; |
753 AVFrame * const p= (AVFrame*)&s->picture; | 764 AVFrame * const p= (AVFrame*)&s->picture; |
754 int bit_depth, color_type, y, len, row_size, ret, is_progressive; | 765 int bit_depth, color_type, y, len, row_size, ret, is_progressive; |
918 return ret; | 929 return ret; |
919 fail: | 930 fail: |
920 ret = -1; | 931 ret = -1; |
921 goto the_end; | 932 goto the_end; |
922 } | 933 } |
923 | 934 #endif |
935 | |
936 #ifdef CONFIG_PNG_DECODER | |
924 AVCodec png_decoder = { | 937 AVCodec png_decoder = { |
925 "png", | 938 "png", |
926 CODEC_TYPE_VIDEO, | 939 CODEC_TYPE_VIDEO, |
927 CODEC_ID_PNG, | 940 CODEC_ID_PNG, |
928 sizeof(PNGContext), | 941 sizeof(PNGContext), |
931 NULL, //decode_end, | 944 NULL, //decode_end, |
932 decode_frame, | 945 decode_frame, |
933 0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/, | 946 0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/, |
934 NULL | 947 NULL |
935 }; | 948 }; |
949 #endif | |
936 | 950 |
937 #ifdef CONFIG_PNG_ENCODER | 951 #ifdef CONFIG_PNG_ENCODER |
938 AVCodec png_encoder = { | 952 AVCodec png_encoder = { |
939 "png", | 953 "png", |
940 CODEC_TYPE_VIDEO, | 954 CODEC_TYPE_VIDEO, |