/[pcsx2_0.9.7]/trunk/pcsx2/IPU/mpeg2lib/Mpeg.h
ViewVC logotype

Annotation of /trunk/pcsx2/IPU/mpeg2lib/Mpeg.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (hide annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File MIME type: text/plain
File size: 5577 byte(s)
re-commit (had local access denied errors when committing)
1 william 31 /*
2     * Mpeg.h
3     * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
4     * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5     * Modified by Florin for PCSX2 emu
6     *
7     * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
8     * See http://libmpeg2.sourceforge.net/ for updates.
9     *
10     * mpeg2dec is free software; you can redistribute it and/or modify
11     * it under the terms of the GNU General Public License as published by
12     * the Free Software Foundation; either version 2 of the License, or
13     * (at your option) any later version.
14     *
15     * mpeg2dec is distributed in the hope that it will be useful,
16     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     * GNU General Public License for more details.
19     *
20     * You should have received a copy of the GNU General Public License
21     * along with this program; if not, write to the Free Software
22     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23     */
24    
25 william 62 #pragma once
26 william 31
27 william 62 // the IPU is fixed to 16 byte strides (128-bit / QWC resolution):
28     static const uint decoder_stride = 16;
29    
30 william 31 enum macroblock_modes
31     {
32     MACROBLOCK_INTRA = 1,
33     MACROBLOCK_PATTERN = 2,
34     MACROBLOCK_MOTION_BACKWARD = 4,
35     MACROBLOCK_MOTION_FORWARD = 8,
36     MACROBLOCK_QUANT = 16,
37     DCT_TYPE_INTERLACED = 32
38     };
39    
40     enum motion_type
41     {
42     MOTION_TYPE_SHIFT = 6,
43     MOTION_TYPE_MASK = (3*64),
44     MOTION_TYPE_BASE = 64,
45     MC_FIELD = (1*64),
46     MC_FRAME = (2*64),
47     MC_16X8 = (2*64),
48     MC_DMV = (3*64)
49     };
50    
51     /* picture structure */
52     enum picture_structure
53     {
54     TOP_FIELD = 1,
55     BOTTOM_FIELD = 2,
56     FRAME_PICTURE = 3
57     };
58    
59     /* picture coding type */
60     enum picture_coding_type
61     {
62     I_TYPE =1,
63     P_TYPE = 2,
64     B_TYPE = 3,
65     D_TYPE = 4
66     };
67    
68     struct macroblock_8{
69 william 62 u8 Y[16][16]; //0
70     u8 Cb[8][8]; //1
71     u8 Cr[8][8]; //2
72 william 31 };
73    
74     struct macroblock_16{
75 william 62 s16 Y[16][16]; //0
76     s16 Cb[8][8]; //1
77     s16 Cr[8][8]; //2
78 william 31 };
79    
80     struct macroblock_rgb32{
81     struct {
82 william 62 u8 r, g, b, a;
83 william 31 } c[16][16];
84     };
85    
86 william 62 struct rgb16_t{
87     u16 r:5, g:5, b:5, a:1;
88 william 31 };
89    
90     struct macroblock_rgb16{
91 william 62 rgb16_t c[16][16];
92 william 31 };
93    
94     struct decoder_t {
95     /* first, state that carries information from one macroblock to the */
96     /* next inside a slice, and is never used outside of mpeg2_slice() */
97    
98     /* DCT coefficients - should be kept aligned ! */
99     s16 DCTblock[64];
100    
101 william 62 u8 niq[64]; //non-intraquant matrix (sequence header)
102     u8 iq[64]; //intraquant matrix (sequence header)
103    
104     macroblock_8 mb8;
105     macroblock_16 mb16;
106     macroblock_rgb32 rgb32;
107     macroblock_rgb16 rgb16;
108    
109 william 191 uint ipu0_data; // amount of data in the output macroblock (in QWC)
110 william 62 uint ipu0_idx;
111    
112 william 273 int quantizer_scale;
113 william 31
114     /* now non-slice-specific information */
115    
116     /* picture header stuff */
117    
118     /* what type of picture this is (I, P, B, D) */
119     int coding_type;
120    
121     /* picture coding extension stuff */
122    
123 william 62 /* predictor for DC coefficients in intra blocks */
124     s16 dc_dct_pred[3];
125    
126 william 31 /* quantization factor for intra dc coefficients */
127     int intra_dc_precision;
128     /* top/bottom/both fields */
129     int picture_structure;
130     /* bool to indicate all predictions are frame based */
131     int frame_pred_frame_dct;
132     /* bool to indicate whether intra blocks have motion vectors */
133     /* (for concealment) */
134     int concealment_motion_vectors;
135     /* bit to indicate which quantization table to use */
136     int q_scale_type;
137     /* bool to use different vlc tables */
138     int intra_vlc_format;
139     /* used for DMV MC */
140     int top_field_first;
141     // Pseudo Sign Offset
142     int sgn;
143     // Dither Enable
144     int dte;
145     // Output Format
146     int ofm;
147     // Macroblock type
148     int macroblock_modes;
149     // DC Reset
150     int dcr;
151     // Coded block pattern
152     int coded_block_pattern;
153    
154     /* stuff derived from bitstream */
155    
156 william 62 /* the zigzag scan we're supposed to be using, true for alt, false for normal */
157     bool scantype;
158 william 31
159     int mpeg1;
160 william 62
161     template< typename T >
162     void SetOutputTo( T& obj )
163     {
164     uint mb_offset = ((uptr)&obj - (uptr)&mb8);
165     pxAssume( (mb_offset & 15) == 0 );
166     ipu0_idx = mb_offset / 16;
167     ipu0_data = sizeof(obj)/16;
168     }
169    
170     u128* GetIpuDataPtr()
171     {
172     return ((u128*)&mb8) + ipu0_idx;
173     }
174    
175     void AdvanceIpuDataBy(uint amt)
176     {
177 william 273 pxAssumeMsg(ipu0_data>=amt, "IPU FIFO Overflow on advance!" );
178 william 62 ipu0_idx += amt;
179     ipu0_data -= amt;
180     }
181 william 31 };
182    
183 william 62 struct mpeg2_scan_pack
184     {
185     u8 norm[64];
186     u8 alt[64];
187 william 31
188 william 62 mpeg2_scan_pack();
189     };
190    
191 william 191 extern int bitstream_init ();
192     extern u32 UBITS(uint bits);
193     extern s32 SBITS(uint bits);
194    
195 william 62 extern void mpeg2_idct_copy(s16 * block, u8* dest, int stride);
196     extern void mpeg2_idct_add(int last, s16 * block, s16* dest, int stride);
197    
198     extern bool mpeg2sliceIDEC();
199     extern bool mpeg2_slice();
200     extern int get_macroblock_address_increment();
201     extern int get_macroblock_modes();
202 william 31
203 william 62 extern int get_motion_delta(const int f_code);
204     extern int get_dmv();
205 william 31
206 william 62 extern void ipu_csc(macroblock_8& mb8, macroblock_rgb32& rgb32, int sgn);
207     extern void ipu_dither(const macroblock_rgb32& rgb32, macroblock_rgb16& rgb16, int dte);
208     extern void ipu_vq(macroblock_rgb16& rgb16, u8* indx4);
209 william 31
210 william 62 extern int slice (u8 * buffer);
211 william 31
212     #ifdef _MSC_VER
213 william 191 #define BigEndian(in) _byteswap_ulong(in)
214 william 31 #else
215 william 191 #define BigEndian(in) __builtin_bswap32(in) // or we could use the asm function bswap...
216 william 31 #endif
217    
218 william 62 #ifdef _MSC_VER
219 william 191 #define BigEndian64(in) _byteswap_uint64(in)
220 william 62 #else
221 william 191 #define BigEndian64(in) __builtin_bswap64(in) // or we could use the asm function bswap...
222 william 62 #endif
223    
224     extern __aligned16 const mpeg2_scan_pack mpeg2_scan;
225     extern const int non_linear_quantizer_scale[];
226    
227     // The IPU can only do one task at once and never uses other buffers so all mpeg state variables
228     // are made available to mpeg/vlc modules as globals here:
229    
230     extern __aligned16 tIPU_BP g_BP;
231     extern __aligned16 decoder_t decoder;
232    

  ViewVC Help
Powered by ViewVC 1.1.22