Mercurial > mplayer.hg
annotate cinepak.c @ 4771:ef9079037084
remove uneeded assert (common case at eof)
author | atmos4 |
---|---|
date | Wed, 20 Feb 2002 22:41:54 +0000 |
parents | 1504901deed8 |
children | f5f854541977 |
rev | line source |
---|---|
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
1 /* ------------------------------------------------------------------------ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
2 * Radius Cinepak Video Decoder |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
3 * |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
4 * Dr. Tim Ferguson, 2001. |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
5 * For more details on the algorithm: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
6 * http://www.csse.monash.edu.au/~timf/videocodec.html |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
7 * |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
8 * This is basically a vector quantiser with adaptive vector density. The |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
9 * frame is segmented into 4x4 pixel blocks, and each block is coded using |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
10 * either 1 or 4 vectors. |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
11 * |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
12 * There are still some issues with this code yet to be resolved. In |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
13 * particular with decoding in the strip boundaries. |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
14 * ------------------------------------------------------------------------ */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
15 #include <stdio.h> |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
16 #include <stdlib.h> |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
17 #include <string.h> |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
18 #include <sys/types.h> |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
19 #include <unistd.h> |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
20 #include <math.h> |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
21 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
22 #include "config.h" |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
23 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
24 #define DBUG 0 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
25 #define MAX_STRIPS 32 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
26 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
27 /* ------------------------------------------------------------------------ */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
28 typedef struct |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
29 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
30 unsigned char y0, y1, y2, y3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
31 char u, v; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
32 unsigned long rgb0, rgb1, rgb2, rgb3; /* should be a union */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
33 unsigned char r[4], g[4], b[4]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
34 } cvid_codebook; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
35 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
36 typedef struct { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
37 cvid_codebook *v4_codebook[MAX_STRIPS]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
38 cvid_codebook *v1_codebook[MAX_STRIPS]; |
4628
1504901deed8
Fixed FILM demuxer so that it now plays (my) FILM files
melanson
parents:
4076
diff
changeset
|
39 unsigned long strip_num; |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
40 } cinepak_info; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
41 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
42 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
43 /* ------------------------------------------------------------------------ */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
44 static unsigned char *in_buffer, uiclip[1024], *uiclp = NULL; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
45 |
4076
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
46 #define SCALEBITS 16 |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
47 #define ONE_HALF ((long) 1 << (SCALEBITS-1)) |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
48 #define FIX(x) ((long) ((x) * (1L<<SCALEBITS) + 0.5)) |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
49 static long CU_Y_tab[256], CV_Y_tab[256], CU_Cb_tab[256], CV_Cb_tab[256], |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
50 CU_Cr_tab[256], CV_Cr_tab[256]; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
51 |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
52 #define get_byte() *(in_buffer++) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
53 #define skip_byte() in_buffer++ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
54 #define get_word() ((unsigned short)(in_buffer += 2, \ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
55 (in_buffer[-2] << 8 | in_buffer[-1]))) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
56 #define get_long() ((unsigned long)(in_buffer += 4, \ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
57 (in_buffer[-4] << 24 | in_buffer[-3] << 16 | in_buffer[-2] << 8 | in_buffer[-1]))) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
58 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
59 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
60 /* ---------------------------------------------------------------------- */ |
3646 | 61 static inline void read_codebook_yuy2(cvid_codebook *c, int mode) |
62 { | |
4076
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
63 unsigned char y0, y1, y2, y3, u, v; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
64 int y_uv; |
3646 | 65 |
66 if(mode) /* black and white */ | |
67 { | |
68 c->y0 = get_byte(); | |
69 c->y1 = get_byte(); | |
70 c->y2 = get_byte(); | |
71 c->y3 = get_byte(); | |
72 c->u = c->v = 128; | |
73 } | |
74 else /* colour */ | |
75 { | |
4076
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
76 y0 = get_byte(); /* luma */ |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
77 y1 = get_byte(); |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
78 y2 = get_byte(); |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
79 y3 = get_byte(); |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
80 u = 128+get_byte(); /* chroma */ |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
81 v = 128+get_byte(); |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
82 |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
83 /* YUV * inv(CinYUV) |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
84 * | Y | | 1 -0.0655 0.0110 | | CY | |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
85 * | Cb | = | 0 1.1656 -0.0062 | | CU | |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
86 * | Cr | | 0 0.0467 1.4187 | | CV | |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
87 */ |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
88 y_uv = (int)((CU_Y_tab[u] + CV_Y_tab[v]) >> SCALEBITS); |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
89 c->y0 = uiclp[y0 + y_uv]; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
90 c->y1 = uiclp[y1 + y_uv]; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
91 c->y2 = uiclp[y2 + y_uv]; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
92 c->y3 = uiclp[y3 + y_uv]; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
93 c->u = uiclp[(int)((CU_Cb_tab[u] + CV_Cb_tab[v]) >> SCALEBITS)]; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
94 c->v = uiclp[(int)((CU_Cr_tab[u] + CV_Cr_tab[v]) >> SCALEBITS)]; |
3646 | 95 } |
96 } | |
97 | |
98 //#define PACK_YUV(cb,y0,y1,u,v) ((cb->y0<<24)|(((unsigned char)cb->u)<<16)|(cb->y1<<8)|(((unsigned char)cb->v))) | |
99 #define PACK_YUV(cb,y0,y1,u,v) ((((unsigned char)cb->v)<<24)|(cb->y1<<16)|(((unsigned char)cb->u)<<8)|(cb->y0)) | |
100 | |
101 #define TO_YUY2_U0(cb) PACK_YUV(cb,y0,y0,u,v) | |
102 #define TO_YUY2_U1(cb) PACK_YUV(cb,y1,y1,u,v) | |
103 #define TO_YUY2_L0(cb) PACK_YUV(cb,y2,y2,u,v) | |
104 #define TO_YUY2_L1(cb) PACK_YUV(cb,y3,y3,u,v) | |
105 | |
106 #define TO_YUY2_U(cb) PACK_YUV(cb,y0,y1,u,v) | |
107 #define TO_YUY2_L(cb) PACK_YUV(cb,y2,y3,u,v) | |
108 | |
109 /* ------------------------------------------------------------------------ */ | |
110 inline void cvid_v1_yuy2(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb) | |
111 { | |
112 unsigned long *vptr = (unsigned long *)frm, rgb; | |
113 int row_inc = stride/4; | |
114 | |
115 vptr[0] = TO_YUY2_U0(cb); | |
116 vptr[1] = TO_YUY2_U1(cb); | |
117 vptr += row_inc; if(vptr > (unsigned long *)end) return; | |
118 | |
119 vptr[0] = TO_YUY2_U0(cb); | |
120 vptr[1] = TO_YUY2_U1(cb); | |
121 vptr += row_inc; if(vptr > (unsigned long *)end) return; | |
122 | |
123 vptr[0] = TO_YUY2_L0(cb); | |
124 vptr[1] = TO_YUY2_L1(cb); | |
125 vptr += row_inc; if(vptr > (unsigned long *)end) return; | |
126 | |
127 vptr[0] = TO_YUY2_L0(cb); | |
128 vptr[1] = TO_YUY2_L1(cb); | |
129 } | |
130 | |
131 | |
132 /* ------------------------------------------------------------------------ */ | |
133 inline void cvid_v4_yuy2(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb0, | |
134 cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) | |
135 { | |
136 unsigned long *vptr = (unsigned long *)frm; | |
137 int row_inc = stride/4; | |
138 | |
139 vptr[0] = TO_YUY2_U(cb0); | |
140 vptr[1] = TO_YUY2_U(cb1); | |
141 vptr += row_inc; if(vptr > (unsigned long *)end) return; | |
142 | |
143 vptr[0] = TO_YUY2_L(cb0); | |
144 vptr[1] = TO_YUY2_L(cb1); | |
145 vptr += row_inc; if(vptr > (unsigned long *)end) return; | |
146 | |
147 vptr[0] = TO_YUY2_U(cb2); | |
148 vptr[1] = TO_YUY2_U(cb3); | |
149 vptr += row_inc; if(vptr > (unsigned long *)end) return; | |
150 | |
151 vptr[0] = TO_YUY2_L(cb2); | |
152 vptr[1] = TO_YUY2_L(cb3); | |
153 | |
154 } | |
155 | |
156 | |
157 /* ---------------------------------------------------------------------- */ | |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
158 static inline void read_codebook_32(cvid_codebook *c, int mode) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
159 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
160 int uvr, uvg, uvb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
161 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
162 if(mode) /* black and white */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
163 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
164 c->y0 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
165 c->y1 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
166 c->y2 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
167 c->y3 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
168 c->u = c->v = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
169 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
170 c->rgb0 = (c->y0 << 16) | (c->y0 << 8) | c->y0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
171 c->rgb1 = (c->y1 << 16) | (c->y1 << 8) | c->y1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
172 c->rgb2 = (c->y2 << 16) | (c->y2 << 8) | c->y2; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
173 c->rgb3 = (c->y3 << 16) | (c->y3 << 8) | c->y3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
174 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
175 else /* colour */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
176 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
177 c->y0 = get_byte(); /* luma */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
178 c->y1 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
179 c->y2 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
180 c->y3 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
181 c->u = get_byte(); /* chroma */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
182 c->v = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
183 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
184 uvr = c->v << 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
185 uvg = -((c->u+1) >> 1) - c->v; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
186 uvb = c->u << 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
187 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
188 c->rgb0 = (uiclp[c->y0 + uvr] << 16) | (uiclp[c->y0 + uvg] << 8) | uiclp[c->y0 + uvb]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
189 c->rgb1 = (uiclp[c->y1 + uvr] << 16) | (uiclp[c->y1 + uvg] << 8) | uiclp[c->y1 + uvb]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
190 c->rgb2 = (uiclp[c->y2 + uvr] << 16) | (uiclp[c->y2 + uvg] << 8) | uiclp[c->y2 + uvb]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
191 c->rgb3 = (uiclp[c->y3 + uvr] << 16) | (uiclp[c->y3 + uvg] << 8) | uiclp[c->y3 + uvb]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
192 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
193 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
194 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
195 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
196 /* ------------------------------------------------------------------------ */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
197 inline void cvid_v1_32(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
198 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
199 unsigned long *vptr = (unsigned long *)frm, rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
200 int row_inc = stride/4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
201 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
202 vptr[0] = rgb = cb->rgb0; vptr[1] = rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
203 vptr[2] = rgb = cb->rgb1; vptr[3] = rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
204 vptr += row_inc; if(vptr > (unsigned long *)end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
205 vptr[0] = rgb = cb->rgb0; vptr[1] = rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
206 vptr[2] = rgb = cb->rgb1; vptr[3] = rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
207 vptr += row_inc; if(vptr > (unsigned long *)end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
208 vptr[0] = rgb = cb->rgb2; vptr[1] = rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
209 vptr[2] = rgb = cb->rgb3; vptr[3] = rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
210 vptr += row_inc; if(vptr > (unsigned long *)end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
211 vptr[0] = rgb = cb->rgb2; vptr[1] = rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
212 vptr[2] = rgb = cb->rgb3; vptr[3] = rgb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
213 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
214 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
215 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
216 /* ------------------------------------------------------------------------ */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
217 inline void cvid_v4_32(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb0, |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
218 cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
219 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
220 unsigned long *vptr = (unsigned long *)frm; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
221 int row_inc = stride/4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
222 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
223 vptr[0] = cb0->rgb0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
224 vptr[1] = cb0->rgb1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
225 vptr[2] = cb1->rgb0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
226 vptr[3] = cb1->rgb1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
227 vptr += row_inc; if(vptr > (unsigned long *)end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
228 vptr[0] = cb0->rgb2; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
229 vptr[1] = cb0->rgb3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
230 vptr[2] = cb1->rgb2; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
231 vptr[3] = cb1->rgb3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
232 vptr += row_inc; if(vptr > (unsigned long *)end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
233 vptr[0] = cb2->rgb0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
234 vptr[1] = cb2->rgb1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
235 vptr[2] = cb3->rgb0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
236 vptr[3] = cb3->rgb1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
237 vptr += row_inc; if(vptr > (unsigned long *)end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
238 vptr[0] = cb2->rgb2; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
239 vptr[1] = cb2->rgb3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
240 vptr[2] = cb3->rgb2; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
241 vptr[3] = cb3->rgb3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
242 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
243 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
244 |
3646 | 245 |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
246 /* ---------------------------------------------------------------------- */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
247 static inline void read_codebook_24(cvid_codebook *c, int mode) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
248 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
249 int uvr, uvg, uvb; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
250 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
251 if(mode) /* black and white */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
252 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
253 c->y0 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
254 c->y1 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
255 c->y2 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
256 c->y3 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
257 c->u = c->v = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
258 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
259 c->r[0] = c->g[0] = c->b[0] = c->y0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
260 c->r[1] = c->g[1] = c->b[1] = c->y1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
261 c->r[2] = c->g[2] = c->b[2] = c->y2; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
262 c->r[3] = c->g[3] = c->b[3] = c->y3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
263 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
264 else /* colour */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
265 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
266 c->y0 = get_byte(); /* luma */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
267 c->y1 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
268 c->y2 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
269 c->y3 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
270 c->u = get_byte(); /* chroma */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
271 c->v = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
272 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
273 uvr = c->v << 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
274 uvg = -((c->u+1) >> 1) - c->v; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
275 uvb = c->u << 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
276 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
277 c->r[0] = uiclp[c->y0 + uvr]; c->g[0] = uiclp[c->y0 + uvg]; c->b[0] = uiclp[c->y0 + uvb]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
278 c->r[1] = uiclp[c->y1 + uvr]; c->g[1] = uiclp[c->y1 + uvg]; c->b[1] = uiclp[c->y1 + uvb]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
279 c->r[2] = uiclp[c->y2 + uvr]; c->g[2] = uiclp[c->y2 + uvg]; c->b[2] = uiclp[c->y2 + uvb]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
280 c->r[3] = uiclp[c->y3 + uvr]; c->g[3] = uiclp[c->y3 + uvg]; c->b[3] = uiclp[c->y3 + uvb]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
281 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
282 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
283 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
284 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
285 /* ------------------------------------------------------------------------ */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
286 void cvid_v1_24(unsigned char *vptr, unsigned char *end, int stride, cvid_codebook *cb) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
287 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
288 unsigned char r, g, b; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
289 int row_inc = stride-4*3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
290 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
291 *vptr++ = b = cb->b[0]; *vptr++ = g = cb->g[0]; *vptr++ = r = cb->r[0]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
292 *vptr++ = b; *vptr++ = g; *vptr++ = r; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
293 *vptr++ = b = cb->b[1]; *vptr++ = g = cb->g[1]; *vptr++ = r = cb->r[1]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
294 *vptr++ = b; *vptr++ = g; *vptr++ = r; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
295 vptr += row_inc; if(vptr > end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
296 *vptr++ = b = cb->b[0]; *vptr++ = g = cb->g[0]; *vptr++ = r = cb->r[0]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
297 *vptr++ = b; *vptr++ = g; *vptr++ = r; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
298 *vptr++ = b = cb->b[1]; *vptr++ = g = cb->g[1]; *vptr++ = r = cb->r[1]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
299 *vptr++ = b; *vptr++ = g; *vptr++ = r; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
300 vptr += row_inc; if(vptr > end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
301 *vptr++ = b = cb->b[2]; *vptr++ = g = cb->g[2]; *vptr++ = r = cb->r[2]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
302 *vptr++ = b; *vptr++ = g; *vptr++ = r; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
303 *vptr++ = b = cb->b[3]; *vptr++ = g = cb->g[3]; *vptr++ = r = cb->r[3]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
304 *vptr++ = b; *vptr++ = g; *vptr++ = r; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
305 vptr += row_inc; if(vptr > end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
306 *vptr++ = b = cb->b[2]; *vptr++ = g = cb->g[2]; *vptr++ = r = cb->r[2]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
307 *vptr++ = b; *vptr++ = g; *vptr++ = r; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
308 *vptr++ = b = cb->b[3]; *vptr++ = g = cb->g[3]; *vptr++ = r = cb->r[3]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
309 *vptr++ = b; *vptr++ = g; *vptr++ = r; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
310 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
311 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
312 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
313 /* ------------------------------------------------------------------------ */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
314 void cvid_v4_24(unsigned char *vptr, unsigned char *end, int stride, cvid_codebook *cb0, |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
315 cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
316 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
317 int row_inc = stride-4*3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
318 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
319 *vptr++ = cb0->b[0]; *vptr++ = cb0->g[0]; *vptr++ = cb0->r[0]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
320 *vptr++ = cb0->b[1]; *vptr++ = cb0->g[1]; *vptr++ = cb0->r[1]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
321 *vptr++ = cb1->b[0]; *vptr++ = cb1->g[0]; *vptr++ = cb1->r[0]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
322 *vptr++ = cb1->b[1]; *vptr++ = cb1->g[1]; *vptr++ = cb1->r[1]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
323 vptr += row_inc; if(vptr > end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
324 *vptr++ = cb0->b[2]; *vptr++ = cb0->g[2]; *vptr++ = cb0->r[2]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
325 *vptr++ = cb0->b[3]; *vptr++ = cb0->g[3]; *vptr++ = cb0->r[3]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
326 *vptr++ = cb1->b[2]; *vptr++ = cb1->g[2]; *vptr++ = cb1->r[2]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
327 *vptr++ = cb1->b[3]; *vptr++ = cb1->g[3]; *vptr++ = cb1->r[3]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
328 vptr += row_inc; if(vptr > end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
329 *vptr++ = cb2->b[0]; *vptr++ = cb2->g[0]; *vptr++ = cb2->r[0]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
330 *vptr++ = cb2->b[1]; *vptr++ = cb2->g[1]; *vptr++ = cb2->r[1]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
331 *vptr++ = cb3->b[0]; *vptr++ = cb3->g[0]; *vptr++ = cb3->r[0]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
332 *vptr++ = cb3->b[1]; *vptr++ = cb3->g[1]; *vptr++ = cb3->r[1]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
333 vptr += row_inc; if(vptr > end) return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
334 *vptr++ = cb2->b[2]; *vptr++ = cb2->g[2]; *vptr++ = cb2->r[2]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
335 *vptr++ = cb2->b[3]; *vptr++ = cb2->g[3]; *vptr++ = cb2->r[3]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
336 *vptr++ = cb3->b[2]; *vptr++ = cb3->g[2]; *vptr++ = cb3->r[2]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
337 *vptr++ = cb3->b[3]; *vptr++ = cb3->g[3]; *vptr++ = cb3->r[3]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
338 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
339 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
340 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
341 /* ------------------------------------------------------------------------ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
342 * Call this function once at the start of the sequence and save the |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
343 * returned context for calls to decode_cinepak(). |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
344 */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
345 void *decode_cinepak_init(void) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
346 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
347 cinepak_info *cvinfo; |
4076
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
348 int i, x; |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
349 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
350 if((cvinfo = calloc(sizeof(cinepak_info), 1)) == NULL) return NULL; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
351 cvinfo->strip_num = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
352 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
353 if(uiclp == NULL) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
354 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
355 uiclp = uiclip+512; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
356 for(i = -512; i < 512; i++) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
357 uiclp[i] = (i < 0 ? 0 : (i > 255 ? 255 : i)); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
358 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
359 |
4076
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
360 for(i = 0, x = -128; i < 256; i++, x++) |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
361 { |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
362 CU_Y_tab[i] = (-FIX(0.0655)) * x; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
363 CV_Y_tab[i] = (FIX(0.0110)) * x + ONE_HALF; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
364 CU_Cb_tab[i] = (FIX(1.1656)) * x; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
365 CV_Cb_tab[i] = (-FIX(0.0062)) * x + ONE_HALF + FIX(128); |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
366 CU_Cr_tab[i] = (FIX(0.0467)) * x; |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
367 CV_Cr_tab[i] = (FIX(1.4187)) * x + ONE_HALF + FIX(128); |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
368 } |
47b9d8d3f3c5
committed Tim Ferguson's patch for proper YUV color space conversion
melanson
parents:
3646
diff
changeset
|
369 |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
370 return (void *)cvinfo; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
371 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
372 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
373 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
374 /* ------------------------------------------------------------------------ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
375 * This function decodes a buffer containing a Cinepak encoded frame. |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
376 * |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
377 * context - the context created by decode_cinepak_init(). |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
378 * buf - the input buffer to be decoded |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
379 * size - the size of the input buffer |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
380 * frame - the output frame buffer (24 or 32 bit per pixel) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
381 * width - the width of the output frame |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
382 * height - the height of the output frame |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
383 * bit_per_pixel - the number of bits per pixel allocated to the output |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
384 * frame (only 24 or 32 bpp are supported) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
385 */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
386 void decode_cinepak(void *context, unsigned char *buf, int size, unsigned char *frame, int width, int height, int bit_per_pixel) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
387 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
388 cinepak_info *cvinfo = (cinepak_info *)context; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
389 cvid_codebook *v4_codebook, *v1_codebook, *codebook = NULL; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
390 unsigned long x, y, y_bottom, frame_flags, strips, cv_width, cv_height, cnum, |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
391 strip_id, chunk_id, x0, y0, x1, y1, ci, flag, mask; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
392 long len, top_size, chunk_size; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
393 unsigned char *frm_ptr, *frm_end; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
394 int i, cur_strip, d0, d1, d2, d3, frm_stride, bpp = 3; |
4628
1504901deed8
Fixed FILM demuxer so that it now plays (my) FILM files
melanson
parents:
4076
diff
changeset
|
395 int modulo; |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
396 void (*read_codebook)(cvid_codebook *c, int mode) = read_codebook_24; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
397 void (*cvid_v1)(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb) = cvid_v1_24; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
398 void (*cvid_v4)(unsigned char *frm, unsigned char *end, int stride, cvid_codebook *cb0, |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
399 cvid_codebook *cb1, cvid_codebook *cb2, cvid_codebook *cb3) = cvid_v4_24; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
400 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
401 x = y = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
402 y_bottom = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
403 in_buffer = buf; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
404 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
405 frame_flags = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
406 len = get_byte() << 16; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
407 len |= get_byte() << 8; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
408 len |= get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
409 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
410 switch(bit_per_pixel) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
411 { |
3646 | 412 case 16: |
413 bpp = 2; | |
414 read_codebook = read_codebook_yuy2; | |
415 cvid_v1 = cvid_v1_yuy2; | |
416 cvid_v4 = cvid_v4_yuy2; | |
417 break; | |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
418 case 24: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
419 bpp = 3; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
420 read_codebook = read_codebook_24; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
421 cvid_v1 = cvid_v1_24; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
422 cvid_v4 = cvid_v4_24; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
423 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
424 case 32: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
425 bpp = 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
426 read_codebook = read_codebook_32; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
427 cvid_v1 = cvid_v1_32; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
428 cvid_v4 = cvid_v4_32; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
429 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
430 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
431 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
432 frm_stride = width * bpp; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
433 frm_ptr = frame; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
434 frm_end = frm_ptr + width * height * bpp; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
435 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
436 if(len != size) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
437 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
438 if(len & 0x01) len++; /* AVIs tend to have a size mismatch */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
439 if(len != size) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
440 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
441 printf("CVID: corruption %d (QT/AVI) != %ld (CV)\n", size, len); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
442 // return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
443 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
444 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
445 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
446 cv_width = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
447 cv_height = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
448 strips = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
449 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
450 if(strips > cvinfo->strip_num) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
451 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
452 if(strips >= MAX_STRIPS) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
453 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
454 printf("CVID: strip overflow (more than %d)\n", MAX_STRIPS); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
455 return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
456 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
457 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
458 for(i = cvinfo->strip_num; i < strips; i++) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
459 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
460 if((cvinfo->v4_codebook[i] = (cvid_codebook *)calloc(sizeof(cvid_codebook), 260)) == NULL) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
461 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
462 printf("CVID: codebook v4 alloc err\n"); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
463 return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
464 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
465 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
466 if((cvinfo->v1_codebook[i] = (cvid_codebook *)calloc(sizeof(cvid_codebook), 260)) == NULL) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
467 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
468 printf("CVID: codebook v1 alloc err\n"); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
469 return; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
470 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
471 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
472 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
473 cvinfo->strip_num = strips; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
474 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
475 #if DBUG |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
476 printf("CVID: <%ld,%ld> strips %ld\n", cv_width, cv_height, strips); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
477 #endif |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
478 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
479 for(cur_strip = 0; cur_strip < strips; cur_strip++) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
480 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
481 v4_codebook = cvinfo->v4_codebook[cur_strip]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
482 v1_codebook = cvinfo->v1_codebook[cur_strip]; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
483 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
484 if((cur_strip > 0) && (!(frame_flags & 0x01))) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
485 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
486 memcpy(cvinfo->v4_codebook[cur_strip], cvinfo->v4_codebook[cur_strip-1], 260 * sizeof(cvid_codebook)); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
487 memcpy(cvinfo->v1_codebook[cur_strip], cvinfo->v1_codebook[cur_strip-1], 260 * sizeof(cvid_codebook)); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
488 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
489 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
490 strip_id = get_word(); /* 1000 = key strip, 1100 = iter strip */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
491 top_size = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
492 y0 = get_word(); /* FIXME: most of these are ignored at the moment */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
493 x0 = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
494 y1 = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
495 x1 = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
496 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
497 y_bottom += y1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
498 top_size -= 12; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
499 x = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
500 if(x1 != width) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
501 printf("CVID: Warning x1 (%ld) != width (%d)\n", x1, width); |
4628
1504901deed8
Fixed FILM demuxer so that it now plays (my) FILM files
melanson
parents:
4076
diff
changeset
|
502 x1 = width; |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
503 #if DBUG |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
504 printf(" %d) %04lx %04ld <%ld,%ld> <%ld,%ld> yt %ld %d\n", |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
505 cur_strip, strip_id, top_size, x0, y0, x1, y1, y_bottom); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
506 #endif |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
507 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
508 while(top_size > 0) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
509 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
510 chunk_id = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
511 chunk_size = get_word(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
512 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
513 #if DBUG |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
514 printf(" %04lx %04ld\n", chunk_id, chunk_size); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
515 #endif |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
516 top_size -= chunk_size; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
517 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
518 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
519 switch(chunk_id) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
520 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
521 /* -------------------- Codebook Entries -------------------- */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
522 case 0x2000: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
523 case 0x2200: |
4628
1504901deed8
Fixed FILM demuxer so that it now plays (my) FILM files
melanson
parents:
4076
diff
changeset
|
524 modulo = chunk_size % 6; |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
525 codebook = (chunk_id == 0x2200 ? v1_codebook : v4_codebook); |
4628
1504901deed8
Fixed FILM demuxer so that it now plays (my) FILM files
melanson
parents:
4076
diff
changeset
|
526 cnum = (chunk_size - modulo) / 6; |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
527 for(i = 0; i < cnum; i++) read_codebook(codebook+i, 0); |
4628
1504901deed8
Fixed FILM demuxer so that it now plays (my) FILM files
melanson
parents:
4076
diff
changeset
|
528 while (modulo--) |
1504901deed8
Fixed FILM demuxer so that it now plays (my) FILM files
melanson
parents:
4076
diff
changeset
|
529 get_byte(); |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
530 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
531 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
532 case 0x2400: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
533 case 0x2600: /* 8 bit per pixel */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
534 codebook = (chunk_id == 0x2600 ? v1_codebook : v4_codebook); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
535 cnum = chunk_size/4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
536 for(i = 0; i < cnum; i++) read_codebook(codebook+i, 1); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
537 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
538 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
539 case 0x2100: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
540 case 0x2300: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
541 codebook = (chunk_id == 0x2300 ? v1_codebook : v4_codebook); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
542 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
543 ci = 0; |
4628
1504901deed8
Fixed FILM demuxer so that it now plays (my) FILM files
melanson
parents:
4076
diff
changeset
|
544 while(chunk_size > 3) |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
545 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
546 flag = get_long(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
547 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
548 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
549 for(i = 0; i < 32; i++) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
550 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
551 if(flag & 0x80000000) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
552 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
553 chunk_size -= 6; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
554 read_codebook(codebook+ci, 0); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
555 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
556 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
557 ci++; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
558 flag <<= 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
559 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
560 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
561 while(chunk_size > 0) { skip_byte(); chunk_size--; } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
562 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
563 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
564 case 0x2500: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
565 case 0x2700: /* 8 bit per pixel */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
566 codebook = (chunk_id == 0x2700 ? v1_codebook : v4_codebook); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
567 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
568 ci = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
569 while(chunk_size > 0) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
570 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
571 flag = get_long(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
572 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
573 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
574 for(i = 0; i < 32; i++) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
575 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
576 if(flag & 0x80000000) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
577 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
578 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
579 read_codebook(codebook+ci, 1); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
580 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
581 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
582 ci++; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
583 flag <<= 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
584 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
585 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
586 while(chunk_size > 0) { skip_byte(); chunk_size--; } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
587 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
588 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
589 /* -------------------- Frame -------------------- */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
590 case 0x3000: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
591 while((chunk_size > 0) && (y < y_bottom)) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
592 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
593 flag = get_long(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
594 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
595 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
596 for(i = 0; i < 32; i++) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
597 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
598 if(y >= y_bottom) break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
599 if(flag & 0x80000000) /* 4 bytes per block */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
600 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
601 d0 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
602 d1 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
603 d2 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
604 d3 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
605 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
606 cvid_v4(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v4_codebook+d0, v4_codebook+d1, v4_codebook+d2, v4_codebook+d3); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
607 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
608 else /* 1 byte per block */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
609 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
610 cvid_v1(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v1_codebook + get_byte()); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
611 chunk_size--; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
612 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
613 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
614 x += 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
615 if(x >= width) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
616 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
617 x = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
618 y += 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
619 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
620 flag <<= 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
621 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
622 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
623 while(chunk_size > 0) { skip_byte(); chunk_size--; } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
624 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
625 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
626 case 0x3100: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
627 while((chunk_size > 0) && (y < y_bottom)) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
628 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
629 /* ---- flag bits: 0 = SKIP, 10 = V1, 11 = V4 ---- */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
630 flag = (unsigned long)get_long(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
631 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
632 mask = 0x80000000; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
633 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
634 while((mask) && (y < y_bottom)) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
635 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
636 if(flag & mask) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
637 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
638 if(mask == 1) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
639 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
640 if(chunk_size < 0) break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
641 flag = (unsigned long)get_long(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
642 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
643 mask = 0x80000000; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
644 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
645 else mask >>= 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
646 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
647 if(flag & mask) /* V4 */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
648 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
649 d0 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
650 d1 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
651 d2 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
652 d3 = get_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
653 chunk_size -= 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
654 cvid_v4(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v4_codebook+d0, v4_codebook+d1, v4_codebook+d2, v4_codebook+d3); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
655 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
656 else /* V1 */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
657 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
658 chunk_size--; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
659 cvid_v1(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v1_codebook + get_byte()); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
660 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
661 } /* else SKIP */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
662 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
663 mask >>= 1; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
664 x += 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
665 if(x >= width) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
666 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
667 x = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
668 y += 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
669 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
670 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
671 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
672 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
673 while(chunk_size > 0) { skip_byte(); chunk_size--; } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
674 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
675 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
676 case 0x3200: /* each byte is a V1 codebook */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
677 while((chunk_size > 0) && (y < y_bottom)) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
678 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
679 cvid_v1(frm_ptr + (y * frm_stride + x * bpp), frm_end, frm_stride, v1_codebook + get_byte()); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
680 chunk_size--; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
681 x += 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
682 if(x >= width) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
683 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
684 x = 0; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
685 y += 4; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
686 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
687 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
688 while(chunk_size > 0) { skip_byte(); chunk_size--; } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
689 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
690 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
691 default: |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
692 printf("CVID: unknown chunk_id %08lx\n", chunk_id); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
693 while(chunk_size > 0) { skip_byte(); chunk_size--; } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
694 break; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
695 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
696 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
697 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
698 |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
699 if(len != size) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
700 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
701 if(len & 0x01) len++; /* AVIs tend to have a size mismatch */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
702 if(len != size) |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
703 { |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
704 long xlen; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
705 skip_byte(); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
706 xlen = get_byte() << 16; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
707 xlen |= get_byte() << 8; |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
708 xlen |= get_byte(); /* Read Len */ |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
709 printf("CVID: END INFO chunk size %d cvid size1 %ld cvid size2 %ld\n", size, len, xlen); |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
710 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
711 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
712 } |
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
diff
changeset
|
713 |