comparison h263.c @ 2080:6a9472a09ffc libavcodec

coefficient saturation fix
author michael
date Mon, 14 Jun 2004 23:41:41 +0000
parents 9629c1180d5f
children 82816cad0e29
comparison
equal deleted inserted replaced
2079:75aae96e6b54 2080:6a9472a09ffc
4715 if(IS_3IV1) 4715 if(IS_3IV1)
4716 cache ^= 0xC0000000; 4716 cache ^= 0xC0000000;
4717 4717
4718 if (cache&0x80000000) { 4718 if (cache&0x80000000) {
4719 if (cache&0x40000000) { 4719 if (cache&0x40000000) {
4720 int ulevel;
4721
4722 /* third escape */ 4720 /* third escape */
4723 SKIP_CACHE(re, &s->gb, 2); 4721 SKIP_CACHE(re, &s->gb, 2);
4724 last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1); 4722 last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
4725 run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6); 4723 run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
4726 SKIP_COUNTER(re, &s->gb, 2+1+6); 4724 SKIP_COUNTER(re, &s->gb, 2+1+6);
4742 }; LAST_SKIP_CACHE(re, &s->gb, 1); 4740 }; LAST_SKIP_CACHE(re, &s->gb, 1);
4743 4741
4744 SKIP_COUNTER(re, &s->gb, 1+12+1); 4742 SKIP_COUNTER(re, &s->gb, 1+12+1);
4745 } 4743 }
4746 4744
4747 if(s->mpeg_quant){
4748 if(intra) ulevel= level*s->qscale*s->intra_matrix[scan_table[1]];
4749 else ulevel= level*s->qscale*s->inter_matrix[scan_table[0]];
4750 }else
4751 ulevel= level*s->qscale*16;
4752 if(ulevel>1030*16 || ulevel<-1030*16){
4753 av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
4754 return -1;
4755 }
4756
4757 #if 0 4745 #if 0
4758 if(s->error_resilience >= FF_ER_COMPLIANT){ 4746 if(s->error_resilience >= FF_ER_COMPLIANT){
4759 const int abs_level= ABS(level); 4747 const int abs_level= ABS(level);
4760 if(abs_level<=MAX_LEVEL && run<=MAX_RUN){ 4748 if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
4761 const int run1= run - rl->max_run[last][abs_level] - 1; 4749 const int run1= run - rl->max_run[last][abs_level] - 1;
4776 } 4764 }
4777 } 4765 }
4778 #endif 4766 #endif
4779 if (level>0) level= level * qmul + qadd; 4767 if (level>0) level= level * qmul + qadd;
4780 else level= level * qmul - qadd; 4768 else level= level * qmul - qadd;
4769
4770 if((unsigned)(level + 2048) > 4095){
4771 if(s->error_resilience > FF_ER_COMPLIANT){
4772 if(level > 2560 || level<-2560){
4773 av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
4774 return -1;
4775 }
4776 }
4777 level= level<0 ? -2048 : 2047;
4778 }
4781 4779
4782 i+= run + 1; 4780 i+= run + 1;
4783 if(last) i+=192; 4781 if(last) i+=192;
4784 } else { 4782 } else {
4785 /* second escape */ 4783 /* second escape */
6060 6058
6061 s->pict_type = I_TYPE + get_bits(&s->gb, 2); 6059 s->pict_type = I_TYPE + get_bits(&s->gb, 2);
6062 s->dropable= s->pict_type > P_TYPE; 6060 s->dropable= s->pict_type > P_TYPE;
6063 if (s->dropable) 6061 if (s->dropable)
6064 s->pict_type = P_TYPE; 6062 s->pict_type = P_TYPE;
6065 6063
6066 skip_bits1(&s->gb); /* deblocking flag */ 6064 skip_bits1(&s->gb); /* deblocking flag */
6067 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); 6065 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
6068 6066
6069 s->h263_plus = 0; 6067 s->h263_plus = 0;
6070 6068