Commit 54e5b4ce authored by Laurent Aimar's avatar Laurent Aimar

* all : try to add an option to allow frame droppping (

--enable-hurry-up ). Begin to work.
parent 9697b479
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library * ffmpeg.c: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.17 2002/07/20 18:53:33 fenrir Exp $ * $Id: ffmpeg.c,v 1.18 2002/07/21 15:07:39 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -80,7 +80,7 @@ void _M( vdec_getfunctions )( function_list_t * p_function_list ) ...@@ -80,7 +80,7 @@ void _M( vdec_getfunctions )( function_list_t * p_function_list )
#define HURRY_UP_LONGTEXT \ #define HURRY_UP_LONGTEXT \
"Allow the decoder to partially decode or skip frame(s) " \ "Allow the decoder to partially decode or skip frame(s) " \
"when there not enough time.\n It's usefull with low CPU power " \ "when there not enough time.\n It's usefull with low CPU power " \
"but it could produce broken pictures (not yet implemented)" "but it could produce broken pictures."
MODULE_CONFIG_START MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL ) ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
...@@ -90,14 +90,12 @@ ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL ) ...@@ -90,14 +90,12 @@ ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_INTEGER ( "ffmpeg-workaround-bugs", 0, NULL, ADD_INTEGER ( "ffmpeg-workaround-bugs", 0, NULL,
"workaround bugs", "0-99, seems to be for msmpeg v3\n" ) "workaround bugs", "0-99, seems to be for msmpeg v3\n" )
#endif #endif
#if LIBAVCODEC_BUILD > 4603
ADD_BOOL( "ffmpeg-hurry-up", 0, NULL, "hurry up", HURRY_UP_LONGTEXT ) ADD_BOOL( "ffmpeg-hurry-up", 0, NULL, "hurry up", HURRY_UP_LONGTEXT )
#endif
MODULE_CONFIG_STOP MODULE_CONFIG_STOP
MODULE_INIT_START MODULE_INIT_START
SET_DESCRIPTION( "ffmpeg video decoder(MS-MPEG4,MPEG4,SVQ1,H263,H263.I)" ) SET_DESCRIPTION( "ffmpeg video decoder((MS)MPEG4,SVQ1,H263)" )
ADD_CAPABILITY( DECODER, 70 ) ADD_CAPABILITY( DECODER, 70 )
MODULE_INIT_STOP MODULE_INIT_STOP
...@@ -768,6 +766,7 @@ static int InitThread( videodec_thread_t *p_vdec ) ...@@ -768,6 +766,7 @@ static int InitThread( videodec_thread_t *p_vdec )
static void DecodeThread( videodec_thread_t *p_vdec ) static void DecodeThread( videodec_thread_t *p_vdec )
{ {
int i_status; int i_status;
int b_drawpicture;
int b_gotpicture; int b_gotpicture;
AVPicture avpicture; /* ffmpeg picture */ AVPicture avpicture; /* ffmpeg picture */
picture_t *p_pic; /* videolan picture */ picture_t *p_pic; /* videolan picture */
...@@ -775,6 +774,48 @@ static void DecodeThread( videodec_thread_t *p_vdec ) ...@@ -775,6 +774,48 @@ static void DecodeThread( videodec_thread_t *p_vdec )
give it to ffmpeg decoder give it to ffmpeg decoder
and send the image to the output */ and send the image to the output */
/* TODO implement it in a better way */
if( ( config_GetInt(p_vdec->p_fifo, "ffmpeg-hurry-up") )&&
( p_vdec->i_frame_late > 4 ) )
{
#if LIBAVCODEC_BUILD > 4603
b_drawpicture = 0;
if( p_vdec->i_frame_late < 8 )
{
p_vdec->p_context->hurry_up = 2;
}
else
{
/* too much late picture, won't decode
but break picture until a new I, and for mpeg4 ...*/
p_vdec->i_frame_late--; /* needed else it will never be decrease */
__PES_NEXT( p_vdec->p_fifo );
return;
}
#else
if( p_vdec->i_frame_late < 8 )
{
b_drawpicture = 0; /* not really good but .. */
}
else
{
/* too much late picture, won't decode
but break picture until a new I, and for mpeg4 ...*/
p_vdec->i_frame_late--; /* needed else it will never be decrease */
__PES_NEXT( p_vdec->p_fifo );
return;
}
#endif
}
else
{
b_drawpicture = 1;
#if LIBAVCODEC_BUILD > 4603
p_vdec->p_context->hurry_up = 0;
#endif
}
__GetFrame( p_vdec ); __GetFrame( p_vdec );
i_status = avcodec_decode_video( p_vdec->p_context, i_status = avcodec_decode_video( p_vdec->p_context,
...@@ -792,10 +833,22 @@ static void DecodeThread( videodec_thread_t *p_vdec ) ...@@ -792,10 +833,22 @@ static void DecodeThread( videodec_thread_t *p_vdec )
p_vdec->i_frame_error++; p_vdec->i_frame_error++;
return; return;
} }
if( !b_gotpicture || avpicture.linesize[0] == 0 ) /* Update frame late count*/
/* I don't make statistic on decoding time */
if( p_vdec->i_pts <= mdate())
{
p_vdec->i_frame_late++;
}
else
{
p_vdec->i_frame_late = 0;
}
if( !b_gotpicture || avpicture.linesize[0] == 0 || !b_drawpicture)
{ {
return; return;
} }
/* Check our vout */ /* Check our vout */
if( !ffmpeg_CheckVout( p_vdec->p_vout, if( !ffmpeg_CheckVout( p_vdec->p_vout,
p_vdec->p_context->width, p_vdec->p_context->width,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg_vdec.h: video decoder using ffmpeg library * ffmpeg_vdec.h: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: ffmpeg.h,v 1.5 2002/07/20 18:53:33 fenrir Exp $ * $Id: ffmpeg.h,v 1.6 2002/07/21 15:07:39 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -106,5 +106,6 @@ typedef struct videodec_thread_s ...@@ -106,5 +106,6 @@ typedef struct videodec_thread_s
int i_frame_error; int i_frame_error;
int i_frame_skip; int i_frame_skip;
int i_frame_late; /* how may frame decoded are in late */
} videodec_thread_t; } videodec_thread_t;
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