summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2002-08-06 23:51:15 +0000
committerMichael Niedermayer <michaelni@gmx.at>2002-08-06 23:51:15 +0000
commit87f8cab45b66712c23f861661afb97739f1fd8f5 (patch)
tree2f30abe9667c4da38a0d0029281ceba4424fe973 /libavcodec
parent508abacadb4249cd0c2c195cff117d8a96b2936f (diff)
mpeg4 mpeg quantizer encoding
Originally committed as revision 844 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h7
-rw-r--r--libavcodec/h263.c15
-rw-r--r--libavcodec/i386/mpegvideo_mmx_template.c3
-rw-r--r--libavcodec/mpegvideo.c15
-rw-r--r--libavcodec/mpegvideo.h3
5 files changed, 28 insertions, 15 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 641cf15216..7dbcc46aff 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -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;
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index 5587f74e92..2fd90e9ec9 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -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 */
diff --git a/libavcodec/i386/mpegvideo_mmx_template.c b/libavcodec/i386/mpegvideo_mmx_template.c
index aed537a23b..d84f253013 100644
--- a/libavcodec/i386/mpegvideo_mmx_template.c
+++ b/libavcodec/i386/mpegvideo_mmx_template.c
@@ -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(
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index f08ff6f9eb..320e2e4a82 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -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 */
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index b88ffcd594..0f4983f495 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -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);