qt: playlist: use item title if available
[vlc.git] / modules / video_chroma / yuy2_i422.c
blob9b9b97bb16cc3b59bb29955c29a368205d644740
1 /*****************************************************************************
2 * yuy2_i422.c : Packed YUV 4:2:2 to Planar YUV conversion module for vlc
3 *****************************************************************************
4 * Copyright (C) 2007 VLC authors and VideoLAN
6 * Authors: Antoine Cellerier <dionoea at videolan dot org>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 /*****************************************************************************
24 * Preamble
25 *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
31 #include <vlc_common.h>
32 #include <vlc_plugin.h>
33 #include <vlc_filter.h>
34 #include <vlc_picture.h>
36 #define SRC_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422"
37 #define DEST_FOURCC "I422"
39 /*****************************************************************************
40 * Local and extern prototypes.
41 *****************************************************************************/
42 static int Activate ( filter_t * );
44 /*****************************************************************************
45 * Module descriptor
46 *****************************************************************************/
47 vlc_module_begin ()
48 set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) )
49 set_callback_video_converter( Activate, 80 )
50 vlc_module_end ()
52 VIDEO_FILTER_WRAPPER( YUY2_I422 )
53 VIDEO_FILTER_WRAPPER( YVYU_I422 )
54 VIDEO_FILTER_WRAPPER( UYVY_I422 )
56 /*****************************************************************************
57 * Activate: allocate a chroma function
58 *****************************************************************************
59 * This function allocates and initializes a chroma function
60 *****************************************************************************/
61 static int Activate( filter_t *p_filter )
63 if( p_filter->fmt_in.video.i_width & 1
64 || p_filter->fmt_in.video.i_height & 1 )
66 return -1;
69 if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width
70 || p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height
71 || p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation)
72 return -1;
74 switch( p_filter->fmt_out.video.i_chroma )
76 case VLC_CODEC_I422:
77 switch( p_filter->fmt_in.video.i_chroma )
79 case VLC_CODEC_YUYV:
80 p_filter->ops = &YUY2_I422_ops;
81 break;
83 case VLC_CODEC_YVYU:
84 p_filter->ops = &YVYU_I422_ops;
85 break;
87 case VLC_CODEC_UYVY:
88 p_filter->ops = &UYVY_I422_ops;
89 break;
91 default:
92 return -1;
94 break;
96 default:
97 return -1;
99 return 0;
102 /* Following functions are local */
104 /*****************************************************************************
105 * YUY2_I422: packed YUY2 4:2:2 to planar YUV 4:2:2
106 *****************************************************************************/
107 static void YUY2_I422( filter_t *p_filter, picture_t *p_source,
108 picture_t *p_dest )
110 uint8_t *p_line = p_source->p->p_pixels;
112 uint8_t *p_y = p_dest->Y_PIXELS;
113 uint8_t *p_u = p_dest->U_PIXELS;
114 uint8_t *p_v = p_dest->V_PIXELS;
116 int i_x, i_y;
118 const int i_dest_margin = p_dest->p[0].i_pitch
119 - p_dest->p[0].i_visible_pitch;
120 const int i_dest_margin_c = p_dest->p[1].i_pitch
121 - p_dest->p[1].i_visible_pitch;
122 const int i_source_margin = p_source->p->i_pitch
123 - p_source->p->i_visible_pitch;
125 for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
127 for( i_x = p_filter->fmt_out.video.i_width / 8 ; i_x-- ; )
129 #define C_YUYV_YUV422( p_line, p_y, p_u, p_v ) \
130 *p_y++ = *p_line++; *p_u++ = *p_line++; \
131 *p_y++ = *p_line++; *p_v++ = *p_line++
132 C_YUYV_YUV422( p_line, p_y, p_u, p_v );
133 C_YUYV_YUV422( p_line, p_y, p_u, p_v );
134 C_YUYV_YUV422( p_line, p_y, p_u, p_v );
135 C_YUYV_YUV422( p_line, p_y, p_u, p_v );
137 for( i_x = ( p_filter->fmt_out.video.i_width % 8 ) / 2; i_x-- ; )
139 C_YUYV_YUV422( p_line, p_y, p_u, p_v );
141 p_line += i_source_margin;
142 p_y += i_dest_margin;
143 p_u += i_dest_margin_c;
144 p_v += i_dest_margin_c;
148 /*****************************************************************************
149 * YVYU_I422: packed YVYU 4:2:2 to planar YUV 4:2:2
150 *****************************************************************************/
151 static void YVYU_I422( filter_t *p_filter, picture_t *p_source,
152 picture_t *p_dest )
154 uint8_t *p_line = p_source->p->p_pixels;
156 uint8_t *p_y = p_dest->Y_PIXELS;
157 uint8_t *p_u = p_dest->U_PIXELS;
158 uint8_t *p_v = p_dest->V_PIXELS;
160 int i_x, i_y;
162 const int i_dest_margin = p_dest->p[0].i_pitch
163 - p_dest->p[0].i_visible_pitch;
164 const int i_dest_margin_c = p_dest->p[1].i_pitch
165 - p_dest->p[1].i_visible_pitch;
166 const int i_source_margin = p_source->p->i_pitch
167 - p_source->p->i_visible_pitch;
169 for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
171 for( i_x = p_filter->fmt_out.video.i_width / 8 ; i_x-- ; )
173 #define C_YVYU_YUV422( p_line, p_y, p_u, p_v ) \
174 *p_y++ = *p_line++; *p_v++ = *p_line++; \
175 *p_y++ = *p_line++; *p_u++ = *p_line++
176 C_YVYU_YUV422( p_line, p_y, p_u, p_v );
177 C_YVYU_YUV422( p_line, p_y, p_u, p_v );
178 C_YVYU_YUV422( p_line, p_y, p_u, p_v );
179 C_YVYU_YUV422( p_line, p_y, p_u, p_v );
181 for( i_x = ( p_filter->fmt_out.video.i_width % 8 ) / 2; i_x-- ; )
183 C_YVYU_YUV422( p_line, p_y, p_u, p_v );
185 p_line += i_source_margin;
186 p_y += i_dest_margin;
187 p_u += i_dest_margin_c;
188 p_v += i_dest_margin_c;
192 /*****************************************************************************
193 * UYVY_I422: packed UYVY 4:2:2 to planar YUV 4:2:2
194 *****************************************************************************/
195 static void UYVY_I422( filter_t *p_filter, picture_t *p_source,
196 picture_t *p_dest )
198 uint8_t *p_line = p_source->p->p_pixels;
200 uint8_t *p_y = p_dest->Y_PIXELS;
201 uint8_t *p_u = p_dest->U_PIXELS;
202 uint8_t *p_v = p_dest->V_PIXELS;
204 int i_x, i_y;
206 const int i_dest_margin = p_dest->p[0].i_pitch
207 - p_dest->p[0].i_visible_pitch;
208 const int i_dest_margin_c = p_dest->p[1].i_pitch
209 - p_dest->p[1].i_visible_pitch;
210 const int i_source_margin = p_source->p->i_pitch
211 - p_source->p->i_visible_pitch;
213 for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
215 for( i_x = p_filter->fmt_out.video.i_width / 8 ; i_x-- ; )
217 #define C_UYVY_YUV422( p_line, p_y, p_u, p_v ) \
218 *p_u++ = *p_line++; *p_y++ = *p_line++; \
219 *p_v++ = *p_line++; *p_y++ = *p_line++
220 C_UYVY_YUV422( p_line, p_y, p_u, p_v );
221 C_UYVY_YUV422( p_line, p_y, p_u, p_v );
222 C_UYVY_YUV422( p_line, p_y, p_u, p_v );
223 C_UYVY_YUV422( p_line, p_y, p_u, p_v );
225 for( i_x = ( p_filter->fmt_out.video.i_width % 8 ) / 2; i_x-- ; )
227 C_UYVY_YUV422( p_line, p_y, p_u, p_v );
229 p_line += i_source_margin;
230 p_y += i_dest_margin;
231 p_u += i_dest_margin_c;
232 p_v += i_dest_margin_c;