Unified · Split
| @@ -21,6 +21,7 @@ OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_arm.o \ · 20 unmodified lines | ||
| 21 | 21 | arm/simple_idct_arm.o |
| 22 | 22 | OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o |
| 23 | 23 | OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_arm.o |
| 24 | +OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_init_arm.o | |
| 24 | 25 | OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o |
| 25 | 26 | OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_arm.o |
| 26 | 27 | OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_init_arm.o |
| @@ -60,6 +61,7 @@ ARMV6-OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_armv6.o \ · 33 unmodified lines | ||
| 60 | 61 | arm/idctdsp_armv6.o \ |
| 61 | 62 | arm/simple_idct_armv6.o |
| 62 | 63 | ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o |
| 64 | +ARMV6-OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_armv6.o | |
| 63 | 65 | |
| 64 | 66 | ARMV6-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv6.o |
| 65 | 67 | ARMV6-OBJS-$(CONFIG_VP7_DECODER) += arm/vp8_armv6.o \ |
| @@ -297,58 +297,3 @@ function ff_sse16_armv6, export=1 · 296 unmodified lines | ||
| 297 | 297 | |
| 298 | 298 | pop {r4-r9, pc} |
| 299 | 299 | endfunc |
| 300 | − | |
| 301 | −function ff_pix_norm1_armv6, export=1 | |
| 302 | − push {r4-r6, lr} | |
| 303 | − mov r12, #16 | |
| 304 | − mov lr, #0 | |
| 305 | −1: | |
| 306 | − ldm r0, {r2-r5} | |
| 307 | − uxtb16 r6, r2 | |
| 308 | − uxtb16 r2, r2, ror #8 | |
| 309 | − smlad lr, r6, r6, lr | |
| 310 | − uxtb16 r6, r3 | |
| 311 | − smlad lr, r2, r2, lr | |
| 312 | − uxtb16 r3, r3, ror #8 | |
| 313 | − smlad lr, r6, r6, lr | |
| 314 | − uxtb16 r6, r4 | |
| 315 | − smlad lr, r3, r3, lr | |
| 316 | − uxtb16 r4, r4, ror #8 | |
| 317 | − smlad lr, r6, r6, lr | |
| 318 | − uxtb16 r6, r5 | |
| 319 | − smlad lr, r4, r4, lr | |
| 320 | − uxtb16 r5, r5, ror #8 | |
| 321 | − smlad lr, r6, r6, lr | |
| 322 | − subs r12, r12, #1 | |
| 323 | − add r0, r0, r1 | |
| 324 | − smlad lr, r5, r5, lr | |
| 325 | − bgt 1b | |
| 326 | − | |
| 327 | − mov r0, lr | |
| 328 | − pop {r4-r6, pc} | |
| 329 | −endfunc | |
| 330 | − | |
| 331 | −function ff_pix_sum_armv6, export=1 | |
| 332 | − push {r4-r7, lr} | |
| 333 | − mov r12, #16 | |
| 334 | − mov r2, #0 | |
| 335 | − mov r3, #0 | |
| 336 | − mov lr, #0 | |
| 337 | − ldr r4, [r0] | |
| 338 | −1: | |
| 339 | − subs r12, r12, #1 | |
| 340 | − ldr r5, [r0, #4] | |
| 341 | − usada8 r2, r4, lr, r2 | |
| 342 | − ldr r6, [r0, #8] | |
| 343 | − usada8 r3, r5, lr, r3 | |
| 344 | − ldr r7, [r0, #12] | |
| 345 | − usada8 r2, r6, lr, r2 | |
| 346 | − beq 2f | |
| 347 | − ldr_pre r4, r0, r1 | |
| 348 | − usada8 r3, r7, lr, r3 | |
| 349 | − bgt 1b | |
| 350 | −2: | |
| 351 | − usada8 r3, r7, lr, r3 | |
| 352 | − add r0, r2, r3 | |
| 353 | − pop {r4-r7, pc} | |
| 354 | −endfunc | |
| @@ -43,9 +43,6 @@ int ff_pix_abs8_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, · 42 unmodified lines | ||
| 43 | 43 | int ff_sse16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, |
| 44 | 44 | int line_size, int h); |
| 45 | 45 | |
| 46 | −int ff_pix_norm1_armv6(uint8_t *pix, int line_size); | |
| 47 | −int ff_pix_sum_armv6(uint8_t *pix, int line_size); | |
| 48 | − | |
| 49 | 46 | av_cold void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx, |
| 50 | 47 | unsigned high_bit_depth) |
| 51 | 48 | { |
| @@ -63,7 +60,4 @@ av_cold void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx, · 11 unmodified lines | ||
| 63 | 60 | c->sad[1] = ff_pix_abs8_armv6; |
| 64 | 61 | |
| 65 | 62 | c->sse[0] = ff_sse16_armv6; |
| 66 | − | |
| 67 | − c->pix_norm1 = ff_pix_norm1_armv6; | |
| 68 | − c->pix_sum = ff_pix_sum_armv6; | |
| 69 | 63 | } |
| @@ -0,0 +1,76 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2009 Mans Rullgard <mans@mansr.com> | |
| 3 | + * | |
| 4 | + * This file is part of Libav. | |
| 5 | + * | |
| 6 | + * Libav is free software; you can redistribute it and/or | |
| 7 | + * modify it under the terms of the GNU Lesser General Public | |
| 8 | + * License as published by the Free Software Foundation; either | |
| 9 | + * version 2.1 of the License, or (at your option) any later version. | |
| 10 | + * | |
| 11 | + * Libav is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | + * Lesser General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public | |
| 17 | + * License along with Libav; if not, write to the Free Software | |
| 18 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#include "libavutil/arm/asm.S" | |
| 22 | + | |
| 23 | +function ff_pix_norm1_armv6, export=1 | |
| 24 | + push {r4-r6, lr} | |
| 25 | + mov r12, #16 | |
| 26 | + mov lr, #0 | |
| 27 | +1: | |
| 28 | + ldm r0, {r2-r5} | |
| 29 | + uxtb16 r6, r2 | |
| 30 | + uxtb16 r2, r2, ror #8 | |
| 31 | + smlad lr, r6, r6, lr | |
| 32 | + uxtb16 r6, r3 | |
| 33 | + smlad lr, r2, r2, lr | |
| 34 | + uxtb16 r3, r3, ror #8 | |
| 35 | + smlad lr, r6, r6, lr | |
| 36 | + uxtb16 r6, r4 | |
| 37 | + smlad lr, r3, r3, lr | |
| 38 | + uxtb16 r4, r4, ror #8 | |
| 39 | + smlad lr, r6, r6, lr | |
| 40 | + uxtb16 r6, r5 | |
| 41 | + smlad lr, r4, r4, lr | |
| 42 | + uxtb16 r5, r5, ror #8 | |
| 43 | + smlad lr, r6, r6, lr | |
| 44 | + subs r12, r12, #1 | |
| 45 | + add r0, r0, r1 | |
| 46 | + smlad lr, r5, r5, lr | |
| 47 | + bgt 1b | |
| 48 | + | |
| 49 | + mov r0, lr | |
| 50 | + pop {r4-r6, pc} | |
| 51 | +endfunc | |
| 52 | + | |
| 53 | +function ff_pix_sum_armv6, export=1 | |
| 54 | + push {r4-r7, lr} | |
| 55 | + mov r12, #16 | |
| 56 | + mov r2, #0 | |
| 57 | + mov r3, #0 | |
| 58 | + mov lr, #0 | |
| 59 | + ldr r4, [r0] | |
| 60 | +1: | |
| 61 | + subs r12, r12, #1 | |
| 62 | + ldr r5, [r0, #4] | |
| 63 | + usada8 r2, r4, lr, r2 | |
| 64 | + ldr r6, [r0, #8] | |
| 65 | + usada8 r3, r5, lr, r3 | |
| 66 | + ldr r7, [r0, #12] | |
| 67 | + usada8 r2, r6, lr, r2 | |
| 68 | + beq 2f | |
| 69 | + ldr_pre r4, r0, r1 | |
| 70 | + usada8 r3, r7, lr, r3 | |
| 71 | + bgt 1b | |
| 72 | +2: | |
| 73 | + usada8 r3, r7, lr, r3 | |
| 74 | + add r0, r2, r3 | |
| 75 | + pop {r4-r7, pc} | |
| 76 | +endfunc | |
| @@ -0,0 +1,38 @@ | ||
| 1 | +/* | |
| 2 | + * This file is part of Libav. | |
| 3 | + * | |
| 4 | + * Libav is free software; you can redistribute it and/or | |
| 5 | + * modify it under the terms of the GNU Lesser General Public | |
| 6 | + * License as published by the Free Software Foundation; either | |
| 7 | + * version 2.1 of the License, or (at your option) any later version. | |
| 8 | + * | |
| 9 | + * Libav is distributed in the hope that it will be useful, | |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | + * Lesser General Public License for more details. | |
| 13 | + * | |
| 14 | + * You should have received a copy of the GNU Lesser General Public | |
| 15 | + * License along with Libav; if not, write to the Free Software | |
| 16 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 17 | + */ | |
| 18 | + | |
| 19 | +#include <stdint.h> | |
| 20 | + | |
| 21 | +#include "libavutil/cpu.h" | |
| 22 | +#include "libavutil/arm/cpu.h" | |
| 23 | +#include "libavcodec/avcodec.h" | |
| 24 | +#include "libavcodec/mpegvideoencdsp.h" | |
| 25 | + | |
| 26 | +int ff_pix_norm1_armv6(uint8_t *pix, int line_size); | |
| 27 | +int ff_pix_sum_armv6(uint8_t *pix, int line_size); | |
| 28 | + | |
| 29 | +av_cold void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c, | |
| 30 | + AVCodecContext *avctx) | |
| 31 | +{ | |
| 32 | + int cpu_flags = av_get_cpu_flags(); | |
| 33 | + | |
| 34 | + if (have_armv6(cpu_flags)) { | |
| 35 | + c->pix_norm1 = ff_pix_norm1_armv6; | |
| 36 | + c->pix_sum = ff_pix_sum_armv6; | |
| 37 | + } | |
| 38 | +} | |
| @@ -309,6 +309,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) · 308 unmodified lines | ||
| 309 | 309 | ff_blockdsp_init(&ctx->bdsp, avctx); |
| 310 | 310 | ff_dsputil_init(&ctx->m.dsp, avctx); |
| 311 | 311 | ff_idctdsp_init(&ctx->m.idsp, avctx); |
| 312 | + ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx); | |
| 312 | 313 | ff_dct_common_init(&ctx->m); |
| 313 | 314 | if (!ctx->m.dct_quantize) |
| 314 | 315 | ctx->m.dct_quantize = ff_dct_quantize_c; |
| @@ -719,8 +720,8 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, · 404 unmodified lines | ||
| 719 | 720 | int varc; |
| 720 | 721 | |
| 721 | 722 | if (!partial_last_row && mb_x * 16 <= avctx->width - 16) { |
| 722 | − sum = ctx->m.dsp.pix_sum(pix, ctx->m.linesize); | |
| 723 | − varc = ctx->m.dsp.pix_norm1(pix, ctx->m.linesize); | |
| 723 | + sum = ctx->m.mpvencdsp.pix_sum(pix, ctx->m.linesize); | |
| 724 | + varc = ctx->m.mpvencdsp.pix_norm1(pix, ctx->m.linesize); | |
| 724 | 725 | } else { |
| 725 | 726 | int bw = FFMIN(avctx->width - 16 * mb_x, 16); |
| 726 | 727 | int bh = FFMIN((avctx->height >> ctx->interlaced) - 16 * mb_y, 16); |
| @@ -26,15 +26,12 @@ · 25 unmodified lines | ||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | #include "libavutil/attributes.h" |
| 29 | −#include "libavutil/imgutils.h" | |
| 30 | 29 | #include "avcodec.h" |
| 31 | 30 | #include "copy_block.h" |
| 32 | 31 | #include "dct.h" |
| 33 | 32 | #include "dsputil.h" |
| 34 | 33 | #include "simple_idct.h" |
| 35 | 34 | #include "faandct.h" |
| 36 | −#include "imgconvert.h" | |
| 37 | −#include "mathops.h" | |
| 38 | 35 | #include "mpegvideo.h" |
| 39 | 36 | #include "config.h" |
| 40 | 37 | |
| @@ -47,74 +44,6 @@ uint32_t ff_square_tab[512] = { 0, }; · 6 unmodified lines | ||
| 47 | 44 | #define BIT_DEPTH 8 |
| 48 | 45 | #include "dsputilenc_template.c" |
| 49 | 46 | |
| 50 | −static int pix_sum_c(uint8_t *pix, int line_size) | |
| 51 | −{ | |
| 52 | − int s = 0, i, j; | |
| 53 | − | |
| 54 | − for (i = 0; i < 16; i++) { | |
| 55 | − for (j = 0; j < 16; j += 8) { | |
| 56 | − s += pix[0]; | |
| 57 | − s += pix[1]; | |
| 58 | − s += pix[2]; | |
| 59 | − s += pix[3]; | |
| 60 | − s += pix[4]; | |
| 61 | − s += pix[5]; | |
| 62 | − s += pix[6]; | |
| 63 | − s += pix[7]; | |
| 64 | − pix += 8; | |
| 65 | − } | |
| 66 | − pix += line_size - 16; | |
| 67 | − } | |
| 68 | − return s; | |
| 69 | −} | |
| 70 | − | |
| 71 | −static int pix_norm1_c(uint8_t *pix, int line_size) | |
| 72 | −{ | |
| 73 | − int s = 0, i, j; | |
| 74 | − uint32_t *sq = ff_square_tab + 256; | |
| 75 | − | |
| 76 | − for (i = 0; i < 16; i++) { | |
| 77 | − for (j = 0; j < 16; j += 8) { | |
| 78 | −#if 0 | |
| 79 | − s += sq[pix[0]]; | |
| 80 | − s += sq[pix[1]]; | |
| 81 | − s += sq[pix[2]]; | |
| 82 | − s += sq[pix[3]]; | |
| 83 | − s += sq[pix[4]]; | |
| 84 | − s += sq[pix[5]]; | |
| 85 | − s += sq[pix[6]]; | |
| 86 | − s += sq[pix[7]]; | |
| 87 | −#else | |
| 88 | −#if HAVE_FAST_64BIT | |
| 89 | − register uint64_t x = *(uint64_t *) pix; | |
| 90 | − s += sq[x & 0xff]; | |
| 91 | − s += sq[(x >> 8) & 0xff]; | |
| 92 | − s += sq[(x >> 16) & 0xff]; | |
| 93 | − s += sq[(x >> 24) & 0xff]; | |
| 94 | − s += sq[(x >> 32) & 0xff]; | |
| 95 | − s += sq[(x >> 40) & 0xff]; | |
| 96 | − s += sq[(x >> 48) & 0xff]; | |
| 97 | − s += sq[(x >> 56) & 0xff]; | |
| 98 | −#else | |
| 99 | − register uint32_t x = *(uint32_t *) pix; | |
| 100 | − s += sq[x & 0xff]; | |
| 101 | − s += sq[(x >> 8) & 0xff]; | |
| 102 | − s += sq[(x >> 16) & 0xff]; | |
| 103 | − s += sq[(x >> 24) & 0xff]; | |
| 104 | − x = *(uint32_t *) (pix + 4); | |
| 105 | − s += sq[x & 0xff]; | |
| 106 | − s += sq[(x >> 8) & 0xff]; | |
| 107 | − s += sq[(x >> 16) & 0xff]; | |
| 108 | − s += sq[(x >> 24) & 0xff]; | |
| 109 | −#endif | |
| 110 | −#endif | |
| 111 | − pix += 8; | |
| 112 | − } | |
| 113 | − pix += line_size - 16; | |
| 114 | − } | |
| 115 | − return s; | |
| 116 | −} | |
| 117 | − | |
| 118 | 47 | static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, |
| 119 | 48 | int line_size, int h) |
| 120 | 49 | { |
| @@ -1055,9 +984,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) · 934 unmodified lines | ||
| 1055 | 984 | |
| 1056 | 985 | c->sum_abs_dctelem = sum_abs_dctelem_c; |
| 1057 | 986 | |
| 1058 | − c->pix_sum = pix_sum_c; | |
| 1059 | − c->pix_norm1 = pix_norm1_c; | |
| 1060 | − | |
| 1061 | 987 | /* TODO [0] 16 [1] 8 */ |
| 1062 | 988 | c->pix_abs[0][0] = pix_abs16_c; |
| 1063 | 989 | c->pix_abs[0][1] = pix_abs16_x2_c; |
| @@ -1097,11 +1023,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) · 33 unmodified lines | ||
| 1097 | 1023 | c->nsse[0] = nsse16_c; |
| 1098 | 1024 | c->nsse[1] = nsse8_c; |
| 1099 | 1025 | |
| 1100 | − c->shrink[0] = av_image_copy_plane; | |
| 1101 | − c->shrink[1] = ff_shrink22; | |
| 1102 | − c->shrink[2] = ff_shrink44; | |
| 1103 | − c->shrink[3] = ff_shrink88; | |
| 1104 | − | |
| 1105 | 1026 | c->draw_edges = draw_edges_8_c; |
| 1106 | 1027 | |
| 1107 | 1028 | switch (avctx->bits_per_raw_sample) { |
| @@ -58,9 +58,6 @@ typedef struct DSPContext { · 57 unmodified lines | ||
| 58 | 58 | int stride); |
| 59 | 59 | int (*sum_abs_dctelem)(int16_t *block /* align 16 */); |
| 60 | 60 | |
| 61 | − int (*pix_sum)(uint8_t *pix, int line_size); | |
| 62 | − int (*pix_norm1)(uint8_t *pix, int line_size); | |
| 63 | − | |
| 64 | 61 | me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */ |
| 65 | 62 | me_cmp_func sse[6]; |
| 66 | 63 | me_cmp_func hadamard8_diff[6]; |
| @@ -92,9 +89,6 @@ typedef struct DSPContext { · 25 unmodified lines | ||
| 92 | 89 | #define EDGE_WIDTH 16 |
| 93 | 90 | #define EDGE_TOP 1 |
| 94 | 91 | #define EDGE_BOTTOM 2 |
| 95 | − | |
| 96 | − void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, | |
| 97 | − int src_wrap, int width, int height); | |
| 98 | 92 | } DSPContext; |
| 99 | 93 | |
| 100 | 94 | void ff_dsputil_static_init(void); |
| @@ -881,8 +881,9 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, · 880 unmodified lines | ||
| 881 | 881 | |
| 882 | 882 | /* intra / predictive decision */ |
| 883 | 883 | pix = c->src[0][0]; |
| 884 | − sum = s->dsp.pix_sum(pix, s->linesize); | |
| 885 | − varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)sum*sum)>>8) + 500; | |
| 884 | + sum = s->mpvencdsp.pix_sum(pix, s->linesize); | |
| 885 | + varc = s->mpvencdsp.pix_norm1(pix, s->linesize) - | |
| 886 | + (((unsigned) sum * sum) >> 8) + 500; | |
| 886 | 887 | |
| 887 | 888 | pic->mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8; |
| 888 | 889 | pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8; |
| @@ -895,7 +895,7 @@ static int get_intra_count(MpegEncContext *s, uint8_t *src, · 894 unmodified lines | ||
| 895 | 895 | int offset = x + y * stride; |
| 896 | 896 | int sad = s->dsp.sad[0](NULL, src + offset, ref + offset, stride, |
| 897 | 897 | 16); |
| 898 | − int mean = (s->dsp.pix_sum(src + offset, stride) + 128) >> 8; | |
| 898 | + int mean = (s->mpvencdsp.pix_sum(src + offset, stride) + 128) >> 8; | |
| 899 | 899 | int sae = get_sae(src + offset, mean, stride); |
| 900 | 900 | |
| 901 | 901 | acc += sae + 500 < sad; |
| @@ -1138,15 +1138,21 @@ static int estimate_best_b_count(MpegEncContext *s) · 236 unmodified lines | ||
| 1138 | 1138 | pre_input.f->data[2] += INPLACE_OFFSET; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | − s->dsp.shrink[scale](s->tmp_frames[i]->data[0], s->tmp_frames[i]->linesize[0], | |
| 1142 | − pre_input.f->data[0], pre_input.f->linesize[0], | |
| 1143 | − c->width, c->height); | |
| 1144 | − s->dsp.shrink[scale](s->tmp_frames[i]->data[1], s->tmp_frames[i]->linesize[1], | |
| 1145 | − pre_input.f->data[1], pre_input.f->linesize[1], | |
| 1146 | − c->width >> 1, c->height >> 1); | |
| 1147 | − s->dsp.shrink[scale](s->tmp_frames[i]->data[2], s->tmp_frames[i]->linesize[2], | |
| 1148 | − pre_input.f->data[2], pre_input.f->linesize[2], | |
| 1149 | − c->width >> 1, c->height >> 1); | |
| 1141 | + s->mpvencdsp.shrink[scale](s->tmp_frames[i]->data[0], | |
| 1142 | + s->tmp_frames[i]->linesize[0], | |
| 1143 | + pre_input.f->data[0], | |
| 1144 | + pre_input.f->linesize[0], | |
| 1145 | + c->width, c->height); | |
| 1146 | + s->mpvencdsp.shrink[scale](s->tmp_frames[i]->data[1], | |
| 1147 | + s->tmp_frames[i]->linesize[1], | |
| 1148 | + pre_input.f->data[1], | |
| 1149 | + pre_input.f->linesize[1], | |
| 1150 | + c->width >> 1, c->height >> 1); | |
| 1151 | + s->mpvencdsp.shrink[scale](s->tmp_frames[i]->data[2], | |
| 1152 | + s->tmp_frames[i]->linesize[2], | |
| 1153 | + pre_input.f->data[2], | |
| 1154 | + pre_input.f->linesize[2], | |
| 1155 | + c->width >> 1, c->height >> 1); | |
| 1150 | 1156 | } |
| 1151 | 1157 | } |
| 1152 | 1158 | |
| @@ -2420,9 +2426,10 @@ static int mb_var_thread(AVCodecContext *c, void *arg){ · 1267 unmodified lines | ||
| 2420 | 2426 | int yy = mb_y * 16; |
| 2421 | 2427 | uint8_t *pix = s->new_picture.f->data[0] + (yy * s->linesize) + xx; |
| 2422 | 2428 | int varc; |
| 2423 | − int sum = s->dsp.pix_sum(pix, s->linesize); | |
| 2429 | + int sum = s->mpvencdsp.pix_sum(pix, s->linesize); | |
| 2424 | 2430 | |
| 2425 | − varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)sum*sum)>>8) + 500 + 128)>>8; | |
| 2431 | + varc = (s->mpvencdsp.pix_norm1(pix, s->linesize) - | |
| 2432 | + (((unsigned) sum * sum) >> 8) + 500 + 128) >> 8; | |
| 2426 | 2433 | |
| 2427 | 2434 | s->current_picture.mb_var [s->mb_stride * mb_y + mb_x] = varc; |
| 2428 | 2435 | s->current_picture.mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8; |
| @@ -21,7 +21,10 @@ · 20 unmodified lines | ||
| 21 | 21 | |
| 22 | 22 | #include "config.h" |
| 23 | 23 | #include "libavutil/attributes.h" |
| 24 | +#include "libavutil/imgutils.h" | |
| 24 | 25 | #include "avcodec.h" |
| 26 | +#include "dsputil.h" | |
| 27 | +#include "imgconvert.h" | |
| 25 | 28 | #include "mpegvideoencdsp.h" |
| 26 | 29 | |
| 27 | 30 | static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], |
| @@ -53,12 +56,92 @@ static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale) · 25 unmodified lines | ||
| 53 | 56 | (BASIS_SHIFT - RECON_SHIFT); |
| 54 | 57 | } |
| 55 | 58 | |
| 59 | +static int pix_sum_c(uint8_t *pix, int line_size) | |
| 60 | +{ | |
| 61 | + int s = 0, i, j; | |
| 62 | + | |
| 63 | + for (i = 0; i < 16; i++) { | |
| 64 | + for (j = 0; j < 16; j += 8) { | |
| 65 | + s += pix[0]; | |
| 66 | + s += pix[1]; | |
| 67 | + s += pix[2]; | |
| 68 | + s += pix[3]; | |
| 69 | + s += pix[4]; | |
| 70 | + s += pix[5]; | |
| 71 | + s += pix[6]; | |
| 72 | + s += pix[7]; | |
| 73 | + pix += 8; | |
| 74 | + } | |
| 75 | + pix += line_size - 16; | |
| 76 | + } | |
| 77 | + return s; | |
| 78 | +} | |
| 79 | + | |
| 80 | +static int pix_norm1_c(uint8_t *pix, int line_size) | |
| 81 | +{ | |
| 82 | + int s = 0, i, j; | |
| 83 | + uint32_t *sq = ff_square_tab + 256; | |
| 84 | + | |
| 85 | + for (i = 0; i < 16; i++) { | |
| 86 | + for (j = 0; j < 16; j += 8) { | |
| 87 | +#if 0 | |
| 88 | + s += sq[pix[0]]; | |
| 89 | + s += sq[pix[1]]; | |
| 90 | + s += sq[pix[2]]; | |
| 91 | + s += sq[pix[3]]; | |
| 92 | + s += sq[pix[4]]; | |
| 93 | + s += sq[pix[5]]; | |
| 94 | + s += sq[pix[6]]; | |
| 95 | + s += sq[pix[7]]; | |
| 96 | +#else | |
| 97 | +#if HAVE_FAST_64BIT | |
| 98 | + register uint64_t x = *(uint64_t *) pix; | |
| 99 | + s += sq[x & 0xff]; | |
| 100 | + s += sq[(x >> 8) & 0xff]; | |
| 101 | + s += sq[(x >> 16) & 0xff]; | |
| 102 | + s += sq[(x >> 24) & 0xff]; | |
| 103 | + s += sq[(x >> 32) & 0xff]; | |
| 104 | + s += sq[(x >> 40) & 0xff]; | |
| 105 | + s += sq[(x >> 48) & 0xff]; | |
| 106 | + s += sq[(x >> 56) & 0xff]; | |
| 107 | +#else | |
| 108 | + register uint32_t x = *(uint32_t *) pix; | |
| 109 | + s += sq[x & 0xff]; | |
| 110 | + s += sq[(x >> 8) & 0xff]; | |
| 111 | + s += sq[(x >> 16) & 0xff]; | |
| 112 | + s += sq[(x >> 24) & 0xff]; | |
| 113 | + x = *(uint32_t *) (pix + 4); | |
| 114 | + s += sq[x & 0xff]; | |
| 115 | + s += sq[(x >> 8) & 0xff]; | |
| 116 | + s += sq[(x >> 16) & 0xff]; | |
| 117 | + s += sq[(x >> 24) & 0xff]; | |
| 118 | +#endif | |
| 119 | +#endif | |
| 120 | + pix += 8; | |
| 121 | + } | |
| 122 | + pix += line_size - 16; | |
| 123 | + } | |
| 124 | + return s; | |
| 125 | +} | |
| 126 | + | |
| 56 | 127 | av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, |
| 57 | 128 | AVCodecContext *avctx) |
| 58 | 129 | { |
| 59 | 130 | c->try_8x8basis = try_8x8basis_c; |
| 60 | 131 | c->add_8x8basis = add_8x8basis_c; |
| 61 | 132 | |
| 133 | + c->shrink[0] = av_image_copy_plane; | |
| 134 | + c->shrink[1] = ff_shrink22; | |
| 135 | + c->shrink[2] = ff_shrink44; | |
| 136 | + c->shrink[3] = ff_shrink88; | |
| 137 | + | |
| 138 | + c->pix_sum = pix_sum_c; | |
| 139 | + c->pix_norm1 = pix_norm1_c; | |
| 140 | + | |
| 141 | + if (ARCH_ARM) | |
| 142 | + ff_mpegvideoencdsp_init_arm(c, avctx); | |
| 143 | + if (ARCH_PPC) | |
| 144 | + ff_mpegvideoencdsp_init_ppc(c, avctx); | |
| 62 | 145 | if (ARCH_X86) |
| 63 | 146 | ff_mpegvideoencdsp_init_x86(c, avctx); |
| 64 | 147 | } |
| @@ -31,10 +31,19 @@ typedef struct MpegvideoEncDSPContext { · 30 unmodified lines | ||
| 31 | 31 | int16_t basis[64], int scale); |
| 32 | 32 | void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale); |
| 33 | 33 | |
| 34 | + int (*pix_sum)(uint8_t *pix, int line_size); | |
| 35 | + int (*pix_norm1)(uint8_t *pix, int line_size); | |
| 36 | + | |
| 37 | + void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, | |
| 38 | + int src_wrap, int width, int height); | |
| 34 | 39 | } MpegvideoEncDSPContext; |
| 35 | 40 | |
| 36 | 41 | void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, |
| 37 | 42 | AVCodecContext *avctx); |
| 43 | +void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c, | |
| 44 | + AVCodecContext *avctx); | |
| 45 | +void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c, | |
| 46 | + AVCodecContext *avctx); | |
| 38 | 47 | void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c, |
| 39 | 48 | AVCodecContext *avctx); |
| 40 | 49 | |
| @@ -13,6 +13,7 @@ OBJS-$(CONFIG_IDCTDSP) += ppc/idctdsp.o · 12 unmodified lines | ||
| 13 | 13 | OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o |
| 14 | 14 | OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \ |
| 15 | 15 | ppc/mpegvideodsp.o |
| 16 | +OBJS-$(CONFIG_MPEGVIDEOENC) += ppc/mpegvideoencdsp.o | |
| 16 | 17 | OBJS-$(CONFIG_VIDEODSP) += ppc/videodsp_ppc.o |
| 17 | 18 | OBJS-$(CONFIG_VP3DSP) += ppc/vp3dsp_altivec.o |
| 18 | 19 | |
| @@ -308,34 +308,6 @@ static int sad8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, · 307 unmodified lines | ||
| 308 | 308 | return s; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | −static int pix_norm1_altivec(uint8_t *pix, int line_size) | |
| 312 | −{ | |
| 313 | − int i, s = 0; | |
| 314 | − const vector unsigned int zero = | |
| 315 | − (const vector unsigned int) vec_splat_u32(0); | |
| 316 | − vector unsigned char perm = vec_lvsl(0, pix); | |
| 317 | − vector unsigned int sv = (vector unsigned int) vec_splat_u32(0); | |
| 318 | − vector signed int sum; | |
| 319 | − | |
| 320 | − for (i = 0; i < 16; i++) { | |
| 321 | − /* Read the potentially unaligned pixels. */ | |
| 322 | − vector unsigned char pixl = vec_ld(0, pix); | |
| 323 | − vector unsigned char pixr = vec_ld(15, pix); | |
| 324 | − vector unsigned char pixv = vec_perm(pixl, pixr, perm); | |
| 325 | − | |
| 326 | − /* Square the values, and add them to our sum. */ | |
| 327 | − sv = vec_msum(pixv, pixv, sv); | |
| 328 | − | |
| 329 | − pix += line_size; | |
| 330 | − } | |
| 331 | − /* Sum up the four partial sums, and put the result into s. */ | |
| 332 | − sum = vec_sums((vector signed int) sv, (vector signed int) zero); | |
| 333 | − sum = vec_splat(sum, 3); | |
| 334 | − vec_ste(sum, 0, &s); | |
| 335 | − | |
| 336 | − return s; | |
| 337 | −} | |
| 338 | − | |
| 339 | 311 | /* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced. |
| 340 | 312 | * It's the sad8_altivec code above w/ squaring added. */ |
| 341 | 313 | static int sse8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, |
| @@ -430,35 +402,6 @@ static int sse16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, · 88 unmodified lines | ||
| 430 | 402 | return s; |
| 431 | 403 | } |
| 432 | 404 | |
| 433 | −static int pix_sum_altivec(uint8_t *pix, int line_size) | |
| 434 | −{ | |
| 435 | − int i, s; | |
| 436 | − const vector unsigned int zero = | |
| 437 | − (const vector unsigned int) vec_splat_u32(0); | |
| 438 | − vector unsigned char perm = vec_lvsl(0, pix); | |
| 439 | − vector unsigned int sad = (vector unsigned int) vec_splat_u32(0); | |
| 440 | − vector signed int sumdiffs; | |
| 441 | − | |
| 442 | − for (i = 0; i < 16; i++) { | |
| 443 | − /* Read the potentially unaligned 16 pixels into t1. */ | |
| 444 | − vector unsigned char pixl = vec_ld(0, pix); | |
| 445 | − vector unsigned char pixr = vec_ld(15, pix); | |
| 446 | − vector unsigned char t1 = vec_perm(pixl, pixr, perm); | |
| 447 | − | |
| 448 | − /* Add each 4 pixel group together and put 4 results into sad. */ | |
| 449 | − sad = vec_sum4s(t1, sad); | |
| 450 | − | |
| 451 | − pix += line_size; | |
| 452 | − } | |
| 453 | − | |
| 454 | − /* Sum up the four partial sums, and put the result into s. */ | |
| 455 | − sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); | |
| 456 | − sumdiffs = vec_splat(sumdiffs, 3); | |
| 457 | − vec_ste(sumdiffs, 0, &s); | |
| 458 | − | |
| 459 | − return s; | |
| 460 | −} | |
| 461 | − | |
| 462 | 405 | static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, |
| 463 | 406 | int line_size) |
| 464 | 407 | { |
| @@ -911,9 +854,6 @@ av_cold void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx, · 446 unmodified lines | ||
| 911 | 854 | c->sse[0] = sse16_altivec; |
| 912 | 855 | c->sse[1] = sse8_altivec; |
| 913 | 856 | |
| 914 | − c->pix_norm1 = pix_norm1_altivec; | |
| 915 | − c->pix_sum = pix_sum_altivec; | |
| 916 | − | |
| 917 | 857 | c->diff_pixels = diff_pixels_altivec; |
| 918 | 858 | |
| 919 | 859 | if (!high_bit_depth) { |
| @@ -0,0 +1,103 @@ | ||
| 1 | +/* | |
| 2 | + * This file is part of Libav. | |
| 3 | + * | |
| 4 | + * Libav is free software; you can redistribute it and/or | |
| 5 | + * modify it under the terms of the GNU Lesser General Public | |
| 6 | + * License as published by the Free Software Foundation; either | |
| 7 | + * version 2.1 of the License, or (at your option) any later version. | |
| 8 | + * | |
| 9 | + * Libav is distributed in the hope that it will be useful, | |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | + * Lesser General Public License for more details. | |
| 13 | + * | |
| 14 | + * You should have received a copy of the GNU Lesser General Public | |
| 15 | + * License along with Libav; if not, write to the Free Software | |
| 16 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 17 | + */ | |
| 18 | + | |
| 19 | +#include "config.h" | |
| 20 | +#include <stdint.h> | |
| 21 | +#if HAVE_ALTIVEC_H | |
| 22 | +#include <altivec.h> | |
| 23 | +#endif | |
| 24 | + | |
| 25 | +#include "libavutil/attributes.h" | |
| 26 | +#include "libavutil/cpu.h" | |
| 27 | +#include "libavutil/ppc/cpu.h" | |
| 28 | +#include "libavutil/ppc/types_altivec.h" | |
| 29 | +#include "libavutil/ppc/util_altivec.h" | |
| 30 | +#include "libavcodec/mpegvideoencdsp.h" | |
| 31 | + | |
| 32 | +#if HAVE_ALTIVEC | |
| 33 | + | |
| 34 | +static int pix_norm1_altivec(uint8_t *pix, int line_size) | |
| 35 | +{ | |
| 36 | + int i, s = 0; | |
| 37 | + const vector unsigned int zero = | |
| 38 | + (const vector unsigned int) vec_splat_u32(0); | |
| 39 | + vector unsigned char perm = vec_lvsl(0, pix); | |
| 40 | + vector unsigned int sv = (vector unsigned int) vec_splat_u32(0); | |
| 41 | + vector signed int sum; | |
| 42 | + | |
| 43 | + for (i = 0; i < 16; i++) { | |
| 44 | + /* Read the potentially unaligned pixels. */ | |
| 45 | + vector unsigned char pixl = vec_ld(0, pix); | |
| 46 | + vector unsigned char pixr = vec_ld(15, pix); | |
| 47 | + vector unsigned char pixv = vec_perm(pixl, pixr, perm); | |
| 48 | + | |
| 49 | + /* Square the values, and add them to our sum. */ | |
| 50 | + sv = vec_msum(pixv, pixv, sv); | |
| 51 | + | |
| 52 | + pix += line_size; | |
| 53 | + } | |
| 54 | + /* Sum up the four partial sums, and put the result into s. */ | |
| 55 | + sum = vec_sums((vector signed int) sv, (vector signed int) zero); | |
| 56 | + sum = vec_splat(sum, 3); | |
| 57 | + vec_ste(sum, 0, &s); | |
| 58 | + | |
| 59 | + return s; | |
| 60 | +} | |
| 61 | + | |
| 62 | +static int pix_sum_altivec(uint8_t *pix, int line_size) | |
| 63 | +{ | |
| 64 | + int i, s; | |
| 65 | + const vector unsigned int zero = | |
| 66 | + (const vector unsigned int) vec_splat_u32(0); | |
| 67 | + vector unsigned char perm = vec_lvsl(0, pix); | |
| 68 | + vector unsigned int sad = (vector unsigned int) vec_splat_u32(0); | |
| 69 | + vector signed int sumdiffs; | |
| 70 | + | |
| 71 | + for (i = 0; i < 16; i++) { | |
| 72 | + /* Read the potentially unaligned 16 pixels into t1. */ | |
| 73 | + vector unsigned char pixl = vec_ld(0, pix); | |
| 74 | + vector unsigned char pixr = vec_ld(15, pix); | |
| 75 | + vector unsigned char t1 = vec_perm(pixl, pixr, perm); | |
| 76 | + | |
| 77 | + /* Add each 4 pixel group together and put 4 results into sad. */ | |
| 78 | + sad = vec_sum4s(t1, sad); | |
| 79 | + | |
| 80 | + pix += line_size; | |
| 81 | + } | |
| 82 | + | |
| 83 | + /* Sum up the four partial sums, and put the result into s. */ | |
| 84 | + sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); | |
| 85 | + sumdiffs = vec_splat(sumdiffs, 3); | |
| 86 | + vec_ste(sumdiffs, 0, &s); | |
| 87 | + | |
| 88 | + return s; | |
| 89 | +} | |
| 90 | + | |
| 91 | +#endif /* HAVE_ALTIVEC */ | |
| 92 | + | |
| 93 | +av_cold void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c, | |
| 94 | + AVCodecContext *avctx) | |
| 95 | +{ | |
| 96 | +#if HAVE_ALTIVEC | |
| 97 | + if (!PPC_ALTIVEC(av_get_cpu_flags())) | |
| 98 | + return; | |
| 99 | + | |
| 100 | + c->pix_norm1 = pix_norm1_altivec; | |
| 101 | + c->pix_sum = pix_sum_altivec; | |
| 102 | +#endif /* HAVE_ALTIVEC */ | |
| 103 | +} | |
| @@ -511,6 +511,7 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) · 510 unmodified lines | ||
| 511 | 511 | |
| 512 | 512 | ff_dsputil_init(&s->dsp, avctx); |
| 513 | 513 | ff_hpeldsp_init(&s->hdsp, avctx->flags); |
| 514 | + ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx); | |
| 514 | 515 | |
| 515 | 516 | avctx->coded_frame = av_frame_alloc(); |
| 516 | 517 | s->current_picture = av_frame_alloc(); |
| @@ -92,6 +92,7 @@ YASM-OBJS-$(CONFIG_HPELDSP) += x86/fpel.o \ · 91 unmodified lines | ||
| 92 | 92 | x86/hpeldsp.o |
| 93 | 93 | YASM-OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp.o |
| 94 | 94 | YASM-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/imdct36.o |
| 95 | +YASM-OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoencdsp.o | |
| 95 | 96 | YASM-OBJS-$(CONFIG_QPELDSP) += x86/qpeldsp.o \ |
| 96 | 97 | x86/fpel.o \ |
| 97 | 98 | x86/qpel.o |
| @@ -418,72 +418,3 @@ cglobal diff_pixels, 4,5 · 417 unmodified lines | ||
| 418 | 418 | add r4, 16 |
| 419 | 419 | jne .loop |
| 420 | 420 | REP_RET |
| 421 | − | |
| 422 | −INIT_MMX mmx | |
| 423 | −; int ff_pix_sum16_mmx(uint8_t *pix, int line_size) | |
| 424 | −cglobal pix_sum16, 2, 3 | |
| 425 | − movsxdifnidn r1, r1d | |
| 426 | − mov r2, r1 | |
| 427 | − neg r2 | |
| 428 | − shl r2, 4 | |
| 429 | − sub r0, r2 | |
| 430 | − pxor m7, m7 | |
| 431 | − pxor m6, m6 | |
| 432 | −.loop: | |
| 433 | − mova m0, [r0+r2+0] | |
| 434 | − mova m1, [r0+r2+0] | |
| 435 | − mova m2, [r0+r2+8] | |
| 436 | − mova m3, [r0+r2+8] | |
| 437 | − punpcklbw m0, m7 | |
| 438 | − punpckhbw m1, m7 | |
| 439 | − punpcklbw m2, m7 | |
| 440 | − punpckhbw m3, m7 | |
| 441 | − paddw m1, m0 | |
| 442 | − paddw m3, m2 | |
| 443 | − paddw m3, m1 | |
| 444 | − paddw m6, m3 | |
| 445 | − add r2, r1 | |
| 446 | − js .loop | |
| 447 | − mova m5, m6 | |
| 448 | − psrlq m6, 32 | |
| 449 | − paddw m6, m5 | |
| 450 | − mova m5, m6 | |
| 451 | − psrlq m6, 16 | |
| 452 | − paddw m6, m5 | |
| 453 | − movd eax, m6 | |
| 454 | − and eax, 0xffff | |
| 455 | − RET | |
| 456 | − | |
| 457 | −INIT_MMX mmx | |
| 458 | −; int ff_pix_norm1_mmx(uint8_t *pix, int line_size) | |
| 459 | −cglobal pix_norm1, 2, 4 | |
| 460 | − movsxdifnidn r1, r1d | |
| 461 | − mov r2, 16 | |
| 462 | − pxor m0, m0 | |
| 463 | − pxor m7, m7 | |
| 464 | −.loop: | |
| 465 | − mova m2, [r0+0] | |
| 466 | − mova m3, [r0+8] | |
| 467 | − mova m1, m2 | |
| 468 | − punpckhbw m1, m0 | |
| 469 | − punpcklbw m2, m0 | |
| 470 | − mova m4, m3 | |
| 471 | − punpckhbw m3, m0 | |
| 472 | − punpcklbw m4, m0 | |
| 473 | − pmaddwd m1, m1 | |
| 474 | − pmaddwd m2, m2 | |
| 475 | − pmaddwd m3, m3 | |
| 476 | − pmaddwd m4, m4 | |
| 477 | − paddd m2, m1 | |
| 478 | − paddd m4, m3 | |
| 479 | − paddd m7, m2 | |
| 480 | − add r0, r1 | |
| 481 | − paddd m7, m4 | |
| 482 | − dec r2 | |
| 483 | − jne .loop | |
| 484 | − mova m1, m7 | |
| 485 | − psrlq m7, 32 | |
| 486 | − paddd m1, m7 | |
| 487 | − movd eax, m1 | |
| 488 | − RET | |
| 489 | − | |
| @@ -35,8 +35,6 @@ void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size); · 34 unmodified lines | ||
| 35 | 35 | void ff_get_pixels_sse2(int16_t *block, const uint8_t *pixels, int line_size); |
| 36 | 36 | void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, |
| 37 | 37 | int stride); |
| 38 | −int ff_pix_sum16_mmx(uint8_t *pix, int line_size); | |
| 39 | −int ff_pix_norm1_mmx(uint8_t *pix, int line_size); | |
| 40 | 38 | |
| 41 | 39 | #if HAVE_INLINE_ASM |
| 42 | 40 | |
| @@ -831,8 +829,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, · 788 unmodified lines | ||
| 831 | 829 | if (!high_bit_depth) |
| 832 | 830 | c->get_pixels = ff_get_pixels_mmx; |
| 833 | 831 | c->diff_pixels = ff_diff_pixels_mmx; |
| 834 | − c->pix_sum = ff_pix_sum16_mmx; | |
| 835 | − c->pix_norm1 = ff_pix_norm1_mmx; | |
| 836 | 832 | } |
| 837 | 833 | |
| 838 | 834 | if (EXTERNAL_SSE2(cpu_flags)) |
| @@ -0,0 +1,95 @@ | ||
| 1 | +;***************************************************************************** | |
| 2 | +;* SIMD-optimized MPEG encoding functions | |
| 3 | +;***************************************************************************** | |
| 4 | +;* Copyright (c) 2000, 2001 Fabrice Bellard | |
| 5 | +;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | |
| 6 | +;* | |
| 7 | +;* This file is part of Libav. | |
| 8 | +;* | |
| 9 | +;* Libav is free software; you can redistribute it and/or | |
| 10 | +;* modify it under the terms of the GNU Lesser General Public | |
| 11 | +;* License as published by the Free Software Foundation; either | |
| 12 | +;* version 2.1 of the License, or (at your option) any later version. | |
| 13 | +;* | |
| 14 | +;* Libav is distributed in the hope that it will be useful, | |
| 15 | +;* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 | +;* Lesser General Public License for more details. | |
| 18 | +;* | |
| 19 | +;* You should have received a copy of the GNU Lesser General Public | |
| 20 | +;* License along with Libav; if not, write to the Free Software | |
| 21 | +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 22 | +;***************************************************************************** | |
| 23 | + | |
| 24 | +%include "libavutil/x86/x86util.asm" | |
| 25 | + | |
| 26 | +SECTION .text | |
| 27 | + | |
| 28 | +INIT_MMX mmx | |
| 29 | +; int ff_pix_sum16_mmx(uint8_t *pix, int line_size) | |
| 30 | +cglobal pix_sum16, 2, 3 | |
| 31 | + movsxdifnidn r1, r1d | |
| 32 | + mov r2, r1 | |
| 33 | + neg r2 | |
| 34 | + shl r2, 4 | |
| 35 | + sub r0, r2 | |
| 36 | + pxor m7, m7 | |
| 37 | + pxor m6, m6 | |
| 38 | +.loop: | |
| 39 | + mova m0, [r0+r2+0] | |
| 40 | + mova m1, [r0+r2+0] | |
| 41 | + mova m2, [r0+r2+8] | |
| 42 | + mova m3, [r0+r2+8] | |
| 43 | + punpcklbw m0, m7 | |
| 44 | + punpckhbw m1, m7 | |
| 45 | + punpcklbw m2, m7 | |
| 46 | + punpckhbw m3, m7 | |
| 47 | + paddw m1, m0 | |
| 48 | + paddw m3, m2 | |
| 49 | + paddw m3, m1 | |
| 50 | + paddw m6, m3 | |
| 51 | + add r2, r1 | |
| 52 | + js .loop | |
| 53 | + mova m5, m6 | |
| 54 | + psrlq m6, 32 | |
| 55 | + paddw m6, m5 | |
| 56 | + mova m5, m6 | |
| 57 | + psrlq m6, 16 | |
| 58 | + paddw m6, m5 | |
| 59 | + movd eax, m6 | |
| 60 | + and eax, 0xffff | |
| 61 | + RET | |
| 62 | + | |
| 63 | +INIT_MMX mmx | |
| 64 | +; int ff_pix_norm1_mmx(uint8_t *pix, int line_size) | |
| 65 | +cglobal pix_norm1, 2, 4 | |
| 66 | + movsxdifnidn r1, r1d | |
| 67 | + mov r2, 16 | |
| 68 | + pxor m0, m0 | |
| 69 | + pxor m7, m7 | |
| 70 | +.loop: | |
| 71 | + mova m2, [r0+0] | |
| 72 | + mova m3, [r0+8] | |
| 73 | + mova m1, m2 | |
| 74 | + punpckhbw m1, m0 | |
| 75 | + punpcklbw m2, m0 | |
| 76 | + mova m4, m3 | |
| 77 | + punpckhbw m3, m0 | |
| 78 | + punpcklbw m4, m0 | |
| 79 | + pmaddwd m1, m1 | |
| 80 | + pmaddwd m2, m2 | |
| 81 | + pmaddwd m3, m3 | |
| 82 | + pmaddwd m4, m4 | |
| 83 | + paddd m2, m1 | |
| 84 | + paddd m4, m3 | |
| 85 | + paddd m7, m2 | |
| 86 | + add r0, r1 | |
| 87 | + paddd m7, m4 | |
| 88 | + dec r2 | |
| 89 | + jne .loop | |
| 90 | + mova m1, m7 | |
| 91 | + psrlq m7, 32 | |
| 92 | + paddd m1, m7 | |
| 93 | + movd eax, m1 | |
| 94 | + RET | |
| 95 | + | |
| @@ -22,6 +22,9 @@ · 21 unmodified lines | ||
| 22 | 22 | #include "libavcodec/avcodec.h" |
| 23 | 23 | #include "libavcodec/mpegvideoencdsp.h" |
| 24 | 24 | |
| 25 | +int ff_pix_sum16_mmx(uint8_t *pix, int line_size); | |
| 26 | +int ff_pix_norm1_mmx(uint8_t *pix, int line_size); | |
| 27 | + | |
| 25 | 28 | #if HAVE_INLINE_ASM |
| 26 | 29 | |
| 27 | 30 | #define PHADDD(a, t) \ |
| @@ -95,9 +98,15 @@ · 67 unmodified lines | ||
| 95 | 98 | av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c, |
| 96 | 99 | AVCodecContext *avctx) |
| 97 | 100 | { |
| 98 | −#if HAVE_INLINE_ASM | |
| 99 | 101 | int cpu_flags = av_get_cpu_flags(); |
| 100 | 102 | |
| 103 | + if (EXTERNAL_MMX(cpu_flags)) { | |
| 104 | + c->pix_sum = ff_pix_sum16_mmx; | |
| 105 | + c->pix_norm1 = ff_pix_norm1_mmx; | |
| 106 | + } | |
| 107 | + | |
| 108 | +#if HAVE_INLINE_ASM | |
| 109 | + | |
| 101 | 110 | if (INLINE_MMX(cpu_flags)) { |
| 102 | 111 | if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { |
| 103 | 112 | c->try_8x8basis = try_8x8basis_mmx; |