Commit f68ad060 authored by arpi_esp's avatar arpi_esp

(commit by michael)

quantizer range bugfix (mpeg1 & mpeg4 encoding)


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@277 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent e77ac108
...@@ -1066,6 +1066,21 @@ static int dct_quantize(MpegEncContext *s, ...@@ -1066,6 +1066,21 @@ static int dct_quantize(MpegEncContext *s,
{ {
int i, j, level, last_non_zero, q; int i, j, level, last_non_zero, q;
const int *qmat; const int *qmat;
int minLevel, maxLevel;
if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){
/* mpeg4 */
minLevel= -2048;
maxLevel= 2047;
}else if(s->out_format==FMT_MPEG1){
/* mpeg1 */
minLevel= -255;
maxLevel= 255;
}else{
/* h263 / msmpeg4 */
minLevel= -128;
maxLevel= 127;
}
av_fdct (block); av_fdct (block);
...@@ -1138,10 +1153,10 @@ static int dct_quantize(MpegEncContext *s, ...@@ -1138,10 +1153,10 @@ static int dct_quantize(MpegEncContext *s,
h263: -128..127 h263: -128..127
mpeg4: -2048..2047 mpeg4: -2048..2047
*/ */
if (level > 127) if (level > maxLevel)
level = 127; level = maxLevel;
else if (level < -128) else if (level < minLevel)
level = -128; level = minLevel;
block[j] = level; block[j] = level;
last_non_zero = i; last_non_zero = i;
} else { } else {
...@@ -1157,6 +1172,21 @@ static int dct_quantize_mmx(MpegEncContext *s, ...@@ -1157,6 +1172,21 @@ static int dct_quantize_mmx(MpegEncContext *s,
{ {
int i, j, level, last_non_zero, q; int i, j, level, last_non_zero, q;
const int *qmat; const int *qmat;
int minLevel, maxLevel;
if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){
/* mpeg4 */
minLevel= -2048;
maxLevel= 2047;
}else if(s->out_format==FMT_MPEG1){
/* mpeg1 */
minLevel= -255;
maxLevel= 255;
}else{
/* h263 / msmpeg4 */
minLevel= -128;
maxLevel= 127;
}
av_fdct (block); av_fdct (block);
...@@ -1202,10 +1232,10 @@ static int dct_quantize_mmx(MpegEncContext *s, ...@@ -1202,10 +1232,10 @@ static int dct_quantize_mmx(MpegEncContext *s,
h263: -128..127 h263: -128..127
mpeg4: -2048..2047 mpeg4: -2048..2047
*/ */
if (level > 127) if (level > maxLevel)
level = 127; level = maxLevel;
else if (level < -128) else if (level < minLevel)
level = -128; level = minLevel;
block[j] = level; block[j] = level;
last_non_zero = i; last_non_zero = i;
} else { } else {
......
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