]> git.sesse.net Git - vlc/blob - plugins/yuvmmx/video_yuv16.c
. rajout de l'option -Winline
[vlc] / plugins / yuvmmx / video_yuv16.c
1 /*****************************************************************************
2  * video_yuv16.c: YUV transformation functions for 16bpp
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  * ConvertY4Gray16: color YUV 4:4:4 to RGB 2 Bpp
52  *****************************************************************************/
53 void ConvertY4Gray16( YUV_ARGS_16BPP )
54 {
55     intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 16\n" );
56 }
57
58 /*****************************************************************************
59  * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 Bpp
60  *****************************************************************************/
61 void ConvertYUV420RGB16( YUV_ARGS_16BPP )
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     u16 *       p_yuv;                              /* base conversion table */
69     u16 *       p_pic_start;       /* beginning of the current line for copy */
70     u16 *       p_buffer_start;                   /* conversion buffer start */
71     u16 *       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_rgb16;
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__( MMX_INIT_16
100                      : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
101
102             __asm__( ".align 8"
103                      MMX_YUV_MUL
104                      MMX_YUV_ADD
105                      MMX_UNPACK_16
106                      : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
107
108             p_y += 8;
109             p_u += 4;
110             p_v += 4;
111             p_buffer += 8;
112         }
113
114         SCALE_WIDTH;
115         SCALE_HEIGHT( 420, 2 );
116     }
117     __asm__( "emms" );
118 }
119
120 /*****************************************************************************
121  * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 Bpp
122  *****************************************************************************/
123 void ConvertYUV422RGB16( YUV_ARGS_16BPP )
124 {
125     intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 16\n" );
126 }
127
128 /*****************************************************************************
129  * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 Bpp
130  *****************************************************************************/
131 void ConvertYUV444RGB16( YUV_ARGS_16BPP )
132 {
133     intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 16\n" );
134 }
135