1 /*
2 * Copyright (c) 2002 The FFmpeg Project
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
30
31
33 {
34 int mb_x, mb_y;
37
41 for (mb_y = 0; mb_y < s->
mb_height; mb_y++)
42 for (mb_x = 0; mb_x < s->
mb_width; mb_x++)
45 break;
48 for (mb_x = 0; mb_x < s->
mb_width; mb_x++)
51 break;
53 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
55 for (mb_x = 0; mb_x < s->
mb_width; mb_x++)
58 } else {
59 for (mb_x = 0; mb_x < s->
mb_width; mb_x++)
62 }
63 }
64 break;
66 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
68 for (mb_y = 0; mb_y < s->
mb_height; mb_y++)
71 } else {
72 for (mb_y = 0; mb_y < s->
mb_height; mb_y++)
75 }
76 }
77 break;
78 }
79 }
80
82 {
85 int fps;
86 int code;
87
90
92
102
103 if (code == 0)
105
107
110 "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, "
111 "tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, "
112 "slices:%d\n",
115 code);
116 return 0;
117 }
118
120 {
122 int code;
123
126
131 }
135
136 return 0;
137 }
138
140 {
142
146 else
147 w->
j_type = 0;
// FIXME check
148
152 else
154
158 }
159
161 }
166 "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",
169 }
170 } else {
171 int cbp_index;
173
177
180 else
181 s->
mspel = 0;
// FIXME check
182
187 }
188
191 else
193
197 }
198
201
202 s->
inter_intra_pred = 0;
// (s->width * s->height < 320 * 240 && s->bit_rate <= II_BITRATE);
204
207 "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d "
208 "per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",
214 }
215 }
219
222 return 1;
223 }
224
225 return 0;
226 }
227
229 {
232
234
235 if (ret < 0)
237
238 if ((((*mx_ptr) | (*my_ptr)) & 1) && s->
mspel)
240 else
242
243 return 0;
244 }
245
247 {
250 int16_t *
A, *
B, *
C, *mot_val;
251
254
256
260
263 else
264 diff = 0;
265
266 if (diff >= 8)
268 else
269 type = 2;
270
271 if (type == 0) {
272 *px = A[0];
273 *py = A[1];
274 } else if (type == 1) {
275 *px = B[0];
276 *py = B[1];
277 } else {
278 /* special case for first (slice) line */
280 *px = A[0];
281 *py = A[1];
282 } else {
285 }
286 }
287
288 return mot_val;
289 }
290
293 {
295 static const int sub_cbp_table[3] = { 2, 3, 1 };
297
298 if (!cbp) {
300 return 0;
301 }
302
306
308 // const uint8_t *scantable = w->abt_scantable[w->abt_type - 1].permutated;
310 // const uint8_t *scantable = w->abt_type - 1 ? w->abt_scantable[1].permutated : w->abt_scantable[0].scantable;
311
313
314 if (sub_cbp & 1)
317
318 if (sub_cbp & 2)
321
323
324 return 0;
325 } else {
328 }
329 }
330
332 {
334 int cbp, code, i,
ret;
336
338 return 0;
339
342 /* skip mb */
344 for (i = 0; i < 6; i++)
352 return 0;
353 }
354
357 if (code < 0)
360
361 cbp = code & 0x3f;
362 } else {
365 if (code < 0) {
367 "II-cbp illegal at %d %d\n", s->
mb_x, s->
mb_y);
369 }
370 /* predict coded block pattern */
371 cbp = 0;
372 for (i = 0; i < 6; i++) {
373 int val = ((code >> (5 - i)) & 1);
374 if (i < 4) {
378 }
379 cbp |= val << (5 - i);
380 }
381 }
382
384 int mx, my;
386
387 if (cbp) {
392 }
393
398 } else
400 }
401
404
409
410 for (i = 0; i < 6; i++) {
413 "\nerror while decoding inter block: %d x %d (%d)\n",
416 }
417 }
418 } else {
422 ((cbp & 3) ? 1 : 0) + ((cbp & 0x3C) ? 2 : 0),
430 }
434 }
435
437 for (i = 0; i < 6; i++) {
440 "\nerror while decoding intra block: %d x %d (%d)\n",
443 }
444 }
445 }
446
447 return 0;
448 }
449
451 {
454
456
459
461
463
464 return 0;
465 }
466
468 {
470
473 }
474
487 };