2 * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
4 * This file is part of FFmpeg.
6 * FFmpeg 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.
11 * FFmpeg 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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "libavutil/attributes.h"
22 #include "libavcodec/idctdsp.h"
23 #include "idctdsp_alpha.h"
26 void put_pixels_clamped_mvi_asm(const int16_t *block, uint8_t *pixels,
28 void add_pixels_clamped_mvi_asm(const int16_t *block, uint8_t *pixels,
31 void (*put_pixels_clamped_axp_p)(const int16_t *block, uint8_t *pixels,
33 void (*add_pixels_clamped_axp_p)(const int16_t *block, uint8_t *pixels,
37 /* These functions were the base for the optimized assembler routines,
38 and remain here for documentation purposes. */
39 static void put_pixels_clamped_mvi(const int16_t *block, uint8_t *pixels,
43 uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
46 uint64_t shorts0, shorts1;
49 shorts0 = maxsw4(shorts0, 0);
50 shorts0 = minsw4(shorts0, clampmask);
51 stl(pkwb(shorts0), pixels);
53 shorts1 = ldq(block + 4);
54 shorts1 = maxsw4(shorts1, 0);
55 shorts1 = minsw4(shorts1, clampmask);
56 stl(pkwb(shorts1), pixels + 4);
63 void add_pixels_clamped_mvi(const int16_t *block, uint8_t *pixels,
67 /* Keep this function a leaf function by generating the constants
68 manually (mainly for the hack value ;-). */
69 uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
70 uint64_t signmask = zap(-1, 0x33);
71 signmask ^= signmask >> 1; /* 0x8000800080008000 */
74 uint64_t shorts0, pix0, signs0;
75 uint64_t shorts1, pix1, signs1;
78 shorts1 = ldq(block + 4);
80 pix0 = unpkbw(ldl(pixels));
81 /* Signed subword add (MMX paddw). */
82 signs0 = shorts0 & signmask;
87 shorts0 = maxsw4(shorts0, 0);
88 shorts0 = minsw4(shorts0, clampmask);
91 pix1 = unpkbw(ldl(pixels + 4));
92 signs1 = shorts1 & signmask;
96 shorts1 = maxsw4(shorts1, 0);
97 shorts1 = minsw4(shorts1, clampmask);
99 stl(pkwb(shorts0), pixels);
100 stl(pkwb(shorts1), pixels + 4);
108 av_cold void ff_idctdsp_init_alpha(IDCTDSPContext *c, AVCodecContext *avctx,
109 unsigned high_bit_depth)
111 /* amask clears all bits that correspond to present features. */
112 if (amask(AMASK_MVI) == 0) {
113 c->put_pixels_clamped = put_pixels_clamped_mvi_asm;
114 c->add_pixels_clamped = add_pixels_clamped_mvi_asm;
117 put_pixels_clamped_axp_p = c->put_pixels_clamped;
118 add_pixels_clamped_axp_p = c->add_pixels_clamped;
120 if (!high_bit_depth && !avctx->lowres &&
121 (avctx->idct_algo == FF_IDCT_AUTO)) {
122 c->idct_put = ff_simple_idct_put_axp;
123 c->idct_add = ff_simple_idct_add_axp;
124 c->idct = ff_simple_idct_axp;