00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <vlc/vlc.h>
00028 #include <vlc/decoder.h>
00029 #include "vlc_filter.h"
00030
00031
00032
00033
00034 struct filter_sys_t
00035 {
00036 es_format_t fmt_in;
00037 es_format_t fmt_out;
00038 };
00039
00040
00041
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
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
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
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
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
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
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
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
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;
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