diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-07-07 15:04:05 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-07-07 15:08:55 +0200 |
commit | 462c6cdb8ed256d2063815b67ca4d14e62e25802 (patch) | |
tree | 324761563d86a2e3e2e8a47dc28e53a407bf8857 /libavcodec/mpegvideoencdsp.c | |
parent | 8324bd51867fdc8a79cbdb5850d36bfd0c741d3f (diff) | |
parent | 8d686ca59db14900ad5c12b547fb8a7afc8b0b94 (diff) | |
download | ffmpeg-462c6cdb8ed256d2063815b67ca4d14e62e25802.tar.gz |
Merge commit '8d686ca59db14900ad5c12b547fb8a7afc8b0b94'
* commit '8d686ca59db14900ad5c12b547fb8a7afc8b0b94':
dsputil: Split off *_8x8basis to a separate context
Conflicts:
libavcodec/dsputil.c
libavcodec/mpegvideo_enc.c
libavcodec/x86/dsputilenc_mmx.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpegvideoencdsp.c')
-rw-r--r-- | libavcodec/mpegvideoencdsp.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c new file mode 100644 index 0000000000..c5e0b4874c --- /dev/null +++ b/libavcodec/mpegvideoencdsp.c @@ -0,0 +1,65 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <assert.h> +#include <stdint.h> + +#include "config.h" +#include "libavutil/avassert.h" +#include "libavutil/attributes.h" +#include "avcodec.h" +#include "mpegvideoencdsp.h" + +static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], + int16_t basis[64], int scale) +{ + int i; + unsigned int sum = 0; + + for (i = 0; i < 8 * 8; i++) { + int b = rem[i] + ((basis[i] * scale + + (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >> + (BASIS_SHIFT - RECON_SHIFT)); + int w = weight[i]; + b >>= RECON_SHIFT; + av_assert2(-512 < b && b < 512); + + sum += (w * b) * (w * b) >> 4; + } + return sum >> 2; +} + +static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale) +{ + int i; + + for (i = 0; i < 8 * 8; i++) + rem[i] += (basis[i] * scale + + (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >> + (BASIS_SHIFT - RECON_SHIFT); +} + +av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, + AVCodecContext *avctx) +{ + c->try_8x8basis = try_8x8basis_c; + c->add_8x8basis = add_8x8basis_c; + + if (ARCH_X86) + ff_mpegvideoencdsp_init_x86(c, avctx); +} |