Mercurial > libavcodec.hg
comparison h263.c @ 344:9f6071a87e17 libavcodec
fixed msmpeg4 infinite loop if buggy stream
rewrote quantizer
fixed bias (+10% compression/quality for h263 like codecs)
qscale=1 support
mpeg1 intra frames looks far less blocky
added codec_id field
author | michaelni |
---|---|
date | Sat, 27 Apr 2002 12:30:26 +0000 |
parents | bf26081c373c |
children | c2f789fe4945 |
comparison
equal
deleted
inserted
replaced
343:9211a0c9466a | 344:9f6071a87e17 |
---|---|
902 init_mv_penalty_and_fcode(s); | 902 init_mv_penalty_and_fcode(s); |
903 } | 903 } |
904 s->mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p | 904 s->mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p |
905 | 905 |
906 // use fcodes >1 only for mpeg4 & h263 & h263p FIXME | 906 // use fcodes >1 only for mpeg4 & h263 & h263p FIXME |
907 if(s->h263_plus) s->fcode_tab= umv_fcode_tab; | 907 switch(s->codec_id){ |
908 else if(s->h263_pred && !s->h263_msmpeg4) s->fcode_tab= fcode_tab; | 908 case CODEC_ID_MPEG4: |
909 s->fcode_tab= fcode_tab; | |
910 s->min_qcoeff= -2048; | |
911 s->max_qcoeff= 2047; | |
912 break; | |
913 case CODEC_ID_H263P: | |
914 s->fcode_tab= umv_fcode_tab; | |
915 s->min_qcoeff= -128; | |
916 s->max_qcoeff= 127; | |
917 break; | |
918 default: //nothing needed default table allready set in mpegvideo.c | |
919 s->min_qcoeff= -128; | |
920 s->max_qcoeff= 127; | |
921 } | |
922 | |
923 /* h263 type bias */ | |
924 //FIXME mpeg4 mpeg quantizer | |
925 s->intra_quant_bias=0; | |
926 s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x | |
909 } | 927 } |
910 | 928 |
911 static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n) | 929 static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n) |
912 { | 930 { |
913 int level, run, last, i, j, last_index, last_non_zero, sign, slevel; | 931 int level, run, last, i, j, last_index, last_non_zero, sign, slevel; |
2700 v= ff_mpeg4_default_intra_matrix[i]; | 2718 v= ff_mpeg4_default_intra_matrix[i]; |
2701 s->intra_matrix[i]= v; | 2719 s->intra_matrix[i]= v; |
2702 s->chroma_intra_matrix[i]= v; | 2720 s->chroma_intra_matrix[i]= v; |
2703 | 2721 |
2704 v= ff_mpeg4_default_non_intra_matrix[i]; | 2722 v= ff_mpeg4_default_non_intra_matrix[i]; |
2705 s->non_intra_matrix[i]= v; | 2723 s->inter_matrix[i]= v; |
2706 s->chroma_non_intra_matrix[i]= v; | 2724 s->chroma_inter_matrix[i]= v; |
2707 } | 2725 } |
2708 | 2726 |
2709 /* load custom intra matrix */ | 2727 /* load custom intra matrix */ |
2710 if(get_bits1(&s->gb)){ | 2728 if(get_bits1(&s->gb)){ |
2711 for(i=0; i<64; i++){ | 2729 for(i=0; i<64; i++){ |
2723 for(i=0; i<64; i++){ | 2741 for(i=0; i<64; i++){ |
2724 v= get_bits(&s->gb, 8); | 2742 v= get_bits(&s->gb, 8); |
2725 if(v==0) break; | 2743 if(v==0) break; |
2726 | 2744 |
2727 j= zigzag_direct[i]; | 2745 j= zigzag_direct[i]; |
2728 s->non_intra_matrix[j]= v; | 2746 s->inter_matrix[j]= v; |
2729 s->chroma_non_intra_matrix[j]= v; | 2747 s->chroma_inter_matrix[j]= v; |
2730 } | 2748 } |
2731 | 2749 |
2732 /* replicate last value */ | 2750 /* replicate last value */ |
2733 for(; i<64; i++){ | 2751 for(; i<64; i++){ |
2734 j= zigzag_direct[i]; | 2752 j= zigzag_direct[i]; |
2735 s->non_intra_matrix[j]= v; | 2753 s->inter_matrix[j]= v; |
2736 s->chroma_non_intra_matrix[j]= v; | 2754 s->chroma_inter_matrix[j]= v; |
2737 } | 2755 } |
2738 } | 2756 } |
2739 | 2757 |
2740 s->dct_unquantize= s->dct_unquantize_mpeg2; | 2758 s->dct_unquantize= s->dct_unquantize_mpeg2; |
2741 | 2759 |