Showing the changes to libavcodec/ppc (3 of 21 files). Show all
Unified · Split
| @@ -13,6 +13,7 @@ OBJS-$(CONFIG_IDCTDSP) += ppc/idctdsp.o · 12 unmodified lines | |||
| 13 | OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o | 13 | OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o |
| 14 | OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \ | 14 | OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \ |
| 15 | ppc/mpegvideodsp.o | 15 | ppc/mpegvideodsp.o |
| 16 | OBJS-$(CONFIG_MPEGVIDEOENC) += ppc/mpegvideoencdsp.o | ||
| 16 | OBJS-$(CONFIG_VIDEODSP) += ppc/videodsp_ppc.o | 17 | OBJS-$(CONFIG_VIDEODSP) += ppc/videodsp_ppc.o |
| 17 | OBJS-$(CONFIG_VP3DSP) += ppc/vp3dsp_altivec.o | 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 | return s; | 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 | /* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced. | 311 | /* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced. |
| 340 | * It's the sad8_altivec code above w/ squaring added. */ | 312 | * It's the sad8_altivec code above w/ squaring added. */ |
| 341 | static int sse8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, | 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 | return s; | 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 | static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, | 405 | static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, |
| 463 | int line_size) | 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 | c->sse[0] = sse16_altivec; | 854 | c->sse[0] = sse16_altivec; |
| 912 | c->sse[1] = sse8_altivec; | 855 | c->sse[1] = sse8_altivec; |
| 913 | 856 | ||
| 914 | c->pix_norm1 = pix_norm1_altivec; | ||
| 915 | c->pix_sum = pix_sum_altivec; | ||
| 916 | |||
| 917 | c->diff_pixels = diff_pixels_altivec; | 857 | c->diff_pixels = diff_pixels_altivec; |
| 918 | 858 | ||
| 919 | if (!high_bit_depth) { | 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 | } | ||