1 /*
2 * Sony PlayStation MDEC (Motion DECoder)
3 * Copyright (c) 2003 Michael Niedermayer
4 *
5 * based upon code from Sebastian Jedruszkiewicz <elf@frogger.rules.pl>
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 /**
25 * @file
26 * Sony PlayStation MDEC (Motion DECoder)
27 * This is very similar to intra-only MPEG-1.
28 */
29
34
52
53 //very similar to MPEG-1
55 {
57 int component;
61 const int qscale = a->
qscale;
62
63 /* DC coefficient */
66 } else {
67 component = (n <= 3 ? 0 : n - 4 + 1);
69 if (diff >= 0xffff)
72 block[0] = a->
last_dc[component] << 3;
73 }
74
75 i = 0;
76 {
78 /* now quantify & encode AC coefficients */
79 for (;;) {
82
83 if (level == 127) {
84 break;
85 } else if (level != 0) {
87 j = scantable[i];
88 level = (level * qscale * quant_matrix[j]) >> 3;
91 } else {
92 /* escape */
97 j = scantable[i];
98 if (level < 0) {
100 level = (level * qscale * quant_matrix[j]) >> 3;
101 level = (level - 1) | 1;
103 } else {
104 level = (level * qscale * quant_matrix[j]) >> 3;
105 level = (level - 1) | 1;
106 }
107 }
108 if (i > 63) {
111 }
112
114 }
116 }
118 return 0;
119 }
120
122 {
124 static const int block_index[6] = { 5, 4, 0, 1, 2, 3 };
125
127
128 for (i = 0; i < 6; i++) {
130 block_index[i])) < 0)
134 }
135 return 0;
136 }
137
139 {
142
143 uint8_t *dest_y = frame->
data[0] + (mb_y * 16* linesize ) + mb_x * 16;
146
151
155 }
156 }
157
159 void *
data,
int *got_frame,
161 {
164 int buf_size = avpkt->
size;
167
172
176 for (i = 0; i < buf_size; i += 2) {
179 }
182
183 /* skip over 4 preamble bytes in stream (typically 0xXX 0xXX 0x00 0x38) */
185
188
190
195
197 }
198 }
199
200 *got_frame = 1;
201
203 }
204
206 {
208
211
213
217
221
222 return 0;
223 }
224
226 {
228
230
231 return 0;
232 }
233
235 {
237
240
241 return 0;
242 }
243
255 };