comparison intrax8.c @ 5906:595a2f31430e libavcodec

misc spelling/grammar/wording fixes in comments
author diego
date Sat, 10 Nov 2007 11:51:56 +0000
parents b838537e0ab3
children fbd10e6dfbe1
comparison
equal deleted inserted replaced
5905:d5790580ed3e 5906:595a2f31430e
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */ 17 */
18 18
19 /** 19 /**
20 * @file intrax8.c 20 * @file intrax8.c
21 * @brief IntraX8 (J-Frame) sub-decoder, used by wmv2 and vc1 21 * @brief IntraX8 (J-Frame) subdecoder, used by WMV2 and VC-1
22 */ 22 */
23 23
24 #include "avcodec.h" 24 #include "avcodec.h"
25 #include "bitstream.h" 25 #include "bitstream.h"
26 #include "mpegvideo.h" 26 #include "mpegvideo.h"
192 i== 0-15 r=0-15 l=0 ;r=i& %01111 192 i== 0-15 r=0-15 l=0 ;r=i& %01111
193 i==16-19 r=0-3 l=1 ;r=i& %00011 193 i==16-19 r=0-3 l=1 ;r=i& %00011
194 i==20-21 r=0-1 l=2 ;r=i& %00001 194 i==20-21 r=0-1 l=2 ;r=i& %00001
195 i==22 r=0 l=3 ;r=i& %00000 195 i==22 r=0 l=3 ;r=i& %00000
196 l=lut_l[i/2]={0,0,0,0,0,0,0,0,1,1,2,3}[i>>1];// 11 10'01 01'00 00'00 00'00 00'00 00 => 0xE50000 196 l=lut_l[i/2]={0,0,0,0,0,0,0,0,1,1,2,3}[i>>1];// 11 10'01 01'00 00'00 00'00 00'00 00 => 0xE50000
197 t=lut_mask[l]={0x0f,0x03,0x01,0x00}[l]; as i<256 the higher bits doesn't matter */ 197 t=lut_mask[l]={0x0f,0x03,0x01,0x00}[l]; as i<256 the higher bits do not matter */
198 l=(0xE50000>>(i&(0x1E)))&3;/*0x1E or (~1) or ((i>>1)<<1)*/ 198 l=(0xE50000>>(i&(0x1E)))&3;/*0x1E or (~1) or ((i>>1)<<1)*/
199 t=(0x01030F>>(l<<3)); 199 t=(0x01030F>>(l<<3));
200 200
201 (*run) = i&t; 201 (*run) = i&t;
202 (*level) = l; 202 (*level) = l;
289 } 289 }
290 290
291 w->flat_dc=0; 291 w->flat_dc=0;
292 if(range < quant || range < 3){ 292 if(range < quant || range < 3){
293 w->orient=0; 293 w->orient=0;
294 if(range < 3){//yep you read right, idct error of +-1 may break decoding! 294 if(range < 3){//yep you read right, a +-1 idct error may break decoding!
295 w->flat_dc=1; 295 w->flat_dc=1;
296 sum+=9; 296 sum+=9;
297 w->predicted_dc = (sum*6899)>>17;//((1<<17)+9)/(8+8+1+2)=6899 297 w->predicted_dc = (sum*6899)>>17;//((1<<17)+9)/(8+8+1+2)=6899
298 } 298 }
299 } 299 }
372 case 3: 372 case 3:
373 w->est_run = 16; 373 w->est_run = 16;
374 w->orient = 0; 374 w->orient = 0;
375 return; 375 return;
376 } 376 }
377 //no edge cases. 377 //no edge cases
378 b= w->prediction_table[2*s->mb_x + !(s->mb_y&1) ];//block[x ][y-1] 378 b= w->prediction_table[2*s->mb_x + !(s->mb_y&1) ];//block[x ][y-1]
379 a= w->prediction_table[2*s->mb_x-2 + (s->mb_y&1) ];//block[x-1][y ] 379 a= w->prediction_table[2*s->mb_x-2 + (s->mb_y&1) ];//block[x-1][y ]
380 c= w->prediction_table[2*s->mb_x-2 + !(s->mb_y&1) ];//block[x-1][y-1] 380 c= w->prediction_table[2*s->mb_x-2 + !(s->mb_y&1) ];//block[x-1][y-1]
381 381
382 w->est_run = FFMIN(b,a); 382 w->est_run = FFMIN(b,a);
383 /*this condition has nothing to do with w->edges, even if it looks similar 383 /* This condition has nothing to do with w->edges, even if it looks
384 it would triger if e.g. x=3;y=2; 384 similar it would trigger if e.g. x=3;y=2;
385 I guess somebody wrote something wrong and it became standard */ 385 I guess somebody wrote something wrong and it became standard. */
386 if( (s->mb_x & s->mb_y) != 0 ) w->est_run=FFMIN(c,w->est_run); 386 if( (s->mb_x & s->mb_y) != 0 ) w->est_run=FFMIN(c,w->est_run);
387 w->est_run>>=2; 387 w->est_run>>=2;
388 388
389 a&=3; 389 a&=3;
390 b&=3; 390 b&=3;
643 return 0; 643 return 0;
644 } 644 }
645 645
646 static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_* 646 static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_*
647 //not s->linesize as this would be wrong for field pics 647 //not s->linesize as this would be wrong for field pics
648 //not that IntraX8 have interlace support ;) 648 //not that IntraX8 has interlacing support ;)
649 const int linesize = s->current_picture.linesize[0]; 649 const int linesize = s->current_picture.linesize[0];
650 const int uvlinesize= s->current_picture.linesize[1]; 650 const int uvlinesize= s->current_picture.linesize[1];
651 651
652 s->dest[0] = s->current_picture.data[0]; 652 s->dest[0] = s->current_picture.data[0];
653 s->dest[1] = s->current_picture.data[1]; 653 s->dest[1] = s->current_picture.data[1];
677 } 677 }
678 678
679 /** 679 /**
680 * Decode single IntraX8 frame. 680 * Decode single IntraX8 frame.
681 * The parent codec must fill s->loopfilter and s->gb (bitstream). 681 * The parent codec must fill s->loopfilter and s->gb (bitstream).
682 * The parent codec must call MPV_frame_start(), ff_er_frame_start() before calling this function 682 * The parent codec must call MPV_frame_start(), ff_er_frame_start() before calling this function.
683 * The parent codec must call ff_er_frame_end(), MPV_frame_end() after calling this function. 683 * The parent codec must call ff_er_frame_end(), MPV_frame_end() after calling this function.
684 * This function does not use MPV_decode_mb(). 684 * This function does not use MPV_decode_mb().
685 * lowres decoding is theoretically impossible. 685 * lowres decoding is theoretically impossible.
686 * @param w pointer to IntraX8Context 686 * @param w pointer to IntraX8Context
687 * @param dquant doubled quantizer, it would be odd in case of vc1 halfpq==1 687 * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
688 * @param quant_offset offset away from zero. 688 * @param quant_offset offset away from zero
689 */ 689 */
690 //FIXME extern uint8_t wmv3_dc_scale_table[32]; 690 //FIXME extern uint8_t wmv3_dc_scale_table[32];
691 int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_offset){ 691 int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_offset){
692 MpegEncContext * const s= w->s; 692 MpegEncContext * const s= w->s;
693 int mb_xy; 693 int mb_xy;
722 722
723 if( s->mb_x & s->mb_y & 1 ){ 723 if( s->mb_x & s->mb_y & 1 ){
724 x8_get_prediction_chroma(w); 724 x8_get_prediction_chroma(w);
725 725
726 /*when setting up chroma, no vlc is read, 726 /*when setting up chroma, no vlc is read,
727 so no error condition could be reached*/ 727 so no error condition can be reached*/
728 x8_setup_spatial_predictor(w,1); 728 x8_setup_spatial_predictor(w,1);
729 if(x8_decode_intra_mb(w,1)) goto error; 729 if(x8_decode_intra_mb(w,1)) goto error;
730 730
731 x8_setup_spatial_predictor(w,2); 731 x8_setup_spatial_predictor(w,2);
732 if(x8_decode_intra_mb(w,2)) goto error; 732 if(x8_decode_intra_mb(w,2)) goto error;