1 /*****************************************************************************
2 * rv32.c: conversion plugin to RV32 format.
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
7 * Author: Cyril Deguet <asmax@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_plugin.h>
33 #include <vlc_filter.h>
35 /****************************************************************************
37 ****************************************************************************/
38 static int OpenFilter ( vlc_object_t * );
39 static void CloseFilter( vlc_object_t * );
41 static picture_t *Filter( filter_t *, picture_t * );
43 /*****************************************************************************
45 *****************************************************************************/
47 set_description( N_("RV32 conversion filter") )
48 set_capability( "video filter2", 1 )
49 set_callbacks( OpenFilter, CloseFilter )
52 /*****************************************************************************
53 * OpenFilter: probe the filter and return score
54 *****************************************************************************/
55 static int OpenFilter( vlc_object_t *p_this )
57 filter_t *p_filter = (filter_t*)p_this;
59 /* XXX Only support RV24 -> RV32 conversion */
60 if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGB24 ||
61 (p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGB32 &&
62 p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGBA) )
67 if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width
68 || p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height )
71 p_filter->pf_video_filter = Filter;
76 /*****************************************************************************
77 * CloseFilter: clean up the filter
78 *****************************************************************************/
79 static void CloseFilter( vlc_object_t *p_this )
84 /****************************************************************************
85 * Filter: the whole thing
86 ****************************************************************************/
87 static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
93 /* Request output picture */
94 p_pic_dst = filter_NewPicture( p_filter );
97 picture_Release( p_pic );
101 /* Convert RV24 to RV32 */
102 for( i_plane = 0; i_plane < p_pic_dst->i_planes; i_plane++ )
104 uint8_t *p_src = p_pic->p[i_plane].p_pixels;
105 uint8_t *p_dst = p_pic_dst->p[i_plane].p_pixels;
106 unsigned int i_width = p_filter->fmt_out.video.i_width;
108 for( i = 0; i < p_pic_dst->p[i_plane].i_lines; i++ )
110 for( j = 0; j < i_width; j++ )
112 *(p_dst++) = p_src[2];
113 *(p_dst++) = p_src[1];
114 *(p_dst++) = p_src[0];
115 *(p_dst++) = 0xff; /* Alpha */
118 p_src += p_pic->p[i_plane].i_pitch - 3 * i_width;
119 p_dst += p_pic_dst->p[i_plane].i_pitch - 4 * i_width;
123 picture_CopyProperties( p_pic_dst, p_pic );
124 picture_Release( p_pic );