1 /*****************************************************************************
2 * vpar_blocks.c : blocks parsing
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: vpar_blocks.c,v 1.4 2001/12/10 04:53:11 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 *****************************************************************************/
31 #include <string.h> /* memset */
39 #include "video_output.h"
41 #include "stream_control.h"
42 #include "input_ext-dec.h"
44 #include "vdec_ext-plugins.h"
45 #include "vpar_pool.h"
46 #include "video_parser.h"
48 #include "vpar_blocks.h"
50 #include "modules_export.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,
185 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
187 dct_lookup_t * p_tab;
189 int i_q_scale = p_vpar->mb.i_quantizer_scale;
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,
333 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
335 dct_lookup_t * p_tab;
337 int i_q_scale = p_vpar->mb.i_quantizer_scale;
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,
477 int i_coeff, i_mismatch, i_code, i_pos, i_value, i_nc;
479 dct_lookup_t * p_tab;
481 int i_q_scale = p_vpar->mb.i_quantizer_scale;
482 dctelem_t * p_dest = p_idct->pi_block;
483 u8 * p_scan = p_vpar->picture.pi_scan;
489 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
491 p_tab = DCT_B14DC_5 - 5 + i_code;
501 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
503 p_tab = DCT_B14AC_5 - 5 + i_code;
505 i_coeff += p_tab->i_run;
514 i_pos = p_scan[ i_coeff ];
515 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
516 i_value = ((2 * p_tab->i_level + 1) * i_q_scale * pi_quant[i_pos])
519 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
520 /* if (i_sign) i_value = -i_value; */
521 i_value = (i_value ^ i_sign) - i_sign;
524 p_dest[i_pos] = i_value;
525 i_mismatch ^= i_value;
530 if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
532 p_tab = DCT_B14_8 - 4 + i_code;
533 i_coeff += p_tab->i_run;
536 /* Normal coefficient */
541 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
544 /* Illegal, but needed to avoid overflow */
545 intf_WarnMsg( 2, "MPEG2NonIntra coeff is out of bound" );
546 p_vpar->picture.b_error = 1;
551 i_pos = p_scan[i_coeff];
552 i_value = 2 * (ShowSignedBits( &p_vpar->bit_stream, 1 )
553 + GetSignedBits( &p_vpar->bit_stream, 12 )) + 1;
555 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 32;
558 p_dest[i_pos] = i_value;
559 i_mismatch ^= i_value;
562 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
564 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
565 i_coeff += p_tab->i_run;
571 else if( i_code >= 0x0080 )
573 p_tab = DCT_13 - 16 + (i_code >> 3);
574 i_coeff += p_tab->i_run;
580 else if( i_code >= 0x0020 )
582 p_tab = DCT_15 - 16 + (i_code >> 1);
583 i_coeff += p_tab->i_run;
591 p_tab = DCT_16 + i_code;
592 i_coeff += p_tab->i_run;
599 intf_WarnMsg( 2, "MPEG2NonIntra coeff is out of bound" );
600 p_vpar->picture.b_error = 1;
604 p_dest[63] ^= i_mismatch & 1;
605 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
613 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
614 p_idct->i_sparse_pos = 63;
618 p_idct->pf_idct = p_vpar->pf_idct_add;
623 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
626 p_idct->i_sparse_pos = 0;
630 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
636 p_idct->pf_idct = p_vpar->pf_idct_add;
640 /*****************************************************************************
641 * MPEG1Intra : Decode an MPEG-1 intra block
642 *****************************************************************************/
643 static void MPEG1Intra( vpar_thread_t * p_vpar, idct_inner_t * p_idct,
646 int i_coeff, i_code, i_pos, i_value, i_nc;
648 dct_lookup_t * p_tab;
650 int i_q_scale = p_vpar->mb.i_quantizer_scale;
651 dctelem_t * p_dest = p_idct->pi_block;
652 u8 * p_scan = p_vpar->picture.pi_scan;
655 i_nc = (p_dest[0] != 0);
659 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
661 p_tab = DCT_B14AC_5 - 5 + i_code;
662 i_coeff += p_tab->i_run;
671 i_pos = p_scan[ i_coeff ];
672 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
673 i_value = (p_tab->i_level * i_q_scale * pi_quant[i_pos])
677 i_value = (i_value - 1) | 1;
679 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
680 /* if (i_sign) i_value = -i_value; */
681 i_value = (i_value ^ i_sign) - i_sign;
684 p_dest[i_pos] = i_value;
688 else if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
690 p_tab = DCT_B14_8 - 4 + i_code;
691 i_coeff += p_tab->i_run;
694 /* Normal coefficient */
699 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
702 /* Illegal, but needed to avoid overflow */
703 intf_WarnMsg( 2, "MPEG1Intra coeff is out of bound" );
704 p_vpar->picture.b_error = 1;
709 i_pos = p_scan[i_coeff];
711 i_value = ShowSignedBits( &p_vpar->bit_stream, 8 );
712 if( !(i_value & 0x7F) )
714 RemoveBits( &p_vpar->bit_stream, 8 );
715 i_value = ShowBits( &p_vpar->bit_stream, 8 ) + 2 * i_value;
718 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 16;
721 i_value = (i_value + ~ShowSignedBits( &p_vpar->bit_stream, 1 )) | 1;
724 p_dest[i_pos] = i_value;
725 RemoveBits( &p_vpar->bit_stream, 8 );
728 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
730 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
731 i_coeff += p_tab->i_run;
737 else if( i_code >= 0x0080 )
739 p_tab = DCT_13 - 16 + (i_code >> 3);
740 i_coeff += p_tab->i_run;
746 else if( i_code >= 0x0020 )
748 p_tab = DCT_15 - 16 + (i_code >> 1);
749 i_coeff += p_tab->i_run;
757 p_tab = DCT_16 + i_code;
758 i_coeff += p_tab->i_run;
765 intf_WarnMsg( 2, "MPEG1Intra coeff is out of bound" );
766 p_vpar->picture.b_error = 1;
770 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
774 p_idct->pf_idct = p_vpar->pf_sparse_idct_copy;
775 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
779 p_idct->pf_idct = p_vpar->pf_idct_copy;
783 /*****************************************************************************
784 * MPEG1NonIntra : Decode a non-intra MPEG-1 block
785 *****************************************************************************/
786 static void MPEG1NonIntra( vpar_thread_t * p_vpar, idct_inner_t * p_idct,
789 int i_coeff, i_code, i_pos, i_value, i_nc;
791 dct_lookup_t * p_tab;
793 int i_q_scale = p_vpar->mb.i_quantizer_scale;
794 dctelem_t * p_dest = p_idct->pi_block;
795 u8 * p_scan = p_vpar->picture.pi_scan;
800 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
802 p_tab = DCT_B14DC_5 - 5 + i_code;
812 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 )) >= 0x5 )
814 p_tab = DCT_B14AC_5 - 5 + i_code;
816 i_coeff += p_tab->i_run;
825 i_pos = p_scan[ i_coeff ];
826 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
827 i_value = ((2 * p_tab->i_level + 1) * i_q_scale * pi_quant[i_pos])
831 i_value = (i_value - 1) | 1;
833 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
834 /* if (i_sign) i_value = -i_value; */
835 i_value = (i_value ^ i_sign) - i_sign;
838 p_dest[i_pos] = i_value;
843 if( (i_code = ShowBits( &p_vpar->bit_stream, 8 )) >= 0x4 )
845 p_tab = DCT_B14_8 - 4 + i_code;
846 i_coeff += p_tab->i_run;
849 /* Normal coefficient */
854 i_coeff += (GetBits( &p_vpar->bit_stream, 12 ) & 0x3F) - 64;
857 /* Illegal, but needed to avoid overflow */
858 intf_WarnMsg( 2, "MPEG1NonIntra coeff is out of bound" );
859 p_vpar->picture.b_error = 1;
864 i_pos = p_scan[i_coeff];
865 i_value = ShowSignedBits( &p_vpar->bit_stream, 8 );
866 if( !(i_value & 0x7F) )
868 RemoveBits( &p_vpar->bit_stream, 8 );
869 i_value = ShowBits( &p_vpar->bit_stream, 8 ) + 2 * i_value;
871 i_sign = ShowSignedBits( &p_vpar->bit_stream, 1 );
872 i_value = 2 * (i_sign + i_value) + 1;
873 i_value = (i_value * i_q_scale * pi_quant[i_pos]) / 32;
876 i_value = (i_value + ~i_sign) | 1;
879 p_dest[i_pos] = i_value;
880 RemoveBits( &p_vpar->bit_stream, 8 );
883 else if( (i_code = ShowBits( &p_vpar->bit_stream, 16)) >= 0x0200 )
885 p_tab = DCT_B14_10 - 8 + (i_code >> 6);
886 i_coeff += p_tab->i_run;
892 else if( i_code >= 0x0080 )
894 p_tab = DCT_13 - 16 + (i_code >> 3);
895 i_coeff += p_tab->i_run;
901 else if( i_code >= 0x0020 )
903 p_tab = DCT_15 - 16 + (i_code >> 1);
904 i_coeff += p_tab->i_run;
912 p_tab = DCT_16 + i_code;
913 i_coeff += p_tab->i_run;
920 intf_WarnMsg( 2, "MPEG1NonIntra coeff is out of bound" );
921 p_vpar->picture.b_error = 1;
925 RemoveBits( &p_vpar->bit_stream, 2 ); /* End of Block */
929 p_idct->pf_idct = p_vpar->pf_sparse_idct_add;
932 p_idct->i_sparse_pos = 0;
936 p_idct->i_sparse_pos = i_coeff - p_tab->i_run;
941 p_idct->pf_idct = p_vpar->pf_idct_add;
947 /*****************************************************************************
948 * *MB : decode all blocks of the macroblock
949 *****************************************************************************/
950 #define DECODE_LUMABLOCK( I_B, PF_MBFUNC ) \
951 p_idct = &p_mb->p_idcts[I_B]; \
952 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
953 p_vpar->mb.pi_dc_dct_pred[0] += GetLumaDCDiff( p_vpar ); \
954 p_idct->pi_block[0] = p_vpar->mb.pi_dc_dct_pred[0] \
955 << (3 - p_vpar->picture.i_intra_dc_precision ); \
956 PF_MBFUNC( p_vpar, p_idct, p_vpar->sequence.intra_quant.pi_matrix );
958 #define DECODE_CHROMABLOCK( I_B, PF_MBFUNC, I_CC ) \
959 p_idct = &p_mb->p_idcts[I_B]; \
960 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
961 p_vpar->mb.pi_dc_dct_pred[I_CC] += GetChromaDCDiff( p_vpar ); \
962 p_idct->pi_block[0] = p_vpar->mb.pi_dc_dct_pred[I_CC] \
963 << (3 - p_vpar->picture.i_intra_dc_precision ); \
964 PF_MBFUNC( p_vpar, p_idct, \
965 p_vpar->sequence.chroma_intra_quant.pi_matrix );
967 #define DECLARE_INTRAMB( PSZ_NAME, PF_MBFUNC ) \
968 static __inline__ void PSZ_NAME( vpar_thread_t * p_vpar, \
969 macroblock_t * p_mb ) \
971 idct_inner_t * p_idct; \
974 p_mb->p_y_data = p_mb->pp_dest[0] + p_vpar->mb.i_offset; \
975 p_mb->p_u_data = p_mb->pp_dest[1] + (p_vpar->mb.i_offset \
976 >> p_vpar->sequence.b_chroma_h_subsampled); \
977 p_mb->p_v_data = p_mb->pp_dest[2] + (p_vpar->mb.i_offset \
978 >> p_vpar->sequence.b_chroma_h_subsampled); \
980 DECODE_LUMABLOCK( 0, PF_MBFUNC ); \
981 DECODE_LUMABLOCK( 1, PF_MBFUNC ); \
982 DECODE_LUMABLOCK( 2, PF_MBFUNC ); \
983 DECODE_LUMABLOCK( 3, PF_MBFUNC ); \
987 DECODE_CHROMABLOCK( i_b, PF_MBFUNC, 1 ); \
988 DECODE_CHROMABLOCK( i_b + 1, PF_MBFUNC, 2 ); \
991 while( i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks ); \
994 DECLARE_INTRAMB( MPEG1IntraMB, MPEG1Intra );
995 DECLARE_INTRAMB( MPEG2IntraB14MB, MPEG2IntraB14 );
996 DECLARE_INTRAMB( MPEG2IntraB15MB, MPEG2IntraB15 );
998 #undef DECLARE_INTRAMB
999 #undef DECODE_LUMABLOCK
1000 #undef DECODE_CHROMABLOCK
1002 #define DECODE_LUMABLOCK( I_B, PF_MBFUNC ) \
1003 if( p_mb->i_coded_block_pattern & (1 << (11 - (I_B))) ) \
1005 p_idct = &p_mb->p_idcts[I_B]; \
1006 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
1007 PF_MBFUNC( p_vpar, p_idct, \
1008 p_vpar->sequence.nonintra_quant.pi_matrix ); \
1011 #define DECODE_CHROMABLOCK( I_B, PF_MBFUNC ) \
1012 if( p_mb->i_coded_block_pattern & (1 << (11 - (I_B))) ) \
1014 p_idct = &p_mb->p_idcts[I_B]; \
1015 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
1016 PF_MBFUNC( p_vpar, p_idct, \
1017 p_vpar->sequence.chroma_nonintra_quant.pi_matrix ); \
1020 #define DECLARE_NONINTRAMB( PSZ_NAME, PF_MBFUNC ) \
1021 static __inline__ void PSZ_NAME( vpar_thread_t * p_vpar, \
1022 macroblock_t * p_mb ) \
1024 idct_inner_t * p_idct; \
1027 p_mb->p_y_data = p_mb->pp_dest[0] + p_vpar->mb.i_offset; \
1028 p_mb->p_u_data = p_mb->pp_dest[1] + (p_vpar->mb.i_offset \
1029 >> p_vpar->sequence.b_chroma_h_subsampled); \
1030 p_mb->p_v_data = p_mb->pp_dest[2] + (p_vpar->mb.i_offset \
1031 >> p_vpar->sequence.b_chroma_h_subsampled); \
1033 DECODE_LUMABLOCK( 0, PF_MBFUNC ); \
1034 DECODE_LUMABLOCK( 1, PF_MBFUNC ); \
1035 DECODE_LUMABLOCK( 2, PF_MBFUNC ); \
1036 DECODE_LUMABLOCK( 3, PF_MBFUNC ); \
1040 DECODE_CHROMABLOCK( i_b, PF_MBFUNC ); \
1041 DECODE_CHROMABLOCK( i_b + 1, PF_MBFUNC ); \
1044 while( i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks ); \
1047 DECLARE_NONINTRAMB( MPEG1NonIntraMB, MPEG1NonIntra );
1048 DECLARE_NONINTRAMB( MPEG2NonIntraMB, MPEG2NonIntra );
1050 #undef DECLARE_NONINTRAMB
1051 #undef DECODE_LUMABLOCK
1052 #undef DECODE_CHROMABLOCK
1059 /****************************************************************************
1060 * MotionDelta : Parse the next motion delta
1061 ****************************************************************************/
1062 static __inline__ int MotionDelta( vpar_thread_t * p_vpar, int i_f_code )
1064 int i_delta, i_sign, i_code;
1067 if( ShowBits( &p_vpar->bit_stream, 1 ) )
1069 RemoveBits( &p_vpar->bit_stream, 1 );
1073 if( (i_code = ShowBits( &p_vpar->bit_stream, 6 )) >= 0x3 )
1075 p_tab = MV_4 + (i_code >> 2);
1076 i_delta = (p_tab->i_value << i_f_code) + 1;
1077 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1079 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
1082 i_delta += GetBits( &p_vpar->bit_stream, i_f_code );
1085 return (i_delta ^ i_sign) - i_sign;
1090 p_tab = MV_10 + ShowBits( &p_vpar->bit_stream, 10 );
1091 i_delta = (p_tab->i_value << i_f_code) + 1;
1092 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1094 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
1097 i_delta += GetBits( &p_vpar->bit_stream, i_f_code );
1100 return (i_delta ^ i_sign) - i_sign;
1104 /****************************************************************************
1105 * BoundMotionVector : Bound a motion_vector :-)
1106 ****************************************************************************/
1107 static __inline__ int BoundMotionVector( int i_vector, int i_f_code )
1111 i_limit = 16 << i_f_code;
1113 if( i_vector >= i_limit )
1115 return i_vector - 2 * i_limit;
1117 else if( i_vector < -i_limit)
1119 return i_vector + 2 * i_limit;
1127 /****************************************************************************
1128 * GetDMV : Decode a differential motion vector (Dual Prime Arithmetic)
1129 ****************************************************************************/
1130 static __inline__ int GetDMV( vpar_thread_t * p_vpar )
1132 dmv_lookup_t * p_tab;
1134 p_tab = DMV_2 + ShowBits( &p_vpar->bit_stream, 2 );
1135 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1136 return( p_tab->i_value );
1139 /****************************************************************************
1140 * Motion* : Parse motion vectors
1141 ****************************************************************************/
1142 #define MOTION_BLOCK( b_aver, i_x, i_y, i_dest, \
1143 pp_src, i_src, i_str, i_hei, \
1146 motion_inner_t * p_m_inner = p_mb->p_motions + p_mb->i_nb_motions; \
1147 p_m_inner->b_average = b_aver; \
1148 p_m_inner->i_x_pred = i_x; \
1149 p_m_inner->i_y_pred = i_y; \
1150 p_m_inner->pp_source[0] = pp_src[0]; \
1151 p_m_inner->pp_source[1] = pp_src[1]; \
1152 p_m_inner->pp_source[2] = pp_src[2]; \
1153 p_m_inner->i_dest_offset = i_dest; \
1154 p_m_inner->i_src_offset = i_src; \
1155 p_m_inner->i_stride = i_str; \
1156 p_m_inner->i_height = i_hei; \
1157 p_m_inner->b_second_half = b_s_half; \
1158 p_mb->i_nb_motions++; \
1161 /* MPEG-1 predictions. */
1163 static void MotionMPEG1( vpar_thread_t * p_vpar,
1164 macroblock_t * p_mb,
1165 motion_t * p_motion,
1166 boolean_t b_average )
1168 int i_motion_x, i_motion_y;
1169 int i_offset = p_vpar->mb.i_offset;
1170 int i_width = p_vpar->picture.i_field_width;
1172 i_motion_x = p_motion->ppi_pmv[0][0]
1173 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1174 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1175 p_motion->ppi_pmv[0][0] = i_motion_x;
1177 i_motion_y = p_motion->ppi_pmv[0][1]
1178 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1179 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[0] );
1180 p_motion->ppi_pmv[0][1] = i_motion_y;
1182 if( p_motion->pi_f_code[1] )
1188 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1189 p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1192 static void MotionMPEG1Reuse( vpar_thread_t * p_vpar,
1193 macroblock_t * p_mb,
1194 motion_t * p_motion,
1195 boolean_t b_average )
1197 int i_motion_x, i_motion_y;
1198 int i_offset = p_vpar->mb.i_offset;
1199 int i_width = p_vpar->picture.i_field_width;
1201 i_motion_x = p_motion->ppi_pmv[0][0];
1202 i_motion_y = p_motion->ppi_pmv[0][1];
1204 if( p_motion->pi_f_code[1] )
1210 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1211 i_offset, p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1214 /* MPEG-2 frame predictions. */
1216 static void MotionFrameFrame( vpar_thread_t * p_vpar,
1217 macroblock_t * p_mb,
1218 motion_t * p_motion,
1219 boolean_t b_average )
1221 int i_motion_x, i_motion_y;
1222 int i_offset = p_vpar->mb.i_offset;
1223 int i_width = p_vpar->picture.i_field_width;
1225 i_motion_x = p_motion->ppi_pmv[0][0]
1226 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1227 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1228 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1230 i_motion_y = p_motion->ppi_pmv[0][1]
1231 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1232 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1233 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1235 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1236 p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1239 static void MotionFrameField( vpar_thread_t * p_vpar,
1240 macroblock_t * p_mb,
1241 motion_t * p_motion,
1242 boolean_t b_average )
1244 int i_motion_x, i_motion_y, i_field_select;
1245 int i_offset = p_vpar->mb.i_offset;
1246 int i_width = p_vpar->picture.i_field_width;
1248 i_field_select = GetSignedBits( &p_vpar->bit_stream, 1 );
1250 i_motion_x = p_motion->ppi_pmv[0][0]
1251 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1252 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1253 p_motion->ppi_pmv[0][0] = i_motion_x;
1255 i_motion_y = (p_motion->ppi_pmv[0][1] >> 1)
1256 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1257 /* According to ISO/IEC 13818-2 section 7.6.3.2, the vertical motion
1258 * vector is restricted to a range that implies it doesn't need to
1260 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1261 p_motion->ppi_pmv[0][1] = i_motion_y << 1;
1263 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1264 p_motion->pppi_ref[0], i_offset + (i_field_select & i_width),
1265 i_width * 2, 8, 0 );
1267 i_field_select = GetSignedBits( &p_vpar->bit_stream, 1 );
1269 i_motion_x = p_motion->ppi_pmv[1][0]
1270 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1271 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1272 p_motion->ppi_pmv[1][0] = i_motion_x;
1274 i_motion_y = (p_motion->ppi_pmv[1][1] >> 1)
1275 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1276 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1277 p_motion->ppi_pmv[1][1] = i_motion_y << 1;
1279 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset + i_width,
1280 p_motion->pppi_ref[0], i_offset + (i_field_select & i_width),
1281 i_width * 2, 8, 0 );
1284 static void MotionFrameDMV( vpar_thread_t * p_vpar,
1285 macroblock_t * p_mb,
1286 motion_t * p_motion,
1287 boolean_t b_average )
1289 int i_motion_x, i_motion_y;
1290 int i_dmv_x, i_dmv_y;
1291 int i_tmp_x, i_tmp_y;
1293 int i_offset = p_vpar->mb.i_offset;
1294 int i_width = p_vpar->picture.i_field_width;
1297 i_motion_x = p_motion->ppi_pmv[0][0]
1298 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1299 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1300 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1302 i_dmv_x = GetDMV( p_vpar );
1304 i_motion_y = (p_motion->ppi_pmv[0][1] >> 1)
1305 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1306 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1307 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y << 1;
1309 i_dmv_y = GetDMV( p_vpar );
1312 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset,
1313 p_motion->pppi_ref[0], i_offset, i_width * 2, 8, 0 );
1314 m = p_vpar->picture.b_top_field_first ? 1 : 3;
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, p_motion->pppi_ref[0],
1318 i_offset + i_width, i_width * 2, 8, 0 );
1321 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset + i_width,
1322 p_motion->pppi_ref[0], i_offset + i_width, i_width * 2, 8, 0 );
1323 m = p_vpar->picture.b_top_field_first ? 3 : 1;
1324 i_tmp_x = ((i_motion_x * m + (i_motion_x > 0)) >> 1) + i_dmv_x;
1325 i_tmp_y = ((i_motion_y * m + (i_motion_y > 0)) >> 1) + i_dmv_y + 1;
1326 MOTION_BLOCK( 1, i_tmp_x, i_tmp_y, i_offset + i_width,
1327 p_motion->pppi_ref[0], i_offset, i_width * 2, 8, 0 );
1330 static void MotionFrameZero( vpar_thread_t * p_vpar,
1331 macroblock_t * p_mb,
1332 motion_t * p_motion,
1333 boolean_t b_average )
1335 int i_offset = p_vpar->mb.i_offset;
1336 int i_width = p_vpar->picture.i_field_width;
1338 MOTION_BLOCK( b_average, 0, 0, i_offset, p_motion->pppi_ref[0],
1339 i_offset, i_width, 16, 0 );
1342 static void MotionFrameReuse( vpar_thread_t * p_vpar,
1343 macroblock_t * p_mb,
1344 motion_t * p_motion,
1345 boolean_t b_average )
1347 int i_offset = p_vpar->mb.i_offset;
1348 int i_width = p_vpar->picture.i_field_width;
1350 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1351 i_offset, p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1354 /* MPEG-2 field predictions. */
1356 static void MotionFieldField( vpar_thread_t * p_vpar,
1357 macroblock_t * p_mb,
1358 motion_t * p_motion,
1359 boolean_t b_average )
1361 int i_motion_x, i_motion_y;
1362 boolean_t b_field_select;
1363 int i_offset = p_vpar->mb.i_offset;
1364 int i_width = p_vpar->picture.i_field_width;
1366 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1368 i_motion_x = p_motion->ppi_pmv[0][0]
1369 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1370 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1371 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1373 i_motion_y = p_motion->ppi_pmv[0][1]
1374 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1375 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1376 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1378 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1379 p_motion->pppi_ref[b_field_select], i_offset, i_width, 16, 0 );
1382 static void MotionField16x8( vpar_thread_t * p_vpar,
1383 macroblock_t * p_mb,
1384 motion_t * p_motion,
1385 boolean_t b_average )
1387 int i_motion_x, i_motion_y;
1388 boolean_t b_field_select;
1389 int i_offset = p_vpar->mb.i_offset;
1390 int i_width = p_vpar->picture.i_field_width;
1393 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1395 i_motion_x = p_motion->ppi_pmv[0][0]
1396 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1397 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1398 p_motion->ppi_pmv[0][0] = i_motion_x;
1400 i_motion_y = p_motion->ppi_pmv[0][1]
1401 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1402 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1403 p_motion->ppi_pmv[0][1] = i_motion_y;
1405 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1406 p_motion->pppi_ref[b_field_select], i_offset, i_width, 8, 0 );
1409 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1411 i_motion_x = p_motion->ppi_pmv[1][0]
1412 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1413 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1414 p_motion->ppi_pmv[1][0] = i_motion_x;
1416 i_motion_y = p_motion->ppi_pmv[1][1]
1417 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1418 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1419 p_motion->ppi_pmv[1][1] = i_motion_y;
1421 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1422 p_motion->pppi_ref[b_field_select], i_offset, i_width, 8, 1 );
1425 static void MotionFieldDMV( vpar_thread_t * p_vpar,
1426 macroblock_t * p_mb,
1427 motion_t * p_motion,
1428 boolean_t b_average )
1430 int i_motion_x, i_motion_y;
1431 int i_dmv_x, i_dmv_y;
1432 int i_offset = p_vpar->mb.i_offset;
1433 int i_width = p_vpar->picture.i_field_width;
1434 boolean_t b_current_field = p_vpar->picture.b_current_field;
1436 i_motion_x = p_motion->ppi_pmv[0][0]
1437 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1438 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1439 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1441 i_dmv_x = GetDMV( p_vpar );
1443 i_motion_y = p_motion->ppi_pmv[0][1]
1444 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1445 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1446 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1448 i_dmv_y = GetDMV( p_vpar );
1450 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset,
1451 p_motion->pppi_ref[b_current_field],
1452 i_offset, i_width, 16, 0 );
1454 i_motion_x = ((i_motion_x + (i_motion_x > 0)) >> 1) + i_dmv_x;
1455 i_motion_y = ((i_motion_y + (i_motion_y > 0)) >> 1) + i_dmv_y
1456 + 2 * b_current_field - 1;
1457 MOTION_BLOCK( 1, i_motion_x, i_motion_y, i_offset,
1458 p_motion->pppi_ref[!b_current_field],
1459 i_offset, i_width, 16, 0 );
1462 static void MotionFieldZero( vpar_thread_t * p_vpar,
1463 macroblock_t * p_mb,
1464 motion_t * p_motion,
1465 boolean_t b_average )
1467 int i_offset = p_vpar->mb.i_offset;
1468 int i_width = p_vpar->picture.i_field_width;
1469 boolean_t b_current_field = p_vpar->picture.b_current_field;
1471 MOTION_BLOCK( b_average, 0, 0, i_offset, p_motion->pppi_ref[b_current_field],
1472 i_offset, i_width, 16, 0 );
1475 static void MotionFieldReuse( vpar_thread_t * p_vpar,
1476 macroblock_t * p_mb,
1477 motion_t * p_motion,
1478 boolean_t b_average )
1480 int i_offset = p_vpar->mb.i_offset;
1481 int i_width = p_vpar->picture.i_field_width;
1482 boolean_t b_current_field = p_vpar->picture.b_current_field;
1484 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1485 i_offset, p_motion->pppi_ref[b_current_field],
1486 i_offset, i_width, 16, 0 );
1489 /* MPEG-2 concealment motion vectors. */
1491 static void MotionFrameConceal( vpar_thread_t * p_vpar,
1492 macroblock_t * p_mv,
1493 motion_t * p_motion )
1497 i_tmp = p_motion->ppi_pmv[0][0]
1498 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1499 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[0] );
1500 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_tmp;
1502 i_tmp = p_motion->ppi_pmv[0][1]
1503 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1504 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[1] );
1505 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_tmp;
1508 RemoveBits( &p_vpar->bit_stream, 1 );
1511 static void MotionFieldConceal( vpar_thread_t * p_vpar,
1512 macroblock_t * p_mv,
1513 motion_t * p_motion )
1518 RemoveBits( &p_vpar->bit_stream, 1 );
1520 i_tmp = p_motion->ppi_pmv[0][0]
1521 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1522 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[0] );
1523 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_tmp;
1525 i_tmp = p_motion->ppi_pmv[0][1]
1526 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1527 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[1] );
1528 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_tmp;
1531 RemoveBits( &p_vpar->bit_stream, 1 );
1536 * Macroblock information structures
1539 /*****************************************************************************
1540 * MacroblockAddressIncrement : Get the macroblock_address_increment field
1541 *****************************************************************************/
1542 static __inline__ int MacroblockAddressIncrement( vpar_thread_t * p_vpar )
1550 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 ) ) >= 0x2 )
1552 p_tab = MBA_5 - 2 + i_code;
1553 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1554 return( i_mba + p_tab->i_value );
1556 else if( (i_code = ShowBits( &p_vpar->bit_stream, 11 )) >= 0x18 )
1558 p_tab = MBA_11 - 24 + i_code;
1559 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1560 return( i_mba + p_tab->i_value );
1562 else switch( i_code )
1565 /* Macroblock escape */
1569 /* Macroblock stuffing (MPEG-1 ONLY) */
1570 RemoveBits( &p_vpar->bit_stream, 11 );
1574 /* End of slice, or error */
1580 /*****************************************************************************
1581 * CodedPattern : coded_block_pattern
1582 *****************************************************************************/
1583 static __inline__ int CodedPattern( vpar_thread_t * p_vpar )
1588 if( (i_code = ShowBits( &p_vpar->bit_stream, 7 )) >= 0x10 )
1590 p_tab = CBP_7 - 16 + i_code;
1591 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1595 p_tab = CBP_9 + ShowBits( &p_vpar->bit_stream, 9 );
1596 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1598 if( p_vpar->sequence.i_chroma_format == CHROMA_420 )
1600 return( p_tab->i_value << 6 );
1602 if( p_vpar->sequence.i_chroma_format == CHROMA_422 )
1604 return( (p_tab->i_value << 6)
1605 | (GetBits( &p_vpar->bit_stream, 2 ) << 4) );
1607 return( (p_tab->i_value << 6)
1608 | GetBits( &p_vpar->bit_stream, 6 ) );
1611 /*****************************************************************************
1612 * MacroblockModes : Get the macroblock_modes structure
1613 *****************************************************************************/
1614 static __inline__ int MacroblockModes( vpar_thread_t * p_vpar,
1615 macroblock_t * p_mb,
1622 switch( i_coding_type )
1625 p_tab = MB_I + ShowBits( &p_vpar->bit_stream, 1 );
1626 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1627 i_mb_modes = p_tab->i_value;
1629 if( (i_structure == FRAME_STRUCTURE) &&
1630 (!p_vpar->picture.b_frame_pred_frame_dct) )
1632 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1633 * DCT_TYPE_INTERLACED;
1635 return( i_mb_modes );
1638 p_tab = MB_P + ShowBits( &p_vpar->bit_stream, 5 );
1639 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1640 i_mb_modes = p_tab->i_value;
1642 if( i_structure != FRAME_STRUCTURE )
1644 if( i_mb_modes & MB_MOTION_FORWARD )
1646 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1649 return( i_mb_modes );
1651 else if( p_vpar->picture.b_frame_pred_frame_dct )
1653 if( i_mb_modes & MB_MOTION_FORWARD )
1655 i_mb_modes |= MC_FRAME;
1657 return( i_mb_modes );
1661 if( i_mb_modes & MB_MOTION_FORWARD )
1663 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1666 if( i_mb_modes & (MB_INTRA | MB_PATTERN) )
1668 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1669 * DCT_TYPE_INTERLACED;
1671 return( i_mb_modes );
1675 p_tab = MB_B + ShowBits( &p_vpar->bit_stream, 6 );
1676 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1677 i_mb_modes = p_tab->i_value;
1679 if( i_structure != FRAME_STRUCTURE )
1681 if( !( i_mb_modes & MB_INTRA ) )
1683 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1686 return( i_mb_modes );
1688 else if( p_vpar->picture.b_frame_pred_frame_dct )
1690 i_mb_modes |= MC_FRAME;
1691 return( i_mb_modes );
1695 if( i_mb_modes & MB_INTRA )
1699 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1701 if( i_mb_modes & (MB_INTRA | MB_PATTERN) )
1704 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1705 * DCT_TYPE_INTERLACED;
1707 return( i_mb_modes );
1711 RemoveBits( &p_vpar->bit_stream, 1 );
1721 * Picture data parsing management
1724 /*****************************************************************************
1725 * ParseSlice : Parse the next slice structure
1726 *****************************************************************************/
1727 #define MOTION( pf_routine, i_direction ) \
1728 if( (i_direction) & MB_MOTION_FORWARD ) \
1730 pf_routine( p_vpar, p_mb, &p_vpar->mb.f_motion, 0 ); \
1731 if( (i_coding_type == B_CODING_TYPE) \
1732 && ((i_direction) & MB_MOTION_BACKWARD) ) \
1734 pf_routine( p_vpar, p_mb, &p_vpar->mb.b_motion, 1 ); \
1737 else if( (i_coding_type == B_CODING_TYPE) \
1738 && ((i_direction) & MB_MOTION_BACKWARD) ) \
1740 pf_routine( p_vpar, p_mb, &p_vpar->mb.b_motion, 0 ); \
1743 #define CHECK_BOUNDARIES \
1744 i_offset = p_vpar->mb.i_offset; \
1745 if( i_offset == i_width ) \
1747 if( i_coding_type != I_CODING_TYPE || \
1748 p_vpar->picture.b_concealment_mv ) \
1750 p_f_motion->pppi_ref[0][0] += 16 * i_offset; \
1751 p_f_motion->pppi_ref[0][1] += i_chroma_tmp; \
1752 p_f_motion->pppi_ref[0][2] += i_chroma_tmp; \
1754 if( i_coding_type == B_CODING_TYPE ) \
1756 p_b_motion->pppi_ref[0][0] += 16 * i_offset; \
1757 p_b_motion->pppi_ref[0][1] += i_chroma_tmp; \
1758 p_b_motion->pppi_ref[0][2] += i_chroma_tmp; \
1760 p_dest[0] += 16 * i_offset; \
1761 p_dest[1] += 4 * i_offset; \
1762 p_dest[2] += 4 * i_offset; \
1765 p_vpar->mb.i_offset = i_offset;
1767 #define PARSEERROR \
1768 if( p_vpar->picture.b_error ) \
1770 /* Go to the next slice. */ \
1771 p_vpar->pool.pf_free_mb( &p_vpar->pool, p_mb ); \
1775 static __inline__ void ParseSlice( vpar_thread_t * p_vpar,
1776 u32 i_vert_code, boolean_t b_mpeg2,
1777 int i_coding_type, int i_structure )
1779 int i_offset, i_width, i_chroma_tmp;
1780 picture_t * pp_forward_ref[2];
1781 yuv_data_t * p_dest[3];
1783 motion_t * p_f_motion = &p_vpar->mb.f_motion;
1784 motion_t * p_b_motion = &p_vpar->mb.b_motion;
1787 LoadQuantizerScale( p_vpar );
1789 if( GetBits( &p_vpar->bit_stream, 1 ) )
1791 /* intra_slice, slice_id */
1792 RemoveBits( &p_vpar->bit_stream, 8 );
1793 /* extra_information_slice */
1794 while( GetBits( &p_vpar->bit_stream, 1 ) )
1796 RemoveBits( &p_vpar->bit_stream, 8 );
1800 /* Calculate the position of the macroblock. */
1801 i_width = p_vpar->sequence.i_width;
1802 i_offset = (i_vert_code - 1) * i_width * 4;
1804 /* Initialize motion context. */
1805 pp_forward_ref[0] = p_vpar->sequence.p_forward;
1807 if( i_structure != FRAME_STRUCTURE )
1811 i_offset * (2 - p_vpar->sequence.b_chroma_v_subsampled)
1812 * (2 - p_vpar->sequence.b_chroma_h_subsampled)
1813 + (i_width >> p_vpar->sequence.b_chroma_h_subsampled);
1814 pp_forward_ref[1] = p_vpar->sequence.p_forward;
1816 if( i_coding_type != B_CODING_TYPE && p_vpar->picture.b_second_field )
1818 pp_forward_ref[!p_vpar->picture.b_current_field] =
1819 p_vpar->picture.p_picture;
1821 if( i_coding_type != I_CODING_TYPE || p_vpar->picture.b_concealment_mv )
1823 p_f_motion->pppi_ref[1][0] =
1824 pp_forward_ref[1]->P_Y + i_offset * 4 + i_width;
1825 p_f_motion->pppi_ref[1][1] =
1826 pp_forward_ref[1]->P_U + i_chroma_tmp;
1827 p_f_motion->pppi_ref[1][2] =
1828 pp_forward_ref[1]->P_V + i_chroma_tmp;
1830 if( i_coding_type == B_CODING_TYPE )
1832 p_b_motion->pppi_ref[1][0] =
1833 p_vpar->sequence.p_backward->P_Y + i_offset * 4 + i_width;
1834 p_b_motion->pppi_ref[1][1] =
1835 p_vpar->sequence.p_backward->P_U + i_chroma_tmp;
1836 p_b_motion->pppi_ref[1][2] =
1837 p_vpar->sequence.p_backward->P_V + i_chroma_tmp;
1841 i_chroma_tmp = i_offset
1842 * (2 - p_vpar->sequence.b_chroma_v_subsampled)
1843 * (2 - p_vpar->sequence.b_chroma_h_subsampled);
1844 if( i_coding_type != I_CODING_TYPE || p_vpar->picture.b_concealment_mv )
1846 p_f_motion->pppi_ref[0][0] = pp_forward_ref[0]->P_Y + i_offset * 4;
1847 p_f_motion->pppi_ref[0][1] = pp_forward_ref[0]->P_U + i_chroma_tmp;
1848 p_f_motion->pppi_ref[0][2] = pp_forward_ref[0]->P_V + i_chroma_tmp;
1849 p_f_motion->pi_f_code[0] = p_vpar->picture.ppi_f_code[0][0];
1850 p_f_motion->pi_f_code[1] = p_vpar->picture.ppi_f_code[0][1];
1851 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1852 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1855 if( i_coding_type == B_CODING_TYPE )
1857 p_b_motion->pppi_ref[0][0] = p_vpar->sequence.p_backward->P_Y
1859 p_b_motion->pppi_ref[0][1] = p_vpar->sequence.p_backward->P_U
1861 p_b_motion->pppi_ref[0][2] = p_vpar->sequence.p_backward->P_V
1863 p_b_motion->pi_f_code[0] = p_vpar->picture.ppi_f_code[1][0];
1864 p_b_motion->pi_f_code[1] = p_vpar->picture.ppi_f_code[1][1];
1865 p_b_motion->ppi_pmv[0][0] = p_b_motion->ppi_pmv[0][1] = 0;
1866 p_b_motion->ppi_pmv[1][0] = p_b_motion->ppi_pmv[1][1] = 0;
1869 /* Initialize destination pointers. */
1870 p_dest[0] = p_vpar->picture.p_picture->P_Y + i_offset * 4;
1871 p_dest[1] = p_vpar->picture.p_picture->P_U + i_chroma_tmp;
1872 p_dest[2] = p_vpar->picture.p_picture->P_V + i_chroma_tmp;
1874 if( i_structure == BOTTOM_FIELD )
1876 p_dest[0] += i_width;
1877 p_dest[1] += i_width >> p_vpar->sequence.b_chroma_h_subsampled;
1878 p_dest[2] += i_width >> p_vpar->sequence.b_chroma_h_subsampled;
1880 i_width = p_vpar->picture.i_field_width;
1882 /* Reset intra DC coefficients predictors (ISO/IEC 13818-2 7.2.1). */
1883 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
1884 = p_vpar->mb.pi_dc_dct_pred[2]
1885 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
1887 p_vpar->mb.i_offset = MacroblockAddressIncrement( p_vpar ) << 4;
1889 i_chroma_tmp = i_width * 4
1890 * (2 - p_vpar->sequence.b_chroma_v_subsampled)
1891 * (2 - p_vpar->sequence.b_chroma_h_subsampled);
1892 while( (int)(p_vpar->mb.i_offset - p_vpar->sequence.i_width) >= 0 )
1894 /* Unusual construct at the start of some slices. Jump one line. */
1895 p_vpar->mb.i_offset -= p_vpar->sequence.i_width;
1896 p_dest[0] += i_width * 16;
1897 p_dest[1] += i_chroma_tmp;
1898 p_dest[2] += i_chroma_tmp;
1899 p_f_motion->pppi_ref[0][0] += i_width * 16;
1900 p_f_motion->pppi_ref[0][1] += i_chroma_tmp;
1901 p_f_motion->pppi_ref[0][2] += i_chroma_tmp;
1902 p_f_motion->pppi_ref[1][0] += i_width * 16;
1903 p_f_motion->pppi_ref[1][1] += i_chroma_tmp;
1904 p_f_motion->pppi_ref[1][2] += i_chroma_tmp;
1909 /* Decode macroblocks. */
1910 macroblock_t * p_mb;
1913 /* Get a macroblock structure. */
1914 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
1915 p_mb->i_nb_motions = 0;
1916 p_mb->pp_dest[0] = p_dest[0];
1917 p_mb->pp_dest[1] = p_dest[1];
1918 p_mb->pp_dest[2] = p_dest[2];
1920 /* Parse off macroblock_modes structure. */
1921 p_mb->i_mb_modes = i_mb_modes =
1922 MacroblockModes( p_vpar, p_mb, i_coding_type, i_structure );
1924 if( i_mb_modes & MB_QUANT )
1926 LoadQuantizerScale( p_vpar );
1929 if( i_mb_modes & MB_INTRA )
1931 if( p_vpar->picture.b_concealment_mv )
1933 if( i_structure == FRAME_STRUCTURE )
1935 MotionFrameConceal( p_vpar, p_mb, p_f_motion );
1939 MotionFieldConceal( p_vpar, p_mb, p_f_motion );
1944 /* Reset motion vectors predictors. */
1945 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1946 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1947 p_b_motion->ppi_pmv[0][0] = p_b_motion->ppi_pmv[0][1] = 0;
1948 p_b_motion->ppi_pmv[1][0] = p_b_motion->ppi_pmv[1][1] = 0;
1954 if( p_vpar->picture.b_intra_vlc_format )
1956 MPEG2IntraB15MB( p_vpar, p_mb );
1960 MPEG2IntraB14MB( p_vpar, p_mb );
1965 MPEG1IntraMB( p_vpar, p_mb );
1968 if( i_coding_type == D_CODING_TYPE )
1970 RemoveBits( &p_vpar->bit_stream, 1 );
1975 /* Non-intra block */
1978 if( (i_mb_modes & MOTION_TYPE_MASK) == MC_FRAME )
1980 MOTION( MotionMPEG1, i_mb_modes );
1984 /* Non-intra MB without forward mv in a P picture. */
1985 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1986 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1987 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
1990 else if( i_structure == FRAME_STRUCTURE )
1992 switch( i_mb_modes & MOTION_TYPE_MASK )
1995 MOTION( MotionFrameFrame, i_mb_modes );
1999 MOTION( MotionFrameField, i_mb_modes );
2003 MOTION( MotionFrameDMV, MB_MOTION_FORWARD );
2007 /* Non-intra MB without forward mv in a P picture. */
2008 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2009 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2010 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
2015 /* Field structure. */
2016 switch( i_mb_modes & MOTION_TYPE_MASK )
2019 MOTION( MotionFieldField, i_mb_modes );
2023 MOTION( MotionField16x8, i_mb_modes );
2027 MOTION( MotionFieldDMV, i_mb_modes );
2031 /* Non-intra MB without forward mv in a P picture. */
2032 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2033 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2034 MOTION( MotionFieldZero, MB_MOTION_FORWARD );
2038 /* ISO/IEC 13818-2 6.3.17.4 : Coded Block Pattern */
2039 if( i_mb_modes & MB_PATTERN )
2041 p_mb->i_coded_block_pattern = CodedPattern( p_vpar );
2044 MPEG2NonIntraMB( p_vpar, p_mb );
2048 MPEG1NonIntraMB( p_vpar, p_mb );
2053 p_mb->i_coded_block_pattern = 0;
2056 /* Reset intra DC coefficients predictors. */
2057 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
2058 = p_vpar->mb.pi_dc_dct_pred[2]
2059 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
2062 /* End of macroblock. */
2064 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2066 /* Prepare context for the next macroblock. */
2067 p_vpar->mb.i_offset += 16;
2070 if( ShowBits( &p_vpar->bit_stream, 1 ) )
2072 /* Macroblock Address Increment == 1 */
2073 RemoveBits( &p_vpar->bit_stream, 1 );
2077 /* Check for skipped macroblock(s). */
2080 i_mba_inc = MacroblockAddressIncrement( p_vpar );
2087 /* Reset intra DC predictors. */
2088 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
2089 = p_vpar->mb.pi_dc_dct_pred[2]
2090 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
2092 if( i_coding_type == P_CODING_TYPE )
2094 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2095 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2098 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
2099 p_mb->i_mb_modes = 0;
2100 p_mb->i_nb_motions = 0;
2101 p_mb->i_coded_block_pattern = 0;
2102 p_mb->pp_dest[0] = p_dest[0];
2103 p_mb->pp_dest[1] = p_dest[1];
2104 p_mb->pp_dest[2] = p_dest[2];
2106 if( i_structure == FRAME_STRUCTURE )
2108 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
2112 MOTION( MotionFieldZero, MB_MOTION_FORWARD );
2115 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2116 p_vpar->mb.i_offset += 16;
2118 } while( --i_mba_inc );
2123 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
2124 p_mb->i_mb_modes = 0;
2125 p_mb->i_nb_motions = 0;
2126 p_mb->i_coded_block_pattern = 0;
2127 p_mb->pp_dest[0] = p_dest[0];
2128 p_mb->pp_dest[1] = p_dest[1];
2129 p_mb->pp_dest[2] = p_dest[2];
2133 MOTION( MotionMPEG1Reuse, i_mb_modes );
2135 else if( i_structure == FRAME_STRUCTURE )
2137 MOTION( MotionFrameReuse, i_mb_modes );
2141 MOTION( MotionFieldReuse, i_mb_modes );
2144 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2145 p_vpar->mb.i_offset += 16;
2147 } while( --i_mba_inc );
2152 NextStartCode( &p_vpar->bit_stream );
2155 /*****************************************************************************
2156 * PictureData : Parse off all macroblocks (ISO/IEC 13818-2 6.2.3.7)
2157 *****************************************************************************/
2158 static __inline__ void vpar_PictureData( vpar_thread_t * p_vpar,
2160 int i_coding_type, int i_structure )
2164 NextStartCode( &p_vpar->bit_stream );
2165 while( !p_vpar->picture.b_error && !p_vpar->p_fifo->b_die )
2167 if( ((i_dummy = ShowBits( &p_vpar->bit_stream, 32 ))
2168 < SLICE_START_CODE_MIN) ||
2169 (i_dummy > SLICE_START_CODE_MAX) )
2173 RemoveBits32( &p_vpar->bit_stream );
2175 /* Decode slice data. */
2176 ParseSlice( p_vpar, i_dummy & 255, b_mpeg2, i_coding_type,
2181 #define DECLARE_PICD( FUNCNAME, B_MPEG2, I_CODING_TYPE, I_STRUCTURE ) \
2182 void FUNCNAME( vpar_thread_t * p_vpar ) \
2184 vpar_PictureData( p_vpar, B_MPEG2, I_CODING_TYPE, I_STRUCTURE ); \
2187 DECLARE_PICD( vpar_PictureDataGENERIC, p_vpar->sequence.b_mpeg2,
2188 p_vpar->picture.i_coding_type, p_vpar->picture.i_structure );
2189 #if (VPAR_OPTIM_LEVEL > 0)
2190 DECLARE_PICD( vpar_PictureData2IF, 1, I_CODING_TYPE, FRAME_STRUCTURE );
2191 DECLARE_PICD( vpar_PictureData2PF, 1, P_CODING_TYPE, FRAME_STRUCTURE );
2192 DECLARE_PICD( vpar_PictureData2BF, 1, B_CODING_TYPE, FRAME_STRUCTURE );
2194 #if (VPAR_OPTIM_LEVEL > 1)
2195 DECLARE_PICD( vpar_PictureData2IT, 1, I_CODING_TYPE, TOP_FIELD );
2196 DECLARE_PICD( vpar_PictureData2PT, 1, P_CODING_TYPE, TOP_FIELD );
2197 DECLARE_PICD( vpar_PictureData2BT, 1, B_CODING_TYPE, TOP_FIELD );
2198 DECLARE_PICD( vpar_PictureData2IB, 1, I_CODING_TYPE, BOTTOM_FIELD );
2199 DECLARE_PICD( vpar_PictureData2PB, 1, P_CODING_TYPE, BOTTOM_FIELD );
2200 DECLARE_PICD( vpar_PictureData2BB, 1, B_CODING_TYPE, BOTTOM_FIELD );
2201 DECLARE_PICD( vpar_PictureData1I, 0, I_CODING_TYPE, FRAME_STRUCTURE );
2202 DECLARE_PICD( vpar_PictureData1P, 0, P_CODING_TYPE, FRAME_STRUCTURE );
2203 DECLARE_PICD( vpar_PictureData1B, 0, B_CODING_TYPE, FRAME_STRUCTURE );
2204 DECLARE_PICD( vpar_PictureData1D, 0, D_CODING_TYPE, FRAME_STRUCTURE );