diff options
author | Diego Biurrun <diego@biurrun.de> | 2014-02-08 02:59:58 +0100 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2014-07-17 09:07:10 -0700 |
commit | 2d60444331fca1910510038dd3817bea885c2367 (patch) | |
tree | 51ac937c7e051b03c7cc8e39b079a37f18dd09b0 /libavcodec | |
parent | a578b0407dc983aecd72028e1127062689b67089 (diff) | |
download | ffmpeg-2d60444331fca1910510038dd3817bea885c2367.tar.gz |
dsputil: Split motion estimation compare bits off into their own context
Diffstat (limited to 'libavcodec')
30 files changed, 175 insertions, 206 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 632b0dabc7..7da6b7e93e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -35,7 +35,6 @@ OBJS-$(CONFIG_BLOCKDSP) += blockdsp.o OBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o OBJS-$(CONFIG_CABAC) += cabac.o OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o -OBJS-$(CONFIG_DSPUTIL) += dsputil.o OBJS-$(CONFIG_DXVA2) += dxva2.o OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o faandct.o \ @@ -60,6 +59,7 @@ OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o OBJS-$(CONFIG_LPC) += lpc.o OBJS-$(CONFIG_LSP) += lsp.o OBJS-$(CONFIG_MDCT) += mdct_fixed.o mdct_float.o +OBJS-$(CONFIG_ME_CMP) += me_cmp.o OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o OBJS-$(CONFIG_MPEGAUDIO) += mpegaudio.o mpegaudiodata.o \ mpegaudiodecheader.o diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index c6dc141eea..5c02e7f9de 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -36,6 +36,7 @@ #include "libavutil/internal.h" #include "libavutil/opt.h" #include "avcodec.h" +#include "me_cmp.h" #include "put_bits.h" #include "audiodsp.h" #include "ac3dsp.h" @@ -379,7 +380,7 @@ static void compute_exp_strategy(AC3EncodeContext *s) exp_strategy[blk] = EXP_NEW; continue; } - exp_diff = s->dsp.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16); + exp_diff = s->mecc.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16); exp_strategy[blk] = EXP_REUSE; if (ch == CPL_CH && exp_diff > (EXP_DIFF_THRESHOLD * (s->blocks[blk].end_freq[ch] - s->start_freq[ch]) / AC3_MAX_COEFS)) exp_strategy[blk] = EXP_NEW; @@ -2482,7 +2483,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) goto init_fail; ff_audiodsp_init(&s->adsp); - ff_dsputil_init(&s->dsp, avctx); + ff_me_cmp_init(&s->mecc, avctx); ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT); dprint_options(s); diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index b8e8768913..30c15d0d2f 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -35,9 +35,9 @@ #include "ac3.h" #include "ac3dsp.h" #include "avcodec.h" -#include "dsputil.h" #include "fft.h" #include "mathops.h" +#include "me_cmp.h" #include "put_bits.h" #include "audiodsp.h" @@ -162,9 +162,9 @@ typedef struct AC3EncodeContext { AC3EncOptions options; ///< encoding options AVCodecContext *avctx; ///< parent AVCodecContext PutBitContext pb; ///< bitstream writer context - DSPContext dsp; AudioDSPContext adsp; AVFloatDSPContext fdsp; + MECmpContext mecc; AC3DSPContext ac3dsp; ///< AC-3 optimized functions FFTContext mdct; ///< FFT context for MDCT calculation const SampleType *mdct_window; ///< MDCT window function array diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile index aab39c85bc..742c3ee726 100644 --- a/libavcodec/arm/Makefile +++ b/libavcodec/arm/Makefile @@ -6,7 +6,6 @@ OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_init_arm.o \ arm/ac3dsp_arm.o OBJS-$(CONFIG_AUDIODSP) += arm/audiodsp_init_arm.o OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_arm.o -OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_arm.o OBJS-$(CONFIG_FFT) += arm/fft_init_arm.o \ arm/fft_fixed_init_arm.o OBJS-$(CONFIG_H264CHROMA) += arm/h264chroma_init_arm.o @@ -19,6 +18,7 @@ OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_arm.o \ arm/idctdsp_arm.o \ arm/jrevdct_arm.o \ arm/simple_idct_arm.o +OBJS-$(CONFIG_ME_CMP) += arm/me_cmp_init_arm.o OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_arm.o OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_init_arm.o @@ -53,13 +53,13 @@ ARMV5TE-OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_armv5te.o \ ARMV5TE-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv5te.o ARMV6-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_armv6.o -ARMV6-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_armv6.o ARMV6-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_armv6.o ARMV6-OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_armv6.o \ arm/hpeldsp_armv6.o ARMV6-OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_armv6.o \ arm/idctdsp_armv6.o \ arm/simple_idct_armv6.o +ARMV6-OBJS-$(CONFIG_ME_CMP) += arm/me_cmp_armv6.o ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o ARMV6-OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_armv6.o ARMV6-OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_armv6.o diff --git a/libavcodec/arm/dsputil_armv6.S b/libavcodec/arm/me_cmp_armv6.S index 436e20dd25..436e20dd25 100644 --- a/libavcodec/arm/dsputil_armv6.S +++ b/libavcodec/arm/me_cmp_armv6.S diff --git a/libavcodec/arm/dsputil_init_arm.c b/libavcodec/arm/me_cmp_init_arm.c index f3fa61f171..819d901f90 100644 --- a/libavcodec/arm/dsputil_init_arm.c +++ b/libavcodec/arm/me_cmp_init_arm.c @@ -22,7 +22,7 @@ #include "libavutil/cpu.h" #include "libavutil/arm/cpu.h" #include "libavcodec/avcodec.h" -#include "libavcodec/dsputil.h" +#include "libavcodec/me_cmp.h" #include "libavcodec/mpegvideo.h" int ff_pix_abs16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, @@ -38,8 +38,7 @@ int ff_pix_abs8_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, int ff_sse16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, int line_size, int h); - -av_cold void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx) +av_cold void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx) { int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/dv.h b/libavcodec/dv.h index f162bb944f..019c15add9 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -28,7 +28,7 @@ #define AVCODEC_DV_H #include "avcodec.h" -#include "dsputil.h" +#include "me_cmp.h" #include "get_bits.h" #include "dv_profile.h" diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 9f458e3e47..5031218b05 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -28,9 +28,9 @@ #include "libavutil/pixdesc.h" #include "config.h" #include "avcodec.h" -#include "dsputil.h" #include "fdctdsp.h" #include "internal.h" +#include "me_cmp.h" #include "pixblockdsp.h" #include "put_bits.h" #include "dv.h" @@ -40,8 +40,8 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) { DVVideoContext *s = avctx->priv_data; - DSPContext dsp; FDCTDSPContext fdsp; + MECmpContext mecc; PixblockDSPContext pdsp; int ret; @@ -65,13 +65,13 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) dv_vlc_map_tableinit(); - ff_dsputil_init(&dsp, avctx); ff_fdctdsp_init(&fdsp, avctx); + ff_me_cmp_init(&mecc, avctx); ff_pixblockdsp_init(&pdsp, avctx); - ff_set_cmp(&dsp, dsp.ildct_cmp, avctx->ildct_cmp); + ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp); s->get_pixels = pdsp.get_pixels; - s->ildct_cmp = dsp.ildct_cmp[5]; + s->ildct_cmp = mecc.ildct_cmp[5]; s->fdct[0] = fdsp.fdct; s->fdct[1] = fdsp.fdct248; diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index 6ab5a980da..b41474ad48 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -715,11 +715,11 @@ FF_ENABLE_DEPRECATION_WARNINGS } else { ff_thread_await_progress(s->last_pic.tf, mb_y, 0); } - is_intra_likely += s->dsp->sad[0](NULL, last_mb_ptr, mb_ptr, - linesize[0], 16); - is_intra_likely -= s->dsp->sad[0](NULL, last_mb_ptr, - last_mb_ptr + linesize[0] * 16, - linesize[0], 16); + is_intra_likely += s->mecc->sad[0](NULL, last_mb_ptr, mb_ptr, + linesize[0], 16); + is_intra_likely -= s->mecc->sad[0](NULL, last_mb_ptr, + last_mb_ptr + linesize[0] * 16, + linesize[0], 16); } else { if (IS_INTRA(s->cur_pic.mb_type[mb_xy])) is_intra_likely++; diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h index 5171094a54..7b9ec1918e 100644 --- a/libavcodec/error_resilience.h +++ b/libavcodec/error_resilience.h @@ -23,7 +23,7 @@ #include <stdint.h> #include "avcodec.h" -#include "dsputil.h" +#include "me_cmp.h" #include "thread.h" ///< current MB is the first after a resync marker @@ -52,7 +52,7 @@ typedef struct ERPicture { typedef struct ERContext { AVCodecContext *avctx; - DSPContext *dsp; + MECmpContext *mecc; int *mb_index2xy; int mb_num; diff --git a/libavcodec/h264.c b/libavcodec/h264.c index dcd2ad831e..ba30e5d38e 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -33,7 +33,6 @@ #include "internal.h" #include "cabac.h" #include "cabac_functions.h" -#include "dsputil.h" #include "error_resilience.h" #include "avcodec.h" #include "h264.h" @@ -42,6 +41,7 @@ #include "h264_mvpred.h" #include "golomb.h" #include "mathops.h" +#include "me_cmp.h" #include "mpegutils.h" #include "rectangle.h" #include "svq3.h" @@ -490,7 +490,7 @@ int ff_h264_context_init(H264Context *h) if (CONFIG_ERROR_RESILIENCE) { /* init ER */ er->avctx = h->avctx; - er->dsp = &h->dsp; + er->mecc = &h->mecc; er->decode_mb = h264_er_decode_mb; er->opaque = h; er->quarter_sample = 1; @@ -620,7 +620,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) /* needed so that IDCT permutation is known early */ if (CONFIG_ERROR_RESILIENCE) - ff_dsputil_init(&h->dsp, h->avctx); + ff_me_cmp_init(&h->mecc, h->avctx); ff_videodsp_init(&h->vdsp, 8); memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t)); @@ -1234,7 +1234,7 @@ int ff_h264_set_parameter_from_sps(H264Context *h) ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma, h->sps.chroma_format_idc); if (CONFIG_ERROR_RESILIENCE) - ff_dsputil_init(&h->dsp, h->avctx); + ff_me_cmp_init(&h->mecc, h->avctx); ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma); } else { av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n", diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 39023dab63..cd4bf87690 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -30,13 +30,13 @@ #include "libavutil/intreadwrite.h" #include "cabac.h" -#include "dsputil.h" #include "error_resilience.h" #include "get_bits.h" #include "h264chroma.h" #include "h264dsp.h" #include "h264pred.h" #include "h264qpel.h" +#include "me_cmp.h" #include "mpegutils.h" #include "parser.h" #include "qpeldsp.h" @@ -302,7 +302,7 @@ typedef struct H264Picture { */ typedef struct H264Context { AVCodecContext *avctx; - DSPContext dsp; + MECmpContext mecc; VideoDSPContext vdsp; H264DSPContext h264dsp; H264ChromaContext h264chroma; diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 1b9f56b488..ce62fbf68e 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -31,7 +31,6 @@ #include "internal.h" #include "cabac.h" #include "cabac_functions.h" -#include "dsputil.h" #include "error_resilience.h" #include "avcodec.h" #include "h264.h" @@ -1119,7 +1118,7 @@ static int h264_slice_header_init(H264Context *h, int reinit) if (!c) return AVERROR(ENOMEM); c->avctx = h->avctx; - c->dsp = h->dsp; + c->mecc = h->mecc; c->vdsp = h->vdsp; c->h264dsp = h->h264dsp; c->h264qpel = h->h264qpel; diff --git a/libavcodec/dsputil.c b/libavcodec/me_cmp.c index ba71a99852..9fcc93739a 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/me_cmp.c @@ -1,8 +1,4 @@ /* - * DSP utils - * Copyright (c) 2000, 2001 Fabrice Bellard - * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> - * * This file is part of Libav. * * Libav is free software; you can redistribute it and/or @@ -20,16 +16,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * @file - * DSP utils - */ - #include "libavutil/attributes.h" #include "avcodec.h" #include "copy_block.h" -#include "dsputil.h" #include "simple_idct.h" +#include "me_cmp.h" #include "mpegvideo.h" #include "config.h" @@ -369,7 +360,7 @@ static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b, return 0; } -void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type) +void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type) { int i; @@ -551,7 +542,7 @@ static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1, s->pdsp.diff_pixels(temp, src1, src2, stride); s->fdsp.fdct(temp); - return s->dsp.sum_abs_dctelem(temp); + return s->mecc.sum_abs_dctelem(temp); } #if CONFIG_GPL @@ -722,7 +713,7 @@ static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2, s->idsp.idct_add(lsrc2, 8, temp); - distortion = s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8); + distortion = s->mecc.sse[1](NULL, lsrc2, lsrc1, 8, 8); return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7); } @@ -891,8 +882,7 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) WRAPPER8_16_SQ(rd8x8_c, rd16_c) WRAPPER8_16_SQ(bit8x8_c, bit16_c) -/* init static data */ -av_cold void ff_dsputil_static_init(void) +av_cold void ff_me_cmp_init_static(void) { int i; @@ -900,7 +890,7 @@ av_cold void ff_dsputil_static_init(void) ff_square_tab[i] = (i - 256) * (i - 256); } -av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) +av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx) { c->sum_abs_dctelem = sum_abs_dctelem_c; @@ -944,9 +934,9 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) c->nsse[1] = nsse8_c; if (ARCH_ARM) - ff_dsputil_init_arm(c, avctx); + ff_me_cmp_init_arm(c, avctx); if (ARCH_PPC) - ff_dsputil_init_ppc(c, avctx); + ff_me_cmp_init_ppc(c, avctx); if (ARCH_X86) - ff_dsputil_init_x86(c, avctx); + ff_me_cmp_init_x86(c, avctx); } diff --git a/libavcodec/dsputil.h b/libavcodec/me_cmp.h index 350ce1c44a..05ae30b0c1 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/me_cmp.h @@ -1,8 +1,4 @@ /* - * DSP utils - * Copyright (c) 2000, 2001, 2002 Fabrice Bellard - * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> - * * This file is part of Libav. * * Libav is free software; you can redistribute it and/or @@ -20,15 +16,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * @file - * DSP utils. - * Note, many functions in here may use MMX which trashes the FPU state, it is - * absolutely necessary to call emms_c() between DSP & float/double code. - */ +#ifndef AVCODEC_ME_CMP_H +#define AVCODEC_ME_CMP_H -#ifndef AVCODEC_DSPUTIL_H -#define AVCODEC_DSPUTIL_H +#include <stdint.h> #include "avcodec.h" @@ -44,10 +35,7 @@ typedef int (*me_cmp_func)(struct MpegEncContext *c, uint8_t *blk1 /* align width (8 or 16) */, uint8_t *blk2 /* align 1 */, int line_size, int h); -/** - * DSPContext. - */ -typedef struct DSPContext { +typedef struct MECmpContext { int (*sum_abs_dctelem)(int16_t *block /* align 16 */); me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */ @@ -71,15 +59,15 @@ typedef struct DSPContext { me_cmp_func frame_skip_cmp[6]; // only width 8 used me_cmp_func pix_abs[2][4]; -} DSPContext; +} MECmpContext; -void ff_dsputil_static_init(void); -void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx); +void ff_me_cmp_init_static(void); -void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type); +void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx); +void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx); +void ff_me_cmp_init_ppc(MECmpContext *c, AVCodecContext *avctx); +void ff_me_cmp_init_x86(MECmpContext *c, AVCodecContext *avctx); -void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx); -void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx); -void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx); +void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type); -#endif /* AVCODEC_DSPUTIL_H */ +#endif /* AVCODEC_ME_CMP_H */ diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index a8a93b73e8..dee28f05ab 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -317,10 +317,10 @@ int ff_init_me(MpegEncContext *s){ av_log(s->avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the selected diamond size\n"); } - ff_set_cmp(&s->dsp, s->dsp.me_pre_cmp, c->avctx->me_pre_cmp); - ff_set_cmp(&s->dsp, s->dsp.me_cmp, c->avctx->me_cmp); - ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, c->avctx->me_sub_cmp); - ff_set_cmp(&s->dsp, s->dsp.mb_cmp, c->avctx->mb_cmp); + ff_set_cmp(&s->mecc, s->mecc.me_pre_cmp, c->avctx->me_pre_cmp); + ff_set_cmp(&s->mecc, s->mecc.me_cmp, c->avctx->me_cmp); + ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, c->avctx->me_sub_cmp); + ff_set_cmp(&s->mecc, s->mecc.mb_cmp, c->avctx->mb_cmp); c->flags = get_flags(c, 0, c->avctx->me_cmp &FF_CMP_CHROMA); c->sub_flags= get_flags(c, 0, c->avctx->me_sub_cmp&FF_CMP_CHROMA); @@ -361,12 +361,10 @@ int ff_init_me(MpegEncContext *s){ /* 8x8 fullpel search would need a 4x4 chroma compare, which we do * not have yet, and even if we had, the motion estimation code * does not expect it. */ - if((c->avctx->me_cmp&FF_CMP_CHROMA)/* && !s->dsp.me_cmp[2]*/){ - s->dsp.me_cmp[2]= zero_cmp; - } - if((c->avctx->me_sub_cmp&FF_CMP_CHROMA) && !s->dsp.me_sub_cmp[2]){ - s->dsp.me_sub_cmp[2]= zero_cmp; - } + if ((c->avctx->me_cmp & FF_CMP_CHROMA) /* && !s->mecc.me_cmp[2] */) + s->mecc.me_cmp[2] = zero_cmp; + if ((c->avctx->me_sub_cmp & FF_CMP_CHROMA) && !s->mecc.me_sub_cmp[2]) + s->mecc.me_sub_cmp[2] = zero_cmp; c->hpel_put[2][0]= c->hpel_put[2][1]= c->hpel_put[2][2]= c->hpel_put[2][3]= zero_hpel; @@ -379,7 +377,7 @@ int ff_init_me(MpegEncContext *s){ #define CHECK_SAD_HALF_MV(suffix, x, y) \ {\ - d= s->dsp.pix_abs[size][(x?1:0)+(y?2:0)](NULL, pix, ptr+((x)>>1), stride, h);\ + d = s->mecc.pix_abs[size][(x ? 1 : 0) + (y ? 2 : 0)](NULL, pix, ptr + ((x) >> 1), stride, h); \ d += (mv_penalty[pen_x + x] + mv_penalty[pen_y + y])*penalty_factor;\ COPY3_IF_LT(dminh, d, dx, x, dy, y)\ } @@ -615,7 +613,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) dmin4= c->sub_motion_search(s, &mx4, &my4, dmin4, block, block, size, h); - if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){ + if (s->mecc.me_sub_cmp[0] != s->mecc.mb_cmp[0]) { int dxy; const int offset= ((block&1) + (block>>1)*stride)*8; uint8_t *dest_y = c->scratchpad + offset; @@ -657,8 +655,11 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) if(same) return INT_MAX; - if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){ - dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16); + if (s->mecc.me_sub_cmp[0] != s->mecc.mb_cmp[0]) { + dmin_sum += s->mecc.mb_cmp[0](s, + s->new_picture.f->data[0] + + s->mb_x * 16 + s->mb_y * 16 * stride, + c->scratchpad, stride, 16); } if(c->avctx->mb_cmp&FF_CMP_CHROMA){ @@ -680,8 +681,8 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_picture.f->data[2] + offset, s->uvlinesize, 8); } - dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad , s->uvlinesize, 8); - dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8); + dmin_sum += s->mecc.mb_cmp[1](s, s->new_picture.f->data[1] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad, s->uvlinesize, 8); + dmin_sum += s->mecc.mb_cmp[1](s, s->new_picture.f->data[2] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad + 8, s->uvlinesize, 8); } c->pred_x= mx; @@ -777,7 +778,7 @@ static int interlaced_search(MpegEncContext *s, int ref_index, mv_table[xy][0]= mx_i; mv_table[xy][1]= my_i; - if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){ + if (s->mecc.me_sub_cmp[0] != s->mecc.mb_cmp[0]) { int dxy; //FIXME chroma ME @@ -789,7 +790,7 @@ static int interlaced_search(MpegEncContext *s, int ref_index, }else{ s->hdsp.put_pixels_tab [size][dxy](c->scratchpad, ref , stride, h); } - dmin= s->dsp.mb_cmp[size](s, c->src[block][0], c->scratchpad, stride, h); + dmin = s->mecc.mb_cmp[size](s, c->src[block][0], c->scratchpad, stride, h); dmin+= (mv_penalty[mx_i-c->pred_x] + mv_penalty[my_i-c->pred_y] + 1)*c->mb_penalty_factor; }else dmin+= c->mb_penalty_factor; //field_select bits @@ -940,7 +941,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, /* At this point (mx,my) are full-pell and the relative displacement */ ppix = c->ref[0][0] + (my * s->linesize) + mx; - vard = s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16); + vard = s->mecc.sse[0](NULL, pix, ppix, s->linesize, 16); pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; c->mc_mb_var_sum_temp += (vard+128)>>8; @@ -1037,7 +1038,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, *(uint32_t*)(&c->scratchpad[i*s->linesize+12]) = mean; } - intra_score= s->dsp.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 16); + intra_score= s->mecc.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 16); } intra_score += c->mb_penalty_factor*16; @@ -1237,7 +1238,7 @@ static inline int check_bidir_mv(MpegEncContext * s, fbmin = (mv_penalty_f[motion_fx-pred_fx] + mv_penalty_f[motion_fy-pred_fy])*c->mb_penalty_factor +(mv_penalty_b[motion_bx-pred_bx] + mv_penalty_b[motion_by-pred_by])*c->mb_penalty_factor - + s->dsp.mb_cmp[size](s, src_data[0], dest_y, stride, h); //FIXME new_pic + + s->mecc.mb_cmp[size](s, src_data[0], dest_y, stride, h); // FIXME new_pic if(c->avctx->mb_cmp&FF_CMP_CHROMA){ } diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index 575dadd269..01936c6a83 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -63,8 +63,8 @@ static int hpel_motion_search(MpegEncContext * s, //FIXME factorize - cmp_sub= s->dsp.me_sub_cmp[size]; - chroma_cmp_sub= s->dsp.me_sub_cmp[size+1]; + cmp_sub = s->mecc.me_sub_cmp[size]; + chroma_cmp_sub = s->mecc.me_sub_cmp[size + 1]; if(c->skip){ //FIXME move out of hpel? *mx_ptr = 0; @@ -166,7 +166,6 @@ static inline int get_mb_score(MpegEncContext *s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate) { -// const int check_luma= s->dsp.me_sub_cmp != s->dsp.mb_cmp; MotionEstContext * const c= &s->me; const int penalty_factor= c->mb_penalty_factor; const int flags= c->mb_flags; @@ -179,8 +178,8 @@ static inline int get_mb_score(MpegEncContext *s, int mx, int my, //FIXME factorize - cmp_sub= s->dsp.mb_cmp[size]; - chroma_cmp_sub= s->dsp.mb_cmp[size+1]; + cmp_sub = s->mecc.mb_cmp[size]; + chroma_cmp_sub = s->mecc.mb_cmp[size + 1]; // assert(!c->skip); // assert(c->avctx->me_sub_cmp != c->avctx->mb_cmp); @@ -226,12 +225,12 @@ static int qpel_motion_search(MpegEncContext * s, LOAD_COMMON int flags= c->sub_flags; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; //factorize FIXME + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; // FIXME: factorize //FIXME factorize - cmp_sub= s->dsp.me_sub_cmp[size]; - chroma_cmp_sub= s->dsp.me_sub_cmp[size+1]; + cmp_sub = s->mecc.me_sub_cmp[size]; + chroma_cmp_sub = s->mecc.me_sub_cmp[size + 1]; if(c->skip){ //FIXME somehow move up (benchmark) *mx_ptr = 0; @@ -427,8 +426,8 @@ static av_always_inline int small_diamond_search(MpegEncContext * s, int *best, LOAD_COMMON2 unsigned map_generation = c->map_generation; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; { /* ensure that the best point is in the MAP as h/qpel refinement needs it */ const unsigned key = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation; @@ -468,8 +467,8 @@ static int funny_diamond_search(MpegEncContext * s, int *best, int dmin, LOAD_COMMON2 unsigned map_generation = c->map_generation; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; for(dia_size=1; dia_size<=4; dia_size++){ int dir; @@ -511,8 +510,8 @@ static int hex_search(MpegEncContext * s, int *best, int dmin, int x,y,d; const int dec= dia_size & (dia_size-1); - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; for(;dia_size; dia_size= dec ? dia_size-1 : dia_size>>1){ do{ @@ -548,8 +547,8 @@ static int l2s_dia_search(MpegEncContext * s, int *best, int dmin, static const int hex[8][2]={{-2, 0}, {-1,-1}, { 0,-2}, { 1,-1}, { 2, 0}, { 1, 1}, { 0, 2}, {-1, 1}}; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; for(; dia_size; dia_size= dec ? dia_size-1 : dia_size>>1){ do{ @@ -587,8 +586,8 @@ static int umh_search(MpegEncContext * s, int *best, int dmin, {-2, 3}, { 0, 4}, { 2, 3}, {-2,-3}, { 0,-4}, { 2,-3},}; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; x= best[0]; y= best[1]; @@ -630,8 +629,8 @@ static int full_search(MpegEncContext * s, int *best, int dmin, int x,y, d; const int dia_size= c->dia_size&0xFF; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; for(y=FFMAX(-dia_size, ymin); y<=FFMIN(dia_size,ymax); y++){ for(x=FFMAX(-dia_size, xmin); x<=FFMIN(dia_size,xmax); x++){ @@ -694,8 +693,8 @@ static int sab_diamond_search(MpegEncContext * s, int *best, int dmin, LOAD_COMMON2 unsigned map_generation = c->map_generation; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; /*Note j<MAX_SAB_SIZE is needed if MAX_SAB_SIZE < ME_MAP_SIZE as j can become larger due to MVs overflowing their ME_MAP_MV_BITS bits space in map @@ -779,8 +778,8 @@ static int var_diamond_search(MpegEncContext * s, int *best, int dmin, LOAD_COMMON2 unsigned map_generation = c->map_generation; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; for(dia_size=1; dia_size<=c->dia_size; dia_size++){ int dir, start, end; @@ -880,12 +879,12 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int if(c->pre_pass){ penalty_factor= c->pre_penalty_factor; - cmpf= s->dsp.me_pre_cmp[size]; - chroma_cmpf= s->dsp.me_pre_cmp[size+1]; + cmpf = s->mecc.me_pre_cmp[size]; + chroma_cmpf = s->mecc.me_pre_cmp[size + 1]; }else{ penalty_factor= c->penalty_factor; - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; } map_generation= update_map_generation(c); @@ -1009,8 +1008,8 @@ static int epzs_motion_search4(MpegEncContext * s, int flags= c->flags; LOAD_COMMON2 - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; map_generation= update_map_generation(c); @@ -1068,8 +1067,8 @@ static int epzs_motion_search2(MpegEncContext * s, int flags= c->flags; LOAD_COMMON2 - cmpf= s->dsp.me_cmp[size]; - chroma_cmpf= s->dsp.me_cmp[size+1]; + cmpf = s->mecc.me_cmp[size]; + chroma_cmpf = s->mecc.me_cmp[size + 1]; map_generation= update_map_generation(c); diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index f120932443..6b87ec7edb 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -689,7 +689,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], b_pic = pic->f->data[0] + offset; if (!pic->shared) b_pic += INPLACE_OFFSET; - diff = s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16); + diff = s->mecc.sad[0](NULL, p_pic, b_pic, s->linesize, 16); if (diff > s->qscale * 70) { // FIXME check that 70 is optimal s->mb_skipped = 0; break; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index a4a37d4931..e1daa2aee0 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -378,9 +378,9 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, av_cold int ff_dct_common_init(MpegEncContext *s) { ff_blockdsp_init(&s->bdsp, s->avctx); - ff_dsputil_init(&s->dsp, s->avctx); ff_hpeldsp_init(&s->hdsp, s->avctx->flags); ff_idctdsp_init(&s->idsp, s->avctx); + ff_me_cmp_init(&s->mecc, s->avctx); ff_mpegvideodsp_init(&s->mdsp); ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample); @@ -1051,7 +1051,7 @@ static int init_er(MpegEncContext *s) int i; er->avctx = s->avctx; - er->dsp = &s->dsp; + er->mecc = &s->mecc; er->mb_index2xy = s->mb_index2xy; er->mb_num = s->mb_num; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index b498d50168..7dd4228c95 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -30,13 +30,13 @@ #include "avcodec.h" #include "blockdsp.h" -#include "dsputil.h" #include "error_resilience.h" #include "fdctdsp.h" #include "get_bits.h" #include "h263dsp.h" #include "hpeldsp.h" #include "idctdsp.h" +#include "me_cmp.h" #include "mpegvideodsp.h" #include "mpegvideoencdsp.h" #include "pixblockdsp.h" @@ -356,10 +356,10 @@ typedef struct MpegEncContext { int h263_long_vectors; ///< use horrible h263v1 long vector mode BlockDSPContext bdsp; - DSPContext dsp; ///< pointers for accelerated dsp functions FDCTDSPContext fdsp; HpelDSPContext hdsp; IDCTDSPContext idsp; + MECmpContext mecc; MpegVideoDSPContext mdsp; MpegvideoEncDSPContext mpvencdsp; PixblockDSPContext pdsp; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index e2504c7b72..f0bf73e210 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -702,6 +702,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) ff_MPV_encode_init_x86(s); ff_fdctdsp_init(&s->fdsp, avctx); + ff_me_cmp_init(&s->mecc, avctx); ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); ff_pixblockdsp_init(&s->pdsp, avctx); ff_qpeldsp_init(&s->qdsp); @@ -744,8 +745,8 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) s->quant_precision = 5; - ff_set_cmp(&s->dsp, s->dsp.ildct_cmp, s->avctx->ildct_cmp); - ff_set_cmp(&s->dsp, s->dsp.frame_skip_cmp, s->avctx->frame_skip_cmp); + ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, s->avctx->ildct_cmp); + ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->avctx->frame_skip_cmp); if (CONFIG_H261_ENCODER && s->out_format == FMT_H261) ff_h261_encode_init(s); @@ -895,8 +896,8 @@ static int get_intra_count(MpegEncContext *s, uint8_t *src, for (y = 0; y < h; y += 16) { for (x = 0; x < w; x += 16) { int offset = x + y * stride; - int sad = s->dsp.sad[0](NULL, src + offset, ref + offset, stride, - 16); + int sad = s->mecc.sad[0](NULL, src + offset, ref + offset, + stride, 16); int mean = (s->mpvencdsp.pix_sum(src + offset, stride) + 128) >> 8; int sae = get_sae(src + offset, mean, stride); @@ -1053,7 +1054,7 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref) int off = p->shared ? 0 : 16; uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off; uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride); - int v = s->dsp.frame_skip_cmp[1](s, dptr, rptr, stride, 8); + int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8); switch (s->avctx->frame_skip_exp) { case 0: score = FFMAX(score, v); break; @@ -1923,16 +1924,15 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int progressive_score, interlaced_score; s->interlaced_dct = 0; - progressive_score = s->dsp.ildct_cmp[4](s, ptr_y, - NULL, wrap_y, 8) + - s->dsp.ildct_cmp[4](s, ptr_y + wrap_y * 8, - NULL, wrap_y, 8) - 400; + progressive_score = s->mecc.ildct_cmp[4](s, ptr_y, NULL, wrap_y, 8) + + s->mecc.ildct_cmp[4](s, ptr_y + wrap_y * 8, + NULL, wrap_y, 8) - 400; if (progressive_score > 0) { - interlaced_score = s->dsp.ildct_cmp[4](s, ptr_y, - NULL, wrap_y * 2, 8) + - s->dsp.ildct_cmp[4](s, ptr_y + wrap_y, - NULL, wrap_y * 2, 8); + interlaced_score = s->mecc.ildct_cmp[4](s, ptr_y, + NULL, wrap_y * 2, 8) + + s->mecc.ildct_cmp[4](s, ptr_y + wrap_y, + NULL, wrap_y * 2, 8); if (progressive_score > interlaced_score) { s->interlaced_dct = 1; @@ -1996,23 +1996,20 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int progressive_score, interlaced_score; s->interlaced_dct = 0; - progressive_score = s->dsp.ildct_cmp[0](s, dest_y, - ptr_y, wrap_y, - 8) + - s->dsp.ildct_cmp[0](s, dest_y + wrap_y * 8, - ptr_y + wrap_y * 8, wrap_y, - 8) - 400; + progressive_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) + + s->mecc.ildct_cmp[0](s, dest_y + wrap_y * 8, + ptr_y + wrap_y * 8, + wrap_y, 8) - 400; if (s->avctx->ildct_cmp == FF_CMP_VSSE) progressive_score -= 400; if (progressive_score > 0) { - interlaced_score = s->dsp.ildct_cmp[0](s, dest_y, - ptr_y, - wrap_y * 2, 8) + - s->dsp.ildct_cmp[0](s, dest_y + wrap_y, - ptr_y + wrap_y, - wrap_y * 2, 8); + interlaced_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y, + wrap_y * 2, 8) + + s->mecc.ildct_cmp[0](s, dest_y + wrap_y, + ptr_y + wrap_y, + wrap_y * 2, 8); if (progressive_score > interlaced_score) { s->interlaced_dct = 1; @@ -2049,33 +2046,28 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, if (s->current_picture.mc_mb_var[s->mb_stride * mb_y + mb_x] < 2 * s->qscale * s->qscale) { // FIXME optimize - if (s->dsp.sad[1](NULL, ptr_y , dest_y, - wrap_y, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_y, dest_y, wrap_y, 8) < 20 * s->qscale) skip_dct[0] = 1; - if (s->dsp.sad[1](NULL, ptr_y + 8, - dest_y + 8, wrap_y, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_y + 8, dest_y + 8, wrap_y, 8) < 20 * s->qscale) skip_dct[1] = 1; - if (s->dsp.sad[1](NULL, ptr_y + dct_offset, - dest_y + dct_offset, wrap_y, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_y + dct_offset, dest_y + dct_offset, + wrap_y, 8) < 20 * s->qscale) skip_dct[2] = 1; - if (s->dsp.sad[1](NULL, ptr_y + dct_offset + 8, - dest_y + dct_offset + 8, - wrap_y, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_y + dct_offset + 8, dest_y + dct_offset + 8, + wrap_y, 8) < 20 * s->qscale) skip_dct[3] = 1; - if (s->dsp.sad[1](NULL, ptr_cb, dest_cb, - wrap_c, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_cb, dest_cb, wrap_c, 8) < 20 * s->qscale) skip_dct[4] = 1; - if (s->dsp.sad[1](NULL, ptr_cr, dest_cr, - wrap_c, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_cr, dest_cr, wrap_c, 8) < 20 * s->qscale) skip_dct[5] = 1; if (!s->chroma_y_shift) { /* 422 */ - if (s->dsp.sad[1](NULL, ptr_cb + (dct_offset >> 1), - dest_cb + (dct_offset >> 1), - wrap_c, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_cb + (dct_offset >> 1), + dest_cb + (dct_offset >> 1), + wrap_c, 8) < 20 * s->qscale) skip_dct[6] = 1; - if (s->dsp.sad[1](NULL, ptr_cr + (dct_offset >> 1), - dest_cr + (dct_offset >> 1), - wrap_c, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_cr + (dct_offset >> 1), + dest_cr + (dct_offset >> 1), + wrap_c, 8) < 20 * s->qscale) skip_dct[7] = 1; } } @@ -2340,9 +2332,9 @@ static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, in int x,y; if(w==16 && h==16) - return s->dsp.sse[0](NULL, src1, src2, stride, 16); + return s->mecc.sse[0](NULL, src1, src2, stride, 16); else if(w==8 && h==8) - return s->dsp.sse[1](NULL, src1, src2, stride, 8); + return s->mecc.sse[1](NULL, src1, src2, stride, 8); for(y=0; y<h; y++){ for(x=0; x<w; x++){ @@ -2364,13 +2356,13 @@ static int sse_mb(MpegEncContext *s){ if(w==16 && h==16) if(s->avctx->mb_cmp == FF_CMP_NSSE){ - return s->dsp.nsse[0](s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16) - +s->dsp.nsse[1](s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8) - +s->dsp.nsse[1](s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8); + return s->mecc.nsse[0](s, s->new_picture.f->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) + + s->mecc.nsse[1](s, s->new_picture.f->data[1] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) + + s->mecc.nsse[1](s, s->new_picture.f->data[2] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8); }else{ - return s->dsp.sse[0](NULL, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16) - +s->dsp.sse[1](NULL, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8) - +s->dsp.sse[1](NULL, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8); + return s->mecc.sse[0](NULL, s->new_picture.f->data[0] + s->mb_x * 16 + s->mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) + + s->mecc.sse[1](NULL, s->new_picture.f->data[1] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) + + s->mecc.sse[1](NULL, s->new_picture.f->data[2] + s->mb_x * 8 + s->mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8); } else return sse(s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize) diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c index 8202034643..109bbe5da8 100644 --- a/libavcodec/mpegvideoencdsp.c +++ b/libavcodec/mpegvideoencdsp.c @@ -24,8 +24,8 @@ #include "libavutil/attributes.h" #include "libavutil/imgutils.h" #include "avcodec.h" -#include "dsputil.h" #include "imgconvert.h" +#include "me_cmp.h" #include "mpegvideoencdsp.h" static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile index eb9623b750..a75d9bf9a0 100644 --- a/libavcodec/ppc/Makefile +++ b/libavcodec/ppc/Makefile @@ -2,7 +2,6 @@ OBJS += ppc/fmtconvert_altivec.o \ OBJS-$(CONFIG_AUDIODSP) += ppc/audiodsp.o OBJS-$(CONFIG_BLOCKDSP) += ppc/blockdsp.o -OBJS-$(CONFIG_DSPUTIL) += ppc/dsputil_altivec.o OBJS-$(CONFIG_FFT) += ppc/fft_altivec.o OBJS-$(CONFIG_H264CHROMA) += ppc/h264chroma_init.o OBJS-$(CONFIG_H264DSP) += ppc/h264dsp.o @@ -11,6 +10,7 @@ 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_ME_CMP) += ppc/me_cmp.o OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \ ppc/mpegvideodsp.o diff --git a/libavcodec/ppc/dsputil_altivec.c b/libavcodec/ppc/me_cmp.c index 33f9b5ae13..88c7feaa7e 100644 --- a/libavcodec/ppc/dsputil_altivec.c +++ b/libavcodec/ppc/me_cmp.c @@ -31,8 +31,8 @@ #include "libavutil/ppc/types_altivec.h" #include "libavutil/ppc/util_altivec.h" #include "libavcodec/avcodec.h" -#include "libavcodec/dsputil.h" #include "libavcodec/mpegvideo.h" +#include "libavcodec/me_cmp.h" #if HAVE_ALTIVEC static int sad16_x2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, @@ -744,7 +744,7 @@ static int hadamard8_diff16_altivec(MpegEncContext *s, uint8_t *dst, } #endif /* HAVE_ALTIVEC */ -av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx) +av_cold void ff_me_cmp_init_ppc(MECmpContext *c, AVCodecContext *avctx) { #if HAVE_ALTIVEC if (!PPC_ALTIVEC(av_get_cpu_flags())) diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 5e3cc55efe..506ee9be9e 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -27,8 +27,8 @@ */ #include "avcodec.h" -#include "dsputil.h" #include "hpeldsp.h" +#include "me_cmp.h" #include "mpegvideo.h" #include "h263.h" #include "internal.h" @@ -306,7 +306,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, s->m.current_picture.motion_val[0] = s->motion_val8[plane] + 2; s->m.p_mv_table = s->motion_val16[plane] + s->m.mb_stride + 1; - s->m.dsp = s->dsp; // move + s->m.mecc = s->mecc; // move ff_init_me(&s->m); s->m.me.dia_size = s->avctx->dia_size; @@ -431,8 +431,8 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, best = score[1] <= score[0]; vlc = ff_svq1_block_type_vlc[SVQ1_BLOCK_SKIP]; - score[2] = s->dsp.sse[0](NULL, src + 16 * x, ref, - stride, 16); + score[2] = s->mecc.sse[0](NULL, src + 16 * x, ref, + stride, 16); score[2] += vlc[1] * lambda; if (score[2] < score[best] && mx == 0 && my == 0) { best = 2; @@ -509,8 +509,8 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) SVQ1EncContext *const s = avctx->priv_data; int ret; - ff_dsputil_init(&s->dsp, avctx); ff_hpeldsp_init(&s->hdsp, avctx->flags); + ff_me_cmp_init(&s->mecc, avctx); ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx); avctx->coded_frame = av_frame_alloc(); diff --git a/libavcodec/svq1enc.h b/libavcodec/svq1enc.h index 1fe2815f19..516e875657 100644 --- a/libavcodec/svq1enc.h +++ b/libavcodec/svq1enc.h @@ -25,9 +25,9 @@ #include "libavutil/frame.h" #include "avcodec.h" -#include "dsputil.h" #include "get_bits.h" #include "hpeldsp.h" +#include "me_cmp.h" #include "mpegvideo.h" #include "put_bits.h" @@ -37,7 +37,7 @@ typedef struct SVQ1EncContext { * of MpegEncContext, so this will be removed then. */ MpegEncContext m; AVCodecContext *avctx; - DSPContext dsp; + MECmpContext mecc; HpelDSPContext hdsp; AVFrame *current_picture; AVFrame *last_picture; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 3af56e9f46..2abc37696f 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -39,8 +39,8 @@ #include "libavutil/samplefmt.h" #include "libavutil/dict.h" #include "avcodec.h" -#include "dsputil.h" #include "libavutil/opt.h" +#include "me_cmp.h" #include "mpegvideo.h" #include "thread.h" #include "internal.h" @@ -100,8 +100,8 @@ static av_cold void avcodec_init(void) return; initialized = 1; - if (CONFIG_DSPUTIL) - ff_dsputil_static_init(); + if (CONFIG_ME_CMP) + ff_me_cmp_init_static(); } int av_codec_is_encoder(const AVCodec *codec) diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index c8804bb37c..3e9b41c890 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -6,7 +6,6 @@ OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_init.o OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp.o OBJS-$(CONFIG_BSWAPDSP) += x86/bswapdsp_init.o OBJS-$(CONFIG_DCT) += x86/dct_init.o -OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_init.o OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o OBJS-$(CONFIG_FFT) += x86/fft_init.o OBJS-$(CONFIG_H263DSP) += x86/h263dsp_init.o @@ -19,6 +18,7 @@ OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp_init.o OBJS-$(CONFIG_HUFFYUVENCDSP) += x86/huffyuvencdsp_mmx.o OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_init.o OBJS-$(CONFIG_LPC) += x86/lpc.o +OBJS-$(CONFIG_ME_CMP) += x86/me_cmp_init.o OBJS-$(CONFIG_MPEGAUDIODSP) += x86/mpegaudiodsp.o OBJS-$(CONFIG_MPEGVIDEO) += x86/mpegvideo.o \ x86/mpegvideodsp.o @@ -70,7 +70,6 @@ YASM-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp.o YASM-OBJS-$(CONFIG_BSWAPDSP) += x86/bswapdsp.o YASM-OBJS-$(CONFIG_DCT) += x86/dct32.o YASM-OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc.o -YASM-OBJS-$(CONFIG_DSPUTIL) += x86/dsputilenc.o YASM-OBJS-$(CONFIG_FFT) += x86/fft.o YASM-OBJS-$(CONFIG_H263DSP) += x86/h263_loopfilter.o YASM-OBJS-$(CONFIG_H264CHROMA) += x86/h264_chromamc.o \ @@ -90,6 +89,7 @@ YASM-OBJS-$(CONFIG_H264QPEL) += x86/h264_qpel_8bit.o \ YASM-OBJS-$(CONFIG_HPELDSP) += x86/fpel.o \ x86/hpeldsp.o YASM-OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp.o +YASM-OBJS-$(CONFIG_ME_CMP) += x86/me_cmp.o YASM-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/imdct36.o YASM-OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoencdsp.o YASM-OBJS-$(CONFIG_PIXBLOCKDSP) += x86/pixblockdsp.o diff --git a/libavcodec/x86/dsputilenc.asm b/libavcodec/x86/me_cmp.asm index 8d989c26f8..1a87f37b39 100644 --- a/libavcodec/x86/dsputilenc.asm +++ b/libavcodec/x86/me_cmp.asm @@ -1,5 +1,5 @@ ;***************************************************************************** -;* MMX optimized DSP utils +;* SIMD-optimized motion compensation estimation ;***************************************************************************** ;* Copyright (c) 2000, 2001 Fabrice Bellard ;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> diff --git a/libavcodec/x86/dsputil_init.c b/libavcodec/x86/me_cmp_init.c index 1303757dd2..e93b67b053 100644 --- a/libavcodec/x86/dsputil_init.c +++ b/libavcodec/x86/me_cmp_init.c @@ -1,5 +1,5 @@ /* - * MMX optimized DSP utils + * SIMD-optimized motion estimation * Copyright (c) 2000, 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * @@ -26,7 +26,7 @@ #include "libavutil/cpu.h" #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" -#include "libavcodec/dsputil.h" +#include "libavcodec/me_cmp.h" #include "libavcodec/mpegvideo.h" #if HAVE_INLINE_ASM @@ -411,7 +411,7 @@ static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, int score1, score2; if (c) - score1 = c->dsp.sse[0](c, pix1, pix2, line_size, h); + score1 = c->mecc.sse[0](c, pix1, pix2, line_size, h); else score1 = sse16_mmx(c, pix1, pix2, line_size, h); score2 = hf_noise16_mmx(pix1, line_size, h) - @@ -1225,7 +1225,7 @@ hadamard_func(mmxext) hadamard_func(sse2) hadamard_func(ssse3) -av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx) +av_cold void ff_me_cmp_init_x86(MECmpContext *c, AVCodecContext *avctx) { int cpu_flags = av_get_cpu_flags(); |