]> git.sesse.net Git - vlc/blob - plugins/yuvmmx/video_yuv32.c
6f708921051e56bd800c2606e1852d0b084d03dc
[vlc] / plugins / yuvmmx / video_yuv32.c
1 /*****************************************************************************
2  * video_yuv32.c: YUV transformation functions for 32 bpp
3  * Provides functions to perform the YUV conversion. The functions provided here
4  * are a complete and portable C implementation, and may be replaced in certain
5  * case by optimized functions.
6  *****************************************************************************
7  * Copyright (C) 1999, 2000 VideoLAN
8  *
9  * Authors:
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public
22  * License along with this program; if not, write to the
23  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include "defs.h"
31
32 #include <math.h>                                            /* exp(), pow() */
33 #include <errno.h>                                                 /* ENOMEM */
34 #include <stdlib.h>                                                /* free() */
35 #include <string.h>                                            /* strerror() */
36
37 #include "config.h"
38 #include "common.h"
39 #include "threads.h"
40 #include "mtime.h"
41 #include "plugins.h"
42 #include "video.h"
43 #include "video_output.h"
44 #include "video_yuv.h"
45 #include "video_yuv_macros.h"
46 #include "video_yuv_asm.h"
47
48 #include "intf_msg.h"
49
50 /*****************************************************************************
51  * ConvertY4Gray32: grayscale YUV 4:x:x to RGB 4 Bpp
52  *****************************************************************************/
53 void ConvertY4Gray32( YUV_ARGS_32BPP )
54 {
55     intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 32\n" );
56 }
57
58 /*****************************************************************************
59  * ConvertYUV420RGB32: color YUV 4:2:0 to RGB 4 Bpp
60  *****************************************************************************/
61 void ConvertYUV420RGB32( YUV_ARGS_32BPP )
62 {
63     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
64     int         i_vertical_scaling;                 /* vertical scaling type */
65     int         i_x, i_y;                 /* horizontal and vertical indexes */
66     int         i_scale_count;                       /* scale modulo counter */
67     int         i_chroma_width;                              /* chroma width */
68     u32 *       p_yuv;                              /* base conversion table */
69     u32 *       p_pic_start;       /* beginning of the current line for copy */
70     u32 *       p_buffer_start;                   /* conversion buffer start */
71     u32 *       p_buffer;                       /* conversion buffer pointer */
72     int *       p_offset_start;                        /* offset array start */
73     int *       p_offset;                            /* offset array pointer */
74
75     /*
76      * Initialize some values  - i_pic_line_width will store the line skip
77      */
78     i_pic_line_width -= i_pic_width;
79     i_chroma_width =    i_width / 2;
80     p_yuv =             p_vout->yuv.yuv.p_rgb32;
81     p_buffer_start =    p_vout->yuv.p_buffer;
82     p_offset_start =    p_vout->yuv.p_offset;
83     SetOffset( i_width, i_height, i_pic_width, i_pic_height,
84                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
85
86     /*
87      * Perform conversion
88      */
89     i_scale_count = i_pic_height;
90     for( i_y = 0; i_y < i_height; i_y++ )
91     {
92         /* Mark beginnning of line for possible later line copy, and initialize
93          * buffer */
94         p_pic_start =   p_pic;
95         p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
96
97         for ( i_x = i_width / 8; i_x--; )
98         {
99             __asm__( ".align 8" MMX_INIT_32
100                      : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
101
102             __asm__( ".align 8" MMX_YUV_ADD MMX_YUV_MUL MMX_UNPACK_32
103                      : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
104
105             p_y += 8;
106             p_u += 4;
107             p_v += 4;
108             p_buffer += 8;
109         }
110
111         SCALE_WIDTH;
112         SCALE_HEIGHT( 420, 2 );
113     }
114     __asm__( "emms" );
115 }
116
117 /*****************************************************************************
118  * ConvertYUV422RGB32: color YUV 4:2:2 to RGB 4 Bpp
119  *****************************************************************************/
120 void ConvertYUV422RGB32( YUV_ARGS_32BPP )
121 {
122     intf_ErrMsg( "yuv error: unhandled function, chroma = 422, bpp = 32\n" );
123 }
124
125 /*****************************************************************************
126  * ConvertYUV444RGB32: color YUV 4:4:4 to RGB 4 Bpp
127  *****************************************************************************/
128 void ConvertYUV444RGB32( YUV_ARGS_32BPP )
129 {
130     intf_ErrMsg( "yuv error: unhandled function, chroma = 444, bpp = 32\n" );
131 }
132