Mercurial > libavcodec.hg
comparison huffyuv.c @ 7782:6efb15a24e91 libavcodec
Replace generic CONFIG_ENCODERS preprocessor conditionals by more specific
CONFIG_FOO_ENCODER conditionals where appropriate.
author | diego |
---|---|
date | Wed, 03 Sep 2008 12:33:21 +0000 |
parents | dbcdd0165e55 |
children | 4525dcd81357 |
comparison
equal
deleted
inserted
replaced
7781:0d62fafc69ae | 7782:6efb15a24e91 |
---|---|
259 bits >>= 1; | 259 bits >>= 1; |
260 } | 260 } |
261 return 0; | 261 return 0; |
262 } | 262 } |
263 | 263 |
264 #ifdef CONFIG_ENCODERS | 264 #if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) |
265 typedef struct { | 265 typedef struct { |
266 uint64_t val; | 266 uint64_t val; |
267 int name; | 267 int name; |
268 } heap_elem_t; | 268 } heap_elem_t; |
269 | 269 |
315 if(dst[i] >= 32) break; | 315 if(dst[i] >= 32) break; |
316 } | 316 } |
317 if(i==size) break; | 317 if(i==size) break; |
318 } | 318 } |
319 } | 319 } |
320 #endif /* CONFIG_ENCODERS */ | 320 #endif /* defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) */ |
321 | 321 |
322 static void generate_joint_tables(HYuvContext *s){ | 322 static void generate_joint_tables(HYuvContext *s){ |
323 uint16_t symbols[1<<VLC_BITS]; | 323 uint16_t symbols[1<<VLC_BITS]; |
324 uint16_t bits[1<<VLC_BITS]; | 324 uint16_t bits[1<<VLC_BITS]; |
325 uint8_t len[1<<VLC_BITS]; | 325 uint8_t len[1<<VLC_BITS]; |
573 | 573 |
574 return 0; | 574 return 0; |
575 } | 575 } |
576 #endif /* defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER) */ | 576 #endif /* defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER) */ |
577 | 577 |
578 #ifdef CONFIG_ENCODERS | 578 #if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) |
579 static int store_table(HYuvContext *s, uint8_t *len, uint8_t *buf){ | 579 static int store_table(HYuvContext *s, uint8_t *len, uint8_t *buf){ |
580 int i; | 580 int i; |
581 int index= 0; | 581 int index= 0; |
582 | 582 |
583 for(i=0; i<256;){ | 583 for(i=0; i<256;){ |
723 | 723 |
724 s->picture_number=0; | 724 s->picture_number=0; |
725 | 725 |
726 return 0; | 726 return 0; |
727 } | 727 } |
728 #endif /* CONFIG_ENCODERS */ | 728 #endif /* defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) */ |
729 | 729 |
730 /* TODO instead of restarting the read when the code isn't in the first level | 730 /* TODO instead of restarting the read when the code isn't in the first level |
731 * of the joint table, jump into the 2nd level of the individual table. */ | 731 * of the joint table, jump into the 2nd level of the individual table. */ |
732 #define READ_2PIX(dst0, dst1, plane1){\ | 732 #define READ_2PIX(dst0, dst1, plane1){\ |
733 uint16_t code = get_vlc2(&s->gb, s->vlc[3+plane1].table, VLC_BITS, 1);\ | 733 uint16_t code = get_vlc2(&s->gb, s->vlc[3+plane1].table, VLC_BITS, 1);\ |
759 for(i=0; i<count; i++){ | 759 for(i=0; i<count; i++){ |
760 READ_2PIX(s->temp[0][2*i ], s->temp[0][2*i+1], 0); | 760 READ_2PIX(s->temp[0][2*i ], s->temp[0][2*i+1], 0); |
761 } | 761 } |
762 } | 762 } |
763 | 763 |
764 #ifdef CONFIG_ENCODERS | 764 #if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) |
765 static int encode_422_bitstream(HYuvContext *s, int count){ | 765 static int encode_422_bitstream(HYuvContext *s, int count){ |
766 int i; | 766 int i; |
767 | 767 |
768 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 2*4*count){ | 768 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 2*4*count){ |
769 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); | 769 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); |
852 WRITE2; | 852 WRITE2; |
853 } | 853 } |
854 } | 854 } |
855 return 0; | 855 return 0; |
856 } | 856 } |
857 #endif /* CONFIG_ENCODERS */ | 857 #endif /* defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) */ |
858 | 858 |
859 static av_always_inline void decode_bgr_1(HYuvContext *s, int count, int decorrelate, int alpha){ | 859 static av_always_inline void decode_bgr_1(HYuvContext *s, int count, int decorrelate, int alpha){ |
860 int i; | 860 int i; |
861 for(i=0; i<count; i++){ | 861 for(i=0; i<count; i++){ |
862 int code = get_vlc2(&s->gb, s->vlc[3].table, VLC_BITS, 1); | 862 int code = get_vlc2(&s->gb, s->vlc[3].table, VLC_BITS, 1); |
1224 | 1224 |
1225 return 0; | 1225 return 0; |
1226 } | 1226 } |
1227 #endif /* defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER) */ | 1227 #endif /* defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER) */ |
1228 | 1228 |
1229 #ifdef CONFIG_ENCODERS | 1229 #if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) |
1230 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ | 1230 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ |
1231 HYuvContext *s = avctx->priv_data; | 1231 HYuvContext *s = avctx->priv_data; |
1232 AVFrame *pict = data; | 1232 AVFrame *pict = data; |
1233 const int width= s->width; | 1233 const int width= s->width; |
1234 const int width2= s->width>>1; | 1234 const int width2= s->width>>1; |
1429 av_freep(&avctx->extradata); | 1429 av_freep(&avctx->extradata); |
1430 av_freep(&avctx->stats_out); | 1430 av_freep(&avctx->stats_out); |
1431 | 1431 |
1432 return 0; | 1432 return 0; |
1433 } | 1433 } |
1434 #endif /* CONFIG_ENCODERS */ | 1434 #endif /* defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) */ |
1435 | 1435 |
1436 #ifdef CONFIG_HUFFYUV_DECODER | 1436 #ifdef CONFIG_HUFFYUV_DECODER |
1437 AVCodec huffyuv_decoder = { | 1437 AVCodec huffyuv_decoder = { |
1438 "huffyuv", | 1438 "huffyuv", |
1439 CODEC_TYPE_VIDEO, | 1439 CODEC_TYPE_VIDEO, |
1463 NULL, | 1463 NULL, |
1464 .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), | 1464 .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), |
1465 }; | 1465 }; |
1466 #endif | 1466 #endif |
1467 | 1467 |
1468 #ifdef CONFIG_ENCODERS | 1468 #ifdef CONFIG_HUFFYUV_ENCODER |
1469 | |
1470 AVCodec huffyuv_encoder = { | 1469 AVCodec huffyuv_encoder = { |
1471 "huffyuv", | 1470 "huffyuv", |
1472 CODEC_TYPE_VIDEO, | 1471 CODEC_TYPE_VIDEO, |
1473 CODEC_ID_HUFFYUV, | 1472 CODEC_ID_HUFFYUV, |
1474 sizeof(HYuvContext), | 1473 sizeof(HYuvContext), |
1476 encode_frame, | 1475 encode_frame, |
1477 encode_end, | 1476 encode_end, |
1478 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE}, | 1477 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE}, |
1479 .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), | 1478 .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), |
1480 }; | 1479 }; |
1481 | 1480 #endif |
1481 | |
1482 #ifdef CONFIG_FFVHUFF_ENCODER | |
1482 AVCodec ffvhuff_encoder = { | 1483 AVCodec ffvhuff_encoder = { |
1483 "ffvhuff", | 1484 "ffvhuff", |
1484 CODEC_TYPE_VIDEO, | 1485 CODEC_TYPE_VIDEO, |
1485 CODEC_ID_FFVHUFF, | 1486 CODEC_ID_FFVHUFF, |
1486 sizeof(HYuvContext), | 1487 sizeof(HYuvContext), |
1488 encode_frame, | 1489 encode_frame, |
1489 encode_end, | 1490 encode_end, |
1490 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE}, | 1491 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_RGB32, PIX_FMT_NONE}, |
1491 .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), | 1492 .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), |
1492 }; | 1493 }; |
1493 | 1494 #endif |
1494 #endif //CONFIG_ENCODERS |