[vlc-commits] codec: faad: workaround unaligned timings

Francois Cartegnie git at videolan.org
Fri Oct 11 19:42:24 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Oct 11 19:34:59 2019 +0200| [c8d7729ae6f3663a5cfde12fb0c185e2a3972461] | committer: Francois Cartegnie

codec: faad: workaround unaligned timings

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c8d7729ae6f3663a5cfde12fb0c185e2a3972461
---

 modules/codec/faad.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 021aa86859..5df25ea17b 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -71,6 +71,7 @@ typedef struct
 
     /* samples */
     date_t date;
+    vlc_tick_t i_last_length;
 
     /* temporary buffer */
     block_t *p_block;
@@ -174,6 +175,8 @@ static int Open( vlc_object_t *p_this )
     cfg->outputFormat = HAVE_FPU ? FAAD_FMT_FLOAT : FAAD_FMT_16BIT;
     NeAACDecSetConfiguration( p_sys->hfaad, cfg );
 
+    p_sys->i_last_length = 0;
+
     /* buffer */
     p_sys->p_block = NULL;
 
@@ -321,7 +324,10 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
 
     if( i_pts != VLC_TICK_INVALID && i_pts != date_Get( &p_sys->date ) )
     {
-        date_Set( &p_sys->date, i_pts );
+        if( p_sys->i_last_length == 0 ||
+            /* We need to be permissive and rebase dts when it's really way off */
+            llabs( i_pts - date_Get( &p_sys->date ) ) > p_sys->i_last_length * 3 / 2  )
+            date_Set( &p_sys->date, i_pts );
     }
     else if( date_Get( &p_sys->date ) == VLC_TICK_INVALID )
     {
@@ -558,7 +564,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
             p_out->i_length = date_Increment( &p_sys->date,
                                               frame.samples / frame.channels )
                               - p_out->i_pts;
-
+            p_sys->i_last_length = p_out->i_length;
             if ( p_dec->fmt_out.audio.channel_type == AUDIO_CHANNEL_TYPE_BITMAP )
             {
                 /* Don't kill speakers if some weird mapping does not gets 1:1 */



More information about the vlc-commits mailing list