Commit 2e2178f7 authored by Antoine Cellerier's avatar Antoine Cellerier

Chroma API change. Chromas are now normal video filters (almost).

parent efc57198
......@@ -221,7 +221,6 @@ typedef struct aout_filter_t aout_filter_t;
/* Video */
typedef struct vout_thread_t vout_thread_t;
typedef struct vout_sys_t vout_sys_t;
typedef struct chroma_sys_t chroma_sys_t;
typedef video_format_t video_frame_format_t;
typedef struct picture_t picture_t;
......
......@@ -28,6 +28,10 @@
#ifndef _VLC_ES_H
#define _VLC_ES_H 1
/* FIXME: i'm not too sure about this include but it fixes compilation of
* video chromas -- dionoea */
#include "vlc_common.h"
/**
* \file
* This file defines the elementary streams format types
......@@ -130,6 +134,9 @@ struct video_format_t
unsigned int i_frame_rate_base; /**< frame rate denominator */
int i_rmask, i_gmask, i_bmask; /**< color masks for RGB chroma */
int i_rrshift, i_lrshift;
int i_rgshift, i_lgshift;
int i_rbshift, i_lbshift;
video_palette_t *p_palette; /**< video palette from demuxer */
};
......
......@@ -60,6 +60,7 @@ struct filter_t
config_chain_t * p_cfg;
picture_t * ( * pf_video_filter ) ( filter_t *, picture_t * );
void ( * pf_video_filter_io ) ( filter_t *, picture_t *, picture_t * ); /* Used by video filters with a preallocated output buffer (ie chroma conversion modules) */
block_t * ( * pf_audio_filter ) ( filter_t *, block_t * );
void ( * pf_video_blend ) ( filter_t *, picture_t *,
picture_t *, picture_t *,
......
......@@ -68,6 +68,7 @@
#define VLC_OBJECT_HTTPD_HOST (-30)
#define VLC_OBJECT_INTERACTION (-32)
#define VLC_OBJECT_CHROMA (-33)
#define VLC_OBJECT_GENERIC (-666)
......
/*****************************************************************************
* vlc_video.h: common video definitions
*****************************************************************************
* Copyright (C) 1999 - 2005 the VideoLAN team
* Copyright (C) 1999 - 2008 the VideoLAN team
* $Id$
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
......@@ -365,31 +365,6 @@ VLC_EXPORT( int, __vout_AllocatePicture,( vlc_object_t *p_this, picture_t *p_pic
* @{
*/
/**
* Chroma conversion function
*
* This is the prototype common to all conversion functions.
* \param p_vout video output thread
* \param p_source source picture
* \param p_dest destination picture
* Picture width and source dimensions must be multiples of 16.
*/
typedef void (vout_chroma_convert_t)( vout_thread_t *,
picture_t *, picture_t * );
typedef struct vout_chroma_t
{
/** conversion functions */
vout_chroma_convert_t *pf_convert;
/** Private module-dependent data */
chroma_sys_t * p_sys; /* private data */
/** Plugin used and shortcuts to access its capabilities */
module_t * p_module;
} vout_chroma_t;
/** Maximum numbers of video filters2 that can be attached to a vout */
#define MAX_VFILTERS 10
......@@ -462,7 +437,7 @@ struct vout_thread_t
picture_heap_t render; /**< rendered pictures */
picture_heap_t output; /**< direct buffers */
bool b_direct; /**< rendered are like direct ? */
vout_chroma_t chroma; /**< translation tables */
filter_t *p_chroma; /**< translation tables */
video_format_t fmt_render; /* render format (from the decoder) */
video_format_t fmt_in; /* input (modified render) format */
......
......@@ -57,7 +57,7 @@ static void ChromaConversion( vout_thread_t *, picture_t *, picture_t * );
* This structure is part of the chroma transformation descriptor, it
* describes the chroma plugin specific properties.
*****************************************************************************/
struct chroma_sys_t
struct filter_sys_t
{
int i_src_vlc_chroma;
int i_src_ffmpeg_chroma;
......@@ -74,50 +74,53 @@ struct chroma_sys_t
*****************************************************************************/
int OpenChroma( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
filter_t *p_filter = (filter_t *)p_this;
int i_ffmpeg_chroma[2], i_vlc_chroma[2], i;
/*
* Check the source chroma first, then the destination chroma
*/
i_vlc_chroma[0] = p_vout->render.i_chroma;
i_vlc_chroma[1] = p_vout->output.i_chroma;
i_vlc_chroma[0] = p_filter->fmt_in.video.i_chroma;
i_vlc_chroma[1] = p_filter->fmt_out.video.i_chroma;
for( i = 0; i < 2; i++ )
{
i_ffmpeg_chroma[i] = GetFfmpegChroma( i_vlc_chroma[i] );
if( i_ffmpeg_chroma[i] < 0 ) return VLC_EGENERIC;
}
p_vout->chroma.pf_convert = ChromaConversion;
p_filter->pf_video_filter_io = ChromaConversion;
p_vout->chroma.p_sys = malloc( sizeof( chroma_sys_t ) );
if( p_vout->chroma.p_sys == NULL )
p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL )
{
return VLC_ENOMEM;
}
p_vout->chroma.p_sys->i_src_vlc_chroma = p_vout->render.i_chroma;
p_vout->chroma.p_sys->i_dst_vlc_chroma = p_vout->output.i_chroma;
p_vout->chroma.p_sys->i_src_ffmpeg_chroma = i_ffmpeg_chroma[0];
p_vout->chroma.p_sys->i_dst_ffmpeg_chroma = i_ffmpeg_chroma[1];
p_filter->.p_sys->i_src_vlc_chroma = p_vout->render.i_chroma;
p_filter->p_sys->i_dst_vlc_chroma = p_vout->output.i_chroma;
p_filter->p_sys->i_src_ffmpeg_chroma = i_ffmpeg_chroma[0];
p_filter->p_sys->i_dst_ffmpeg_chroma = i_ffmpeg_chroma[1];
if( ( p_vout->render.i_height != p_vout->output.i_height ||
p_vout->render.i_width != p_vout->output.i_width ) &&
( p_vout->chroma.p_sys->i_dst_vlc_chroma == VLC_FOURCC('I','4','2','0') ||
p_vout->chroma.p_sys->i_dst_vlc_chroma == VLC_FOURCC('Y','V','1','2') ))
if( ( p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height ||
p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width ) &&
( p_filter->p_sys->i_dst_vlc_chroma == VLC_FOURCC('I','4','2','0') ||
p_filter->p_sys->i_dst_vlc_chroma == VLC_FOURCC('Y','V','1','2') ))
{
msg_Dbg( p_vout, "preparing to resample picture" );
p_vout->chroma.p_sys->p_rsc =
img_resample_init( p_vout->output.i_width, p_vout->output.i_height,
p_vout->render.i_width, p_vout->render.i_height );
avpicture_alloc( &p_vout->chroma.p_sys->tmp_pic,
p_vout->chroma.p_sys->i_dst_ffmpeg_chroma,
p_vout->render.i_width, p_vout->render.i_height );
msg_Dbg( p_filter, "preparing to resample picture" );
p_filter->p_sys->p_rsc =
img_resample_init( p_filter->fmt_out.video.i_width,
p_filter->fmt_out.video.i_height,
p_filter->fmt_in.video.i_width,
p_filter->fmt_in.video.i_height );
avpicture_alloc( &p_filter->p_sys->tmp_pic,
p_filter->p_sys->i_dst_ffmpeg_chroma,
p_filter->fmt_in.video.i_width,
p_filter->fmt_in.video.i_height );
}
else
{
msg_Dbg( p_vout, "no resampling" );
p_vout->chroma.p_sys->p_rsc = NULL;
msg_Dbg( p_filter, "no resampling" );
p_filter->p_sys->p_rsc = NULL;
}
/* libavcodec needs to be initialized for some chroma conversions */
......@@ -129,7 +132,7 @@ int OpenChroma( vlc_object_t *p_this )
/*****************************************************************************
* ChromaConversion: actual chroma conversion function
*****************************************************************************/
static void ChromaConversion( vout_thread_t *p_vout,
static void ChromaConversion( filter_t *p_filter,
picture_t *p_src, picture_t *p_dest )
{
AVPicture src_pic;
......@@ -149,38 +152,40 @@ static void ChromaConversion( vout_thread_t *p_vout,
}
/* Special cases */
if( p_vout->chroma.p_sys->i_src_vlc_chroma == VLC_FOURCC('Y','V','1','2') ||
p_vout->chroma.p_sys->i_src_vlc_chroma == VLC_FOURCC('Y','V','U','9') )
if( p_filter->p_sys->i_src_vlc_chroma == VLC_FOURCC('Y','V','1','2') ||
p_filter->p_sys->i_src_vlc_chroma == VLC_FOURCC('Y','V','U','9') )
{
/* Invert U and V */
src_pic.data[1] = p_src->p[2].p_pixels;
src_pic.data[2] = p_src->p[1].p_pixels;
}
if( p_vout->chroma.p_sys->i_dst_vlc_chroma == VLC_FOURCC('Y','V','1','2') ||
p_vout->chroma.p_sys->i_dst_vlc_chroma == VLC_FOURCC('Y','V','U','9') )
if( p_filter->p_sys->i_dst_vlc_chroma == VLC_FOURCC('Y','V','1','2') ||
p_filter->p_sys->i_dst_vlc_chroma == VLC_FOURCC('Y','V','U','9') )
{
/* Invert U and V */
dest_pic.data[1] = p_dest->p[2].p_pixels;
dest_pic.data[2] = p_dest->p[1].p_pixels;
}
if( p_vout->chroma.p_sys->i_src_ffmpeg_chroma == PIX_FMT_RGB24 )
if( p_vout->render.i_bmask == 0x00ff0000 )
p_vout->chroma.p_sys->i_src_ffmpeg_chroma = PIX_FMT_BGR24;
if( p_filter->p_sys->i_src_ffmpeg_chroma == PIX_FMT_RGB24 )
if( p_filter->fmt_in.video.i_bmask == 0x00ff0000 )
p_filter->p_sys->i_src_ffmpeg_chroma = PIX_FMT_BGR24;
if( p_vout->chroma.p_sys->p_rsc )
if( p_filter->p_sys->p_rsc )
{
img_convert( &p_vout->chroma.p_sys->tmp_pic,
p_vout->chroma.p_sys->i_dst_ffmpeg_chroma,
&src_pic, p_vout->chroma.p_sys->i_src_ffmpeg_chroma,
p_vout->render.i_width, p_vout->render.i_height );
img_resample( p_vout->chroma.p_sys->p_rsc, &dest_pic,
&p_vout->chroma.p_sys->tmp_pic );
img_convert( &p_filter->p_sys->tmp_pic,
p_filter->p_sys->i_dst_ffmpeg_chroma,
&src_pic, p_filter->p_sys->i_src_ffmpeg_chroma,
p_filter->fmt_in.video.i_width,
p_filter->fmt_in.video.i_height );
img_resample( p_filter->p_sys->p_rsc, &dest_pic,
&p_filter->p_sys->tmp_pic );
}
else
{
img_convert( &dest_pic, p_vout->chroma.p_sys->i_dst_ffmpeg_chroma,
&src_pic, p_vout->chroma.p_sys->i_src_ffmpeg_chroma,
p_vout->render.i_width, p_vout->render.i_height );
img_convert( &dest_pic, p_filter->p_sys->i_dst_ffmpeg_chroma,
&src_pic, p_filter->p_sys->i_src_ffmpeg_chroma,
p_filter->fmt_in.video.i_width,
p_filter->fmt_in.video.i_height );
}
}
......@@ -191,176 +196,12 @@ static void ChromaConversion( vout_thread_t *p_vout,
*****************************************************************************/
void CloseChroma( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
if( p_vout->chroma.p_sys->p_rsc )
filter_t *p_filter = (filter_t *)p_this;
if( p_filter->p_sys->p_rsc )
{
img_resample_close( p_vout->chroma.p_sys->p_rsc );
avpicture_free( &p_vout->chroma.p_sys->tmp_pic );
img_resample_close( p_filter->p_sys->p_rsc );
avpicture_free( &p_filter->p_sys->tmp_pic );
}
free( p_vout->chroma.p_sys );
free( p_filter->p_sys );
}
#else
static void ChromaConversion( vout_thread_t *, picture_t *, picture_t * );
/*****************************************************************************
* chroma_sys_t: chroma method descriptor
*****************************************************************************
* This structure is part of the chroma transformation descriptor, it
* describes the chroma plugin specific properties.
*****************************************************************************/
struct chroma_sys_t
{
filter_t *p_swscaler;
};
/*****************************************************************************
* Video Filter2 functions
*****************************************************************************/
struct filter_owner_sys_t
{
vout_thread_t *p_vout;
};
static void PictureRelease( picture_t *p_pic )
{
free( p_pic->p_data_orig );
}
static picture_t *video_new_buffer_filter( filter_t *p_filter )
{
picture_t *p_picture = malloc( sizeof(picture_t) );
if( !p_picture ) return NULL;
if( vout_AllocatePicture( p_filter, p_picture,
p_filter->fmt_out.video.i_chroma,
p_filter->fmt_out.video.i_width,
p_filter->fmt_out.video.i_height,
p_filter->fmt_out.video.i_aspect )
!= VLC_SUCCESS )
{
free( p_picture );
return NULL;
}
p_picture->pf_release = PictureRelease;
return p_picture;
}
static void video_del_buffer_filter( filter_t *p_filter, picture_t *p_pic )
{
VLC_UNUSED(p_filter);
if( p_pic )
{
free( p_pic->p_data_orig );
free( p_pic );
}
}
/*****************************************************************************
* OpenChroma: allocate a chroma function
*****************************************************************************
* This function allocates and initializes a chroma function
*****************************************************************************/
int OpenChroma( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
chroma_sys_t *p_sys = p_vout->chroma.p_sys;
p_vout->chroma.p_sys = p_sys = malloc( sizeof( chroma_sys_t ) );
if( p_vout->chroma.p_sys == NULL )
{
return VLC_ENOMEM;
}
p_vout->chroma.pf_convert = ChromaConversion;
p_sys->p_swscaler = vlc_object_create( p_vout, VLC_OBJECT_FILTER );
vlc_object_attach( p_sys->p_swscaler, p_vout );
p_sys->p_swscaler->pf_vout_buffer_new = video_new_buffer_filter;
p_sys->p_swscaler->pf_vout_buffer_del = video_del_buffer_filter;
p_sys->p_swscaler->fmt_out.video.i_x_offset =
p_sys->p_swscaler->fmt_out.video.i_y_offset = 0;
p_sys->p_swscaler->fmt_in.video = p_vout->fmt_in;
p_sys->p_swscaler->fmt_out.video = p_vout->fmt_out;
p_sys->p_swscaler->fmt_out.video.i_aspect = p_vout->render.i_aspect;
p_sys->p_swscaler->fmt_in.video.i_chroma = p_vout->render.i_chroma;
p_sys->p_swscaler->fmt_out.video.i_chroma = p_vout->output.i_chroma;
p_sys->p_swscaler->p_module = module_Need( p_sys->p_swscaler,
"video filter2", 0, 0 );
if( p_sys->p_swscaler->p_module )
{
p_sys->p_swscaler->p_owner =
malloc( sizeof( filter_owner_sys_t ) );
if( p_sys->p_swscaler->p_owner )
p_sys->p_swscaler->p_owner->p_vout = p_vout;
}
if( !p_sys->p_swscaler->p_module || !p_sys->p_swscaler->p_owner )
{
vlc_object_detach( p_sys->p_swscaler );
vlc_object_release( p_sys->p_swscaler );
free( p_vout->chroma.p_sys );
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
/*****************************************************************************
* ChromaConversion: actual chroma conversion function
*****************************************************************************/
static void ChromaConversion( vout_thread_t *p_vout,
picture_t *p_src, picture_t *p_dest )
{
chroma_sys_t *p_sys = (chroma_sys_t *) p_vout->chroma.p_sys;
if( p_sys && p_src && p_dest &&
p_sys->p_swscaler && p_sys->p_swscaler->p_module )
{
picture_t *p_pic;
p_sys->p_swscaler->fmt_in.video = p_vout->fmt_in;
p_sys->p_swscaler->fmt_out.video = p_vout->fmt_out;
#if 0
msg_Dbg( p_vout, "chroma %4.4s (%d) to %4.4s (%d)",
(char *)&p_vout->fmt_in.i_chroma, p_src->i_planes,
(char *)&p_vout->fmt_out.i_chroma, p_dest->i_planes );
#endif
p_pic = p_sys->p_swscaler->pf_vout_buffer_new( p_sys->p_swscaler );
if( p_pic )
{
picture_t *p_dst_pic;
vout_CopyPicture( p_vout, p_pic, p_src );
p_dst_pic = p_sys->p_swscaler->pf_video_filter( p_sys->p_swscaler, p_pic );
vout_CopyPicture( p_vout, p_dest, p_dst_pic );
p_dst_pic->pf_release( p_dst_pic );
}
}
}
/*****************************************************************************
* CloseChroma: free the chroma function
*****************************************************************************
* This function frees the previously allocated chroma function
*****************************************************************************/
void CloseChroma( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
chroma_sys_t *p_sys = (chroma_sys_t *)p_vout->chroma.p_sys;
if( p_sys->p_swscaler && p_sys->p_swscaler->p_module )
{
free( p_sys->p_swscaler->p_owner );
module_Unneed( p_sys->p_swscaler, p_sys->p_swscaler->p_module );
vlc_object_detach( p_sys->p_swscaler );
vlc_object_release( p_sys->p_swscaler );
p_sys->p_swscaler= NULL;
}
free( p_vout->chroma.p_sys );
}
#endif /* !defined(HAVE_LIBSWSCALE_SWSCALE_H) && !defined(HAVE_FFMPEG_SWSCALE_H) */
......@@ -252,13 +252,13 @@ vlc_module_begin();
set_capability( "crop padd", 10 );
set_callbacks( OpenCropPadd, CloseFilter );
set_description( N_("FFmpeg crop padd filter") );
#endif
/* chroma conversion submodule */
add_submodule();
set_capability( "chroma", 50 );
set_callbacks( OpenChroma, CloseChroma );
set_description( N_("FFmpeg chroma conversion") );
#endif
/* video filter submodule */
add_submodule();
......
/*****************************************************************************
* chain.c : chain multiple chroma modules as a last resort solution
*****************************************************************************
* Copyright (C) 2007 the VideoLAN team
* Copyright (C) 2007-2008 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
......@@ -31,6 +31,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
#include <vlc_vout.h>
/*****************************************************************************
......@@ -38,7 +39,7 @@
*****************************************************************************/
static int Activate ( vlc_object_t * );
static void Destroy ( vlc_object_t * );
static void Chain ( vout_thread_t *, picture_t *, picture_t * );
static void Chain ( filter_t *, picture_t *, picture_t * );
/*****************************************************************************
* Module descriptor
......@@ -51,19 +52,21 @@ vlc_module_end();
#define MAX_CHROMAS 2
struct chroma_sys_t
struct filter_sys_t
{
vlc_fourcc_t i_chroma;
vout_chroma_t chroma1;
vout_chroma_t chroma2;
filter_t *p_chroma1;
filter_t *p_chroma2;
picture_t *p_tmp;
picture_t *p_tmp;
};
static const vlc_fourcc_t pi_allowed_chromas[] = {
VLC_FOURCC('I','4','2','0'),
VLC_FOURCC('I','4','2','2'),
VLC_FOURCC('R','V','3','2'),
VLC_FOURCC('R','V','2','4'),
0
};
......@@ -74,8 +77,9 @@ static const vlc_fourcc_t pi_allowed_chromas[] = {
*****************************************************************************/
static int Activate( vlc_object_t *p_this )
{
#if 0
static int hack = 1;
vout_thread_t *p_vout = (vout_thread_t *)p_this;
filter_t *p_filter = (filter_t *)p_this;
hack++;
if( hack > MAX_CHROMAS )
......@@ -86,25 +90,25 @@ static int Activate( vlc_object_t *p_this )
return VLC_EGENERIC;
}
chroma_sys_t *p_sys = (chroma_sys_t *)malloc( sizeof( chroma_sys_t ) );
filter_sys_t *p_sys = (filter_sys_t *)malloc( sizeof( filter_sys_t ) );
if( !p_sys )
{
hack--;
return VLC_ENOMEM;
}
memset( p_sys, 0, sizeof( chroma_sys_t ) );
memset( p_sys, 0, sizeof( filter_sys_t ) );
int i;
vlc_fourcc_t i_output_chroma = p_vout->output.i_chroma;
vlc_fourcc_t i_render_chroma = p_vout->render.i_chroma;
vlc_fourcc_t i_output_chroma = p_filter->fmt_in.video.i_chroma;
vlc_fourcc_t i_render_chroma = p_filter->fmt_out.video.i_chroma;
for( i = 0; pi_allowed_chromas[i]; i++ )
{
msg_Warn( p_vout, "Trying %4s as a chroma chain",
msg_Warn( p_filter, "Trying %4s as a chroma chain",
(const char *)&pi_allowed_chromas[i] );
p_vout->output.i_chroma = pi_allowed_chromas[i];
p_vout->chroma.p_module = module_Need( p_vout, "chroma", NULL, 0 );
p_vout->output.i_chroma = i_output_chroma;
p_filter->output.i_chroma = pi_allowed_chromas[i];
p_filter->p_chroma1.p_module = module_Need( p_vout, "chroma", NULL, 0 );
p_filter->output.i_chroma = i_output_chroma;
if( !p_vout->chroma.p_module )
continue;
......@@ -136,15 +140,16 @@ static int Activate( vlc_object_t *p_this )
free( p_sys );
hack--;
#endif
return VLC_EGENERIC;
}
static void Destroy( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
#if 0
filter_t *p_filter = (filter_t *)p_this;
vout_chroma_t chroma = p_vout->chroma;
p_vout->chroma = chroma.p_sys->chroma1;
module_Unneed( p_vout, p_vout->chroma.p_module );
p_vout->chroma = chroma.p_sys->chroma2;
......@@ -158,14 +163,16 @@ static void Destroy( vlc_object_t *p_this )
}
free( chroma.p_sys );
chroma.p_sys = NULL;
#endif
}
/*****************************************************************************
* Chain
*****************************************************************************/
static void Chain( vout_thread_t *p_vout, picture_t *p_source,
static void Chain( filter_t *p_filter, picture_t *p_source,
picture_t *p_dest )
{
#if 0
chroma_sys_t *p_sys = p_vout->chroma.p_sys;
if( !p_sys->p_tmp )
......@@ -190,4 +197,5 @@ static void Chain( vout_thread_t *p_vout, picture_t *p_source,
p_vout->chroma = p_sys->chroma2;
p_sys->chroma2.pf_convert( p_vout, p_sys->p_tmp, p_dest );
p_vout->chroma = chroma;
#endif
}
/*****************************************************************************
* grey_yuv.c : grayscale to others conversion module for vlc
*****************************************************************************
* Copyright (C) 2007 the VideoLAN team
* Copyright (C) 2007, 2008 the VideoLAN team
* $Id$
*
* Authors: Sam Hocevar <sam@zoy.org>
......@@ -31,6 +31,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
#include <vlc_vout.h>
#define SRC_FOURCC "GREY"
......@@ -41,8 +42,8 @@
*****************************************************************************/
static int Activate ( vlc_object_t * );
static void GREY_I420 ( vout_thread_t *, picture_t *, picture_t * );
static void GREY_YUY2 ( vout_thread_t *, picture_t *, picture_t * );
static void GREY_I420( filter_t *, picture_t *, picture_t * );
static void GREY_YUY2( filter_t *, picture_t *, picture_t * );
/*****************************************************************************
* Module descriptor.
......@@ -60,25 +61,26 @@ vlc_module_end();
*****************************************************************************/
static int Activate( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
filter_t *p_filter = (filter_t *)p_this;
if( p_vout->render.i_width & 1 || p_vout->render.i_height & 1 )
if( p_filter->fmt_out.video.i_width & 1
|| p_filter->fmt_out.video.i_height & 1 )
{
return -1;
}
switch( p_vout->render.i_chroma )
switch( p_filter->fmt_in.video.i_chroma )
{
case VLC_FOURCC('Y','8','0','0'):
p_vout->render.i_chroma = VLC_FOURCC('G','R','E','Y');
p_filter->fmt_in.video.i_chroma = VLC_FOURCC('G','R','E','Y');
case VLC_FOURCC('G','R','E','Y'):
switch( p_vout->output.i_chroma )
switch( p_filter->fmt_out.video.i_chroma )
{
case VLC_FOURCC('I','4','2','0'):
p_vout->chroma.pf_convert = GREY_I420;
p_filter->pf_video_filter_io = GREY_I420;
break;
case VLC_FOURCC('Y','U','Y','2'):
p_vout->chroma.pf_convert = GREY_YUY2;
p_filter->pf_video_filter_io = GREY_YUY2;
break;
default:
return -1;
......@@ -97,8 +99,8 @@ static int Activate( vlc_object_t *p_this )
/*****************************************************************************
* GREY_I420: 8-bit grayscale to planar YUV 4:2:0
*****************************************************************************/
static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
picture_t *p_dest )
static void GREY_I420( filter_t *p_filter, picture_t *p_source,
picture_t *p_dest )
{
uint8_t *p_line = p_source->p->p_pixels;
uint8_t *p_y = p_dest->Y_PIXELS;
......@@ -114,7 +116,7 @@ static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
const int i_dest_margin_c = p_dest->p[1].i_pitch
- p_dest->p[1].i_visible_pitch;
for( i_y = p_vout->render.i_height / 2; i_y-- ; )
for( i_y = p_filter->fmt_in.video.i_height / 2; i_y-- ; )
{
memset(p_u, 0x80, p_dest->p[1].i_visible_pitch);
p_u += i_dest_margin_c;
......@@ -123,9 +125,9 @@ static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
p_v += i_dest_margin_c;
}
for( i_y = p_vout->render.i_height; i_y-- ; )
for( i_y = p_filter->fmt_in.video.i_height; i_y-- ; )
{
for( i_x = p_vout->render.i_width / 8; i_x-- ; )
for( i_x = p_filter->fmt_in.video.i_width / 8; i_x-- ; )
{
*p_y++ = *p_line++; *p_y++ = *p_line++;
*p_y++ = *p_line++; *p_y++ = *p_line++;
......@@ -133,7 +135,7 @@ static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
*p_y++ = *p_line++; *p_y++ = *p_line++;
}
for( i_x = p_vout->render.i_width % 8; i_x-- ; )
for( i_x = p_filter->fmt_in.video.i_width % 8; i_x-- ; )
{
*p_y++ = *p_line++;
}
......@@ -146,8 +148,8 @@ static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
/*****************************************************************************
* GREY_YUY2: 8-bit grayscale to packed YUY2
*****************************************************************************/
static void GREY_YUY2( vout_thread_t *p_vout, picture_t *p_source,
picture_t *p_dest )
static void GREY_YUY2( filter_t *p_filter, picture_t *p_source,
picture_t *p_dest )
{
uint8_t *p_in = p_source->p->p_pixels;
uint8_t *p_out = p_dest->p->p_pixels;
......@@ -159,9 +161,9 @@ static void GREY_YUY2( vout_thread_t *p_vout, picture_t *p_source,
const int i_dest_margin = p_dest->p->i_pitch
- p_dest->p->i_visible_pitch;
for( i_y = p_vout->render.i_height; i_y-- ; )
for( i_y = p_filter->fmt_out.video.i_height; i_y-- ; )
{
for( i_x = p_vout->render.i_width / 8; i_x-- ; )
for( i_x = p_filter->fmt_out.video.i_width / 8; i_x-- ; )
{
*p_out++ = *p_in++; *p_out++ = 0x80;
*p_out++ = *p_in++; *p_out++ = 0x80;
......@@ -173,7 +175,7 @@ static void GREY_YUY2( vout_thread_t *p_vout, picture_t *p_source,
*p_out++ = *p_in++; *p_out++ = 0x80;
}
for( i_x = (p_vout->render.i_width % 8) / 2; i_x-- ; )
for( i_x = (p_filter->fmt_out.video.i_width % 8) / 2; i_x-- ; )
{
*p_out++ = *p_in++; *p_out++ = 0x80;
*p_out++ = *p_in++; *p_out++ = 0x80;
......