diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-07-08 03:12:10 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-07-08 03:19:06 +0200 |
commit | 14e2406de7d211d50fcce0059c90103bdaa947aa (patch) | |
tree | 10e20cd60b4f4bc91d14957b9565871cdd0381c3 /libavcodec | |
parent | 5c7bf354dc0c8bea6e7af21c0bc2edad92974274 (diff) | |
parent | a9aee08d900f686e966c64afec5d88a7d9d130a3 (diff) | |
download | ffmpeg-14e2406de7d211d50fcce0059c90103bdaa947aa.tar.gz |
Merge commit 'a9aee08d900f686e966c64afec5d88a7d9d130a3'
* commit 'a9aee08d900f686e966c64afec5d88a7d9d130a3':
dsputil: Split off FDCT bits into their own context
Conflicts:
configure
libavcodec/Makefile
libavcodec/asvenc.c
libavcodec/dnxhdenc.c
libavcodec/dsputil.c
libavcodec/mpegvideo.h
libavcodec/mpegvideo_enc.c
libavcodec/x86/Makefile
libavcodec/x86/dsputilenc_mmx.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/Makefile | 3 | ||||
-rw-r--r-- | libavcodec/asv.h | 2 | ||||
-rw-r--r-- | libavcodec/asvenc.c | 6 | ||||
-rw-r--r-- | libavcodec/dnxhdenc.c | 4 | ||||
-rw-r--r-- | libavcodec/dsputil.c | 24 | ||||
-rw-r--r-- | libavcodec/dsputil.h | 4 | ||||
-rw-r--r-- | libavcodec/dvenc.c | 7 | ||||
-rw-r--r-- | libavcodec/fdctdsp.c | 50 | ||||
-rw-r--r-- | libavcodec/fdctdsp.h | 37 | ||||
-rw-r--r-- | libavcodec/libavcodec.v | 1 | ||||
-rw-r--r-- | libavcodec/mpegvideo.h | 2 | ||||
-rw-r--r-- | libavcodec/mpegvideo_enc.c | 21 | ||||
-rw-r--r-- | libavcodec/ppc/Makefile | 2 | ||||
-rw-r--r-- | libavcodec/ppc/dsputil_altivec.h | 2 | ||||
-rw-r--r-- | libavcodec/ppc/dsputil_ppc.c | 9 | ||||
-rw-r--r-- | libavcodec/ppc/fdctdsp.c (renamed from libavcodec/ppc/fdct_altivec.c) | 27 | ||||
-rw-r--r-- | libavcodec/ppc/fdctdsp.h | 26 | ||||
-rw-r--r-- | libavcodec/proresenc_anatoliy.c | 19 | ||||
-rw-r--r-- | libavcodec/proresenc_kostya.c | 31 | ||||
-rw-r--r-- | libavcodec/x86/Makefile | 3 | ||||
-rw-r--r-- | libavcodec/x86/dsputilenc_mmx.c | 13 | ||||
-rw-r--r-- | libavcodec/x86/fdctdsp_init.c | 44 |
22 files changed, 242 insertions, 95 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 51d2dd0299..b75bcd27f9 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -41,9 +41,10 @@ OBJS-$(CONFIG_CRYSTALHD) += crystalhd.o OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o OBJS-$(CONFIG_DSPUTIL) += dsputil.o OBJS-$(CONFIG_DXVA2) += dxva2.o -OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o OBJS-$(CONFIG_EXIF) += exif.o tiff_common.o +OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o faandct.o \ + jfdctfst.o jfdctint.o FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \ fft_fixed_32.o fft_init_table.o \ diff --git a/libavcodec/asv.h b/libavcodec/asv.h index 6f89dcc27c..e1f90e51ec 100644 --- a/libavcodec/asv.h +++ b/libavcodec/asv.h @@ -34,6 +34,7 @@ #include "blockdsp.h" #include "bswapdsp.h" #include "dsputil.h" +#include "fdctdsp.h" #include "idctdsp.h" #include "get_bits.h" #include "put_bits.h" @@ -43,6 +44,7 @@ typedef struct ASV1Context{ BlockDSPContext bdsp; BswapDSPContext bbdsp; DSPContext dsp; + FDCTDSPContext fdsp; IDCTDSPContext idsp; PutBitContext pb; GetBitContext gb; diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c index c27e652efe..ae81953f30 100644 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@ -28,6 +28,7 @@ #include "asv.h" #include "avcodec.h" +#include "fdctdsp.h" #include "internal.h" #include "mathops.h" #include "mpeg12data.h" @@ -164,13 +165,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[3], ptr_y + 8*linesize + 8, linesize); for(i=0; i<4; i++) - a->dsp.fdct(block[i]); + a->fdsp.fdct(block[i]); if(!(a->avctx->flags&CODEC_FLAG_GRAY)){ a->dsp.get_pixels(block[4], ptr_cb, frame->linesize[1]); a->dsp.get_pixels(block[5], ptr_cr, frame->linesize[2]); for(i=4; i<6; i++) - a->dsp.fdct(block[i]); + a->fdsp.fdct(block[i]); } } @@ -282,6 +283,7 @@ static av_cold int encode_init(AVCodecContext *avctx){ ff_asv_common_init(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; diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 45b882da40..f6f9af833a 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "blockdsp.h" #include "dsputil.h" +#include "fdctdsp.h" #include "internal.h" #include "mpegvideo.h" #include "dnxhdenc.h" @@ -109,7 +110,7 @@ static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, int16_t *block, int last_non_zero = 0; int i; - ctx->dsp.fdct(block); + ctx->fdsp.fdct(block); // Divide by 4 with rounding, to compensate scaling of DCT coefficients block[0] = (block[0] + 2) >> 2; @@ -322,6 +323,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) avctx->bits_per_raw_sample = ctx->cid_table->bit_depth; ff_blockdsp_init(&ctx->bdsp, avctx); + ff_fdctdsp_init(&ctx->m.fdsp, avctx); ff_idctdsp_init(&ctx->m.idsp, avctx); ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx); ff_dct_common_init(&ctx->m); diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 5d7fbb1126..c68a70a79e 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -29,10 +29,8 @@ #include "libavutil/internal.h" #include "avcodec.h" #include "copy_block.h" -#include "dct.h" #include "dsputil.h" #include "simple_idct.h" -#include "faandct.h" #include "mpegvideo.h" #include "config.h" @@ -589,7 +587,7 @@ static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1, av_assert2(h == 8); s->dsp.diff_pixels(temp, src1, src2, stride); - s->dsp.fdct(temp); + s->fdsp.fdct(temp); return s->dsp.sum_abs_dctelem(temp); } @@ -656,7 +654,7 @@ static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1, av_assert2(h == 8); s->dsp.diff_pixels(temp, src1, src2, stride); - s->dsp.fdct(temp); + s->fdsp.fdct(temp); for (i = 0; i < 64; i++) sum = FFMAX(sum, FFABS(temp[i])); @@ -973,24 +971,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) ff_check_alignment(); -#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->sum_abs_dctelem = sum_abs_dctelem_c; diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 0d7dd14734..ea5d13c72d 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -95,10 +95,6 @@ typedef struct DSPContext { me_cmp_func frame_skip_cmp[6]; // only width 8 used me_cmp_func pix_abs[2][4]; - - /* (I)DCT */ - void (*fdct)(int16_t *block /* align 16 */); - void (*fdct248)(int16_t *block /* align 16 */); } DSPContext; void ff_dsputil_static_init(void); diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index d1e7707b02..b01122eacc 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -29,6 +29,7 @@ #include "config.h" #include "avcodec.h" #include "dsputil.h" +#include "fdctdsp.h" #include "internal.h" #include "put_bits.h" #include "dv.h" @@ -38,6 +39,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) { DVVideoContext *s = avctx->priv_data; DSPContext dsp; + FDCTDSPContext fdsp; int ret; s->sys = avpriv_dv_codec_profile(avctx); @@ -66,13 +68,14 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) memset(&dsp,0, sizeof(dsp)); ff_dsputil_init(&dsp, avctx); + ff_fdctdsp_init(&fdsp, avctx); ff_set_cmp(&dsp, dsp.ildct_cmp, avctx->ildct_cmp); s->get_pixels = dsp.get_pixels; s->ildct_cmp = dsp.ildct_cmp[5]; - s->fdct[0] = dsp.fdct; - s->fdct[1] = dsp.fdct248; + s->fdct[0] = fdsp.fdct; + s->fdct[1] = fdsp.fdct248; return ff_dvvideo_init(avctx); } diff --git a/libavcodec/fdctdsp.c b/libavcodec/fdctdsp.c new file mode 100644 index 0000000000..f75eed5086 --- /dev/null +++ b/libavcodec/fdctdsp.c @@ -0,0 +1,50 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; 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); +} diff --git a/libavcodec/fdctdsp.h b/libavcodec/fdctdsp.h new file mode 100644 index 0000000000..3e1f683b9e --- /dev/null +++ b/libavcodec/fdctdsp.h @@ -0,0 +1,37 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; 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 */ diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index 54402833ac..5909dce46b 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -28,5 +28,6 @@ LIBAVCODEC_$MAJOR { ff_dnxhd_get_cid_table; ff_dnxhd_cid_table; ff_idctdsp_init; + ff_fdctdsp_init; local: *; }; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index cf0c47b4dd..f2d884bad5 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -32,6 +32,7 @@ #include "blockdsp.h" #include "dsputil.h" #include "error_resilience.h" +#include "fdctdsp.h" #include "get_bits.h" #include "h264chroma.h" #include "h263dsp.h" @@ -364,6 +365,7 @@ typedef struct MpegEncContext { BlockDSPContext bdsp; DSPContext dsp; ///< pointers for accelerated dsp functions + FDCTDSPContext fdsp; H264ChromaContext h264chroma; HpelDSPContext hdsp; IDCTDSPContext idsp; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index d39f88edde..826f061eea 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -78,15 +78,15 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra) { - DSPContext *dsp = &s->dsp; + FDCTDSPContext *fdsp = &s->fdsp; int qscale; int shift = 0; for (qscale = qmin; qscale <= qmax; qscale++) { int i; - if (dsp->fdct == ff_jpeg_fdct_islow_8 || - dsp->fdct == ff_jpeg_fdct_islow_10 || - dsp->fdct == ff_faandct) { + if (fdsp->fdct == ff_jpeg_fdct_islow_8 || + fdsp->fdct == ff_jpeg_fdct_islow_10 || + fdsp->fdct == ff_faandct) { for (i = 0; i < 64; i++) { const int j = s->idsp.idct_permutation[i]; /* 16 <= qscale * quant_matrix[i] <= 7905 @@ -98,7 +98,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); } - } else if (dsp->fdct == ff_fdct_ifast) { + } else if (fdsp->fdct == ff_fdct_ifast) { for (i = 0; i < 64; i++) { const int j = s->idsp.idct_permutation[i]; /* 16 <= qscale * quant_matrix[i] <= 7905 @@ -136,7 +136,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], for (i = intra; i < 64; i++) { int64_t max = 8191; - if (dsp->fdct == ff_fdct_ifast) { + if (fdsp->fdct == ff_fdct_ifast) { max = (8191LL * ff_aanscales[i]) >> 14; } while (((max * qmat[qscale][i]) >> shift) > INT_MAX) { @@ -818,6 +818,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) if (ff_MPV_common_init(s) < 0) return -1; + ff_fdctdsp_init(&s->fdsp, avctx); ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); ff_qpeldsp_init(&s->qdsp); @@ -3714,7 +3715,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, uint8_t * last_length; const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6); - s->dsp.fdct (block); + s->fdsp.fdct(block); if(s->dct_error_sum) s->denoise_dct(s, block); @@ -3809,7 +3810,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, int dct_coeff= FFABS(block[ scantable[i] ]); 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; zero_distortion= dct_coeff*dct_coeff; @@ -4141,7 +4142,7 @@ STOP_TIMER("init rem[]") STOP_TIMER("rem*w*w")} {START_TIMER #endif - s->dsp.fdct(d1); + s->fdsp.fdct(d1); #ifdef REFINE_STATS STOP_TIMER("dct")} #endif @@ -4388,7 +4389,7 @@ int ff_dct_quantize_c(MpegEncContext *s, int max=0; unsigned int threshold1, threshold2; - s->dsp.fdct (block); + s->fdsp.fdct(block); if(s->dct_error_sum) s->denoise_dct(s, block); diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile index c357dafbac..8f0f0ff308 100644 --- a/libavcodec/ppc/Makefile +++ b/libavcodec/ppc/Makefile @@ -9,6 +9,7 @@ OBJS-$(CONFIG_H264DSP) += ppc/h264dsp.o ppc/hpeldsp_altivec.o OBJS-$(CONFIG_H264QPEL) += ppc/h264qpel.o OBJS-$(CONFIG_HPELDSP) += ppc/hpeldsp_altivec.o OBJS-$(CONFIG_HUFFYUVDSP) += ppc/huffyuvdsp_altivec.o +OBJS-$(CONFIG_FDCTDSP) += ppc/fdctdsp.o OBJS-$(CONFIG_IDCTDSP) += ppc/idctdsp.o OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \ @@ -25,7 +26,6 @@ OBJS-$(CONFIG_VP7_DECODER) += ppc/vp8dsp_altivec.o OBJS-$(CONFIG_VP8_DECODER) += ppc/vp8dsp_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_VSX) += ppc/fft_vsx.o diff --git a/libavcodec/ppc/dsputil_altivec.h b/libavcodec/ppc/dsputil_altivec.h index aa90d348b6..d4a97af479 100644 --- a/libavcodec/ppc/dsputil_altivec.h +++ b/libavcodec/ppc/dsputil_altivec.h @@ -27,8 +27,6 @@ #include "libavcodec/dsputil.h" -void ff_fdct_altivec(int16_t *block); - void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index e0db9d484d..720aafba80 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -35,14 +35,5 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx, int mm_flags = av_get_cpu_flags(); if (PPC_ALTIVEC(mm_flags)) { 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 - } } } diff --git a/libavcodec/ppc/fdct_altivec.c b/libavcodec/ppc/fdctdsp.c index e6f36497ac..561e469ab8 100644 --- a/libavcodec/ppc/fdct_altivec.c +++ b/libavcodec/ppc/fdctdsp.c @@ -23,8 +23,13 @@ #include <altivec.h> #endif -#include "libavutil/common.h" -#include "dsputil_altivec.h" +#include "libavutil/attributes.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 vs32(v) ((vector signed int) (v)) @@ -454,3 +459,21 @@ void ff_fdct_altivec(int16_t *block) #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 */ +} diff --git a/libavcodec/ppc/fdctdsp.h b/libavcodec/ppc/fdctdsp.h new file mode 100644 index 0000000000..89be76846f --- /dev/null +++ b/libavcodec/ppc/fdctdsp.h @@ -0,0 +1,26 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; 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 */ diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index 23323bb7fa..434021d6a6 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -32,6 +32,7 @@ #include "put_bits.h" #include "bytestream.h" #include "dsputil.h" +#include "fdctdsp.h" #define DEFAULT_SLICE_MB_WIDTH 8 @@ -145,7 +146,7 @@ static const uint8_t QMAT_CHROMA[4][64] = { typedef struct { - DSPContext dsp; + FDCTDSPContext fdsp; uint8_t* fill_y; uint8_t* fill_u; uint8_t* fill_v; @@ -274,10 +275,10 @@ static void get(uint8_t *pixels, int stride, int16_t* block) } } -static void fdct_get(DSPContext *dsp, uint8_t *pixels, int stride, int16_t* block) +static void fdct_get(FDCTDSPContext *fdsp, uint8_t *pixels, int stride, int16_t* block) { get(pixels, stride, block); - dsp->fdct(block); + fdsp->fdct(block); } static int encode_slice_plane(AVCodecContext *avctx, int mb_count, @@ -285,18 +286,18 @@ static int encode_slice_plane(AVCodecContext *avctx, int mb_count, int *qmat, int chroma) { ProresContext* ctx = avctx->priv_data; - DSPContext *dsp = &ctx->dsp; + FDCTDSPContext *fdsp = &ctx->fdsp; DECLARE_ALIGNED(16, int16_t, blocks)[DEFAULT_SLICE_MB_WIDTH << 8], *block; int i, blocks_per_slice; PutBitContext pb; block = blocks; for (i = 0; i < mb_count; i++) { - fdct_get(dsp, src, src_stride, block + (0 << 6)); - fdct_get(dsp, src + 8 * src_stride, src_stride, block + ((2 - chroma) << 6)); + fdct_get(fdsp, src, src_stride, block + (0 << 6)); + fdct_get(fdsp, src + 8 * src_stride, src_stride, block + ((2 - chroma) << 6)); if (!chroma) { - fdct_get(dsp, src + 16, src_stride, block + (1 << 6)); - fdct_get(dsp, src + 16 + 8 * src_stride, src_stride, block + (3 << 6)); + fdct_get(fdsp, src + 16, src_stride, block + (1 << 6)); + fdct_get(fdsp, src + 16 + 8 * src_stride, src_stride, block + (3 << 6)); } block += (256 >> chroma); @@ -576,7 +577,7 @@ static av_cold int prores_encode_init(AVCodecContext *avctx) return -1; } - ff_dsputil_init(&ctx->dsp, avctx); + ff_fdctdsp_init(&ctx->fdsp, avctx); avctx->codec_tag = AV_RL32((const uint8_t*)profiles[avctx->profile].name); diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c index ea1fd8ae7f..93bcde727d 100644 --- a/libavcodec/proresenc_kostya.c +++ b/libavcodec/proresenc_kostya.c @@ -26,8 +26,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avcodec.h" -#include "dct.h" -#include "dsputil.h" +#include "fdctdsp.h" #include "put_bits.h" #include "bytestream.h" #include "internal.h" @@ -195,9 +194,9 @@ typedef struct ProresContext { const uint8_t *quant_mat; const uint8_t *scantable; - void (* fdct)(DSPContext *dsp, const uint16_t *src, - int linesize, int16_t *block); - DSPContext dsp; + void (*fdct)(FDCTDSPContext *fdsp, const uint16_t *src, + int linesize, int16_t *block); + FDCTDSPContext fdsp; int mb_width, mb_height; int mbs_per_slice; @@ -266,27 +265,27 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src, mb_width * sizeof(*emu_buf)); } if (!is_chroma) { - ctx->fdct(&ctx->dsp, esrc, elinesize, blocks); + ctx->fdct(&ctx->fdsp, esrc, elinesize, blocks); blocks += 64; if (blocks_per_mb > 2) { - ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks); + ctx->fdct(&ctx->fdsp, esrc + 8, elinesize, blocks); blocks += 64; } - ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks); + ctx->fdct(&ctx->fdsp, esrc + elinesize * 4, elinesize, blocks); blocks += 64; 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; } } else { - ctx->fdct(&ctx->dsp, esrc, elinesize, blocks); + ctx->fdct(&ctx->fdsp, esrc, elinesize, blocks); blocks += 64; - ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks); + ctx->fdct(&ctx->fdsp, esrc + elinesize * 4, elinesize, blocks); blocks += 64; if (blocks_per_mb > 2) { - ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks); + ctx->fdct(&ctx->fdsp, esrc + 8, elinesize, blocks); blocks += 64; - ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks); + ctx->fdct(&ctx->fdsp, esrc + elinesize * 4 + 8, elinesize, blocks); blocks += 64; } } @@ -1066,7 +1065,7 @@ static av_cold int encode_close(AVCodecContext *avctx) 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 x, y; @@ -1077,7 +1076,7 @@ static void prores_fdct(DSPContext *dsp, const uint16_t *src, block[y * 8 + x] = tsrc[x]; tsrc += linesize >> 1; } - dsp->fdct(block); + fdsp->fdct(block); } static av_cold int encode_init(AVCodecContext *avctx) @@ -1096,7 +1095,7 @@ static av_cold int encode_init(AVCodecContext *avctx) ctx->fdct = prores_fdct; ctx->scantable = interlaced ? ff_prores_interlaced_scan : ff_prores_progressive_scan; - ff_dsputil_init(&ctx->dsp, avctx); + ff_fdctdsp_init(&ctx->fdsp, avctx); mps = ctx->mbs_per_slice; if (mps & (mps - 1)) { diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index adcf62746a..0843dcc774 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -9,6 +9,7 @@ OBJS-$(CONFIG_DCT) += x86/dct_init.o OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_init.o OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o \ x86/motion_est.o +OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o OBJS-$(CONFIG_FFT) += x86/fft_init.o OBJS-$(CONFIG_FLAC_DECODER) += x86/flacdsp_init.o OBJS-$(CONFIG_FLAC_ENCODER) += x86/flacdsp_init.o @@ -59,7 +60,7 @@ OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o OBJS-$(CONFIG_WEBP_DECODER) += x86/vp8dsp_init.o MMX-OBJS-$(CONFIG_DIRAC_DECODER) += x86/dirac_dwt.o -MMX-OBJS-$(CONFIG_ENCODERS) += x86/fdct.o +MMX-OBJS-$(CONFIG_FDCTDSP) += x86/fdct.o MMX-OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_mmx.o \ x86/idct_mmx_xvid.o \ x86/idct_sse2_xvid.o \ diff --git a/libavcodec/x86/dsputilenc_mmx.c b/libavcodec/x86/dsputilenc_mmx.c index 9e3078b144..d0936595d0 100644 --- a/libavcodec/x86/dsputilenc_mmx.c +++ b/libavcodec/x86/dsputilenc_mmx.c @@ -26,7 +26,6 @@ #include "libavutil/cpu.h" #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" -#include "libavcodec/dct.h" #include "libavcodec/dsputil.h" #include "libavcodec/mpegvideo.h" #include "dsputil_x86.h" @@ -353,7 +352,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) { int cpu_flags = av_get_cpu_flags(); - const int dct_algo = avctx->dct_algo; if (EXTERNAL_MMX(cpu_flags)) { if (!high_bit_depth) @@ -367,10 +365,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, #if HAVE_INLINE_ASM 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->vsad[4] = vsad_intra16_mmx; if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { @@ -379,10 +373,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, } 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->vsad[4] = vsad_intra16_mmxext; if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { @@ -391,9 +381,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, } if (INLINE_SSE2(cpu_flags)) { - if (!high_bit_depth && - (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX)) - c->fdct = ff_fdct_sse2; } #if HAVE_SSSE3_INLINE diff --git a/libavcodec/x86/fdctdsp_init.c b/libavcodec/x86/fdctdsp_init.c new file mode 100644 index 0000000000..261db979c5 --- /dev/null +++ b/libavcodec/x86/fdctdsp_init.c @@ -0,0 +1,44 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; 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; + } + } +} |