Commit 2ad1516a authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

idct permutation cleanup, idct can be selected per context now

fixing some threadunsafe code

Originally committed as revision 980 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent f9bb4bdf
......@@ -117,6 +117,7 @@ static int do_deinterlace = 0;
static int workaround_bugs = 0;
static int error_resilience = 0;
static int dct_algo = 0;
static int idct_algo = 0;
static int use_part = 0;
static int packet_size = 0;
......@@ -1392,6 +1393,12 @@ void opt_dct_algo(const char *arg)
dct_algo = atoi(arg);
}
void opt_idct_algo(const char *arg)
{
idct_algo = atoi(arg);
}
void opt_error_resilience(const char *arg)
{
error_resilience = atoi(arg);
......@@ -1750,6 +1757,7 @@ void opt_input_file(const char *filename)
rfps = ic->streams[i]->r_frame_rate;
enc->workaround_bugs = workaround_bugs;
enc->error_resilience = error_resilience;
enc->idct_algo= idct_algo;
if (enc->frame_rate != rfps) {
fprintf(stderr,"\nSeems that stream %d comes from film source: %2.2f->%2.2f\n",
i, (float)enc->frame_rate / FRAME_RATE_BASE,
......@@ -1922,6 +1930,7 @@ void opt_output_file(const char *filename)
video_enc->i_quant_offset = video_i_qoffset;
video_enc->b_quant_offset = video_b_qoffset;
video_enc->dct_algo = dct_algo;
video_enc->idct_algo = idct_algo;
if(packet_size){
video_enc->rtp_mode= 1;
video_enc->rtp_payload_size= packet_size;
......@@ -2287,6 +2296,7 @@ const OptionDef options[] = {
{ "me", HAS_ARG | OPT_EXPERT, {(void*)opt_motion_estimation}, "set motion estimation method",
"method" },
{ "dct_algo", HAS_ARG | OPT_EXPERT, {(void*)opt_dct_algo}, "set dct algo", "algo" },
{ "idct_algo", HAS_ARG | OPT_EXPERT, {(void*)opt_idct_algo}, "set idct algo", "algo" },
{ "er", HAS_ARG | OPT_EXPERT, {(void*)opt_error_resilience}, "set error resilience", "" },
{ "bf", HAS_ARG | OPT_EXPERT, {(void*)opt_b_frames}, "use 'frames' B frames (only MPEG-4)", "frames" },
{ "hq", OPT_BOOL | OPT_EXPERT, {(void*)&use_hq}, "activate high quality settings" },
......
......@@ -5,8 +5,8 @@
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 4628
#define LIBAVCODEC_BUILD_STR "4628"
#define LIBAVCODEC_BUILD 4629
#define LIBAVCODEC_BUILD_STR "4629"
enum CodecID {
CODEC_ID_NONE,
......@@ -684,6 +684,21 @@ typedef struct AVCodecContext {
*/
int fourcc;
/**
* idct algorithm, see FF_IDCT_* below
* encoding: set by user
* decoding: set by user
*/
int idct_algo;
#define FF_IDCT_AUTO 0
#define FF_IDCT_INT 1
#define FF_IDCT_SIMPLE 2
#define FF_IDCT_SIMPLEMMX 3
#define FF_IDCT_LIBMPEG2MMX 4
#define FF_IDCT_PS2 5
#define FF_IDCT_MLIB 6
#define FF_IDCT_ARM 7
//FIXME this should be reordered after kabis API is finished ...
//TODO kill kabi
/*
......
......@@ -932,6 +932,22 @@ static inline int ff_get_fourcc(char *s){
return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24);
}
#ifdef ARCH_X86
#define MASK_ABS(mask, level)\
asm volatile(\
"cdq \n\t"\
"xorl %1, %0 \n\t"\
"subl %1, %0 \n\t"\
: "+a" (level), "=&d" (mask)\
);
#else
#define MASK_ABS(mask, level)\
mask= level>>31;\
level= (level^mask)-mask;
#endif
#if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT)
#define COPY3_IF_LT(x,y,a,b,c,d)\
asm volatile (\
......
......@@ -20,11 +20,7 @@
*/
#include "avcodec.h"
#include "dsputil.h"
#include "simple_idct.h"
void (*ff_idct)(DCTELEM *block);
void (*ff_idct_put)(UINT8 *dest, int line_size, DCTELEM *block);
void (*ff_idct_add)(UINT8 *dest, int line_size, DCTELEM *block);
void (*get_pixels)(DCTELEM *block, const UINT8 *pixels, int line_size);
void (*diff_pixels)(DCTELEM *block, const UINT8 *s1, const UINT8 *s2, int stride);
void (*put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
......@@ -49,16 +45,11 @@ int ff_bit_exact=0;
UINT8 cropTbl[256 + 2 * MAX_NEG_CROP];
UINT32 squareTbl[512];
extern INT16 ff_mpeg1_default_intra_matrix[64];
extern INT16 ff_mpeg1_default_non_intra_matrix[64];
extern INT16 ff_mpeg4_default_intra_matrix[64];
extern INT16 ff_mpeg4_default_non_intra_matrix[64];
UINT8 zigzag_direct[64] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
const UINT8 ff_zigzag_direct[64] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34,
27, 20, 13, 6, 7, 14, 21, 28,
27, 20, 13, 6, 7, 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36,
29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46,
......@@ -68,11 +59,8 @@ UINT8 zigzag_direct[64] = {
/* not permutated inverse zigzag_direct + 1 for MMX quantizer */
UINT16 __align8 inv_zigzag_direct16[64];
/* not permutated zigzag_direct for MMX quantizer */
UINT8 zigzag_direct_noperm[64];
UINT8 ff_alternate_horizontal_scan[64] = {
0, 1, 2, 3, 8, 9, 16, 17,
const UINT8 ff_alternate_horizontal_scan[64] = {
0, 1, 2, 3, 8, 9, 16, 17,
10, 11, 4, 5, 6, 7, 15, 14,
13, 12, 19, 18, 24, 25, 32, 33,
26, 27, 20, 21, 22, 23, 28, 29,
......@@ -82,8 +70,8 @@ UINT8 ff_alternate_horizontal_scan[64] = {
52, 53, 54, 55, 60, 61, 62, 63,
};
UINT8 ff_alternate_vertical_scan[64] = {
0, 8, 16, 24, 1, 9, 2, 10,
const UINT8 ff_alternate_vertical_scan[64] = {
0, 8, 16, 24, 1, 9, 2, 10,
17, 25, 32, 40, 48, 56, 57, 49,
41, 33, 26, 18, 3, 11, 4, 12,
19, 27, 34, 42, 50, 58, 35, 43,
......@@ -93,21 +81,6 @@ UINT8 ff_alternate_vertical_scan[64] = {
38, 46, 54, 62, 39, 47, 55, 63,
};
#ifdef SIMPLE_IDCT
/* Input permutation for the simple_idct_mmx */
static UINT8 simple_mmx_permutation[64]={
0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
};
#endif
/* a*inverse[b]>>32 == a/b for all 0<=a<=65536 && 2<=b<=255 */
UINT32 inverse[256]={
0, 4294967295U,2147483648U,1431655766, 1073741824, 858993460, 715827883, 613566757,
......@@ -144,24 +117,6 @@ UINT32 inverse[256]={
17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010,
};
/* used to skip zeros at the end */
UINT8 zigzag_end[64];
UINT8 permutation[64];
//UINT8 invPermutation[64];
static void build_zigzag_end(void)
{
int lastIndex;
int lastIndexAfterPerm=0;
for(lastIndex=0; lastIndex<64; lastIndex++)
{
if(zigzag_direct[lastIndex] > lastIndexAfterPerm)
lastIndexAfterPerm= zigzag_direct[lastIndex];
zigzag_end[lastIndex]= lastIndexAfterPerm + 1;
}
}
int pix_sum_c(UINT8 * pix, int line_size)
{
int s, i, j;
......@@ -1540,65 +1495,24 @@ int pix_abs8x8_xy2_c(UINT8 *pix1, UINT8 *pix2, int line_size)
/* permute block according so that it corresponds to the MMX idct
order */
#ifdef SIMPLE_IDCT
/* general permutation, but perhaps slightly slower */
void block_permute(INT16 *block)
void block_permute(INT16 *block, UINT8 *permutation)
{
int i;
INT16 temp[64];
for(i=0; i<64; i++) temp[ block_permute_op(i) ] = block[i];
for(i=0; i<64; i++) temp[ permutation[i] ] = block[i];
for(i=0; i<64; i++) block[i] = temp[i];
}
#else
void block_permute(INT16 *block)
{
int tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
int i;
for(i=0;i<8;i++) {
tmp1 = block[1];
tmp2 = block[2];
tmp3 = block[3];
tmp4 = block[4];
tmp5 = block[5];
tmp6 = block[6];
block[1] = tmp2;
block[2] = tmp4;
block[3] = tmp6;
block[4] = tmp1;
block[5] = tmp3;
block[6] = tmp5;
block += 8;
}
}
#endif
void clear_blocks_c(DCTELEM *blocks)
{
memset(blocks, 0, sizeof(DCTELEM)*6*64);
}
/* XXX: those functions should be suppressed ASAP when all IDCTs are
converted */
void gen_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
{
ff_idct (block);
put_pixels_clamped(block, dest, line_size);
}
void gen_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
{
ff_idct (block);
add_pixels_clamped(block, dest, line_size);
}
void dsputil_init(void)
{
int i, j;
int use_permuted_idct;
for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i;
for(i=0;i<MAX_NEG_CROP;i++) {
......@@ -1610,11 +1524,6 @@ void dsputil_init(void)
squareTbl[i] = (i - 256) * (i - 256);
}
#ifdef SIMPLE_IDCT
ff_idct = NULL;
#else
ff_idct = j_rev_dct;
#endif
get_pixels = get_pixels_c;
diff_pixels = diff_pixels_c;
put_pixels_clamped = put_pixels_clamped_c;
......@@ -1633,8 +1542,6 @@ void dsputil_init(void)
pix_abs8x8_y2 = pix_abs8x8_y2_c;
pix_abs8x8_xy2 = pix_abs8x8_xy2_c;
use_permuted_idct = 1;
#ifdef HAVE_MMX
dsputil_init_mmx();
#endif
......@@ -1643,61 +1550,18 @@ void dsputil_init(void)
#endif
#ifdef HAVE_MLIB
dsputil_init_mlib();
use_permuted_idct = 0;
#endif
#ifdef ARCH_ALPHA
dsputil_init_alpha();
use_permuted_idct = 0;
#endif
#ifdef ARCH_POWERPC
dsputil_init_ppc();
#endif
#ifdef HAVE_MMI
dsputil_init_mmi();
use_permuted_idct = 0;
#endif
#ifdef SIMPLE_IDCT
if (ff_idct == NULL) {
ff_idct_put = simple_idct_put;
ff_idct_add = simple_idct_add;
use_permuted_idct=0;
}
#endif
if(ff_idct != NULL) {
ff_idct_put = gen_idct_put;
ff_idct_add = gen_idct_add;
}
if(use_permuted_idct)
#ifdef SIMPLE_IDCT
for(i=0; i<64; i++) permutation[i]= simple_mmx_permutation[i];
#else
for(i=0; i<64; i++) permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
#endif
else
for(i=0; i<64; i++) permutation[i]=i;
for(i=0; i<64; i++) inv_zigzag_direct16[zigzag_direct[i]]= i+1;
for(i=0; i<64; i++) zigzag_direct_noperm[i]= zigzag_direct[i];
if (use_permuted_idct) {
/* permute for IDCT */
for(i=0;i<64;i++) {
j = zigzag_direct[i];
zigzag_direct[i] = block_permute_op(j);
j = ff_alternate_horizontal_scan[i];
ff_alternate_horizontal_scan[i] = block_permute_op(j);
j = ff_alternate_vertical_scan[i];
ff_alternate_vertical_scan[i] = block_permute_op(j);
}
block_permute(ff_mpeg1_default_intra_matrix);
block_permute(ff_mpeg1_default_non_intra_matrix);
block_permute(ff_mpeg4_default_intra_matrix);
block_permute(ff_mpeg4_default_non_intra_matrix);
}
build_zigzag_end();
for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
}
/* remove any non bit exact operation (testing purpose) */
......
......@@ -34,12 +34,9 @@ void j_rev_dct (DCTELEM *data);
void ff_fdct_mmx(DCTELEM *block);
/* encoding scans */
extern UINT8 ff_alternate_horizontal_scan[64];
extern UINT8 ff_alternate_vertical_scan[64];
extern UINT8 zigzag_direct[64];
/* permutation table */
extern UINT8 permutation[64];
extern const UINT8 ff_alternate_horizontal_scan[64];
extern const UINT8 ff_alternate_vertical_scan[64];
extern const UINT8 ff_zigzag_direct[64];
/* pixel operations */
#define MAX_NEG_CROP 384
......@@ -61,9 +58,6 @@ i (michael) didnt check them, these are just the alignents which i think could b
*/
/* pixel ops : interface with DCT */
extern void (*ff_idct)(DCTELEM *block/*align 16*/);
extern void (*ff_idct_put)(UINT8 *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
extern void (*ff_idct_add)(UINT8 *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
extern void (*get_pixels)(DCTELEM *block/*align 16*/, const UINT8 *pixels/*align 8*/, int line_size);
extern void (*diff_pixels)(DCTELEM *block/*align 16*/, const UINT8 *s1/*align 8*/, const UINT8 *s2/*align 8*/, int stride);
extern void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, UINT8 *pixels/*align 8*/, int line_size);
......@@ -119,12 +113,7 @@ int pix_abs16x16_x2_c(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_y2_c(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_xy2_c(UINT8 *blk1, UINT8 *blk2, int lx);
static inline int block_permute_op(int j)
{
return permutation[j];
}
void block_permute(INT16 *block);
void block_permute(INT16 *block, UINT8 *permutation);
#if defined(HAVE_MMX)
......
......@@ -287,19 +287,19 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
if(s->mb_y==0 || s->qscale == s->qscale_table[xy] || n==2 || n==3){
/* same qscale */
for(i=1; i<8; i++){
const int level= block[n][block_permute_op(i )];
const int level= block[n][s->idct_permutation[i ]];
score0+= ABS(level);
score1+= ABS(level - ac_val[i+8]);
ac_val1[i ]= block[n][block_permute_op(i<<3)];
ac_val1[i ]= block[n][s->idct_permutation[i<<3]];
ac_val1[i+8]= level;
}
}else{
/* different qscale, we must rescale */
for(i=1; i<8; i++){
const int level= block[n][block_permute_op(i )];
const int level= block[n][s->idct_permutation[i ]];
score0+= ABS(level);
score1+= ABS(level - ROUNDED_DIV(ac_val[i + 8]*s->qscale_table[xy], s->qscale));
ac_val1[i ]= block[n][block_permute_op(i<<3)];
ac_val1[i ]= block[n][s->idct_permutation[i<<3]];
ac_val1[i+8]= level;
}
}
......@@ -310,20 +310,20 @@ static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int d
if(s->mb_x==0 || s->qscale == s->qscale_table[xy] || n==1 || n==3){
/* same qscale */
for(i=1; i<8; i++){
const int level= block[n][block_permute_op(i<<3)];
const int level= block[n][s->idct_permutation[i<<3]];
score0+= ABS(level);
score1+= ABS(level - ac_val[i]);
ac_val1[i ]= level;
ac_val1[i+8]= block[n][block_permute_op(i )];
ac_val1[i+8]= block[n][s->idct_permutation[i ]];
}
}else{
/* different qscale, we must rescale */
for(i=1; i<8; i++){
const int level= block[n][block_permute_op(i<<3)];
const int level= block[n][s->idct_permutation[i<<3]];
score0+= ABS(level);
score1+= ABS(level - ROUNDED_DIV(ac_val[i]*s->qscale_table[xy], s->qscale));
ac_val1[i ]= level;
ac_val1[i+8]= block[n][block_permute_op(i )];
ac_val1[i+8]= block[n][s->idct_permutation[i ]];
}
}
}
......@@ -519,7 +519,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
/* encode each block */
for (i = 0; i < 6; i++) {
mpeg4_encode_block(s, block[i], i, 0, zigzag_direct, NULL, &s->pb);
mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, NULL, &s->pb);
}
if(interleaved_stats){
......@@ -637,7 +637,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
/* encode each block */
for (i = 0; i < 6; i++) {
mpeg4_encode_block(s, block[i], i, 0, zigzag_direct, NULL, tex_pb);
mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, NULL, tex_pb);
}
if(interleaved_stats){
......@@ -674,8 +674,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
int last_index;
mpeg4_inv_pred_ac(s, block[i], i, dir[i]);
if (dir[i]==0) st = ff_alternate_vertical_scan; /* left */
else st = ff_alternate_horizontal_scan; /* top */
if (dir[i]==0) st = s->intra_v_scantable.permutated; /* left */
else st = s->intra_h_scantable.permutated; /* top */
for(last_index=63; last_index>=0; last_index--) //FIXME optimize
if(block[i][st[last_index]]) break;
......@@ -685,7 +685,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
}else{
for(i=0; i<6; i++)
scan_table[i]= zigzag_direct;
scan_table[i]= s->intra_scantable.permutated;
}
/* compute cbp */
......@@ -746,10 +746,10 @@ void mpeg4_encode_mb(MpegEncContext * s,
if(dir[i]){
for(j=1; j<8; j++)
block[i][block_permute_op(j )]= ac_val[j+8];
block[i][s->idct_permutation[j ]]= ac_val[j+8];
}else{
for(j=1; j<8; j++)
block[i][block_permute_op(j<<3)]= ac_val[j ];
block[i][s->idct_permutation[j<<3]]= ac_val[j ];
}
s->block_last_index[i]= zigzag_last_index[i];
}
......@@ -974,7 +974,7 @@ void h263_pred_acdc(MpegEncContext * s, INT16 *block, int n)
if (a != 1024) {
ac_val -= 16;
for(i=1;i<8;i++) {
block[block_permute_op(i*8)] += ac_val[i];
block[s->idct_permutation[i<<3]] += ac_val[i];
}
pred_dc = a;
}
......@@ -983,7 +983,7 @@ void h263_pred_acdc(MpegEncContext * s, INT16 *block, int n)
if (c != 1024) {
ac_val -= 16 * wrap;
for(i=1;i<8;i++) {
block[block_permute_op(i)] += ac_val[i + 8];
block[s->idct_permutation[i ]] += ac_val[i + 8];
}
pred_dc = c;
}
......@@ -1011,10 +1011,10 @@ void h263_pred_acdc(MpegEncContext * s, INT16 *block, int n)
/* left copy */
for(i=1;i<8;i++)
ac_val1[i] = block[block_permute_op(i * 8)];
ac_val1[i ] = block[s->idct_permutation[i<<3]];
/* top copy */
for(i=1;i<8;i++)
ac_val1[8 + i] = block[block_permute_op(i)];
ac_val1[8 + i] = block[s->idct_permutation[i ]];
}
INT16 *h263_pred_motion(MpegEncContext * s, int block,
......@@ -1425,7 +1425,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
last_index = s->block_last_index[n];
last_non_zero = i - 1;
for (; i <= last_index; i++) {
j = zigzag_direct[i];
j = s->intra_scantable.permutated[i];
level = block[j];
if (level) {
run = i - last_non_zero - 1;
......@@ -1710,12 +1710,12 @@ void mpeg4_pred_ac(MpegEncContext * s, INT16 *block, int n,
if(s->mb_x==0 || s->qscale == s->qscale_table[xy] || n==1 || n==3){
/* same qscale */
for(i=1;i<8;i++) {
block[block_permute_op(i*8)] += ac_val[i];
block[s->idct_permutation[i<<3]] += ac_val[i];
}
}else{
/* different qscale, we must rescale */
for(i=1;i<8;i++) {
block[block_permute_op(i*8)] += ROUNDED_DIV(ac_val[i]*s->qscale_table[xy], s->qscale);
block[s->idct_permutation[i<<3]] += ROUNDED_DIV(ac_val[i]*s->qscale_table[xy], s->qscale);
}
}
} else {
......@@ -1726,23 +1726,23 @@ void mpeg4_pred_ac(MpegEncContext * s, INT16 *block, int n,
if(s->mb_y==0 || s->qscale == s->qscale_table[xy] || n==2 || n==3){
/* same qscale */
for(i=1;i<8;i++) {
block[block_permute_op(i)] += ac_val[i + 8];
block[s->idct_permutation[i]] += ac_val[i + 8];
}
}else{
/* different qscale, we must rescale */
for(i=1;i<8;i++) {
block[block_permute_op(i)] += ROUNDED_DIV(ac_val[i + 8]*s->qscale_table[xy], s->qscale);
block[s->idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8]*s->qscale_table[xy], s->qscale);
}
}
}
}
/* left copy */
for(i=1;i<8;i++)
ac_val1[i] = block[block_permute_op(i * 8)];
ac_val1[i ] = block[s->idct_permutation[i<<3]];
/* top copy */
for(i=1;i<8;i++)
ac_val1[8 + i] = block[block_permute_op(i)];
ac_val1[8 + i] = block[s->idct_permutation[i ]];
}
......@@ -1762,12 +1762,12 @@ static void mpeg4_inv_pred_ac(MpegEncContext * s, INT16 *block, int n,
if(s->mb_x==0 || s->qscale == s->qscale_table[xy] || n==1 || n==3){
/* same qscale */
for(i=1;i<8;i++) {
block[block_permute_op(i*8)] -= ac_val[i];
block[s->idct_permutation[i<<3]] -= ac_val[i];
}
}else{
/* different qscale, we must rescale */
for(i=1;i<8;i++) {
block[block_permute_op(i*8)] -= ROUNDED_DIV(ac_val[i]*s->qscale_table[xy], s->qscale);
block[s->idct_permutation[i<<3]] -= ROUNDED_DIV(ac_val[i]*s->qscale_table[xy], s->qscale);
}
}
} else {
......@@ -1777,12 +1777,12 @@ static void mpeg4_inv_pred_ac(MpegEncContext * s, INT16 *block, int n,
if(s->mb_y==0 || s->qscale == s