Commit a9aee08d authored by Diego Biurrun's avatar Diego Biurrun

dsputil: Split off FDCT bits into their own context

parent 1e9a93bf
...@@ -1534,6 +1534,7 @@ CONFIG_EXTRA=" ...@@ -1534,6 +1534,7 @@ CONFIG_EXTRA="
bswapdsp bswapdsp
cabac cabac
dsputil dsputil
fdctdsp
gcrypt gcrypt
golomb golomb
gplv3 gplv3
...@@ -1704,7 +1705,7 @@ threads_if_any="$THREADS_LIST" ...@@ -1704,7 +1705,7 @@ threads_if_any="$THREADS_LIST"
# subsystems # subsystems
dct_select="rdft" dct_select="rdft"
dsputil_select="idctdsp" dsputil_select="fdctdsp idctdsp"
error_resilience_select="dsputil" error_resilience_select="dsputil"
intrax8_select="error_resilience" intrax8_select="error_resilience"
mdct_select="fft" mdct_select="fft"
...@@ -1730,9 +1731,9 @@ amrwb_decoder_select="lsp" ...@@ -1730,9 +1731,9 @@ amrwb_decoder_select="lsp"
amv_decoder_select="sp5x_decoder" amv_decoder_select="sp5x_decoder"
ape_decoder_select="bswapdsp" ape_decoder_select="bswapdsp"
asv1_decoder_select="blockdsp bswapdsp idctdsp" asv1_decoder_select="blockdsp bswapdsp idctdsp"
asv1_encoder_select="bswapdsp dsputil" asv1_encoder_select="bswapdsp dsputil fdctdsp"
asv2_decoder_select="blockdsp bswapdsp idctdsp" asv2_decoder_select="blockdsp bswapdsp idctdsp"
asv2_encoder_select="bswapdsp dsputil" asv2_encoder_select="bswapdsp dsputil fdctdsp"
atrac1_decoder_select="mdct sinewin" atrac1_decoder_select="mdct sinewin"
atrac3_decoder_select="mdct" atrac3_decoder_select="mdct"
atrac3p_decoder_select="mdct sinewin" atrac3p_decoder_select="mdct sinewin"
...@@ -1747,9 +1748,9 @@ cscd_decoder_select="lzo" ...@@ -1747,9 +1748,9 @@ cscd_decoder_select="lzo"
cscd_decoder_suggest="zlib" cscd_decoder_suggest="zlib"
dca_decoder_select="mdct" dca_decoder_select="mdct"
dnxhd_decoder_select="blockdsp idctdsp" dnxhd_decoder_select="blockdsp idctdsp"
dnxhd_encoder_select="aandcttables blockdsp dsputil idctdsp mpegvideoenc" dnxhd_encoder_select="aandcttables blockdsp dsputil fdctdsp idctdsp mpegvideoenc"
dvvideo_decoder_select="idctdsp" dvvideo_decoder_select="idctdsp"
dvvideo_encoder_select="dsputil" dvvideo_encoder_select="dsputil fdctdsp"
dxa_decoder_deps="zlib" dxa_decoder_deps="zlib"
eac3_decoder_select="ac3_decoder" eac3_decoder_select="ac3_decoder"
eac3_encoder_select="ac3_encoder" eac3_encoder_select="ac3_encoder"
...@@ -1838,7 +1839,7 @@ png_decoder_deps="zlib" ...@@ -1838,7 +1839,7 @@ png_decoder_deps="zlib"
png_encoder_deps="zlib" png_encoder_deps="zlib"
png_encoder_select="huffyuvencdsp" png_encoder_select="huffyuvencdsp"
prores_decoder_select="idctdsp" prores_decoder_select="idctdsp"
prores_encoder_select="dsputil" prores_encoder_select="fdctdsp"
qcelp_decoder_select="lsp" qcelp_decoder_select="lsp"
qdm2_decoder_select="mdct rdft mpegaudiodsp" qdm2_decoder_select="mdct rdft mpegaudiodsp"
ra_144_encoder_select="audio_frame_queue lpc" ra_144_encoder_select="audio_frame_queue lpc"
......
...@@ -35,8 +35,9 @@ OBJS-$(CONFIG_CABAC) += cabac.o ...@@ -35,8 +35,9 @@ OBJS-$(CONFIG_CABAC) += cabac.o
OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
OBJS-$(CONFIG_DSPUTIL) += dsputil.o OBJS-$(CONFIG_DSPUTIL) += dsputil.o
OBJS-$(CONFIG_DXVA2) += dxva2.o OBJS-$(CONFIG_DXVA2) += dxva2.o
OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o
OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o
OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o faandct.o \
jfdctfst.o jfdctint.o
FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o
OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \ OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \
$(FFT-OBJS-yes) $(FFT-OBJS-yes)
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "blockdsp.h" #include "blockdsp.h"
#include "bswapdsp.h" #include "bswapdsp.h"
#include "dsputil.h" #include "dsputil.h"
#include "fdctdsp.h"
#include "idctdsp.h" #include "idctdsp.h"
#include "get_bits.h" #include "get_bits.h"
#include "put_bits.h" #include "put_bits.h"
...@@ -43,6 +44,7 @@ typedef struct ASV1Context{ ...@@ -43,6 +44,7 @@ typedef struct ASV1Context{
BlockDSPContext bdsp; BlockDSPContext bdsp;
BswapDSPContext bbdsp; BswapDSPContext bbdsp;
DSPContext dsp; DSPContext dsp;
FDCTDSPContext fdsp;
IDCTDSPContext idsp; IDCTDSPContext idsp;
PutBitContext pb; PutBitContext pb;
GetBitContext gb; GetBitContext gb;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "asv.h" #include "asv.h"
#include "avcodec.h" #include "avcodec.h"
#include "fdctdsp.h"
#include "mathops.h" #include "mathops.h"
#include "mpeg12data.h" #include "mpeg12data.h"
...@@ -163,13 +164,13 @@ static inline void dct_get(ASV1Context *a, const AVFrame *frame, ...@@ -163,13 +164,13 @@ static inline void dct_get(ASV1Context *a, const AVFrame *frame,
a->dsp.get_pixels(block[2], ptr_y + 8*linesize , linesize); a->dsp.get_pixels(block[2], ptr_y + 8*linesize , linesize);
a->dsp.get_pixels(block[3], ptr_y + 8*linesize + 8, linesize); a->dsp.get_pixels(block[3], ptr_y + 8*linesize + 8, linesize);
for(i=0; i<4; i++) for(i=0; i<4; i++)
a->dsp.fdct(block[i]); a->fdsp.fdct(block[i]);
if(!(a->avctx->flags&CODEC_FLAG_GRAY)){ if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
a->dsp.get_pixels(block[4], ptr_cb, frame->linesize[1]); a->dsp.get_pixels(block[4], ptr_cb, frame->linesize[1]);
a->dsp.get_pixels(block[5], ptr_cr, frame->linesize[2]); a->dsp.get_pixels(block[5], ptr_cr, frame->linesize[2]);
for(i=4; i<6; i++) for(i=4; i<6; i++)
a->dsp.fdct(block[i]); a->fdsp.fdct(block[i]);
} }
} }
...@@ -248,6 +249,7 @@ static av_cold int encode_init(AVCodecContext *avctx){ ...@@ -248,6 +249,7 @@ static av_cold int encode_init(AVCodecContext *avctx){
ff_asv_common_init(avctx); ff_asv_common_init(avctx);
ff_dsputil_init(&a->dsp, avctx); ff_dsputil_init(&a->dsp, avctx);
ff_fdctdsp_init(&a->fdsp, avctx);
if(avctx->global_quality == 0) avctx->global_quality= 4*FF_QUALITY_SCALE; if(avctx->global_quality == 0) avctx->global_quality= 4*FF_QUALITY_SCALE;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "avcodec.h" #include "avcodec.h"
#include "blockdsp.h" #include "blockdsp.h"
#include "dsputil.h" #include "dsputil.h"
#include "fdctdsp.h"
#include "internal.h" #include "internal.h"
#include "mpegvideo.h" #include "mpegvideo.h"
#include "dnxhdenc.h" #include "dnxhdenc.h"
...@@ -100,7 +101,7 @@ static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, int16_t *block, ...@@ -100,7 +101,7 @@ static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, int16_t *block,
int last_non_zero = 0; int last_non_zero = 0;
int i; int i;
ctx->dsp.fdct(block); ctx->fdsp.fdct(block);
// Divide by 4 with rounding, to compensate scaling of DCT coefficients // Divide by 4 with rounding, to compensate scaling of DCT coefficients
block[0] = (block[0] + 2) >> 2; block[0] = (block[0] + 2) >> 2;
...@@ -308,6 +309,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) ...@@ -308,6 +309,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
ff_blockdsp_init(&ctx->bdsp, avctx); ff_blockdsp_init(&ctx->bdsp, avctx);
ff_dsputil_init(&ctx->m.dsp, avctx); ff_dsputil_init(&ctx->m.dsp, avctx);
ff_fdctdsp_init(&ctx->m.fdsp, avctx);
ff_idctdsp_init(&ctx->m.idsp, avctx); ff_idctdsp_init(&ctx->m.idsp, avctx);
ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx); ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx);
ff_dct_common_init(&ctx->m); ff_dct_common_init(&ctx->m);
......
...@@ -28,10 +28,8 @@ ...@@ -28,10 +28,8 @@
#include "libavutil/attributes.h" #include "libavutil/attributes.h"
#include "avcodec.h" #include "avcodec.h"
#include "copy_block.h" #include "copy_block.h"
#include "dct.h"
#include "dsputil.h" #include "dsputil.h"
#include "simple_idct.h" #include "simple_idct.h"
#include "faandct.h"
#include "mpegvideo.h" #include "mpegvideo.h"
#include "config.h" #include "config.h"
...@@ -580,7 +578,7 @@ static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1, ...@@ -580,7 +578,7 @@ static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
assert(h == 8); assert(h == 8);
s->dsp.diff_pixels(temp, src1, src2, stride); s->dsp.diff_pixels(temp, src1, src2, stride);
s->dsp.fdct(temp); s->fdsp.fdct(temp);
return s->dsp.sum_abs_dctelem(temp); return s->dsp.sum_abs_dctelem(temp);
} }
...@@ -647,7 +645,7 @@ static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1, ...@@ -647,7 +645,7 @@ static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
assert(h == 8); assert(h == 8);
s->dsp.diff_pixels(temp, src1, src2, stride); s->dsp.diff_pixels(temp, src1, src2, stride);
s->dsp.fdct(temp); s->fdsp.fdct(temp);
for (i = 0; i < 64; i++) for (i = 0; i < 64; i++)
sum = FFMAX(sum, FFABS(temp[i])); sum = FFMAX(sum, FFABS(temp[i]));
...@@ -934,24 +932,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) ...@@ -934,24 +932,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
{ {
const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
#if CONFIG_ENCODERS
if (avctx->bits_per_raw_sample == 10) {
c->fdct = ff_jpeg_fdct_islow_10;
c->fdct248 = ff_fdct248_islow_10;
} else {
if (avctx->dct_algo == FF_DCT_FASTINT) {
c->fdct = ff_fdct_ifast;
c->fdct248 = ff_fdct_ifast248;
} else if (avctx->dct_algo == FF_DCT_FAAN) {
c->fdct = ff_faandct;
c->fdct248 = ff_faandct248;
} else {
c->fdct = ff_jpeg_fdct_islow_8; // slow/accurate/default
c->fdct248 = ff_fdct248_islow_8;
}
}
#endif /* CONFIG_ENCODERS */
c->diff_pixels = diff_pixels_c; c->diff_pixels = diff_pixels_c;
c->sum_abs_dctelem = sum_abs_dctelem_c; c->sum_abs_dctelem = sum_abs_dctelem_c;
......
...@@ -79,10 +79,6 @@ typedef struct DSPContext { ...@@ -79,10 +79,6 @@ typedef struct DSPContext {
me_cmp_func frame_skip_cmp[6]; // only width 8 used me_cmp_func frame_skip_cmp[6]; // only width 8 used
me_cmp_func pix_abs[2][4]; me_cmp_func pix_abs[2][4];
/* (I)DCT */
void (*fdct)(int16_t *block /* align 16 */);
void (*fdct248)(int16_t *block /* align 16 */);
} DSPContext; } DSPContext;
void ff_dsputil_static_init(void); void ff_dsputil_static_init(void);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "config.h" #include "config.h"
#include "avcodec.h" #include "avcodec.h"
#include "dsputil.h" #include "dsputil.h"
#include "fdctdsp.h"
#include "internal.h" #include "internal.h"
#include "put_bits.h" #include "put_bits.h"
#include "dv.h" #include "dv.h"
...@@ -38,6 +39,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) ...@@ -38,6 +39,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
{ {
DVVideoContext *s = avctx->priv_data; DVVideoContext *s = avctx->priv_data;
DSPContext dsp; DSPContext dsp;
FDCTDSPContext fdsp;
int ret; int ret;
s->sys = avpriv_dv_codec_profile(avctx); s->sys = avpriv_dv_codec_profile(avctx);
...@@ -61,13 +63,14 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) ...@@ -61,13 +63,14 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
dv_vlc_map_tableinit(); dv_vlc_map_tableinit();
ff_dsputil_init(&dsp, avctx); ff_dsputil_init(&dsp, avctx);
ff_fdctdsp_init(&fdsp, avctx);
ff_set_cmp(&dsp, dsp.ildct_cmp, avctx->ildct_cmp); ff_set_cmp(&dsp, dsp.ildct_cmp, avctx->ildct_cmp);
s->get_pixels = dsp.get_pixels; s->get_pixels = dsp.get_pixels;
s->ildct_cmp = dsp.ildct_cmp[5]; s->ildct_cmp = dsp.ildct_cmp[5];
s->fdct[0] = dsp.fdct; s->fdct[0] = fdsp.fdct;
s->fdct[1] = dsp.fdct248; s->fdct[1] = fdsp.fdct248;
return ff_dvvideo_init(avctx); return ff_dvvideo_init(avctx);
} }
......
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/attributes.h"
#include "avcodec.h"
#include "dct.h"
#include "faandct.h"
#include "fdctdsp.h"
#include "config.h"
av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx)
{
const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
if (avctx->bits_per_raw_sample == 10) {
c->fdct = ff_jpeg_fdct_islow_10;
c->fdct248 = ff_fdct248_islow_10;
} else {
if (avctx->dct_algo == FF_DCT_FASTINT) {
c->fdct = ff_fdct_ifast;
c->fdct248 = ff_fdct_ifast248;
} else if (avctx->dct_algo == FF_DCT_FAAN) {
c->fdct = ff_faandct;
c->fdct248 = ff_faandct248;
} else {
c->fdct = ff_jpeg_fdct_islow_8; // slow/accurate/default
c->fdct248 = ff_fdct248_islow_8;
}
}
if (ARCH_PPC)
ff_fdctdsp_init_ppc(c, avctx, high_bit_depth);
if (ARCH_X86)
ff_fdctdsp_init_x86(c, avctx, high_bit_depth);
}
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_FDCTDSP_H
#define AVCODEC_FDCTDSP_H
#include <stdint.h>
#include "avcodec.h"
typedef struct FDCTDSPContext {
void (*fdct)(int16_t *block /* align 16 */);
void (*fdct248)(int16_t *block /* align 16 */);
} FDCTDSPContext;
void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx);
void ff_fdctdsp_init_ppc(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth);
void ff_fdctdsp_init_x86(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth);
#endif /* AVCODEC_FDCTDSP_H */
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "blockdsp.h" #include "blockdsp.h"
#include "dsputil.h" #include "dsputil.h"
#include "error_resilience.h" #include "error_resilience.h"
#include "fdctdsp.h"
#include "get_bits.h" #include "get_bits.h"
#include "h263dsp.h" #include "h263dsp.h"
#include "hpeldsp.h" #include "hpeldsp.h"
...@@ -355,6 +356,7 @@ typedef struct MpegEncContext { ...@@ -355,6 +356,7 @@ typedef struct MpegEncContext {
BlockDSPContext bdsp; BlockDSPContext bdsp;
DSPContext dsp; ///< pointers for accelerated dsp functions DSPContext dsp; ///< pointers for accelerated dsp functions
FDCTDSPContext fdsp;
HpelDSPContext hdsp; HpelDSPContext hdsp;
IDCTDSPContext idsp; IDCTDSPContext idsp;
MpegVideoDSPContext mdsp; MpegVideoDSPContext mdsp;
......
...@@ -77,15 +77,15 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], ...@@ -77,15 +77,15 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
const uint16_t *quant_matrix, const uint16_t *quant_matrix,
int bias, int qmin, int qmax, int intra) int bias, int qmin, int qmax, int intra)
{ {
DSPContext *dsp = &s->dsp; FDCTDSPContext *fdsp = &s->fdsp;
int qscale; int qscale;
int shift = 0; int shift = 0;
for (qscale = qmin; qscale <= qmax; qscale++) { for (qscale = qmin; qscale <= qmax; qscale++) {
int i; int i;
if (dsp->fdct == ff_jpeg_fdct_islow_8 || if (fdsp->fdct == ff_jpeg_fdct_islow_8 ||
dsp->fdct == ff_jpeg_fdct_islow_10 || fdsp->fdct == ff_jpeg_fdct_islow_10 ||
dsp->fdct == ff_faandct) { fdsp->fdct == ff_faandct) {
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i]; const int j = s->idsp.idct_permutation[i];
/* 16 <= qscale * quant_matrix[i] <= 7905 /* 16 <= qscale * quant_matrix[i] <= 7905
...@@ -97,7 +97,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], ...@@ -97,7 +97,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) /
(qscale * quant_matrix[j])); (qscale * quant_matrix[j]));
} }
} else if (dsp->fdct == ff_fdct_ifast) { } else if (fdsp->fdct == ff_fdct_ifast) {
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i]; const int j = s->idsp.idct_permutation[i];
/* 16 <= qscale * quant_matrix[i] <= 7905 /* 16 <= qscale * quant_matrix[i] <= 7905
...@@ -136,7 +136,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], ...@@ -136,7 +136,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
for (i = intra; i < 64; i++) { for (i = intra; i < 64; i++) {
int64_t max = 8191; int64_t max = 8191;
if (dsp->fdct == ff_fdct_ifast) { if (fdsp->fdct == ff_fdct_ifast) {
max = (8191LL * ff_aanscales[i]) >> 14; max = (8191LL * ff_aanscales[i]) >> 14;
} }
while (((max * qmat[qscale][i]) >> shift) > INT_MAX) { while (((max * qmat[qscale][i]) >> shift) > INT_MAX) {
...@@ -701,6 +701,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) ...@@ -701,6 +701,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
if (ARCH_X86) if (ARCH_X86)
ff_MPV_encode_init_x86(s); ff_MPV_encode_init_x86(s);
ff_fdctdsp_init(&s->fdsp, avctx);
ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
ff_qpeldsp_init(&s->qdsp); ff_qpeldsp_init(&s->qdsp);
...@@ -3492,7 +3493,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, ...@@ -3492,7 +3493,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
uint8_t * last_length; uint8_t * last_length;
const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6); const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
s->dsp.fdct (block); s->fdsp.fdct(block);
if(s->dct_error_sum) if(s->dct_error_sum)
s->denoise_dct(s, block); s->denoise_dct(s, block);
...@@ -3587,7 +3588,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, ...@@ -3587,7 +3588,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
int dct_coeff= FFABS(block[ scantable[i] ]); int dct_coeff= FFABS(block[ scantable[i] ]);
int best_score=256*256*256*120; int best_score=256*256*256*120;
if (s->dsp.fdct == ff_fdct_ifast) if (s->fdsp.fdct == ff_fdct_ifast)
dct_coeff= (dct_coeff*ff_inv_aanscales[ scantable[i] ]) >> 12; dct_coeff= (dct_coeff*ff_inv_aanscales[ scantable[i] ]) >> 12;
zero_distortion= dct_coeff*dct_coeff; zero_distortion= dct_coeff*dct_coeff;
...@@ -3919,7 +3920,7 @@ STOP_TIMER("init rem[]") ...@@ -3919,7 +3920,7 @@ STOP_TIMER("init rem[]")
STOP_TIMER("rem*w*w")} STOP_TIMER("rem*w*w")}
{START_TIMER {START_TIMER
#endif #endif
s->dsp.fdct(d1); s->fdsp.fdct(d1);
#ifdef REFINE_STATS #ifdef REFINE_STATS
STOP_TIMER("dct")} STOP_TIMER("dct")}
#endif #endif
...@@ -4166,7 +4167,7 @@ int ff_dct_quantize_c(MpegEncContext *s, ...@@ -4166,7 +4167,7 @@ int ff_dct_quantize_c(MpegEncContext *s,
int max=0; int max=0;
unsigned int threshold1, threshold2; unsigned int threshold1, threshold2;
s->dsp.fdct (block); s->fdsp.fdct(block);
if(s->dct_error_sum) if(s->dct_error_sum)
s->denoise_dct(s, block); s->denoise_dct(s, block);
......
...@@ -9,6 +9,7 @@ OBJS-$(CONFIG_H264DSP) += ppc/h264dsp.o ...@@ -9,6 +9,7 @@ OBJS-$(CONFIG_H264DSP) += ppc/h264dsp.o
OBJS-$(CONFIG_H264QPEL) += ppc/h264qpel.o OBJS-$(CONFIG_H264QPEL) += ppc/h264qpel.o
OBJS-$(CONFIG_HPELDSP) += ppc/hpeldsp_altivec.o OBJS-$(CONFIG_HPELDSP) += ppc/hpeldsp_altivec.o
OBJS-$(CONFIG_HUFFYUVDSP) += ppc/huffyuvdsp_altivec.o OBJS-$(CONFIG_HUFFYUVDSP) += ppc/huffyuvdsp_altivec.o
OBJS-$(CONFIG_FDCTDSP) += ppc/fdctdsp.o
OBJS-$(CONFIG_IDCTDSP) += ppc/idctdsp.o OBJS-$(CONFIG_IDCTDSP) += ppc/idctdsp.o
OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o
OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \ OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \
...@@ -25,7 +26,6 @@ OBJS-$(CONFIG_VP7_DECODER) += ppc/vp8dsp_altivec.o ...@@ -25,7 +26,6 @@ OBJS-$(CONFIG_VP7_DECODER) += ppc/vp8dsp_altivec.o
OBJS-$(CONFIG_VP8_DECODER) += ppc/vp8dsp_altivec.o OBJS-$(CONFIG_VP8_DECODER) += ppc/vp8dsp_altivec.o
ALTIVEC-OBJS-$(CONFIG_DSPUTIL) += ppc/dsputil_altivec.o \ ALTIVEC-OBJS-$(CONFIG_DSPUTIL) += ppc/dsputil_altivec.o \
ppc/fdct_altivec.o \
FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o
ALTIVEC-OBJS-$(CONFIG_FFT) += $(FFT-OBJS-yes) ALTIVEC-OBJS-$(CONFIG_FFT) += $(FFT-OBJS-yes)
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
void ff_fdct_altivec(int16_t *block);
void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx, void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth); unsigned high_bit_depth);
......
...@@ -34,14 +34,5 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx, ...@@ -34,14 +34,5 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx,
{ {
if (PPC_ALTIVEC(av_get_cpu_flags())) { if (PPC_ALTIVEC(av_get_cpu_flags())) {
ff_dsputil_init_altivec(c, avctx, high_bit_depth); ff_dsputil_init_altivec(c, avctx, high_bit_depth);
if (!high_bit_depth) {
#if CONFIG_ENCODERS
if (avctx->dct_algo == FF_DCT_AUTO ||
avctx->dct_algo == FF_DCT_ALTIVEC) {
c->fdct = ff_fdct_altivec;
}
#endif //CONFIG_ENCODERS
}
} }
} }
...@@ -23,8 +23,13 @@ ...@@ -23,8 +23,13 @@
#include <altivec.h> #include <altivec.h>
#endif #endif
#include "libavutil/common.h" #include "libavutil/attributes.h"
#include "dsputil_altivec.h" #include "libavutil/cpu.h"
#include "libavutil/ppc/cpu.h"
#include "libavcodec/fdctdsp.h"
#include "fdctdsp.h"
#if HAVE_ALTIVEC
#define vs16(v) ((vector signed short) (v)) #define vs16(v) ((vector signed short) (v))
#define vs32(v) ((vector signed int) (v)) #define vs32(v) ((vector signed int) (v))
...@@ -454,3 +459,21 @@ void ff_fdct_altivec(int16_t *block) ...@@ -454,3 +459,21 @@ void ff_fdct_altivec(int16_t *block)
#undef CTS #undef CTS
/* }}} */ /* }}} */
} }
#endif /* HAVE_ALTIVEC */
av_cold void ff_fdctdsp_init_ppc(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
#if HAVE_ALTIVEC
if (!PPC_ALTIVEC(av_get_cpu_flags()))
return;
if (!high_bit_depth) {
if (avctx->dct_algo == FF_DCT_AUTO ||
avctx->dct_algo == FF_DCT_ALTIVEC) {
c->fdct = ff_fdct_altivec;
}
}
#endif /* HAVE_ALTIVEC */
}
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_PPC_FDCTDSP_H
#define AVCODEC_PPC_FDCTDSP_H
#include <stdint.h>
void ff_fdct_altivec(int16_t *block);
#endif /* AVCODEC_PPC_FDCTDSP_H */
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "avcodec.h" #include "avcodec.h"
#include "dct.h" #include "fdctdsp.h"
#include "dsputil.h"
#include "put_bits.h" #include "put_bits.h"
#include "bytestream.h" #include "bytestream.h"
#include "internal.h" #include "internal.h"
...@@ -192,9 +191,9 @@ typedef struct ProresContext { ...@@ -192,9 +191,9 @@ typedef struct ProresContext {
const uint8_t *quant_mat; const uint8_t *quant_mat;
const uint8_t *scantable; const uint8_t *scantable;
void (* fdct)(DSPContext *dsp, const uint16_t *src, void (*fdct)(FDCTDSPContext *fdsp, const uint16_t *src,
int linesize, int16_t *block); int linesize, int16_t *block);
DSPContext dsp; FDCTDSPContext fdsp;
int mb_width, mb_height; int mb_width, mb_height;
int mbs_per_slice; int mbs_per_slice;
...@@ -263,27 +262,27 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src, ...@@ -263,27 +262,27 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src,
mb_width * sizeof(*emu_buf)); mb_width * sizeof(*emu_buf));
} }
if (!is_chroma) { if (!is_chroma) {
ctx->fdct(&ctx->dsp, esrc, elinesize, blocks); ctx->fdct(&ctx->fdsp, esrc, elinesize, blocks);
blocks += 64; blocks += 64;
if (blocks_per_mb > 2) { if (blocks_per_mb > 2) {
ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks); ctx->fdct(&ctx->fdsp, esrc + 8, elinesize, blocks);
blocks += 64; blocks += 64;
} }
ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks); ctx->fdct(&ctx->fdsp, esrc + elinesize * 4, elinesize, blocks);
blocks += 64; blocks += 64;
if (blocks_per_mb > 2) { if (blocks_per_mb > 2) {
ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks); ctx->fdct(&ctx->fdsp, esrc + elinesize * 4 + 8, elinesize, blocks);
blocks += 64; blocks += 64;
} }
} else { } else {
ctx->fdct(&ctx->dsp, esrc, elinesize, blocks); ctx->fdct(&ctx->fdsp, esrc, elinesize, blocks);
blocks += 64; blocks += 64;
ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks); ctx->fdct(&ctx->fdsp, esrc + elinesize * 4, elinesize, blocks);
blocks += 64; blocks += 64;
if (blocks_per_mb > 2) { if (blocks_per_mb > 2) {
ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks); ctx->fdct(&ctx->fdsp, esrc + 8, elinesize, blocks);
blocks += 64; blocks += 64;
ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks); ctx->fdct(&ctx->fdsp, esrc + elinesize * 4 + 8, elinesize, blocks);
blocks += 64; blocks += 64;
} }
} }
...@@ -1068,7 +1067,7 @@ static av_cold int encode_close(AVCodecContext *avctx) ...@@ -1068,7 +1067,7 @@ static av_cold int encode_close(AVCodecContext *avctx)
return 0; return 0;
} }
static void prores_fdct(DSPContext *dsp, const uint16_t *src, static void prores_fdct(FDCTDSPContext *fdsp, const uint16_t *src,
int linesize, int16_t *block) int linesize, int16_t *block)
{ {
int x, y; int x, y;
...@@ -1079,7 +1078,7 @@ static void prores_fdct(DSPContext *dsp, const uint16_t *src, ...@@ -1079,7 +1078,7 @@ static void prores_fdct(DSPContext *dsp, const uint16_t *src,
block[y * 8 + x] = tsrc[x]; block[y * 8 + x] = tsrc[x];
tsrc += linesize >> 1; tsrc += linesize >> 1;
} }
dsp->fdct(block); fdsp->fdct(block);
} }
static av_cold int encode_init(AVCodecContext *avctx) static av_cold int encode_init(AVCodecContext *avctx)
...@@ -1098,7 +1097,7 @@ static av_cold int encode_init(AVCodecContext *avctx) ...@@ -1098,7 +1097,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
ctx->fdct = prores_fdct; ctx->fdct = prores_fdct;
ctx->scantable = interlaced ? ff_prores_interlaced_scan ctx->scantable = interlaced ? ff_prores_interlaced_scan
: ff_prores_progressive_scan; : ff_prores_progressive_scan;
ff_dsputil_init(&ctx->dsp, avctx); ff_fdctdsp_init(&ctx->fdsp, avctx);
mps = ctx->mbs_per_slice; mps = ctx->mbs_per_slice;
if (mps & (mps - 1)) { if (mps & (mps - 1)) {
......
...@@ -9,6 +9,7 @@ OBJS-$(CONFIG_DCT) += x86/dct_init.o ...@@ -9,6 +9,7 @@ OBJS-$(CONFIG_DCT) += x86/dct_init.o
OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_init.o OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_init.o
OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o \ OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o \
x86/motion_est.o x86/motion_est.o
OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o
OBJS-$(CONFIG_FFT) += x86/fft_init.o OBJS-$(CONFIG_FFT) += x86/fft_init.o
OBJS-$(CONFIG_H263DSP) += x86/h263dsp_init.o OBJS-$(CONFIG_H263DSP) += x86/h263dsp_init.o
OBJS-$(CONFIG_H264CHROMA) += x86/h264chroma_init.o OBJS-$(CONFIG_H264CHROMA) += x86/h264chroma_init.o
...@@ -51,9 +52,9 @@ OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp_init.o ...@@ -51,9 +52,9 @@ OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp_init.o
OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o
MMX-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_mmx.o MMX-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_mmx.o
MMX-OBJS-$(CONFIG_ENCODERS) += x86/fdct.o
MMX-OBJS-$(CONFIG_HPELDSP) += x86/fpel_mmx.o \ MMX-OBJS-$(CONFIG_HPELDSP) += x86/fpel_mmx.o \
x86/hpeldsp_mmx.o x86/hpeldsp_mmx.o
MMX-OBJS-$(CONFIG_FDCTDSP) += x86/fdct.o
MMX-OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_mmx.o \ MMX-OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_mmx.o \
x86/idct_mmx_xvid.o \ x86/idct_mmx_xvid.o \
x86/idct_sse2_xvid.o \ x86/idct_sse2_xvid.o \
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "libavutil/cpu.h" #include "libavutil/cpu.h"
#include "libavutil/x86/asm.h" #include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h" #include "libavutil/x86/cpu.h"
#include "libavcodec/dct.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "libavcodec/mpegvideo.h" #include "libavcodec/mpegvideo.h"
#include "dsputil_x86.h" #include "dsputil_x86.h"
...@@ -823,7 +822,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, ...@@ -823,7 +822,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth) unsigned high_bit_depth)
{ {
int cpu_flags = av_get_cpu_flags(); int cpu_flags = av_get_cpu_flags();
const int dct_algo = avctx->dct_algo;
if (EXTERNAL_MMX(cpu_flags)) { if (EXTERNAL_MMX(cpu_flags)) {
if (!high_bit_depth) if (!high_bit_depth)
...@@ -837,10 +835,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, ...@@ -837,10 +835,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
#if HAVE_INLINE_ASM #if HAVE_INLINE_ASM
if (INLINE_MMX(cpu_flags)) { if (INLINE_MMX(cpu_flags)) {
if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_mmx;
c->sum_abs_dctelem = sum_abs_dctelem_mmx; c->sum_abs_dctelem = sum_abs_dctelem_mmx;
c->sse[0] = sse16_mmx; c->sse[0] = sse16_mmx;
...@@ -855,10 +849,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, ...@@ -855,10 +849,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
} }
if (INLINE_MMXEXT(cpu_flags)) { if (INLINE_MMXEXT(cpu_flags)) {
if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_mmxext;
c->sum_abs_dctelem = sum_abs_dctelem_mmxext; c->sum_abs_dctelem = sum_abs_dctelem_mmxext;
c->vsad[4] = vsad_intra16_mmxext; c->vsad[4] = vsad_intra16_mmxext;
...@@ -868,10 +858,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, ...@@ -868,10 +858,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
} }
if (INLINE_SSE2(cpu_flags)) { if (INLINE_SSE2(cpu_flags)) {
if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_sse2;
c->sum_abs_dctelem = sum_abs_dctelem_sse2; c->sum_abs_dctelem = sum_abs_dctelem_sse2;
} }
......
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* 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
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/dct.h"
#include "libavcodec/fdctdsp.h"
av_cold void ff_fdctdsp_init_x86(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
const int dct_algo = avctx->dct_algo;
if (!high_bit_depth) {
if ((dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX)) {
if (INLINE_MMX(cpu_flags))
c->fdct = ff_fdct_mmx;
if (INLINE_MMXEXT(cpu_flags))
c->fdct = ff_fdct_mmxext;
if (INLINE_SSE2(cpu_flags))
c->fdct = ff_fdct_sse2;
}
}
}
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