2002-01-27 13:30:18 +00:00
|
|
|
/*
|
2002-05-25 22:45:33 +00:00
|
|
|
* MPEG video MMX templates
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
*
|
2006-10-07 15:30:46 +00:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2002-05-25 22:45:33 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 15:30:46 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2002-05-25 22:45:33 +00:00
|
|
|
*
|
2006-10-07 15:30:46 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2002-05-25 22:45:33 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2006-10-07 15:30:46 +00:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2006-01-12 22:43:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-05-25 22:45:33 +00:00
|
|
|
*/
|
2007-05-12 05:55:09 +00:00
|
|
|
|
|
|
|
#undef MMREG_WIDTH
|
|
|
|
#undef MM
|
|
|
|
#undef MOVQ
|
2002-01-27 13:30:18 +00:00
|
|
|
#undef SPREADW
|
|
|
|
#undef PMAXW
|
2006-07-02 21:53:30 +00:00
|
|
|
#undef PMAX
|
2007-05-12 05:55:09 +00:00
|
|
|
#undef SAVE_SIGN
|
|
|
|
#undef RESTORE_SIGN
|
|
|
|
|
|
|
|
#if defined(HAVE_SSE2)
|
|
|
|
#define MMREG_WIDTH "16"
|
|
|
|
#define MM "%%xmm"
|
|
|
|
#define MOVQ "movdqa"
|
|
|
|
#define SPREADW(a) \
|
|
|
|
"pshuflw $0, "a", "a" \n\t"\
|
|
|
|
"punpcklwd "a", "a" \n\t"
|
|
|
|
#define PMAXW(a,b) "pmaxsw "a", "b" \n\t"
|
2005-09-21 21:17:09 +00:00
|
|
|
#define PMAX(a,b) \
|
2007-05-12 05:55:09 +00:00
|
|
|
"movhlps "a", "b" \n\t"\
|
2005-12-22 01:10:11 +00:00
|
|
|
PMAXW(b, a)\
|
2007-05-12 05:55:09 +00:00
|
|
|
"pshuflw $0x0E, "a", "b" \n\t"\
|
|
|
|
PMAXW(b, a)\
|
|
|
|
"pshuflw $0x01, "a", "b" \n\t"\
|
|
|
|
PMAXW(b, a)
|
|
|
|
#else
|
|
|
|
#define MMREG_WIDTH "8"
|
|
|
|
#define MM "%%mm"
|
|
|
|
#define MOVQ "movq"
|
|
|
|
#if defined(HAVE_MMX2)
|
|
|
|
#define SPREADW(a) "pshufw $0, "a", "a" \n\t"
|
|
|
|
#define PMAXW(a,b) "pmaxsw "a", "b" \n\t"
|
|
|
|
#define PMAX(a,b) \
|
|
|
|
"pshufw $0x0E, "a", "b" \n\t"\
|
|
|
|
PMAXW(b, a)\
|
|
|
|
"pshufw $0x01, "a", "b" \n\t"\
|
2005-12-22 01:10:11 +00:00
|
|
|
PMAXW(b, a)
|
2002-01-27 13:30:18 +00:00
|
|
|
#else
|
|
|
|
#define SPREADW(a) \
|
2007-05-12 05:55:09 +00:00
|
|
|
"punpcklwd "a", "a" \n\t"\
|
|
|
|
"punpcklwd "a", "a" \n\t"
|
2002-01-27 13:30:18 +00:00
|
|
|
#define PMAXW(a,b) \
|
2007-05-12 05:55:09 +00:00
|
|
|
"psubusw "a", "b" \n\t"\
|
|
|
|
"paddw "a", "b" \n\t"
|
2005-09-21 21:17:09 +00:00
|
|
|
#define PMAX(a,b) \
|
2007-05-12 05:55:09 +00:00
|
|
|
"movq "a", "b" \n\t"\
|
|
|
|
"psrlq $32, "a" \n\t"\
|
2005-12-22 01:10:11 +00:00
|
|
|
PMAXW(b, a)\
|
2007-05-12 05:55:09 +00:00
|
|
|
"movq "a", "b" \n\t"\
|
|
|
|
"psrlq $16, "a" \n\t"\
|
2005-12-22 01:10:11 +00:00
|
|
|
PMAXW(b, a)
|
2005-09-21 21:17:09 +00:00
|
|
|
|
2002-01-27 13:30:18 +00:00
|
|
|
#endif
|
2007-05-12 05:55:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SSSE3
|
|
|
|
#define SAVE_SIGN(a,b) \
|
|
|
|
"movdqa "b", "a" \n\t"\
|
|
|
|
"pabsw "b", "b" \n\t"
|
|
|
|
#define RESTORE_SIGN(a,b) \
|
|
|
|
"psignw "a", "b" \n\t"
|
|
|
|
#else
|
|
|
|
#define SAVE_SIGN(a,b) \
|
|
|
|
"pxor "a", "a" \n\t"\
|
|
|
|
"pcmpgtw "b", "a" \n\t" /* block[i] <= 0 ? 0xFF : 0x00 */\
|
|
|
|
"pxor "a", "b" \n\t"\
|
|
|
|
"psubw "a", "b" \n\t" /* ABS(block[i]) */
|
|
|
|
#define RESTORE_SIGN(a,b) \
|
|
|
|
"pxor "a", "b" \n\t"\
|
|
|
|
"psubw "a", "b" \n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
|
|
|
|
#endif
|
2002-01-27 13:30:18 +00:00
|
|
|
|
|
|
|
static int RENAME(dct_quantize)(MpegEncContext *s,
|
|
|
|
DCTELEM *block, int n,
|
2002-04-27 12:30:26 +00:00
|
|
|
int qscale, int *overflow)
|
2002-01-27 13:30:18 +00:00
|
|
|
{
|
2004-10-11 02:19:29 +00:00
|
|
|
long last_non_zero_p1;
|
2007-06-12 18:50:50 +00:00
|
|
|
int level=0, q; //=0 is cuz gcc says uninitialized ...
|
2003-02-11 16:35:48 +00:00
|
|
|
const uint16_t *qmat, *bias;
|
2007-05-12 05:55:09 +00:00
|
|
|
DECLARE_ALIGNED_16(int16_t, temp_block[64]);
|
2005-12-17 18:14:38 +00:00
|
|
|
|
2003-08-15 19:58:27 +00:00
|
|
|
assert((7&(int)(&temp_block[0])) == 0); //did gcc align it correctly?
|
2002-01-27 13:30:18 +00:00
|
|
|
|
2002-08-29 23:55:32 +00:00
|
|
|
//s->fdct (block);
|
2007-06-12 09:29:25 +00:00
|
|
|
RENAMEl(ff_fdct) (block); //cannot be anything else ...
|
2002-04-27 12:30:26 +00:00
|
|
|
|
2003-11-02 23:19:47 +00:00
|
|
|
if(s->dct_error_sum)
|
2004-01-02 22:29:08 +00:00
|
|
|
s->denoise_dct(s, block);
|
2003-11-02 23:19:47 +00:00
|
|
|
|
2002-01-27 13:30:18 +00:00
|
|
|
if (s->mb_intra) {
|
|
|
|
int dummy;
|
|
|
|
if (n < 4)
|
2002-09-02 16:56:29 +00:00
|
|
|
q = s->y_dc_scale;
|
2002-01-27 13:30:18 +00:00
|
|
|
else
|
2002-09-02 16:56:29 +00:00
|
|
|
q = s->c_dc_scale;
|
2002-01-27 13:30:18 +00:00
|
|
|
/* note: block[0] is assumed to be positive */
|
2002-05-02 04:39:45 +00:00
|
|
|
if (!s->h263_aic) {
|
2002-01-27 13:30:18 +00:00
|
|
|
#if 1
|
2002-04-27 12:30:26 +00:00
|
|
|
asm volatile (
|
2005-12-22 01:10:11 +00:00
|
|
|
"mul %%ecx \n\t"
|
|
|
|
: "=d" (level), "=a"(dummy)
|
2006-11-12 18:49:36 +00:00
|
|
|
: "a" ((block[0]>>2) + q), "c" (ff_inverse[q<<1])
|
2002-04-27 12:30:26 +00:00
|
|
|
);
|
2002-01-27 13:30:18 +00:00
|
|
|
#else
|
2002-04-27 12:30:26 +00:00
|
|
|
asm volatile (
|
2005-12-22 01:10:11 +00:00
|
|
|
"xorl %%edx, %%edx \n\t"
|
|
|
|
"divw %%cx \n\t"
|
|
|
|
"movzwl %%ax, %%eax \n\t"
|
|
|
|
: "=a" (level)
|
|
|
|
: "a" ((block[0]>>2) + q), "c" (q<<1)
|
|
|
|
: "%edx"
|
2002-04-27 12:30:26 +00:00
|
|
|
);
|
2002-01-27 13:30:18 +00:00
|
|
|
#endif
|
2002-05-02 04:39:45 +00:00
|
|
|
} else
|
|
|
|
/* For AIC we skip quant/dequant of INTRADC */
|
2002-09-02 16:56:29 +00:00
|
|
|
level = (block[0] + 4)>>3;
|
2005-12-17 18:14:38 +00:00
|
|
|
|
2002-04-27 12:30:26 +00:00
|
|
|
block[0]=0; //avoid fake overflow
|
2002-01-27 13:30:18 +00:00
|
|
|
// temp_block[0] = (block[0] + (q >> 1)) / q;
|
|
|
|
last_non_zero_p1 = 1;
|
2003-10-22 11:23:39 +00:00
|
|
|
bias = s->q_intra_matrix16[qscale][1];
|
|
|
|
qmat = s->q_intra_matrix16[qscale][0];
|
2002-01-27 13:30:18 +00:00
|
|
|
} else {
|
|
|
|
last_non_zero_p1 = 0;
|
2003-10-22 11:23:39 +00:00
|
|
|
bias = s->q_inter_matrix16[qscale][1];
|
|
|
|
qmat = s->q_inter_matrix16[qscale][0];
|
2002-01-27 13:30:18 +00:00
|
|
|
}
|
|
|
|
|
2004-10-28 10:12:57 +00:00
|
|
|
if((s->out_format == FMT_H263 || s->out_format == FMT_H261) && s->mpeg_quant==0){
|
2005-12-17 18:14:38 +00:00
|
|
|
|
2002-04-27 12:30:26 +00:00
|
|
|
asm volatile(
|
2007-05-12 05:55:09 +00:00
|
|
|
"movd %%"REG_a", "MM"3 \n\t" // last_non_zero_p1
|
|
|
|
SPREADW(MM"3")
|
|
|
|
"pxor "MM"7, "MM"7 \n\t" // 0
|
|
|
|
"pxor "MM"4, "MM"4 \n\t" // 0
|
|
|
|
MOVQ" (%2), "MM"5 \n\t" // qmat[0]
|
|
|
|
"pxor "MM"6, "MM"6 \n\t"
|
|
|
|
"psubw (%3), "MM"6 \n\t" // -bias[0]
|
2005-12-22 01:10:11 +00:00
|
|
|
"mov $-128, %%"REG_a" \n\t"
|
2006-08-12 16:37:31 +00:00
|
|
|
ASMALIGN(4)
|
2005-12-22 01:10:11 +00:00
|
|
|
"1: \n\t"
|
2007-05-12 05:55:09 +00:00
|
|
|
MOVQ" (%1, %%"REG_a"), "MM"0 \n\t" // block[i]
|
|
|
|
SAVE_SIGN(MM"1", MM"0") // ABS(block[i])
|
|
|
|
"psubusw "MM"6, "MM"0 \n\t" // ABS(block[i]) + bias[0]
|
|
|
|
"pmulhw "MM"5, "MM"0 \n\t" // (ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16
|
|
|
|
"por "MM"0, "MM"4 \n\t"
|
|
|
|
RESTORE_SIGN(MM"1", MM"0") // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
|
|
|
|
MOVQ" "MM"0, (%5, %%"REG_a") \n\t"
|
|
|
|
"pcmpeqw "MM"7, "MM"0 \n\t" // out==0 ? 0xFF : 0x00
|
|
|
|
MOVQ" (%4, %%"REG_a"), "MM"1 \n\t"
|
|
|
|
MOVQ" "MM"7, (%1, %%"REG_a") \n\t" // 0
|
|
|
|
"pandn "MM"1, "MM"0 \n\t"
|
|
|
|
PMAXW(MM"0", MM"3")
|
|
|
|
"add $"MMREG_WIDTH", %%"REG_a" \n\t"
|
2005-12-22 01:10:11 +00:00
|
|
|
" js 1b \n\t"
|
2007-05-12 05:55:09 +00:00
|
|
|
PMAX(MM"3", MM"0")
|
|
|
|
"movd "MM"3, %%"REG_a" \n\t"
|
2005-12-22 01:10:11 +00:00
|
|
|
"movzb %%al, %%"REG_a" \n\t" // last_non_zero_p1
|
|
|
|
: "+a" (last_non_zero_p1)
|
2003-05-13 08:21:35 +00:00
|
|
|
: "r" (block+64), "r" (qmat), "r" (bias),
|
2006-11-14 03:18:09 +00:00
|
|
|
"r" (inv_zigzag_direct16+64), "r" (temp_block+64)
|
2003-05-13 08:21:35 +00:00
|
|
|
);
|
2002-04-27 12:30:26 +00:00
|
|
|
}else{ // FMT_H263
|
|
|
|
asm volatile(
|
2007-05-12 05:55:09 +00:00
|
|
|
"movd %%"REG_a", "MM"3 \n\t" // last_non_zero_p1
|
|
|
|
SPREADW(MM"3")
|
|
|
|
"pxor "MM"7, "MM"7 \n\t" // 0
|
|
|
|
"pxor "MM"4, "MM"4 \n\t" // 0
|
2005-12-22 01:10:11 +00:00
|
|
|
"mov $-128, %%"REG_a" \n\t"
|
2006-08-12 16:37:31 +00:00
|
|
|
ASMALIGN(4)
|
2005-12-22 01:10:11 +00:00
|
|
|
"1: \n\t"
|
2007-05-12 05:55:09 +00:00
|
|
|
MOVQ" (%1, %%"REG_a"), "MM"0 \n\t" // block[i]
|
|
|
|
SAVE_SIGN(MM"1", MM"0") // ABS(block[i])
|
|
|
|
MOVQ" (%3, %%"REG_a"), "MM"6 \n\t" // bias[0]
|
|
|
|
"paddusw "MM"6, "MM"0 \n\t" // ABS(block[i]) + bias[0]
|
|
|
|
MOVQ" (%2, %%"REG_a"), "MM"5 \n\t" // qmat[i]
|
|
|
|
"pmulhw "MM"5, "MM"0 \n\t" // (ABS(block[i])*qmat[0] + bias[0]*qmat[0])>>16
|
|
|
|
"por "MM"0, "MM"4 \n\t"
|
|
|
|
RESTORE_SIGN(MM"1", MM"0") // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
|
|
|
|
MOVQ" "MM"0, (%5, %%"REG_a") \n\t"
|
|
|
|
"pcmpeqw "MM"7, "MM"0 \n\t" // out==0 ? 0xFF : 0x00
|
|
|
|
MOVQ" (%4, %%"REG_a"), "MM"1 \n\t"
|
|
|
|
MOVQ" "MM"7, (%1, %%"REG_a") \n\t" // 0
|
|
|
|
"pandn "MM"1, "MM"0 \n\t"
|
|
|
|
PMAXW(MM"0", MM"3")
|
|
|
|
"add $"MMREG_WIDTH", %%"REG_a" \n\t"
|
2005-12-22 01:10:11 +00:00
|
|
|
" js 1b \n\t"
|
2007-05-12 05:55:09 +00:00
|
|
|
PMAX(MM"3", MM"0")
|
|
|
|
"movd "MM"3, %%"REG_a" \n\t"
|
2005-12-22 01:10:11 +00:00
|
|
|
"movzb %%al, %%"REG_a" \n\t" // last_non_zero_p1
|
|
|
|
: "+a" (last_non_zero_p1)
|
2003-05-13 08:21:35 +00:00
|
|
|
: "r" (block+64), "r" (qmat+64), "r" (bias+64),
|
2006-11-14 03:18:09 +00:00
|
|
|
"r" (inv_zigzag_direct16+64), "r" (temp_block+64)
|
2002-04-27 12:30:26 +00:00
|
|
|
);
|
2007-05-12 05:55:09 +00:00
|
|
|
}
|
|
|
|
asm volatile(
|
|
|
|
"movd %1, "MM"1 \n\t" // max_qcoeff
|
|
|
|
SPREADW(MM"1")
|
|
|
|
"psubusw "MM"1, "MM"4 \n\t"
|
|
|
|
"packuswb "MM"4, "MM"4 \n\t"
|
|
|
|
#ifdef HAVE_SSE2
|
|
|
|
"packuswb "MM"4, "MM"4 \n\t"
|
|
|
|
#endif
|
|
|
|
"movd "MM"4, %0 \n\t" // *overflow
|
2003-05-13 08:21:35 +00:00
|
|
|
: "=g" (*overflow)
|
|
|
|
: "g" (s->max_qcoeff)
|
2007-05-12 05:55:09 +00:00
|
|
|
);
|
2002-04-27 12:30:26 +00:00
|
|
|
|
2002-09-29 22:44:22 +00:00
|
|
|
if(s->mb_intra) block[0]= level;
|
|
|
|
else block[0]= temp_block[0];
|
|
|
|
|
2003-03-03 14:54:00 +00:00
|
|
|
if(s->dsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM){
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 1) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08];
|
|
|
|
block[0x20] = temp_block[0x10];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 4) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x18] = temp_block[0x09]; block[0x04] = temp_block[0x02];
|
|
|
|
block[0x09] = temp_block[0x03];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 7) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x14] = temp_block[0x0A]; block[0x28] = temp_block[0x11];
|
|
|
|
block[0x12] = temp_block[0x18]; block[0x02] = temp_block[0x20];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 11) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x1A] = temp_block[0x19]; block[0x24] = temp_block[0x12];
|
|
|
|
block[0x19] = temp_block[0x0B]; block[0x01] = temp_block[0x04];
|
|
|
|
block[0x0C] = temp_block[0x05];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 16) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x11] = temp_block[0x0C]; block[0x29] = temp_block[0x13];
|
|
|
|
block[0x16] = temp_block[0x1A]; block[0x0A] = temp_block[0x21];
|
|
|
|
block[0x30] = temp_block[0x28]; block[0x22] = temp_block[0x30];
|
|
|
|
block[0x38] = temp_block[0x29]; block[0x06] = temp_block[0x22];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 24) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x1B] = temp_block[0x1B]; block[0x21] = temp_block[0x14];
|
|
|
|
block[0x1C] = temp_block[0x0D]; block[0x05] = temp_block[0x06];
|
|
|
|
block[0x0D] = temp_block[0x07]; block[0x15] = temp_block[0x0E];
|
|
|
|
block[0x2C] = temp_block[0x15]; block[0x13] = temp_block[0x1C];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 32) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x0B] = temp_block[0x23]; block[0x34] = temp_block[0x2A];
|
|
|
|
block[0x2A] = temp_block[0x31]; block[0x32] = temp_block[0x38];
|
|
|
|
block[0x3A] = temp_block[0x39]; block[0x26] = temp_block[0x32];
|
|
|
|
block[0x39] = temp_block[0x2B]; block[0x03] = temp_block[0x24];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 40) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x1E] = temp_block[0x1D]; block[0x25] = temp_block[0x16];
|
|
|
|
block[0x1D] = temp_block[0x0F]; block[0x2D] = temp_block[0x17];
|
|
|
|
block[0x17] = temp_block[0x1E]; block[0x0E] = temp_block[0x25];
|
|
|
|
block[0x31] = temp_block[0x2C]; block[0x2B] = temp_block[0x33];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 48) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x36] = temp_block[0x3A]; block[0x3B] = temp_block[0x3B];
|
|
|
|
block[0x23] = temp_block[0x34]; block[0x3C] = temp_block[0x2D];
|
|
|
|
block[0x07] = temp_block[0x26]; block[0x1F] = temp_block[0x1F];
|
|
|
|
block[0x0F] = temp_block[0x27]; block[0x35] = temp_block[0x2E];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 56) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x2E] = temp_block[0x35]; block[0x33] = temp_block[0x3C];
|
|
|
|
block[0x3E] = temp_block[0x3D]; block[0x27] = temp_block[0x36];
|
|
|
|
block[0x3D] = temp_block[0x2F]; block[0x2F] = temp_block[0x37];
|
2002-09-29 22:44:22 +00:00
|
|
|
block[0x37] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
|
2003-03-03 14:54:00 +00:00
|
|
|
}else if(s->dsp.idct_permutation_type == FF_LIBMPEG2_IDCT_PERM){
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 1) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x04] = temp_block[0x01];
|
|
|
|
block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 4) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x0C] = temp_block[0x09]; block[0x01] = temp_block[0x02];
|
|
|
|
block[0x05] = temp_block[0x03];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 7) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x09] = temp_block[0x0A]; block[0x14] = temp_block[0x11];
|
|
|
|
block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 11) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x1C] = temp_block[0x19];
|
|
|
|
block[0x11] = temp_block[0x12]; block[0x0D] = temp_block[0x0B];
|
|
|
|
block[0x02] = temp_block[0x04]; block[0x06] = temp_block[0x05];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 16) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x0A] = temp_block[0x0C]; block[0x15] = temp_block[0x13];
|
|
|
|
block[0x19] = temp_block[0x1A]; block[0x24] = temp_block[0x21];
|
|
|
|
block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30];
|
|
|
|
block[0x2C] = temp_block[0x29]; block[0x21] = temp_block[0x22];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 24) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x1D] = temp_block[0x1B]; block[0x12] = temp_block[0x14];
|
|
|
|
block[0x0E] = temp_block[0x0D]; block[0x03] = temp_block[0x06];
|
|
|
|
block[0x07] = temp_block[0x07]; block[0x0B] = temp_block[0x0E];
|
|
|
|
block[0x16] = temp_block[0x15]; block[0x1A] = temp_block[0x1C];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 32) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x25] = temp_block[0x23]; block[0x29] = temp_block[0x2A];
|
|
|
|
block[0x34] = temp_block[0x31]; block[0x38] = temp_block[0x38];
|
|
|
|
block[0x3C] = temp_block[0x39]; block[0x31] = temp_block[0x32];
|
|
|
|
block[0x2D] = temp_block[0x2B]; block[0x22] = temp_block[0x24];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 40) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x1E] = temp_block[0x1D]; block[0x13] = temp_block[0x16];
|
|
|
|
block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17];
|
|
|
|
block[0x1B] = temp_block[0x1E]; block[0x26] = temp_block[0x25];
|
|
|
|
block[0x2A] = temp_block[0x2C]; block[0x35] = temp_block[0x33];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 48) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x39] = temp_block[0x3A]; block[0x3D] = temp_block[0x3B];
|
|
|
|
block[0x32] = temp_block[0x34]; block[0x2E] = temp_block[0x2D];
|
|
|
|
block[0x23] = temp_block[0x26]; block[0x1F] = temp_block[0x1F];
|
|
|
|
block[0x27] = temp_block[0x27]; block[0x2B] = temp_block[0x2E];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 56) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x36] = temp_block[0x35]; block[0x3A] = temp_block[0x3C];
|
|
|
|
block[0x3E] = temp_block[0x3D]; block[0x33] = temp_block[0x36];
|
|
|
|
block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37];
|
2002-09-29 22:44:22 +00:00
|
|
|
block[0x3B] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
|
|
|
|
}else{
|
|
|
|
if(last_non_zero_p1 <= 1) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x01] = temp_block[0x01];
|
|
|
|
block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 4) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x09] = temp_block[0x09]; block[0x02] = temp_block[0x02];
|
|
|
|
block[0x03] = temp_block[0x03];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 7) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x0A] = temp_block[0x0A]; block[0x11] = temp_block[0x11];
|
|
|
|
block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 11) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x19] = temp_block[0x19];
|
|
|
|
block[0x12] = temp_block[0x12]; block[0x0B] = temp_block[0x0B];
|
|
|
|
block[0x04] = temp_block[0x04]; block[0x05] = temp_block[0x05];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 16) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x0C] = temp_block[0x0C]; block[0x13] = temp_block[0x13];
|
|
|
|
block[0x1A] = temp_block[0x1A]; block[0x21] = temp_block[0x21];
|
|
|
|
block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30];
|
|
|
|
block[0x29] = temp_block[0x29]; block[0x22] = temp_block[0x22];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 24) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x1B] = temp_block[0x1B]; block[0x14] = temp_block[0x14];
|
|
|
|
block[0x0D] = temp_block[0x0D]; block[0x06] = temp_block[0x06];
|
|
|
|
block[0x07] = temp_block[0x07]; block[0x0E] = temp_block[0x0E];
|
|
|
|
block[0x15] = temp_block[0x15]; block[0x1C] = temp_block[0x1C];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 32) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x23] = temp_block[0x23]; block[0x2A] = temp_block[0x2A];
|
|
|
|
block[0x31] = temp_block[0x31]; block[0x38] = temp_block[0x38];
|
|
|
|
block[0x39] = temp_block[0x39]; block[0x32] = temp_block[0x32];
|
|
|
|
block[0x2B] = temp_block[0x2B]; block[0x24] = temp_block[0x24];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 40) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x1D] = temp_block[0x1D]; block[0x16] = temp_block[0x16];
|
|
|
|
block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17];
|
|
|
|
block[0x1E] = temp_block[0x1E]; block[0x25] = temp_block[0x25];
|
|
|
|
block[0x2C] = temp_block[0x2C]; block[0x33] = temp_block[0x33];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 48) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x3A] = temp_block[0x3A]; block[0x3B] = temp_block[0x3B];
|
|
|
|
block[0x34] = temp_block[0x34]; block[0x2D] = temp_block[0x2D];
|
|
|
|
block[0x26] = temp_block[0x26]; block[0x1F] = temp_block[0x1F];
|
|
|
|
block[0x27] = temp_block[0x27]; block[0x2E] = temp_block[0x2E];
|
2002-09-29 22:44:22 +00:00
|
|
|
if(last_non_zero_p1 <= 56) goto end;
|
2005-12-17 18:14:38 +00:00
|
|
|
block[0x35] = temp_block[0x35]; block[0x3C] = temp_block[0x3C];
|
|
|
|
block[0x3D] = temp_block[0x3D]; block[0x36] = temp_block[0x36];
|
|
|
|
block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37];
|
2002-09-29 22:44:22 +00:00
|
|
|
block[0x3E] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
|
|
|
|
}
|
|
|
|
end:
|
2002-01-27 13:30:18 +00:00
|
|
|
/*
|
|
|
|
for(i=0; i<last_non_zero_p1; i++)
|
|
|
|
{
|
|
|
|
int j= zigzag_direct_noperm[i];
|
|
|
|
block[block_permute_op(j)]= temp_block[j];
|
|
|
|
}
|
|
|
|
*/
|
2002-04-27 12:30:26 +00:00
|
|
|
|
2002-01-27 13:30:18 +00:00
|
|
|
return last_non_zero_p1 - 1;
|
|
|
|
}
|