summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-03-22 12:09:02 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-03-22 12:09:02 +0000
commit1984f6359ebaf2856b8254747255d154a2a2fe73 (patch)
treeee1e0d21653f2b167e1b379d0e4a064c31698e47 /libavcodec
parent65f7062dfaa6aeedb68b0d0b10cbe71ca5b8b2c9 (diff)
user setable quantizer bias
Originally committed as revision 1701 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h21
-rw-r--r--libavcodec/h263.c8
-rw-r--r--libavcodec/mjpeg.c1
-rw-r--r--libavcodec/mpeg12.c2
-rw-r--r--libavcodec/mpegvideo.c16
-rw-r--r--libavcodec/mpegvideo.h2
-rw-r--r--libavcodec/utils.c3
7 files changed, 38 insertions, 15 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 00b0a19e06..6977159e96 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -15,8 +15,8 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
-#define LIBAVCODEC_BUILD 4662
-#define LIBAVCODEC_BUILD_STR "4662"
+#define LIBAVCODEC_BUILD 4663
+#define LIBAVCODEC_BUILD_STR "4663"
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
@@ -1038,8 +1038,23 @@ typedef struct AVCodecContext {
* - decoding: set by lavc.
* @todo move this after frame_rate
*/
- int frame_rate_base;
+ int frame_rate_base;
+ /**
+ * intra quantizer bias.
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int intra_quant_bias;
+#define FF_DEFAULT_QUANT_BIAS 999999
+
+ /**
+ * inter quantizer bias.
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int inter_quant_bias;
+
} AVCodecContext;
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index 76a421a707..a054ebfb02 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -1484,14 +1484,6 @@ void h263_encode_init(MpegEncContext *s)
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
-
- 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
- }
}
/**
diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c
index d05f4cd72b..135066796f 100644
--- a/libavcodec/mjpeg.c
+++ b/libavcodec/mjpeg.c
@@ -251,7 +251,6 @@ int mjpeg_init(MpegEncContext *s)
s->min_qcoeff=-1023;
s->max_qcoeff= 1023;
- s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x
/* build all the huffman tables */
build_huffman_codes(m->huff_size_dc_luminance,
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 37d9243029..729b2f04f0 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -702,8 +702,6 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
s->fcode_tab= fcode_tab;
s->min_qcoeff=-255;
s->max_qcoeff= 255;
- s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
- s->inter_quant_bias= 0;
s->intra_ac_vlc_length=
s->inter_ac_vlc_length= uni_mpeg1_ac_vlc_len;
}
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index fd2f104495..46b44f3786 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -551,6 +551,22 @@ int MPV_encode_init(AVCodecContext *avctx)
s->progressive_sequence= !(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
+ if(s->codec_id==CODEC_ID_MJPEG){
+ s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x
+ s->inter_quant_bias= 0;
+ }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO){
+ 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
+ }
+
+ if(avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
+ s->intra_quant_bias= avctx->intra_quant_bias;
+ if(avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
+ s->inter_quant_bias= avctx->inter_quant_bias;
+
switch(avctx->codec->id) {
case CODEC_ID_MPEG1VIDEO:
s->out_format = FMT_MPEG1;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index ab2dd5176c..eb45fe7b70 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -360,7 +360,7 @@ typedef struct MpegEncContext {
uint16_t chroma_intra_matrix[64];
uint16_t inter_matrix[64];
uint16_t chroma_inter_matrix[64];
-#define QUANT_BIAS_SHIFT 4
+#define QUANT_BIAS_SHIFT 8
int intra_quant_bias; ///< bias for the quantizer
int inter_quant_bias; ///< bias for the quantizer
int min_qcoeff; ///< minimum encodable coefficient
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index d0fae978ca..037abdc00f 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -244,6 +244,9 @@ void avcodec_get_context_defaults(AVCodecContext *s){
s->release_buffer= avcodec_default_release_buffer;
s->get_format= avcodec_default_get_format;
s->me_subpel_quality=8;
+
+ s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
+ s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
}
/**