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
37
57
58 //very similar to MPEG-1
60 {
62 int component;
66 const int qscale = a->
qscale;
67
68 /* DC coefficient */
71 } else {
72 component = (n <= 3 ? 0 : n - 4 + 1);
74 if (diff >= 0xffff)
77 block[0] = a->
last_dc[component] << 3;
78 }
79
80 i = 0;
81 {
83 /* now quantify & encode AC coefficients */
84 for (;;) {
87
88 if (level == 127) {
89 break;
90 } else if (level != 0) {
92 j = scantable[i];
93 level = (level * qscale * quant_matrix[j]) >> 3;
96 } else {
97 /* escape */
102 j = scantable[i];
103 if (level < 0) {
105 level = (level * qscale * quant_matrix[j]) >> 3;
106 level = (level - 1) | 1;
108 } else {
109 level = (level * qscale * quant_matrix[j]) >> 3;
110 level = (level - 1) | 1;
111 }
112 }
113 if (i > 63) {
116 }
117
119 }
121 }
123 return 0;
124 }
125
127 {
129 static const int block_index[6] = { 5, 4, 0, 1, 2, 3 };
130
132
133 for (i = 0; i < 6; i++) {
135 block_index[i])) < 0)
139 }
140 return 0;
141 }
142
144 {
147
148 uint8_t *dest_y = frame->
data[0] + (mb_y * 16* linesize ) + mb_x * 16;
151
156
160 }
161 }
162
164 void *
data,
int *got_frame,
166 {
169 int buf_size = avpkt->
size;
172
177
184
185 /* skip over 4 preamble bytes in stream (typically 0xXX 0xXX 0x00 0x38) */
187
190
192
197
199 }
200 }
201
202 *got_frame = 1;
203
205 }
206
208 {
210
213
215
222
227
228 return 0;
229 }
230
232 {
234
236
237 return 0;
238 }
239
241 {
243
246
247 return 0;
248 }
249
261 };