annotate roqvideo.c @ 1455:c4539ef4d8cb libavcodec

removed warnings
author bellard
date Tue, 09 Sep 2003 22:59:16 +0000
parents a4d00b1f0271
children 07029b2cd44f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
1 /*
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
2 * Copyright (C) 2003 the ffmpeg project
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
3 *
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
4 * This library is free software; you can redistribute it and/or
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
5 * modify it under the terms of the GNU Lesser General Public
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
7 * version 2 of the License, or (at your option) any later version.
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
8 *
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
9 * This library is distributed in the hope that it will be useful,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
12 * Lesser General Public License for more details.
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
13 *
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
14 * You should have received a copy of the GNU Lesser General Public
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
15 * License along with this library; if not, write to the Free Software
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
17 *
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
18 */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
19
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
20 /**
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
21 * @file roqvideo.c
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
22 * Id RoQ Video Decoder by Dr. Tim Ferguson
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
23 * For more information about the Id RoQ format, visit:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
24 * http://www.csse.monash.edu.au/~timf/
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
25 */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
26
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
27 #include <stdio.h>
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
28 #include <stdlib.h>
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
29 #include <string.h>
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
30 #include <unistd.h>
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
31
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
32 #include "common.h"
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
33 #include "avcodec.h"
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
34 #include "dsputil.h"
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
35
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
36 typedef struct {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
37 unsigned char y0, y1, y2, y3, u, v;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
38 } roq_cell;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
39
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
40 typedef struct {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
41 int idx[4];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
42 } roq_qcell;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
43
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
44
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
45 typedef struct RoqContext {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
46
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
47 AVCodecContext *avctx;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
48 DSPContext dsp;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
49 AVFrame last_frame;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
50 AVFrame current_frame;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
51 int first_frame;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
52 int y_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
53 int c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
54
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
55 roq_cell cells[256];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
56 roq_qcell qcells[256];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
57
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
58 unsigned char *buf;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
59 int size;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
60
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
61 } RoqContext;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
62
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
63 #define RoQ_INFO 0x1001
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
64 #define RoQ_QUAD_CODEBOOK 0x1002
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
65 #define RoQ_QUAD_VQ 0x1011
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
66 #define RoQ_SOUND_MONO 0x1020
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
67 #define RoQ_SOUND_STEREO 0x1021
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
68
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
69 #define RoQ_ID_MOT 0x00
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
70 #define RoQ_ID_FCC 0x01
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
71 #define RoQ_ID_SLD 0x02
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
72 #define RoQ_ID_CCC 0x03
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
73
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
74 #define get_byte(in_buffer) *(in_buffer++)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
75 #define get_word(in_buffer) ((unsigned short)(in_buffer += 2, \
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
76 (in_buffer[-1] << 8 | in_buffer[-2])))
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
77 #define get_long(in_buffer) ((unsigned long)(in_buffer += 4, \
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
78 (in_buffer[-1] << 24 | in_buffer[-2] << 16 | in_buffer[-3] << 8 | in_buffer[-4])))
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
79
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
80
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
81 static void apply_vector_2x2(RoqContext *ri, int x, int y, roq_cell *cell)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
82 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
83 unsigned char *yptr;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
84
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
85 yptr = ri->current_frame.data[0] + (y * ri->y_stride) + x;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
86 *yptr++ = cell->y0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
87 *yptr++ = cell->y1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
88 yptr += (ri->y_stride - 2);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
89 *yptr++ = cell->y2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
90 *yptr++ = cell->y3;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
91 ri->current_frame.data[1][(y/2) * (ri->c_stride) + x/2] = cell->u;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
92 ri->current_frame.data[2][(y/2) * (ri->c_stride) + x/2] = cell->v;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
93 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
94
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
95 static void apply_vector_4x4(RoqContext *ri, int x, int y, roq_cell *cell)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
96 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
97 unsigned long row_inc, c_row_inc;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
98 register unsigned char y0, y1, u, v;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
99 unsigned char *yptr, *uptr, *vptr;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
100
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
101 yptr = ri->current_frame.data[0] + (y * ri->y_stride) + x;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
102 uptr = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
103 vptr = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
104
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
105 row_inc = ri->y_stride - 4;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
106 c_row_inc = (ri->c_stride) - 2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
107 *yptr++ = y0 = cell->y0; *uptr++ = u = cell->u; *vptr++ = v = cell->v;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
108 *yptr++ = y0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
109 *yptr++ = y1 = cell->y1; *uptr++ = u; *vptr++ = v;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
110 *yptr++ = y1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
111
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
112 yptr += row_inc;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
113
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
114 *yptr++ = y0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
115 *yptr++ = y0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
116 *yptr++ = y1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
117 *yptr++ = y1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
118
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
119 yptr += row_inc; uptr += c_row_inc; vptr += c_row_inc;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
120
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
121 *yptr++ = y0 = cell->y2; *uptr++ = u; *vptr++ = v;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
122 *yptr++ = y0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
123 *yptr++ = y1 = cell->y3; *uptr++ = u; *vptr++ = v;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
124 *yptr++ = y1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
125
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
126 yptr += row_inc;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
127
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
128 *yptr++ = y0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
129 *yptr++ = y0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
130 *yptr++ = y1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
131 *yptr++ = y1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
132 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
133
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
134 static void apply_motion_4x4(RoqContext *ri, int x, int y, unsigned char mv,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
135 char mean_x, char mean_y)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
136 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
137 int i, mx, my;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
138 unsigned char *pa, *pb;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
139
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
140 mx = x + 8 - (mv >> 4) - mean_x;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
141 my = y + 8 - (mv & 0xf) - mean_y;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
142
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
143 pa = ri->current_frame.data[0] + (y * ri->y_stride) + x;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
144 pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
145 for(i = 0; i < 4; i++) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
146 pa[0] = pb[0];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
147 pa[1] = pb[1];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
148 pa[2] = pb[2];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
149 pa[3] = pb[3];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
150 pa += ri->y_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
151 pb += ri->y_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
152 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
153
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
154 pa = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
155 pb = ri->last_frame.data[1] + (my/2) * (ri->c_stride) + (mx + 1)/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
156 for(i = 0; i < 2; i++) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
157 pa[0] = pb[0];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
158 pa[1] = pb[1];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
159 pa += ri->c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
160 pb += ri->c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
161 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
162
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
163 pa = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
164 pb = ri->last_frame.data[2] + (my/2) * (ri->c_stride) + (mx + 1)/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
165 for(i = 0; i < 2; i++) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
166 pa[0] = pb[0];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
167 pa[1] = pb[1];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
168 pa += ri->c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
169 pb += ri->c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
170 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
171 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
172
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
173 static void apply_motion_8x8(RoqContext *ri, int x, int y,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
174 unsigned char mv, char mean_x, char mean_y)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
175 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
176 int mx, my, i;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
177 unsigned char *pa, *pb;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
178
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
179 mx = x + 8 - (mv >> 4) - mean_x;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
180 my = y + 8 - (mv & 0xf) - mean_y;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
181
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
182 pa = ri->current_frame.data[0] + (y * ri->y_stride) + x;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
183 pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
184 for(i = 0; i < 8; i++) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
185 pa[0] = pb[0];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
186 pa[1] = pb[1];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
187 pa[2] = pb[2];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
188 pa[3] = pb[3];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
189 pa[4] = pb[4];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
190 pa[5] = pb[5];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
191 pa[6] = pb[6];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
192 pa[7] = pb[7];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
193 pa += ri->y_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
194 pb += ri->y_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
195 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
196
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
197 pa = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
198 pb = ri->last_frame.data[1] + (my/2) * (ri->c_stride) + (mx + 1)/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
199 for(i = 0; i < 4; i++) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
200 pa[0] = pb[0];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
201 pa[1] = pb[1];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
202 pa[2] = pb[2];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
203 pa[3] = pb[3];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
204 pa += ri->c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
205 pb += ri->c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
206 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
207
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
208 pa = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
209 pb = ri->last_frame.data[2] + (my/2) * (ri->c_stride) + (mx + 1)/2;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
210 for(i = 0; i < 4; i++) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
211 pa[0] = pb[0];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
212 pa[1] = pb[1];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
213 pa[2] = pb[2];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
214 pa[3] = pb[3];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
215 pa += ri->c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
216 pb += ri->c_stride;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
217 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
218 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
219
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
220 static void roqvideo_decode_frame(RoqContext *ri)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
221 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
222 unsigned int chunk_id = 0, chunk_arg = 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
223 unsigned long chunk_size = 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
224 int i, j, k, nv1, nv2, vqflg = 0, vqflg_pos = -1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
225 int vqid, bpos, xpos, ypos, xp, yp, x, y;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
226 int frame_stats[2][4] = {{0},{0}};
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
227 roq_qcell *qcell;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
228 unsigned char *buf = ri->buf;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
229 unsigned char *buf_end = ri->buf + ri->size;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
230
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
231 while (buf < buf_end) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
232 chunk_id = get_word(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
233 chunk_size = get_long(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
234 chunk_arg = get_word(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
235
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
236 if(chunk_id == RoQ_QUAD_VQ)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
237 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
238 if(chunk_id == RoQ_QUAD_CODEBOOK) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
239 if((nv1 = chunk_arg >> 8) == 0)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
240 nv1 = 256;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
241 if((nv2 = chunk_arg & 0xff) == 0 && nv1 * 6 < chunk_size)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
242 nv2 = 256;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
243 for(i = 0; i < nv1; i++) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
244 ri->cells[i].y0 = get_byte(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
245 ri->cells[i].y1 = get_byte(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
246 ri->cells[i].y2 = get_byte(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
247 ri->cells[i].y3 = get_byte(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
248 ri->cells[i].u = get_byte(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
249 ri->cells[i].v = get_byte(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
250 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
251 for(i = 0; i < nv2; i++)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
252 for(j = 0; j < 4; j++)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
253 ri->qcells[i].idx[j] = get_byte(buf);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
254 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
255 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
256
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
257 bpos = xpos = ypos = 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
258 while(bpos < chunk_size) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
259 for (yp = ypos; yp < ypos + 16; yp += 8)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
260 for (xp = xpos; xp < xpos + 16; xp += 8) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
261 if (vqflg_pos < 0) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
262 vqflg = buf[bpos++]; vqflg |= (buf[bpos++] << 8);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
263 vqflg_pos = 7;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
264 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
265 vqid = (vqflg >> (vqflg_pos * 2)) & 0x3;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
266 frame_stats[0][vqid]++;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
267 vqflg_pos--;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
268
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
269 switch(vqid) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
270 case RoQ_ID_MOT:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
271 apply_motion_8x8(ri, xp, yp, 0, 8, 8);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
272 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
273 case RoQ_ID_FCC:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
274 apply_motion_8x8(ri, xp, yp, buf[bpos++], chunk_arg >> 8,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
275 chunk_arg & 0xff);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
276 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
277 case RoQ_ID_SLD:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
278 qcell = ri->qcells + buf[bpos++];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
279 apply_vector_4x4(ri, xp, yp, ri->cells + qcell->idx[0]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
280 apply_vector_4x4(ri, xp+4, yp, ri->cells + qcell->idx[1]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
281 apply_vector_4x4(ri, xp, yp+4, ri->cells + qcell->idx[2]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
282 apply_vector_4x4(ri, xp+4, yp+4, ri->cells + qcell->idx[3]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
283 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
284 case RoQ_ID_CCC:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
285 for (k = 0; k < 4; k++) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
286 x = xp; y = yp;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
287 if(k & 0x01) x += 4;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
288 if(k & 0x02) y += 4;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
289
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
290 if (vqflg_pos < 0) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
291 vqflg = buf[bpos++];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
292 vqflg |= (buf[bpos++] << 8);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
293 vqflg_pos = 7;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
294 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
295 vqid = (vqflg >> (vqflg_pos * 2)) & 0x3;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
296 frame_stats[1][vqid]++;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
297 vqflg_pos--;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
298 switch(vqid) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
299 case RoQ_ID_MOT:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
300 apply_motion_4x4(ri, x, y, 0, 8, 8);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
301 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
302 case RoQ_ID_FCC:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
303 apply_motion_4x4(ri, x, y, buf[bpos++],
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
304 chunk_arg >> 8, chunk_arg & 0xff);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
305 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
306 case RoQ_ID_SLD:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
307 qcell = ri->qcells + buf[bpos++];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
308 apply_vector_2x2(ri, x, y, ri->cells + qcell->idx[0]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
309 apply_vector_2x2(ri, x+2, y, ri->cells + qcell->idx[1]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
310 apply_vector_2x2(ri, x, y+2, ri->cells + qcell->idx[2]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
311 apply_vector_2x2(ri, x+2, y+2, ri->cells + qcell->idx[3]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
312 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
313 case RoQ_ID_CCC:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
314 apply_vector_2x2(ri, x, y, ri->cells + buf[bpos]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
315 apply_vector_2x2(ri, x+2, y, ri->cells + buf[bpos+1]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
316 apply_vector_2x2(ri, x, y+2, ri->cells + buf[bpos+2]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
317 apply_vector_2x2(ri, x+2, y+2, ri->cells + buf[bpos+3]);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
318 bpos += 4;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
319 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
320 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
321 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
322 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
323 default:
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
324 printf("Unknown vq code: %d\n", vqid);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
325 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
326 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
327
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
328 xpos += 16;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
329 if (xpos >= ri->avctx->width) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
330 xpos -= ri->avctx->width;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
331 ypos += 16;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
332 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
333 if(ypos >= ri->avctx->height)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
334 break;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
335 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
336 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
337
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
338
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
339 static int roq_decode_init(AVCodecContext *avctx)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
340 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
341 RoqContext *s = avctx->priv_data;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
342
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
343 s->avctx = avctx;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
344 s->first_frame = 1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
345 avctx->pix_fmt = PIX_FMT_YUV420P;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
346 avctx->has_b_frames = 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
347 dsputil_init(&s->dsp, avctx);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
348
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
349 return 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
350 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
351
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
352 static int roq_decode_frame(AVCodecContext *avctx,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
353 void *data, int *data_size,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
354 uint8_t *buf, int buf_size)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
355 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
356 RoqContext *s = avctx->priv_data;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
357
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
358 *data_size = 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
359
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
360 if (avctx->get_buffer(avctx, &s->current_frame)) {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
361 printf (" RoQ: get_buffer() failed\n");
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
362 return -1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
363 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
364 s->y_stride = s->current_frame.linesize[0];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
365 s->c_stride = s->current_frame.linesize[1];
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
366
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
367 s->buf = buf;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
368 s->size = buf_size;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
369 roqvideo_decode_frame(s);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
370
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
371 /* release the last frame if it is allocated */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
372 if (s->first_frame)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
373 s->first_frame = 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
374 else
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
375 avctx->release_buffer(avctx, &s->last_frame);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
376
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
377 /* shuffle frames */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
378 s->last_frame = s->current_frame;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
379
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
380 *data_size = sizeof(AVFrame);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
381 *(AVFrame*)data = s->current_frame;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
382
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
383 return buf_size;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
384 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
385
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
386 static int roq_decode_end(AVCodecContext *avctx)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
387 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
388 RoqContext *s = avctx->priv_data;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
389
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
390 /* release the last frame */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
391 avctx->release_buffer(avctx, &s->last_frame);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
392
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
393 return 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
394 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
395
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
396 AVCodec roq_decoder = {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
397 "roqvideo",
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
398 CODEC_TYPE_VIDEO,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
399 CODEC_ID_ROQ,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
400 sizeof(RoqContext),
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
401 roq_decode_init,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
402 NULL,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
403 roq_decode_end,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
404 roq_decode_frame,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
405 CODEC_CAP_DR1,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
406 };