Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

rv32.c

00001 /*****************************************************************************
00002  * rv32.c: conversion plugin to RV32 format.
00003  *****************************************************************************
00004  * Copyright (C) 2005 the VideoLAN team
00005  * $Id: rv32.c 12821 2005-10-11 17:16:13Z zorglub $
00006  *
00007  * Author: Cyril Deguet <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include <vlc/vlc.h>
00028 #include <vlc/decoder.h>
00029 #include "vlc_filter.h"
00030 
00031 /*****************************************************************************
00032  * filter_sys_t : filter descriptor
00033  *****************************************************************************/
00034 struct filter_sys_t
00035 {
00036     es_format_t fmt_in;
00037     es_format_t fmt_out;
00038 };
00039 
00040 /****************************************************************************
00041  * Local prototypes
00042  ****************************************************************************/
00043 static int  OpenFilter ( vlc_object_t * );
00044 static void CloseFilter( vlc_object_t * );
00045 
00046 static picture_t *Filter( filter_t *, picture_t * );
00047 
00048 /*****************************************************************************
00049  * Module descriptor
00050  *****************************************************************************/
00051 vlc_module_begin();
00052     set_description( _("RV32 conversion filter") );
00053     set_capability( "video filter2", 1 );
00054     set_callbacks( OpenFilter, CloseFilter );
00055 vlc_module_end();
00056 
00057 /*****************************************************************************
00058  * OpenFilter: probe the filter and return score
00059  *****************************************************************************/
00060 static int OpenFilter( vlc_object_t *p_this )
00061 {
00062     filter_t *p_filter = (filter_t*)p_this;
00063     filter_sys_t *p_sys;
00064 
00065     /* XXX Only support RV24 -> RV32 conversion */
00066     if( p_filter->fmt_in.video.i_chroma != VLC_FOURCC('R','V','2','4') ||
00067         p_filter->fmt_out.video.i_chroma != VLC_FOURCC('R', 'V', '3', '2') )
00068     {
00069         return VLC_EGENERIC;
00070     }
00071 
00072     /* Allocate the memory needed to store the decoder's structure */
00073     if( ( p_filter->p_sys = p_sys =
00074           (filter_sys_t *)malloc(sizeof(filter_sys_t)) ) == NULL )
00075     {
00076         msg_Err( p_filter, "out of memory" );
00077         return VLC_EGENERIC;
00078     }
00079 
00080     p_filter->pf_video_filter = Filter;
00081 
00082     return VLC_SUCCESS;
00083 }
00084 
00085 /*****************************************************************************
00086  * CloseFilter: clean up the filter
00087  *****************************************************************************/
00088 static void CloseFilter( vlc_object_t *p_this )
00089 {
00090     filter_t *p_filter = (filter_t*)p_this;
00091     filter_sys_t *p_sys = p_filter->p_sys;
00092 
00093     free( p_sys );
00094 }
00095 
00096 /****************************************************************************
00097  * Filter: the whole thing
00098  ****************************************************************************/
00099 static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
00100 {
00101     picture_t *p_pic_dst;
00102     int i_plane, i;
00103     unsigned int j;
00104 
00105     /* Request output picture */
00106     p_pic_dst = p_filter->pf_vout_buffer_new( p_filter );
00107     if( !p_pic_dst )
00108     {
00109         msg_Warn( p_filter, "can't get output picture" );
00110         if( p_pic->pf_release )
00111             p_pic->pf_release( p_pic );
00112         return NULL;
00113     }
00114 
00115     /* Convert RV24 to RV32 */
00116     for( i_plane = 0; i_plane < p_pic_dst->i_planes; i_plane++ )
00117     {
00118         uint8_t *p_src = p_pic->p[i_plane].p_pixels;
00119         uint8_t *p_dst = p_pic_dst->p[i_plane].p_pixels;
00120         unsigned int i_width = p_filter->fmt_out.video.i_width;
00121 
00122         for( i = 0; i < p_pic_dst->p[i_plane].i_lines; i++ )
00123         {
00124             for( j = 0; j < i_width; j++ )
00125             {
00126                 *(p_dst++) = p_src[2];
00127                 *(p_dst++) = p_src[1];
00128                 *(p_dst++) = p_src[0];
00129                 *(p_dst++) = 0xff;  /* Alpha */
00130                 p_src += 3;
00131             }
00132             p_src += p_pic->p[i_plane].i_pitch - 3 * i_width;
00133             p_dst += p_pic_dst->p[i_plane].i_pitch - 4 * i_width;
00134         }
00135     }
00136 
00137     p_pic_dst->date = p_pic->date;
00138     p_pic_dst->b_force = p_pic->b_force;
00139     p_pic_dst->i_nb_fields = p_pic->i_nb_fields;
00140     p_pic_dst->b_progressive = p_pic->b_progressive;
00141     p_pic_dst->b_top_field_first = p_pic->b_top_field_first;
00142 
00143     p_pic->pf_release( p_pic );
00144     return p_pic_dst;
00145 }
00146 

Generated on Tue Dec 20 10:14:53 2005 for vlc-0.8.4a by  doxygen 1.4.2