qt: playlist: use item title if available
[vlc.git] / modules / video_chroma / rv32.c
blobc4300d45680f3c28c9806e22d4ee286c59d885cb
1 /*****************************************************************************
2 * rv32.c: conversion plugin to RV32 format.
3 *****************************************************************************
4 * Copyright (C) 2005 VLC authors and VideoLAN
6 * Author: Cyril Deguet <asmax@videolan.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 *****************************************************************************/
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
30 #include <vlc_common.h>
31 #include <vlc_plugin.h>
32 #include <vlc_filter.h>
33 #include <vlc_picture.h>
35 /****************************************************************************
36 * Local prototypes
37 ****************************************************************************/
38 static int OpenFilter ( filter_t * );
39 static picture_t *Filter( filter_t *, picture_t * );
41 /*****************************************************************************
42 * Module descriptor
43 *****************************************************************************/
44 vlc_module_begin ()
45 set_description( N_("RV32 conversion filter") )
46 set_callback_video_converter( OpenFilter, 1 )
47 vlc_module_end ()
49 static const struct vlc_filter_operations filter_ops = {
50 .filter_video = Filter,
53 /*****************************************************************************
54 * OpenFilter: probe the filter and return score
55 *****************************************************************************/
56 static int OpenFilter( filter_t *p_filter )
58 /* XXX Only support RV24 -> RV32 conversion */
59 if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGB24 ||
60 (p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGB32 &&
61 p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGBA) )
63 return VLC_EGENERIC;
66 if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width
67 || p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height
68 || p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation)
69 return -1;
71 p_filter->ops = &filter_ops;
73 return VLC_SUCCESS;
76 /****************************************************************************
77 * Filter: the whole thing
78 ****************************************************************************/
79 static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
81 picture_t *p_pic_dst;
82 int i_plane, i;
83 unsigned int j;
85 /* Request output picture */
86 p_pic_dst = filter_NewPicture( p_filter );
87 if( !p_pic_dst )
89 picture_Release( p_pic );
90 return NULL;
93 /* Convert RV24 to RV32 */
94 for( i_plane = 0; i_plane < p_pic_dst->i_planes; i_plane++ )
96 uint8_t *p_src = p_pic->p[i_plane].p_pixels;
97 uint8_t *p_dst = p_pic_dst->p[i_plane].p_pixels;
98 unsigned int i_width = p_filter->fmt_out.video.i_width;
100 for( i = 0; i < p_pic_dst->p[i_plane].i_lines; i++ )
102 for( j = 0; j < i_width; j++ )
104 *(p_dst++) = p_src[2];
105 *(p_dst++) = p_src[1];
106 *(p_dst++) = p_src[0];
107 *(p_dst++) = 0xff; /* Alpha */
108 p_src += 3;
110 p_src += p_pic->p[i_plane].i_pitch - 3 * i_width;
111 p_dst += p_pic_dst->p[i_plane].i_pitch - 4 * i_width;
115 picture_CopyProperties( p_pic_dst, p_pic );
116 picture_Release( p_pic );
118 return p_pic_dst;