]> git.sesse.net Git - vlc/blob - modules/video_chroma/rv32.c
httpd: reject incoming requests bodies over 64k
[vlc] / modules / video_chroma / rv32.c
1 /*****************************************************************************
2  * rv32.c: conversion plugin to RV32 format.
3  *****************************************************************************
4  * Copyright (C) 2005 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Author: Cyril Deguet <asmax@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
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 Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <vlc_common.h>
32 #include <vlc_plugin.h>
33 #include <vlc_filter.h>
34
35 /****************************************************************************
36  * Local prototypes
37  ****************************************************************************/
38 static int  OpenFilter ( vlc_object_t * );
39 static picture_t *Filter( filter_t *, picture_t * );
40
41 /*****************************************************************************
42  * Module descriptor
43  *****************************************************************************/
44 vlc_module_begin ()
45     set_description( N_("RV32 conversion filter") )
46     set_capability( "video filter2", 1 )
47     set_callbacks( OpenFilter, NULL )
48 vlc_module_end ()
49
50 /*****************************************************************************
51  * OpenFilter: probe the filter and return score
52  *****************************************************************************/
53 static int OpenFilter( vlc_object_t *p_this )
54 {
55     filter_t *p_filter = (filter_t*)p_this;
56
57     /* XXX Only support RV24 -> RV32 conversion */
58     if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGB24 ||
59         (p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGB32 &&
60         p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGBA) )
61     {
62         return VLC_EGENERIC;
63     }
64
65     if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width
66      || p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height
67      || p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation)
68         return -1;
69
70     p_filter->pf_video_filter = Filter;
71
72     return VLC_SUCCESS;
73 }
74
75 /****************************************************************************
76  * Filter: the whole thing
77  ****************************************************************************/
78 static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
79 {
80     picture_t *p_pic_dst;
81     int i_plane, i;
82     unsigned int j;
83
84     /* Request output picture */
85     p_pic_dst = filter_NewPicture( p_filter );
86     if( !p_pic_dst )
87     {
88         picture_Release( p_pic );
89         return NULL;
90     }
91
92     /* Convert RV24 to RV32 */
93     for( i_plane = 0; i_plane < p_pic_dst->i_planes; i_plane++ )
94     {
95         uint8_t *p_src = p_pic->p[i_plane].p_pixels;
96         uint8_t *p_dst = p_pic_dst->p[i_plane].p_pixels;
97         unsigned int i_width = p_filter->fmt_out.video.i_width;
98
99         for( i = 0; i < p_pic_dst->p[i_plane].i_lines; i++ )
100         {
101             for( j = 0; j < i_width; j++ )
102             {
103                 *(p_dst++) = p_src[2];
104                 *(p_dst++) = p_src[1];
105                 *(p_dst++) = p_src[0];
106                 *(p_dst++) = 0xff;  /* Alpha */
107                 p_src += 3;
108             }
109             p_src += p_pic->p[i_plane].i_pitch - 3 * i_width;
110             p_dst += p_pic_dst->p[i_plane].i_pitch - 4 * i_width;
111         }
112     }
113
114     picture_CopyProperties( p_pic_dst, p_pic );
115     picture_Release( p_pic );
116
117     return p_pic_dst;
118 }
119