annotate indeo3.c @ 8344:844463c05193 libavcodec

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