Commit 16b4210c authored by Jean-Paul Saman's avatar Jean-Paul Saman

input/decoder.c: Drop buffer instead of entire decoder fifo, when its full.

If the decoder fifo is full (growing to large), then instead of flushing and
producing a big artefact in the stream, just drop one buffer. This still limits
the size of the fifo, but does not produce a big artefact as the original code.

Also make the size configurable with a commandline option.
parent 6ddd92de
...@@ -114,6 +114,7 @@ struct decoder_owner_sys_t ...@@ -114,6 +114,7 @@ struct decoder_owner_sys_t
/* fifo */ /* fifo */
block_fifo_t *p_fifo; block_fifo_t *p_fifo;
size_t i_max_fifo_size;
/* Lock for communication with decoder thread */ /* Lock for communication with decoder thread */
vlc_mutex_t lock; vlc_mutex_t lock;
...@@ -398,17 +399,21 @@ void input_DecoderDecode( decoder_t *p_dec, block_t *p_block, bool b_do_pace ) ...@@ -398,17 +399,21 @@ void input_DecoderDecode( decoder_t *p_dec, block_t *p_block, bool b_do_pace )
if( !p_owner->b_buffering ) if( !p_owner->b_buffering )
block_FifoPace( p_owner->p_fifo, 10, SIZE_MAX ); block_FifoPace( p_owner->p_fifo, 10, SIZE_MAX );
} }
#ifdef __arm__ else if( block_FifoSize( p_owner->p_fifo ) > p_owner->i_max_fifo_size )
else if( block_FifoSize( p_owner->p_fifo ) > 50*1024*1024 /* 50 MiB */ )
#else
else if( block_FifoSize( p_owner->p_fifo ) > 400*1024*1024 /* 400 MiB, ie ~ 50mb/s for 60s */ )
#endif
{ {
/* FIXME: ideally we would check the time amount of data /* FIXME: ideally we would check the time amount of data
* in the FIFO instead of its size. */ * in the FIFO instead of its size. */
#if 0
msg_Warn( p_dec, "decoder/packetizer fifo full (data not " msg_Warn( p_dec, "decoder/packetizer fifo full (data not "
"consumed quickly enough), resetting fifo!" ); "consumed quickly enough), resetting fifo!" );
block_FifoEmpty( p_owner->p_fifo ); block_FifoEmpty( p_owner->p_fifo );
#else
msg_Warn( p_dec, "decoder/packetizer fifo full (data not "
"consumed quickly enough), dropping buffers!" );
block_t *p_block = block_FifoGet( p_owner->p_fifo );
if ( p_block )
block_Release( p_block );
#endif
} }
block_FifoPut( p_owner->p_fifo, p_block ); block_FifoPut( p_owner->p_fifo, p_block );
...@@ -797,6 +802,8 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent, ...@@ -797,6 +802,8 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
vlc_object_release( p_dec ); vlc_object_release( p_dec );
return NULL; return NULL;
} }
p_owner->i_max_fifo_size =
var_InheritInteger( p_dec, "decoder-buffer-size" ) * 1024 * 1024;
/* Set buffers allocation callbacks for the decoders */ /* Set buffers allocation callbacks for the decoders */
p_dec->pf_aout_buffer_new = aout_new_buffer; p_dec->pf_aout_buffer_new = aout_new_buffer;
......
...@@ -602,6 +602,13 @@ static const char *const ppsz_pos_descriptions[] = ...@@ -602,6 +602,13 @@ static const char *const ppsz_pos_descriptions[] =
"You should only disable this option if your video has a " \ "You should only disable this option if your video has a " \
"non-standard format requiring all 1088 lines.") "non-standard format requiring all 1088 lines.")
#define DECODER_BUFFER_SIZE_TEXT N_("Adjust decodering buffering size in MiB")
#define DECODER_BUFFER_SIZE_LONGTEXT N_( \
"Adjust buffering size between decoder and output/stream_output modules. " \
"By default this value is 400 * 1024 * 1024 MiB (50 mb/s for 60 seconds), however " \
"in certain situations one might need to adjust this. This options is for " \
"advanced usage only." )
#define MASPECT_RATIO_TEXT N_("Monitor pixel aspect ratio") #define MASPECT_RATIO_TEXT N_("Monitor pixel aspect ratio")
#define MASPECT_RATIO_LONGTEXT N_( \ #define MASPECT_RATIO_LONGTEXT N_( \
"This forces the monitor aspect ratio. Most monitors have square " \ "This forces the monitor aspect ratio. Most monitors have square " \
...@@ -1747,6 +1754,13 @@ vlc_module_begin () ...@@ -1747,6 +1754,13 @@ vlc_module_begin ()
add_string( "custom-aspect-ratios", NULL, CUSTOM_ASPECT_RATIOS_TEXT, add_string( "custom-aspect-ratios", NULL, CUSTOM_ASPECT_RATIOS_TEXT,
CUSTOM_ASPECT_RATIOS_LONGTEXT, false ) CUSTOM_ASPECT_RATIOS_LONGTEXT, false )
add_bool( "hdtv-fix", 1, HDTV_FIX_TEXT, HDTV_FIX_LONGTEXT, true ) add_bool( "hdtv-fix", 1, HDTV_FIX_TEXT, HDTV_FIX_LONGTEXT, true )
#ifdef __arm__
# define DECODER_BUFFER_SIZE (50) /* 50 * 1024 *1024 = 50 MiB */
#else
# define DECODER_BUFFER_SIZE (400) /* 400 * 1024 *1024 = 400 MiB, ie ~ 50mb/s for 60s */
#endif
add_integer( "decoder-buffer-size", DECODER_BUFFER_SIZE, DECODER_BUFFER_SIZE_TEXT,
DECODER_BUFFER_SIZE_LONGTEXT, true )
add_bool( "video-deco", 1, VIDEO_DECO_TEXT, add_bool( "video-deco", 1, VIDEO_DECO_TEXT,
VIDEO_DECO_LONGTEXT, true ) VIDEO_DECO_LONGTEXT, true )
add_string( "video-title", NULL, VIDEO_TITLE_TEXT, add_string( "video-title", NULL, VIDEO_TITLE_TEXT,
......
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