comparison huffyuv.c @ 3777:20545fbb6f7c libavcodec

add some #ifdef CONFIG_ENCODERS/DECODERS
author mru
date Wed, 27 Sep 2006 19:54:07 +0000
parents f76861f4d5ca
children c8c591fe26f8
comparison
equal deleted inserted replaced
3776:1843a85123b7 3777:20545fbb6f7c
234 bits >>= 1; 234 bits >>= 1;
235 } 235 }
236 return 0; 236 return 0;
237 } 237 }
238 238
239 #ifdef CONFIG_ENCODERS
239 static void generate_len_table(uint8_t *dst, uint64_t *stats, int size){ 240 static void generate_len_table(uint8_t *dst, uint64_t *stats, int size){
240 uint64_t counts[2*size]; 241 uint64_t counts[2*size];
241 int up[2*size]; 242 int up[2*size];
242 int offset, i, next; 243 int offset, i, next;
243 244
289 dst[i]= len; 290 dst[i]= len;
290 } 291 }
291 if(i==size) break; 292 if(i==size) break;
292 } 293 }
293 } 294 }
295 #endif /* CONFIG_ENCODERS */
294 296
295 static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){ 297 static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){
296 GetBitContext gb; 298 GetBitContext gb;
297 int i; 299 int i;
298 300
373 assert(s->width>0 && s->height>0); 375 assert(s->width>0 && s->height>0);
374 376
375 return 0; 377 return 0;
376 } 378 }
377 379
380 #ifdef CONFIG_DECODERS
378 static int decode_init(AVCodecContext *avctx) 381 static int decode_init(AVCodecContext *avctx)
379 { 382 {
380 HYuvContext *s = avctx->priv_data; 383 HYuvContext *s = avctx->priv_data;
381 384
382 common_init(avctx); 385 common_init(avctx);
468 471
469 // av_log(NULL, AV_LOG_DEBUG, "pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_sample, s->interlaced); 472 // av_log(NULL, AV_LOG_DEBUG, "pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_sample, s->interlaced);
470 473
471 return 0; 474 return 0;
472 } 475 }
473 476 #endif
477
478 #ifdef CONFIG_ENCODERS
474 static int store_table(HYuvContext *s, uint8_t *len, uint8_t *buf){ 479 static int store_table(HYuvContext *s, uint8_t *len, uint8_t *buf){
475 int i; 480 int i;
476 int index= 0; 481 int index= 0;
477 482
478 for(i=0; i<256;){ 483 for(i=0; i<256;){
610 615
611 s->picture_number=0; 616 s->picture_number=0;
612 617
613 return 0; 618 return 0;
614 } 619 }
620 #endif /* CONFIG_ENCODERS */
615 621
616 static void decode_422_bitstream(HYuvContext *s, int count){ 622 static void decode_422_bitstream(HYuvContext *s, int count){
617 int i; 623 int i;
618 624
619 count/=2; 625 count/=2;
635 s->temp[0][2*i ]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); 641 s->temp[0][2*i ]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3);
636 s->temp[0][2*i+1]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); 642 s->temp[0][2*i+1]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3);
637 } 643 }
638 } 644 }
639 645
646 #ifdef CONFIG_ENCODERS
640 static int encode_422_bitstream(HYuvContext *s, int count){ 647 static int encode_422_bitstream(HYuvContext *s, int count){
641 int i; 648 int i;
642 649
643 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 2*4*count){ 650 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 2*4*count){
644 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); 651 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
709 put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]); 716 put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
710 } 717 }
711 } 718 }
712 return 0; 719 return 0;
713 } 720 }
721 #endif /* CONFIG_ENCODERS */
714 722
715 static void decode_bgr_bitstream(HYuvContext *s, int count){ 723 static void decode_bgr_bitstream(HYuvContext *s, int count){
716 int i; 724 int i;
717 725
718 if(s->decorrelate){ 726 if(s->decorrelate){
746 } 754 }
747 } 755 }
748 } 756 }
749 } 757 }
750 758
759 #ifdef CONFIG_DECODERS
751 static void draw_slice(HYuvContext *s, int y){ 760 static void draw_slice(HYuvContext *s, int y){
752 int h, cy; 761 int h, cy;
753 int offset[4]; 762 int offset[4];
754 763
755 if(s->avctx->draw_horiz_band==NULL) 764 if(s->avctx->draw_horiz_band==NULL)
1012 *picture= *p; 1021 *picture= *p;
1013 *data_size = sizeof(AVFrame); 1022 *data_size = sizeof(AVFrame);
1014 1023
1015 return (get_bits_count(&s->gb)+31)/32*4 + table_size; 1024 return (get_bits_count(&s->gb)+31)/32*4 + table_size;
1016 } 1025 }
1026 #endif
1017 1027
1018 static int common_end(HYuvContext *s){ 1028 static int common_end(HYuvContext *s){
1019 int i; 1029 int i;
1020 1030
1021 for(i=0; i<3; i++){ 1031 for(i=0; i<3; i++){
1022 av_freep(&s->temp[i]); 1032 av_freep(&s->temp[i]);
1023 } 1033 }
1024 return 0; 1034 return 0;
1025 } 1035 }
1026 1036
1037 #ifdef CONFIG_DECODERS
1027 static int decode_end(AVCodecContext *avctx) 1038 static int decode_end(AVCodecContext *avctx)
1028 { 1039 {
1029 HYuvContext *s = avctx->priv_data; 1040 HYuvContext *s = avctx->priv_data;
1030 int i; 1041 int i;
1031 1042
1036 free_vlc(&s->vlc[i]); 1047 free_vlc(&s->vlc[i]);
1037 } 1048 }
1038 1049
1039 return 0; 1050 return 0;
1040 } 1051 }
1041 1052 #endif
1053
1054 #ifdef CONFIG_ENCODERS
1042 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ 1055 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
1043 HYuvContext *s = avctx->priv_data; 1056 HYuvContext *s = avctx->priv_data;
1044 AVFrame *pict = data; 1057 AVFrame *pict = data;
1045 const int width= s->width; 1058 const int width= s->width;
1046 const int width2= s->width>>1; 1059 const int width2= s->width>>1;
1216 av_freep(&avctx->extradata); 1229 av_freep(&avctx->extradata);
1217 av_freep(&avctx->stats_out); 1230 av_freep(&avctx->stats_out);
1218 1231
1219 return 0; 1232 return 0;
1220 } 1233 }
1221 1234 #endif /* CONFIG_ENCODERS */
1235
1236 #ifdef CONFIG_DECODERS
1222 AVCodec huffyuv_decoder = { 1237 AVCodec huffyuv_decoder = {
1223 "huffyuv", 1238 "huffyuv",
1224 CODEC_TYPE_VIDEO, 1239 CODEC_TYPE_VIDEO,
1225 CODEC_ID_HUFFYUV, 1240 CODEC_ID_HUFFYUV,
1226 sizeof(HYuvContext), 1241 sizeof(HYuvContext),
1242 decode_end, 1257 decode_end,
1243 decode_frame, 1258 decode_frame,
1244 CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, 1259 CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
1245 NULL 1260 NULL
1246 }; 1261 };
1262 #endif
1247 1263
1248 #ifdef CONFIG_ENCODERS 1264 #ifdef CONFIG_ENCODERS
1249 1265
1250 AVCodec huffyuv_encoder = { 1266 AVCodec huffyuv_encoder = {
1251 "huffyuv", 1267 "huffyuv",