Commit cc872f33 authored by Antoine Cellerier's avatar Antoine Cellerier

Revive postprocessing. It is now a video filter (the interface code

needs to be changed accordingly). It "works" but I can't spot any
difference between postproc-q 6 and postproc-q 0 using the
redefined-nintendo.mpg test video ... I'd appreciate feedback on that
point.
parent 13d659d2
......@@ -49,22 +49,17 @@ SOURCES_imgresample = \
chroma.h \
$(NULL)
SOURCES_postproc = \
$(NULL)
libvlc_LTLIBRARIES += \
$(LTLIBavcodec) \
$(LTLIBavformat) \
$(LTLIBswscale) \
$(LTLIBimgresample) \
$(LTLIBpostproc)
$(LTLIBimgresample)
EXTRA_LTLIBRARIES += \
libavcodec_plugin.la \
libavformat_plugin.la \
libswscale_plugin.la \
libimgresample_plugin.la \
libpostproc_plugin.la
libimgresample_plugin.la
# FIXME SOURCES_ffmpegaltivec = \
# FIXME ffmpeg.c \
......
......@@ -125,9 +125,6 @@ vlc_module_begin();
SKIPLOOPF_LONGTEXT, true );
change_integer_list( nloopf_list, nloopf_list_text, 0 );
add_integer( "ffmpeg-pp-q", 0, NULL, PP_Q_TEXT, PP_Q_LONGTEXT, false );
add_string( "ffmpeg-pp-name", "default", NULL, LIBAVCODEC_PP_TEXT,
LIBAVCODEC_PP_LONGTEXT, true );
add_integer( "ffmpeg-debug", 0, NULL, DEBUG_TEXT, DEBUG_LONGTEXT,
true );
......
......@@ -91,12 +91,6 @@ void EndAudioDec( decoder_t *p_dec );
"Force skipping of idct to speed up decoding for frame types" \
"(-1=None, 0=Default, 1=B-frames, 2=P-frames, 3=B+P frames, 4=all frames)." )
#define PP_Q_TEXT N_("Post processing quality")
#define PP_Q_LONGTEXT N_( \
"Quality of post processing. Valid range is 0 to 6\n" \
"Higher levels require considerable more CPU power, but produce " \
"better looking pictures." )
#define DEBUG_TEXT N_( "Debug mask" )
#define DEBUG_LONGTEXT N_( "Set ffmpeg debug mask" )
......@@ -119,43 +113,6 @@ void EndAudioDec( decoder_t *p_dec );
"usually has a detrimental effect on quality. However it provides a big " \
"speedup for high definition streams." )
#define LIBAVCODEC_PP_TEXT N_("FFmpeg post processing filter chains")
/* FIXME (cut/past from ffmpeg */
#define LIBAVCODEC_PP_LONGTEXT \
N_("<filterName>[:<option>[:<option>...]][[,|/][-]<filterName>[:<option>...]]...\n" \
"long form example:\n" \
"vdeblock:autoq/hdeblock:autoq/linblenddeint default,-vdeblock\n" \
"short form example:\n" \
"vb:a/hb:a/lb de,-vb\n" \
"more examples:\n" \
"tn:64:128:256\n" \
"Filters Options\n" \
"short long name short long option Description\n" \
"* * a autoq cpu power dependent enabler\n" \
" c chrom chrominance filtring enabled\n" \
" y nochrom chrominance filtring disabled\n" \
"hb hdeblock (2 Threshold) horizontal deblocking filter\n" \
" 1. difference factor: default=64, higher -> more deblocking\n" \
" 2. flatness threshold: default=40, lower -> more deblocking\n" \
" the h & v deblocking filters share these\n" \
" so u cant set different thresholds for h / v\n" \
"vb vdeblock (2 Threshold) vertical deblocking filter\n" \
"h1 x1hdeblock Experimental h deblock filter 1\n" \
"v1 x1vdeblock Experimental v deblock filter 1\n" \
"dr dering Deringing filter\n" \
"al autolevels automatic brightness / contrast\n" \
" f fullyrange stretch luminance to (0..255)\n" \
"lb linblenddeint linear blend deinterlacer\n" \
"li linipoldeint linear interpolating deinterlace\n" \
"ci cubicipoldeint cubic interpolating deinterlacer\n" \
"md mediandeint median deinterlacer\n" \
"fd ffmpegdeint ffmpeg deinterlacer\n" \
"de default hb:a,vb:a,dr:a,al\n" \
"fa fast h1:a,v1:a,dr:a,al\n" \
"tn tmpnoise (3 Thresholds) Temporal Noise Reducer\n" \
" 1. <= 2. <= 3. larger -> stronger filtering\n" \
"fq forceQuant <quantizer> Force quantizer\n")
/*
* Encoder options
*/
......
/*****************************************************************************
* postprocess.c: video postprocessing using the ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 the VideoLAN team
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_vout.h>
#include <vlc_codec.h>
/* ffmpeg header */
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
# include <libavcodec/avcodec.h>
#elif defined(HAVE_FFMPEG_AVCODEC_H)
# include <ffmpeg/avcodec.h>
#else
# include <avcodec.h>
#endif
#ifdef HAVE_POSTPROC_POSTPROCESS_H
# include <postproc/postprocess.h>
#else
# include <libpostproc/postprocess.h>
#endif
#ifndef PP_CPU_CAPS_ALTIVEC
# define PP_CPU_CAPS_ALTIVEC 0
#endif
/*****************************************************************************
* video_postproc_sys_t : ffmpeg video postprocessing descriptor
*****************************************************************************/
typedef struct video_postproc_sys_t
{
pp_context_t *pp_context;
pp_mode_t *pp_mode;
bool *pb_pp;
int i_width;
int i_height;
} video_postproc_sys_t;
static int PPQCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data );
/*****************************************************************************
* OpenPostproc: probe and open the postproc
*****************************************************************************/
void *OpenPostproc( decoder_t *p_dec, bool *pb_pp )
{
video_postproc_sys_t *p_sys;
vlc_value_t val, val_orig, text;
p_sys = malloc( sizeof(video_postproc_sys_t) );
p_sys->pp_context = NULL;
p_sys->pp_mode = NULL;
*pb_pp = false;
p_sys->pb_pp = pb_pp;
/* Create object variable if not already done */
if( var_Type( p_dec, "ffmpeg-pp-q" ) == 0 )
{
var_Create( p_dec, "ffmpeg-pp-q",
VLC_VAR_INTEGER | VLC_VAR_HASCHOICE | VLC_VAR_DOINHERIT );
text.psz_string = _("Post processing");
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_SETTEXT, &text, NULL );
var_Get( p_dec, "ffmpeg-pp-q", &val_orig );
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_DELCHOICE, &val_orig, NULL );
val.i_int = 0; text.psz_string = _("Disable");
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = 1; text.psz_string = _("1 (Lowest)");
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = 2;
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_ADDCHOICE, &val, NULL );
val.i_int = 3;
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_ADDCHOICE, &val, NULL );
val.i_int = 4;
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_ADDCHOICE, &val, NULL );
val.i_int = 5;
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_ADDCHOICE, &val, NULL );
val.i_int = 6; text.psz_string = _("6 (Highest)");
var_Change( p_dec, "ffmpeg-pp-q", VLC_VAR_ADDCHOICE, &val, &text );
var_AddCallback( p_dec, "ffmpeg-pp-q", PPQCallback, p_sys );
}
/* ***** Load post processing if enabled ***** */
var_Get( p_dec, "ffmpeg-pp-q", &val );
var_Set( p_dec, "ffmpeg-pp-q", val_orig );
if( val_orig.i_int )
*pb_pp = true;
return p_sys;
}
/*****************************************************************************
* InitPostproc:
*****************************************************************************/
int InitPostproc( void *p_data, int i_width, int i_height, int pix_fmt )
{
video_postproc_sys_t *p_sys = (video_postproc_sys_t *)p_data;
unsigned i_cpu = vlc_CPU();
int i_flags = 0;
/* Set CPU capabilities */
if( i_cpu & CPU_CAPABILITY_MMX )
{
i_flags |= PP_CPU_CAPS_MMX;
}
if( i_cpu & CPU_CAPABILITY_MMXEXT )
{
i_flags |= PP_CPU_CAPS_MMX2;
}
if( i_cpu & CPU_CAPABILITY_3DNOW )
{
i_flags |= PP_CPU_CAPS_3DNOW;
}
if( i_cpu & CPU_CAPABILITY_ALTIVEC )
{
i_flags |= PP_CPU_CAPS_ALTIVEC;
}
switch( pix_fmt )
{
case PIX_FMT_YUV444P:
i_flags |= PP_FORMAT_444;
break;
case PIX_FMT_YUV422P:
i_flags |= PP_FORMAT_422;
break;
case PIX_FMT_YUV411P:
i_flags |= PP_FORMAT_411;
break;
default:
i_flags |= PP_FORMAT_420;
break;
}
p_sys->pp_context = pp_get_context( i_width, i_height, i_flags );
p_sys->i_width = i_width;
p_sys->i_height = i_height;
return VLC_SUCCESS;
}
/*****************************************************************************
* PostprocPict:
*****************************************************************************/
int PostprocPict( void *p_data, picture_t *p_pic, AVFrame *p_ff_pic )
{
video_postproc_sys_t *p_sys = (video_postproc_sys_t *)p_data;
uint8_t *src[3], *dst[3];
int i_plane, i_src_stride[3], i_dst_stride[3];
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{
src[i_plane] = p_ff_pic->data[i_plane];
dst[i_plane] = p_pic->p[i_plane].p_pixels;
i_src_stride[i_plane] = p_ff_pic->linesize[i_plane];
i_dst_stride[i_plane] = p_pic->p[i_plane].i_pitch;
}
pp_postprocess( src, i_src_stride, dst, i_dst_stride,
p_sys->i_width, p_sys->i_height,
p_ff_pic->qscale_table, p_ff_pic->qstride,
p_sys->pp_mode, p_sys->pp_context,
p_ff_pic->pict_type );
return VLC_SUCCESS;
}
/*****************************************************************************
* ClosePostproc:
*****************************************************************************/
void ClosePostproc( decoder_t *p_dec, void *p_data )
{
video_postproc_sys_t *p_sys = (video_postproc_sys_t *)p_data;
if( p_sys && p_sys->pp_mode )
{
pp_free_mode( p_sys->pp_mode );
if( p_sys->pp_context ) pp_free_context( p_sys->pp_context );
}
var_DelCallback( p_dec, "ffmpeg-pp-q", PPQCallback, p_sys );
free( p_sys );
}
/*****************************************************************************
* object variables callbacks: a bunch of object variables are used by the
* interfaces to interact with the decoder.
*****************************************************************************/
static int PPQCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
decoder_t *p_dec = (decoder_t *)p_this;
video_postproc_sys_t *p_sys = (video_postproc_sys_t *)p_data;
if( newval.i_int > 0 )
{
int i_quality = newval.i_int;
char *psz_name = config_GetPsz( p_dec, "ffmpeg-pp-name" );
pp_mode_t *pp_mode;
if( !psz_name )
{
psz_name = strdup( "default" );
}
else if( *psz_name == '\0' )
{
free( psz_name );
psz_name = strdup( "default" );
}
pp_mode = pp_get_mode_by_name_and_quality( psz_name, i_quality );
if( !pp_mode )
{
msg_Err( p_dec, "failed getting mode for postproc" );
newval.i_int = 0;
}
else
{
msg_Dbg( p_dec, "postprocessing enabled" );
}
free( psz_name );
p_sys->pp_mode = pp_mode;
}
else
{
msg_Dbg( p_dec, "postprocessing disabled" );
}
*p_sys->pb_pp = newval.i_int;
return VLC_SUCCESS;
}
......@@ -40,4 +40,5 @@ SOURCES_seamcarving = seamcarving.c
SOURCES_croppadd = croppadd.c
SOURCES_blendbench = blendbench.c
SOURCES_chain = chain.c
SOURCES_postproc = postproc.c
noinst_HEADERS = filter_common.h filter_picture.h
This diff is collapsed.
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