[vlc-commits] codec: cc: rework demux loop to remove local storage
Francois Cartegnie
git at videolan.org
Tue Sep 19 22:35:51 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Sep 19 18:38:26 2017 +0200| [1237e666afa70d2ad99cdd7d1d997cff73b341e3] | committer: Francois Cartegnie
codec: cc: rework demux loop to remove local storage
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1237e666afa70d2ad99cdd7d1d997cff73b341e3
---
modules/codec/cc.c | 88 +++++++++++++++++++-----------------------------------
1 file changed, 30 insertions(+), 58 deletions(-)
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 34c02fde51..ae1ed13997 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -214,12 +214,9 @@ struct decoder_sys_t
int i_queue;
block_t *p_queue;
- block_t *p_block; /* currently processed block (if incomplely) */
-
int i_field;
int i_channel;
- mtime_t i_display_time;
int i_reorder_depth;
eia608_t eia608;
@@ -290,16 +287,10 @@ static void Flush( decoder_t *p_dec )
decoder_sys_t *p_sys = p_dec->p_sys;
Eia608Init( &p_sys->eia608 );
- p_sys->i_display_time = VLC_TS_INVALID;
block_ChainRelease( p_sys->p_queue );
p_sys->p_queue = NULL;
p_sys->i_queue = 0;
- if( p_sys->p_block )
- {
- block_Release( p_sys->p_block );
- p_sys->p_block = NULL;
- }
}
/****************************************************************************
@@ -309,20 +300,16 @@ static void Flush( decoder_t *p_dec )
****************************************************************************/
static void Push( decoder_t *, block_t * );
static block_t *Pop( decoder_t *, bool );
-static subpicture_t *Convert( decoder_t *, block_t ** );
+static void Convert( decoder_t *, mtime_t, const uint8_t *, size_t );
static bool DoDecode( decoder_t *p_dec, bool b_drain )
{
- decoder_sys_t *p_sys = p_dec->p_sys;
-
- if( !p_sys->p_block )
- p_sys->p_block = Pop( p_dec, b_drain );
- if( !p_sys->p_block )
+ block_t *p_block = Pop( p_dec, b_drain );
+ if( !p_block )
return false;
- subpicture_t *p_spu = Convert( p_dec, &p_sys->p_block );
- if( p_spu )
- decoder_QueueSub( p_dec, p_spu );
+ Convert( p_dec, p_block->i_pts, p_block->p_buffer, p_block->i_buffer );
+ block_Release( p_block );
return true;
}
@@ -339,7 +326,7 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
/* Drain */
for( ; DoDecode( p_dec, true ) ; );
Eia608Init( &p_sys->eia608 );
- p_sys->i_display_time = VLC_TS_INVALID;
+
if( (p_block->i_flags & BLOCK_FLAG_CORRUPTED) || p_block->i_buffer < 1 )
{
block_Release( p_block );
@@ -483,54 +470,39 @@ static subpicture_t *Subtitle( decoder_t *p_dec, eia608_t *h, mtime_t i_pts )
return p_spu;
}
-static subpicture_t *Convert( decoder_t *p_dec, block_t **pp_block )
+static void Convert( decoder_t *p_dec, mtime_t i_pts,
+ const uint8_t *p_buffer, size_t i_buffer )
{
- assert( pp_block && *pp_block );
-
- block_t *p_block = *pp_block;
-
decoder_sys_t *p_sys = p_dec->p_sys;
- if( p_sys->i_display_time == VLC_TS_INVALID )
- p_sys->i_display_time = p_block->i_pts;
-
- eia608_status_t i_status = EIA608_STATUS_DEFAULT;
-
- /* TODO do the real decoding here */
- while( p_block->i_buffer >= 3 && !(i_status & EIA608_STATUS_DISPLAY) )
+ size_t i_ticks = 0;
+ while( i_buffer >= 3 )
{
/* Mask off the specific i_field bit, else some sequences can be lost. */
- if ( (p_block->p_buffer[0] & 0x03) == p_sys->i_field &&
- (p_block->p_buffer[0] & 0x04) /* Valid bit */ )
+ if ( (p_buffer[0] & 0x03) == p_sys->i_field &&
+ (p_buffer[0] & 0x04) /* Valid bit */ )
{
- i_status = Eia608Parse( &p_sys->eia608, p_sys->i_channel, &p_block->p_buffer[1] );
- p_sys->i_display_time += CLOCK_FREQ / 30;
+ eia608_status_t i_status =
+ Eia608Parse( &p_sys->eia608, p_sys->i_channel, &p_buffer[1] );
+
+ /* a caption is ready or removed, process its screen */
+ /*
+ * In case of rollup/painton with 1 packet/frame, we need to update on Changed status.
+ * Batch decoding might be incorrect if those in large number of commands (mp4, ...) then.
+ * see CEAv1.2zero.trp tests
+ */
+ if( i_status & (EIA608_STATUS_DISPLAY | EIA608_STATUS_CHANGED) )
+ {
+ subpicture_t *p_spu = Subtitle( p_dec, &p_sys->eia608, i_pts + i_ticks * CLOCK_FREQ / 30 );
+ if( p_spu )
+ decoder_QueueSub( p_dec, p_spu );
+ }
}
+ i_ticks++;
- p_block->i_buffer -= 3;
- p_block->p_buffer += 3;
- }
-
- const mtime_t i_pts = p_sys->i_display_time;
-
- if( p_block->i_buffer < 3 )
- {
- block_Release( p_block );
- p_sys->i_display_time = VLC_TS_INVALID;
- *pp_block = NULL;
- }
-
- /* a caption is ready or removed, process its screen */
- /*
- * In case of rollup/painton with 1 packet/frame, we need to update on Changed status.
- * Batch decoding might be incorrect if those in large number of commands (mp4, ...) then.
- * see CEAv1.2zero.trp tests
- */
- if( i_status & (EIA608_STATUS_DISPLAY | EIA608_STATUS_CHANGED) )
- {
- return Subtitle( p_dec, &p_sys->eia608, i_pts );
+ i_buffer -= 3;
+ p_buffer += 3;
}
- return NULL;
}
More information about the vlc-commits
mailing list