]> git.sesse.net Git - ffmpeg/blob - libavcodec/mlib/dsputil_mlib.c
fixing *pixels_tab stuff (hopefully, as its untested ...)
[ffmpeg] / libavcodec / mlib / dsputil_mlib.c
1 /*
2  * Sun mediaLib optimized DSP utils
3  * Copyright (c) 2001 Fabrice Bellard.
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include "../dsputil.h"
21 #include "../mpegvideo.h"
22
23 #include <mlib_types.h>
24 #include <mlib_status.h>
25 #include <mlib_sys.h>
26 #include <mlib_video.h>
27
28
29 static void put_pixels_mlib (uint8_t * dest, const uint8_t * ref,
30                              int stride, int height)
31 {
32     assert(height == 16 || height == 8);
33     if (height == 16)
34         mlib_VideoCopyRef_U8_U8_8x16(dest, (uint8_t *)ref, stride);
35     else
36         mlib_VideoCopyRef_U8_U8_8x8 (dest, (uint8_t *)ref, stride);
37 }
38
39 static void put_pixels_x2_mlib (uint8_t * dest, const uint8_t * ref,
40                                 int stride, int height)
41 {
42     assert(height == 16 || height == 8);
43     if (height == 16)
44         mlib_VideoInterpX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
45     else
46         mlib_VideoInterpX_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
47 }
48
49 static void put_pixels_y2_mlib (uint8_t * dest, const uint8_t * ref,
50                                 int stride, int height)
51 {
52     assert(height == 16 || height == 8);
53     if (height == 16)
54         mlib_VideoInterpY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
55     else
56         mlib_VideoInterpY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
57 }
58
59 static void put_pixels_xy2_mlib(uint8_t * dest, const uint8_t * ref,
60                                 int stride, int height)
61 {
62     assert(height == 16 || height == 8);
63     if (height == 16) 
64         mlib_VideoInterpXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
65     else
66         mlib_VideoInterpXY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
67 }
68
69 static void avg_pixels_mlib (uint8_t * dest, const uint8_t * ref,
70                              int stride, int height)
71 {
72     assert(height == 16 || height == 8);
73     if (height == 16)
74         mlib_VideoCopyRefAve_U8_U8_8x16(dest, (uint8_t *)ref, stride);
75     else
76         mlib_VideoCopyRefAve_U8_U8_8x8 (dest, (uint8_t *)ref, stride);
77 }
78
79 static void avg_pixels_x2_mlib (uint8_t * dest, const uint8_t * ref,
80                                 int stride, int height)
81 {
82     assert(height == 16 || height == 8);
83     if (height == 16)
84         mlib_VideoInterpAveX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
85     else
86         mlib_VideoInterpAveX_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
87 }
88
89 static void avg_pixels_y2_mlib (uint8_t * dest, const uint8_t * ref,
90                                 int stride, int height)
91 {
92     assert(height == 16 || height == 8);
93     if (height == 16)
94         mlib_VideoInterpAveY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
95     else
96         mlib_VideoInterpAveY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
97 }
98
99 static void avg_pixels_xy2_mlib (uint8_t * dest, const uint8_t * ref,
100                                  int stride, int height)
101 {
102     assert(height == 16 || height == 8);
103     if (height == 16)
104         mlib_VideoInterpAveXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
105     else
106         mlib_VideoInterpAveXY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
107 }
108
109
110 static void add_pixels_clamped_mlib(const DCTELEM *block, UINT8 *pixels, int line_size)
111 {
112     mlib_VideoAddBlock_U8_S16(pixels, (mlib_s16 *)block, line_size);
113 }
114
115
116 void ff_idct_mlib(DCTELEM *data)
117 {
118     mlib_VideoIDCT8x8_S16_S16 (data, data);
119 }
120
121
122 void ff_fdct_mlib(DCTELEM *data)
123 {
124     mlib_VideoDCT8x8_S16_S16 (data, data);
125 }
126
127 void dsputil_init_mlib(void)
128 {
129     ff_idct = ff_idct_mlib;
130
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;
135
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;
140     
141     put_no_rnd_pixels_tab[1][0] = put_pixels_mlib;
142     
143     add_pixels_clamped = add_pixels_clamped_mlib;
144 }
145
146 void MPV_common_init_mlib(MpegEncContext *s)
147 {
148     if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
149         s->fdct = ff_fdct_mlib;
150     }
151 }