diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-07-17 23:27:40 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-07-17 23:27:40 +0200 |
commit | 3a2d1465c88625774530399b06dc4d48b24bb51f (patch) | |
tree | 4be7740e2fca1a95af5ec112526c84ca69b64092 | |
parent | 6be71e9955954422227f9691b4f5367a7169b099 (diff) | |
parent | 2d60444331fca1910510038dd3817bea885c2367 (diff) | |
download | ffmpeg-3a2d1465c88625774530399b06dc4d48b24bb51f.tar.gz |
Merge commit '2d60444331fca1910510038dd3817bea885c2367'
* commit '2d60444331fca1910510038dd3817bea885c2367':
dsputil: Split motion estimation compare bits off into their own context
Conflicts:
configure
libavcodec/Makefile
libavcodec/arm/Makefile
libavcodec/dvenc.c
libavcodec/error_resilience.c
libavcodec/h264.h
libavcodec/h264_slice.c
libavcodec/me_cmp.c
libavcodec/me_cmp.h
libavcodec/motion_est.c
libavcodec/motion_est_template.c
libavcodec/mpeg4videoenc.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo_enc.c
libavcodec/x86/Makefile
libavcodec/x86/me_cmp_init.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
51 files changed, 228 insertions, 283 deletions
@@ -1804,7 +1804,6 @@ CONFIG_EXTRA=" blockdsp bswapdsp cabac - dsputil dvprofile exif fdctdsp @@ -1827,6 +1826,7 @@ CONFIG_EXTRA=" llauddsp llviddsp lpc + me_cmp mpeg_er mpegaudio mpegaudiodsp @@ -2002,17 +2002,17 @@ threads_if_any="$THREADS_LIST" # subsystems dct_select="rdft" -dsputil_select="fdctdsp idctdsp pixblockdsp" -error_resilience_select="dsputil" +error_resilience_select="me_cmp" frame_thread_encoder_deps="encoders threads" intrax8_select="error_resilience" mdct_select="fft" rdft_select="fft" +me_cmp_select="fdctdsp idctdsp pixblockdsp" mpeg_er_select="error_resilience" mpegaudio_select="mpegaudiodsp" mpegaudiodsp_select="dct" -mpegvideo_select="blockdsp dsputil h264chroma hpeldsp idctdsp videodsp" -mpegvideoenc_select="dsputil mpegvideo pixblockdsp qpeldsp" +mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp videodsp" +mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp" # decoders / encoders aac_decoder_select="mdct sinewin" @@ -2020,8 +2020,8 @@ aac_encoder_select="audio_frame_queue mdct sinewin" aac_latm_decoder_select="aac_decoder aac_latm_parser" ac3_decoder_select="ac3_parser ac3dsp bswapdsp mdct" ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct" -ac3_encoder_select="ac3dsp audiodsp dsputil mdct" -ac3_fixed_encoder_select="ac3dsp audiodsp dsputil mdct" +ac3_encoder_select="ac3dsp audiodsp mdct me_cmp" +ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp" aic_decoder_select="golomb idctdsp" alac_encoder_select="lpc" als_decoder_select="bswapdsp" @@ -2048,11 +2048,11 @@ cook_decoder_select="audiodsp mdct sinewin" cscd_decoder_select="lzo" cscd_decoder_suggest="zlib" dca_decoder_select="mdct" -dirac_decoder_select="dsputil dwt golomb videodsp mpegvideoenc" +dirac_decoder_select="dwt golomb videodsp mpegvideoenc" dnxhd_decoder_select="blockdsp idctdsp" dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp" dvvideo_decoder_select="dvprofile idctdsp" -dvvideo_encoder_select="dsputil dvprofile fdctdsp pixblockdsp" +dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp" dxa_decoder_select="zlib" eac3_decoder_select="ac3_decoder" eac3_encoder_select="ac3_encoder" @@ -2147,8 +2147,8 @@ qdm2_decoder_select="mdct rdft mpegaudiodsp" ra_144_encoder_select="audio_frame_queue lpc audiodsp" ra_144_decoder_select="audiodsp" ralf_decoder_select="golomb" -rawvideo_decoder_select="dsputil bswapdsp" -rtjpeg_decoder_select="dsputil" +rawvideo_decoder_select="bswapdsp" +rtjpeg_decoder_select="me_cmp" rv10_decoder_select="error_resilience h263_decoder h263dsp mpeg_er" rv10_encoder_select="h263_encoder" rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er" @@ -2157,14 +2157,14 @@ rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_e rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo videodsp" shorten_decoder_select="golomb" sipr_decoder_select="lsp" -snow_decoder_select="dsputil dwt h264qpel hpeldsp rangecoder" -snow_encoder_select="aandcttables dsputil dwt h264qpel hpeldsp mpegvideoenc rangecoder" +snow_decoder_select="dwt h264qpel hpeldsp rangecoder" +snow_encoder_select="aandcttables dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder" sonic_decoder_select="golomb rangecoder" sonic_encoder_select="golomb rangecoder" sonic_ls_encoder_select="golomb rangecoder" sp5x_decoder_select="mjpeg_decoder" svq1_decoder_select="hpeldsp" -svq1_encoder_select="aandcttables dsputil hpeldsp mpegvideoenc" +svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc" svq3_decoder_select="h264_decoder hpeldsp tpeldsp" svq3_decoder_suggest="zlib" tak_decoder_select="audiodsp" @@ -2517,7 +2517,7 @@ dctdnoiz_filter_deps="avcodec" dctdnoiz_filter_select="dct" delogo_filter_deps="gpl" deshake_filter_deps="avcodec" -deshake_filter_select="dsputil" +deshake_filter_select="me_cmp" drawtext_filter_deps="libfreetype" ebur128_filter_deps="gpl" flite_filter_deps="libflite" @@ -2536,7 +2536,7 @@ mcdeint_filter_deps="avcodec gpl" movie_filter_deps="avcodec avformat" mp_filter_deps="gpl avcodec swscale inline_asm" mpdecimate_filter_deps="gpl avcodec" -mpdecimate_filter_select="dsputil pixblockdsp" +mpdecimate_filter_select="me_cmp pixblockdsp" mptestsrc_filter_deps="gpl" negate_filter_deps="lut_filter" perspective_filter_deps="gpl" @@ -2554,7 +2554,7 @@ smartblur_filter_deps="gpl swscale" showspectrum_filter_deps="avcodec" showspectrum_filter_select="rdft" spp_filter_deps="gpl avcodec" -spp_filter_select="dsputil fft idctdsp fdctdsp pixblockdsp" +spp_filter_select="fft idctdsp fdctdsp me_cmp pixblockdsp" stereo3d_filter_deps="gpl" subtitles_filter_deps="avformat avcodec libass" super2xsai_filter_deps="gpl" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0bbfa27e48..307ad22a1b 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -41,7 +41,6 @@ OBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o OBJS-$(CONFIG_CABAC) += cabac.o 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_ERROR_RESILIENCE) += error_resilience.o OBJS-$(CONFIG_EXIF) += exif.o tiff_common.o @@ -70,6 +69,7 @@ OBJS-$(CONFIG_LLVIDDSP) += lossless_videodsp.o OBJS-$(CONFIG_LPC) += lpc.o OBJS-$(CONFIG_LSP) += lsp.o OBJS-$(CONFIG_MDCT) += mdct_fixed.o mdct_float.o mdct_fixed_32.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 dc974702d6..3ae44ff498 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; @@ -2480,7 +2481,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 0ce44bab1c..9c9a7ce509 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 e42ef645e5..5d31f55411 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 @@ -20,6 +19,7 @@ OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_arm.o \ arm/jrevdct_arm.o \ arm/simple_idct_arm.o OBJS-$(CONFIG_LLAUDDSP) += arm/lossless_audiodsp_init_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 @@ -54,13 +54,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/startcode_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 fa5a82301e..fa5a82301e 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 37abe7fc56..eb48b383f5 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/dirac_dwt.c b/libavcodec/dirac_dwt.c index 51a924be95..96d8baee30 100644 --- a/libavcodec/dirac_dwt.c +++ b/libavcodec/dirac_dwt.c @@ -22,7 +22,6 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/common.h" -#include "dsputil.h" #include "dirac_dwt.h" #include "libavcodec/x86/dirac_dwt.h" diff --git a/libavcodec/diracdsp.c b/libavcodec/diracdsp.c index 429241dd86..3b8c39dfea 100644 --- a/libavcodec/diracdsp.c +++ b/libavcodec/diracdsp.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "dsputil.h" +#include "avcodec.h" #include "diracdsp.h" #include "libavcodec/x86/diracdsp_mmx.h" diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 54ac06a65e..14cfbce194 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/dvd_nav_parser.c b/libavcodec/dvd_nav_parser.c index 4b03e399f3..6e2352dc3c 100644 --- a/libavcodec/dvd_nav_parser.c +++ b/libavcodec/dvd_nav_parser.c @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" -#include "dsputil.h" #include "get_bits.h" #include "parser.h" diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index aeb4a33259..4ea181c6d8 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; @@ -69,14 +69,14 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) dv_vlc_map_tableinit(); - memset(&dsp,0, sizeof(dsp)); - ff_dsputil_init(&dsp, avctx); + memset(&mecc,0, sizeof(mecc)); 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 7bb7860f91..86e33a1dcb 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -739,12 +739,12 @@ static int is_intra_more_likely(ERContext *s) } 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->mecc->sad[0](NULL, last_mb_ptr, mb_ptr, + linesize[0], 16); // FIXME need await_progress() here - 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, + 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 9d227e87a1..171af0836e 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 fbab317d91..ba3a7898cf 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -36,7 +36,6 @@ #include "internal.h" #include "cabac.h" #include "cabac_functions.h" -#include "dsputil.h" #include "error_resilience.h" #include "avcodec.h" #include "h264.h" @@ -45,6 +44,7 @@ #include "h264_mvpred.h" #include "golomb.h" #include "mathops.h" +#include "me_cmp.h" #include "mpegutils.h" #include "rectangle.h" #include "svq3.h" @@ -515,7 +515,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; @@ -653,7 +653,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)); @@ -1266,7 +1266,7 @@ int ff_h264_set_parameter_from_sps(H264Context *h) 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 228558b6f4..00f8b7f241 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" @@ -338,13 +338,13 @@ typedef struct H264Picture { */ typedef struct H264Context { AVCodecContext *avctx; + MECmpContext mecc; VideoDSPContext vdsp; H264DSPContext h264dsp; H264ChromaContext h264chroma; H264QpelContext h264qpel; ParseContext parse_context; GetBitContext gb; - DSPContext dsp; ERContext er; H264Picture *DPB; diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index ac4da9de12..f1fbbdcbee 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" @@ -1203,7 +1202,7 @@ static int h264_slice_header_init(H264Context *h, int reinit) return AVERROR(ENOMEM); c->avctx = h->avctx; if (CONFIG_ERROR_RESILIENCE) { - c->dsp = h->dsp; + c->mecc = h->mecc; } c->vdsp = h->vdsp; c->h264dsp = h->h264dsp; diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index 5a8c005b97..b4bd2c88ed 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -3,8 +3,6 @@ LIBAVCODEC_$MAJOR { #deprecated, remove after next bump audio_resample; audio_resample_close; - dsputil_init; - ff_dsputil_init; ff_find_pix_fmt; ff_framenum_to_drop_timecode; ff_framenum_to_smtpe_timecode; @@ -30,5 +28,6 @@ LIBAVCODEC_$MAJOR { ff_idctdsp_init; ff_fdctdsp_init; ff_pixblockdsp_init; + ff_me_cmp_init; local: *; }; diff --git a/libavcodec/dsputil.c b/libavcodec/me_cmp.c index 315e853173..7923c58c69 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 FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -20,17 +16,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * @file - * DSP utils - */ - #include "libavutil/attributes.h" #include "libavutil/internal.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" @@ -370,7 +361,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; @@ -560,7 +551,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 @@ -731,7 +722,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); } @@ -907,8 +898,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; @@ -937,7 +927,7 @@ int ff_check_alignment(void) return 0; } -av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) +av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx) { ff_check_alignment(); @@ -988,21 +978,11 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) #endif if (ARCH_ALPHA) - ff_dsputil_init_alpha(c, avctx); + ff_me_cmp_init_alpha(c, avctx); 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); -} - -av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) -{ - ff_dsputil_init(c, avctx); -} - -av_cold void avpriv_dsputil_init(DSPContext *c, AVCodecContext *avctx) -{ - ff_dsputil_init(c, avctx); + ff_me_cmp_init_x86(c, avctx); } diff --git a/libavcodec/dsputil.h b/libavcodec/me_cmp.h index 9010729b90..0e3b9221bd 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 FFmpeg. * * FFmpeg 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" @@ -58,10 +49,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 * */ @@ -87,22 +75,20 @@ 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 avpriv_dsputil_init(DSPContext* p, AVCodecContext *avctx); -attribute_deprecated void dsputil_init(DSPContext* c, AVCodecContext *avctx); +void ff_me_cmp_init_static(void); int ff_check_alignment(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_alpha(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_alpha(DSPContext* 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); -void ff_dsputil_init_dwt(DSPContext *c); +void ff_dsputil_init_dwt(MECmpContext *c); -#endif /* AVCODEC_DSPUTIL_H */ +#endif /* AVCODEC_ME_CMP_H */ diff --git a/libavcodec/motion-test.c b/libavcodec/motion-test.c index 73087177a1..7cfe41cf6e 100644 --- a/libavcodec/motion-test.c +++ b/libavcodec/motion-test.c @@ -28,7 +28,7 @@ #include <string.h> #include "config.h" -#include "dsputil.h" +#include "me_cmp.h" #include "libavutil/internal.h" #include "libavutil/lfg.h" #include "libavutil/mem.h" @@ -115,7 +115,7 @@ int main(int argc, char **argv) { AVCodecContext *ctx; int c; - DSPContext cctx, mmxctx; + MECmpContext cctx, mmxctx; int flags[2] = { AV_CPU_FLAG_MMX, AV_CPU_FLAG_MMXEXT }; int flags_size = HAVE_MMXEXT ? 2 : 1; @@ -130,12 +130,12 @@ int main(int argc, char **argv) ctx->flags |= CODEC_FLAG_BITEXACT; av_force_cpu_flags(0); memset(&cctx, 0, sizeof(cctx)); - ff_dsputil_init(&cctx, ctx); + ff_me_cmp_init(&cctx, ctx); for (c = 0; c < flags_size; c++) { int x; av_force_cpu_flags(flags[c]); memset(&mmxctx, 0, sizeof(mmxctx)); - ff_dsputil_init(&mmxctx, ctx); + ff_me_cmp_init(&mmxctx, ctx); for (x = 0; x < 2; x++) { printf("%s for %dx%d pixels\n", c ? "mmx2" : "mmx", diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 6b3cd61e8a..fb0bec377c 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -316,10 +316,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); @@ -360,13 +360,11 @@ 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(s->codec_id != AV_CODEC_ID_SNOW){ - 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 (s->codec_id != AV_CODEC_ID_SNOW) { + 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; } @@ -380,7 +378,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)\ } @@ -633,7 +631,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; @@ -675,8 +673,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){ @@ -698,8 +699,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; @@ -795,7 +796,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 @@ -807,7 +808,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 @@ -962,7 +963,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; @@ -1059,7 +1060,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; @@ -1259,7 +1260,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 53a39c0cbe..ae2cbdea4d 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; @@ -165,7 +165,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; @@ -178,8 +177,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]; d= cmp(s, mx>>(qpel+1), my>>(qpel+1), mx&mask, my&mask, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags); //FIXME check cbp before adding penalty for (0,0) vector @@ -222,12 +221,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; @@ -423,8 +422,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; @@ -464,8 +463,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; @@ -507,8 +506,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{ @@ -544,8 +543,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{ @@ -583,8 +582,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]; @@ -626,8 +625,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++){ @@ -692,8 +691,8 @@ static int sab_diamond_search(MpegEncContext * s, int *best, int dmin, av_assert1(minima_count <= MAX_SAB_SIZE); - 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 @@ -777,8 +776,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; @@ -878,12 +877,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); @@ -1007,8 +1006,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); @@ -1066,8 +1065,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 f938119476..6a3d7e7331 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -698,7 +698,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], } diff = diff * 256 / (xe * ye); } else { - 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; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index a9024a978e..15e9f7415b 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -380,10 +380,10 @@ static void gray8(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h) av_cold int ff_dct_common_init(MpegEncContext *s) { ff_blockdsp_init(&s->bdsp, s->avctx); - ff_dsputil_init(&s->dsp, s->avctx); ff_h264chroma_init(&s->h264chroma, 8); //for lowres 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); @@ -1106,7 +1106,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 94937e5cdc..48654e622b 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -30,7 +30,6 @@ #include "avcodec.h" #include "blockdsp.h" -#include "dsputil.h" #include "error_resilience.h" #include "fdctdsp.h" #include "get_bits.h" @@ -38,6 +37,7 @@ #include "h263dsp.h" #include "hpeldsp.h" #include "idctdsp.h" +#include "me_cmp.h" #include "mpegvideodsp.h" #include "mpegvideoencdsp.h" #include "pixblockdsp.h" @@ -365,11 +365,11 @@ typedef struct MpegEncContext { int h263_long_vectors; ///< use horrible h263v1 long vector mode BlockDSPContext bdsp; - DSPContext dsp; ///< pointers for accelerated dsp functions FDCTDSPContext fdsp; H264ChromaContext h264chroma; 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 a4786b4a3a..cf873b1c4c 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -836,6 +836,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) return -1; 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); @@ -872,8 +873,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); @@ -1027,8 +1028,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); @@ -1205,7 +1206,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 (FFABS(s->avctx->frame_skip_exp)) { case 0: score = FFMAX(score, v); break; @@ -2089,16 +2090,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; @@ -2169,23 +2169,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; @@ -2223,33 +2220,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 + uv_dct_offset, - dest_cb + uv_dct_offset, - wrap_c, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_cb + uv_dct_offset, + dest_cb + uv_dct_offset, + wrap_c, 8) < 20 * s->qscale) skip_dct[6] = 1; - if (s->dsp.sad[1](NULL, ptr_cr + uv_dct_offset, - dest_cr + uv_dct_offset, - wrap_c, 8) < 20 * s->qscale) + if (s->mecc.sad[1](NULL, ptr_cr + uv_dct_offset, + dest_cr + uv_dct_offset, + wrap_c, 8) < 20 * s->qscale) skip_dct[7] = 1; } } @@ -2522,9 +2514,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++){ @@ -2546,13 +2538,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 10ad369a67..860c2d8574 100644 --- a/libavcodec/mpegvideoencdsp.c +++ b/libavcodec/mpegvideoencdsp.c @@ -25,8 +25,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 6305904fa7..50cf411d81 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 ppc/hpeldsp_altivec.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 26d088ed7e..18f2c6e499 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/proresdec.h b/libavcodec/proresdec.h index cb7297937d..14ede5d16b 100644 --- a/libavcodec/proresdec.h +++ b/libavcodec/proresdec.h @@ -22,7 +22,6 @@ #ifndef AVCODEC_PRORESDEC_H #define AVCODEC_PRORESDEC_H -#include "dsputil.h" #include "blockdsp.h" #include "proresdsp.h" @@ -36,7 +35,6 @@ typedef struct { } SliceContext; typedef struct { - DSPContext dsp; BlockDSPContext bdsp; ProresDSPContext prodsp; AVFrame *frame; diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index d597114482..4d04a0ad85 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -50,7 +50,6 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->bits_per_raw_sample = 10; - ff_dsputil_init(&ctx->dsp, avctx); ff_blockdsp_init(&ctx->bdsp, avctx); ff_proresdsp_init(&ctx->prodsp, avctx); diff --git a/libavcodec/proresdsp.h b/libavcodec/proresdsp.h index 07871cfbd8..1ac0649bb5 100644 --- a/libavcodec/proresdsp.h +++ b/libavcodec/proresdsp.h @@ -24,7 +24,6 @@ #define AVCODEC_PRORESDSP_H #include <stdint.h> -#include "dsputil.h" #define PRORES_BITS_PER_SAMPLE 10 ///< output precision of prores decoder diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index b2445cabab..f471f4987e 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -31,7 +31,6 @@ #include "internal.h" #include "put_bits.h" #include "bytestream.h" -#include "dsputil.h" #include "fdctdsp.h" #define DEFAULT_SLICE_MB_WIDTH 8 diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 668fe72bfb..dc80ce6f3b 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -22,7 +22,7 @@ #include "libavutil/log.h" #include "libavutil/opt.h" #include "avcodec.h" -#include "dsputil.h" +#include "me_cmp.h" #include "snow_dwt.h" #include "internal.h" #include "snow.h" @@ -435,7 +435,7 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ s->avctx= avctx; s->max_ref_frames=1; //just make sure it's not an invalid value in case of no initial keyframe - ff_dsputil_init(&s->dsp, avctx); + ff_me_cmp_init(&s->mecc, avctx); ff_hpeldsp_init(&s->hdsp, avctx->flags); ff_videodsp_init(&s->vdsp, 8); ff_dwt_init(&s->dwt); diff --git a/libavcodec/snow.h b/libavcodec/snow.h index 2cda5b323d..38810c11d3 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -22,8 +22,8 @@ #ifndef AVCODEC_SNOW_H #define AVCODEC_SNOW_H -#include "dsputil.h" #include "hpeldsp.h" +#include "me_cmp.h" #include "qpeldsp.h" #include "snow_dwt.h" @@ -110,7 +110,7 @@ typedef struct SnowContext{ AVClass *class; AVCodecContext *avctx; RangeCoder c; - DSPContext dsp; + MECmpContext mecc; HpelDSPContext hdsp; QpelDSPContext qdsp; VideoDSPContext vdsp; diff --git a/libavcodec/snow_dwt.c b/libavcodec/snow_dwt.c index cd94c13309..63ff7a0995 100644 --- a/libavcodec/snow_dwt.c +++ b/libavcodec/snow_dwt.c @@ -22,7 +22,7 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/common.h" -#include "dsputil.h" +#include "me_cmp.h" #include "snow_dwt.h" int ff_slice_buffer_init(slice_buffer *buf, int line_count, @@ -844,7 +844,7 @@ int ff_w97_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line return w_c(v, pix1, pix2, line_size, 32, h, 0); } -void ff_dsputil_init_dwt(DSPContext *c) +void ff_dsputil_init_dwt(MECmpContext *c) { c->w53[0] = w53_16_c; c->w53[1] = w53_8_c; diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 7287a2e64c..327157b0d2 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -22,7 +22,6 @@ #include "libavutil/log.h" #include "libavutil/opt.h" #include "avcodec.h" -#include "dsputil.h" #include "snow_dwt.h" #include "internal.h" #include "snow.h" diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 0911392785..0fae0a61c1 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -22,7 +22,6 @@ #include "libavutil/log.h" #include "libavutil/opt.h" #include "avcodec.h" -#include "dsputil.h" #include "internal.h" #include "snow_dwt.h" #include "snow.h" @@ -121,8 +120,8 @@ static av_cold int encode_init(AVCodecContext *avctx) } avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); - ff_set_cmp(&s->dsp, s->dsp.me_cmp, s->avctx->me_cmp); - ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, s->avctx->me_sub_cmp); + ff_set_cmp(&s->mecc, s->mecc.me_cmp, s->avctx->me_cmp); + ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, s->avctx->me_sub_cmp); s->input_picture = av_frame_alloc(); if (!s->input_picture) @@ -669,12 +668,12 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin distortion = 0; for(i=0; i<4; i++){ int off = sx+16*(i&1) + (sy+16*(i>>1))*ref_stride; - distortion += s->dsp.me_cmp[0](&s->m, src + off, dst + off, ref_stride, 16); + distortion += s->mecc.me_cmp[0](&s->m, src + off, dst + off, ref_stride, 16); } } }else{ av_assert2(block_w==8); - distortion = s->dsp.me_cmp[0](&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, block_w*2); + distortion = s->mecc.me_cmp[0](&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, block_w*2); } if(plane_index==0){ @@ -738,7 +737,7 @@ static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){ } av_assert1(block_w== 8 || block_w==16); - distortion += s->dsp.me_cmp[block_w==8](&s->m, src + x + y*ref_stride, dst + x + y*ref_stride, ref_stride, block_h); + distortion += s->mecc.me_cmp[block_w==8](&s->m, src + x + y*ref_stride, dst + x + y*ref_stride, ref_stride, block_h); } if(plane_index==0){ @@ -1660,12 +1659,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, s->m.qscale= (s->m.lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7); s->lambda2= s->m.lambda2= (s->m.lambda*s->m.lambda + FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT; - s->m.dsp= s->dsp; //move + s->m.mecc= s->mecc; //move s->m.qdsp= s->qdsp; //move s->m.hdsp = s->hdsp; ff_init_me(&s->m); s->hdsp = s->m.hdsp; - s->dsp= s->m.dsp; + s->mecc= s->m.mecc; } if(s->pass1_rc){ diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 9ff690dce2..95dcee4466 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" @@ -314,7 +314,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; @@ -437,8 +437,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; @@ -515,8 +515,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 612b6e2b4a..740d2ff61b 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 9fa8e16042..24f059e699 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -41,8 +41,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 "frame_thread_encoder.h" @@ -195,8 +195,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 a208296e67..f6765f5b1a 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_init.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_FLAC_DECODER) += x86/flacdsp_init.o @@ -24,6 +23,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 @@ -80,7 +80,6 @@ YASM-OBJS-$(CONFIG_DCT) += x86/dct32.o YASM-OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp_mmx.o x86/diracdsp_yasm.o\ x86/dwt_yasm.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_FLAC_DECODER) += x86/flacdsp.o YASM-OBJS-$(CONFIG_H263DSP) += x86/h263_loopfilter.o @@ -107,6 +106,7 @@ YASM-OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp.o YASM-OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp.o YASM-OBJS-$(CONFIG_LLAUDDSP) += x86/lossless_audiodsp.o YASM-OBJS-$(CONFIG_LLVIDDSP) += x86/lossless_videodsp.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 023f512edd..b0741f398b 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 c1148a31a8..21db2214c6 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" int ff_sum_abs_dctelem_mmx(int16_t *block); @@ -60,7 +60,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 = ff_sse16_mmx(c, pix1, pix2, line_size, h); score2 = ff_hf_noise16_mmx(pix1, line_size, h) + ff_hf_noise8_mmx(pix1+8, line_size, h) @@ -754,7 +754,7 @@ PIX_SAD(mmxext) #endif /* HAVE_INLINE_ASM */ -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(); diff --git a/libavfilter/deshake.h b/libavfilter/deshake.h index 615953cfe3..568d022602 100644 --- a/libavfilter/deshake.h +++ b/libavfilter/deshake.h @@ -24,7 +24,7 @@ #include "config.h" #include "avfilter.h" -#include "libavcodec/dsputil.h" +#include "libavcodec/me_cmp.h" #include "transform.h" #if CONFIG_OPENCL #include "libavutil/opencl.h" @@ -81,7 +81,7 @@ typedef struct { int contrast; ///< Contrast threshold int search; ///< Motion search method AVCodecContext *avctx; - DSPContext c; ///< Context providing optimized SAD methods + MECmpContext c; ///< Context providing optimized SAD methods Transform last; ///< Transform from last frame int refcount; ///< Number of reference frames (defines averaging window) FILE *fp; diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c index c7c53b43ed..3579665bcb 100644 --- a/libavfilter/f_select.c +++ b/libavfilter/f_select.c @@ -35,7 +35,7 @@ #include "video.h" #if CONFIG_AVCODEC -#include "libavcodec/dsputil.h" +#include "libavcodec/me_cmp.h" #endif static const char *const var_names[] = { @@ -146,7 +146,7 @@ typedef struct SelectContext { int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise #if CONFIG_AVCODEC AVCodecContext *avctx; ///< codec context required for the DSPContext (scene detect only) - DSPContext c; ///< context providing optimized SAD methods (scene detect only) + MECmpContext c; ///< context providing optimized SAD methods (scene detect only) double prev_mafd; ///< previous MAFD (scene detect only) #endif AVFrame *prev_picref; ///< previous frame (scene detect only) @@ -245,7 +245,7 @@ static int config_input(AVFilterLink *inlink) select->avctx = avcodec_alloc_context3(NULL); if (!select->avctx) return AVERROR(ENOMEM); - avpriv_dsputil_init(&select->c, select->avctx); + ff_me_cmp_init(&select->c, select->avctx); } #endif return 0; diff --git a/libavfilter/libmpcodecs/vf_fspp.c b/libavfilter/libmpcodecs/vf_fspp.c index e1b26bc625..c4a36ef8a8 100644 --- a/libavfilter/libmpcodecs/vf_fspp.c +++ b/libavfilter/libmpcodecs/vf_fspp.c @@ -53,7 +53,6 @@ #include "libavutil/mem.h" #include "libavutil/x86/asm.h" #include "libavcodec/avcodec.h" -#include "libavcodec/dsputil.h" #undef free #undef malloc diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index 50aa451a32..9a56b71b39 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -57,7 +57,7 @@ #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" -#include "libavcodec/dsputil.h" +#include "libavcodec/me_cmp.h" #include "deshake.h" #include "deshake_opencl.h" @@ -414,7 +414,7 @@ static int config_props(AVFilterLink *link) deshake->last.zoom = 0; deshake->avctx = avcodec_alloc_context3(NULL); - avpriv_dsputil_init(&deshake->c, deshake->avctx); + ff_me_cmp_init(&deshake->c, deshake->avctx); return 0; } diff --git a/libavfilter/vf_mpdecimate.c b/libavfilter/vf_mpdecimate.c index c667a9f4cc..b030f06b19 100644 --- a/libavfilter/vf_mpdecimate.c +++ b/libavfilter/vf_mpdecimate.c @@ -27,7 +27,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/timestamp.h" -#include "libavcodec/dsputil.h" +#include "libavcodec/me_cmp.h" #include "libavcodec/pixblockdsp.h" #include "avfilter.h" #include "internal.h" @@ -49,7 +49,7 @@ typedef struct { int hsub, vsub; ///< chroma subsampling values AVFrame *ref; ///< reference picture - DSPContext dspctx; ///< context providing optimized diff routines + MECmpContext mecc; ///< context providing optimized diff routines PixblockDSPContext pdsp; AVCodecContext *avctx; ///< codec context required for the DSPContext } DecimateContext; @@ -76,7 +76,7 @@ static int diff_planes(AVFilterContext *ctx, int w, int h) { DecimateContext *decimate = ctx->priv; - DSPContext *dspctx = &decimate->dspctx; + MECmpContext *mecc = &decimate->mecc; PixblockDSPContext *pdsp = &decimate->pdsp; int x, y; @@ -90,7 +90,7 @@ static int diff_planes(AVFilterContext *ctx, pdsp->diff_pixels(block, cur+x+y*linesize, ref+x+y*linesize, linesize); - d = dspctx->sum_abs_dctelem(block); + d = mecc->sum_abs_dctelem(block); if (d > decimate->hi) return 1; if (d > decimate->lo) { @@ -143,7 +143,7 @@ static av_cold int init(AVFilterContext *ctx) decimate->avctx = avcodec_alloc_context3(NULL); if (!decimate->avctx) return AVERROR(ENOMEM); - avpriv_dsputil_init(&decimate->dspctx, decimate->avctx); + ff_me_cmp_init(&decimate->mecc, decimate->avctx); ff_pixblockdsp_init(&decimate->pdsp, decimate->avctx); return 0; diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c index 4e4a5795f4..bb85778647 100644 --- a/libavfilter/vf_spp.c +++ b/libavfilter/vf_spp.c @@ -31,7 +31,6 @@ * ported by Clément Bœsch for FFmpeg. */ -#include "libavcodec/dsputil.h" #include "libavutil/avassert.h" #include "libavutil/imgutils.h" #include "libavutil/opt.h" |