[vlc-commits] [Git][videolan/vlc][master] 6 commits: video_filter: group RGB+x and RGB+a switch cases
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Oct 8 14:30:07 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
96b4e994 by Steve Lhomme at 2023-10-08T13:56:35+00:00
video_filter: group RGB+x and RGB+a switch cases
As it's done for some other common chromas.
- - - - -
e6016c37 by Steve Lhomme at 2023-10-08T13:56:35+00:00
video_filter: group 16-bit/15-bit RGB switch cases
As it's done for some other common chromas.
- - - - -
6c741311 by Steve Lhomme at 2023-10-08T13:56:35+00:00
filter/scale: use common case for RGB+x, RGB+a chromas
- - - - -
4498db85 by Steve Lhomme at 2023-10-08T13:56:35+00:00
chroma/yuvp: use GetPackedRgbIndexes() to get the RGBA indexes
We could probably support RGB+x and RGB24 sources as well.
vlc_uint8() is defined the same way in filter_picture.h
- - - - -
bdafa979 by Steve Lhomme at 2023-10-08T13:56:35+00:00
chroma/yuvp: use common case for RGB+a chromas
- - - - -
6468fb25 by Steve Lhomme at 2023-10-08T13:56:35+00:00
chroma/i420_rgb: use common case for RGB chromas
- - - - -
6 changed files:
- modules/video_chroma/i420_rgb.c
- modules/video_chroma/yuvp.c
- modules/video_filter/filter_picture.h
- modules/video_filter/mirror.c
- modules/video_filter/posterize.c
- modules/video_filter/scale.c
Changes:
=====================================
modules/video_chroma/i420_rgb.c
=====================================
@@ -36,6 +36,7 @@
#include <vlc_cpu.h>
#include "i420_rgb.h"
+#include "../video_filter/filter_picture.h"
#ifdef PLUGIN_PLAIN
# include "i420_rgb_c.h"
@@ -153,10 +154,7 @@ static int Activate( filter_t *p_filter )
case VLC_CODEC_BGR555:
p_filter->ops = &I420_RGB16_ops;
break;
- case VLC_CODEC_XRGB:
- case VLC_CODEC_XBGR:
- case VLC_CODEC_RGBX:
- case VLC_CODEC_BGRX:
+ CASE_PACKED_RGBX
p_filter->ops = &I420_RGB32_ops;
break;
#endif
@@ -185,20 +183,10 @@ static int Activate( filter_t *p_filter )
p_sys->i_bytespp = 1;
break;
#endif
- case VLC_CODEC_RGB565BE:
- case VLC_CODEC_BGR565BE:
- case VLC_CODEC_RGB565LE:
- case VLC_CODEC_BGR565LE:
- case VLC_CODEC_RGB555BE:
- case VLC_CODEC_BGR555BE:
- case VLC_CODEC_RGB555LE:
- case VLC_CODEC_BGR555LE:
+ CASE_PACKED_RGB1615
p_sys->i_bytespp = 2;
break;
- case VLC_CODEC_XRGB:
- case VLC_CODEC_XBGR:
- case VLC_CODEC_RGBX:
- case VLC_CODEC_BGRX:
+ CASE_PACKED_RGBX
case VLC_CODEC_RGB24:
case VLC_CODEC_BGR24:
p_sys->i_bytespp = 4;
@@ -366,14 +354,7 @@ static void SetYUV( filter_t *p_filter, const video_format_t *vfmt )
Set8bppPalette( p_filter, p_sys->p_rgb8 );
break;
- case VLC_CODEC_RGB565BE:
- case VLC_CODEC_BGR565BE:
- case VLC_CODEC_RGB565LE:
- case VLC_CODEC_BGR565LE:
- case VLC_CODEC_RGB555BE:
- case VLC_CODEC_BGR555BE:
- case VLC_CODEC_RGB555LE:
- case VLC_CODEC_BGR555LE:
+ CASE_PACKED_RGB1615
p_sys->p_rgb16 = (uint16_t *)p_sys->p_base;
for( unsigned i_index = 0; i_index < RED_MARGIN; i_index++ )
{
@@ -398,10 +379,7 @@ static void SetYUV( filter_t *p_filter, const video_format_t *vfmt )
}
break;
- case VLC_CODEC_XRGB:
- case VLC_CODEC_XBGR:
- case VLC_CODEC_RGBX:
- case VLC_CODEC_BGRX:
+ CASE_PACKED_RGBX
case VLC_CODEC_RGB24:
case VLC_CODEC_BGR24:
p_sys->p_rgb32 = (uint32_t *)p_sys->p_base;
=====================================
modules/video_chroma/yuvp.c
=====================================
@@ -32,6 +32,7 @@
#include <vlc_filter.h>
#include <vlc_picture.h>
#include <assert.h>
+#include "../video_filter/filter_picture.h"
/* TODO:
* Add anti-aliasing support (specially for DVD where only 4 colors are used)
@@ -61,18 +62,20 @@ static int Open( filter_t *p_filter )
{
/* It only supports YUVP to YUVA/RGBA without scaling
* (if scaling is required another filter can do it) */
- if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVP ||
- ( p_filter->fmt_out.video.i_chroma != VLC_CODEC_YUVA &&
- p_filter->fmt_out.video.i_chroma != VLC_CODEC_RGBA &&
- p_filter->fmt_out.video.i_chroma != VLC_CODEC_ARGB &&
- p_filter->fmt_out.video.i_chroma != VLC_CODEC_BGRA &&
- p_filter->fmt_out.video.i_chroma != VLC_CODEC_ABGR) ||
- p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width ||
+ if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVP )
+ return VLC_EGENERIC;
+ switch ( p_filter->fmt_out.video.i_chroma )
+ {
+ CASE_PACKED_RGBA
+ case VLC_CODEC_YUVA:
+ break;
+ default:
+ return VLC_EGENERIC;
+ }
+ if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width ||
p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height ||
p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation )
- {
return VLC_EGENERIC;
- }
p_filter->ops = &Convert_ops;
@@ -125,15 +128,7 @@ static void Convert( filter_t *p_filter, picture_t *p_source,
video_palette_t rgbp;
int r, g, b, a;
- switch( p_filter->fmt_out.video.i_chroma )
- {
- case VLC_CODEC_ARGB: r = 1, g = 2, b = 3, a = 0; break;
- case VLC_CODEC_RGBA: r = 0, g = 1, b = 2, a = 3; break;
- case VLC_CODEC_BGRA: r = 2, g = 1, b = 0, a = 3; break;
- case VLC_CODEC_ABGR: r = 3, g = 2, b = 1, a = 0; break;
- default:
- vlc_assert_unreachable();
- }
+ GetPackedRgbIndexes(p_filter->fmt_out.video.i_chroma, &r, &g, &b, &a);
/* Create a RGBA palette */
rgbp.i_entries = p_yuvp->i_entries;
for( int i = 0; i < p_yuvp->i_entries; i++ )
@@ -170,15 +165,6 @@ static void Convert( filter_t *p_filter, picture_t *p_source,
}
}
-/* FIXME copied from blend.c */
-static inline uint8_t vlc_uint8( int v )
-{
- if( v > 255 )
- return 255;
- else if( v < 0 )
- return 0;
- return v;
-}
static void Yuv2Rgb( uint8_t *r, uint8_t *g, uint8_t *b, int y1, int u1, int v1 )
{
/* macros used for YUV pixel conversions */
=====================================
modules/video_filter/filter_picture.h
=====================================
@@ -56,6 +56,38 @@
case VLC_CODEC_YUYV: \
case VLC_CODEC_YVYU:
+#define CASE_PACKED_RGBX \
+ case VLC_CODEC_RGBX: \
+ case VLC_CODEC_XRGB: \
+ case VLC_CODEC_BGRX: \
+ case VLC_CODEC_XBGR:
+
+#define CASE_PACKED_RGBA \
+ case VLC_CODEC_RGBA: \
+ case VLC_CODEC_ARGB: \
+ case VLC_CODEC_BGRA: \
+ case VLC_CODEC_ABGR:
+
+#define CASE_PACKED_RGB32 \
+ CASE_PACKED_RGBX \
+ CASE_PACKED_RGBA
+
+#define CASE_PACKED_RGB16 \
+ case VLC_CODEC_RGB565BE: \
+ case VLC_CODEC_RGB565LE: \
+ case VLC_CODEC_BGR565BE: \
+ case VLC_CODEC_BGR565LE:
+
+#define CASE_PACKED_RGB15 \
+ case VLC_CODEC_RGB555BE: \
+ case VLC_CODEC_RGB555LE: \
+ case VLC_CODEC_BGR555BE: \
+ case VLC_CODEC_BGR555LE:
+
+#define CASE_PACKED_RGB1615 \
+ CASE_PACKED_RGB16 \
+ CASE_PACKED_RGB15
+
static inline int GetPackedYuvOffsets( vlc_fourcc_t i_chroma,
int *i_y_offset, int *i_u_offset, int *i_v_offset )
{
=====================================
modules/video_filter/mirror.c
=====================================
@@ -120,16 +120,10 @@ static int Create( filter_t *p_filter )
break;
CASE_PACKED_YUV_422
break;
+ CASE_PACKED_RGB32
+ break;
case VLC_CODEC_RGB24:
case VLC_CODEC_BGR24:
- case VLC_CODEC_RGBA:
- case VLC_CODEC_ARGB:
- case VLC_CODEC_BGRA:
- case VLC_CODEC_ABGR:
- case VLC_CODEC_RGBX:
- case VLC_CODEC_XRGB:
- case VLC_CODEC_BGRX:
- case VLC_CODEC_XBGR:
break;
default:
@@ -229,14 +223,7 @@ static void VerticalMirror( picture_t *p_pic, picture_t *p_outpic, int i_plane,
case VLC_CODEC_BGR24:
RV24VerticalMirror( p_pic, p_outpic, i_plane, b_left_to_right );
break;
- case VLC_CODEC_RGBA:
- case VLC_CODEC_ARGB:
- case VLC_CODEC_BGRA:
- case VLC_CODEC_ABGR:
- case VLC_CODEC_RGBX:
- case VLC_CODEC_XRGB:
- case VLC_CODEC_BGRX:
- case VLC_CODEC_XBGR:
+ CASE_PACKED_RGB32
RV32VerticalMirror( p_pic, p_outpic, i_plane, b_left_to_right );
break;
default:
=====================================
modules/video_filter/posterize.c
=====================================
@@ -105,14 +105,7 @@ static int Create( filter_t *p_filter )
case VLC_CODEC_RGB24:
case VLC_CODEC_BGR24:
break;
- case VLC_CODEC_RGBA:
- case VLC_CODEC_ARGB:
- case VLC_CODEC_BGRA:
- case VLC_CODEC_ABGR:
- case VLC_CODEC_RGBX:
- case VLC_CODEC_XRGB:
- case VLC_CODEC_BGRX:
- case VLC_CODEC_XBGR:
+ CASE_PACKED_RGB32
break;
default:
msg_Err( p_filter, "Unsupported input chroma (%4.4s)",
@@ -175,14 +168,7 @@ static void Filter( filter_t *p_filter, picture_t *p_pic, picture_t *p_outpic )
case VLC_CODEC_BGR24:
RVPosterize( p_pic, p_outpic, false, level );
break;
- case VLC_CODEC_RGBA:
- case VLC_CODEC_ARGB:
- case VLC_CODEC_BGRA:
- case VLC_CODEC_ABGR:
- case VLC_CODEC_RGBX:
- case VLC_CODEC_XRGB:
- case VLC_CODEC_BGRX:
- case VLC_CODEC_XBGR:
+ CASE_PACKED_RGB32
RVPosterize( p_pic, p_outpic, true, level );
break;
CASE_PLANAR_YUV_SQUARE
=====================================
modules/video_filter/scale.c
=====================================
@@ -33,6 +33,7 @@
#include <vlc_plugin.h>
#include <vlc_filter.h>
#include <vlc_picture.h>
+#include "filter_picture.h"
/****************************************************************************
* Local prototypes
@@ -53,22 +54,19 @@ vlc_module_end ()
*****************************************************************************/
static int OpenFilter( filter_t *p_filter )
{
- if( ( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVP &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVA &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_I420 &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_YV12 &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGBA &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_ARGB &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_BGRA &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_ABGR &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGBX &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_XRGB &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_BGRX &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_XBGR ) ||
- !video_format_IsSameChroma( &p_filter->fmt_in.video,
- &p_filter->fmt_out.video ) )
+ switch (p_filter->fmt_in.video.i_chroma)
{
- return VLC_EGENERIC;
+ case VLC_CODEC_YUVP:
+ case VLC_CODEC_YUVA:
+ case VLC_CODEC_I420:
+ case VLC_CODEC_YV12:
+ CASE_PACKED_RGB32
+ if (!video_format_IsSameChroma( &p_filter->fmt_in.video,
+ &p_filter->fmt_out.video ) )
+ return VLC_EINVAL;
+ break;
+ default:
+ return VLC_EINVAL;
}
if( p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation )
@@ -94,15 +92,9 @@ static void Filter( filter_t *p_filter, picture_t *p_pic, picture_t *p_pic_dst )
#warning Converter cannot (really) change output format.
video_format_ScaleCropAr( &p_filter->fmt_out.video, &p_filter->fmt_in.video );
- if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGBA &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_ARGB &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_BGRA &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_ABGR &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_RGBX &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_XRGB &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_BGRX &&
- p_filter->fmt_in.video.i_chroma != VLC_CODEC_XBGR )
+ switch (p_filter->fmt_in.video.i_chroma)
{
+ default:
for( int i_plane = 0; i_plane < p_pic_dst->i_planes; i_plane++ )
{
const int i_src_pitch = p_pic->p[i_plane].i_pitch;
@@ -147,8 +139,8 @@ static void Filter( filter_t *p_filter, picture_t *p_pic, picture_t *p_pic_dst )
}
}
}
- }
- else /* RGBA */
+ break;
+ CASE_PACKED_RGB32
{
const int i_src_pitch = p_pic->p->i_pitch;
const int i_dst_pitch = p_pic_dst->p->i_pitch;
@@ -190,5 +182,7 @@ static void Filter( filter_t *p_filter, picture_t *p_pic, picture_t *p_pic_dst )
*p_dst = p_srcl[__MIN( i_src_width_1, k >> SHIFT_SIZE )];
}
}
+ break;
+ }
}
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2b5929edd6001a2b14c308989a51be4c73103265...6468fb25955ebe9c76b553abfb755dc0392369e5
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2b5929edd6001a2b14c308989a51be4c73103265...6468fb25955ebe9c76b553abfb755dc0392369e5
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list