Commit 44754713 authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/ffmpeg/*: new --ffmpeg-lowres option to force video decoding at a lower resolution.

parent 74392a20
......@@ -5,7 +5,7 @@
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
* Gildas Bazin <gbazin@videolan.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
......
......@@ -306,6 +306,8 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
if( p_enc->fmt_in.i_cat == VIDEO_ES )
{
int i_aspect_num, i_aspect_den;
if( !p_enc->fmt_in.video.i_width || !p_enc->fmt_in.video.i_height )
{
msg_Warn( p_enc, "invalid size %ix%i", p_enc->fmt_in.video.i_width,
......@@ -335,11 +337,14 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context->b_frame_strategy = 0;
#if LIBAVCODEC_BUILD >= 4687
av_reduce( &i_aspect_num, &i_aspect_den,
p_enc->fmt_in.video.i_aspect,
VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
av_reduce( &p_context->sample_aspect_ratio.num,
&p_context->sample_aspect_ratio.den,
p_enc->fmt_in.video.i_aspect *
i_aspect_num *
(int64_t)p_context->height / p_context->width,
VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
i_aspect_den, 1 << 30 /* something big */ );
#else
p_context->aspect_ratio = ((float)p_enc->fmt_in.video.i_aspect) /
VOUT_ASPECT_FACTOR;
......
......@@ -98,6 +98,9 @@ vlc_module_begin();
VLC_FALSE );
add_integer ( "ffmpeg-vismv", 0, NULL, VISMV_TEXT, VISMV_LONGTEXT,
VLC_TRUE );
add_integer ( "ffmpeg-lowres", 0, NULL, LOWRES_TEXT, LOWRES_LONGTEXT,
VLC_TRUE );
change_integer_range( 0, 2 );
#ifdef LIBAVCODEC_PP
add_integer( "ffmpeg-pp-q", 0, NULL, PP_Q_TEXT, PP_Q_LONGTEXT, VLC_FALSE );
......@@ -270,16 +273,6 @@ static void CloseDecoder( vlc_object_t *p_this )
decoder_t *p_dec = (decoder_t *)p_this;
decoder_sys_t *p_sys = p_dec->p_sys;
if( p_sys->p_context )
{
if( p_sys->p_context->extradata )
free( p_sys->p_context->extradata );
avcodec_close( p_sys->p_context );
msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->psz_namecodec );
av_free( p_sys->p_context );
}
switch( p_sys->i_cat )
{
case AUDIO_ES:
......@@ -290,9 +283,19 @@ static void CloseDecoder( vlc_object_t *p_this )
break;
}
if( p_sys->p_context )
{
if( p_sys->p_context->extradata )
free( p_sys->p_context->extradata );
avcodec_close( p_sys->p_context );
msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->psz_namecodec );
av_free( p_sys->p_context );
}
free( p_sys );
}
/*****************************************************************************
* local Functions
*****************************************************************************/
......
......@@ -124,6 +124,10 @@ void E_(ClosePostproc)( decoder_t *, void * );
"2 - visualize forward predicted MVs of B frames\n" \
"4 - visualize backward predicted MVs of B frames" )
#define LOWRES_TEXT N_( "Low resolution decoding" )
#define LOWRES_LONGTEXT N_( "Will only decode a low resolution version of " \
"the video." )
#define LIBAVCODEC_PP_TEXT N_("ffmpeg post processing filter chains")
/* FIXME (cut/past from ffmpeg */
#define LIBAVCODEC_PP_LONGTEXT \
......
......@@ -152,6 +152,11 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
return NULL; /* invalid display size */
}
#if LIBAVCODEC_BUILD >= 4723
p_dec->fmt_out.video.i_width >>= p_context->lowres;
p_dec->fmt_out.video.i_height >>= p_context->lowres;
#endif
if( !p_dec->fmt_out.i_codec )
{
/* we make conversion if possible*/
......@@ -245,6 +250,12 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
if( val.i_int ) p_sys->p_context->debug_mv = val.i_int;
#endif
var_Create( p_dec, "ffmpeg-lowres", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_dec, "ffmpeg-lowres", &val );
#if LIBAVCODEC_BUILD >= 4723
if( val.i_int > 0 && val.i_int <= 2 ) p_sys->p_context->lowres = val.i_int;
#endif
/* ***** ffmpeg frame skipping ***** */
var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Get( p_dec, "ffmpeg-hurry-up", &val );
......
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