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 *****************************************************************************/
32 #include <vlc_plugin.h>
34 #include "vlc_filter.h"
36 /*****************************************************************************
37 * filter_sys_t : filter descriptor
38 *****************************************************************************/
45 /****************************************************************************
47 ****************************************************************************/
48 static int OpenFilter ( vlc_object_t * );
49 static void CloseFilter( vlc_object_t * );
51 static picture_t *Filter( filter_t *, picture_t * );
53 /*****************************************************************************
55 *****************************************************************************/
57 set_description( _("RV32 conversion filter") );
58 set_capability( "video filter2", 1 );
59 set_callbacks( OpenFilter, CloseFilter );
62 /*****************************************************************************
63 * OpenFilter: probe the filter and return score
64 *****************************************************************************/
65 static int OpenFilter( vlc_object_t *p_this )
67 filter_t *p_filter = (filter_t*)p_this;
70 /* XXX Only support RV24 -> RV32 conversion */
71 if( p_filter->fmt_in.video.i_chroma != VLC_FOURCC('R','V','2','4') ||
72 p_filter->fmt_out.video.i_chroma != VLC_FOURCC('R', 'V', '3', '2') )
77 /* Allocate the memory needed to store the decoder's structure */
78 if( ( p_filter->p_sys = p_sys =
79 (filter_sys_t *)malloc(sizeof(filter_sys_t)) ) == NULL )
81 msg_Err( p_filter, "out of memory" );
85 p_filter->pf_video_filter = Filter;
90 /*****************************************************************************
91 * CloseFilter: clean up the filter
92 *****************************************************************************/
93 static void CloseFilter( vlc_object_t *p_this )
95 filter_t *p_filter = (filter_t*)p_this;
96 filter_sys_t *p_sys = p_filter->p_sys;
101 /****************************************************************************
102 * Filter: the whole thing
103 ****************************************************************************/
104 static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
106 picture_t *p_pic_dst;
110 /* Request output picture */
111 p_pic_dst = p_filter->pf_vout_buffer_new( p_filter );
114 msg_Warn( p_filter, "can't get output picture" );
115 if( p_pic->pf_release )
116 p_pic->pf_release( p_pic );
120 /* Convert RV24 to RV32 */
121 for( i_plane = 0; i_plane < p_pic_dst->i_planes; i_plane++ )
123 uint8_t *p_src = p_pic->p[i_plane].p_pixels;
124 uint8_t *p_dst = p_pic_dst->p[i_plane].p_pixels;
125 unsigned int i_width = p_filter->fmt_out.video.i_width;
127 for( i = 0; i < p_pic_dst->p[i_plane].i_lines; i++ )
129 for( j = 0; j < i_width; j++ )
131 *(p_dst++) = p_src[2];
132 *(p_dst++) = p_src[1];
133 *(p_dst++) = p_src[0];
134 *(p_dst++) = 0xff; /* Alpha */
137 p_src += p_pic->p[i_plane].i_pitch - 3 * i_width;
138 p_dst += p_pic_dst->p[i_plane].i_pitch - 4 * i_width;
142 p_pic_dst->date = p_pic->date;
143 p_pic_dst->b_force = p_pic->b_force;
144 p_pic_dst->i_nb_fields = p_pic->i_nb_fields;
145 p_pic_dst->b_progressive = p_pic->b_progressive;
146 p_pic_dst->b_top_field_first = p_pic->b_top_field_first;
148 p_pic->pf_release( p_pic );