annotate indeo3.c @ 2169:db8baace74d8 libavcodec

Minor Patch for shared libs on Mac OSX by (Bill May <wmay at cisco dot com>)
author michael
date Fri, 13 Aug 2004 15:30:42 +0000
parents 141a9539e270
children 4a0cfd63f078
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1 /*
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
2 * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
3 * written, produced, and directed by Alan Smithee
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
4 *
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
9 *
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
13 * Lesser General Public License for more details.
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
14 *
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
18 */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
19
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
20 #include <stdio.h>
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
21 #include <stdlib.h>
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
22 #include <string.h>
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
23 #include <unistd.h>
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
24
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
25 #include "common.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
26 #include "avcodec.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
27 #include "dsputil.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
28 #include "mpegvideo.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
29
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
30 #include "indeo3data.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
31
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
32 typedef struct
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
33 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
34 unsigned char *Ybuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
35 unsigned char *Ubuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
36 unsigned char *Vbuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
37 unsigned char *the_buf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
38 unsigned int the_buf_size;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
39 unsigned short y_w, y_h;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
40 unsigned short uv_w, uv_h;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
41 } YUVBufs;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
42
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
43 typedef struct Indeo3DecodeContext {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
44 AVCodecContext *avctx;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
45 int width, height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
46 AVFrame frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
47
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
48 YUVBufs iv_frame[2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
49 YUVBufs *cur_frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
50 YUVBufs *ref_frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
51
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
52 unsigned char *ModPred;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
53 unsigned short *corrector_type;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
54 } Indeo3DecodeContext;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
55
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
56 static int corrector_type_0[24] = {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
57 195, 159, 133, 115, 101, 93, 87, 77,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
58 195, 159, 133, 115, 101, 93, 87, 77,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
59 128, 79, 79, 79, 79, 79, 79, 79
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
60 };
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
61
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
62 static int corrector_type_2[8] = { 9, 7, 6, 8, 5, 4, 3, 2 };
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
63
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
64 static void build_modpred(Indeo3DecodeContext *s)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
65 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
66 int i, j;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
67
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
68 s->ModPred = (unsigned char *) av_malloc (8 * 128);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
69
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
70 for (i=0; i < 128; ++i) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
71 s->ModPred[i+0*128] = (i > 126) ? 254 : 2*((i + 1) - ((i + 1) % 2));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
72 s->ModPred[i+1*128] = (i == 7) ? 20 : ((i == 119 || i == 120)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
73 ? 236 : 2*((i + 2) - ((i + 1) % 3)));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
74 s->ModPred[i+2*128] = (i > 125) ? 248 : 2*((i + 2) - ((i + 2) % 4));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
75 s->ModPred[i+3*128] = 2*((i + 1) - ((i - 3) % 5));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
76 s->ModPred[i+4*128] = (i == 8) ? 20 : 2*((i + 1) - ((i - 3) % 6));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
77 s->ModPred[i+5*128] = 2*((i + 4) - ((i + 3) % 7));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
78 s->ModPred[i+6*128] = (i > 123) ? 240 : 2*((i + 4) - ((i + 4) % 8));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
79 s->ModPred[i+7*128] = 2*((i + 5) - ((i + 4) % 9));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
80 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
81
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
82 s->corrector_type = (unsigned short *) av_malloc (24 * 256 * sizeof(unsigned short));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
83
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
84 for (i=0; i < 24; ++i) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
85 for (j=0; j < 256; ++j) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
86 s->corrector_type[i*256+j] = (j < corrector_type_0[i])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
87 ? 1 : ((j < 248 || (i == 16 && j == 248))
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
88 ? 0 : corrector_type_2[j - 248]);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
89 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
90 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
91 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
92
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
93 static void iv_Decode_Chunk(Indeo3DecodeContext *s, unsigned char *cur,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
94 unsigned char *ref, int width, int height, unsigned char *buf1,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
95 long fflags2, unsigned char *hdr,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
96 unsigned char *buf2, int min_width_160);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
97
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
98 #define min(a,b) ((a) < (b) ? (a) : (b))
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
99
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
100 /* ---------------------------------------------------------------------- */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
101 static void iv_alloc_frames(Indeo3DecodeContext *s)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
102 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
103 int luma_width, luma_height, luma_pixels, chroma_width, chroma_height,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
104 chroma_pixels, bufsize, i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
105
1481
0cfed95c7707 fixes levis.avi
michaelni
parents: 1454
diff changeset
106 luma_width = (s->width + 3) & (~3);
0cfed95c7707 fixes levis.avi
michaelni
parents: 1454
diff changeset
107 luma_height = (s->height + 3) & (~3);
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
108
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
109 s->iv_frame[0].y_w = s->iv_frame[0].y_h =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
110 s->iv_frame[0].the_buf_size = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
111 s->iv_frame[1].y_w = s->iv_frame[1].y_h =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
112 s->iv_frame[1].the_buf_size = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
113 s->iv_frame[1].the_buf = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
114
1481
0cfed95c7707 fixes levis.avi
michaelni
parents: 1454
diff changeset
115 chroma_width = ((luma_width >> 2) + 3) & (~3);
0cfed95c7707 fixes levis.avi
michaelni
parents: 1454
diff changeset
116 chroma_height = ((luma_height>> 2) + 3) & (~3);
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
117 luma_pixels = luma_width * luma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
118 chroma_pixels = chroma_width * chroma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
119
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
120 bufsize = luma_pixels * 2 + luma_width * 3 +
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
121 (chroma_pixels + chroma_width) * 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
122
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
123 if((s->iv_frame[0].the_buf =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
124 (s->iv_frame[0].the_buf_size == 0 ? av_malloc(bufsize) :
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
125 av_realloc(s->iv_frame[0].the_buf, bufsize))) == NULL)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
126 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
127 s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
128 s->iv_frame[0].y_h = s->iv_frame[1].y_h = luma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
129 s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = chroma_width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
130 s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = chroma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
131 s->iv_frame[0].the_buf_size = bufsize;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
132
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
133 s->iv_frame[0].Ybuf = s->iv_frame[0].the_buf + luma_width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
134 i = luma_pixels + luma_width * 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
135 s->iv_frame[1].Ybuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
136 i += (luma_pixels + luma_width);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
137 s->iv_frame[0].Ubuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
138 i += (chroma_pixels + chroma_width);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
139 s->iv_frame[1].Ubuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
140 i += (chroma_pixels + chroma_width);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
141 s->iv_frame[0].Vbuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
142 i += (chroma_pixels + chroma_width);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
143 s->iv_frame[1].Vbuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
144
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
145 for(i = 1; i <= luma_width; i++)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
146 s->iv_frame[0].Ybuf[-i] = s->iv_frame[1].Ybuf[-i] =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
147 s->iv_frame[0].Ubuf[-i] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
148
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
149 for(i = 1; i <= chroma_width; i++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
150 s->iv_frame[1].Ubuf[-i] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
151 s->iv_frame[0].Vbuf[-i] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
152 s->iv_frame[1].Vbuf[-i] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
153 s->iv_frame[1].Vbuf[chroma_pixels+i-1] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
154 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
155 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
156
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
157 /* ---------------------------------------------------------------------- */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
158 static void iv_free_func(Indeo3DecodeContext *s)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
159 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
160 int i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
161
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
162 for(i = 0 ; i < 2 ; i++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
163 if(s->iv_frame[i].the_buf != NULL)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
164 av_free(s->iv_frame[i].the_buf);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
165 s->iv_frame[i].Ybuf = s->iv_frame[i].Ubuf =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
166 s->iv_frame[i].Vbuf = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
167 s->iv_frame[i].the_buf = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
168 s->iv_frame[i].the_buf_size = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
169 s->iv_frame[i].y_w = s->iv_frame[i].y_h = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
170 s->iv_frame[i].uv_w = s->iv_frame[i].uv_h = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
171 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
172
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
173 av_free(s->ModPred);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
174 av_free(s->corrector_type);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
175 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
176
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
177 /* ---------------------------------------------------------------------- */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
178 static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
179 unsigned char *buf, int buf_size)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
180 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
181 unsigned int hdr_width, hdr_height,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
182 chroma_width, chroma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
183 unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
184 unsigned char *hdr_pos, *buf_pos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
185
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
186 buf_pos = buf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
187 buf_pos += 18;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
188
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
189 fflags1 = le2me_16(*(uint16_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
190 buf_pos += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
191 fflags3 = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
192 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
193 fflags2 = *buf_pos++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
194 buf_pos += 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
195 hdr_height = le2me_16(*(uint16_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
196 buf_pos += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
197 hdr_width = le2me_16(*(uint16_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
198 buf_pos += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
199 chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
200 chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
201 offs1 = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
202 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
203 offs2 = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
204 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
205 offs3 = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
206 buf_pos += 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
207 hdr_pos = buf_pos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
208 if(fflags3 == 0x80) return 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
209
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
210 if(fflags1 & 0x200) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
211 s->cur_frame = s->iv_frame + 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
212 s->ref_frame = s->iv_frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
213 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
214 s->cur_frame = s->iv_frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
215 s->ref_frame = s->iv_frame + 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
216 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
217
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
218 buf_pos = buf + 16 + offs1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
219 offs = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
220 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
221
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
222 iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
223 hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
224 min(hdr_width, 160));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
225
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
226 buf_pos = buf + 16 + offs2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
227 offs = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
228 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
229
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
230 iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
231 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
232 min(chroma_width, 40));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
233
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
234 buf_pos = buf + 16 + offs3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
235 offs = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
236 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
237
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
238 iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
239 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
240 min(chroma_width, 40));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
241
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
242 return 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
243 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
244
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
245 typedef struct {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
246 long xpos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
247 long ypos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
248 long width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
249 long height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
250 long split_flag;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
251 long split_direction;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
252 long usl7;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
253 } ustr_t;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
254
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
255 /* ---------------------------------------------------------------------- */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
256
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
257 #define LV1_CHECK(buf1,rle_v3,lv1,lp2) \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
258 if((lv1 & 0x80) != 0) { \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
259 if(rle_v3 != 0) \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
260 rle_v3 = 0; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
261 else { \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
262 rle_v3 = 1; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
263 buf1 -= 2; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
264 } \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
265 } \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
266 lp2 = 4;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
267
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
268
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
269 #define RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
270 if(rle_v3 == 0) { \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
271 rle_v2 = *buf1; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
272 rle_v1 = 1; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
273 if(rle_v2 > 32) { \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
274 rle_v2 -= 32; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
275 rle_v1 = 0; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
276 } \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
277 rle_v3 = 1; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
278 } \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
279 buf1--;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
280
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
281
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
282 #define LP2_CHECK(buf1,rle_v3,lp2) \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
283 if(lp2 == 0 && rle_v3 != 0) \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
284 rle_v3 = 0; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
285 else { \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
286 buf1--; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
287 rle_v3 = 1; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
288 }
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
289
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
290
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
291 #define RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
292 rle_v2--; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
293 if(rle_v2 == 0) { \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
294 rle_v3 = 0; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
295 buf1 += 2; \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
296 } \
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
297 lp2 = 4;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
298
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
299 static void iv_Decode_Chunk(Indeo3DecodeContext *s,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
300 unsigned char *cur, unsigned char *ref, int width, int height,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
301 unsigned char *buf1, long fflags2, unsigned char *hdr,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
302 unsigned char *buf2, int min_width_160)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
303 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
304 unsigned char bit_buf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
305 unsigned long bit_pos, lv, lv1, lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
306 long *width_tbl, width_tbl_arr[10];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
307 char *ref_vectors;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
308 unsigned char *cur_frm_pos, *ref_frm_pos, *cp, *cp2;
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
309 uint32_t *cur_lp, *ref_lp;
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
310 const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2];
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
311 unsigned short *correction_type_sp[2];
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
312 ustr_t strip_tbl[20], *strip;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
313 int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
314 rle_v1, rle_v2, rle_v3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
315
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
316 bit_buf = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
317 ref_vectors = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
318
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
319 width_tbl = width_tbl_arr + 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
320 i = (width < 0 ? width + 3 : width)/4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
321 for(j = -1; j < 8; j++)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
322 width_tbl[j] = i * j;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
323
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
324 strip = strip_tbl;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
325
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
326 for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
327
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
328 strip->ypos = strip->xpos = 0;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
329 for(strip->width = min_width_160; width > strip->width; strip->width *= 2);
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
330 strip->height = height;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
331 strip->split_direction = 0;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
332 strip->split_flag = 0;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
333 strip->usl7 = 0;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
334
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
335 bit_pos = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
336
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
337 rle_v1 = rle_v2 = rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
338
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
339 while(strip >= strip_tbl) {
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
340 if(bit_pos <= 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
341 bit_pos = 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
342 bit_buf = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
343 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
344
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
345 bit_pos -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
346 cmd = (bit_buf >> bit_pos) & 0x03;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
347
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
348 if(cmd == 0) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
349 strip++;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
350 memcpy(strip, strip-1, sizeof(ustr_t));
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
351 strip->split_flag = 1;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
352 strip->split_direction = 0;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
353 strip->height = (strip->height > 8 ? ((strip->height+8)>>4)<<3 : 4);
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
354 continue;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
355 } else if(cmd == 1) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
356 strip++;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
357 memcpy(strip, strip-1, sizeof(ustr_t));
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
358 strip->split_flag = 1;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
359 strip->split_direction = 1;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
360 strip->width = (strip->width > 8 ? ((strip->width+8)>>4)<<3 : 4);
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
361 continue;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
362 } else if(cmd == 2) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
363 if(strip->usl7 == 0) {
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
364 strip->usl7 = 1;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
365 ref_vectors = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
366 continue;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
367 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
368 } else if(cmd == 3) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
369 if(strip->usl7 == 0) {
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
370 strip->usl7 = 1;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
371 ref_vectors = buf2 + (*buf1 * 2);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
372 buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
373 continue;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
374 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
375 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
376
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
377 cur_frm_pos = cur + width * strip->ypos + strip->xpos;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
378
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
379 if((blks_width = strip->width) < 0)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
380 blks_width += 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
381 blks_width >>= 2;
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
382 blks_height = strip->height;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
383
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
384 if(ref_vectors != NULL) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
385 ref_frm_pos = ref + (ref_vectors[0] + strip->ypos) * width +
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
386 ref_vectors[1] + strip->xpos;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
387 } else
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
388 ref_frm_pos = cur_frm_pos - width_tbl[4];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
389
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
390 if(cmd == 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
391 if(bit_pos <= 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
392 bit_pos = 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
393 bit_buf = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
394 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
395
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
396 bit_pos -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
397 cmd = (bit_buf >> bit_pos) & 0x03;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
398
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
399 if(cmd == 0 || ref_vectors != NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
400 for(lp1 = 0; lp1 < blks_width; lp1++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
401 for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1])
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
402 ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j];
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
403 cur_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
404 ref_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
405 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
406 } else if(cmd != 1)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
407 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
408 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
409 k = *buf1 >> 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
410 j = *buf1 & 0x0f;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
411 buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
412 lv = j + fflags2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
413
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
414 if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
415 cp2 = s->ModPred + ((lv - 8) << 7);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
416 cp = ref_frm_pos;
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
417 for(i = 0; i < blks_width << 2; i++) {
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
418 int v = *cp >> 1;
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
419 *(cp++) = cp2[v];
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
420 }
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
421 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
422
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
423 if(k == 1 || k == 4) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
424 lv = (hdr[j] & 0xf) + fflags2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
425 correction_type_sp[0] = s->corrector_type + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
426 correction_lp[0] = correction + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
427 lv = (hdr[j] >> 4) + fflags2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
428 correction_lp[1] = correction + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
429 correction_type_sp[1] = s->corrector_type + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
430 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
431 correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
432 correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
433 correction_type_sp[0] = correction_type_sp[1] = s->corrector_type + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
434 correction_lp[0] = correction_lp[1] = correction + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
435 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
436
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
437 switch(k) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
438 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
439 case 0: /********** CASE 0 **********/
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
440 for( ; blks_height > 0; blks_height -= 4) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
441 for(lp1 = 0; lp1 < blks_width; lp1++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
442 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
443 k = *buf1++;
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
444 cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2];
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
445 ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2];
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
446
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
447 switch(correction_type_sp[0][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
448 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
449 *cur_lp = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
450 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
451 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
452 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
453 ((unsigned short *)cur_lp)[0] = ((((unsigned short *)(ref_lp))[0] >> 1)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
454 + correction_lp[lp2 & 0x01][*buf1++]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
455 ((unsigned short *)cur_lp)[1] = ((((unsigned short *)(ref_lp))[1] >> 1)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
456 + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
457 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
458 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
459 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
460 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
461 for(i = 0, j = 0; i < 2; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
462 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
463 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
464 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
465 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
466 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
467 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
468 for(i = 0, j = 0; i < (3 - lp2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
469 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
470 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
471 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
472 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
473 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
474 if(lp2 == 0) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
475 RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
476
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
477 if(rle_v1 == 1 || ref_vectors != NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
478 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
479 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
480 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
481
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
482 RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
483 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
484 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
485 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
486 rle_v2 = *buf1 - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
487 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
488 case 5:
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
489 LP2_CHECK(buf1,rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
490 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
491 for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
492 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
493 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
494 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
495
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
496 case 7:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
497 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
498 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
499 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
500 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
501 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
502 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
503 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
504 if(ref_vectors != NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
505 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
506 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
507 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
508 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
509 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
510
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
511 case 9:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
512 lv1 = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
513 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
514 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
515 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
516 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
517 cur_lp[j] = lv;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
518
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
519 LV1_CHECK(buf1,rle_v3,lv1,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
520 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
521 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
522 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
523 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
524 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
525
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
526 cur_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
527 ref_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
528 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
529
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
530 cur_frm_pos += ((width - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
531 ref_frm_pos += ((width - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
532 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
533 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
534
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
535 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
536 case 3: /********** CASE 3 **********/
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
537 if(ref_vectors != NULL)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
538 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
539 flag1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
540
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
541 for( ; blks_height > 0; blks_height -= 8) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
542 for(lp1 = 0; lp1 < blks_width; lp1++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
543 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
544 k = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
545
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
546 cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
547 ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
548
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
549 switch(correction_type_sp[lp2 & 0x01][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
550 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
551 cur_lp[width_tbl[1]] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
552 if(lp2 > 0 || flag1 == 0 || strip->ypos != 0)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
553 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
554 else
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
555 cur_lp[0] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
556 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
557 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
558
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
559 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
560 ((unsigned short *)cur_lp)[width_tbl[2]] =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
561 ((((unsigned short *)ref_lp)[0] >> 1) + correction_lp[lp2 & 0x01][*buf1++]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
562 ((unsigned short *)cur_lp)[width_tbl[2]+1] =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
563 ((((unsigned short *)ref_lp)[1] >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
564 if(lp2 > 0 || flag1 == 0 || strip->ypos != 0)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
565 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
566 else
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
567 cur_lp[0] = cur_lp[width_tbl[1]];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
568 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
569 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
570
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
571 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
572 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
573 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
574 cur_lp[j] = *ref_lp;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
575 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
576 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
577 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
578
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
579 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
580 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
581 for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
582 cur_lp[j] = *ref_lp;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
583 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
584 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
585 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
586
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
587 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
588 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
589 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
590
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
591 case 7:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
592 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
593 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
594 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
595 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
596 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
597 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
598 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
599 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
600
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
601 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
602 if(lp2 == 0) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
603 RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
604
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
605 if(rle_v1 == 1) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
606 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
607 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
608 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
609
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
610 RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
611 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
612 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
613 rle_v2 = (*buf1) - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
614 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
615 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
616 case 5:
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
617 LP2_CHECK(buf1,rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
618 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
619 for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
620 cur_lp[j] = *ref_lp;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
621 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
622 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
623
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
624 case 9:
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1481
diff changeset
625 av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
626 lv1 = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
627 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
628 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
629 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
630
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
631 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
632 cur_lp[j] = lv;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
633
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
634 LV1_CHECK(buf1,rle_v3,lv1,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
635 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
636
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
637 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
638 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
639 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
640 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
641
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
642 cur_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
643 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
644
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
645 cur_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
646 flag1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
647 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
648 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
649
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
650 case 10: /********** CASE 10 **********/
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
651 if(ref_vectors == NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
652 flag1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
653
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
654 for( ; blks_height > 0; blks_height -= 8) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
655 for(lp1 = 0; lp1 < blks_width; lp1 += 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
656 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
657 k = *buf1++;
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
658 cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
659 ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
660 lv1 = ref_lp[0];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
661 lv2 = ref_lp[1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
662 if(lp2 == 0 && flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
663 lv1 = lv1 & 0x00FF00FF;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
664 lv1 = (lv1 << 8) | lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
665 lv2 = lv2 & 0x00FF00FF;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
666 lv2 = (lv2 << 8) | lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
667 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
668
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
669 switch(correction_type_sp[lp2 & 0x01][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
670 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
671 cur_lp[width_tbl[1]] = ((lv1 >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
672 cur_lp[width_tbl[1]+1] = ((lv2 >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1;
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
673 if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) {
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
674 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
675 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
676 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
677 cur_lp[0] = cur_lp[width_tbl[1]];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
678 cur_lp[1] = cur_lp[width_tbl[1]+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
679 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
680 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
681 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
682
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
683 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
684 cur_lp[width_tbl[1]] = ((lv1 >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1++]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
685 cur_lp[width_tbl[1]+1] = ((lv2 >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1;
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
686 if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) {
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
687 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
688 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
689 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
690 cur_lp[0] = cur_lp[width_tbl[1]];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
691 cur_lp[1] = cur_lp[width_tbl[1]+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
692 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
693 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
694 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
695
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
696 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
697 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
698 if(flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
699 for(i = 0, j = width_tbl[1]; i < 3; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
700 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
701 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
702 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
703 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
704 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
705 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
706 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
707 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
708 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
709 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
710 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
711 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
712 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
713 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
714
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
715 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
716 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
717 if(lp2 == 0 && flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
718 for(i = 0, j = width_tbl[1]; i < 5; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
719 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
720 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
721 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
722 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
723 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
724 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
725 for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
726 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
727 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
728 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
729 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
730 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
731 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
732 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
733
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
734 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
735 if(lp2 == 0) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
736 RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
737 if(rle_v1 == 1) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
738 if(flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
739 for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
740 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
741 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
742 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
743 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
744 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
745 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
746 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
747 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
748 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
749 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
750 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
751 }
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
752 RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
753 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
754 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
755 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
756 rle_v2 = (*buf1) - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
757 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
758 case 5:
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
759 LP2_CHECK(buf1,rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
760 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
761 if(lp2 == 0 && flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
762 for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
763 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
764 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
765 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
766 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
767 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
768 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
769 for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
770 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
771 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
772 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
773 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
774 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
775 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
776
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
777 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
778 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
779 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
780
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
781 case 7:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
782 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
783 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
784 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
785 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
786 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
787 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
788 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
789 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
790 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
791 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
792
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
793 case 9:
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1481
diff changeset
794 av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
795 lv1 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
796 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
797 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
798 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
799 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
800 cur_lp[j] = lv;
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
801 LV1_CHECK(buf1,rle_v3,lv1,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
802 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
803
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
804 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
805 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
806 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
807 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
808
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
809 cur_frm_pos += 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
810 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
811
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
812 cur_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
813 flag1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
814 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
815 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
816 for( ; blks_height > 0; blks_height -= 8) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
817 for(lp1 = 0; lp1 < blks_width; lp1 += 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
818 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
819 k = *buf1++;
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
820 cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
821 ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2];
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
822
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
823 switch(correction_type_sp[lp2 & 0x01][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
824 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
825 lv1 = correctionloworder_lp[lp2 & 0x01][k];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
826 lv2 = correctionhighorder_lp[lp2 & 0x01][k];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
827 cur_lp[0] = ((ref_lp[0] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
828 cur_lp[1] = ((ref_lp[1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
829 cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
830 cur_lp[width_tbl[1]+1] = ((ref_lp[width_tbl[1]+1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
831 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
832 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
833
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
834 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
835 lv1 = correctionloworder_lp[lp2 & 0x01][*buf1++];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
836 lv2 = correctionloworder_lp[lp2 & 0x01][k];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
837 cur_lp[0] = ((ref_lp[0] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
838 cur_lp[1] = ((ref_lp[1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
839 cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
840 cur_lp[width_tbl[1]+1] = ((ref_lp[width_tbl[1]+1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
841 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
842 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
843
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
844 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
845 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
846 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
847 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
848 cur_lp[j+1] = ref_lp[j+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
849 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
850 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
851 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
852 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
853
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
854 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
855 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
856 for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
857 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
858 cur_lp[j+1] = ref_lp[j+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
859 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
860 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
861 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
862 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
863
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
864 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
865 if(lp2 == 0) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
866 RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
867 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
868 ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j];
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
869 ((uint32_t *)cur_frm_pos)[j+1] = ((uint32_t *)ref_frm_pos)[j+1];
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
870 }
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
871 RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
872 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
873 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
874 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
875 rle_v2 = (*buf1) - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
876 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
877 case 5:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
878 case 7:
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
879 LP2_CHECK(buf1,rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
880 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
881 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
882 for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
883 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
884 cur_lp[j+1] = ref_lp[j+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
885 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
886 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
887 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
888
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
889 case 9:
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1481
diff changeset
890 av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
891 lv1 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
892 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
893 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
894 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
895 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
896 ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)cur_frm_pos)[j+1] = lv;
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
897 LV1_CHECK(buf1,rle_v3,lv1,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
898 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
899
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
900 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
901 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
902 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
903 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
904
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
905 cur_frm_pos += 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
906 ref_frm_pos += 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
907 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
908
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
909 cur_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
910 ref_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
911 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
912 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
913 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
914
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
915 case 11: /********** CASE 11 **********/
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
916 if(ref_vectors == NULL)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
917 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
918
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
919 for( ; blks_height > 0; blks_height -= 8) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
920 for(lp1 = 0; lp1 < blks_width; lp1++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
921 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
922 k = *buf1++;
1454
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
923 cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
8b6e5cca1d37 use const data - began to make code more portable
bellard
parents: 1282
diff changeset
924 ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2];
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
925
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
926 switch(correction_type_sp[lp2 & 0x01][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
927 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
928 cur_lp[0] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
929 cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
930 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
931 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
932
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
933 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
934 lv1 = (unsigned short)(correction_lp[lp2 & 0x01][*buf1++]);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
935 lv2 = (unsigned short)(correction_lp[lp2 & 0x01][k]);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
936 ((unsigned short *)cur_lp)[0] = ((((unsigned short *)ref_lp)[0] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
937 ((unsigned short *)cur_lp)[1] = ((((unsigned short *)ref_lp)[1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
938 ((unsigned short *)cur_lp)[width_tbl[2]] = ((((unsigned short *)ref_lp)[width_tbl[2]] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
939 ((unsigned short *)cur_lp)[width_tbl[2]+1] = ((((unsigned short *)ref_lp)[width_tbl[2]+1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
940 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
941 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
942
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
943 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
944 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
945 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
946 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
947 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
948 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
949 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
950
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
951 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
952 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
953 for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
954 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
955 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
956 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
957 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
958
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
959 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
960 if(lp2 == 0) {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
961 RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
962
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
963 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
964 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
965
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
966 RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
967 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
968 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
969 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
970 rle_v2 = (*buf1) - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
971 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
972 case 5:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
973 case 7:
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
974 LP2_CHECK(buf1,rle_v3,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
975 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
976 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
977 for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
978 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
979 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
980 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
981
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
982 case 9:
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1481
diff changeset
983 av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
984 lv1 = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
985 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
986 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
987 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
988 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
989 cur_lp[j] = lv;
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
990 LV1_CHECK(buf1,rle_v3,lv1,lp2)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
991 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
992
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
993 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
994 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
995 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
996 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
997
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
998 cur_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
999 ref_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1000 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1001
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1002 cur_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1003 ref_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1004 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1005 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1006
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1007 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1008 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1009 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1010 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1011
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1012 if(strip < strip_tbl)
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1013 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1014
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1015 for( ; strip >= strip_tbl; strip--) {
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1016 if(strip->split_flag != 0) {
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1017 strip->split_flag = 0;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1018 strip->usl7 = (strip-1)->usl7;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1019
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1020 if(strip->split_direction) {
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1021 strip->xpos += strip->width;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1022 strip->width = (strip-1)->width - strip->width;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1023 if(region_160_width <= strip->xpos && width < strip->width + strip->xpos)
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1024 strip->width = width - strip->xpos;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1025 } else {
1198
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1026 strip->ypos += strip->height;
cae31b22b14e code redundancy reduction, courtesy of suxen_drol -at- hotmail.com
tmmm
parents: 1190
diff changeset
1027 strip->height = (strip-1)->height - strip->height;
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1028 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1029 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1030 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1031 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1032 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1033 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1034
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1035 static int indeo3_decode_init(AVCodecContext *avctx)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1036 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1037 Indeo3DecodeContext *s = avctx->priv_data;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1038
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1039 s->avctx = avctx;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1040 s->width = avctx->width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1041 s->height = avctx->height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1042 avctx->pix_fmt = PIX_FMT_YUV410P;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1043 avctx->has_b_frames = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1044
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1045 build_modpred(s);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1046 iv_alloc_frames(s);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1047
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1048 return 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1049 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1050
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1051 static int indeo3_decode_frame(AVCodecContext *avctx,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1052 void *data, int *data_size,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1053 unsigned char *buf, int buf_size)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1054 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1055 Indeo3DecodeContext *s=avctx->priv_data;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1056 unsigned char *src, *dest;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1057 int y;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1058
1793
11124a5d04f6 segfault fix
michael
parents: 1598
diff changeset
1059 /* no supplementary picture */
11124a5d04f6 segfault fix
michael
parents: 1598
diff changeset
1060 if (buf_size == 0) {
11124a5d04f6 segfault fix
michael
parents: 1598
diff changeset
1061 return 0;
11124a5d04f6 segfault fix
michael
parents: 1598
diff changeset
1062 }
11124a5d04f6 segfault fix
michael
parents: 1598
diff changeset
1063
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1064 iv_decode_frame(s, buf, buf_size);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1065
1228
d63e0185a90f release buffer cleanup
michaelni
parents: 1198
diff changeset
1066 if(s->frame.data[0])
d63e0185a90f release buffer cleanup
michaelni
parents: 1198
diff changeset
1067 avctx->release_buffer(avctx, &s->frame);
d63e0185a90f release buffer cleanup
michaelni
parents: 1198
diff changeset
1068
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1069 s->frame.reference = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1070 if(avctx->get_buffer(avctx, &s->frame) < 0) {
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1481
diff changeset
1071 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1072 return -1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1073 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1074
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1075 src = s->cur_frame->Ybuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1076 dest = s->frame.data[0];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1077 for (y = 0; y < s->height; y++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1078 memcpy(dest, src, s->cur_frame->y_w);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1079 src += s->cur_frame->y_w;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1080 dest += s->frame.linesize[0];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1081 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1082
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1083 src = s->cur_frame->Ubuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1084 dest = s->frame.data[1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1085 for (y = 0; y < s->height / 4; y++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1086 memcpy(dest, src, s->cur_frame->uv_w);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1087 src += s->cur_frame->uv_w;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1088 dest += s->frame.linesize[1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1089 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1090
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1091 src = s->cur_frame->Vbuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1092 dest = s->frame.data[2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1093 for (y = 0; y < s->height / 4; y++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1094 memcpy(dest, src, s->cur_frame->uv_w);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1095 src += s->cur_frame->uv_w;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1096 dest += s->frame.linesize[2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1097 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1098
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1099 *data_size=sizeof(AVFrame);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1100 *(AVFrame*)data= s->frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1101
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1102 return buf_size;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1103 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1104
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1105 static int indeo3_decode_end(AVCodecContext *avctx)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1106 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1107 Indeo3DecodeContext *s = avctx->priv_data;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1108
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1109 iv_free_func(s);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1110
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1111 return 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1112 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1113
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1114 AVCodec indeo3_decoder = {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1115 "indeo3",
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1116 CODEC_TYPE_VIDEO,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1117 CODEC_ID_INDEO3,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1118 sizeof(Indeo3DecodeContext),
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1119 indeo3_decode_init,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1120 NULL,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1121 indeo3_decode_end,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1122 indeo3_decode_frame,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1123 0,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1124 NULL
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1125 };