1 /*****************************************************************************
2 * vpar_blocks.c : blocks parsing
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: vpar_blocks.c,v 1.5 2001/12/30 07:09:56 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, "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, "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, "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, "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, "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, "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, \
962 macroblock_t * p_mb ) \
964 idct_inner_t * p_idct; \
967 p_mb->p_y_data = p_mb->pp_dest[0] + p_vpar->mb.i_offset; \
968 p_mb->p_u_data = p_mb->pp_dest[1] + (p_vpar->mb.i_offset \
969 >> p_vpar->sequence.b_chroma_h_subsampled); \
970 p_mb->p_v_data = p_mb->pp_dest[2] + (p_vpar->mb.i_offset \
971 >> p_vpar->sequence.b_chroma_h_subsampled); \
973 DECODE_LUMABLOCK( 0, PF_MBFUNC ); \
974 DECODE_LUMABLOCK( 1, PF_MBFUNC ); \
975 DECODE_LUMABLOCK( 2, PF_MBFUNC ); \
976 DECODE_LUMABLOCK( 3, PF_MBFUNC ); \
980 DECODE_CHROMABLOCK( i_b, PF_MBFUNC, 1 ); \
981 DECODE_CHROMABLOCK( i_b + 1, PF_MBFUNC, 2 ); \
984 while( i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks ); \
987 DECLARE_INTRAMB( MPEG1IntraMB, MPEG1Intra );
988 DECLARE_INTRAMB( MPEG2IntraB14MB, MPEG2IntraB14 );
989 DECLARE_INTRAMB( MPEG2IntraB15MB, MPEG2IntraB15 );
991 #undef DECLARE_INTRAMB
992 #undef DECODE_LUMABLOCK
993 #undef DECODE_CHROMABLOCK
995 #define DECODE_LUMABLOCK( I_B, PF_MBFUNC ) \
996 if( p_mb->i_coded_block_pattern & (1 << (11 - (I_B))) ) \
998 p_idct = &p_mb->p_idcts[I_B]; \
999 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
1000 PF_MBFUNC( p_vpar, p_idct, \
1001 p_vpar->sequence.nonintra_quant.pi_matrix ); \
1004 #define DECODE_CHROMABLOCK( I_B, PF_MBFUNC ) \
1005 if( p_mb->i_coded_block_pattern & (1 << (11 - (I_B))) ) \
1007 p_idct = &p_mb->p_idcts[I_B]; \
1008 memset( p_idct->pi_block, 0, 64*sizeof(dctelem_t) ); \
1009 PF_MBFUNC( p_vpar, p_idct, \
1010 p_vpar->sequence.chroma_nonintra_quant.pi_matrix ); \
1013 #define DECLARE_NONINTRAMB( PSZ_NAME, PF_MBFUNC ) \
1014 static __inline__ void PSZ_NAME( vpar_thread_t * p_vpar, \
1015 macroblock_t * p_mb ) \
1017 idct_inner_t * p_idct; \
1020 p_mb->p_y_data = p_mb->pp_dest[0] + p_vpar->mb.i_offset; \
1021 p_mb->p_u_data = p_mb->pp_dest[1] + (p_vpar->mb.i_offset \
1022 >> p_vpar->sequence.b_chroma_h_subsampled); \
1023 p_mb->p_v_data = p_mb->pp_dest[2] + (p_vpar->mb.i_offset \
1024 >> p_vpar->sequence.b_chroma_h_subsampled); \
1026 DECODE_LUMABLOCK( 0, PF_MBFUNC ); \
1027 DECODE_LUMABLOCK( 1, PF_MBFUNC ); \
1028 DECODE_LUMABLOCK( 2, PF_MBFUNC ); \
1029 DECODE_LUMABLOCK( 3, PF_MBFUNC ); \
1033 DECODE_CHROMABLOCK( i_b, PF_MBFUNC ); \
1034 DECODE_CHROMABLOCK( i_b + 1, PF_MBFUNC ); \
1037 while( i_b < 4 + p_vpar->sequence.i_chroma_nb_blocks ); \
1040 DECLARE_NONINTRAMB( MPEG1NonIntraMB, MPEG1NonIntra );
1041 DECLARE_NONINTRAMB( MPEG2NonIntraMB, MPEG2NonIntra );
1043 #undef DECLARE_NONINTRAMB
1044 #undef DECODE_LUMABLOCK
1045 #undef DECODE_CHROMABLOCK
1052 /****************************************************************************
1053 * MotionDelta : Parse the next motion delta
1054 ****************************************************************************/
1055 static __inline__ int MotionDelta( vpar_thread_t * p_vpar, int i_f_code )
1057 int i_delta, i_sign, i_code;
1060 if( ShowBits( &p_vpar->bit_stream, 1 ) )
1062 RemoveBits( &p_vpar->bit_stream, 1 );
1066 if( (i_code = ShowBits( &p_vpar->bit_stream, 6 )) >= 0x3 )
1068 p_tab = MV_4 + (i_code >> 2);
1069 i_delta = (p_tab->i_value << i_f_code) + 1;
1070 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1072 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
1075 i_delta += GetBits( &p_vpar->bit_stream, i_f_code );
1078 return (i_delta ^ i_sign) - i_sign;
1083 p_tab = MV_10 + ShowBits( &p_vpar->bit_stream, 10 );
1084 i_delta = (p_tab->i_value << i_f_code) + 1;
1085 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1087 i_sign = GetSignedBits( &p_vpar->bit_stream, 1 );
1090 i_delta += GetBits( &p_vpar->bit_stream, i_f_code );
1093 return (i_delta ^ i_sign) - i_sign;
1097 /****************************************************************************
1098 * BoundMotionVector : Bound a motion_vector :-)
1099 ****************************************************************************/
1100 static __inline__ int BoundMotionVector( int i_vector, int i_f_code )
1104 i_limit = 16 << i_f_code;
1106 if( i_vector >= i_limit )
1108 return i_vector - 2 * i_limit;
1110 else if( i_vector < -i_limit)
1112 return i_vector + 2 * i_limit;
1120 /****************************************************************************
1121 * GetDMV : Decode a differential motion vector (Dual Prime Arithmetic)
1122 ****************************************************************************/
1123 static __inline__ int GetDMV( vpar_thread_t * p_vpar )
1125 dmv_lookup_t * p_tab;
1127 p_tab = DMV_2 + ShowBits( &p_vpar->bit_stream, 2 );
1128 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1129 return( p_tab->i_value );
1132 /****************************************************************************
1133 * Motion* : Parse motion vectors
1134 ****************************************************************************/
1135 #define MOTION_BLOCK( b_aver, i_x, i_y, i_dest, \
1136 pp_src, i_src, i_str, i_hei, \
1139 motion_inner_t * p_m_inner = p_mb->p_motions + p_mb->i_nb_motions; \
1140 p_m_inner->b_average = b_aver; \
1141 p_m_inner->i_x_pred = i_x; \
1142 p_m_inner->i_y_pred = i_y; \
1143 p_m_inner->pp_source[0] = pp_src[0]; \
1144 p_m_inner->pp_source[1] = pp_src[1]; \
1145 p_m_inner->pp_source[2] = pp_src[2]; \
1146 p_m_inner->i_dest_offset = i_dest; \
1147 p_m_inner->i_src_offset = i_src; \
1148 p_m_inner->i_stride = i_str; \
1149 p_m_inner->i_height = i_hei; \
1150 p_m_inner->b_second_half = b_s_half; \
1151 p_mb->i_nb_motions++; \
1154 /* MPEG-1 predictions. */
1156 static void MotionMPEG1( vpar_thread_t * p_vpar,
1157 macroblock_t * p_mb,
1158 motion_t * p_motion,
1159 boolean_t b_average )
1161 int i_motion_x, i_motion_y;
1162 int i_offset = p_vpar->mb.i_offset;
1163 int i_width = p_vpar->picture.i_field_width;
1165 i_motion_x = p_motion->ppi_pmv[0][0]
1166 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1167 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1168 p_motion->ppi_pmv[0][0] = i_motion_x;
1170 i_motion_y = p_motion->ppi_pmv[0][1]
1171 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1172 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[0] );
1173 p_motion->ppi_pmv[0][1] = i_motion_y;
1175 if( p_motion->pi_f_code[1] )
1181 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1182 p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1185 static void MotionMPEG1Reuse( vpar_thread_t * p_vpar,
1186 macroblock_t * p_mb,
1187 motion_t * p_motion,
1188 boolean_t b_average )
1190 int i_motion_x, i_motion_y;
1191 int i_offset = p_vpar->mb.i_offset;
1192 int i_width = p_vpar->picture.i_field_width;
1194 i_motion_x = p_motion->ppi_pmv[0][0];
1195 i_motion_y = p_motion->ppi_pmv[0][1];
1197 if( p_motion->pi_f_code[1] )
1203 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1204 i_offset, p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1207 /* MPEG-2 frame predictions. */
1209 static void MotionFrameFrame( vpar_thread_t * p_vpar,
1210 macroblock_t * p_mb,
1211 motion_t * p_motion,
1212 boolean_t b_average )
1214 int i_motion_x, i_motion_y;
1215 int i_offset = p_vpar->mb.i_offset;
1216 int i_width = p_vpar->picture.i_field_width;
1218 i_motion_x = p_motion->ppi_pmv[0][0]
1219 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1220 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1221 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1223 i_motion_y = p_motion->ppi_pmv[0][1]
1224 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1225 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1226 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1228 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1229 p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1232 static void MotionFrameField( vpar_thread_t * p_vpar,
1233 macroblock_t * p_mb,
1234 motion_t * p_motion,
1235 boolean_t b_average )
1237 int i_motion_x, i_motion_y, i_field_select;
1238 int i_offset = p_vpar->mb.i_offset;
1239 int i_width = p_vpar->picture.i_field_width;
1241 i_field_select = GetSignedBits( &p_vpar->bit_stream, 1 );
1243 i_motion_x = p_motion->ppi_pmv[0][0]
1244 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1245 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1246 p_motion->ppi_pmv[0][0] = i_motion_x;
1248 i_motion_y = (p_motion->ppi_pmv[0][1] >> 1)
1249 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1250 /* According to ISO/IEC 13818-2 section 7.6.3.2, the vertical motion
1251 * vector is restricted to a range that implies it doesn't need to
1253 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1254 p_motion->ppi_pmv[0][1] = i_motion_y << 1;
1256 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1257 p_motion->pppi_ref[0], i_offset + (i_field_select & i_width),
1258 i_width * 2, 8, 0 );
1260 i_field_select = GetSignedBits( &p_vpar->bit_stream, 1 );
1262 i_motion_x = p_motion->ppi_pmv[1][0]
1263 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1264 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1265 p_motion->ppi_pmv[1][0] = i_motion_x;
1267 i_motion_y = (p_motion->ppi_pmv[1][1] >> 1)
1268 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1269 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1270 p_motion->ppi_pmv[1][1] = i_motion_y << 1;
1272 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset + i_width,
1273 p_motion->pppi_ref[0], i_offset + (i_field_select & i_width),
1274 i_width * 2, 8, 0 );
1277 static void MotionFrameDMV( vpar_thread_t * p_vpar,
1278 macroblock_t * p_mb,
1279 motion_t * p_motion,
1280 boolean_t b_average )
1282 int i_motion_x, i_motion_y;
1283 int i_dmv_x, i_dmv_y;
1284 int i_tmp_x, i_tmp_y;
1286 int i_offset = p_vpar->mb.i_offset;
1287 int i_width = p_vpar->picture.i_field_width;
1290 i_motion_x = p_motion->ppi_pmv[0][0]
1291 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1292 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1293 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1295 i_dmv_x = GetDMV( p_vpar );
1297 i_motion_y = (p_motion->ppi_pmv[0][1] >> 1)
1298 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1299 /* i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] ); */
1300 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y << 1;
1302 i_dmv_y = GetDMV( p_vpar );
1305 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset,
1306 p_motion->pppi_ref[0], i_offset, i_width * 2, 8, 0 );
1307 m = p_vpar->picture.b_top_field_first ? 1 : 3;
1308 i_tmp_x = ((i_motion_x * m + (i_motion_x > 0)) >> 1) + i_dmv_x;
1309 i_tmp_y = ((i_motion_y * m + (i_motion_y > 0)) >> 1) + i_dmv_y - 1;
1310 MOTION_BLOCK( 1, i_tmp_x, i_tmp_y, i_offset, p_motion->pppi_ref[0],
1311 i_offset + i_width, i_width * 2, 8, 0 );
1314 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset + i_width,
1315 p_motion->pppi_ref[0], i_offset + i_width, i_width * 2, 8, 0 );
1316 m = p_vpar->picture.b_top_field_first ? 3 : 1;
1317 i_tmp_x = ((i_motion_x * m + (i_motion_x > 0)) >> 1) + i_dmv_x;
1318 i_tmp_y = ((i_motion_y * m + (i_motion_y > 0)) >> 1) + i_dmv_y + 1;
1319 MOTION_BLOCK( 1, i_tmp_x, i_tmp_y, i_offset + i_width,
1320 p_motion->pppi_ref[0], i_offset, i_width * 2, 8, 0 );
1323 static void MotionFrameZero( vpar_thread_t * p_vpar,
1324 macroblock_t * p_mb,
1325 motion_t * p_motion,
1326 boolean_t b_average )
1328 int i_offset = p_vpar->mb.i_offset;
1329 int i_width = p_vpar->picture.i_field_width;
1331 MOTION_BLOCK( b_average, 0, 0, i_offset, p_motion->pppi_ref[0],
1332 i_offset, i_width, 16, 0 );
1335 static void MotionFrameReuse( vpar_thread_t * p_vpar,
1336 macroblock_t * p_mb,
1337 motion_t * p_motion,
1338 boolean_t b_average )
1340 int i_offset = p_vpar->mb.i_offset;
1341 int i_width = p_vpar->picture.i_field_width;
1343 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1344 i_offset, p_motion->pppi_ref[0], i_offset, i_width, 16, 0 );
1347 /* MPEG-2 field predictions. */
1349 static void MotionFieldField( vpar_thread_t * p_vpar,
1350 macroblock_t * p_mb,
1351 motion_t * p_motion,
1352 boolean_t b_average )
1354 int i_motion_x, i_motion_y;
1355 boolean_t b_field_select;
1356 int i_offset = p_vpar->mb.i_offset;
1357 int i_width = p_vpar->picture.i_field_width;
1359 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1361 i_motion_x = p_motion->ppi_pmv[0][0]
1362 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1363 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1364 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1366 i_motion_y = p_motion->ppi_pmv[0][1]
1367 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1368 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1369 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1371 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1372 p_motion->pppi_ref[b_field_select], i_offset, i_width, 16, 0 );
1375 static void MotionField16x8( vpar_thread_t * p_vpar,
1376 macroblock_t * p_mb,
1377 motion_t * p_motion,
1378 boolean_t b_average )
1380 int i_motion_x, i_motion_y;
1381 boolean_t b_field_select;
1382 int i_offset = p_vpar->mb.i_offset;
1383 int i_width = p_vpar->picture.i_field_width;
1386 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1388 i_motion_x = p_motion->ppi_pmv[0][0]
1389 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1390 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1391 p_motion->ppi_pmv[0][0] = i_motion_x;
1393 i_motion_y = p_motion->ppi_pmv[0][1]
1394 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1395 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1396 p_motion->ppi_pmv[0][1] = i_motion_y;
1398 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1399 p_motion->pppi_ref[b_field_select], i_offset, i_width, 8, 0 );
1402 b_field_select = GetBits( &p_vpar->bit_stream, 1 );
1404 i_motion_x = p_motion->ppi_pmv[1][0]
1405 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1406 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1407 p_motion->ppi_pmv[1][0] = i_motion_x;
1409 i_motion_y = p_motion->ppi_pmv[1][1]
1410 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1411 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1412 p_motion->ppi_pmv[1][1] = i_motion_y;
1414 MOTION_BLOCK( b_average, i_motion_x, i_motion_y, i_offset,
1415 p_motion->pppi_ref[b_field_select], i_offset, i_width, 8, 1 );
1418 static void MotionFieldDMV( vpar_thread_t * p_vpar,
1419 macroblock_t * p_mb,
1420 motion_t * p_motion,
1421 boolean_t b_average )
1423 int i_motion_x, i_motion_y;
1424 int i_dmv_x, i_dmv_y;
1425 int i_offset = p_vpar->mb.i_offset;
1426 int i_width = p_vpar->picture.i_field_width;
1427 boolean_t b_current_field = p_vpar->picture.b_current_field;
1429 i_motion_x = p_motion->ppi_pmv[0][0]
1430 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1431 i_motion_x = BoundMotionVector( i_motion_x, p_motion->pi_f_code[0] );
1432 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_motion_x;
1434 i_dmv_x = GetDMV( p_vpar );
1436 i_motion_y = p_motion->ppi_pmv[0][1]
1437 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1438 i_motion_y = BoundMotionVector( i_motion_y, p_motion->pi_f_code[1] );
1439 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_motion_y;
1441 i_dmv_y = GetDMV( p_vpar );
1443 MOTION_BLOCK( 0, i_motion_x, i_motion_y, i_offset,
1444 p_motion->pppi_ref[b_current_field],
1445 i_offset, i_width, 16, 0 );
1447 i_motion_x = ((i_motion_x + (i_motion_x > 0)) >> 1) + i_dmv_x;
1448 i_motion_y = ((i_motion_y + (i_motion_y > 0)) >> 1) + i_dmv_y
1449 + 2 * b_current_field - 1;
1450 MOTION_BLOCK( 1, i_motion_x, i_motion_y, i_offset,
1451 p_motion->pppi_ref[!b_current_field],
1452 i_offset, i_width, 16, 0 );
1455 static void MotionFieldZero( vpar_thread_t * p_vpar,
1456 macroblock_t * p_mb,
1457 motion_t * p_motion,
1458 boolean_t b_average )
1460 int i_offset = p_vpar->mb.i_offset;
1461 int i_width = p_vpar->picture.i_field_width;
1462 boolean_t b_current_field = p_vpar->picture.b_current_field;
1464 MOTION_BLOCK( b_average, 0, 0, i_offset, p_motion->pppi_ref[b_current_field],
1465 i_offset, i_width, 16, 0 );
1468 static void MotionFieldReuse( vpar_thread_t * p_vpar,
1469 macroblock_t * p_mb,
1470 motion_t * p_motion,
1471 boolean_t b_average )
1473 int i_offset = p_vpar->mb.i_offset;
1474 int i_width = p_vpar->picture.i_field_width;
1475 boolean_t b_current_field = p_vpar->picture.b_current_field;
1477 MOTION_BLOCK( b_average, p_motion->ppi_pmv[0][0], p_motion->ppi_pmv[0][1],
1478 i_offset, p_motion->pppi_ref[b_current_field],
1479 i_offset, i_width, 16, 0 );
1482 /* MPEG-2 concealment motion vectors. */
1484 static void MotionFrameConceal( vpar_thread_t * p_vpar,
1485 macroblock_t * p_mv,
1486 motion_t * p_motion )
1490 i_tmp = p_motion->ppi_pmv[0][0]
1491 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1492 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[0] );
1493 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_tmp;
1495 i_tmp = p_motion->ppi_pmv[0][1]
1496 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1497 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[1] );
1498 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_tmp;
1501 RemoveBits( &p_vpar->bit_stream, 1 );
1504 static void MotionFieldConceal( vpar_thread_t * p_vpar,
1505 macroblock_t * p_mv,
1506 motion_t * p_motion )
1511 RemoveBits( &p_vpar->bit_stream, 1 );
1513 i_tmp = p_motion->ppi_pmv[0][0]
1514 + MotionDelta( p_vpar, p_motion->pi_f_code[0] );
1515 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[0] );
1516 p_motion->ppi_pmv[1][0] = p_motion->ppi_pmv[0][0] = i_tmp;
1518 i_tmp = p_motion->ppi_pmv[0][1]
1519 + MotionDelta( p_vpar, p_motion->pi_f_code[1] );
1520 i_tmp = BoundMotionVector( i_tmp, p_motion->pi_f_code[1] );
1521 p_motion->ppi_pmv[1][1] = p_motion->ppi_pmv[0][1] = i_tmp;
1524 RemoveBits( &p_vpar->bit_stream, 1 );
1529 * Macroblock information structures
1532 /*****************************************************************************
1533 * MacroblockAddressIncrement : Get the macroblock_address_increment field
1534 *****************************************************************************/
1535 static __inline__ int MacroblockAddressIncrement( vpar_thread_t * p_vpar )
1543 if( (i_code = ShowBits( &p_vpar->bit_stream, 5 ) ) >= 0x2 )
1545 p_tab = MBA_5 - 2 + i_code;
1546 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1547 return( i_mba + p_tab->i_value );
1549 else if( (i_code = ShowBits( &p_vpar->bit_stream, 11 )) >= 0x18 )
1551 p_tab = MBA_11 - 24 + i_code;
1552 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1553 return( i_mba + p_tab->i_value );
1555 else switch( i_code )
1558 /* Macroblock escape */
1562 /* Macroblock stuffing (MPEG-1 ONLY) */
1563 RemoveBits( &p_vpar->bit_stream, 11 );
1567 /* End of slice, or error */
1573 /*****************************************************************************
1574 * CodedPattern : coded_block_pattern
1575 *****************************************************************************/
1576 static __inline__ int CodedPattern( vpar_thread_t * p_vpar )
1581 if( (i_code = ShowBits( &p_vpar->bit_stream, 7 )) >= 0x10 )
1583 p_tab = CBP_7 - 16 + i_code;
1584 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1588 p_tab = CBP_9 + ShowBits( &p_vpar->bit_stream, 9 );
1589 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1591 if( p_vpar->sequence.i_chroma_format == CHROMA_420 )
1593 return( p_tab->i_value << 6 );
1595 if( p_vpar->sequence.i_chroma_format == CHROMA_422 )
1597 return( (p_tab->i_value << 6)
1598 | (GetBits( &p_vpar->bit_stream, 2 ) << 4) );
1600 return( (p_tab->i_value << 6)
1601 | GetBits( &p_vpar->bit_stream, 6 ) );
1604 /*****************************************************************************
1605 * MacroblockModes : Get the macroblock_modes structure
1606 *****************************************************************************/
1607 static __inline__ int MacroblockModes( vpar_thread_t * p_vpar,
1608 macroblock_t * p_mb,
1615 switch( i_coding_type )
1618 p_tab = MB_I + ShowBits( &p_vpar->bit_stream, 1 );
1619 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1620 i_mb_modes = p_tab->i_value;
1622 if( (i_structure == FRAME_STRUCTURE) &&
1623 (!p_vpar->picture.b_frame_pred_frame_dct) )
1625 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1626 * DCT_TYPE_INTERLACED;
1628 return( i_mb_modes );
1631 p_tab = MB_P + ShowBits( &p_vpar->bit_stream, 5 );
1632 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1633 i_mb_modes = p_tab->i_value;
1635 if( i_structure != FRAME_STRUCTURE )
1637 if( i_mb_modes & MB_MOTION_FORWARD )
1639 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1642 return( i_mb_modes );
1644 else if( p_vpar->picture.b_frame_pred_frame_dct )
1646 if( i_mb_modes & MB_MOTION_FORWARD )
1648 i_mb_modes |= MC_FRAME;
1650 return( i_mb_modes );
1654 if( i_mb_modes & MB_MOTION_FORWARD )
1656 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1659 if( i_mb_modes & (MB_INTRA | MB_PATTERN) )
1661 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1662 * DCT_TYPE_INTERLACED;
1664 return( i_mb_modes );
1668 p_tab = MB_B + ShowBits( &p_vpar->bit_stream, 6 );
1669 RemoveBits( &p_vpar->bit_stream, p_tab->i_length );
1670 i_mb_modes = p_tab->i_value;
1672 if( i_structure != FRAME_STRUCTURE )
1674 if( !( i_mb_modes & MB_INTRA ) )
1676 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1679 return( i_mb_modes );
1681 else if( p_vpar->picture.b_frame_pred_frame_dct )
1683 i_mb_modes |= MC_FRAME;
1684 return( i_mb_modes );
1688 if( i_mb_modes & MB_INTRA )
1692 i_mb_modes |= GetBits( &p_vpar->bit_stream, 2 )
1694 if( i_mb_modes & (MB_INTRA | MB_PATTERN) )
1697 i_mb_modes |= GetBits( &p_vpar->bit_stream, 1 )
1698 * DCT_TYPE_INTERLACED;
1700 return( i_mb_modes );
1704 RemoveBits( &p_vpar->bit_stream, 1 );
1714 * Picture data parsing management
1717 /*****************************************************************************
1718 * ParseSlice : Parse the next slice structure
1719 *****************************************************************************/
1720 #define MOTION( pf_routine, i_direction ) \
1721 if( (i_direction) & MB_MOTION_FORWARD ) \
1723 pf_routine( p_vpar, p_mb, &p_vpar->mb.f_motion, 0 ); \
1724 if( (i_coding_type == B_CODING_TYPE) \
1725 && ((i_direction) & MB_MOTION_BACKWARD) ) \
1727 pf_routine( p_vpar, p_mb, &p_vpar->mb.b_motion, 1 ); \
1730 else if( (i_coding_type == B_CODING_TYPE) \
1731 && ((i_direction) & MB_MOTION_BACKWARD) ) \
1733 pf_routine( p_vpar, p_mb, &p_vpar->mb.b_motion, 0 ); \
1736 #define CHECK_BOUNDARIES \
1737 i_offset = p_vpar->mb.i_offset; \
1738 if( i_offset == i_width ) \
1740 if( i_coding_type != I_CODING_TYPE || \
1741 p_vpar->picture.b_concealment_mv ) \
1743 p_f_motion->pppi_ref[0][0] += 16 * i_offset; \
1744 p_f_motion->pppi_ref[0][1] += i_chroma_tmp; \
1745 p_f_motion->pppi_ref[0][2] += i_chroma_tmp; \
1747 if( i_coding_type == B_CODING_TYPE ) \
1749 p_b_motion->pppi_ref[0][0] += 16 * i_offset; \
1750 p_b_motion->pppi_ref[0][1] += i_chroma_tmp; \
1751 p_b_motion->pppi_ref[0][2] += i_chroma_tmp; \
1753 p_dest[0] += 16 * i_offset; \
1754 p_dest[1] += 4 * i_offset; \
1755 p_dest[2] += 4 * i_offset; \
1758 p_vpar->mb.i_offset = i_offset;
1760 #define PARSEERROR \
1761 if( p_vpar->picture.b_error ) \
1763 /* Go to the next slice. */ \
1764 p_vpar->pool.pf_free_mb( &p_vpar->pool, p_mb ); \
1768 static __inline__ void ParseSlice( vpar_thread_t * p_vpar,
1769 u32 i_vert_code, boolean_t b_mpeg2,
1770 int i_coding_type, int i_structure )
1772 int i_offset, i_width, i_chroma_tmp;
1773 picture_t * pp_forward_ref[2];
1774 yuv_data_t * p_dest[3];
1776 motion_t * p_f_motion = &p_vpar->mb.f_motion;
1777 motion_t * p_b_motion = &p_vpar->mb.b_motion;
1780 LoadQuantizerScale( p_vpar );
1782 if( GetBits( &p_vpar->bit_stream, 1 ) )
1784 /* intra_slice, slice_id */
1785 RemoveBits( &p_vpar->bit_stream, 8 );
1786 /* extra_information_slice */
1787 while( GetBits( &p_vpar->bit_stream, 1 ) )
1789 RemoveBits( &p_vpar->bit_stream, 8 );
1793 /* Calculate the position of the macroblock. */
1794 i_width = p_vpar->sequence.i_width;
1795 i_offset = (i_vert_code - 1) * i_width * 4;
1797 /* Initialize motion context. */
1798 pp_forward_ref[0] = p_vpar->sequence.p_forward;
1800 if( i_structure != FRAME_STRUCTURE )
1804 i_offset * (2 - p_vpar->sequence.b_chroma_v_subsampled)
1805 * (2 - p_vpar->sequence.b_chroma_h_subsampled)
1806 + (i_width >> p_vpar->sequence.b_chroma_h_subsampled);
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 )
1816 p_f_motion->pppi_ref[1][0] =
1817 pp_forward_ref[1]->P_Y + i_offset * 4 + i_width;
1818 p_f_motion->pppi_ref[1][1] =
1819 pp_forward_ref[1]->P_U + i_chroma_tmp;
1820 p_f_motion->pppi_ref[1][2] =
1821 pp_forward_ref[1]->P_V + i_chroma_tmp;
1823 if( i_coding_type == B_CODING_TYPE )
1825 p_b_motion->pppi_ref[1][0] =
1826 p_vpar->sequence.p_backward->P_Y + i_offset * 4 + i_width;
1827 p_b_motion->pppi_ref[1][1] =
1828 p_vpar->sequence.p_backward->P_U + i_chroma_tmp;
1829 p_b_motion->pppi_ref[1][2] =
1830 p_vpar->sequence.p_backward->P_V + i_chroma_tmp;
1834 i_chroma_tmp = i_offset
1835 * (2 - p_vpar->sequence.b_chroma_v_subsampled)
1836 * (2 - p_vpar->sequence.b_chroma_h_subsampled);
1837 if( i_coding_type != I_CODING_TYPE || p_vpar->picture.b_concealment_mv )
1839 p_f_motion->pppi_ref[0][0] = pp_forward_ref[0]->P_Y + i_offset * 4;
1840 p_f_motion->pppi_ref[0][1] = pp_forward_ref[0]->P_U + i_chroma_tmp;
1841 p_f_motion->pppi_ref[0][2] = pp_forward_ref[0]->P_V + i_chroma_tmp;
1842 p_f_motion->pi_f_code[0] = p_vpar->picture.ppi_f_code[0][0];
1843 p_f_motion->pi_f_code[1] = p_vpar->picture.ppi_f_code[0][1];
1844 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1845 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1848 if( i_coding_type == B_CODING_TYPE )
1850 p_b_motion->pppi_ref[0][0] = p_vpar->sequence.p_backward->P_Y
1852 p_b_motion->pppi_ref[0][1] = p_vpar->sequence.p_backward->P_U
1854 p_b_motion->pppi_ref[0][2] = p_vpar->sequence.p_backward->P_V
1856 p_b_motion->pi_f_code[0] = p_vpar->picture.ppi_f_code[1][0];
1857 p_b_motion->pi_f_code[1] = p_vpar->picture.ppi_f_code[1][1];
1858 p_b_motion->ppi_pmv[0][0] = p_b_motion->ppi_pmv[0][1] = 0;
1859 p_b_motion->ppi_pmv[1][0] = p_b_motion->ppi_pmv[1][1] = 0;
1862 /* Initialize destination pointers. */
1863 p_dest[0] = p_vpar->picture.p_picture->P_Y + i_offset * 4;
1864 p_dest[1] = p_vpar->picture.p_picture->P_U + i_chroma_tmp;
1865 p_dest[2] = p_vpar->picture.p_picture->P_V + i_chroma_tmp;
1867 if( i_structure == BOTTOM_FIELD )
1869 p_dest[0] += i_width;
1870 p_dest[1] += i_width >> p_vpar->sequence.b_chroma_h_subsampled;
1871 p_dest[2] += i_width >> p_vpar->sequence.b_chroma_h_subsampled;
1873 i_width = p_vpar->picture.i_field_width;
1875 /* Reset intra DC coefficients predictors (ISO/IEC 13818-2 7.2.1). */
1876 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
1877 = p_vpar->mb.pi_dc_dct_pred[2]
1878 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
1880 p_vpar->mb.i_offset = MacroblockAddressIncrement( p_vpar ) << 4;
1882 i_chroma_tmp = i_width * 4
1883 * (2 - p_vpar->sequence.b_chroma_v_subsampled)
1884 * (2 - p_vpar->sequence.b_chroma_h_subsampled);
1885 while( (int)(p_vpar->mb.i_offset - p_vpar->sequence.i_width) >= 0 )
1887 /* Unusual construct at the start of some slices. Jump one line. */
1888 p_vpar->mb.i_offset -= p_vpar->sequence.i_width;
1889 p_dest[0] += i_width * 16;
1890 p_dest[1] += i_chroma_tmp;
1891 p_dest[2] += i_chroma_tmp;
1892 p_f_motion->pppi_ref[0][0] += i_width * 16;
1893 p_f_motion->pppi_ref[0][1] += i_chroma_tmp;
1894 p_f_motion->pppi_ref[0][2] += i_chroma_tmp;
1895 p_f_motion->pppi_ref[1][0] += i_width * 16;
1896 p_f_motion->pppi_ref[1][1] += i_chroma_tmp;
1897 p_f_motion->pppi_ref[1][2] += i_chroma_tmp;
1902 /* Decode macroblocks. */
1903 macroblock_t * p_mb;
1906 /* Get a macroblock structure. */
1907 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
1908 p_mb->i_nb_motions = 0;
1909 p_mb->pp_dest[0] = p_dest[0];
1910 p_mb->pp_dest[1] = p_dest[1];
1911 p_mb->pp_dest[2] = p_dest[2];
1913 /* Parse off macroblock_modes structure. */
1914 p_mb->i_mb_modes = i_mb_modes =
1915 MacroblockModes( p_vpar, p_mb, i_coding_type, i_structure );
1917 if( i_mb_modes & MB_QUANT )
1919 LoadQuantizerScale( p_vpar );
1922 if( i_mb_modes & MB_INTRA )
1924 if( p_vpar->picture.b_concealment_mv )
1926 if( i_structure == FRAME_STRUCTURE )
1928 MotionFrameConceal( p_vpar, p_mb, p_f_motion );
1932 MotionFieldConceal( p_vpar, p_mb, p_f_motion );
1937 /* Reset motion vectors predictors. */
1938 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1939 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1940 p_b_motion->ppi_pmv[0][0] = p_b_motion->ppi_pmv[0][1] = 0;
1941 p_b_motion->ppi_pmv[1][0] = p_b_motion->ppi_pmv[1][1] = 0;
1947 if( p_vpar->picture.b_intra_vlc_format )
1949 MPEG2IntraB15MB( p_vpar, p_mb );
1953 MPEG2IntraB14MB( p_vpar, p_mb );
1958 MPEG1IntraMB( p_vpar, p_mb );
1961 if( i_coding_type == D_CODING_TYPE )
1963 RemoveBits( &p_vpar->bit_stream, 1 );
1968 /* Non-intra block */
1971 if( (i_mb_modes & MOTION_TYPE_MASK) == MC_FRAME )
1973 MOTION( MotionMPEG1, i_mb_modes );
1977 /* Non-intra MB without forward mv in a P picture. */
1978 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
1979 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
1980 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
1983 else if( i_structure == FRAME_STRUCTURE )
1985 switch( i_mb_modes & MOTION_TYPE_MASK )
1988 MOTION( MotionFrameFrame, i_mb_modes );
1992 MOTION( MotionFrameField, i_mb_modes );
1996 MOTION( MotionFrameDMV, MB_MOTION_FORWARD );
2000 /* Non-intra MB without forward mv in a P picture. */
2001 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2002 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2003 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
2008 /* Field structure. */
2009 switch( i_mb_modes & MOTION_TYPE_MASK )
2012 MOTION( MotionFieldField, i_mb_modes );
2016 MOTION( MotionField16x8, i_mb_modes );
2020 MOTION( MotionFieldDMV, i_mb_modes );
2024 /* Non-intra MB without forward mv in a P picture. */
2025 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2026 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2027 MOTION( MotionFieldZero, MB_MOTION_FORWARD );
2031 /* ISO/IEC 13818-2 6.3.17.4 : Coded Block Pattern */
2032 if( i_mb_modes & MB_PATTERN )
2034 p_mb->i_coded_block_pattern = CodedPattern( p_vpar );
2037 MPEG2NonIntraMB( p_vpar, p_mb );
2041 MPEG1NonIntraMB( p_vpar, p_mb );
2046 p_mb->i_coded_block_pattern = 0;
2049 /* Reset intra DC coefficients predictors. */
2050 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
2051 = p_vpar->mb.pi_dc_dct_pred[2]
2052 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
2055 /* End of macroblock. */
2057 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2059 /* Prepare context for the next macroblock. */
2060 p_vpar->mb.i_offset += 16;
2063 if( ShowBits( &p_vpar->bit_stream, 1 ) )
2065 /* Macroblock Address Increment == 1 */
2066 RemoveBits( &p_vpar->bit_stream, 1 );
2070 /* Check for skipped macroblock(s). */
2073 i_mba_inc = MacroblockAddressIncrement( p_vpar );
2080 /* Reset intra DC predictors. */
2081 p_vpar->mb.pi_dc_dct_pred[0] = p_vpar->mb.pi_dc_dct_pred[1]
2082 = p_vpar->mb.pi_dc_dct_pred[2]
2083 = 1 << (7 + p_vpar->picture.i_intra_dc_precision);
2085 if( i_coding_type == P_CODING_TYPE )
2087 p_f_motion->ppi_pmv[0][0] = p_f_motion->ppi_pmv[0][1] = 0;
2088 p_f_motion->ppi_pmv[1][0] = p_f_motion->ppi_pmv[1][1] = 0;
2091 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
2092 p_mb->i_mb_modes = 0;
2093 p_mb->i_nb_motions = 0;
2094 p_mb->i_coded_block_pattern = 0;
2095 p_mb->pp_dest[0] = p_dest[0];
2096 p_mb->pp_dest[1] = p_dest[1];
2097 p_mb->pp_dest[2] = p_dest[2];
2099 if( i_structure == FRAME_STRUCTURE )
2101 MOTION( MotionFrameZero, MB_MOTION_FORWARD );
2105 MOTION( MotionFieldZero, MB_MOTION_FORWARD );
2108 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2109 p_vpar->mb.i_offset += 16;
2111 } while( --i_mba_inc );
2116 p_mb = p_vpar->pool.pf_new_mb( &p_vpar->pool );
2117 p_mb->i_mb_modes = 0;
2118 p_mb->i_nb_motions = 0;
2119 p_mb->i_coded_block_pattern = 0;
2120 p_mb->pp_dest[0] = p_dest[0];
2121 p_mb->pp_dest[1] = p_dest[1];
2122 p_mb->pp_dest[2] = p_dest[2];
2126 MOTION( MotionMPEG1Reuse, i_mb_modes );
2128 else if( i_structure == FRAME_STRUCTURE )
2130 MOTION( MotionFrameReuse, i_mb_modes );
2134 MOTION( MotionFieldReuse, i_mb_modes );
2137 p_vpar->pool.pf_decode_mb( &p_vpar->pool, p_mb );
2138 p_vpar->mb.i_offset += 16;
2140 } while( --i_mba_inc );
2145 NextStartCode( &p_vpar->bit_stream );
2148 /*****************************************************************************
2149 * PictureData : Parse off all macroblocks (ISO/IEC 13818-2 6.2.3.7)
2150 *****************************************************************************/
2151 static __inline__ void vpar_PictureData( vpar_thread_t * p_vpar,
2153 int i_coding_type, int i_structure )
2157 NextStartCode( &p_vpar->bit_stream );
2158 while( !p_vpar->picture.b_error && !p_vpar->p_fifo->b_die )
2160 if( ((i_dummy = ShowBits( &p_vpar->bit_stream, 32 ))
2161 < SLICE_START_CODE_MIN) ||
2162 (i_dummy > SLICE_START_CODE_MAX) )
2166 RemoveBits32( &p_vpar->bit_stream );
2168 /* Decode slice data. */
2169 ParseSlice( p_vpar, i_dummy & 255, b_mpeg2, i_coding_type,
2174 #define DECLARE_PICD( FUNCNAME, B_MPEG2, I_CODING_TYPE, I_STRUCTURE ) \
2175 void FUNCNAME( vpar_thread_t * p_vpar ) \
2177 vpar_PictureData( p_vpar, B_MPEG2, I_CODING_TYPE, I_STRUCTURE ); \
2180 DECLARE_PICD( vpar_PictureDataGENERIC, p_vpar->sequence.b_mpeg2,
2181 p_vpar->picture.i_coding_type, p_vpar->picture.i_structure );
2182 #if (VPAR_OPTIM_LEVEL > 0)
2183 DECLARE_PICD( vpar_PictureData2IF, 1, I_CODING_TYPE, FRAME_STRUCTURE );
2184 DECLARE_PICD( vpar_PictureData2PF, 1, P_CODING_TYPE, FRAME_STRUCTURE );
2185 DECLARE_PICD( vpar_PictureData2BF, 1, B_CODING_TYPE, FRAME_STRUCTURE );
2187 #if (VPAR_OPTIM_LEVEL > 1)
2188 DECLARE_PICD( vpar_PictureData2IT, 1, I_CODING_TYPE, TOP_FIELD );
2189 DECLARE_PICD( vpar_PictureData2PT, 1, P_CODING_TYPE, TOP_FIELD );
2190 DECLARE_PICD( vpar_PictureData2BT, 1, B_CODING_TYPE, TOP_FIELD );
2191 DECLARE_PICD( vpar_PictureData2IB, 1, I_CODING_TYPE, BOTTOM_FIELD );
2192 DECLARE_PICD( vpar_PictureData2PB, 1, P_CODING_TYPE, BOTTOM_FIELD );
2193 DECLARE_PICD( vpar_PictureData2BB, 1, B_CODING_TYPE, BOTTOM_FIELD );
2194 DECLARE_PICD( vpar_PictureData1I, 0, I_CODING_TYPE, FRAME_STRUCTURE );
2195 DECLARE_PICD( vpar_PictureData1P, 0, P_CODING_TYPE, FRAME_STRUCTURE );
2196 DECLARE_PICD( vpar_PictureData1B, 0, B_CODING_TYPE, FRAME_STRUCTURE );
2197 DECLARE_PICD( vpar_PictureData1D, 0, D_CODING_TYPE, FRAME_STRUCTURE );