]> git.sesse.net Git - vlc/commitdiff
d�but de la synchro. �a n'influe pas sur le reste pour le moment, mais
authorSam Hocevar <sam@videolan.org>
Tue, 18 Jan 2000 22:33:16 +0000 (22:33 +0000)
committerSam Hocevar <sam@videolan.org>
Tue, 18 Jan 2000 22:33:16 +0000 (22:33 +0000)
la base des algos � deux balles est l�.

include/vpar_synchro.h
src/input/input.c
src/video_parser/vpar_synchro.c

index e4806aa842be62f54064fe57dfe6b781898745d1..1a6bc2be918588b60ecd9aaf0ec34b9d02f2d433 100644 (file)
  *****************************************************************************/
 
 /*****************************************************************************
- * video_synchro_t : timers for the video synchro
+ * video_synchro_t and video_synchro_tab_s : timers for the video synchro
  *****************************************************************************/
+typedef struct video_synchro_tab_s
+{
+    double mean;
+    double deviation;
+    int count;
+    
+} video_synchro_tab_t;
+
 typedef struct video_synchro_s
 {
+    int modulo;
+
+    /* P images since the last I */
+    int current_p_count;
+    double p_count_predict;
+    /* B images since the last I */
+    int current_b_count;
+    double b_count_predict;
+
+    /* 1 for linear count, 2 for binary count, 3 for ternary count */
+    video_synchro_tab_t tab_p[6];
+    video_synchro_tab_t tab_b[6];
 
 } video_synchro_t;
 
index 961187bb29772cd3f65c64da782826b7f74cf90e..c0f42219cdc839fbfa0c17c969623dc98f21eb54 100644 (file)
@@ -995,6 +995,7 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
                     break;
 
                 case AC3_AUDIO_ES:
+                    /* we skip 4 bytes at the beginning of the AC3 payload */
                     p_ts->i_payload_start += 4;
                     p_fifo = &(((ac3dec_thread_t *)(p_es_descriptor->p_dec))->fifo);
                     break;
index 01f69883921101ffb21ac5bfa36c45e57329c59f..f92f3a3145d5528e79b9d4fd737f9ff1b144a9ad 100644 (file)
 #include "vpar_synchro.h"
 #include "video_parser.h"
 
+#define MAX_COUNT 3
+
 /*
  * Local prototypes
  */
 
+/*****************************************************************************
+ * vpar_SynchroUpdateTab : Update a mean table in the synchro structure
+ *****************************************************************************/
+double vpar_SynchroUpdateTab( video_synchro_tab_t * tab, int count )
+{
+    if( tab->count < MAX_COUNT)
+        tab->count++;
+
+    tab->mean = ( (tab->count-1) * tab->mean + count )
+                    / tab->count;
+
+    tab->deviation = ( (tab->count-1) * tab->deviation
+                    + abs (tab->mean - count) ) / tab->count;
+
+}
+
+/*****************************************************************************
+ * vpar_SynchroUpdateStructures : Update the synchro structures
+ *****************************************************************************/
+void vpar_SynchroUpdateStructures( video_synchro_tab_t * tab,
+                                   int i_coding_type )
+{
+    double candidate_deviation;
+    double optimal_deviation;
+    double predict;
+
+    switch(i_coding_type)
+    {
+        case P_CODING_TYPE:
+            p_vpar->synchro.current_p_count++;
+            break;
+        case B_CODING_TYPE:
+            p_vpar->synchro.current_b_count++;
+            break;
+        case I_CODING_TYPE:
+
+            /* update all the structures for P images */
+            optimal_deviation = vpar_SynchroUpdateTab(
+                            &p_vpar->synchro.tab_p[0],
+                            p_vpar->synchro.current_p_count);
+            predict = p_vpar->synchro.tab_p[0].mean;
+
+            candidate_deviation = vpar_SynchroUpdateTab(
+                            &p_vpar->synchro.tab_p[1 + (modulo & 0x1)],
+                            p_vpar->synchro.current_p_count);
+            if (candidate_deviation < optimal_deviation)
+           {
+                optimal_deviation = candidate_deviation;
+                predict = p_vpar->synchro.tab_p[1 + (modulo & 0x1)].mean;
+            }
+
+            candidate_deviation = vpar_SynchroUpdateTab(
+                            &p_vpar->synchro.tab_p[3 + (modulo % 3)],
+                            p_vpar->synchro.current_p_count);
+            if (candidate_deviation < optimal_deviation)
+           {
+                optimal_deviation = candidate_deviation;
+                predict = p_vpar->synchro.tab_p[1 + (modulo & 0x1)].mean;
+            }
+
+           p_vpar->synchro.p_count_predict = predict;
+
+
+            /* update all the structures for B images */
+            optimal_deviation = vpar_SynchroUpdateTab(
+                            &p_vpar->synchro.tab_b[0],
+                            p_vpar->synchro.current_b_count);
+            predict = p_vpar->synchro.tab_b[0].mean;
+
+            candidate_deviation = vpar_SynchroUpdateTab(
+                            &p_vpar->synchro.tab_b[1 + (modulo & 0x1)],
+                            p_vpar->synchro.current_b_count);
+            if (candidate_deviation < optimal_deviation)
+           {
+                optimal_deviation = candidate_deviation;
+                predict = p_vpar->synchro.tab_b[1 + (modulo & 0x1)].mean;
+            }
+
+            candidate_deviation = vpar_SynchroUpdateTab(
+                            &p_vpar->synchro.tab_b[3 + (modulo % 3)],
+                            p_vpar->synchro.current_b_count);
+            if (candidate_deviation < optimal_deviation)
+           {
+                optimal_deviation = candidate_deviation;
+                predict = p_vpar->synchro.tab_b[1 + (modulo & 0x1)].mean;
+            }
+
+           p_vpar->synchro.b_count_predict = predict;
+
+
+            break;
+    }
+
+    p_vpar->synchro.modulo++;
+}
+
 /*****************************************************************************
  * vpar_SynchroChoose : Decide whether we will decode a picture or not
  *****************************************************************************/
@@ -60,6 +158,7 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
 void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
                         int i_structure )
 {
+    vpar_SynchroUpdateStructures (p_vpar, i_coding_type, i_structure);
 
 }
 
@@ -69,6 +168,8 @@ void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
 mtime_t vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
                             int i_structure )
 {
+    vpar_SynchroUpdateStructures (p_vpar, i_coding_type, i_structure);
+
     return mdate() + 3000000;
 }
 
@@ -80,5 +181,3 @@ void vpar_SynchroEnd( vpar_thread_t * p_vpar )
 
 }
 
-
-