r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / quicktime / libavcodec / mlib / dsputil_mlib.c
blobb951cd455e72eaf93ea2990c73027d1496caedbd
1 /*
2 * Sun mediaLib optimized DSP utils
3 * Copyright (c) 2001 Fabrice Bellard.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "../dsputil.h"
21 #include "../mpegvideo.h"
23 #include <mlib_types.h>
24 #include <mlib_status.h>
25 #include <mlib_sys.h>
26 #include <mlib_video.h>
29 /* copy block, width 16 pixel, height 8/16 */
31 static void put_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
32 int stride, int height)
34 assert(height == 16 || height == 8);
35 if (height == 16)
36 mlib_VideoCopyRef_U8_U8_16x16(dest, (uint8_t *)ref, stride);
37 else
38 mlib_VideoCopyRef_U8_U8_16x8 (dest, (uint8_t *)ref, stride);
41 static void put_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
42 int stride, int height)
44 assert(height == 16 || height == 8);
45 if (height == 16)
46 mlib_VideoInterpX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
47 else
48 mlib_VideoInterpX_U8_U8_16x8 (dest, (uint8_t *)ref, stride, stride);
51 static void put_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
52 int stride, int height)
54 assert(height == 16 || height == 8);
55 if (height == 16)
56 mlib_VideoInterpY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
57 else
58 mlib_VideoInterpY_U8_U8_16x8 (dest, (uint8_t *)ref, stride, stride);
61 static void put_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref,
62 int stride, int height)
64 assert(height == 16 || height == 8);
65 if (height == 16)
66 mlib_VideoInterpXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
67 else
68 mlib_VideoInterpXY_U8_U8_16x8 (dest, (uint8_t *)ref, stride, stride);
72 /* copy block, width 8 pixel, height 8/16 */
74 static void put_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
75 int stride, int height)
77 assert(height == 16 || height == 8);
78 if (height == 16)
79 mlib_VideoCopyRef_U8_U8_8x16(dest, (uint8_t *)ref, stride);
80 else
81 mlib_VideoCopyRef_U8_U8_8x8 (dest, (uint8_t *)ref, stride);
84 static void put_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
85 int stride, int height)
87 assert(height == 16 || height == 8);
88 if (height == 16)
89 mlib_VideoInterpX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
90 else
91 mlib_VideoInterpX_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
94 static void put_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
95 int stride, int height)
97 assert(height == 16 || height == 8);
98 if (height == 16)
99 mlib_VideoInterpY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
100 else
101 mlib_VideoInterpY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
104 static void put_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref,
105 int stride, int height)
107 assert(height == 16 || height == 8);
108 if (height == 16)
109 mlib_VideoInterpXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
110 else
111 mlib_VideoInterpXY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
115 /* average/merge dest+source block, width 16 pixel, height 8/16 */
117 static void avg_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
118 int stride, int height)
120 assert(height == 16 || height == 8);
121 if (height == 16)
122 mlib_VideoCopyRefAve_U8_U8_16x16(dest, (uint8_t *)ref, stride);
123 else
124 mlib_VideoCopyRefAve_U8_U8_16x8 (dest, (uint8_t *)ref, stride);
127 static void avg_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
128 int stride, int height)
130 assert(height == 16 || height == 8);
131 if (height == 16)
132 mlib_VideoInterpAveX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
133 else
134 mlib_VideoInterpAveX_U8_U8_16x8 (dest, (uint8_t *)ref, stride, stride);
137 static void avg_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
138 int stride, int height)
140 assert(height == 16 || height == 8);
141 if (height == 16)
142 mlib_VideoInterpAveY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
143 else
144 mlib_VideoInterpAveY_U8_U8_16x8 (dest, (uint8_t *)ref, stride, stride);
147 static void avg_pixels16_xy2_mlib (uint8_t * dest, const uint8_t * ref,
148 int stride, int height)
150 assert(height == 16 || height == 8);
151 if (height == 16)
152 mlib_VideoInterpAveXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
153 else
154 mlib_VideoInterpAveXY_U8_U8_16x8 (dest, (uint8_t *)ref, stride, stride);
158 /* average/merge dest+source block, width 8 pixel, height 8/16 */
160 static void avg_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
161 int stride, int height)
163 assert(height == 16 || height == 8);
164 if (height == 16)
165 mlib_VideoCopyRefAve_U8_U8_8x16(dest, (uint8_t *)ref, stride);
166 else
167 mlib_VideoCopyRefAve_U8_U8_8x8 (dest, (uint8_t *)ref, stride);
170 static void avg_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
171 int stride, int height)
173 assert(height == 16 || height == 8);
174 if (height == 16)
175 mlib_VideoInterpAveX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
176 else
177 mlib_VideoInterpAveX_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
180 static void avg_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
181 int stride, int height)
183 assert(height == 16 || height == 8);
184 if (height == 16)
185 mlib_VideoInterpAveY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
186 else
187 mlib_VideoInterpAveY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
190 static void avg_pixels8_xy2_mlib (uint8_t * dest, const uint8_t * ref,
191 int stride, int height)
193 assert(height == 16 || height == 8);
194 if (height == 16)
195 mlib_VideoInterpAveXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
196 else
197 mlib_VideoInterpAveXY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
201 static void (*put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
204 static void add_pixels_clamped_mlib(const DCTELEM *block, UINT8 *pixels, int line_size)
206 mlib_VideoAddBlock_U8_S16(pixels, (mlib_s16 *)block, line_size);
210 /* XXX: those functions should be suppressed ASAP when all IDCTs are
211 converted */
212 static void ff_idct_put_mlib(UINT8 *dest, int line_size, DCTELEM *data)
214 mlib_VideoIDCT8x8_S16_S16 (data, data);
215 put_pixels_clamped(data, dest, line_size);
218 static void ff_idct_add_mlib(UINT8 *dest, int line_size, DCTELEM *data)
220 mlib_VideoIDCT8x8_S16_S16 (data, data);
221 mlib_VideoAddBlock_U8_S16(dest, (mlib_s16 *)data, line_size);
224 static void ff_fdct_mlib(DCTELEM *data)
226 mlib_VideoDCT8x8_S16_S16 (data, data);
229 void dsputil_init_mlib(DSPContext* c, unsigned mask)
231 c->put_pixels_tab[0][0] = put_pixels16_mlib;
232 c->put_pixels_tab[0][1] = put_pixels16_x2_mlib;
233 c->put_pixels_tab[0][2] = put_pixels16_y2_mlib;
234 c->put_pixels_tab[0][3] = put_pixels16_xy2_mlib;
235 c->put_pixels_tab[1][0] = put_pixels8_mlib;
236 c->put_pixels_tab[1][1] = put_pixels8_x2_mlib;
237 c->put_pixels_tab[1][2] = put_pixels8_y2_mlib;
238 c->put_pixels_tab[1][3] = put_pixels8_xy2_mlib;
240 c->avg_pixels_tab[0][0] = avg_pixels16_mlib;
241 c->avg_pixels_tab[0][1] = avg_pixels16_x2_mlib;
242 c->avg_pixels_tab[0][2] = avg_pixels16_y2_mlib;
243 c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mlib;
244 c->avg_pixels_tab[1][0] = avg_pixels8_mlib;
245 c->avg_pixels_tab[1][1] = avg_pixels8_x2_mlib;
246 c->avg_pixels_tab[1][2] = avg_pixels8_y2_mlib;
247 c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mlib;
249 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mlib;
250 c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mlib;
252 c->add_pixels_clamped = add_pixels_clamped_mlib;
253 put_pixels_clamped = c->put_pixels_clamped;
256 void MPV_common_init_mlib(MpegEncContext *s)
258 int i;
260 if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
261 s->fdct = ff_fdct_mlib;
264 if(s->avctx->idct_algo==FF_IDCT_AUTO || s->avctx->idct_algo==FF_IDCT_MLIB){
265 s->idct_put= ff_idct_put_mlib;
266 s->idct_add= ff_idct_add_mlib;
267 s->idct_permutation_type= FF_NO_IDCT_PERM;