Mercurial > libavcodec.hg
comparison asv1.c @ 1274:95061e8c5ea9 libavcodec
CONFIG_ENCODERS patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
author | michaelni |
---|---|
date | Tue, 20 May 2003 00:42:14 +0000 |
parents | a979fab41ed8 |
children | f78341ab5fba |
comparison
equal
deleted
inserted
replaced
1273:a979fab41ed8 | 1274:95061e8c5ea9 |
---|---|
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 | |
98 static inline void put_level(PutBitContext *pb, int level){ | 100 static inline void put_level(PutBitContext *pb, int level){ |
99 unsigned int index= level + 3; | 101 unsigned int index= level + 3; |
100 | 102 |
101 if(index <= 6) put_bits(pb, level_tab[index][1], level_tab[index][0]); | 103 if(index <= 6) put_bits(pb, level_tab[index][1], level_tab[index][0]); |
102 else{ | 104 else{ |
103 put_bits(pb, level_tab[3][1], level_tab[3][0]); | 105 put_bits(pb, level_tab[3][1], level_tab[3][0]); |
104 put_bits(pb, 8, level&0xFF); | 106 put_bits(pb, 8, level&0xFF); |
105 } | 107 } |
106 } | 108 } |
109 | |
110 #endif //CONFIG_ENCODERS | |
107 | 111 |
108 static inline int decode_block(ASV1Context *a, DCTELEM block[64]){ | 112 static inline int decode_block(ASV1Context *a, DCTELEM block[64]){ |
109 int i; | 113 int i; |
110 | 114 |
111 block[0]= 8*get_bits(&a->gb, 8); | 115 block[0]= 8*get_bits(&a->gb, 8); |
127 } | 131 } |
128 } | 132 } |
129 | 133 |
130 return 0; | 134 return 0; |
131 } | 135 } |
136 | |
137 #ifdef CONFIG_ENCODERS | |
132 | 138 |
133 static inline void encode_block(ASV1Context *a, DCTELEM block[64]){ | 139 static inline void encode_block(ASV1Context *a, DCTELEM block[64]){ |
134 int i; | 140 int i; |
135 int nc_count=0; | 141 int nc_count=0; |
136 | 142 |
161 } | 167 } |
162 } | 168 } |
163 put_bits(&a->pb, ccp_tab[16][1], ccp_tab[16][0]); | 169 put_bits(&a->pb, ccp_tab[16][1], ccp_tab[16][0]); |
164 } | 170 } |
165 | 171 |
172 #endif //CONFIG_ENCODERS | |
173 | |
166 static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){ | 174 static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){ |
167 int i; | 175 int i; |
168 | 176 |
169 a->dsp.clear_blocks(block[0]); | 177 a->dsp.clear_blocks(block[0]); |
170 | 178 |
173 return -1; | 181 return -1; |
174 } | 182 } |
175 return 0; | 183 return 0; |
176 } | 184 } |
177 | 185 |
186 #ifdef CONFIG_ENCODERS | |
187 | |
178 static inline void encode_mb(ASV1Context *a, DCTELEM block[6][64]){ | 188 static inline void encode_mb(ASV1Context *a, DCTELEM block[6][64]){ |
179 int i; | 189 int i; |
180 | 190 |
181 for(i=0; i<6; i++){ | 191 for(i=0; i<6; i++){ |
182 encode_block(a, block[i]); | 192 encode_block(a, block[i]); |
183 } | 193 } |
184 } | 194 } |
185 | 195 |
196 #endif //CONFIG_ENCODERS | |
197 | |
186 static inline void idct_put(ASV1Context *a, int mb_x, int mb_y){ | 198 static inline void idct_put(ASV1Context *a, int mb_x, int mb_y){ |
187 DCTELEM (*block)[64]= a->block; | 199 DCTELEM (*block)[64]= a->block; |
188 int linesize= a->picture.linesize[0]; | 200 int linesize= a->picture.linesize[0]; |
189 | 201 |
190 uint8_t *dest_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16; | 202 uint8_t *dest_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16; |
199 if(!(a->avctx->flags&CODEC_FLAG_GRAY)){ | 211 if(!(a->avctx->flags&CODEC_FLAG_GRAY)){ |
200 a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]); | 212 a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]); |
201 a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]); | 213 a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]); |
202 } | 214 } |
203 } | 215 } |
216 | |
217 #ifdef CONFIG_ENCODERS | |
204 | 218 |
205 static inline void dct_get(ASV1Context *a, int mb_x, int mb_y){ | 219 static inline void dct_get(ASV1Context *a, int mb_x, int mb_y){ |
206 DCTELEM (*block)[64]= a->block; | 220 DCTELEM (*block)[64]= a->block; |
207 int linesize= a->picture.linesize[0]; | 221 int linesize= a->picture.linesize[0]; |
208 int i; | 222 int i; |
223 a->dsp.get_pixels(block[5], ptr_cr, a->picture.linesize[2]); | 237 a->dsp.get_pixels(block[5], ptr_cr, a->picture.linesize[2]); |
224 for(i=4; i<6; i++) | 238 for(i=4; i<6; i++) |
225 a->dsp.fdct(block[i]); | 239 a->dsp.fdct(block[i]); |
226 } | 240 } |
227 } | 241 } |
242 | |
243 #endif //CONFIG_ENCODERS | |
228 | 244 |
229 static int decode_frame(AVCodecContext *avctx, | 245 static int decode_frame(AVCodecContext *avctx, |
230 void *data, int *data_size, | 246 void *data, int *data_size, |
231 uint8_t *buf, int buf_size) | 247 uint8_t *buf, int buf_size) |
232 { | 248 { |
306 emms_c(); | 322 emms_c(); |
307 | 323 |
308 return (get_bits_count(&a->gb)+31)/32*4; | 324 return (get_bits_count(&a->gb)+31)/32*4; |
309 } | 325 } |
310 | 326 |
327 #ifdef CONFIG_ENCODERS | |
328 | |
311 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ | 329 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ |
312 ASV1Context * const a = avctx->priv_data; | 330 ASV1Context * const a = avctx->priv_data; |
313 AVFrame *pict = data; | 331 AVFrame *pict = data; |
314 AVFrame * const p= (AVFrame*)&a->picture; | 332 AVFrame * const p= (AVFrame*)&a->picture; |
315 int size; | 333 int size; |
354 a->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size); | 372 a->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size); |
355 | 373 |
356 return size*4; | 374 return size*4; |
357 } | 375 } |
358 | 376 |
377 #endif //CONFIG_ENCODERS | |
378 | |
359 static void common_init(AVCodecContext *avctx){ | 379 static void common_init(AVCodecContext *avctx){ |
360 ASV1Context * const a = avctx->priv_data; | 380 ASV1Context * const a = avctx->priv_data; |
361 | 381 |
362 dsputil_init(&a->dsp, avctx); | 382 dsputil_init(&a->dsp, avctx); |
363 | 383 |
394 p->qscale_table= av_mallocz( p->qstride * a->mb_height); | 414 p->qscale_table= av_mallocz( p->qstride * a->mb_height); |
395 | 415 |
396 return 0; | 416 return 0; |
397 } | 417 } |
398 | 418 |
419 #ifdef CONFIG_ENCODERS | |
420 | |
399 static int encode_init(AVCodecContext *avctx){ | 421 static int encode_init(AVCodecContext *avctx){ |
400 ASV1Context * const a = avctx->priv_data; | 422 ASV1Context * const a = avctx->priv_data; |
401 int i; | 423 int i; |
402 | 424 |
403 common_init(avctx); | 425 common_init(avctx); |
416 a->q_intra_matrix[i]= ((a->inv_qscale<<16) + q/2) / q; | 438 a->q_intra_matrix[i]= ((a->inv_qscale<<16) + q/2) / q; |
417 } | 439 } |
418 | 440 |
419 return 0; | 441 return 0; |
420 } | 442 } |
443 | |
444 #endif //CONFIG_ENCODERS | |
421 | 445 |
422 static int decode_end(AVCodecContext *avctx){ | 446 static int decode_end(AVCodecContext *avctx){ |
423 ASV1Context * const a = avctx->priv_data; | 447 ASV1Context * const a = avctx->priv_data; |
424 | 448 |
425 av_freep(&a->bitstream_buffer); | 449 av_freep(&a->bitstream_buffer); |
441 decode_end, | 465 decode_end, |
442 decode_frame, | 466 decode_frame, |
443 CODEC_CAP_DR1, | 467 CODEC_CAP_DR1, |
444 }; | 468 }; |
445 | 469 |
470 #ifdef CONFIG_ENCODERS | |
471 | |
446 AVCodec asv1_encoder = { | 472 AVCodec asv1_encoder = { |
447 "asv1", | 473 "asv1", |
448 CODEC_TYPE_VIDEO, | 474 CODEC_TYPE_VIDEO, |
449 CODEC_ID_ASV1, | 475 CODEC_ID_ASV1, |
450 sizeof(ASV1Context), | 476 sizeof(ASV1Context), |
451 encode_init, | 477 encode_init, |
452 encode_frame, | 478 encode_frame, |
453 //encode_end, | 479 //encode_end, |
454 }; | 480 }; |
481 | |
482 #endif //CONFIG_ENCODERS |