10l - MMX/FPU state was not restored, causing nonsense fpu behaviour in caller (mplayer)
[libav.git] / libavcodec / mlib / dsputil_mlib.c
CommitLineData
c34270f5
FB
1/*
2 * Sun mediaLib optimized DSP utils
ff4ec49e 3 * Copyright (c) 2001 Fabrice Bellard.
c34270f5 4 *
ff4ec49e
FB
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.
c34270f5 9 *
ff4ec49e 10 * This library is distributed in the hope that it will be useful,
c34270f5 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ff4ec49e
FB
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
c34270f5 14 *
ff4ec49e
FB
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
c34270f5
FB
18 */
19
20#include "../dsputil.h"
c7e07931 21#include "../mpegvideo.h"
c34270f5
FB
22
23#include <mlib_types.h>
24#include <mlib_status.h>
25#include <mlib_sys.h>
26#include <mlib_video.h>
27
28
29static 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
39static 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
49static 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
59static 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
69static 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
79static 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
89static 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
99static 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
110static 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
676e200c
MN
115/* XXX: those functions should be suppressed ASAP when all IDCTs are
116 converted */
117static void mlib_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
c34270f5
FB
118{
119 mlib_VideoIDCT8x8_S16_S16 (data, data);
676e200c
MN
120 put_pixels_clamped(block, dest, line_size);
121}
122static void mlib_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
123{
124 mlib_VideoIDCT8x8_S16_S16 (data, data);
125 add_pixels_clamped(block, dest, line_size);
c34270f5 126}
c34270f5
FB
127
128void ff_fdct_mlib(DCTELEM *data)
129{
130 mlib_VideoDCT8x8_S16_S16 (data, data);
131}
132
133void dsputil_init_mlib(void)
134{
590d3f81
MN
135 put_pixels_tab[1][0] = put_pixels_mlib;
136 put_pixels_tab[1][1] = put_pixels_x2_mlib;
137 put_pixels_tab[1][2] = put_pixels_y2_mlib;
138 put_pixels_tab[1][3] = put_pixels_xy2_mlib;
139
140 avg_pixels_tab[1][0] = avg_pixels_mlib;
141 avg_pixels_tab[1][1] = avg_pixels_x2_mlib;
142 avg_pixels_tab[1][2] = avg_pixels_y2_mlib;
143 avg_pixels_tab[1][3] = avg_pixels_xy2_mlib;
c34270f5 144
590d3f81 145 put_no_rnd_pixels_tab[1][0] = put_pixels_mlib;
c34270f5
FB
146
147 add_pixels_clamped = add_pixels_clamped_mlib;
148}
c7e07931
MO
149
150void MPV_common_init_mlib(MpegEncContext *s)
151{
676e200c
MN
152 int i;
153 const int idct_algo= s->avctx->idct_algo;
154
c7e07931
MO
155 if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
156 s->fdct = ff_fdct_mlib;
157 }
676e200c
MN
158
159 if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_MLIB){
160 s->idct_put= mlib_idct_put;
161 s->idct_add= mlib_idct_add;
162 for(i=0; i<64; i++)
163 s->idct_permutation[i]= i;
164 }
165
c7e07931 166}