]> git.sesse.net Git - vlc/blobdiff - modules/packetizer/dirac.c
sftp: implement directory listing
[vlc] / modules / packetizer / dirac.c
index 04ec28af3ee2e030c78f6e829f68c991a4763a1a..71b0b11a129601debc73663c68fe9bec88f6993f 100644 (file)
@@ -128,9 +128,6 @@ struct decoder_sys_t
      * completed encapsulation units from the front */
     block_t *p_outqueue;
     block_t **pp_outqueue_last;
-    /* p_out_dts points to an element in p_outqueue.  It is used for VLC's
-     * fake pts hidden in DTS hack, as used by AVI */
-    block_t *p_out_dts;
 
     uint32_t u_tg_last_picnum; /*< most recent picturenumber output from RoB */
     bool b_tg_last_picnum; /*< u_tg_last_picnum valid */
@@ -660,9 +657,8 @@ static block_t *dirac_EmitEOS( decoder_t *p_dec, uint32_t i_prev_parse_offset )
 
     p_block->i_flags = DIRAC_NON_DATED;
 
-    return p_block;
-
     (void) p_dec;
+    return p_block;
 }
 
 /***
@@ -735,7 +731,7 @@ static block_t *dirac_DoSync( decoder_t *p_dec )
             {
                 return NULL; /* retry later */
             }
-            /* attempt to syncronise backwards from pu.u_next_offset */
+            /* attempt to synchronise backwards from pu.u_next_offset */
             p_sys->i_offset = pu.u_next_offset;
             /* fall through */
         case TRY_SYNC: /* -> SYNCED | NOT_SYNCED */
@@ -851,7 +847,7 @@ static int dirac_InspectDataUnit( decoder_t *p_dec, block_t **pp_block, block_t
         Actually, this is a bad idea:
          - It sets the discontinuity for every dirac EOS packet
            which doesnt imply a time discontinuity.
-         - When the syncronizer detects a real discontinuity, it
+         - When the synchronizer detects a real discontinuity, it
            should copy the flags through.
         p_eu->i_flags |= BLOCK_FLAG_DISCONTINUITY;
         */
@@ -1144,9 +1140,6 @@ static int dirac_TimeGenPush( decoder_t *p_dec, block_t *p_block_in )
     if( p_sys->b_dts == p_sys->b_pts )
         return 0;
 
-    if( !p_sys->p_out_dts )
-        p_sys->p_out_dts = p_sys->p_outqueue;
-
     /* model the reorder buffer */
     block_t *p_block = dirac_Reorder( p_dec, p_block_in, u_picnum );
     if( !p_block )
@@ -1183,25 +1176,35 @@ static int dirac_TimeGenPush( decoder_t *p_dec, block_t *p_block_in )
     p_sys->b_tg_last_picnum = true;
     p_sys->u_tg_last_picnum = u_picnum;
 
-    if( !p_sys->b_pts )
+    return 0;
+}
+
+
+static void dirac_ReorderDequeueAndReleaseBlock( decoder_t *p_dec, block_t *p_block )
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+    /* Check if that block is present in reorder queue and release it
+       if needed */
+    struct dirac_reorder_entry **pp_at = &p_sys->reorder_buf.p_head;
+    for( ; *pp_at; pp_at = &(*pp_at)->p_next )
     {
-        /* some demuxers (eg, AVI) will provide a series of fake dts values,
-         * which are actually inorder pts values (ie, what should be seen at
-         * the output of a decoder.  A main reason for simulating the reorder
-         * buffer is to turn the inorder fakedts into an out-of-order pts */
-        p_block->i_pts = p_sys->p_out_dts->i_dts;
-        p_sys->p_out_dts->i_dts = VLC_TS_INVALID;
-    }
+        /* backup address in case we remove member */
+        struct dirac_reorder_entry *p_entry = *pp_at;
+        if ( p_entry->p_eu == p_block )
+        {
+            /* unlink member */
+            *pp_at = (*pp_at)->p_next;
 
-    /* If pts was copied from dts, the dts needs to be corrected to account for reordering*/
-    /* If dts has never been seen, the same needs to happen */
-    p_sys->p_out_dts->i_dts = p_block->i_pts - p_sys->i_pts_offset;
+            /* Add to empty reorder entry list*/
+            p_entry->p_next = p_sys->reorder_buf.p_empty;
+            p_sys->reorder_buf.p_empty = p_entry;
 
-    /* move dts pointer */
-    if( p_sys->p_out_dts )
-        p_sys->p_out_dts = p_sys->p_out_dts->p_next;
+            p_sys->reorder_buf.u_size--;
+            break;
+        }
+    }
 
-    return 0;
+    block_Release( p_block );
 }
 
 /*****************************************************************************
@@ -1227,7 +1230,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
             if( p_block )
             {
                 p_block->p_next = dirac_EmitEOS( p_dec, 13 );
-                /* need two EOS to ensure it gets detected by syncro
+                /* need two EOS to ensure it gets detected by synchro
                  * duplicates get discarded in forming encapsulation unit */
             }
         }
@@ -1245,7 +1248,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
     }
 
     /* form as many encapsulation units as possible, give up
-     * when the syncronizer runs out of input data */
+     * when the synchronizer runs out of input data */
     while( ( p_block = dirac_DoSync( p_dec ) ) )
     {
         p_block = dirac_BuildEncapsulationUnit( p_dec, p_block );
@@ -1314,7 +1317,6 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
         dirac_ReorderInit( &p_sys->reorder_buf );
 
         assert( p_sys->p_outqueue == NULL );
-        p_sys->p_out_dts = NULL;
     }
 
     /* perform sanity check:
@@ -1333,7 +1335,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
             block_t *p_block_next = p_block->p_next;
             if( p_block->i_pts > VLC_TS_INVALID && p_block->i_dts > VLC_TS_INVALID )
                 break;
-            block_Release( p_block );
+            dirac_ReorderDequeueAndReleaseBlock( p_dec, p_block );
             p_sys->p_outqueue = p_block = p_block_next;
         }
     }