1 /*****************************************************************************
2 * vpar_motion.c : motion vectors parsing
4 *****************************************************************************/
6 /*****************************************************************************
8 *****************************************************************************/
16 #include <X11/extensions/XShm.h>
21 #include "vlc_thread.h"
24 #include "debug.h" /* ?? temporaire, requis par netlist.h */
27 #include "input_netlist.h"
28 #include "decoder_fifo.h"
30 #include "video_output.h"
32 #include "vdec_idct.h"
33 #include "video_decoder.h"
34 #include "vdec_motion.h"
36 #include "vpar_blocks.h"
37 #include "vpar_headers.h"
38 #include "video_fifo.h"
39 #include "vpar_synchro.h"
40 #include "video_parser.h"
48 /*****************************************************************************
49 * vpar_SynchroUpdateTab : Update a mean table in the synchro structure
50 *****************************************************************************/
51 float vpar_SynchroUpdateTab( video_synchro_tab_t * tab, int count )
54 tab->mean = ( tab->mean + 3 * count ) / 4;
55 tab->deviation = ( tab->deviation + 3 * abs (tab->mean - count) ) / 4;
57 return tab->deviation;
60 /*****************************************************************************
61 * vpar_SynchroUpdateStructures : Update the synchro structures
62 *****************************************************************************/
63 void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
66 float candidate_deviation;
67 float optimal_deviation;
73 p_vpar->synchro.current_p_count++;
76 p_vpar->synchro.current_b_count++;
80 /* update all the structures for P images */
81 optimal_deviation = vpar_SynchroUpdateTab(
82 &p_vpar->synchro.tab_p[0],
83 p_vpar->synchro.current_p_count);
84 predict = p_vpar->synchro.tab_p[0].mean;
86 candidate_deviation = vpar_SynchroUpdateTab(
87 &p_vpar->synchro.tab_p[1 + (p_vpar->synchro.modulo & 0x1)],
88 p_vpar->synchro.current_p_count);
89 if (candidate_deviation < optimal_deviation)
91 optimal_deviation = candidate_deviation;
92 predict = p_vpar->synchro.tab_p[1 + (p_vpar->synchro.modulo & 0x1)].mean;
95 candidate_deviation = vpar_SynchroUpdateTab(
96 &p_vpar->synchro.tab_p[3 + (p_vpar->synchro.modulo % 3)],
97 p_vpar->synchro.current_p_count);
98 if (candidate_deviation < optimal_deviation)
100 optimal_deviation = candidate_deviation;
101 predict = p_vpar->synchro.tab_p[1 + (p_vpar->synchro.modulo % 3)].mean;
104 p_vpar->synchro.p_count_predict = predict;
105 p_vpar->synchro.current_p_count = 0;
108 /* update all the structures for B images */
109 optimal_deviation = vpar_SynchroUpdateTab(
110 &p_vpar->synchro.tab_b[0],
111 p_vpar->synchro.current_b_count);
112 predict = p_vpar->synchro.tab_b[0].mean;
114 candidate_deviation = vpar_SynchroUpdateTab(
115 &p_vpar->synchro.tab_b[1 + (p_vpar->synchro.modulo & 0x1)],
116 p_vpar->synchro.current_b_count);
117 if (candidate_deviation < optimal_deviation)
119 optimal_deviation = candidate_deviation;
120 predict = p_vpar->synchro.tab_b[1 + (p_vpar->synchro.modulo & 0x1)].mean;
123 candidate_deviation = vpar_SynchroUpdateTab(
124 &p_vpar->synchro.tab_b[3 + (p_vpar->synchro.modulo % 3)],
125 p_vpar->synchro.current_b_count);
126 if (candidate_deviation < optimal_deviation)
128 optimal_deviation = candidate_deviation;
129 predict = p_vpar->synchro.tab_b[1 + (p_vpar->synchro.modulo % 3)].mean;
132 p_vpar->synchro.b_count_predict = predict;
133 p_vpar->synchro.current_b_count = 0;
139 p_vpar->synchro.modulo++;
142 /*****************************************************************************
143 * vpar_SynchroChoose : Decide whether we will decode a picture or not
144 *****************************************************************************/
145 boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
149 return( i_coding_type == I_CODING_TYPE || i_coding_type == P_CODING_TYPE );
150 intf_DbgMsg("vpar debug: synchro image %i - modulo is %i\n", i_coding_type, p_vpar->synchro.modulo);
151 intf_DbgMsg("vpar debug: synchro predict P %e - predict B %e\n", p_vpar->synchro.p_count_predict, p_vpar->synchro.b_count_predict);
154 return( i_coding_type == I_CODING_TYPE );
157 /*****************************************************************************
158 * vpar_SynchroTrash : Update timers when we trash a picture
159 *****************************************************************************/
160 void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
163 vpar_SynchroUpdateStructures (p_vpar, i_coding_type);
167 /*****************************************************************************
168 * vpar_SynchroDecode : Update timers when we decide to decode a picture
169 *****************************************************************************/
170 void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
173 vpar_SynchroUpdateStructures (p_vpar, i_coding_type);
177 /*****************************************************************************
178 * vpar_SynchroEnd : Called when the image is totally decoded
179 *****************************************************************************/
180 void vpar_SynchroEnd( vpar_thread_t * p_vpar )
183 // return mdate() + 700000;
186 mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
188 return mdate() + 700000;