Commit 7c7f2f88 authored by Antoine Cellerier's avatar Antoine Cellerier

Some more filter work:

 * adjust.c, extract.c: packed YUV 422 support.
 * filter_picture.h: code shared by some "video filter2" filters.
 * erase.c: validate the picture chroma in the constructor.
parent 5a2dd0dd
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
#ifndef M_PI #ifndef M_PI
# define M_PI 3.14159265358979323846 # define M_PI 3.14159265358979323846
...@@ -46,7 +47,8 @@ ...@@ -46,7 +47,8 @@
static int Create ( vlc_object_t * ); static int Create ( vlc_object_t * );
static void Destroy ( vlc_object_t * ); static void Destroy ( vlc_object_t * );
static picture_t *Filter( filter_t *, picture_t * ); static picture_t *FilterPlanar( filter_t *, picture_t * );
static picture_t *FilterPacked( filter_t *, picture_t * );
static int AdjustCallback( vlc_object_t *p_this, char const *psz_var, static int AdjustCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, vlc_value_t oldval, vlc_value_t newval,
void *p_data ); void *p_data );
...@@ -114,39 +116,37 @@ struct filter_sys_t ...@@ -114,39 +116,37 @@ struct filter_sys_t
}; };
/***************************************************************************** /*****************************************************************************
* Create: allocates adjust video thread output method * Create: allocates adjust video filter
*****************************************************************************
* This function allocates and initializes a adjust vout method.
*****************************************************************************/ *****************************************************************************/
static int Create( vlc_object_t *p_this ) static int Create( vlc_object_t *p_this )
{ {
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys; filter_sys_t *p_sys;
/* XXX: we might need to add/remove some FOURCCs ... */ switch( p_filter->fmt_in.video.i_chroma )
if( p_filter->fmt_in.video.i_chroma != VLC_FOURCC('I','4','2','0')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('I','Y','U','V')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('J','4','2','0')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','V','1','2')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('I','U','Y','V')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('U','Y','V','Y')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('U','Y','N','V')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','4','2','2')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('c','y','u','v')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','U','Y','2')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','U','N','V')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','V','Y','U')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('I','4','1','1')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('I','4','1','0')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','V','U','9')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','M','G','A')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('I','4','2','2')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('J','4','2','2')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('I','4','4','4')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('J','4','4','4')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','U','V','P')
&& p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','U','V','A') )
{ {
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','2','2'):
case VLC_FOURCC('J','4','2','2'):
case VLC_FOURCC('I','4','4','4'):
case VLC_FOURCC('J','4','4','4'):
case VLC_FOURCC('Y','U','V','A'):
/* Planar YUV */
p_filter->pf_video_filter = FilterPlanar;
break;
CASE_PACKED_YUV_422
/* Packed YUV 4:2:2 */
p_filter->pf_video_filter = FilterPacked;
break;
default:
msg_Err( p_filter, "Unsupported input chroma (%4s)", msg_Err( p_filter, "Unsupported input chroma (%4s)",
(char*)&(p_filter->fmt_in.video.i_chroma) ); (char*)&(p_filter->fmt_in.video.i_chroma) );
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -167,8 +167,6 @@ static int Create( vlc_object_t *p_this ) ...@@ -167,8 +167,6 @@ static int Create( vlc_object_t *p_this )
} }
p_sys = p_filter->p_sys; p_sys = p_filter->p_sys;
p_filter->pf_video_filter = Filter;
/* needed to get options passed in transcode using the /* needed to get options passed in transcode using the
* adjust{name=value} syntax */ * adjust{name=value} syntax */
config_ChainParse( p_filter, "", ppsz_filter_options, config_ChainParse( p_filter, "", ppsz_filter_options,
...@@ -194,9 +192,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -194,9 +192,7 @@ static int Create( vlc_object_t *p_this )
} }
/***************************************************************************** /*****************************************************************************
* Destroy: destroy adjust video thread output method * Destroy: destroy adjust video filter
*****************************************************************************
* Terminate an output method created by adjustCreateOutputMethod
*****************************************************************************/ *****************************************************************************/
static void Destroy( vlc_object_t *p_this ) static void Destroy( vlc_object_t *p_this )
{ {
...@@ -205,13 +201,9 @@ static void Destroy( vlc_object_t *p_this ) ...@@ -205,13 +201,9 @@ static void Destroy( vlc_object_t *p_this )
} }
/***************************************************************************** /*****************************************************************************
* Render: displays previously rendered output * Run the filter on a Planar YUV picture
*****************************************************************************
* This function send the currently rendered image to adjust modified image,
* waits until it is displayed and switch the two rendering buffers, preparing
* next frame.
*****************************************************************************/ *****************************************************************************/
static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic )
{ {
int pi_luma[256]; int pi_luma[256];
int pi_gamma[256]; int pi_gamma[256];
...@@ -381,6 +373,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -381,6 +373,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
p_out_v += p_outpic->p[V_PLANE].i_pitch p_out_v += p_outpic->p[V_PLANE].i_pitch
- p_outpic->p[V_PLANE].i_visible_pitch; - p_outpic->p[V_PLANE].i_visible_pitch;
} }
#undef WRITE_UV_CLIP
} }
else else
{ {
...@@ -420,6 +413,249 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -420,6 +413,249 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
p_out_v += p_outpic->p[V_PLANE].i_pitch p_out_v += p_outpic->p[V_PLANE].i_pitch
- p_outpic->p[V_PLANE].i_visible_pitch; - p_outpic->p[V_PLANE].i_visible_pitch;
} }
#undef WRITE_UV
}
p_outpic->date = p_pic->date;
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
}
/*****************************************************************************
* Run the filter on a Packed YUV picture
*****************************************************************************/
static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
{
int pi_luma[256];
int pi_gamma[256];
picture_t *p_outpic;
uint8_t *p_in, *p_in_v, *p_in_end, *p_line_end;
uint8_t *p_out, *p_out_v;
int i_y_offset, i_u_offset, i_v_offset;
int i_lines, i_visible_lines, i_pitch, i_visible_pitch;
vlc_bool_t b_thres;
double f_hue;
double f_gamma;
int32_t i_cont, i_lum;
int i_sat, i_sin, i_cos, i_x, i_y;
int i;
filter_sys_t *p_sys = p_filter->p_sys;
if( !p_pic ) return NULL;
i_lines = p_pic->p->i_lines;
i_visible_lines = p_pic->p->i_visible_lines;
i_pitch = p_pic->p->i_pitch;
i_visible_pitch = p_pic->p->i_visible_pitch;
if( GetPackedYuvOffsets( p_pic->format.i_chroma, &i_y_offset,
&i_u_offset, &i_v_offset ) != VLC_SUCCESS )
{
msg_Warn( p_filter, "Unsupported input chroma (%4s)",
(char*)&(p_pic->format.i_chroma) );
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return NULL;
}
p_outpic = p_filter->pf_vout_buffer_new( p_filter );
if( !p_outpic )
{
msg_Warn( p_filter, "can't get output picture" );
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return NULL;
}
/* Getvariables */
i_cont = (int)( p_sys->f_contrast * 255 );
i_lum = (int)( (p_sys->f_brightness - 1.0)*255 );
f_hue = (float)( p_sys->i_hue * M_PI / 180 );
i_sat = (int)( p_sys->f_saturation * 256 );
f_gamma = 1.0 / p_sys->f_gamma;
b_thres = p_sys->b_brightness_threshold;
/*
* Threshold mode drops out everything about luma, contrast and gamma.
*/
if( b_thres != VLC_TRUE )
{
/* Contrast is a fast but kludged function, so I put this gap to be
* cleaner :) */
i_lum += 128 - i_cont / 2;
/* Fill the gamma lookup table */
for( i = 0 ; i < 256 ; i++ )
{
pi_gamma[ i ] = clip_uint8_vlc( pow(i / 255.0, f_gamma) * 255.0);
}
/* Fill the luma lookup table */
for( i = 0 ; i < 256 ; i++ )
{
pi_luma[ i ] = pi_gamma[clip_uint8_vlc( i_lum + i_cont * i / 256)];
}
}
else
{
/*
* We get luma as threshold value: the higher it is, the darker is
* the image. Should I reverse this?
*/
for( i = 0 ; i < 256 ; i++ )
{
pi_luma[ i ] = (i < i_lum) ? 0 : 255;
}
/*
* Desaturates image to avoid that strange yellow halo...
*/
i_sat = 0;
}
/*
* Do the Y plane
*/
p_in = p_pic->p->p_pixels + i_y_offset;
p_in_end = p_in + p_pic->p->i_visible_lines * p_pic->p->i_pitch - 8 * 4;
p_out = p_outpic->p->p_pixels + i_y_offset;
for( ; p_in < p_in_end ; )
{
p_line_end = p_in + i_visible_pitch - 8 * 4;
for( ; p_in < p_line_end ; )
{
/* Do 8 pixels at a time */
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
}
p_line_end += 8 * 4;
for( ; p_in < p_line_end ; )
{
*p_out = pi_luma[ *p_in ]; p_in += 2; p_out += 2;
}
p_in += i_pitch - p_pic->p->i_visible_pitch;
p_out += i_pitch - p_outpic->p->i_visible_pitch;
}
/*
* Do the U and V planes
*/
p_in = p_pic->p->p_pixels + i_u_offset;
p_in_v = p_pic->p->p_pixels + i_v_offset;
p_in_end = p_in + i_visible_lines * i_pitch - 8 * 4;
p_out = p_outpic->p->p_pixels + i_u_offset;
p_out_v = p_outpic->p->p_pixels + i_v_offset;
i_sin = sin(f_hue) * 256;
i_cos = cos(f_hue) * 256;
i_x = ( cos(f_hue) + sin(f_hue) ) * 32768;
i_y = ( cos(f_hue) - sin(f_hue) ) * 32768;
if ( i_sat > 256 )
{
#define WRITE_UV_CLIP() \
i_u = *p_in; p_in += 4; i_v = *p_in_v; p_in_v += 4; \
*p_out = clip_uint8_vlc( (( ((i_u * i_cos + i_v * i_sin - i_x) >> 8) \
* i_sat) >> 8) + 128); \
p_out += 4; \
*p_out_v = clip_uint8_vlc( (( ((i_v * i_cos - i_u * i_sin - i_y) >> 8) \
* i_sat) >> 8) + 128); \
p_out_v += 4
uint8_t i_u, i_v;
for( ; p_in < p_in_end ; )
{
p_line_end = p_in + i_visible_pitch - 8 * 4;
for( ; p_in < p_line_end ; )
{
/* Do 8 pixels at a time */
WRITE_UV_CLIP(); WRITE_UV_CLIP();
WRITE_UV_CLIP(); WRITE_UV_CLIP();
WRITE_UV_CLIP(); WRITE_UV_CLIP();
WRITE_UV_CLIP(); WRITE_UV_CLIP();
}
p_line_end += 8 * 4;
for( ; p_in < p_line_end ; )
{
WRITE_UV_CLIP();
}
p_in += i_pitch - i_visible_pitch;
p_in_v += i_pitch - i_visible_pitch;
p_out += i_pitch - i_visible_pitch;
p_out_v += i_pitch - i_visible_pitch;
}
#undef WRITE_UV_CLIP
}
else
{
#define WRITE_UV() \
i_u = *p_in; p_in += 4; i_v = *p_in_v; p_in_v += 4; \
*p_out = (( ((i_u * i_cos + i_v * i_sin - i_x) >> 8) \
* i_sat) >> 8) + 128; \
p_out += 4; \
*p_out_v = (( ((i_v * i_cos - i_u * i_sin - i_y) >> 8) \
* i_sat) >> 8) + 128; \
p_out_v += 4
uint8_t i_u, i_v;
for( ; p_in < p_in_end ; )
{
p_line_end = p_in + i_visible_pitch - 8 * 4;
for( ; p_in < p_line_end ; )
{
/* Do 8 pixels at a time */
WRITE_UV(); WRITE_UV(); WRITE_UV(); WRITE_UV();
WRITE_UV(); WRITE_UV(); WRITE_UV(); WRITE_UV();
}
p_line_end += 8 * 4;
for( ; p_in < p_line_end ; )
{
WRITE_UV();
}
p_in += i_pitch - i_visible_pitch;
p_in_v += i_pitch - i_visible_pitch;
p_out += i_pitch - i_visible_pitch;
p_out_v += i_pitch - i_visible_pitch;
}
#undef WRITE_UV
} }
p_outpic->date = p_pic->date; p_outpic->date = p_pic->date;
......
...@@ -120,6 +120,23 @@ static int Create( vlc_object_t *p_this ) ...@@ -120,6 +120,23 @@ static int Create( vlc_object_t *p_this )
filter_sys_t *p_sys; filter_sys_t *p_sys;
char *psz_filename; char *psz_filename;
switch( p_filter->fmt_in.video.i_chroma )
{
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','2','2'):
case VLC_FOURCC('J','4','2','2'):
break;
default:
msg_Err( p_filter, "Unsupported input chroma (%4s)",
(char*)&(p_filter->fmt_in.video.i_chroma) );
return VLC_EGENERIC;
}
/* Allocate structure */ /* Allocate structure */
p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL ) if( p_filter->p_sys == NULL )
...@@ -181,23 +198,6 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -181,23 +198,6 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
picture_t *p_outpic; picture_t *p_outpic;
if( !p_pic ) return NULL; if( !p_pic ) return NULL;
switch( p_pic->format.i_chroma )
{
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','2','2'):
case VLC_FOURCC('J','4','2','2'):
break;
default:
msg_Warn( p_filter, "Unsupported input chroma (%4s)",
(char*)&(p_pic->format.i_chroma) );
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return NULL;
}
p_outpic = p_filter->pf_vout_buffer_new( p_filter ); p_outpic = p_filter->pf_vout_buffer_new( p_filter );
if( !p_outpic ) if( !p_outpic )
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
#include "math.h" #include "math.h"
...@@ -51,6 +52,7 @@ static void get_blue_from_yuv422( picture_t *, picture_t *, int, int, int ); ...@@ -51,6 +52,7 @@ static void get_blue_from_yuv422( picture_t *, picture_t *, int, int, int );
static void make_projection_matrix( filter_t *, int color, int *matrix ); static void make_projection_matrix( filter_t *, int color, int *matrix );
static void get_custom_from_yuv420( picture_t *, picture_t *, int, int, int, int * ); static void get_custom_from_yuv420( picture_t *, picture_t *, int, int, int, int * );
static void get_custom_from_yuv422( picture_t *, picture_t *, int, int, int, int * ); static void get_custom_from_yuv422( picture_t *, picture_t *, int, int, int, int * );
static void get_custom_from_packedyuv422( picture_t *, picture_t *, int * );
#define COMPONENT_TEXT N_("RGB component to extract") #define COMPONENT_TEXT N_("RGB component to extract")
...@@ -96,6 +98,26 @@ static int Create( vlc_object_t *p_this ) ...@@ -96,6 +98,26 @@ static int Create( vlc_object_t *p_this )
{ {
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
switch( p_filter->fmt_in.video.i_chroma )
{
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','2','2'):
case VLC_FOURCC('J','4','2','2'):
CASE_PACKED_YUV_422
break;
default:
/* We only want planar YUV 4:2:0 or 4:2:2 */
msg_Err( p_filter, "Unsupported input chroma (%4s)",
(char*)&(p_filter->fmt_in.video.i_chroma) );
return VLC_EGENERIC;
}
/* Allocate structure */ /* Allocate structure */
p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL ) if( p_filter->p_sys == NULL )
...@@ -118,17 +140,10 @@ static int Create( vlc_object_t *p_this ) ...@@ -118,17 +140,10 @@ static int Create( vlc_object_t *p_this )
FILTER_PREFIX "component" ); FILTER_PREFIX "component" );
var_AddCallback( p_filter, FILTER_PREFIX "component", var_AddCallback( p_filter, FILTER_PREFIX "component",
ExtractCallback, p_filter->p_sys ); ExtractCallback, p_filter->p_sys );
switch( p_filter->p_sys->i_color )
{ /* Matrix won't be used for RED, GREEN or BLUE in planar formats */
case RED:
case GREEN:
case BLUE:
break;
default:
make_projection_matrix( p_filter, p_filter->p_sys->i_color, make_projection_matrix( p_filter, p_filter->p_sys->i_color,
p_filter->p_sys->projection_matrix ); p_filter->p_sys->projection_matrix );
break;
}
p_filter->pf_video_filter = Filter; p_filter->pf_video_filter = Filter;
...@@ -216,6 +231,11 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -216,6 +231,11 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
} }
break; break;
CASE_PACKED_YUV_422
get_custom_from_packedyuv422( p_pic, p_outpic,
p_filter->p_sys->projection_matrix );
break;
default: default:
msg_Warn( p_filter, "Unsupported input chroma (%4s)", msg_Warn( p_filter, "Unsupported input chroma (%4s)",
(char*)&(p_pic->format.i_chroma) ); (char*)&(p_pic->format.i_chroma) );
...@@ -392,6 +412,59 @@ static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic, ...@@ -392,6 +412,59 @@ static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
} }
} }
static void get_custom_from_packedyuv422( picture_t *p_inpic,
picture_t *p_outpic,
int *m )
{
int i_y_offset, i_u_offset, i_v_offset;
if( GetPackedYuvOffsets( p_inpic->format.i_chroma, &i_y_offset,
&i_u_offset, &i_v_offset ) != VLC_SUCCESS )
return;
uint8_t *yin = p_inpic->p->p_pixels + i_y_offset;
uint8_t *uin = p_inpic->p->p_pixels + i_u_offset;
uint8_t *vin = p_inpic->p->p_pixels + i_v_offset;
uint8_t *yout = p_outpic->p->p_pixels + i_y_offset;
uint8_t *uout = p_outpic->p->p_pixels + i_u_offset;
uint8_t *vout = p_outpic->p->p_pixels + i_v_offset;
const int i_pitch = p_inpic->p->i_pitch;
const int i_visible_pitch = p_inpic->p->i_visible_pitch;
const int i_visible_lines = p_inpic->p->i_visible_lines;
const uint8_t *yend = yin + i_visible_lines * i_pitch;
while( yin < yend )
{
const uint8_t *ylend = yin + i_visible_pitch;
while( yin < ylend )
{
*uout = crop( (*yin * m[3] + (*uin-U) * m[4] + (*vin-V) * m[5])
/ 65536 + U );
uout += 4;
*vout = crop( (*yin * m[6] + (*uin-U) * m[7] + (*vin-V) * m[8])
/ 65536 + V );
vout += 4;
*yout = crop( (*yin * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
/ 65536 );
yin += 2;
yout += 2;
*yout = crop( (*yin * m[0] + (*uin-U) * m[1] + (*vin-V) * m[2])
/ 65536 );
yin += 2;
yout += 2;
uin += 4;
vin += 4;
}
yin += i_pitch - i_visible_pitch;
yout += i_pitch - i_visible_pitch;
uin += i_pitch - i_visible_pitch;
uout += i_pitch - i_visible_pitch;
vin += i_pitch - i_visible_pitch;
vout += i_pitch - i_visible_pitch;
}
}
static void get_red_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, static void get_red_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
int yp, int up, int vp ) int yp, int up, int vp )
{ {
...@@ -699,17 +772,9 @@ static int ExtractCallback( vlc_object_t *p_this, char const *psz_var, ...@@ -699,17 +772,9 @@ static int ExtractCallback( vlc_object_t *p_this, char const *psz_var,
if( !strcmp( psz_var, FILTER_PREFIX "component" ) ) if( !strcmp( psz_var, FILTER_PREFIX "component" ) )
{ {
p_sys->i_color = newval.i_int; p_sys->i_color = newval.i_int;
switch( p_sys->i_color ) /* Matrix won't be used for RED, GREEN or BLUE in planar formats */
{
case RED:
case GREEN:
case BLUE:
break;
default:
make_projection_matrix( (filter_t *)p_this, p_sys->i_color, make_projection_matrix( (filter_t *)p_this, p_sys->i_color,
p_sys->projection_matrix ); p_sys->projection_matrix );
break;
}
} }
else else
{ {
......
/*****************************************************************************
* filter_picture.h: Common picture functions for filters
*****************************************************************************
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
*
* 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
* (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.
*
* 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.
*****************************************************************************/
#define CASE_PACKED_YUV_422 \
case VLC_FOURCC('I','U','Y','V'): \
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'):
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('I','U','Y','V'): /* <-- FIXME: interlaced */
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 */
/* 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'):
/* YUYV */
*i_y_offset = 0;
*i_u_offset = 1;
*i_v_offset = 3;
return VLC_SUCCESS;
case VLC_FOURCC('Y','V','Y','U'):
/* YVYU */
*i_y_offset = 0;
*i_u_offset = 3;
*i_v_offset = 1;
return VLC_SUCCESS;
default:
return VLC_EGENERIC;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment