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>
26 #include <mlib_video.h>
29 static void put_pixels_mlib (uint8_t * dest, const uint8_t * ref,
30 int stride, int height)
32 assert(height == 16 || height == 8);
34 mlib_VideoCopyRef_U8_U8_8x16(dest, (uint8_t *)ref, stride);
36 mlib_VideoCopyRef_U8_U8_8x8 (dest, (uint8_t *)ref, stride);
39 static void put_pixels_x2_mlib (uint8_t * dest, const uint8_t * ref,
40 int stride, int height)
42 assert(height == 16 || height == 8);
44 mlib_VideoInterpX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
46 mlib_VideoInterpX_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
49 static void put_pixels_y2_mlib (uint8_t * dest, const uint8_t * ref,
50 int stride, int height)
52 assert(height == 16 || height == 8);
54 mlib_VideoInterpY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
56 mlib_VideoInterpY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
59 static void put_pixels_xy2_mlib(uint8_t * dest, const uint8_t * ref,
60 int stride, int height)
62 assert(height == 16 || height == 8);
64 mlib_VideoInterpXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
66 mlib_VideoInterpXY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
69 static void avg_pixels_mlib (uint8_t * dest, const uint8_t * ref,
70 int stride, int height)
72 assert(height == 16 || height == 8);
74 mlib_VideoCopyRefAve_U8_U8_8x16(dest, (uint8_t *)ref, stride);
76 mlib_VideoCopyRefAve_U8_U8_8x8 (dest, (uint8_t *)ref, stride);
79 static void avg_pixels_x2_mlib (uint8_t * dest, const uint8_t * ref,
80 int stride, int height)
82 assert(height == 16 || height == 8);
84 mlib_VideoInterpAveX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
86 mlib_VideoInterpAveX_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
89 static void avg_pixels_y2_mlib (uint8_t * dest, const uint8_t * ref,
90 int stride, int height)
92 assert(height == 16 || height == 8);
94 mlib_VideoInterpAveY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
96 mlib_VideoInterpAveY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
99 static void avg_pixels_xy2_mlib (uint8_t * dest, const uint8_t * ref,
100 int stride, int height)
102 assert(height == 16 || height == 8);
104 mlib_VideoInterpAveXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
106 mlib_VideoInterpAveXY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
110 static void add_pixels_clamped_mlib(const DCTELEM *block, UINT8 *pixels, int line_size)
112 mlib_VideoAddBlock_U8_S16(pixels, (mlib_s16 *)block, line_size);
116 void ff_idct_mlib(DCTELEM *data)
118 mlib_VideoIDCT8x8_S16_S16 (data, data);
122 void ff_fdct_mlib(DCTELEM *data)
124 mlib_VideoDCT8x8_S16_S16 (data, data);
127 void dsputil_init_mlib(void)
129 ff_idct = ff_idct_mlib;
131 put_pixels_tab[1][0] = put_pixels_mlib;
132 put_pixels_tab[1][1] = put_pixels_x2_mlib;
133 put_pixels_tab[1][2] = put_pixels_y2_mlib;
134 put_pixels_tab[1][3] = put_pixels_xy2_mlib;
136 avg_pixels_tab[1][0] = avg_pixels_mlib;
137 avg_pixels_tab[1][1] = avg_pixels_x2_mlib;
138 avg_pixels_tab[1][2] = avg_pixels_y2_mlib;
139 avg_pixels_tab[1][3] = avg_pixels_xy2_mlib;
141 put_no_rnd_pixels_tab[1][0] = put_pixels_mlib;
143 add_pixels_clamped = add_pixels_clamped_mlib;
146 void MPV_common_init_mlib(MpegEncContext *s)
148 if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
149 s->fdct = ff_fdct_mlib;