Browse Source

mpeg4 mpeg quantizer encoding

Originally committed as revision 844 to svn://svn.ffmpeg.org/ffmpeg/trunk
tags/v0.5
Michael Niedermayer 23 years ago
parent
commit
87f8cab45b
5 changed files with 28 additions and 15 deletions
  1. +3
    -4
      libavcodec/avcodec.h
  2. +10
    -5
      libavcodec/h263.c
  3. +2
    -1
      libavcodec/i386/mpegvideo_mmx_template.c
  4. +10
    -5
      libavcodec/mpegvideo.c
  5. +3
    -0
      libavcodec/mpegvideo.h

+ 3
- 4
libavcodec/avcodec.h View File

@@ -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 @@ typedef struct AVCodecContext {
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 @@ typedef struct AVCodecContext {
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;


+ 10
- 5
libavcodec/h263.c View File

@@ -1122,10 +1122,13 @@ void h263_encode_init(MpegEncContext *s)
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 @@ static void mpeg4_encode_vol_header(MpegEncContext * s)
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 */


+ 2
- 1
libavcodec/i386/mpegvideo_mmx_template.c View File

@@ -82,7 +82,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
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 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
}

if(s->mb_intra) temp_block[0]= level; //FIXME move afer permute
// last_non_zero_p1=64;
/* permute for IDCT */
asm volatile(


+ 10
- 5
libavcodec/mpegvideo.c View File

@@ -390,6 +390,7 @@ int MPV_encode_init(AVCodecContext *avctx)
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 @@ int MPV_encode_init(AVCodecContext *avctx)
/* 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 */


+ 3
- 0
libavcodec/mpegvideo.h View File

@@ -521,6 +521,9 @@ static inline int get_rl_index(const RLTable *rl, int last, int run, int level)

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);


Loading…
Cancel
Save