X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Ffilter_picture.h;h=b2be09046c30b03852458ac83e479554440c676b;hb=ddece1c533efeffec235a190f44a72853a604ea7;hp=97ac7b32a154279e6b19fd9e8f40faa3575dbb17;hpb=b6dc08dbaaf134f80a528e1ac1e63309a55cf9c7;p=vlc diff --git a/modules/video_filter/filter_picture.h b/modules/video_filter/filter_picture.h index 97ac7b32a1..b2be09046c 100644 --- a/modules/video_filter/filter_picture.h +++ b/modules/video_filter/filter_picture.h @@ -1,78 +1,76 @@ /***************************************************************************** * filter_picture.h: Common picture functions for filters ***************************************************************************** - * Copyright (C) 2007 the VideoLAN team + * Copyright (C) 2007 VLC authors and VideoLAN * $Id$ * * Authors: Antoine Cellerier * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /* FIXME: do all of these really have square pixels? */ #define CASE_PLANAR_YUV_SQUARE \ - case VLC_FOURCC('I','4','2','0'): \ - case VLC_FOURCC('I','Y','U','V'): \ - case VLC_FOURCC('J','4','2','0'): \ - case VLC_FOURCC('Y','V','1','2'): \ - case VLC_FOURCC('I','4','1','1'): \ - case VLC_FOURCC('I','4','1','0'): \ - case VLC_FOURCC('Y','V','U','9'): \ - case VLC_FOURCC('I','4','4','4'): \ - case VLC_FOURCC('J','4','4','4'): \ - case VLC_FOURCC('Y','U','V','A'): + case VLC_CODEC_I420: \ + case VLC_CODEC_J420: \ + case VLC_CODEC_YV12: \ + case VLC_CODEC_I411: \ + case VLC_CODEC_I410: \ + case VLC_CODEC_I444: \ + case VLC_CODEC_J444: \ + case VLC_CODEC_YUVA: #define CASE_PLANAR_YUV_NONSQUARE \ - case VLC_FOURCC('I','4','2','2'): \ - case VLC_FOURCC('J','4','2','2'): + case VLC_CODEC_I422: \ + case VLC_CODEC_J422: #define CASE_PLANAR_YUV \ CASE_PLANAR_YUV_SQUARE \ CASE_PLANAR_YUV_NONSQUARE \ #define CASE_PACKED_YUV_422 \ - case VLC_FOURCC('U','Y','V','Y'): \ - case VLC_FOURCC('U','Y','N','V'): \ - case VLC_FOURCC('Y','4','2','2'): \ - case VLC_FOURCC('c','y','u','v'): \ - case VLC_FOURCC('Y','U','Y','2'): \ - case VLC_FOURCC('Y','U','N','V'): \ - case VLC_FOURCC('Y','V','Y','U'): + case VLC_CODEC_UYVY: \ + case VLC_CODEC_CYUV: \ + case VLC_CODEC_YUYV: \ + case VLC_CODEC_YVYU: static inline int GetPackedYuvOffsets( vlc_fourcc_t i_chroma, int *i_y_offset, int *i_u_offset, int *i_v_offset ) { switch( i_chroma ) { - case VLC_FOURCC('U','Y','V','Y'): - case VLC_FOURCC('U','Y','N','V'): - case VLC_FOURCC('Y','4','2','2'): - case VLC_FOURCC('c','y','u','v'): /* <-- FIXME: reverted, whatever that means */ + case VLC_CODEC_UYVY: + case VLC_CODEC_CYUV: /* <-- FIXME: reverted, whatever that means */ /* UYVY */ *i_y_offset = 1; *i_u_offset = 0; *i_v_offset = 2; return VLC_SUCCESS; - case VLC_FOURCC('Y','U','Y','2'): - case VLC_FOURCC('Y','U','N','V'): + case VLC_CODEC_VYUY: + /* VYUY */ + *i_y_offset = 1; + *i_u_offset = 2; + *i_v_offset = 0; + return VLC_SUCCESS; + case VLC_CODEC_YUYV: /* YUYV */ *i_y_offset = 0; *i_u_offset = 1; *i_v_offset = 3; return VLC_SUCCESS; - case VLC_FOURCC('Y','V','Y','U'): + case VLC_CODEC_YVYU: /* YVYU */ *i_y_offset = 0; *i_u_offset = 3; @@ -83,19 +81,75 @@ static inline int GetPackedYuvOffsets( vlc_fourcc_t i_chroma, } } +static inline int GetPackedRgbIndexes( const video_format_t *p_fmt, int *i_r_index, + int *i_g_index, int *i_b_index ) +{ + if( p_fmt->i_chroma != VLC_CODEC_RGB24 && p_fmt->i_chroma != VLC_CODEC_RGB32 ) + return VLC_EGENERIC; + +#ifdef WORDS_BIGENDIAN + const int i_mask_bits = p_fmt->i_chroma == VLC_CODEC_RGB24 ? 24 : 32; + *i_r_index = ( i_mask_bits - p_fmt->i_lrshift ) / 8; + *i_g_index = ( i_mask_bits - p_fmt->i_lgshift ) / 8; + *i_b_index = ( i_mask_bits - p_fmt->i_lbshift ) / 8; +#else + *i_r_index = p_fmt->i_lrshift / 8; + *i_g_index = p_fmt->i_lgshift / 8; + *i_b_index = p_fmt->i_lbshift / 8; +#endif + return VLC_SUCCESS; +} + +static inline uint8_t vlc_uint8( int v ) +{ + if( v > 255 ) + return 255; + else if( v < 0 ) + return 0; + return v; +} + +static inline void yuv_to_rgb( int *r, int *g, int *b, + uint8_t y1, uint8_t u1, uint8_t v1 ) +{ + /* macros used for YUV pixel conversions */ +# define SCALEBITS 10 +# define ONE_HALF (1 << (SCALEBITS - 1)) +# define FIX(x) ((int) ((x) * (1<> SCALEBITS ); + *g = vlc_uint8( (y + g_add) >> SCALEBITS ); + *b = vlc_uint8( (y + b_add) >> SCALEBITS ); +#undef FIX +#undef ONE_HALF +#undef SCALEBITS +} + +static inline void rgb_to_yuv( uint8_t *y, uint8_t *u, uint8_t *v, + int r, int g, int b ) +{ + *y = ( ( ( 66 * r + 129 * g + 25 * b + 128 ) >> 8 ) + 16 ); + *u = ( ( -38 * r - 74 * g + 112 * b + 128 ) >> 8 ) + 128 ; + *v = ( ( 112 * r - 94 * g - 18 * b + 128 ) >> 8 ) + 128 ; +} + /***************************************************************************** * *****************************************************************************/ -static inline picture_t *CopyMetaAndRelease( picture_t *p_outpic, picture_t *p_inpic ) +static inline picture_t *CopyInfoAndRelease( picture_t *p_outpic, picture_t *p_inpic ) { - p_outpic->date = p_inpic->date; - p_outpic->b_force = p_inpic->b_force; - p_outpic->i_nb_fields = p_inpic->i_nb_fields; - p_outpic->b_progressive = p_inpic->b_progressive; - p_outpic->b_top_field_first = p_inpic->b_top_field_first; + picture_CopyProperties( p_outpic, p_inpic ); - if( p_inpic->pf_release ) - p_inpic->pf_release( p_inpic ); + picture_Release( p_inpic ); return p_outpic; }