1 /*****************************************************************************
2 * vpar_blocks.c : blocks parsing
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: vpar_blocks.c,v 1.12 2001/10/01 16:44:07 massiot Exp $
7 * Authors: Michel Lespinasse <walken@zoy.org>
8 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
9 * Christophe Massiot <massiot@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
31 #include <string.h> /* memset */
40 #include "stream_control.h"
41 #include "input_ext-dec.h"
44 #include "video_output.h"
46 #include "vdec_ext-plugins.h"
47 #include "vpar_pool.h"
48 #include "video_parser.h"
50 #include "vpar_blocks.h"
53 * Welcome to vpar_blocks.c ! Here's where the heavy processor-critical parsing
54 * task is done. This file is divided in several parts :
55 * - Decoding of coded blocks
56 * - Decoding of motion vectors
57 * - Decoding of the other macroblock structures
58 * - Picture data parsing management (slices and error handling)
59 * It's a pretty long file. Good luck and have a nice day.
63 /*****************************************************************************
64 * vpar_InitScanTable : Initialize scan table
65 *****************************************************************************/
66 void vpar_InitScanTable( vpar_thread_t * p_vpar )
70 memcpy( p_vpar->ppi_scan, pi_scan, sizeof(pi_scan) );
71 p_vpar->pf_norm_scan( p_vpar->ppi_scan );
73 /* If scan table has changed, we must change the quantization matrices. */
74 for( i = 0; i < 64; i++ )
76 p_vpar->pi_default_intra_quant[ p_vpar->ppi_scan[0][i] ] =
77 pi_default_intra_quant[ pi_scan[0][i] ];
78 p_vpar->pi_default_nonintra_quant[ p_vpar->ppi_scan[0][i] ] =
79 pi_default_nonintra_quant[ pi_scan[0][i] ];
88 /*****************************************************************************
89 * GetLumaDCDiff : Get the luminance DC coefficient difference
90 *****************************************************************************/
91 static __inline__ int GetLumaDCDiff( vpar_thread_t * p_vpar )
94 int i_size, i_dc_diff, i_code;
96 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) < 0x1F )
98 p_tab = DC_lum_5 + i_code;
99 i_size = p_tab->i_value;
102 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
103 i_dc_diff = GetBits( &p_vpar->bit_stream, i_size );
104 if ((i_dc_diff & (1 << (i_size - 1))) == 0)
106 i_dc_diff -= (1 << i_size) - 1;
112 RemoveBits( &p_vpar->bit_stream, 3 );
118 p_tab = DC_long - 0x1e0 + ShowBits( &p_vpar->bit_stream, 9 );
119 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
120 i_size = p_tab->i_value;
121 i_dc_diff = GetBits( &p_vpar->bit_stream, i_size );
122 if ((i_dc_diff & (1 << (i_size - 1))) == 0)
124 i_dc_diff -= (1 << i_size) - 1;
130 /*****************************************************************************
131 * GetChromaDCDiff : Get the chrominance DC coefficient difference
132 *****************************************************************************/
133 static __inline__ int GetChromaDCDiff( vpar_thread_t * p_vpar )
136 int i_size, i_dc_diff, i_code;
138 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) < 0x1F )
140 p_tab = DC_chrom_5 + i_code;
141 i_size = p_tab->i_value;
144 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
145 i_dc_diff = GetBits( &p_vpar->bit_stream, i_size );
146 if ((i_dc_diff & (1 << (i_size - 1))) == 0)
148 i_dc_diff -= (1 << i_size) - 1;
154 RemoveBits( &p_vpar->bit_stream, 2 );
160 p_tab = DC_long - 0x3e0 + ShowBits( &p_vpar->bit_stream, 10 );
161 RemoveBits( &p_vpar->bit_stream, p_tab->i_length + 1 );
162 i_size = p_tab->i_value;
163 i_dc_diff = GetBits( &p_vpar->bit_stream, i_size );
164 if ((i_dc_diff & (1 << (i_size - 1))) == 0)
166 i_dc_diff -= (1 << i_size) - 1;
173 #define SATURATE(val) \
174 if ((u32)(val + 2048) > 4095) \
176 val = (val > 0) ? 2047 : -2048; \
179 /*****************************************************************************
180 * MPEG2IntraB14 : Decode an intra block according to ISO/IEC 13818-2 table B14
181 *****************************************************************************/
182 static void MPEG2IntraB14( vpar_thread_t * p_vpar, idct_inner_t * p_idct )
184 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
186 dct_lookup_t * p_tab;
188 int i_q_scale = p_vpar->mb.i_quantizer_scale;
189 u8 * pi_quant = p_vpar->sequence.intra_quant.pi_matrix;
190 dctelem_t * p_dest = p_idct->pi_block;
191 u8 * p_scan = p_vpar->picture.pi_scan;
194 i_mismatch = ~p_dest[0];
195 i_nc = (p_dest[0] != 0);
199 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
201 p_tab = DCT_B14AC_5 - 5 + i_code;
202 i_coeff += p_tab->i_run;
211 i_pos = p_scan[ i_coeff ];
212 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
213 i_value = (p_tab->i_level * i_q_scale * pi_quant[i_pos])
216 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
217 /* if (i_sign) i_value = -i_value; */
218 i_value = (i_value ^ i_sign) - i_sign;
221 p_dest[i_pos] = i_value;
222 i_mismatch ^= i_value;
226 else if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
228 p_tab = DCT_B14_8 - 4 + i_code;
229 i_coeff += p_tab->i_run;
232 /* Normal coefficient */
237 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
240 /* Illegal, but needed to avoid overflow */
241 intf_WarnMsg( 2, "Intra-B14 coeff is out of bound" );
242 p_vpar->picture.b_error = 1;
247 i_pos = p_scan[i_coeff];
248 i_value = (GetSignedBits( &p_vpar->bit_stream, 12 )
249 * i_q_scale * pi_quant[i_pos]) / 16;
252 p_dest[i_pos] = i_value;
253 i_mismatch ^= i_value;
256 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
258 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
259 i_coeff += p_tab->i_run;
265 else if( i_code >= 0x0080 )
267 p_tab = DCT_13 - 16 + (i_code >> 3);
268 i_coeff += p_tab->i_run;
274 else if( i_code >= 0x0020 )
276 p_tab = DCT_15 - 16 + (i_code >> 1);
277 i_coeff += p_tab->i_run;
285 p_tab = DCT_16 + i_code;
286 i_coeff += p_tab->i_run;
293 intf_WarnMsg( 2, "Intra-B14 coeff is out of bound" );
294 p_vpar->picture.b_error = 1;
298 p_dest[63] ^= i_mismatch & 1;
299 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
307 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
308 p_idct->i_sparse_pos = 63;
312 p_idct->pf_idct = p_vpar->pf_idct_copy;
317 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
318 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
323 p_idct->pf_idct = p_vpar->pf_idct_copy;
327 /*****************************************************************************
328 * MPEG2IntraB15 : Decode an intra block according to ISO/IEC 13818-2 table B15
329 *****************************************************************************/
330 static void MPEG2IntraB15( vpar_thread_t * p_vpar, idct_inner_t * p_idct )
332 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
334 dct_lookup_t * p_tab;
336 int i_q_scale = p_vpar->mb.i_quantizer_scale;
337 u8 * pi_quant = p_vpar->sequence.intra_quant.pi_matrix;
338 dctelem_t * p_dest = p_idct->pi_block;
339 u8 * p_scan = p_vpar->picture.pi_scan;
342 i_mismatch = ~p_dest[0];
343 i_nc = (p_dest[0] != 0);
347 if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
349 p_tab = DCT_B15_8 - 4 + i_code;
350 i_coeff += p_tab->i_run;
356 i_pos = p_scan[ i_coeff ];
357 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
358 i_value = (p_tab->i_level * i_q_scale * pi_quant[i_pos])
361 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
362 /* if (i_sign) i_value = -i_value; */
363 i_value = (i_value ^ i_sign) - i_sign;
366 p_dest[i_pos] = i_value;
367 i_mismatch ^= i_value;
380 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
383 /* Illegal, but needed to avoid overflow */
384 intf_WarnMsg( 2, "Intra-B15 coeff is out of bound" );
385 p_vpar->picture.b_error = 1;
390 i_pos = p_scan[i_coeff];
391 i_value = (GetSignedBits( &p_vpar->bit_stream, 12 )
392 * i_q_scale * pi_quant[i_pos]) / 16;
395 p_dest[i_pos] = i_value;
396 i_mismatch ^= i_value;
400 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
402 p_tab = DCT_B15_10 - 8 + (i_code >> 6);
403 i_coeff += p_tab->i_run;
409 else if( i_code >= 0x0080 )
411 p_tab = DCT_13 - 16 + (i_code >> 3);
412 i_coeff += p_tab->i_run;
418 else if( i_code >= 0x0020 )
420 p_tab = DCT_15 - 16 + (i_code >> 1);
421 i_coeff += p_tab->i_run;
429 p_tab = DCT_16 + i_code;
430 i_coeff += p_tab->i_run;
437 intf_WarnMsg( 2, "Intra-B15 coeff is out of bound" );
438 p_vpar->picture.b_error = 1;
442 p_dest[63] ^= i_mismatch & 1;
443 RemoveBits( &p_vpar->bit_stream, 4 ); /* End of Block */
451 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
452 p_idct->i_sparse_pos = 63;
456 p_idct->pf_idct = p_vpar->pf_idct_copy;
461 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
462 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
467 p_idct->pf_idct = p_vpar->pf_idct_copy;
471 /*****************************************************************************
472 * MPEG2NonIntra : Decode a non-intra MPEG-2 block
473 *****************************************************************************/
474 static void MPEG2NonIntra( vpar_thread_t * p_vpar, idct_inner_t * p_idct )
476 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
478 dct_lookup_t * p_tab;
480 int i_q_scale = p_vpar->mb.i_quantizer_scale;
481 u8 * pi_quant = p_vpar->sequence.nonintra_quant.pi_matrix;
482 dctelem_t * p_dest = p_idct->pi_block;
483 u8 * p_scan = p_vpar->picture.pi_scan;
493 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
495 p_tab = DCT_B14DC_5 - 5 + i_code;
505 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
507 p_tab = DCT_B14AC_5 - 5 + i_code;
509 i_coeff += p_tab->i_run;
518 i_pos = p_scan[ i_coeff ];
519 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
520 i_value = ((2 * p_tab->i_level + 1) * i_q_scale * pi_quant[i_pos])
523 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
524 /* if (i_sign) i_value = -i_value; */
525 i_value = (i_value ^ i_sign) - i_sign;
528 p_dest[i_pos] = i_value;
529 i_mismatch ^= i_value;
534 if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
536 p_tab = DCT_B14_8 - 4 + i_code;
537 i_coeff += p_tab->i_run;
540 /* Normal coefficient */
545 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
548 /* Illegal, but needed to avoid overflow */
549 intf_WarnMsg( 2, "MPEG2NonIntra coeff is out of bound" );
550 p_vpar->picture.b_error = 1;
555 i_pos = p_scan[i_coeff];
556 i_value = 2 * (ShowSignedBits( &p_vpar->bit_stream, 1 )
557 + GetSignedBits( &p_vpar->bit_stream, 12 )) + 1;
559 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 32;
562 p_dest[i_pos] = i_value;
563 i_mismatch ^= i_value;
566 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
568 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
569 i_coeff += p_tab->i_run;
575 else if( i_code >= 0x0080 )
577 p_tab = DCT_13 - 16 + (i_code >> 3);
578 i_coeff += p_tab->i_run;
584 else if( i_code >= 0x0020 )
586 p_tab = DCT_15 - 16 + (i_code >> 1);
587 i_coeff += p_tab->i_run;
595 p_tab = DCT_16 + i_code;
596 i_coeff += p_tab->i_run;
603 intf_WarnMsg( 2, "MPEG2NonIntra coeff is out of bound" );
604 p_vpar->picture.b_error = 1;
608 p_dest[63] ^= i_mismatch & 1;
609 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
617 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
618 p_idct->i_sparse_pos = 63;
622 p_idct->pf_idct = p_vpar->pf_idct_add;
627 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
630 p_idct->i_sparse_pos = 0;
634 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
640 p_idct->pf_idct = p_vpar->pf_idct_add;
644 /*****************************************************************************
645 * MPEG1Intra : Decode an MPEG-1 intra block
646 *****************************************************************************/
647 static void MPEG1Intra( vpar_thread_t * p_vpar, idct_inner_t * p_idct )
649 int i_coeff, i_code, i_pos, i_value, i_nc;
651 dct_lookup_t * p_tab;
653 int i_q_scale = p_vpar->mb.i_quantizer_scale;
654 u8 * pi_quant = p_vpar->sequence.intra_quant.pi_matrix;
655 dctelem_t * p_dest = p_idct->pi_block;
656 u8 * p_scan = p_vpar->picture.pi_scan;
659 i_nc = (p_dest[0] != 0);
663 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
665 p_tab = DCT_B14AC_5 - 5 + i_code;
666 i_coeff += p_tab->i_run;
675 i_pos = p_scan[ i_coeff ];
676 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
677 i_value = (p_tab->i_level * i_q_scale * pi_quant[i_pos])
681 i_value = (i_value - 1) | 1;
683 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
684 /* if (i_sign) i_value = -i_value; */
685 i_value = (i_value ^ i_sign) - i_sign;
688 p_dest[i_pos] = i_value;
692 else if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
694 p_tab = DCT_B14_8 - 4 + i_code;
695 i_coeff += p_tab->i_run;
698 /* Normal coefficient */
703 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
706 /* Illegal, but needed to avoid overflow */
707 intf_WarnMsg( 2, "MPEG1Intra coeff is out of bound" );
708 p_vpar->picture.b_error = 1;
713 i_pos = p_scan[i_coeff];
715 i_value = ShowSignedBits( &p_vpar->bit_stream, 8 );
716 if( !(i_value & 0x7F) )
718 RemoveBits( &p_vpar->bit_stream, 8 );
719 i_value = ShowBits( &p_vpar->bit_stream, 8 ) + 2 * i_value;
722 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 16;
725 i_value = (i_value + ~ShowSignedBits( &p_vpar->bit_stream, 1 )) | 1;
728 p_dest[i_pos] = i_value;
729 RemoveBits( &p_vpar->bit_stream, 8 );
732 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
734 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
735 i_coeff += p_tab->i_run;
741 else if( i_code >= 0x0080 )
743 p_tab = DCT_13 - 16 + (i_code >> 3);
744 i_coeff += p_tab->i_run;
750 else if( i_code >= 0x0020 )
752 p_tab = DCT_15 - 16 + (i_code >> 1);
753 i_coeff += p_tab->i_run;
761 p_tab = DCT_16 + i_code;
762 i_coeff += p_tab->i_run;
769 intf_WarnMsg( 2, "MPEG1Intra coeff is out of bound" );
770 p_vpar->picture.b_error = 1;
774 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
778 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
779 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
783 p_idct->pf_idct = p_vpar->pf_idct_copy;
787 /*****************************************************************************
788 * MPEG1NonIntra : Decode a non-intra MPEG-1 block
789 *****************************************************************************/
790 static void MPEG1NonIntra( vpar_thread_t * p_vpar, idct_inner_t * p_idct )
792 int i_coeff, i_code, i_pos, i_value, i_nc;
794 dct_lookup_t * p_tab;
796 int i_q_scale = p_vpar->mb.i_quantizer_scale;
797 u8 * pi_quant = p_vpar->sequence.nonintra_quant.pi_matrix;
798 dctelem_t * p_dest = p_idct->pi_block;
799 u8 * p_scan = p_vpar->picture.pi_scan;
804 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
806 p_tab = DCT_B14DC_5 - 5 + i_code;
816 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
818 p_tab = DCT_B14AC_5 - 5 + i_code;
820 i_coeff += p_tab->i_run;
829 i_pos = p_scan[ i_coeff ];
830 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
831 i_value = ((2 * p_tab->i_level + 1) * i_q_scale * pi_quant[i_pos])
835 i_value = (i_value - 1) | 1;
837 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
838 /* if (i_sign) i_value = -i_value; */
839 i_value = (i_value ^ i_sign) - i_sign;
842 p_dest[i_pos] = i_value;
847 if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
849 p_tab = DCT_B14_8 - 4 + i_code;
850 i_coeff += p_tab->i_run;
853 /* Normal coefficient */
858 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
861 /* Illegal, but needed to avoid overflow */
862 intf_WarnMsg( 2, "MPEG1NonIntra coeff is out of bound" );
863 p_vpar->picture.b_error = 1;
868 i_pos = p_scan[i_coeff];
869 i_value = ShowSignedBits( &p_vpar->bit_stream, 8 );
870 if( !(i_value & 0x7F) )
872 RemoveBits( &p_vpar->bit_stream, 8 );
873 i_value = ShowBits( &p_vpar->bit_stream, 8 ) + 2 * i_value;
875 i_sign = ShowSignedBits( &p_vpar->bit_stream, 1 );
876 i_value = 2 * (i_sign + i_value) + 1;
877 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 32;
880 i_value = (i_value + ~i_sign) | 1;
883 p_dest[i_pos] = i_value;
884 RemoveBits( &p_vpar->bit_stream, 8 );
887 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
889 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
890 i_coeff += p_tab->i_run;
896 else if( i_code >= 0x0080 )
898 p_tab = DCT_13 - 16 + (i_code >> 3);
899 i_coeff += p_tab->i_run;
905 else if( i_code >= 0x0020 )
907 p_tab = DCT_15 - 16 + (i_code >> 1);
908 i_coeff += p_tab->i_run;
916 p_tab = DCT_16 + i_code;
917 i_coeff += p_tab->i_run;
924 intf_WarnMsg( 2, "MPEG1NonIntra coeff is out of bound" );
925 p_vpar->picture.b_error = 1;
929 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
933 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
936 p_idct->i_sparse_pos = 0;
940 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
945 p_idct->pf_idct = p_vpar->pf_idct_add;
951 /*****************************************************************************
952 * *MB : decode all blocks of the macroblock
953 *****************************************************************************/
954 #define DECODE_LUMABLOCK( i_b, p_dest, PF_MBFUNC ) \
955 p_idct = &p_mb->p_idcts[i_b]; \
956 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
957 p_idct->p_dct_data = p_dest; \
958 p_vpar->mb.pi_dc_dct_pred[0] += GetLumaDCDiff( p_vpar ); \
959 p_idct->pi_block[0] = p_vpar->mb.pi_dc_dct_pred[0] \
960 << (3 - p_vpar->picture.i_intra_dc_precision ); \
961 PF_MBFUNC( p_vpar, p_idct );
963 #define DECLARE_INTRAMB( PSZ_NAME, PF_MBFUNC ) \
964 static __inline__ void PSZ_NAME( vpar_thread_t * p_vpar, \
965 macroblock_t * p_mb ) \
968 yuv_data_t * p_lum_dest; \
969 idct_inner_t * p_idct; \
971 p_lum_dest = p_mb->pp_dest[0] + p_vpar->mb.i_offset; \
973 if( p_mb->i_mb_modes & DCT_TYPE_INTERLACED ) \
975 i_dct_offset = p_vpar->picture.i_field_width; \
976 p_mb->i_lum_dct_stride = p_vpar->picture.i_field_width * 2; \
980 i_dct_offset = p_vpar->picture.i_field_width * 8; \
981 p_mb->i_lum_dct_stride = p_vpar->picture.i_field_width; \
983 p_mb->i_chrom_dct_stride = p_vpar->picture.i_field_width >> 1; \
985 DECODE_LUMABLOCK( 0, p_lum_dest, PF_MBFUNC ); \
986 DECODE_LUMABLOCK( 1, p_lum_dest + 8, PF_MBFUNC ); \
987 DECODE_LUMABLOCK( 2, p_lum_dest + i_dct_offset, PF_MBFUNC ); \
988 DECODE_LUMABLOCK( 3, p_lum_dest + i_dct_offset + 8, PF_MBFUNC ); \
990 p_idct = &p_mb->p_idcts[4]; \
991 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
992 p_idct->p_dct_data = p_mb->pp_dest[1] + (p_vpar->mb.i_offset >> 1); \
993 p_vpar->mb.pi_dc_dct_pred[1] += GetChromaDCDiff( p_vpar ); \
994 p_idct->pi_block[0] = p_vpar->mb.pi_dc_dct_pred[1] \
995 << (3 - p_vpar->picture.i_intra_dc_precision ); \
996 PF_MBFUNC( p_vpar, p_idct ); \
998 p_idct = &p_mb->p_idcts[5]; \
999 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
1000 p_idct->p_dct_data = p_mb->pp_dest[2] + (p_vpar->mb.i_offset >> 1); \
1001 p_vpar->mb.pi_dc_dct_pred[2] += GetChromaDCDiff( p_vpar ); \
1002 p_idct->pi_block[0] = p_vpar->mb.pi_dc_dct_pred[2] \
1003 << (3 - p_vpar->picture.i_intra_dc_precision ); \
1004 PF_MBFUNC( p_vpar, p_idct ); \
1007 DECLARE_INTRAMB( MPEG1IntraMB, MPEG1Intra );
1008 DECLARE_INTRAMB( MPEG2IntraB14MB, MPEG2IntraB14 );
1009 DECLARE_INTRAMB( MPEG2IntraB15MB, MPEG2IntraB15 );
1011 #undef DECLARE_INTRAMB
1012 #undef DECODE_LUMABLOCK
1014 #define DECODE_BLOCK( i_b, p_dest, PF_MBFUNC ) \
1015 if( p_mb->i_coded_block_pattern & (1 << (5 - i_b)) ) \
1017 p_idct = &p_mb->p_idcts[i_b]; \
1018 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
1019 p_idct->p_dct_data = p_dest; \
1020 PF_MBFUNC( p_vpar, p_idct ); \
1023 #define DECLARE_NONINTRAMB( PSZ_NAME, PF_MBFUNC ) \
1024 static __inline__ void PSZ_NAME( vpar_thread_t * p_vpar, \
1025 macroblock_t * p_mb ) \
1028 yuv_data_t * p_lum_dest; \
1029 idct_inner_t * p_idct; \
1031 p_lum_dest = p_mb->pp_dest[0] + p_vpar->mb.i_offset; \
1033 if( p_mb->i_mb_modes & DCT_TYPE_INTERLACED ) \
1035 i_dct_offset = p_vpar->picture.i_field_width; \
1036 p_mb->i_lum_dct_stride = p_vpar->picture.i_field_width * 2; \
1040 i_dct_offset = p_vpar->picture.i_field_width * 8; \
1041 p_mb->i_lum_dct_stride = p_vpar->picture.i_field_width; \
1043 p_mb->i_chrom_dct_stride = p_vpar->picture.i_field_width >> 1; \
1045 DECODE_BLOCK( 0, p_lum_dest, PF_MBFUNC ); \
1046 DECODE_BLOCK( 1, p_lum_dest + 8, PF_MBFUNC ); \
1047 DECODE_BLOCK( 2, p_lum_dest + i_dct_offset, PF_MBFUNC ); \
1048 DECODE_BLOCK( 3, p_lum_dest + i_dct_offset + 8, PF_MBFUNC ); \
1049 DECODE_BLOCK( 4, p_mb->pp_dest[1] + (p_vpar->mb.i_offset >> 1), \
1051 DECODE_BLOCK( 5, p_mb->pp_dest[2] + (p_vpar->mb.i_offset >> 1), \
1055 DECLARE_NONINTRAMB( MPEG1NonIntraMB, MPEG1NonIntra );
1056 DECLARE_NONINTRAMB( MPEG2NonIntraMB, MPEG2NonIntra );
1058 #undef DECLARE_NONINTRAMB
1066 /****************************************************************************
1067 * MotionDelta : Parse the next motion delta
1068 ****************************************************************************/
1069 static __inline__ int MotionDelta( vpar_thread_t * p_vpar, int i_f_code )
1071 int i_delta, i_sign, i_code;
1074 if( ShowBits( &p_vpar->bit_stream, 1 ) )
1076 RemoveBits( &p_vpar->bit_stream, 1 );
1080 if( (i_code = ShowBits( &p_vpar->bit_stream, 6 )) >= 0x3 )
1082 p_tab = MV_4 + (i_code >> 2);
1083 i_delta = (p_tab->i_value << i_f_code) + 1;
1084 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1086 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
1089 i_delta += GetBits( &p_vpar->bit_stream, i_f_code );
1092 return (i_delta ^ i_sign) - i_sign;
1097 p_tab = MV_10 + ShowBits( &p_vpar->bit_stream, 10 );
1098 i_delta = (p_tab->i_value << i_f_code) + 1;
1099 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1101 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
1104 i_delta += GetBits( &p_vpar->bit_stream, i_f_code );
1107 return (i_delta ^ i_sign) - i_sign;
1111 /****************************************************************************
1112 * BoundMotionVector : Bound a motion_vector :-)
1113 ****************************************************************************/
1114 static __inline__ int BoundMotionVector( int i_vector, int i_f_code )
1118 i_limit = 16 << i_f_code;
1120 if( i_vector >= i_limit )
1122 return i_vector - 2 * i_limit;
1124 else if( i_vector < -i_limit)
1126 return i_vector + 2 * i_limit;
1134 /****************************************************************************
1135 * GetDMV : Decode a differential motion vector (Dual Prime Arithmetic)
1136 ****************************************************************************/
1137 static __inline__ int GetDMV( vpar_thread_t * p_vpar )
1139 dmv_lookup_t * p_tab;
1141 p_tab = DMV_2 + ShowBits( &p_vpar->bit_stream, 2 );
1142 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1143 return( p_tab->i_value );
1146 /****************************************************************************
1147 * Motion* : Parse motion vectors
1148 ****************************************************************************/
1149 #define MOTION_BLOCK( b_aver, i_x, i_y, i_dest, \
1150 pp_src, i_src, i_str, i_hei, \
1153 motion_inner_t * p_m_inner = p_mb->p_motions + p_mb->i_nb_motions; \
1154 p_m_inner->b_average = b_aver; \
1155 p_m_inner->i_x_pred = i_x; \
1156 p_m_inner->i_y_pred = i_y; \
1157 p_m_inner->pp_source[0] = pp_src[0]; \
1158 p_m_inner->pp_source[1] = pp_src[1]; \
1159 p_m_inner->pp_source[2] = pp_src[2]; \
1160 p_m_inner->i_dest_offset = i_dest; \
1161 p_m_inner->i_src_offset = i_src; \
1162 p_m_inner->i_stride = i_str; \
1163 p_m_inner->i_height = i_hei; \
1164 p_m_inner->b_second_half = b_s_half; \
1165 p_mb->i_nb_motions++; \
1168 /* MPEG-1 predictions. */
1170 static void MotionMPEG1( vpar_thread_t * p_vpar,
1171 macroblock_t * p_mb,
1172 motion_t * p_motion,
1173 boolean_t b_average )
1175 int i_motion_x, i_motion_y;
1176 int i_offset = p_vpar->mb.i_offset;
1177 int i_width = p_vpar->picture.i_field_width;
1179 i_motion_x = p_motion->ppi_pmv[0][0]
1180 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1181 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1182 p_motion->ppi_pmv[0][0] = i_motion_x;
1184 i_motion_y = p_motion->ppi_pmv[0][1]
1185 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1186 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[0] );
1187 p_motion->ppi_pmv[0][1] = i_motion_y;
1189 if( p_motion->pi_f_code[1] )
1195 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1196 p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1199 static void MotionMPEG1Reuse( vpar_thread_t * p_vpar,
1200 macroblock_t * p_mb,
1201 motion_t * p_motion,
1202 boolean_t b_average )
1204 int i_motion_x, i_motion_y;
1205 int i_offset = p_vpar->mb.i_offset;
1206 int i_width = p_vpar->picture.i_field_width;
1208 i_motion_x = p_motion->ppi_pmv[0][0];
1209 i_motion_y = p_motion->ppi_pmv[0][1];
1211 if( p_motion->pi_f_code[1] )
1217 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1218 i_offset, p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1221 /* MPEG-2 frame predictions. */
1223 static void MotionFrameFrame( vpar_thread_t * p_vpar,
1224 macroblock_t * p_mb,
1225 motion_t * p_motion,
1226 boolean_t b_average )
1228 int i_motion_x, i_motion_y;
1229 int i_offset = p_vpar->mb.i_offset;
1230 int i_width = p_vpar->picture.i_field_width;
1232 i_motion_x = p_motion->ppi_pmv[0][0]
1233 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1234 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1235 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1237 i_motion_y = p_motion->ppi_pmv[0][1]
1238 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1239 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1240 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1242 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1243 p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1246 static void MotionFrameField( vpar_thread_t * p_vpar,
1247 macroblock_t * p_mb,
1248 motion_t * p_motion,
1249 boolean_t b_average )
1251 int i_motion_x, i_motion_y, i_field_select;
1252 int i_offset = p_vpar->mb.i_offset;
1253 int i_width = p_vpar->picture.i_field_width;
1255 i_field_select = GetSignedBits( &p_vpar->bit_stream, 1 );
1257 i_motion_x = p_motion->ppi_pmv[0][0]
1258 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1259 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1260 p_motion->ppi_pmv[0][0] = i_motion_x;
1262 i_motion_y = (p_motion->ppi_pmv[0][1] >> 1)
1263 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1264 /* According to ISO/IEC 13818-2 section 7.6.3.2, the vertical motion
1265 * vector is restricted to a range that implies it doesn't need to
1267 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1268 p_motion->ppi_pmv[0][1] = i_motion_y << 1;
1270 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1271 p_motion->pppi_ref[0], i_offset + (i_field_select & i_width),
1272 i_width * 2, 8, 0 );
1274 i_field_select = GetSignedBits( &p_vpar->bit_stream, 1 );
1276 i_motion_x = p_motion->ppi_pmv[1][0]
1277 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1278 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1279 p_motion->ppi_pmv[1][0] = i_motion_x;
1281 i_motion_y = (p_motion->ppi_pmv[1][1] >> 1)
1282 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1283 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1284 p_motion->ppi_pmv[1][1] = i_motion_y << 1;
1286 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset + i_width,
1287 p_motion->pppi_ref[0], i_offset + (i_field_select & i_width),
1288 i_width * 2, 8, 0 );
1291 static void MotionFrameDMV( vpar_thread_t * p_vpar,
1292 macroblock_t * p_mb,
1293 motion_t * p_motion,
1294 boolean_t b_average )
1296 int i_motion_x, i_motion_y;
1297 int i_dmv_x, i_dmv_y;
1298 int i_tmp_x, i_tmp_y;
1300 int i_offset = p_vpar->mb.i_offset;
1301 int i_width = p_vpar->picture.i_field_width;
1304 i_motion_x = p_motion->ppi_pmv[0][0]
1305 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1306 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1307 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1309 i_dmv_x = GetDMV( p_vpar );
1311 i_motion_y = (p_motion->ppi_pmv[0][1] >> 1)
1312 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1313 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1314 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y << 1;
1316 i_dmv_y = GetDMV( p_vpar );
1319 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset,
1320 p_motion->pppi_ref[0], i_offset, i_width * 2, 8, 0 );
1321 m = p_vpar->picture.b_top_field_first ? 1 : 3;
1322 i_tmp_x = ((i_motion_x * m + (i_motion_x > 0)) >> 1) + i_dmv_x;
1323 i_tmp_y = ((i_motion_y * m + (i_motion_y > 0)) >> 1) + i_dmv_y - 1;
1324 MOTION_BLOCK( 1, i_tmp_x, i_tmp_y, i_offset, p_motion->pppi_ref[0],
1325 i_offset + i_width, i_width * 2, 8, 0 );
1328 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset + i_width,
1329 p_motion->pppi_ref[0], i_offset + i_width, i_width * 2, 8, 0 );
1330 m = p_vpar->picture.b_top_field_first ? 3 : 1;
1331 i_tmp_x = ((i_motion_x * m + (i_motion_x > 0)) >> 1) + i_dmv_x;
1332 i_tmp_y = ((i_motion_y * m + (i_motion_y > 0)) >> 1) + i_dmv_y + 1;
1333 MOTION_BLOCK( 1, i_tmp_x, i_tmp_y, i_offset + i_width,
1334 p_motion->pppi_ref[0], i_offset, i_width * 2, 8, 0 );
1337 static void MotionFrameZero( vpar_thread_t * p_vpar,
1338 macroblock_t * p_mb,
1339 motion_t * p_motion,
1340 boolean_t b_average )
1342 int i_offset = p_vpar->mb.i_offset;
1343 int i_width = p_vpar->picture.i_field_width;
1345 MOTION_BLOCK( b_average, 0, 0, i_offset, p_motion->pppi_ref[0],
1346 i_offset, i_width, 16, 0 );
1349 static void MotionFrameReuse( vpar_thread_t * p_vpar,
1350 macroblock_t * p_mb,
1351 motion_t * p_motion,
1352 boolean_t b_average )
1354 int i_offset = p_vpar->mb.i_offset;
1355 int i_width = p_vpar->picture.i_field_width;
1357 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1358 i_offset, p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1361 /* MPEG-2 field predictions. */
1363 static void MotionFieldField( vpar_thread_t * p_vpar,
1364 macroblock_t * p_mb,
1365 motion_t * p_motion,
1366 boolean_t b_average )
1368 int i_motion_x, i_motion_y;
1369 boolean_t b_field_select;
1370 int i_offset = p_vpar->mb.i_offset;
1371 int i_width = p_vpar->picture.i_field_width;
1373 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1375 i_motion_x = p_motion->ppi_pmv[0][0]
1376 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1377 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1378 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1380 i_motion_y = p_motion->ppi_pmv[0][1]
1381 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1382 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1383 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1385 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1386 p_motion->pppi_ref[b_field_select], i_offset, i_width, 16, 0 );
1389 static void MotionField16x8( vpar_thread_t * p_vpar,
1390 macroblock_t * p_mb,
1391 motion_t * p_motion,
1392 boolean_t b_average )
1394 int i_motion_x, i_motion_y;
1395 boolean_t b_field_select;
1396 int i_offset = p_vpar->mb.i_offset;
1397 int i_width = p_vpar->picture.i_field_width;
1400 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1402 i_motion_x = p_motion->ppi_pmv[0][0]
1403 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1404 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1405 p_motion->ppi_pmv[0][0] = i_motion_x;
1407 i_motion_y = p_motion->ppi_pmv[0][1]
1408 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1409 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1410 p_motion->ppi_pmv[0][1] = i_motion_y;
1412 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1413 p_motion->pppi_ref[b_field_select], i_offset, i_width, 8, 0 );
1416 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1418 i_motion_x = p_motion->ppi_pmv[1][0]
1419 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1420 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1421 p_motion->ppi_pmv[1][0] = i_motion_x;
1423 i_motion_y = p_motion->ppi_pmv[1][1]
1424 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1425 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1426 p_motion->ppi_pmv[1][1] = i_motion_y;
1428 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1429 p_motion->pppi_ref[b_field_select], i_offset, i_width, 8, 1 );
1432 static void MotionFieldDMV( vpar_thread_t * p_vpar,
1433 macroblock_t * p_mb,
1434 motion_t * p_motion,
1435 boolean_t b_average )
1437 int i_motion_x, i_motion_y;
1438 int i_dmv_x, i_dmv_y;
1439 int i_offset = p_vpar->mb.i_offset;
1440 int i_width = p_vpar->picture.i_field_width;
1441 boolean_t b_current_field = p_vpar->picture.b_current_field;
1443 i_motion_x = p_motion->ppi_pmv[0][0]
1444 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1445 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1446 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1448 i_dmv_x = GetDMV( p_vpar );
1450 i_motion_y = p_motion->ppi_pmv[0][1]
1451 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1452 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1453 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1455 i_dmv_y = GetDMV( p_vpar );
1457 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset,
1458 p_motion->pppi_ref[b_current_field],
1459 i_offset, i_width, 16, 0 );
1461 i_motion_x = ((i_motion_x + (i_motion_x > 0)) >> 1) + i_dmv_x;
1462 i_motion_y = ((i_motion_y + (i_motion_y > 0)) >> 1) + i_dmv_y
1463 + 2 * b_current_field - 1;
1464 MOTION_BLOCK( 1, i_motion_x, i_motion_y, i_offset,
1465 p_motion->pppi_ref[!b_current_field],
1466 i_offset, i_width, 16, 0 );
1469 static void MotionFieldZero( vpar_thread_t * p_vpar,
1470 macroblock_t * p_mb,
1471 motion_t * p_motion,
1472 boolean_t b_average )
1474 int i_offset = p_vpar->mb.i_offset;
1475 int i_width = p_vpar->picture.i_field_width;
1476 boolean_t b_current_field = p_vpar->picture.b_current_field;
1478 MOTION_BLOCK( b_average, 0, 0, i_offset, p_motion->pppi_ref[b_current_field],
1479 i_offset, i_width, 16, 0 );
1482 static void MotionFieldReuse( vpar_thread_t * p_vpar,
1483 macroblock_t * p_mb,
1484 motion_t * p_motion,
1485 boolean_t b_average )
1487 int i_offset = p_vpar->mb.i_offset;
1488 int i_width = p_vpar->picture.i_field_width;
1489 boolean_t b_current_field = p_vpar->picture.b_current_field;
1491 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1492 i_offset, p_motion->pppi_ref[b_current_field],
1493 i_offset, i_width, 16, 0 );
1496 /* MPEG-2 concealment motion vectors. */
1498 static void MotionFrameConceal( vpar_thread_t * p_vpar,
1499 macroblock_t * p_mv,
1500 motion_t * p_motion )
1504 i_tmp = p_motion->ppi_pmv[0][0]
1505 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1506 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[0] );
1507 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_tmp;
1509 i_tmp = p_motion->ppi_pmv[0][1]
1510 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1511 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[1] );
1512 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_tmp;
1515 RemoveBits( &p_vpar->bit_stream, 1 );
1518 static void MotionFieldConceal( vpar_thread_t * p_vpar,
1519 macroblock_t * p_mv,
1520 motion_t * p_motion )
1525 RemoveBits( &p_vpar->bit_stream, 1 );
1527 i_tmp = p_motion->ppi_pmv[0][0]
1528 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1529 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[0] );
1530 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_tmp;
1532 i_tmp = p_motion->ppi_pmv[0][1]
1533 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1534 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[1] );
1535 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_tmp;
1538 RemoveBits( &p_vpar->bit_stream, 1 );
1543 * Macroblock information structures
1546 /*****************************************************************************
1547 * MacroblockAddressIncrement : Get the macroblock_address_increment field
1548 *****************************************************************************/
1549 static __inline__ int MacroblockAddressIncrement( vpar_thread_t * p_vpar )
1557 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 ) ) >= 0x2 )
1559 p_tab = MBA_5 - 2 + i_code;
1560 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1561 return( i_mba + p_tab->i_value );
1563 else if( (i_code = ShowBits( &p_vpar->bit_stream, 11 )) >= 0x18 )
1565 p_tab = MBA_11 - 24 + i_code;
1566 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1567 return( i_mba + p_tab->i_value );
1569 else switch( i_code )
1572 /* Macroblock escape */
1576 /* Macroblock stuffing (MPEG-1 ONLY) */
1577 RemoveBits( &p_vpar->bit_stream, 11 );
1581 /* End of slice, or error */
1587 /*****************************************************************************
1588 * CodedPattern : coded_block_pattern
1589 *****************************************************************************/
1590 static __inline__ int CodedPattern( vpar_thread_t * p_vpar )
1595 if( (i_code = ShowBits( &p_vpar->bit_stream, 7 )) >= 0x10 ) /* ? */
1597 p_tab = CBP_7 - 16 + i_code;
1598 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1599 return( p_tab->i_value );
1603 p_tab = CBP_9 + ShowBits( &p_vpar->bit_stream, 9 );
1604 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1605 return( p_tab->i_value );
1609 /*****************************************************************************
1610 * MacroblockModes : Get the macroblock_modes structure
1611 *****************************************************************************/
1612 static __inline__ int MacroblockModes( vpar_thread_t * p_vpar,
1613 macroblock_t * p_mb,
1620 switch( i_coding_type )
1623 p_tab = MB_I + ShowBits( &p_vpar->bit_stream, 1 );
1624 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1625 i_mb_modes = p_tab->i_value;
1627 if( (i_structure == FRAME_STRUCTURE) &&
1628 (!p_vpar->picture.b_frame_pred_frame_dct) )
1630 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1631 * DCT_TYPE_INTERLACED;
1633 return( i_mb_modes );
1636 p_tab = MB_P + ShowBits( &p_vpar->bit_stream, 5 );
1637 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1638 i_mb_modes = p_tab->i_value;
1640 if( i_structure != FRAME_STRUCTURE )
1642 if( i_mb_modes & MB_MOTION_FORWARD )
1644 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1647 return( i_mb_modes );
1649 else if( p_vpar->picture.b_frame_pred_frame_dct )
1651 if( i_mb_modes & MB_MOTION_FORWARD )
1653 i_mb_modes |= MC_FRAME;
1655 return( i_mb_modes );
1659 if( i_mb_modes & MB_MOTION_FORWARD )
1661 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1664 if( i_mb_modes & (MB_INTRA | MB_PATTERN) )
1666 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1667 * DCT_TYPE_INTERLACED;
1669 return( i_mb_modes );
1673 p_tab = MB_B + ShowBits( &p_vpar->bit_stream, 6 );
1674 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1675 i_mb_modes = p_tab->i_value;
1677 if( i_structure != FRAME_STRUCTURE )
1679 if( !( i_mb_modes & MB_INTRA ) )
1681 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1684 return( i_mb_modes );
1686 else if( p_vpar->picture.b_frame_pred_frame_dct )
1688 i_mb_modes |= MC_FRAME;
1689 return( i_mb_modes );
1693 if( i_mb_modes & MB_INTRA )
1697 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1699 if( i_mb_modes & (MB_INTRA | MB_PATTERN) )
1702 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1703 * DCT_TYPE_INTERLACED;
1705 return( i_mb_modes );
1709 RemoveBits( &p_vpar->bit_stream, 1 );
1719 * Picture data parsing management
1722 /*****************************************************************************
1723 * ParseSlice : Parse the next slice structure
1724 *****************************************************************************/
1725 #define MOTION( pf_routine, i_direction ) \
1726 if( (i_direction) & MB_MOTION_FORWARD ) \
1728 pf_routine( p_vpar, p_mb, &p_vpar->mb.f_motion, 0 ); \
1729 if( (i_coding_type == B_CODING_TYPE) \
1730 && ((i_direction) & MB_MOTION_BACKWARD) ) \
1732 pf_routine( p_vpar, p_mb, &p_vpar->mb.b_motion, 1 ); \
1735 else if( (i_coding_type == B_CODING_TYPE) \
1736 && ((i_direction) & MB_MOTION_BACKWARD) ) \
1738 pf_routine( p_vpar, p_mb, &p_vpar->mb.b_motion, 0 ); \
1741 #define CHECK_BOUNDARIES \
1742 i_offset = p_vpar->mb.i_offset; \
1743 if( i_offset == i_width ) \
1745 if( i_coding_type != I_CODING_TYPE || \
1746 p_vpar->picture.b_concealment_mv ) \
1748 p_f_motion->pppi_ref[0][0] += 16 * i_offset; \
1749 p_f_motion->pppi_ref[0][1] += 4 * i_offset; \
1750 p_f_motion->pppi_ref[0][2] += 4 * i_offset; \
1752 if( i_coding_type == B_CODING_TYPE ) \
1754 p_b_motion->pppi_ref[0][0] += 16 * i_offset; \
1755 p_b_motion->pppi_ref[0][1] += 4 * i_offset; \
1756 p_b_motion->pppi_ref[0][2] += 4 * i_offset; \
1758 p_dest[0] += 16 * i_offset; \
1759 p_dest[1] += 4 * i_offset; \
1760 p_dest[2] += 4 * i_offset; \
1763 p_vpar->mb.i_offset = i_offset;
1765 #define PARSEERROR \
1766 if( p_vpar->picture.b_error ) \
1768 /* Go to the next slice. */ \
1769 p_vpar->pool.pf_free_mb( &p_vpar->pool, p_mb ); \
1773 static __inline__ void ParseSlice( vpar_thread_t * p_vpar,
1774 u32 i_vert_code, boolean_t b_mpeg2,
1775 int i_coding_type, int i_structure )
1777 int i_offset, i_width;
1778 picture_t * pp_forward_ref[2];
1779 yuv_data_t * p_dest[3];
1781 motion_t * p_f_motion = &p_vpar->mb.f_motion;
1782 motion_t * p_b_motion = &p_vpar->mb.b_motion;
1785 LoadQuantizerScale( p_vpar );
1787 if( GetBits( &p_vpar->bit_stream, 1 ) )
1789 /* intra_slice, slice_id */
1790 RemoveBits( &p_vpar->bit_stream, 8 );
1791 /* extra_information_slice */
1792 while( GetBits( &p_vpar->bit_stream, 1 ) )
1794 RemoveBits( &p_vpar->bit_stream, 8 );
1798 /* Calculate the position of the macroblock. */
1799 i_width = p_vpar->sequence.i_width;
1800 i_offset = (i_vert_code - 1) * i_width * 4;
1802 /* Initialize motion context. */
1803 pp_forward_ref[0] = p_vpar->sequence.p_forward;
1805 if( i_structure != FRAME_STRUCTURE )
1808 pp_forward_ref[1] = p_vpar->sequence.p_forward;
1810 if( i_coding_type != B_CODING_TYPE && p_vpar->picture.b_second_field )
1812 pp_forward_ref[!p_vpar->picture.b_current_field] =
1813 p_vpar->picture.p_picture;
1815 if( i_coding_type != I_CODING_TYPE || p_vpar->picture.b_concealment_mv )
1817 p_f_motion->pppi_ref[1][0] =
1818 pp_forward_ref[1]->p_y + i_offset * 4 + i_width;
1819 p_f_motion->pppi_ref[1][1] =
1820 pp_forward_ref[1]->p_u + i_offset + (i_width >> 1);
1821 p_f_motion->pppi_ref[1][2] =
1822 pp_forward_ref[1]->p_v + i_offset + (i_width >> 1);
1824 if( i_coding_type == B_CODING_TYPE )
1826 p_b_motion->pppi_ref[1][0] =
1827 p_vpar->sequence.p_backward->p_y + i_offset * 4 + i_width;
1828 p_b_motion->pppi_ref[1][1] =
1829 p_vpar->sequence.p_backward->p_u + i_offset + (i_width >> 1);
1830 p_b_motion->pppi_ref[1][2] =
1831 p_vpar->sequence.p_backward->p_v + i_offset + (i_width >> 1);
1835 if( i_coding_type != I_CODING_TYPE || p_vpar->picture.b_concealment_mv )
1837 p_f_motion->pppi_ref[0][0] = pp_forward_ref[0]->p_y + i_offset * 4;
1838 p_f_motion->pppi_ref[0][1] = pp_forward_ref[0]->p_u + i_offset;
1839 p_f_motion->pppi_ref[0][2] = pp_forward_ref[0]->p_v + i_offset;
1840 p_f_motion->pi_f_code[0] = p_vpar->picture.ppi_f_code[0][0];
1841 p_f_motion->pi_f_code[1] = p_vpar->picture.ppi_f_code[0][1];
1842 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1843 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1846 if( i_coding_type == B_CODING_TYPE )
1848 p_b_motion->pppi_ref[0][0] = p_vpar->sequence.p_backward->p_y
1850 p_b_motion->pppi_ref[0][1] = p_vpar->sequence.p_backward->p_u
1852 p_b_motion->pppi_ref[0][2] = p_vpar->sequence.p_backward->p_v
1854 p_b_motion->pi_f_code[0] = p_vpar->picture.ppi_f_code[1][0];
1855 p_b_motion->pi_f_code[1] = p_vpar->picture.ppi_f_code[1][1];
1856 p_b_motion->ppi_pmv[0][0] = p_b_motion->ppi_pmv[0][1] = 0;
1857 p_b_motion->ppi_pmv[1][0] = p_b_motion->ppi_pmv[1][1] = 0;
1860 /* Initialize destination pointers. */
1861 p_dest[0] = p_vpar->picture.p_picture->p_y + i_offset * 4;
1862 p_dest[1] = p_vpar->picture.p_picture->p_u + i_offset;
1863 p_dest[2] = p_vpar->picture.p_picture->p_v + i_offset;
1865 if( i_structure == BOTTOM_FIELD )
1867 p_dest[0] += i_width;
1868 p_dest[1] += i_width >> 1;
1869 p_dest[2] += i_width >> 1;
1871 i_width = p_vpar->picture.i_field_width;
1873 /* Reset intra DC coefficients predictors (ISO/IEC 13818-2 7.2.1). */
1874 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
1875 = p_vpar->mb.pi_dc_dct_pred[2]
1876 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
1878 p_vpar->mb.i_offset = MacroblockAddressIncrement( p_vpar ) << 4;
1880 while( (int)(p_vpar->mb.i_offset - p_vpar->sequence.i_width) >= 0 )
1882 /* Unusual construct at the start of some slices. Jump one line. */
1883 p_vpar->mb.i_offset -= p_vpar->sequence.i_width;
1884 p_dest[0] += i_width * 16;
1885 p_dest[1] += i_width * 4;
1886 p_dest[2] += i_width * 4;
1887 p_f_motion->pppi_ref[0][0] += i_width * 16;
1888 p_f_motion->pppi_ref[0][1] += i_width * 4;
1889 p_f_motion->pppi_ref[0][2] += i_width * 4;
1890 p_f_motion->pppi_ref[1][0] += i_width * 16;
1891 p_f_motion->pppi_ref[1][1] += i_width * 4;
1892 p_f_motion->pppi_ref[1][2] += i_width * 4;
1897 /* Decode macroblocks. */
1898 macroblock_t * p_mb;
1901 /* Get a macroblock structure. */
1902 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
1903 p_mb->i_nb_motions = 0;
1904 p_mb->pp_dest[0] = p_dest[0];
1905 p_mb->pp_dest[1] = p_dest[1];
1906 p_mb->pp_dest[2] = p_dest[2];
1908 /* Parse off macroblock_modes structure. */
1909 p_mb->i_mb_modes = i_mb_modes =
1910 MacroblockModes( p_vpar, p_mb, i_coding_type, i_structure );
1912 if( i_mb_modes & MB_QUANT )
1914 LoadQuantizerScale( p_vpar );
1917 if( i_mb_modes & MB_INTRA )
1919 if( p_vpar->picture.b_concealment_mv )
1921 if( i_structure == FRAME_STRUCTURE )
1923 MotionFrameConceal( p_vpar, p_mb, p_f_motion );
1927 MotionFieldConceal( p_vpar, p_mb, p_f_motion );
1932 /* Reset motion vectors predictors. */
1933 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1934 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1935 p_b_motion->ppi_pmv[0][0] = p_b_motion->ppi_pmv[0][1] = 0;
1936 p_b_motion->ppi_pmv[1][0] = p_b_motion->ppi_pmv[1][1] = 0;
1940 p_mb->i_coded_block_pattern = (1 << 6) - 1;
1943 if( p_vpar->picture.b_intra_vlc_format )
1945 MPEG2IntraB15MB( p_vpar, p_mb );
1949 MPEG2IntraB14MB( p_vpar, p_mb );
1954 MPEG1IntraMB( p_vpar, p_mb );
1957 if( i_coding_type == D_CODING_TYPE )
1959 RemoveBits( &p_vpar->bit_stream, 1 );
1964 /* Non-intra block */
1967 if( (i_mb_modes & MOTION_TYPE_MASK) == MC_FRAME )
1969 MOTION( MotionMPEG1, i_mb_modes );
1973 /* Non-intra MB without forward mv in a P picture. */
1974 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1975 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1976 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
1979 else if( i_structure == FRAME_STRUCTURE )
1981 switch( i_mb_modes & MOTION_TYPE_MASK )
1984 MOTION( MotionFrameFrame, i_mb_modes );
1988 MOTION( MotionFrameField, i_mb_modes );
1992 MOTION( MotionFrameDMV, MB_MOTION_FORWARD );
1996 /* Non-intra MB without forward mv in a P picture. */
1997 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1998 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1999 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
2004 /* Field structure. */
2005 switch( i_mb_modes & MOTION_TYPE_MASK )
2008 MOTION( MotionFieldField, i_mb_modes );
2012 MOTION( MotionField16x8, i_mb_modes );
2016 MOTION( MotionFieldDMV, i_mb_modes );
2020 /* Non-intra MB without forward mv in a P picture. */
2021 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2022 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2023 MOTION( MotionFieldZero, MB_MOTION_FORWARD );
2027 /* ISO/IEC 13818-2 6.3.17.4 : Coded Block Pattern */
2028 if( i_mb_modes & MB_PATTERN )
2030 p_mb->i_coded_block_pattern = CodedPattern( p_vpar );
2033 MPEG2NonIntraMB( p_vpar, p_mb );
2037 MPEG1NonIntraMB( p_vpar, p_mb );
2042 p_mb->i_coded_block_pattern = 0;
2045 /* Reset intra DC coefficients predictors. */
2046 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
2047 = p_vpar->mb.pi_dc_dct_pred[2]
2048 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
2051 /* End of macroblock. */
2053 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2055 /* Prepare context for the next macroblock. */
2056 p_vpar->mb.i_offset += 16;
2059 if( ShowBits( &p_vpar->bit_stream, 1 ) )
2061 /* Macroblock Address Increment == 1 */
2062 RemoveBits( &p_vpar->bit_stream, 1 );
2066 /* Check for skipped macroblock(s). */
2069 i_mba_inc = MacroblockAddressIncrement( p_vpar );
2076 /* Reset intra DC predictors. */
2077 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
2078 = p_vpar->mb.pi_dc_dct_pred[2]
2079 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
2081 if( i_coding_type == P_CODING_TYPE )
2083 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2084 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2087 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
2088 p_mb->i_mb_modes = 0;
2089 p_mb->i_nb_motions = 0;
2090 p_mb->i_coded_block_pattern = 0;
2091 p_mb->pp_dest[0] = p_dest[0];
2092 p_mb->pp_dest[1] = p_dest[1];
2093 p_mb->pp_dest[2] = p_dest[2];
2095 if( i_structure == FRAME_STRUCTURE )
2097 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
2101 MOTION( MotionFieldZero, MB_MOTION_FORWARD );
2104 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2105 p_vpar->mb.i_offset += 16;
2107 } while( --i_mba_inc );
2112 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
2113 p_mb->i_mb_modes = 0;
2114 p_mb->i_nb_motions = 0;
2115 p_mb->i_coded_block_pattern = 0;
2116 p_mb->pp_dest[0] = p_dest[0];
2117 p_mb->pp_dest[1] = p_dest[1];
2118 p_mb->pp_dest[2] = p_dest[2];
2122 MOTION( MotionMPEG1Reuse, i_mb_modes );
2124 else if( i_structure == FRAME_STRUCTURE )
2126 MOTION( MotionFrameReuse, i_mb_modes );
2130 MOTION( MotionFieldReuse, i_mb_modes );
2133 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2134 p_vpar->mb.i_offset += 16;
2136 } while( --i_mba_inc );
2141 NextStartCode( &p_vpar->bit_stream );
2144 /*****************************************************************************
2145 * PictureData : Parse off all macroblocks (ISO/IEC 13818-2 6.2.3.7)
2146 *****************************************************************************/
2147 static __inline__ void vpar_PictureData( vpar_thread_t * p_vpar,
2149 int i_coding_type, int i_structure )
2153 NextStartCode( &p_vpar->bit_stream );
2154 while( !p_vpar->picture.b_error && !p_vpar->p_fifo->b_die )
2156 if( ((i_dummy = ShowBits( &p_vpar->bit_stream, 32 ))
2157 < SLICE_START_CODE_MIN) ||
2158 (i_dummy > SLICE_START_CODE_MAX) )
2162 RemoveBits32( &p_vpar->bit_stream );
2164 /* Decode slice data. */
2165 ParseSlice( p_vpar, i_dummy & 255, b_mpeg2, i_coding_type,
2170 #define DECLARE_PICD( FUNCNAME, B_MPEG2, I_CODING_TYPE, I_STRUCTURE ) \
2171 void FUNCNAME( vpar_thread_t * p_vpar ) \
2173 vpar_PictureData( p_vpar, B_MPEG2, I_CODING_TYPE, I_STRUCTURE ); \
2176 DECLARE_PICD( vpar_PictureDataGENERIC, p_vpar->sequence.b_mpeg2,
2177 p_vpar->picture.i_coding_type, p_vpar->picture.i_structure );
2178 #if (VPAR_OPTIM_LEVEL > 0)
2179 DECLARE_PICD( vpar_PictureData2IF, 1, I_CODING_TYPE, FRAME_STRUCTURE );
2180 DECLARE_PICD( vpar_PictureData2PF, 1, P_CODING_TYPE, FRAME_STRUCTURE );
2181 DECLARE_PICD( vpar_PictureData2BF, 1, B_CODING_TYPE, FRAME_STRUCTURE );
2183 #if (VPAR_OPTIM_LEVEL > 1)
2184 DECLARE_PICD( vpar_PictureData2IT, 1, I_CODING_TYPE, TOP_FIELD );
2185 DECLARE_PICD( vpar_PictureData2PT, 1, P_CODING_TYPE, TOP_FIELD );
2186 DECLARE_PICD( vpar_PictureData2BT, 1, B_CODING_TYPE, TOP_FIELD );
2187 DECLARE_PICD( vpar_PictureData2IB, 1, I_CODING_TYPE, BOTTOM_FIELD );
2188 DECLARE_PICD( vpar_PictureData2PB, 1, P_CODING_TYPE, BOTTOM_FIELD );
2189 DECLARE_PICD( vpar_PictureData2BB, 1, B_CODING_TYPE, BOTTOM_FIELD );
2190 DECLARE_PICD( vpar_PictureData1I, 0, I_CODING_TYPE, FRAME_STRUCTURE );
2191 DECLARE_PICD( vpar_PictureData1P, 0, P_CODING_TYPE, FRAME_STRUCTURE );
2192 DECLARE_PICD( vpar_PictureData1B, 0, B_CODING_TYPE, FRAME_STRUCTURE );
2193 DECLARE_PICD( vpar_PictureData1D, 0, D_CODING_TYPE, FRAME_STRUCTURE );