Revision 4e3269e8

View differences:

libavcodec/mpegvideo.c
1066 1066
{
1067 1067
    int i, j, level, last_non_zero, q;
1068 1068
    const int *qmat;
1069
    int minLevel, maxLevel;
1070

  
1071
    if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){
1072
	/* mpeg4 */
1073
        minLevel= -2048;
1074
	maxLevel= 2047;
1075
    }else if(s->out_format==FMT_MPEG1){
1076
	/* mpeg1 */
1077
        minLevel= -255;
1078
	maxLevel= 255;
1079
    }else{
1080
	/* h263 / msmpeg4 */
1081
        minLevel= -128;
1082
	maxLevel= 127;
1083
    }
1069 1084

  
1070 1085
    av_fdct (block);
1071 1086

  
......
1138 1153
               h263:  -128..127
1139 1154
               mpeg4: -2048..2047
1140 1155
            */
1141
            if (level > 127)
1142
                level = 127;
1143
            else if (level < -128)
1144
                level = -128;
1156
            if (level > maxLevel)
1157
                level = maxLevel;
1158
            else if (level < minLevel)
1159
                level = minLevel;
1145 1160
            block[j] = level;
1146 1161
            last_non_zero = i;
1147 1162
        } else {
......
1157 1172
{
1158 1173
    int i, j, level, last_non_zero, q;
1159 1174
    const int *qmat;
1175
    int minLevel, maxLevel;
1176

  
1177
    if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){
1178
	/* mpeg4 */
1179
        minLevel= -2048;
1180
	maxLevel= 2047;
1181
    }else if(s->out_format==FMT_MPEG1){
1182
	/* mpeg1 */
1183
        minLevel= -255;
1184
	maxLevel= 255;
1185
    }else{
1186
	/* h263 / msmpeg4 */
1187
        minLevel= -128;
1188
	maxLevel= 127;
1189
    }
1160 1190

  
1161 1191
    av_fdct (block);
1162 1192
    
......
1202 1232
               h263:  -128..127
1203 1233
               mpeg4: -2048..2047
1204 1234
            */
1205
            if (level > 127)
1206
                level = 127;
1207
            else if (level < -128)
1208
                level = -128;
1235
            if (level > maxLevel)
1236
                level = maxLevel;
1237
            else if (level < minLevel)
1238
                level = minLevel;
1209 1239
            block[j] = level;
1210 1240
            last_non_zero = i;
1211 1241
        } else {

Also available in: Unified diff