comparison mpeg12.c @ 1992:938e47c809b0 libavcodec

intra_dc_precission>0 encoding support
author michael
date Fri, 30 Apr 2004 13:44:29 +0000
parents 11991f81afd6
children 141a9539e270
comparison
equal deleted inserted replaced
1991:fa09319b80af 1992:938e47c809b0
358 358
359 static void common_init(MpegEncContext *s) 359 static void common_init(MpegEncContext *s)
360 { 360 {
361 361
362 s->y_dc_scale_table= 362 s->y_dc_scale_table=
363 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; 363 s->c_dc_scale_table= mpeg2_dc_scale_table[s->intra_dc_precision];
364 364
365 } 365 }
366 366
367 void ff_mpeg1_clean_buffers(MpegEncContext *s){ 367 void ff_mpeg1_clean_buffers(MpegEncContext *s){
368 s->last_dc[0] = 1 << (7 + s->intra_dc_precision); 368 s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
835 s->inter_ac_vlc_last_length= uni_mpeg1_ac_vlc_len; 835 s->inter_ac_vlc_last_length= uni_mpeg1_ac_vlc_len;
836 } 836 }
837 837
838 static inline void encode_dc(MpegEncContext *s, int diff, int component) 838 static inline void encode_dc(MpegEncContext *s, int diff, int component)
839 { 839 {
840 if(((unsigned) (diff+255)) >= 511){
841 int index;
842
843 if(diff<0){
844 index= av_log2_16bit(-2*diff);
845 diff--;
846 }else{
847 index= av_log2_16bit(2*diff);
848 }
849 if (component == 0) {
850 put_bits(
851 &s->pb,
852 vlc_dc_lum_bits[index] + index,
853 (vlc_dc_lum_code[index]<<index) + (diff & ((1 << index) - 1)));
854 }else{
855 put_bits(
856 &s->pb,
857 vlc_dc_chroma_bits[index] + index,
858 (vlc_dc_chroma_code[index]<<index) + (diff & ((1 << index) - 1)));
859 }
860 }else{
840 if (component == 0) { 861 if (component == 0) {
841 put_bits( 862 put_bits(
842 &s->pb, 863 &s->pb,
843 mpeg1_lum_dc_uni[diff+255]&0xFF, 864 mpeg1_lum_dc_uni[diff+255]&0xFF,
844 mpeg1_lum_dc_uni[diff+255]>>8); 865 mpeg1_lum_dc_uni[diff+255]>>8);
846 put_bits( 867 put_bits(
847 &s->pb, 868 &s->pb,
848 mpeg1_chr_dc_uni[diff+255]&0xFF, 869 mpeg1_chr_dc_uni[diff+255]&0xFF,
849 mpeg1_chr_dc_uni[diff+255]>>8); 870 mpeg1_chr_dc_uni[diff+255]>>8);
850 } 871 }
872 }
851 } 873 }
852 874
853 static void mpeg1_encode_block(MpegEncContext *s, 875 static void mpeg1_encode_block(MpegEncContext *s,
854 DCTELEM *block, 876 DCTELEM *block,
855 int n) 877 int n)