mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
idct: Convert IDCT permutation #defines to an enum
Also rename the enum values to be consistent with other DCT permutations.
This commit is contained in:
parent
c0de9159a7
commit
b4987f7219
@ -78,12 +78,12 @@ av_cold void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx,
|
||||
c->idct_put = j_rev_dct_arm_put;
|
||||
c->idct_add = j_rev_dct_arm_add;
|
||||
c->idct = ff_j_rev_dct_arm;
|
||||
c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_LIBMPEG2;
|
||||
} else if (avctx->idct_algo == FF_IDCT_SIMPLEARM) {
|
||||
c->idct_put = simple_idct_arm_put;
|
||||
c->idct_add = simple_idct_arm_add;
|
||||
c->idct = ff_simple_idct_arm;
|
||||
c->idct_permutation_type = FF_NO_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,6 @@ av_cold void ff_idctdsp_init_armv5te(IDCTDSPContext *c, AVCodecContext *avctx,
|
||||
c->idct_put = ff_simple_idct_put_armv5te;
|
||||
c->idct_add = ff_simple_idct_add_armv5te;
|
||||
c->idct = ff_simple_idct_armv5te;
|
||||
c->idct_permutation_type = FF_NO_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_NONE;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ av_cold void ff_idctdsp_init_armv6(IDCTDSPContext *c, AVCodecContext *avctx,
|
||||
c->idct_put = ff_simple_idct_put_armv6;
|
||||
c->idct_add = ff_simple_idct_add_armv6;
|
||||
c->idct = ff_simple_idct_armv6;
|
||||
c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_LIBMPEG2;
|
||||
}
|
||||
}
|
||||
c->add_pixels_clamped = ff_add_pixels_clamped_armv6;
|
||||
|
@ -43,7 +43,7 @@ av_cold void ff_idctdsp_init_neon(IDCTDSPContext *c, AVCodecContext *avctx,
|
||||
c->idct_put = ff_simple_idct_put_neon;
|
||||
c->idct_add = ff_simple_idct_add_neon;
|
||||
c->idct = ff_simple_idct_neon;
|
||||
c->idct_permutation_type = FF_PARTTRANS_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_PARTTRANS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) {
|
||||
c->cavs_filter_cv = cavs_filter_cv_c;
|
||||
c->cavs_filter_ch = cavs_filter_ch_c;
|
||||
c->cavs_idct8_add = cavs_idct8_add_c;
|
||||
c->idct_perm = FF_NO_IDCT_PERM;
|
||||
c->idct_perm = FF_IDCT_PERM_NONE;
|
||||
|
||||
if (ARCH_X86)
|
||||
ff_cavsdsp_init_x86(c, avctx);
|
||||
|
@ -68,7 +68,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
ff_blockdsp_init(&s->bdsp, avctx);
|
||||
ff_bswapdsp_init(&s->bbdsp);
|
||||
ff_idctdsp_init(&s->idsp, avctx);
|
||||
ff_init_scantable_permutation(s->idsp.idct_permutation, FF_NO_IDCT_PERM);
|
||||
ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE);
|
||||
ff_init_scantable(s->idsp.idct_permutation, &s->scantable, ff_zigzag_direct);
|
||||
ff_mpeg12_init_vlcs();
|
||||
|
||||
|
@ -51,7 +51,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx)
|
||||
TgqContext *s = avctx->priv_data;
|
||||
uint8_t idct_permutation[64];
|
||||
s->avctx = avctx;
|
||||
ff_init_scantable_permutation(idct_permutation, FF_NO_IDCT_PERM);
|
||||
ff_init_scantable_permutation(idct_permutation, FF_IDCT_PERM_NONE);
|
||||
ff_init_scantable(idct_permutation, &s->scantable, ff_zigzag_direct);
|
||||
avctx->time_base = (AVRational){1, 15};
|
||||
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
|
@ -53,7 +53,7 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx)
|
||||
ff_blockdsp_init(&s->bdsp, avctx);
|
||||
ff_bswapdsp_init(&t->bsdsp);
|
||||
ff_idctdsp_init(&s->idsp, avctx);
|
||||
ff_init_scantable_permutation(s->idsp.idct_permutation, FF_NO_IDCT_PERM);
|
||||
ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE);
|
||||
ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
|
||||
s->qscale = 1;
|
||||
avctx->time_base = (AVRational){1, 15};
|
||||
|
@ -47,29 +47,29 @@ av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
|
||||
}
|
||||
|
||||
av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
|
||||
int idct_permutation_type)
|
||||
enum idct_permutation_type perm_type)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ARCH_X86)
|
||||
if (ff_init_scantable_permutation_x86(idct_permutation,
|
||||
idct_permutation_type))
|
||||
perm_type))
|
||||
return;
|
||||
|
||||
switch (idct_permutation_type) {
|
||||
case FF_NO_IDCT_PERM:
|
||||
switch (perm_type) {
|
||||
case FF_IDCT_PERM_NONE:
|
||||
for (i = 0; i < 64; i++)
|
||||
idct_permutation[i] = i;
|
||||
break;
|
||||
case FF_LIBMPEG2_IDCT_PERM:
|
||||
case FF_IDCT_PERM_LIBMPEG2:
|
||||
for (i = 0; i < 64; i++)
|
||||
idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
|
||||
break;
|
||||
case FF_TRANSPOSE_IDCT_PERM:
|
||||
case FF_IDCT_PERM_TRANSPOSE:
|
||||
for (i = 0; i < 64; i++)
|
||||
idct_permutation[i] = ((i & 7) << 3) | (i >> 3);
|
||||
break;
|
||||
case FF_PARTTRANS_IDCT_PERM:
|
||||
case FF_IDCT_PERM_PARTTRANS:
|
||||
for (i = 0; i < 64; i++)
|
||||
idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3);
|
||||
break;
|
||||
@ -161,23 +161,23 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
|
||||
c->idct_put = ff_simple_idct_put_10;
|
||||
c->idct_add = ff_simple_idct_add_10;
|
||||
c->idct = ff_simple_idct_10;
|
||||
c->idct_permutation_type = FF_NO_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_NONE;
|
||||
} else {
|
||||
if (avctx->idct_algo == FF_IDCT_INT) {
|
||||
c->idct_put = jref_idct_put;
|
||||
c->idct_add = jref_idct_add;
|
||||
c->idct = ff_j_rev_dct;
|
||||
c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_LIBMPEG2;
|
||||
} else if (avctx->idct_algo == FF_IDCT_FAAN) {
|
||||
c->idct_put = ff_faanidct_put;
|
||||
c->idct_add = ff_faanidct_add;
|
||||
c->idct = ff_faanidct;
|
||||
c->idct_permutation_type = FF_NO_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_NONE;
|
||||
} else { // accurate/default
|
||||
c->idct_put = ff_simple_idct_put_8;
|
||||
c->idct_add = ff_simple_idct_add_8;
|
||||
c->idct = ff_simple_idct_8;
|
||||
c->idct_permutation_type = FF_NO_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,5 +193,5 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
|
||||
ff_idctdsp_init_x86(c, avctx, high_bit_depth);
|
||||
|
||||
ff_init_scantable_permutation(c->idct_permutation,
|
||||
c->idct_permutation_type);
|
||||
c->perm_type);
|
||||
}
|
||||
|
@ -32,12 +32,21 @@ typedef struct ScanTable {
|
||||
uint8_t raster_end[64];
|
||||
} ScanTable;
|
||||
|
||||
enum idct_permutation_type {
|
||||
FF_IDCT_PERM_NONE,
|
||||
FF_IDCT_PERM_LIBMPEG2,
|
||||
FF_IDCT_PERM_SIMPLE,
|
||||
FF_IDCT_PERM_TRANSPOSE,
|
||||
FF_IDCT_PERM_PARTTRANS,
|
||||
FF_IDCT_PERM_SSE2,
|
||||
};
|
||||
|
||||
void ff_init_scantable(uint8_t *permutation, ScanTable *st,
|
||||
const uint8_t *src_scantable);
|
||||
void ff_init_scantable_permutation(uint8_t *idct_permutation,
|
||||
int idct_permutation_type);
|
||||
enum idct_permutation_type perm_type);
|
||||
int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
|
||||
int idct_permutation_type);
|
||||
enum idct_permutation_type perm_type);
|
||||
|
||||
typedef struct IDCTDSPContext {
|
||||
/* pixel ops : interface with DCT */
|
||||
@ -83,13 +92,7 @@ typedef struct IDCTDSPContext {
|
||||
* -> simple_idct_mmx -> ...)
|
||||
*/
|
||||
uint8_t idct_permutation[64];
|
||||
int idct_permutation_type;
|
||||
#define FF_NO_IDCT_PERM 1
|
||||
#define FF_LIBMPEG2_IDCT_PERM 2
|
||||
#define FF_SIMPLE_IDCT_PERM 3
|
||||
#define FF_TRANSPOSE_IDCT_PERM 4
|
||||
#define FF_PARTTRANS_IDCT_PERM 5
|
||||
#define FF_SSE2_IDCT_PERM 6
|
||||
enum idct_permutation_type perm_type;
|
||||
} IDCTDSPContext;
|
||||
|
||||
void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx);
|
||||
|
@ -4223,7 +4223,7 @@ int ff_dct_quantize_c(MpegEncContext *s,
|
||||
*overflow= s->max_qcoeff < max; //overflow might have happened
|
||||
|
||||
/* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
|
||||
if (s->idsp.idct_permutation_type != FF_NO_IDCT_PERM)
|
||||
if (s->idsp.perm_type != FF_IDCT_PERM_NONE)
|
||||
ff_block_permute(block, s->idsp.idct_permutation,
|
||||
scantable, last_non_zero);
|
||||
|
||||
|
@ -237,7 +237,7 @@ av_cold void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx,
|
||||
(avctx->idct_algo == FF_IDCT_ALTIVEC)) {
|
||||
c->idct_add = idct_add_altivec;
|
||||
c->idct_put = idct_put_altivec;
|
||||
c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ static void prores_idct_put_c(uint16_t *out, int linesize, int16_t *block, const
|
||||
av_cold void ff_proresdsp_init(ProresDSPContext *dsp)
|
||||
{
|
||||
dsp->idct_put = prores_idct_put_c;
|
||||
dsp->idct_permutation_type = FF_NO_IDCT_PERM;
|
||||
dsp->idct_permutation_type = FF_IDCT_PERM_NONE;
|
||||
|
||||
if (ARCH_X86)
|
||||
ff_proresdsp_init_x86(dsp);
|
||||
|
@ -31,7 +31,7 @@ av_cold void ff_wmv2_common_init(Wmv2Context * w){
|
||||
|
||||
ff_blockdsp_init(&s->bdsp, s->avctx);
|
||||
ff_wmv2dsp_init(&w->wdsp);
|
||||
s->idsp.idct_permutation_type = w->wdsp.idct_perm;
|
||||
s->idsp.perm_type = w->wdsp.idct_perm;
|
||||
ff_init_scantable_permutation(s->idsp.idct_permutation,
|
||||
w->wdsp.idct_perm);
|
||||
ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0],
|
||||
|
@ -252,7 +252,7 @@ av_cold void ff_wmv2dsp_init(WMV2DSPContext *c)
|
||||
{
|
||||
c->idct_add = wmv2_idct_add_c;
|
||||
c->idct_put = wmv2_idct_put_c;
|
||||
c->idct_perm = FF_NO_IDCT_PERM;
|
||||
c->idct_perm = FF_IDCT_PERM_NONE;
|
||||
|
||||
c->put_mspel_pixels_tab[0] = ff_put_pixels8x8_c;
|
||||
c->put_mspel_pixels_tab[1] = put_mspel8_mc10_c;
|
||||
|
@ -493,7 +493,7 @@ static av_cold void cavsdsp_init_mmx(CAVSDSPContext *c,
|
||||
c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmx;
|
||||
|
||||
c->cavs_idct8_add = cavs_idct8_add_mmx;
|
||||
c->idct_perm = FF_TRANSPOSE_IDCT_PERM;
|
||||
c->idct_perm = FF_IDCT_PERM_TRANSPOSE;
|
||||
}
|
||||
#endif /* HAVE_MMX_INLINE */
|
||||
|
||||
|
@ -41,16 +41,16 @@ static const uint8_t simple_mmx_permutation[64] = {
|
||||
static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
|
||||
|
||||
av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
|
||||
int idct_permutation_type)
|
||||
enum idct_permutation_type perm_type)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (idct_permutation_type) {
|
||||
case FF_SIMPLE_IDCT_PERM:
|
||||
switch (perm_type) {
|
||||
case FF_IDCT_PERM_SIMPLE:
|
||||
for (i = 0; i < 64; i++)
|
||||
idct_permutation[i] = simple_mmx_permutation[i];
|
||||
return 1;
|
||||
case FF_SSE2_IDCT_PERM:
|
||||
case FF_IDCT_PERM_SSE2:
|
||||
for (i = 0; i < 64; i++)
|
||||
idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7];
|
||||
return 1;
|
||||
@ -76,7 +76,7 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
|
||||
c->idct_put = ff_simple_idct_put_mmx;
|
||||
c->idct_add = ff_simple_idct_add_mmx;
|
||||
c->idct = ff_simple_idct_mmx;
|
||||
c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_SIMPLE;
|
||||
break;
|
||||
case FF_IDCT_XVIDMMX:
|
||||
c->idct_put = ff_idct_xvid_mmx_put;
|
||||
@ -100,7 +100,7 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
|
||||
c->idct_put = ff_idct_xvid_sse2_put;
|
||||
c->idct_add = ff_idct_xvid_sse2_add;
|
||||
c->idct = ff_idct_xvid_sse2;
|
||||
c->idct_permutation_type = FF_SSE2_IDCT_PERM;
|
||||
c->perm_type = FF_IDCT_PERM_SSE2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
|
||||
if(s->mb_intra) block[0]= level;
|
||||
else block[0]= temp_block[0];
|
||||
|
||||
if (s->idsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM) {
|
||||
if (s->idsp.perm_type == FF_IDCT_PERM_SIMPLE) {
|
||||
if(last_non_zero_p1 <= 1) goto end;
|
||||
block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08];
|
||||
block[0x20] = temp_block[0x10];
|
||||
|
@ -38,17 +38,17 @@ av_cold void ff_proresdsp_init_x86(ProresDSPContext *dsp)
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||
dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
|
||||
dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
|
||||
dsp->idct_put = ff_prores_idct_put_10_sse2;
|
||||
}
|
||||
|
||||
if (EXTERNAL_SSE4(cpu_flags)) {
|
||||
dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
|
||||
dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
|
||||
dsp->idct_put = ff_prores_idct_put_10_sse4;
|
||||
}
|
||||
|
||||
if (EXTERNAL_AVX(cpu_flags)) {
|
||||
dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
|
||||
dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
|
||||
dsp->idct_put = ff_prores_idct_put_10_avx;
|
||||
}
|
||||
#endif /* ARCH_X86_64 */
|
||||
|
Loading…
Reference in New Issue
Block a user