Commit d790dac9 authored by michaelni's avatar michaelni

user setable quantizer bias


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@1701 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 12d32a79
...@@ -15,8 +15,8 @@ extern "C" { ...@@ -15,8 +15,8 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406 #define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6" #define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 4662 #define LIBAVCODEC_BUILD 4663
#define LIBAVCODEC_BUILD_STR "4662" #define LIBAVCODEC_BUILD_STR "4663"
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
...@@ -1038,8 +1038,23 @@ typedef struct AVCodecContext { ...@@ -1038,8 +1038,23 @@ typedef struct AVCodecContext {
* - decoding: set by lavc. * - decoding: set by lavc.
* @todo move this after frame_rate * @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; } AVCodecContext;
......
...@@ -1484,14 +1484,6 @@ void h263_encode_init(MpegEncContext *s) ...@@ -1484,14 +1484,6 @@ void h263_encode_init(MpegEncContext *s)
s->y_dc_scale_table= s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_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
}
} }
/** /**
......
...@@ -251,7 +251,6 @@ int mjpeg_init(MpegEncContext *s) ...@@ -251,7 +251,6 @@ int mjpeg_init(MpegEncContext *s)
s->min_qcoeff=-1023; s->min_qcoeff=-1023;
s->max_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 all the huffman tables */
build_huffman_codes(m->huff_size_dc_luminance, build_huffman_codes(m->huff_size_dc_luminance,
......
...@@ -702,8 +702,6 @@ void ff_mpeg1_encode_init(MpegEncContext *s) ...@@ -702,8 +702,6 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
s->fcode_tab= fcode_tab; s->fcode_tab= fcode_tab;
s->min_qcoeff=-255; s->min_qcoeff=-255;
s->max_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->intra_ac_vlc_length=
s->inter_ac_vlc_length= uni_mpeg1_ac_vlc_len; s->inter_ac_vlc_length= uni_mpeg1_ac_vlc_len;
} }
......
...@@ -551,6 +551,22 @@ int MPV_encode_init(AVCodecContext *avctx) ...@@ -551,6 +551,22 @@ int MPV_encode_init(AVCodecContext *avctx)
s->progressive_sequence= !(avctx->flags & CODEC_FLAG_INTERLACED_DCT); 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) { switch(avctx->codec->id) {
case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG1VIDEO:
s->out_format = FMT_MPEG1; s->out_format = FMT_MPEG1;
......
...@@ -360,7 +360,7 @@ typedef struct MpegEncContext { ...@@ -360,7 +360,7 @@ typedef struct MpegEncContext {
uint16_t chroma_intra_matrix[64]; uint16_t chroma_intra_matrix[64];
uint16_t inter_matrix[64]; uint16_t inter_matrix[64];
uint16_t chroma_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 intra_quant_bias; ///< bias for the quantizer
int inter_quant_bias; ///< bias for the quantizer int inter_quant_bias; ///< bias for the quantizer
int min_qcoeff; ///< minimum encodable coefficient int min_qcoeff; ///< minimum encodable coefficient
......
...@@ -244,6 +244,9 @@ void avcodec_get_context_defaults(AVCodecContext *s){ ...@@ -244,6 +244,9 @@ void avcodec_get_context_defaults(AVCodecContext *s){
s->release_buffer= avcodec_default_release_buffer; s->release_buffer= avcodec_default_release_buffer;
s->get_format= avcodec_default_get_format; s->get_format= avcodec_default_get_format;
s->me_subpel_quality=8; s->me_subpel_quality=8;
s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment