1 /*****************************************************************************
2 * vpar_blocks.c : blocks parsing
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: vpar_blocks.c,v 1.9 2002/05/18 17:47:47 sam 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 *****************************************************************************/
29 #include <string.h> /* memset */
31 #include <videolan/vlc.h>
34 #include "video_output.h"
36 #include "stream_control.h"
37 #include "input_ext-dec.h"
39 #include "vdec_ext-plugins.h"
40 #include "vpar_pool.h"
41 #include "video_parser.h"
43 #include "vpar_blocks.h"
46 * Welcome to vpar_blocks.c ! Here's where the heavy processor-critical parsing
47 * task is done. This file is divided in several parts :
48 * - Decoding of coded blocks
49 * - Decoding of motion vectors
50 * - Decoding of the other macroblock structures
51 * - Picture data parsing management (slices and error handling)
52 * It's a pretty long file. Good luck and have a nice day.
56 /*****************************************************************************
57 * vpar_InitScanTable : Initialize scan table
58 *****************************************************************************/
59 void vpar_InitScanTable( vpar_thread_t * p_vpar )
63 memcpy( p_vpar->ppi_scan, pi_scan, sizeof(pi_scan) );
64 p_vpar->pf_norm_scan( p_vpar->ppi_scan );
66 /* If scan table has changed, we must change the quantization matrices. */
67 for( i = 0; i < 64; i++ )
69 p_vpar->pi_default_intra_quant[ p_vpar->ppi_scan[0][i] ] =
70 pi_default_intra_quant[ pi_scan[0][i] ];
71 p_vpar->pi_default_nonintra_quant[ p_vpar->ppi_scan[0][i] ] =
72 pi_default_nonintra_quant[ pi_scan[0][i] ];
81 /*****************************************************************************
82 * GetLumaDCDiff : Get the luminance DC coefficient difference
83 *****************************************************************************/
84 static inline int GetLumaDCDiff( vpar_thread_t * p_vpar )
87 int i_size, i_dc_diff, i_code;
89 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) < 0x1F )
91 p_tab = DC_lum_5 + i_code;
92 i_size = p_tab->i_value;
95 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
96 i_dc_diff = GetBits( &p_vpar->bit_stream, i_size );
97 if ((i_dc_diff & (1 << (i_size - 1))) == 0)
99 i_dc_diff -= (1 << i_size) - 1;
105 RemoveBits( &p_vpar->bit_stream, 3 );
111 p_tab = DC_long - 0x1e0 + ShowBits( &p_vpar->bit_stream, 9 );
112 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
113 i_size = p_tab->i_value;
114 i_dc_diff = GetBits( &p_vpar->bit_stream, i_size );
115 if ((i_dc_diff & (1 << (i_size - 1))) == 0)
117 i_dc_diff -= (1 << i_size) - 1;
123 /*****************************************************************************
124 * GetChromaDCDiff : Get the chrominance DC coefficient difference
125 *****************************************************************************/
126 static inline int GetChromaDCDiff( vpar_thread_t * p_vpar )
129 int i_size, i_dc_diff, i_code;
131 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) < 0x1F )
133 p_tab = DC_chrom_5 + i_code;
134 i_size = p_tab->i_value;
137 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
138 i_dc_diff = GetBits( &p_vpar->bit_stream, i_size );
139 if ((i_dc_diff & (1 << (i_size - 1))) == 0)
141 i_dc_diff -= (1 << i_size) - 1;
147 RemoveBits( &p_vpar->bit_stream, 2 );
153 p_tab = DC_long - 0x3e0 + ShowBits( &p_vpar->bit_stream, 10 );
154 RemoveBits( &p_vpar->bit_stream, p_tab->i_length + 1 );
155 i_size = p_tab->i_value;
156 i_dc_diff = GetBits( &p_vpar->bit_stream, i_size );
157 if ((i_dc_diff & (1 << (i_size - 1))) == 0)
159 i_dc_diff -= (1 << i_size) - 1;
166 #define SATURATE(val) \
167 if ((u32)(val + 2048) > 4095) \
169 val = (val > 0) ? 2047 : -2048; \
172 /*****************************************************************************
173 * MPEG2IntraB14 : Decode an intra block according to ISO/IEC 13818-2 table B14
174 *****************************************************************************/
175 static void MPEG2IntraB14( vpar_thread_t * p_vpar, idct_inner_t * p_idct,
178 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
180 dct_lookup_t * p_tab;
182 int i_q_scale = p_vpar->mb.i_quantizer_scale;
183 dctelem_t * p_dest = p_idct->pi_block;
184 u8 * p_scan = p_vpar->picture.pi_scan;
187 i_mismatch = ~p_dest[0];
188 i_nc = (p_dest[0] != 0);
192 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
194 p_tab = DCT_B14AC_5 - 5 + i_code;
195 i_coeff += p_tab->i_run;
204 i_pos = p_scan[ i_coeff ];
205 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
206 i_value = (p_tab->i_level * i_q_scale * pi_quant[i_pos])
209 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
210 /* if (i_sign) i_value = -i_value; */
211 i_value = (i_value ^ i_sign) - i_sign;
214 p_dest[i_pos] = i_value;
215 i_mismatch ^= i_value;
219 else if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
221 p_tab = DCT_B14_8 - 4 + i_code;
222 i_coeff += p_tab->i_run;
225 /* Normal coefficient */
230 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
233 /* Illegal, but needed to avoid overflow */
234 intf_WarnMsg( 2, "Intra-B14 coeff is out of bound" );
235 p_vpar->picture.b_error = 1;
240 i_pos = p_scan[i_coeff];
241 i_value = (GetSignedBits( &p_vpar->bit_stream, 12 )
242 * i_q_scale * pi_quant[i_pos]) / 16;
245 p_dest[i_pos] = i_value;
246 i_mismatch ^= i_value;
249 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
251 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
252 i_coeff += p_tab->i_run;
258 else if( i_code >= 0x0080 )
260 p_tab = DCT_13 - 16 + (i_code >> 3);
261 i_coeff += p_tab->i_run;
267 else if( i_code >= 0x0020 )
269 p_tab = DCT_15 - 16 + (i_code >> 1);
270 i_coeff += p_tab->i_run;
278 p_tab = DCT_16 + i_code;
279 i_coeff += p_tab->i_run;
286 intf_WarnMsg( 2, "Intra-B14 coeff is out of bound" );
287 p_vpar->picture.b_error = 1;
291 p_dest[63] ^= i_mismatch & 1;
292 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
300 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
301 p_idct->i_sparse_pos = 63;
305 p_idct->pf_idct = p_vpar->pf_idct_copy;
310 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
311 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
316 p_idct->pf_idct = p_vpar->pf_idct_copy;
320 /*****************************************************************************
321 * MPEG2IntraB15 : Decode an intra block according to ISO/IEC 13818-2 table B15
322 *****************************************************************************/
323 static void MPEG2IntraB15( vpar_thread_t * p_vpar, idct_inner_t * p_idct,
326 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
328 dct_lookup_t * p_tab;
330 int i_q_scale = p_vpar->mb.i_quantizer_scale;
331 dctelem_t * p_dest = p_idct->pi_block;
332 u8 * p_scan = p_vpar->picture.pi_scan;
335 i_mismatch = ~p_dest[0];
336 i_nc = (p_dest[0] != 0);
340 if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
342 p_tab = DCT_B15_8 - 4 + i_code;
343 i_coeff += p_tab->i_run;
349 i_pos = p_scan[ i_coeff ];
350 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
351 i_value = (p_tab->i_level * i_q_scale * pi_quant[i_pos])
354 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
355 /* if (i_sign) i_value = -i_value; */
356 i_value = (i_value ^ i_sign) - i_sign;
359 p_dest[i_pos] = i_value;
360 i_mismatch ^= i_value;
373 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
376 /* Illegal, but needed to avoid overflow */
377 intf_WarnMsg( 2, "Intra-B15 coeff is out of bound" );
378 p_vpar->picture.b_error = 1;
383 i_pos = p_scan[i_coeff];
384 i_value = (GetSignedBits( &p_vpar->bit_stream, 12 )
385 * i_q_scale * pi_quant[i_pos]) / 16;
388 p_dest[i_pos] = i_value;
389 i_mismatch ^= i_value;
393 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
395 p_tab = DCT_B15_10 - 8 + (i_code >> 6);
396 i_coeff += p_tab->i_run;
402 else if( i_code >= 0x0080 )
404 p_tab = DCT_13 - 16 + (i_code >> 3);
405 i_coeff += p_tab->i_run;
411 else if( i_code >= 0x0020 )
413 p_tab = DCT_15 - 16 + (i_code >> 1);
414 i_coeff += p_tab->i_run;
422 p_tab = DCT_16 + i_code;
423 i_coeff += p_tab->i_run;
430 intf_WarnMsg( 2, "Intra-B15 coeff is out of bound" );
431 p_vpar->picture.b_error = 1;
435 p_dest[63] ^= i_mismatch & 1;
436 RemoveBits( &p_vpar->bit_stream, 4 ); /* End of Block */
444 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
445 p_idct->i_sparse_pos = 63;
449 p_idct->pf_idct = p_vpar->pf_idct_copy;
454 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
455 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
460 p_idct->pf_idct = p_vpar->pf_idct_copy;
464 /*****************************************************************************
465 * MPEG2NonIntra : Decode a non-intra MPEG-2 block
466 *****************************************************************************/
467 static void MPEG2NonIntra( vpar_thread_t * p_vpar, idct_inner_t * p_idct,
470 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
472 dct_lookup_t * p_tab;
474 int i_q_scale = p_vpar->mb.i_quantizer_scale;
475 dctelem_t * p_dest = p_idct->pi_block;
476 u8 * p_scan = p_vpar->picture.pi_scan;
482 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
484 p_tab = DCT_B14DC_5 - 5 + i_code;
494 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
496 p_tab = DCT_B14AC_5 - 5 + i_code;
498 i_coeff += p_tab->i_run;
507 i_pos = p_scan[ i_coeff ];
508 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
509 i_value = ((2 * p_tab->i_level + 1) * i_q_scale * pi_quant[i_pos])
512 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
513 /* if (i_sign) i_value = -i_value; */
514 i_value = (i_value ^ i_sign) - i_sign;
517 p_dest[i_pos] = i_value;
518 i_mismatch ^= i_value;
523 if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
525 p_tab = DCT_B14_8 - 4 + i_code;
526 i_coeff += p_tab->i_run;
529 /* Normal coefficient */
534 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
537 /* Illegal, but needed to avoid overflow */
538 intf_WarnMsg( 2, "vpar warning: MPEG2NonIntra coeff is out of bound" );
539 p_vpar->picture.b_error = 1;
544 i_pos = p_scan[i_coeff];
545 i_value = 2 * (ShowSignedBits( &p_vpar->bit_stream, 1 )
546 + GetSignedBits( &p_vpar->bit_stream, 12 )) + 1;
548 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 32;
551 p_dest[i_pos] = i_value;
552 i_mismatch ^= i_value;
555 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
557 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
558 i_coeff += p_tab->i_run;
564 else if( i_code >= 0x0080 )
566 p_tab = DCT_13 - 16 + (i_code >> 3);
567 i_coeff += p_tab->i_run;
573 else if( i_code >= 0x0020 )
575 p_tab = DCT_15 - 16 + (i_code >> 1);
576 i_coeff += p_tab->i_run;
584 p_tab = DCT_16 + i_code;
585 i_coeff += p_tab->i_run;
592 intf_WarnMsg( 2, "vpar warning: MPEG2NonIntra coeff is out of bound" );
593 p_vpar->picture.b_error = 1;
597 p_dest[63] ^= i_mismatch & 1;
598 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
606 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
607 p_idct->i_sparse_pos = 63;
611 p_idct->pf_idct = p_vpar->pf_idct_add;
616 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
619 p_idct->i_sparse_pos = 0;
623 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
629 p_idct->pf_idct = p_vpar->pf_idct_add;
633 /*****************************************************************************
634 * MPEG1Intra : Decode an MPEG-1 intra block
635 *****************************************************************************/
636 static void MPEG1Intra( vpar_thread_t * p_vpar, idct_inner_t * p_idct,
639 int i_coeff, i_code, i_pos, i_value, i_nc;
641 dct_lookup_t * p_tab;
643 int i_q_scale = p_vpar->mb.i_quantizer_scale;
644 dctelem_t * p_dest = p_idct->pi_block;
645 u8 * p_scan = p_vpar->picture.pi_scan;
648 i_nc = (p_dest[0] != 0);
652 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
654 p_tab = DCT_B14AC_5 - 5 + i_code;
655 i_coeff += p_tab->i_run;
664 i_pos = p_scan[ i_coeff ];
665 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
666 i_value = (p_tab->i_level * i_q_scale * pi_quant[i_pos])
670 i_value = (i_value - 1) | 1;
672 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
673 /* if (i_sign) i_value = -i_value; */
674 i_value = (i_value ^ i_sign) - i_sign;
677 p_dest[i_pos] = i_value;
681 else if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
683 p_tab = DCT_B14_8 - 4 + i_code;
684 i_coeff += p_tab->i_run;
687 /* Normal coefficient */
692 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
695 /* Illegal, but needed to avoid overflow */
696 intf_WarnMsg( 2, "vpar warning: MPEG1Intra coeff is out of bound" );
697 p_vpar->picture.b_error = 1;
702 i_pos = p_scan[i_coeff];
704 i_value = ShowSignedBits( &p_vpar->bit_stream, 8 );
705 if( !(i_value & 0x7F) )
707 RemoveBits( &p_vpar->bit_stream, 8 );
708 i_value = ShowBits( &p_vpar->bit_stream, 8 ) + 2 * i_value;
711 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 16;
714 i_value = (i_value + ~ShowSignedBits( &p_vpar->bit_stream, 1 )) | 1;
717 p_dest[i_pos] = i_value;
718 RemoveBits( &p_vpar->bit_stream, 8 );
721 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
723 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
724 i_coeff += p_tab->i_run;
730 else if( i_code >= 0x0080 )
732 p_tab = DCT_13 - 16 + (i_code >> 3);
733 i_coeff += p_tab->i_run;
739 else if( i_code >= 0x0020 )
741 p_tab = DCT_15 - 16 + (i_code >> 1);
742 i_coeff += p_tab->i_run;
750 p_tab = DCT_16 + i_code;
751 i_coeff += p_tab->i_run;
758 intf_WarnMsg( 2, "vpar warning: MPEG1Intra coeff is out of bound" );
759 p_vpar->picture.b_error = 1;
763 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
767 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
768 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
772 p_idct->pf_idct = p_vpar->pf_idct_copy;
776 /*****************************************************************************
777 * MPEG1NonIntra : Decode a non-intra MPEG-1 block
778 *****************************************************************************/
779 static void MPEG1NonIntra( vpar_thread_t * p_vpar, idct_inner_t * p_idct,
782 int i_coeff, i_code, i_pos, i_value, i_nc;
784 dct_lookup_t * p_tab;
786 int i_q_scale = p_vpar->mb.i_quantizer_scale;
787 dctelem_t * p_dest = p_idct->pi_block;
788 u8 * p_scan = p_vpar->picture.pi_scan;
793 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
795 p_tab = DCT_B14DC_5 - 5 + i_code;
805 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
807 p_tab = DCT_B14AC_5 - 5 + i_code;
809 i_coeff += p_tab->i_run;
818 i_pos = p_scan[ i_coeff ];
819 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
820 i_value = ((2 * p_tab->i_level + 1) * i_q_scale * pi_quant[i_pos])
824 i_value = (i_value - 1) | 1;
826 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
827 /* if (i_sign) i_value = -i_value; */
828 i_value = (i_value ^ i_sign) - i_sign;
831 p_dest[i_pos] = i_value;
836 if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
838 p_tab = DCT_B14_8 - 4 + i_code;
839 i_coeff += p_tab->i_run;
842 /* Normal coefficient */
847 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
850 /* Illegal, but needed to avoid overflow */
851 intf_WarnMsg( 2, "vpar warning: MPEG1NonIntra coeff is out of bound" );
852 p_vpar->picture.b_error = 1;
857 i_pos = p_scan[i_coeff];
858 i_value = ShowSignedBits( &p_vpar->bit_stream, 8 );
859 if( !(i_value & 0x7F) )
861 RemoveBits( &p_vpar->bit_stream, 8 );
862 i_value = ShowBits( &p_vpar->bit_stream, 8 ) + 2 * i_value;
864 i_sign = ShowSignedBits( &p_vpar->bit_stream, 1 );
865 i_value = 2 * (i_sign + i_value) + 1;
866 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 32;
869 i_value = (i_value + ~i_sign) | 1;
872 p_dest[i_pos] = i_value;
873 RemoveBits( &p_vpar->bit_stream, 8 );
876 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
878 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
879 i_coeff += p_tab->i_run;
885 else if( i_code >= 0x0080 )
887 p_tab = DCT_13 - 16 + (i_code >> 3);
888 i_coeff += p_tab->i_run;
894 else if( i_code >= 0x0020 )
896 p_tab = DCT_15 - 16 + (i_code >> 1);
897 i_coeff += p_tab->i_run;
905 p_tab = DCT_16 + i_code;
906 i_coeff += p_tab->i_run;
913 intf_WarnMsg( 2, "vpar warning: MPEG1NonIntra coeff is out of bound" );
914 p_vpar->picture.b_error = 1;
918 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
922 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
925 p_idct->i_sparse_pos = 0;
929 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
934 p_idct->pf_idct = p_vpar->pf_idct_add;
940 /*****************************************************************************
941 * *MB : decode all blocks of the macroblock
942 *****************************************************************************/
943 #define DECODE_LUMABLOCK( I_B, PF_MBFUNC ) \
944 p_idct = &p_mb->p_idcts[I_B]; \
945 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
946 p_vpar->mb.pi_dc_dct_pred[0] += GetLumaDCDiff( p_vpar ); \
947 p_idct->pi_block[0] = p_vpar->mb.pi_dc_dct_pred[0] \
948 << (3 - p_vpar->picture.i_intra_dc_precision ); \
949 PF_MBFUNC( p_vpar, p_idct, p_vpar->sequence.intra_quant.pi_matrix );
951 #define DECODE_CHROMABLOCK( I_B, PF_MBFUNC, I_CC ) \
952 p_idct = &p_mb->p_idcts[I_B]; \
953 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
954 p_vpar->mb.pi_dc_dct_pred[I_CC] += GetChromaDCDiff( p_vpar ); \
955 p_idct->pi_block[0] = p_vpar->mb.pi_dc_dct_pred[I_CC] \
956 << (3 - p_vpar->picture.i_intra_dc_precision ); \
957 PF_MBFUNC( p_vpar, p_idct, \
958 p_vpar->sequence.chroma_intra_quant.pi_matrix );
960 #define DECLARE_INTRAMB( PSZ_NAME, PF_MBFUNC ) \
961 static inline void PSZ_NAME( vpar_thread_t * p_vpar, macroblock_t * p_mb ) \
963 idct_inner_t * p_idct; \
966 p_mb->p_y_data = p_mb->pp_dest[0] + p_vpar->mb.i_offset; \
967 p_mb->p_u_data = p_mb->pp_dest[1] + (p_vpar->mb.i_offset \
968 >> p_vpar->sequence.b_chroma_h_subsampled); \
969 p_mb->p_v_data = p_mb->pp_dest[2] + (p_vpar->mb.i_offset \
970 >> p_vpar->sequence.b_chroma_h_subsampled); \
972 DECODE_LUMABLOCK( 0, PF_MBFUNC ); \
973 DECODE_LUMABLOCK( 1, PF_MBFUNC ); \
974 DECODE_LUMABLOCK( 2, PF_MBFUNC ); \
975 DECODE_LUMABLOCK( 3, PF_MBFUNC ); \
979 DECODE_CHROMABLOCK( i_b, PF_MBFUNC, 1 ); \
980 DECODE_CHROMABLOCK( i_b + 1, PF_MBFUNC, 2 ); \
983 while( i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks ); \
986 DECLARE_INTRAMB( MPEG1IntraMB, MPEG1Intra );
987 DECLARE_INTRAMB( MPEG2IntraB14MB, MPEG2IntraB14 );
988 DECLARE_INTRAMB( MPEG2IntraB15MB, MPEG2IntraB15 );
990 #undef DECLARE_INTRAMB
991 #undef DECODE_LUMABLOCK
992 #undef DECODE_CHROMABLOCK
994 #define DECODE_LUMABLOCK( I_B, PF_MBFUNC ) \
995 if( p_mb->i_coded_block_pattern & (1 << (11 - (I_B))) ) \
997 p_idct = &p_mb->p_idcts[I_B]; \
998 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
999 PF_MBFUNC( p_vpar, p_idct, \
1000 p_vpar->sequence.nonintra_quant.pi_matrix ); \
1003 #define DECODE_CHROMABLOCK( I_B, PF_MBFUNC ) \
1004 if( p_mb->i_coded_block_pattern & (1 << (11 - (I_B))) ) \
1006 p_idct = &p_mb->p_idcts[I_B]; \
1007 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
1008 PF_MBFUNC( p_vpar, p_idct, \
1009 p_vpar->sequence.chroma_nonintra_quant.pi_matrix ); \
1012 #define DECLARE_NONINTRAMB( PSZ_NAME, PF_MBFUNC ) \
1013 static inline void PSZ_NAME( vpar_thread_t * p_vpar, macroblock_t * p_mb ) \
1015 idct_inner_t * p_idct; \
1018 p_mb->p_y_data = p_mb->pp_dest[0] + p_vpar->mb.i_offset; \
1019 p_mb->p_u_data = p_mb->pp_dest[1] + (p_vpar->mb.i_offset \
1020 >> p_vpar->sequence.b_chroma_h_subsampled); \
1021 p_mb->p_v_data = p_mb->pp_dest[2] + (p_vpar->mb.i_offset \
1022 >> p_vpar->sequence.b_chroma_h_subsampled); \
1024 DECODE_LUMABLOCK( 0, PF_MBFUNC ); \
1025 DECODE_LUMABLOCK( 1, PF_MBFUNC ); \
1026 DECODE_LUMABLOCK( 2, PF_MBFUNC ); \
1027 DECODE_LUMABLOCK( 3, PF_MBFUNC ); \
1031 DECODE_CHROMABLOCK( i_b, PF_MBFUNC ); \
1032 DECODE_CHROMABLOCK( i_b + 1, PF_MBFUNC ); \
1035 while( i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks ); \
1038 DECLARE_NONINTRAMB( MPEG1NonIntraMB, MPEG1NonIntra );
1039 DECLARE_NONINTRAMB( MPEG2NonIntraMB, MPEG2NonIntra );
1041 #undef DECLARE_NONINTRAMB
1042 #undef DECODE_LUMABLOCK
1043 #undef DECODE_CHROMABLOCK
1050 /****************************************************************************
1051 * MotionDelta : Parse the next motion delta
1052 ****************************************************************************/
1053 static inline int MotionDelta( vpar_thread_t * p_vpar, int i_f_code )
1055 int i_delta, i_sign, i_code;
1058 if( ShowBits( &p_vpar->bit_stream, 1 ) )
1060 RemoveBits( &p_vpar->bit_stream, 1 );
1064 if( (i_code = ShowBits( &p_vpar->bit_stream, 6 )) >= 0x3 )
1066 p_tab = MV_4 + (i_code >> 2);
1067 i_delta = (p_tab->i_value << i_f_code) + 1;
1068 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1070 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
1073 i_delta += GetBits( &p_vpar->bit_stream, i_f_code );
1076 return (i_delta ^ i_sign) - i_sign;
1081 p_tab = MV_10 + ShowBits( &p_vpar->bit_stream, 10 );
1082 i_delta = (p_tab->i_value << i_f_code) + 1;
1083 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1085 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
1088 i_delta += GetBits( &p_vpar->bit_stream, i_f_code );
1091 return (i_delta ^ i_sign) - i_sign;
1095 /****************************************************************************
1096 * BoundMotionVector : Bound a motion_vector :-)
1097 ****************************************************************************/
1098 static inline int BoundMotionVector( int i_vector, int i_f_code )
1102 i_limit = 16 << i_f_code;
1104 if( i_vector >= i_limit )
1106 return i_vector - 2 * i_limit;
1108 else if( i_vector < -i_limit)
1110 return i_vector + 2 * i_limit;
1118 /****************************************************************************
1119 * GetDMV : Decode a differential motion vector (Dual Prime Arithmetic)
1120 ****************************************************************************/
1121 static inline int GetDMV( vpar_thread_t * p_vpar )
1123 dmv_lookup_t * p_tab;
1125 p_tab = DMV_2 + ShowBits( &p_vpar->bit_stream, 2 );
1126 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1127 return( p_tab->i_value );
1130 /****************************************************************************
1131 * Motion* : Parse motion vectors
1132 ****************************************************************************/
1133 #define MOTION_BLOCK( b_aver, i_x, i_y, i_dest, \
1134 pp_src, i_src, i_str, i_hei, \
1137 motion_inner_t * p_m_inner = p_mb->p_motions + p_mb->i_nb_motions; \
1138 p_m_inner->b_average = b_aver; \
1139 p_m_inner->i_x_pred = i_x; \
1140 p_m_inner->i_y_pred = i_y; \
1141 p_m_inner->pp_source[0] = pp_src[0]; \
1142 p_m_inner->pp_source[1] = pp_src[1]; \
1143 p_m_inner->pp_source[2] = pp_src[2]; \
1144 p_m_inner->i_dest_offset = i_dest; \
1145 p_m_inner->i_src_offset = i_src; \
1146 p_m_inner->i_stride = i_str; \
1147 p_m_inner->i_height = i_hei; \
1148 p_m_inner->b_second_half = b_s_half; \
1149 p_mb->i_nb_motions++; \
1152 /* MPEG-1 predictions. */
1154 static void MotionMPEG1( vpar_thread_t * p_vpar,
1155 macroblock_t * p_mb,
1156 motion_t * p_motion,
1157 boolean_t b_average )
1159 int i_motion_x, i_motion_y;
1160 int i_offset = p_vpar->mb.i_offset;
1161 int i_width = p_vpar->picture.i_lum_stride;
1163 i_motion_x = p_motion->ppi_pmv[0][0]
1164 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1165 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1166 p_motion->ppi_pmv[0][0] = i_motion_x;
1168 i_motion_y = p_motion->ppi_pmv[0][1]
1169 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1170 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[0] );
1171 p_motion->ppi_pmv[0][1] = i_motion_y;
1173 if( p_motion->pi_f_code[1] )
1179 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1180 p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1183 static void MotionMPEG1Reuse( vpar_thread_t * p_vpar,
1184 macroblock_t * p_mb,
1185 motion_t * p_motion,
1186 boolean_t b_average )
1188 int i_motion_x, i_motion_y;
1189 int i_offset = p_vpar->mb.i_offset;
1190 int i_width = p_vpar->picture.i_lum_stride;
1192 i_motion_x = p_motion->ppi_pmv[0][0];
1193 i_motion_y = p_motion->ppi_pmv[0][1];
1195 if( p_motion->pi_f_code[1] )
1201 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1202 i_offset, p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1205 /* MPEG-2 frame predictions. */
1207 static void MotionFrameFrame( vpar_thread_t * p_vpar,
1208 macroblock_t * p_mb,
1209 motion_t * p_motion,
1210 boolean_t b_average )
1212 int i_motion_x, i_motion_y;
1213 int i_offset = p_vpar->mb.i_offset;
1214 int i_width = p_vpar->picture.i_lum_stride;
1216 i_motion_x = p_motion->ppi_pmv[0][0]
1217 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1218 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1219 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1221 i_motion_y = p_motion->ppi_pmv[0][1]
1222 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1223 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1224 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1226 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1227 p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1230 static void MotionFrameField( vpar_thread_t * p_vpar,
1231 macroblock_t * p_mb,
1232 motion_t * p_motion,
1233 boolean_t b_average )
1235 int i_motion_x, i_motion_y, i_field_select;
1236 int i_offset = p_vpar->mb.i_offset;
1237 int i_width = p_vpar->picture.i_lum_stride;
1239 i_field_select = GetSignedBits( &p_vpar->bit_stream, 1 );
1241 i_motion_x = p_motion->ppi_pmv[0][0]
1242 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1243 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1244 p_motion->ppi_pmv[0][0] = i_motion_x;
1246 i_motion_y = (p_motion->ppi_pmv[0][1] >> 1)
1247 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1248 /* According to ISO/IEC 13818-2 section 7.6.3.2, the vertical motion
1249 * vector is restricted to a range that implies it doesn't need to
1251 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1252 p_motion->ppi_pmv[0][1] = i_motion_y << 1;
1254 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1255 p_motion->pppi_ref[0], i_offset + (i_field_select & i_width),
1256 i_width * 2, 8, 0 );
1258 i_field_select = GetSignedBits( &p_vpar->bit_stream, 1 );
1260 i_motion_x = p_motion->ppi_pmv[1][0]
1261 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1262 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1263 p_motion->ppi_pmv[1][0] = i_motion_x;
1265 i_motion_y = (p_motion->ppi_pmv[1][1] >> 1)
1266 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1267 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1268 p_motion->ppi_pmv[1][1] = i_motion_y << 1;
1270 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset + i_width,
1271 p_motion->pppi_ref[0], i_offset + (i_field_select & i_width),
1272 i_width * 2, 8, 0 );
1275 static void MotionFrameDMV( vpar_thread_t * p_vpar,
1276 macroblock_t * p_mb,
1277 motion_t * p_motion,
1278 boolean_t b_average )
1280 int i_motion_x, i_motion_y;
1281 int i_dmv_x, i_dmv_y;
1282 int i_tmp_x, i_tmp_y;
1284 int i_offset = p_vpar->mb.i_offset;
1285 int i_width = p_vpar->picture.i_lum_stride;
1288 i_motion_x = p_motion->ppi_pmv[0][0]
1289 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1290 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1291 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1293 i_dmv_x = GetDMV( p_vpar );
1295 i_motion_y = (p_motion->ppi_pmv[0][1] >> 1)
1296 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1297 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1298 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y << 1;
1300 i_dmv_y = GetDMV( p_vpar );
1303 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset,
1304 p_motion->pppi_ref[0], i_offset, i_width * 2, 8, 0 );
1305 m = p_vpar->picture.b_top_field_first ? 1 : 3;
1306 i_tmp_x = ((i_motion_x * m + (i_motion_x > 0)) >> 1) + i_dmv_x;
1307 i_tmp_y = ((i_motion_y * m + (i_motion_y > 0)) >> 1) + i_dmv_y - 1;
1308 MOTION_BLOCK( 1, i_tmp_x, i_tmp_y, i_offset, p_motion->pppi_ref[0],
1309 i_offset + i_width, i_width * 2, 8, 0 );
1312 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset + i_width,
1313 p_motion->pppi_ref[0], i_offset + i_width, i_width * 2, 8, 0 );
1314 m = p_vpar->picture.b_top_field_first ? 3 : 1;
1315 i_tmp_x = ((i_motion_x * m + (i_motion_x > 0)) >> 1) + i_dmv_x;
1316 i_tmp_y = ((i_motion_y * m + (i_motion_y > 0)) >> 1) + i_dmv_y + 1;
1317 MOTION_BLOCK( 1, i_tmp_x, i_tmp_y, i_offset + i_width,
1318 p_motion->pppi_ref[0], i_offset, i_width * 2, 8, 0 );
1321 static void MotionFrameZero( vpar_thread_t * p_vpar,
1322 macroblock_t * p_mb,
1323 motion_t * p_motion,
1324 boolean_t b_average )
1326 int i_offset = p_vpar->mb.i_offset;
1327 int i_width = p_vpar->picture.i_lum_stride;
1329 MOTION_BLOCK( b_average, 0, 0, i_offset, p_motion->pppi_ref[0],
1330 i_offset, i_width, 16, 0 );
1333 static void MotionFrameReuse( vpar_thread_t * p_vpar,
1334 macroblock_t * p_mb,
1335 motion_t * p_motion,
1336 boolean_t b_average )
1338 int i_offset = p_vpar->mb.i_offset;
1339 int i_width = p_vpar->picture.i_lum_stride;
1341 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1342 i_offset, p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1345 /* MPEG-2 field predictions. */
1347 static void MotionFieldField( vpar_thread_t * p_vpar,
1348 macroblock_t * p_mb,
1349 motion_t * p_motion,
1350 boolean_t b_average )
1352 int i_motion_x, i_motion_y;
1353 boolean_t b_field_select;
1354 int i_offset = p_vpar->mb.i_offset;
1355 int i_width = p_vpar->picture.i_lum_stride;
1357 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1359 i_motion_x = p_motion->ppi_pmv[0][0]
1360 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1361 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1362 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1364 i_motion_y = p_motion->ppi_pmv[0][1]
1365 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1366 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1367 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1369 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1370 p_motion->pppi_ref[b_field_select], i_offset, i_width, 16, 0 );
1373 static void MotionField16x8( vpar_thread_t * p_vpar,
1374 macroblock_t * p_mb,
1375 motion_t * p_motion,
1376 boolean_t b_average )
1378 int i_motion_x, i_motion_y;
1379 boolean_t b_field_select;
1380 int i_offset = p_vpar->mb.i_offset;
1381 int i_width = p_vpar->picture.i_lum_stride;
1384 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1386 i_motion_x = p_motion->ppi_pmv[0][0]
1387 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1388 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1389 p_motion->ppi_pmv[0][0] = i_motion_x;
1391 i_motion_y = p_motion->ppi_pmv[0][1]
1392 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1393 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1394 p_motion->ppi_pmv[0][1] = i_motion_y;
1396 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1397 p_motion->pppi_ref[b_field_select], i_offset, i_width, 8, 0 );
1400 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1402 i_motion_x = p_motion->ppi_pmv[1][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[1][0] = i_motion_x;
1407 i_motion_y = p_motion->ppi_pmv[1][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[1][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, 1 );
1416 static void MotionFieldDMV( vpar_thread_t * p_vpar,
1417 macroblock_t * p_mb,
1418 motion_t * p_motion,
1419 boolean_t b_average )
1421 int i_motion_x, i_motion_y;
1422 int i_dmv_x, i_dmv_y;
1423 int i_offset = p_vpar->mb.i_offset;
1424 int i_width = p_vpar->picture.i_lum_stride;
1425 boolean_t b_current_field = p_vpar->picture.b_current_field;
1427 i_motion_x = p_motion->ppi_pmv[0][0]
1428 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1429 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1430 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1432 i_dmv_x = GetDMV( p_vpar );
1434 i_motion_y = p_motion->ppi_pmv[0][1]
1435 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1436 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1437 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1439 i_dmv_y = GetDMV( p_vpar );
1441 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset,
1442 p_motion->pppi_ref[b_current_field],
1443 i_offset, i_width, 16, 0 );
1445 i_motion_x = ((i_motion_x + (i_motion_x > 0)) >> 1) + i_dmv_x;
1446 i_motion_y = ((i_motion_y + (i_motion_y > 0)) >> 1) + i_dmv_y
1447 + 2 * b_current_field - 1;
1448 MOTION_BLOCK( 1, i_motion_x, i_motion_y, i_offset,
1449 p_motion->pppi_ref[!b_current_field],
1450 i_offset, i_width, 16, 0 );
1453 static void MotionFieldZero( vpar_thread_t * p_vpar,
1454 macroblock_t * p_mb,
1455 motion_t * p_motion,
1456 boolean_t b_average )
1458 int i_offset = p_vpar->mb.i_offset;
1459 int i_width = p_vpar->picture.i_lum_stride;
1460 boolean_t b_current_field = p_vpar->picture.b_current_field;
1462 MOTION_BLOCK( b_average, 0, 0, i_offset, p_motion->pppi_ref[b_current_field],
1463 i_offset, i_width, 16, 0 );
1466 static void MotionFieldReuse( vpar_thread_t * p_vpar,
1467 macroblock_t * p_mb,
1468 motion_t * p_motion,
1469 boolean_t b_average )
1471 int i_offset = p_vpar->mb.i_offset;
1472 int i_width = p_vpar->picture.i_lum_stride;
1473 boolean_t b_current_field = p_vpar->picture.b_current_field;
1475 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1476 i_offset, p_motion->pppi_ref[b_current_field],
1477 i_offset, i_width, 16, 0 );
1480 /* MPEG-2 concealment motion vectors. */
1482 static void MotionFrameConceal( vpar_thread_t * p_vpar,
1483 macroblock_t * p_mv,
1484 motion_t * p_motion )
1488 i_tmp = p_motion->ppi_pmv[0][0]
1489 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1490 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[0] );
1491 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_tmp;
1493 i_tmp = p_motion->ppi_pmv[0][1]
1494 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1495 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[1] );
1496 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_tmp;
1499 RemoveBits( &p_vpar->bit_stream, 1 );
1502 static void MotionFieldConceal( vpar_thread_t * p_vpar,
1503 macroblock_t * p_mv,
1504 motion_t * p_motion )
1509 RemoveBits( &p_vpar->bit_stream, 1 );
1511 i_tmp = p_motion->ppi_pmv[0][0]
1512 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1513 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[0] );
1514 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_tmp;
1516 i_tmp = p_motion->ppi_pmv[0][1]
1517 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1518 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[1] );
1519 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_tmp;
1522 RemoveBits( &p_vpar->bit_stream, 1 );
1527 * Macroblock information structures
1530 /*****************************************************************************
1531 * MacroblockAddressIncrement : Get the macroblock_address_increment field
1532 *****************************************************************************/
1533 static inline int MacroblockAddressIncrement( vpar_thread_t * p_vpar )
1541 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 ) ) >= 0x2 )
1543 p_tab = MBA_5 - 2 + i_code;
1544 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1545 return( i_mba + p_tab->i_value );
1547 else if( (i_code = ShowBits( &p_vpar->bit_stream, 11 )) >= 0x18 )
1549 p_tab = MBA_11 - 24 + i_code;
1550 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1551 return( i_mba + p_tab->i_value );
1553 else switch( i_code )
1556 /* Macroblock escape */
1560 /* Macroblock stuffing (MPEG-1 ONLY) */
1561 RemoveBits( &p_vpar->bit_stream, 11 );
1565 /* End of slice, or error */
1571 /*****************************************************************************
1572 * CodedPattern : coded_block_pattern
1573 *****************************************************************************/
1574 static inline int CodedPattern( vpar_thread_t * p_vpar )
1579 if( (i_code = ShowBits( &p_vpar->bit_stream, 7 )) >= 0x10 )
1581 p_tab = CBP_7 - 16 + i_code;
1582 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1586 p_tab = CBP_9 + ShowBits( &p_vpar->bit_stream, 9 );
1587 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1589 if( p_vpar->sequence.i_chroma_format == CHROMA_420 )
1591 return( p_tab->i_value << 6 );
1593 if( p_vpar->sequence.i_chroma_format == CHROMA_422 )
1595 return( (p_tab->i_value << 6)
1596 | (GetBits( &p_vpar->bit_stream, 2 ) << 4) );
1598 return( (p_tab->i_value << 6)
1599 | GetBits( &p_vpar->bit_stream, 6 ) );
1602 /*****************************************************************************
1603 * MacroblockModes : Get the macroblock_modes structure
1604 *****************************************************************************/
1605 static inline int MacroblockModes( vpar_thread_t * p_vpar, macroblock_t * p_mb,
1606 int i_coding_type, int i_structure )
1611 switch( i_coding_type )
1614 p_tab = MB_I + ShowBits( &p_vpar->bit_stream, 1 );
1615 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1616 i_mb_modes = p_tab->i_value;
1618 if( (i_structure == FRAME_STRUCTURE) &&
1619 (!p_vpar->picture.b_frame_pred_frame_dct) )
1621 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1622 * DCT_TYPE_INTERLACED;
1624 return( i_mb_modes );
1627 p_tab = MB_P + ShowBits( &p_vpar->bit_stream, 5 );
1628 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1629 i_mb_modes = p_tab->i_value;
1631 if( i_structure != FRAME_STRUCTURE )
1633 if( i_mb_modes & MB_MOTION_FORWARD )
1635 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1638 return( i_mb_modes );
1640 else if( p_vpar->picture.b_frame_pred_frame_dct )
1642 if( i_mb_modes & MB_MOTION_FORWARD )
1644 i_mb_modes |= MC_FRAME;
1646 return( i_mb_modes );
1650 if( i_mb_modes & MB_MOTION_FORWARD )
1652 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1655 if( i_mb_modes & (MB_INTRA | MB_PATTERN) )
1657 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1658 * DCT_TYPE_INTERLACED;
1660 return( i_mb_modes );
1664 p_tab = MB_B + ShowBits( &p_vpar->bit_stream, 6 );
1665 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1666 i_mb_modes = p_tab->i_value;
1668 if( i_structure != FRAME_STRUCTURE )
1670 if( !( i_mb_modes & MB_INTRA ) )
1672 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1675 return( i_mb_modes );
1677 else if( p_vpar->picture.b_frame_pred_frame_dct )
1679 i_mb_modes |= MC_FRAME;
1680 return( i_mb_modes );
1684 if( i_mb_modes & MB_INTRA )
1688 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1690 if( i_mb_modes & (MB_INTRA | MB_PATTERN) )
1693 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1694 * DCT_TYPE_INTERLACED;
1696 return( i_mb_modes );
1700 RemoveBits( &p_vpar->bit_stream, 1 );
1710 * Picture data parsing management
1713 /*****************************************************************************
1714 * ParseSlice : Parse the next slice structure
1715 *****************************************************************************/
1716 #define MOTION( pf_routine, i_direction ) \
1717 if( (i_direction) & MB_MOTION_FORWARD ) \
1719 pf_routine( p_vpar, p_mb, &p_vpar->mb.f_motion, 0 ); \
1720 if( (i_coding_type == B_CODING_TYPE) \
1721 && ((i_direction) & MB_MOTION_BACKWARD) ) \
1723 pf_routine( p_vpar, p_mb, &p_vpar->mb.b_motion, 1 ); \
1726 else if( (i_coding_type == B_CODING_TYPE) \
1727 && ((i_direction) & MB_MOTION_BACKWARD) ) \
1729 pf_routine( p_vpar, p_mb, &p_vpar->mb.b_motion, 0 ); \
1732 #define CHECK_BOUNDARIES \
1733 i_offset = p_vpar->mb.i_offset; \
1734 if( i_offset == p_vpar->picture.i_field_width ) \
1736 if( i_coding_type != I_CODING_TYPE || \
1737 p_vpar->picture.b_concealment_mv ) \
1739 p_f_motion->pppi_ref[0][0] += i_lum_vsize; \
1740 p_f_motion->pppi_ref[0][1] += i_chrom_vsize; \
1741 p_f_motion->pppi_ref[0][2] += i_chrom_vsize; \
1743 if( i_coding_type == B_CODING_TYPE ) \
1745 p_b_motion->pppi_ref[0][0] += i_lum_vsize; \
1746 p_b_motion->pppi_ref[0][1] += i_chrom_vsize; \
1747 p_b_motion->pppi_ref[0][2] += i_chrom_vsize; \
1749 p_dest[0] += i_lum_vsize; \
1750 p_dest[1] += i_chrom_vsize; \
1751 p_dest[2] += i_chrom_vsize; \
1754 p_vpar->mb.i_offset = i_offset;
1756 #define PARSEERROR \
1757 if( p_vpar->picture.b_error ) \
1759 /* Go to the next slice. */ \
1760 p_vpar->pool.pf_free_mb( &p_vpar->pool, p_mb ); \
1764 static inline void ParseSlice( vpar_thread_t * p_vpar,
1765 u32 i_vert_code, boolean_t b_mpeg2,
1766 int i_coding_type, int i_structure )
1768 int i_lum_offset, i_chrom_offset, i_offset, i_lum_vsize, i_chrom_vsize;
1769 picture_t * pp_forward_ref[2];
1770 yuv_data_t * p_dest[3];
1772 motion_t * p_f_motion = &p_vpar->mb.f_motion;
1773 motion_t * p_b_motion = &p_vpar->mb.b_motion;
1776 LoadQuantizerScale( p_vpar );
1778 if( GetBits( &p_vpar->bit_stream, 1 ) )
1780 /* intra_slice, slice_id */
1781 RemoveBits( &p_vpar->bit_stream, 8 );
1782 /* extra_information_slice */
1783 while( GetBits( &p_vpar->bit_stream, 1 ) )
1785 RemoveBits( &p_vpar->bit_stream, 8 );
1789 /* Calculate the position of the macroblock. */
1790 i_lum_offset = (i_vert_code - 1) * p_vpar->picture.p_picture->Y_PITCH * 16;
1791 i_chrom_offset = (i_vert_code - 1) * p_vpar->picture.p_picture->U_PITCH
1792 * 8 * (2 - p_vpar->sequence.b_chroma_v_subsampled);
1793 i_lum_vsize = 16 * p_vpar->picture.p_picture->Y_PITCH;
1794 i_chrom_vsize = 8 * (2 - p_vpar->sequence.b_chroma_v_subsampled)
1795 * p_vpar->picture.p_picture->U_PITCH;
1797 /* Initialize motion context. */
1798 pp_forward_ref[0] = p_vpar->sequence.p_forward;
1800 if( i_structure != FRAME_STRUCTURE )
1803 i_chrom_offset <<= 1;
1805 i_chrom_vsize <<= 1;
1807 pp_forward_ref[1] = p_vpar->sequence.p_forward;
1809 if( i_coding_type != B_CODING_TYPE && p_vpar->picture.b_second_field )
1811 pp_forward_ref[!p_vpar->picture.b_current_field] =
1812 p_vpar->picture.p_picture;
1814 if( i_coding_type != I_CODING_TYPE || p_vpar->picture.b_concealment_mv )
1817 p_f_motion->pppi_ref[1][0] = pp_forward_ref[1]->Y_PIXELS +
1818 i_lum_offset + pp_forward_ref[1]->Y_PITCH;
1819 p_f_motion->pppi_ref[1][1] = pp_forward_ref[1]->U_PIXELS +
1820 (i_tmp = i_chrom_offset + pp_forward_ref[1]->U_PITCH);
1821 p_f_motion->pppi_ref[1][2] = pp_forward_ref[1]->V_PIXELS +
1824 if( i_coding_type == B_CODING_TYPE )
1827 p_b_motion->pppi_ref[1][0] = p_vpar->sequence.p_backward->Y_PIXELS
1828 + i_lum_offset + p_vpar->sequence.p_backward->Y_PITCH;
1829 p_b_motion->pppi_ref[1][1] = p_vpar->sequence.p_backward->U_PIXELS
1830 + (i_tmp = i_chrom_offset + p_vpar->sequence.p_backward->U_PITCH);
1831 p_b_motion->pppi_ref[1][2] = p_vpar->sequence.p_backward->V_PIXELS
1836 if( i_coding_type != I_CODING_TYPE || p_vpar->picture.b_concealment_mv )
1838 p_f_motion->pppi_ref[0][0] = pp_forward_ref[0]->Y_PIXELS +
1840 p_f_motion->pppi_ref[0][1] = pp_forward_ref[0]->U_PIXELS +
1842 p_f_motion->pppi_ref[0][2] = pp_forward_ref[0]->V_PIXELS +
1844 p_f_motion->pi_f_code[0] = p_vpar->picture.ppi_f_code[0][0];
1845 p_f_motion->pi_f_code[1] = p_vpar->picture.ppi_f_code[0][1];
1846 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1847 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1850 if( i_coding_type == B_CODING_TYPE )
1852 p_b_motion->pppi_ref[0][0] = p_vpar->sequence.p_backward->Y_PIXELS +
1854 p_b_motion->pppi_ref[0][1] = p_vpar->sequence.p_backward->U_PIXELS +
1856 p_b_motion->pppi_ref[0][2] = p_vpar->sequence.p_backward->V_PIXELS +
1858 p_b_motion->pi_f_code[0] = p_vpar->picture.ppi_f_code[1][0];
1859 p_b_motion->pi_f_code[1] = p_vpar->picture.ppi_f_code[1][1];
1860 p_b_motion->ppi_pmv[0][0] = p_b_motion->ppi_pmv[0][1] = 0;
1861 p_b_motion->ppi_pmv[1][0] = p_b_motion->ppi_pmv[1][1] = 0;
1864 /* Initialize destination pointers. */
1865 p_dest[0] = p_vpar->picture.p_picture->Y_PIXELS +
1867 p_dest[1] = p_vpar->picture.p_picture->U_PIXELS +
1869 p_dest[2] = p_vpar->picture.p_picture->V_PIXELS +
1872 if( i_structure == BOTTOM_FIELD )
1874 p_dest[0] += p_vpar->picture.p_picture->Y_PITCH;
1875 p_dest[1] += p_vpar->picture.p_picture->U_PITCH;
1876 p_dest[2] += p_vpar->picture.p_picture->U_PITCH;
1879 /* Reset intra DC coefficients predictors (ISO/IEC 13818-2 7.2.1). */
1880 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
1881 = p_vpar->mb.pi_dc_dct_pred[2]
1882 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
1884 p_vpar->mb.i_offset = MacroblockAddressIncrement( p_vpar ) << 4;
1886 while( (int)(p_vpar->mb.i_offset - p_vpar->sequence.i_width) >= 0 )
1888 /* Unusual construct at the start of some slices. Jump one line. */
1889 p_vpar->mb.i_offset -= p_vpar->sequence.i_width;
1891 p_dest[0] += i_lum_vsize;
1892 p_dest[1] += i_chrom_vsize;
1893 p_dest[2] += i_chrom_vsize;
1895 p_f_motion->pppi_ref[0][0] += i_lum_vsize;
1896 p_f_motion->pppi_ref[0][1] += i_chrom_vsize;
1897 p_f_motion->pppi_ref[0][2] += i_chrom_vsize;
1899 p_f_motion->pppi_ref[1][0] += i_lum_vsize;
1900 p_f_motion->pppi_ref[1][1] += i_chrom_vsize;
1901 p_f_motion->pppi_ref[1][2] += i_chrom_vsize;
1906 /* Decode macroblocks. */
1907 macroblock_t * p_mb;
1910 /* Get a macroblock structure. */
1911 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
1912 p_mb->i_nb_motions = 0;
1913 p_mb->pp_dest[0] = p_dest[0];
1914 p_mb->pp_dest[1] = p_dest[1];
1915 p_mb->pp_dest[2] = p_dest[2];
1917 /* Parse off macroblock_modes structure. */
1918 p_mb->i_mb_modes = i_mb_modes =
1919 MacroblockModes( p_vpar, p_mb, i_coding_type, i_structure );
1921 if( i_mb_modes & MB_QUANT )
1923 LoadQuantizerScale( p_vpar );
1926 if( i_mb_modes & MB_INTRA )
1928 if( p_vpar->picture.b_concealment_mv )
1930 if( i_structure == FRAME_STRUCTURE )
1932 MotionFrameConceal( p_vpar, p_mb, p_f_motion );
1936 MotionFieldConceal( p_vpar, p_mb, p_f_motion );
1941 /* Reset motion vectors predictors. */
1942 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1943 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1944 p_b_motion->ppi_pmv[0][0] = p_b_motion->ppi_pmv[0][1] = 0;
1945 p_b_motion->ppi_pmv[1][0] = p_b_motion->ppi_pmv[1][1] = 0;
1951 if( p_vpar->picture.b_intra_vlc_format )
1953 MPEG2IntraB15MB( p_vpar, p_mb );
1957 MPEG2IntraB14MB( p_vpar, p_mb );
1962 MPEG1IntraMB( p_vpar, p_mb );
1965 if( i_coding_type == D_CODING_TYPE )
1967 RemoveBits( &p_vpar->bit_stream, 1 );
1972 /* Non-intra block */
1975 if( (i_mb_modes & MOTION_TYPE_MASK) == MC_FRAME )
1977 MOTION( MotionMPEG1, i_mb_modes );
1981 /* Non-intra MB without forward mv in a P picture. */
1982 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1983 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1984 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
1987 else if( i_structure == FRAME_STRUCTURE )
1989 switch( i_mb_modes & MOTION_TYPE_MASK )
1992 MOTION( MotionFrameFrame, i_mb_modes );
1996 MOTION( MotionFrameField, i_mb_modes );
2000 MOTION( MotionFrameDMV, MB_MOTION_FORWARD );
2004 /* Non-intra MB without forward mv in a P picture. */
2005 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2006 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2007 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
2012 /* Field structure. */
2013 switch( i_mb_modes & MOTION_TYPE_MASK )
2016 MOTION( MotionFieldField, i_mb_modes );
2020 MOTION( MotionField16x8, i_mb_modes );
2024 MOTION( MotionFieldDMV, i_mb_modes );
2028 /* Non-intra MB without forward mv in a P picture. */
2029 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2030 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2031 MOTION( MotionFieldZero, MB_MOTION_FORWARD );
2035 /* ISO/IEC 13818-2 6.3.17.4 : Coded Block Pattern */
2036 if( i_mb_modes & MB_PATTERN )
2038 p_mb->i_coded_block_pattern = CodedPattern( p_vpar );
2041 MPEG2NonIntraMB( p_vpar, p_mb );
2045 MPEG1NonIntraMB( p_vpar, p_mb );
2050 p_mb->i_coded_block_pattern = 0;
2053 /* Reset intra DC coefficients predictors. */
2054 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
2055 = p_vpar->mb.pi_dc_dct_pred[2]
2056 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
2059 /* End of macroblock. */
2061 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2063 /* Prepare context for the next macroblock. */
2064 p_vpar->mb.i_offset += 16;
2067 if( ShowBits( &p_vpar->bit_stream, 1 ) )
2069 /* Macroblock Address Increment == 1 */
2070 RemoveBits( &p_vpar->bit_stream, 1 );
2074 /* Check for skipped macroblock(s). */
2077 i_mba_inc = MacroblockAddressIncrement( p_vpar );
2084 /* Reset intra DC predictors. */
2085 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
2086 = p_vpar->mb.pi_dc_dct_pred[2]
2087 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
2089 if( i_coding_type == P_CODING_TYPE )
2091 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2092 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2095 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
2096 p_mb->i_mb_modes = 0;
2097 p_mb->i_nb_motions = 0;
2098 p_mb->i_coded_block_pattern = 0;
2099 p_mb->pp_dest[0] = p_dest[0];
2100 p_mb->pp_dest[1] = p_dest[1];
2101 p_mb->pp_dest[2] = p_dest[2];
2103 if( i_structure == FRAME_STRUCTURE )
2105 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
2109 MOTION( MotionFieldZero, MB_MOTION_FORWARD );
2112 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2113 p_vpar->mb.i_offset += 16;
2115 } while( --i_mba_inc );
2120 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
2121 p_mb->i_mb_modes = 0;
2122 p_mb->i_nb_motions = 0;
2123 p_mb->i_coded_block_pattern = 0;
2124 p_mb->pp_dest[0] = p_dest[0];
2125 p_mb->pp_dest[1] = p_dest[1];
2126 p_mb->pp_dest[2] = p_dest[2];
2130 MOTION( MotionMPEG1Reuse, i_mb_modes );
2132 else if( i_structure == FRAME_STRUCTURE )
2134 MOTION( MotionFrameReuse, i_mb_modes );
2138 MOTION( MotionFieldReuse, i_mb_modes );
2141 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2142 p_vpar->mb.i_offset += 16;
2144 } while( --i_mba_inc );
2149 NextStartCode( &p_vpar->bit_stream );
2152 /*****************************************************************************
2153 * PictureData : Parse off all macroblocks (ISO/IEC 13818-2 6.2.3.7)
2154 *****************************************************************************/
2155 static inline void vpar_PictureData( vpar_thread_t * p_vpar, boolean_t b_mpeg2,
2156 int i_coding_type, int i_structure )
2160 NextStartCode( &p_vpar->bit_stream );
2161 while( !p_vpar->picture.b_error && !p_vpar->p_fifo->b_die )
2163 if( ((i_dummy = ShowBits( &p_vpar->bit_stream, 32 ))
2164 < SLICE_START_CODE_MIN) ||
2165 (i_dummy > SLICE_START_CODE_MAX) )
2169 RemoveBits32( &p_vpar->bit_stream );
2171 /* Decode slice data. */
2172 ParseSlice( p_vpar, i_dummy & 255, b_mpeg2, i_coding_type,
2177 #define DECLARE_PICD( FUNCNAME, B_MPEG2, I_CODING_TYPE, I_STRUCTURE ) \
2178 void FUNCNAME( vpar_thread_t * p_vpar ) \
2180 vpar_PictureData( p_vpar, B_MPEG2, I_CODING_TYPE, I_STRUCTURE ); \
2183 DECLARE_PICD( vpar_PictureDataGENERIC, p_vpar->sequence.b_mpeg2,
2184 p_vpar->picture.i_coding_type, p_vpar->picture.i_structure );
2185 #if (VPAR_OPTIM_LEVEL > 0)
2186 DECLARE_PICD( vpar_PictureData2IF, 1, I_CODING_TYPE, FRAME_STRUCTURE );
2187 DECLARE_PICD( vpar_PictureData2PF, 1, P_CODING_TYPE, FRAME_STRUCTURE );
2188 DECLARE_PICD( vpar_PictureData2BF, 1, B_CODING_TYPE, FRAME_STRUCTURE );
2190 #if (VPAR_OPTIM_LEVEL > 1)
2191 DECLARE_PICD( vpar_PictureData2IT, 1, I_CODING_TYPE, TOP_FIELD );
2192 DECLARE_PICD( vpar_PictureData2PT, 1, P_CODING_TYPE, TOP_FIELD );
2193 DECLARE_PICD( vpar_PictureData2BT, 1, B_CODING_TYPE, TOP_FIELD );
2194 DECLARE_PICD( vpar_PictureData2IB, 1, I_CODING_TYPE, BOTTOM_FIELD );
2195 DECLARE_PICD( vpar_PictureData2PB, 1, P_CODING_TYPE, BOTTOM_FIELD );
2196 DECLARE_PICD( vpar_PictureData2BB, 1, B_CODING_TYPE, BOTTOM_FIELD );
2197 DECLARE_PICD( vpar_PictureData1I, 0, I_CODING_TYPE, FRAME_STRUCTURE );
2198 DECLARE_PICD( vpar_PictureData1P, 0, P_CODING_TYPE, FRAME_STRUCTURE );
2199 DECLARE_PICD( vpar_PictureData1B, 0, B_CODING_TYPE, FRAME_STRUCTURE );
2200 DECLARE_PICD( vpar_PictureData1D, 0, D_CODING_TYPE, FRAME_STRUCTURE );