annotate indeo3.c @ 7952:7f123fad56ea libavcodec

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