# HG changeset patch # User michaelni # Date 1028677875 0 # Node ID b1a191202f960ccd3e7fcd12f80b1824a9182844 # Parent 0c950f816d61ce935613da4c7a87a206b3837b93 mpeg4 mpeg quantizer encoding diff -r 0c950f816d61 -r b1a191202f96 avcodec.h --- a/avcodec.h Mon Aug 05 21:36:14 2002 +0000 +++ b/avcodec.h Tue Aug 06 23:51:15 2002 +0000 @@ -5,8 +5,8 @@ #define LIBAVCODEC_VERSION_INT 0x000406 #define LIBAVCODEC_VERSION "0.4.6" -#define LIBAVCODEC_BUILD 4618 -#define LIBAVCODEC_BUILD_STR "4618" +#define LIBAVCODEC_BUILD 4619 +#define LIBAVCODEC_BUILD_STR "4619" enum CodecID { CODEC_ID_NONE, @@ -278,6 +278,7 @@ int parse_only; /* decoding only: if true, only parsing is done (function avcodec_parse_frame()). The frame data is returned. Only MPEG codecs support this now. */ + int mpeg_quant; /* 0-> h263 quant 1-> mpeg quant */ //FIXME this should be reordered after kabis API is finished ... /* @@ -300,8 +301,6 @@ unsigned long int ul_res0,ul_res1,ul_res2,ul_res3,ul_res4,ul_res5, ul_res6,ul_res7,ul_res8,ul_res9,ul_res10,ul_res11,ul_res12; - unsigned int - ui_res0; unsigned short int us_res0,us_res1,us_res2,us_res3,us_res4,us_res5, us_res6,us_res7,us_res8,us_res9,us_res10,us_res11,us_res12; diff -r 0c950f816d61 -r b1a191202f96 h263.c --- a/h263.c Mon Aug 05 21:36:14 2002 +0000 +++ b/h263.c Tue Aug 06 23:51:15 2002 +0000 @@ -1122,10 +1122,13 @@ s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } - /* h263 type bias */ - //FIXME mpeg4 mpeg quantizer - s->intra_quant_bias=0; - s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x + if(s->mpeg_quant){ + s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x + s->inter_quant_bias= 0; + }else{ + s->intra_quant_bias=0; + s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x + } } static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n) @@ -1274,7 +1277,9 @@ put_bits(&s->pb, 2, s->vol_sprite_usage=0); /* sprite enable */ } put_bits(&s->pb, 1, 0); /* not 8 bit */ - put_bits(&s->pb, 1, 0); /* quant type= h263 style*/ + put_bits(&s->pb, 1, s->mpeg_quant); /* quant type= (0=h263 style)*/ + if(s->mpeg_quant) put_bits(&s->pb, 2, 0); /* no custom matrixes */ + if (vo_ver_id != 1) put_bits(&s->pb, 1, s->quarter_sample=0); put_bits(&s->pb, 1, 1); /* complexity estimation disable */ diff -r 0c950f816d61 -r b1a191202f96 i386/mpegvideo_mmx_template.c --- a/i386/mpegvideo_mmx_template.c Mon Aug 05 21:36:14 2002 +0000 +++ b/i386/mpegvideo_mmx_template.c Tue Aug 06 23:51:15 2002 +0000 @@ -82,7 +82,7 @@ qmat = s->q_inter_matrix16[qscale]; } - if(s->out_format == FMT_H263){ + if(s->out_format == FMT_H263 && s->mpeg_quant==0){ asm volatile( "movd %%eax, %%mm3 \n\t" // last_non_zero_p1 @@ -189,6 +189,7 @@ } if(s->mb_intra) temp_block[0]= level; //FIXME move afer permute + // last_non_zero_p1=64; /* permute for IDCT */ asm volatile( diff -r 0c950f816d61 -r b1a191202f96 mpegvideo.c --- a/mpegvideo.c Mon Aug 05 21:36:14 2002 +0000 +++ b/mpegvideo.c Tue Aug 06 23:51:15 2002 +0000 @@ -390,6 +390,7 @@ s->chroma_elim_threshold= avctx->chroma_elim_threshold; s->strict_std_compliance= avctx->strict_std_compliance; s->data_partitioning= avctx->flags & CODEC_FLAG_PART; + s->mpeg_quant= avctx->mpeg_quant; if (s->gop_size <= 1) { s->intra_only = 1; @@ -542,12 +543,16 @@ /* init default q matrix */ for(i=0;i<64;i++) { - if(s->out_format == FMT_H263) - s->intra_matrix[i] = ff_mpeg1_default_non_intra_matrix[i]; - else + if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){ + s->intra_matrix[i] = ff_mpeg4_default_intra_matrix[i]; + s->inter_matrix[i] = ff_mpeg4_default_non_intra_matrix[i]; + }else if(s->out_format == FMT_H263){ + s->intra_matrix[i] = + s->inter_matrix[i] = ff_mpeg1_default_non_intra_matrix[i]; + }else{ /* mpeg1 */ s->intra_matrix[i] = ff_mpeg1_default_intra_matrix[i]; - - s->inter_matrix[i] = ff_mpeg1_default_non_intra_matrix[i]; + s->inter_matrix[i] = ff_mpeg1_default_non_intra_matrix[i]; + } } /* precompute matrix */ diff -r 0c950f816d61 -r b1a191202f96 mpegvideo.h --- a/mpegvideo.h Mon Aug 05 21:36:14 2002 +0000 +++ b/mpegvideo.h Tue Aug 06 23:51:15 2002 +0000 @@ -521,6 +521,9 @@ extern UINT8 ff_mpeg4_y_dc_scale_table[32]; extern UINT8 ff_mpeg4_c_dc_scale_table[32]; +extern INT16 ff_mpeg4_default_intra_matrix[64]; +extern INT16 ff_mpeg4_default_non_intra_matrix[64]; + void h263_encode_mb(MpegEncContext *s, DCTELEM block[6][64], int motion_x, int motion_y);