comparison asv1.c @ 1325:1cbc2380d172 libavcodec

CONFIG_ENCODERS cleanup
author michaelni
date Sun, 22 Jun 2003 11:08:22 +0000
parents f78341ab5fba
children 46d3fa8501cd
comparison
equal deleted inserted replaced
1324:7d328fd9d8a5 1325:1cbc2380d172
93 93
94 if(code==3) return get_sbits(gb, 8); 94 if(code==3) return get_sbits(gb, 8);
95 else return code - 3; 95 else return code - 3;
96 } 96 }
97 97
98 #ifdef CONFIG_ENCODERS
99
100 static inline void put_level(PutBitContext *pb, int level){ 98 static inline void put_level(PutBitContext *pb, int level){
101 unsigned int index= level + 3; 99 unsigned int index= level + 3;
102 100
103 if(index <= 6) put_bits(pb, level_tab[index][1], level_tab[index][0]); 101 if(index <= 6) put_bits(pb, level_tab[index][1], level_tab[index][0]);
104 else{ 102 else{
105 put_bits(pb, level_tab[3][1], level_tab[3][0]); 103 put_bits(pb, level_tab[3][1], level_tab[3][0]);
106 put_bits(pb, 8, level&0xFF); 104 put_bits(pb, 8, level&0xFF);
107 } 105 }
108 } 106 }
109
110 #endif //CONFIG_ENCODERS
111 107
112 static inline int decode_block(ASV1Context *a, DCTELEM block[64]){ 108 static inline int decode_block(ASV1Context *a, DCTELEM block[64]){
113 int i; 109 int i;
114 110
115 block[0]= 8*get_bits(&a->gb, 8); 111 block[0]= 8*get_bits(&a->gb, 8);
131 } 127 }
132 } 128 }
133 129
134 return 0; 130 return 0;
135 } 131 }
136
137 #ifdef CONFIG_ENCODERS
138 132
139 static inline void encode_block(ASV1Context *a, DCTELEM block[64]){ 133 static inline void encode_block(ASV1Context *a, DCTELEM block[64]){
140 int i; 134 int i;
141 int nc_count=0; 135 int nc_count=0;
142 136
167 } 161 }
168 } 162 }
169 put_bits(&a->pb, ccp_tab[16][1], ccp_tab[16][0]); 163 put_bits(&a->pb, ccp_tab[16][1], ccp_tab[16][0]);
170 } 164 }
171 165
172 #endif //CONFIG_ENCODERS
173
174 static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){ 166 static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){
175 int i; 167 int i;
176 168
177 a->dsp.clear_blocks(block[0]); 169 a->dsp.clear_blocks(block[0]);
178 170
181 return -1; 173 return -1;
182 } 174 }
183 return 0; 175 return 0;
184 } 176 }
185 177
186 #ifdef CONFIG_ENCODERS
187
188 static inline void encode_mb(ASV1Context *a, DCTELEM block[6][64]){ 178 static inline void encode_mb(ASV1Context *a, DCTELEM block[6][64]){
189 int i; 179 int i;
190 180
191 for(i=0; i<6; i++){ 181 for(i=0; i<6; i++){
192 encode_block(a, block[i]); 182 encode_block(a, block[i]);
193 } 183 }
194 } 184 }
195
196 #endif //CONFIG_ENCODERS
197 185
198 static inline void idct_put(ASV1Context *a, int mb_x, int mb_y){ 186 static inline void idct_put(ASV1Context *a, int mb_x, int mb_y){
199 DCTELEM (*block)[64]= a->block; 187 DCTELEM (*block)[64]= a->block;
200 int linesize= a->picture.linesize[0]; 188 int linesize= a->picture.linesize[0];
201 189
211 if(!(a->avctx->flags&CODEC_FLAG_GRAY)){ 199 if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
212 a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]); 200 a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]);
213 a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]); 201 a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]);
214 } 202 }
215 } 203 }
216
217 #ifdef CONFIG_ENCODERS
218 204
219 static inline void dct_get(ASV1Context *a, int mb_x, int mb_y){ 205 static inline void dct_get(ASV1Context *a, int mb_x, int mb_y){
220 DCTELEM (*block)[64]= a->block; 206 DCTELEM (*block)[64]= a->block;
221 int linesize= a->picture.linesize[0]; 207 int linesize= a->picture.linesize[0];
222 int i; 208 int i;
237 a->dsp.get_pixels(block[5], ptr_cr, a->picture.linesize[2]); 223 a->dsp.get_pixels(block[5], ptr_cr, a->picture.linesize[2]);
238 for(i=4; i<6; i++) 224 for(i=4; i<6; i++)
239 a->dsp.fdct(block[i]); 225 a->dsp.fdct(block[i]);
240 } 226 }
241 } 227 }
242
243 #endif //CONFIG_ENCODERS
244 228
245 static int decode_frame(AVCodecContext *avctx, 229 static int decode_frame(AVCodecContext *avctx,
246 void *data, int *data_size, 230 void *data, int *data_size,
247 uint8_t *buf, int buf_size) 231 uint8_t *buf, int buf_size)
248 { 232 {
322 emms_c(); 306 emms_c();
323 307
324 return (get_bits_count(&a->gb)+31)/32*4; 308 return (get_bits_count(&a->gb)+31)/32*4;
325 } 309 }
326 310
327 #ifdef CONFIG_ENCODERS
328
329 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ 311 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
330 ASV1Context * const a = avctx->priv_data; 312 ASV1Context * const a = avctx->priv_data;
331 AVFrame *pict = data; 313 AVFrame *pict = data;
332 AVFrame * const p= (AVFrame*)&a->picture; 314 AVFrame * const p= (AVFrame*)&a->picture;
333 int size; 315 int size;
372 a->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size); 354 a->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size);
373 355
374 return size*4; 356 return size*4;
375 } 357 }
376 358
377 #endif //CONFIG_ENCODERS
378
379 static void common_init(AVCodecContext *avctx){ 359 static void common_init(AVCodecContext *avctx){
380 ASV1Context * const a = avctx->priv_data; 360 ASV1Context * const a = avctx->priv_data;
381 361
382 dsputil_init(&a->dsp, avctx); 362 dsputil_init(&a->dsp, avctx);
383 363
414 p->qscale_table= av_mallocz( p->qstride * a->mb_height); 394 p->qscale_table= av_mallocz( p->qstride * a->mb_height);
415 395
416 return 0; 396 return 0;
417 } 397 }
418 398
419 #ifdef CONFIG_ENCODERS
420
421 static int encode_init(AVCodecContext *avctx){ 399 static int encode_init(AVCodecContext *avctx){
422 ASV1Context * const a = avctx->priv_data; 400 ASV1Context * const a = avctx->priv_data;
423 int i; 401 int i;
424 402
425 common_init(avctx); 403 common_init(avctx);
438 a->q_intra_matrix[i]= ((a->inv_qscale<<16) + q/2) / q; 416 a->q_intra_matrix[i]= ((a->inv_qscale<<16) + q/2) / q;
439 } 417 }
440 418
441 return 0; 419 return 0;
442 } 420 }
443
444 #endif //CONFIG_ENCODERS
445 421
446 static int decode_end(AVCodecContext *avctx){ 422 static int decode_end(AVCodecContext *avctx){
447 ASV1Context * const a = avctx->priv_data; 423 ASV1Context * const a = avctx->priv_data;
448 424
449 av_freep(&a->bitstream_buffer); 425 av_freep(&a->bitstream_buffer);