comparison indeo3.c @ 6239:e270eccc622f libavcodec

Use bytestream.
author michael
date Fri, 01 Feb 2008 13:38:55 +0000
parents dfdff1ca78a7
children 442529fa4b73
comparison
equal deleted inserted replaced
6238:7100aeea042e 6239:e270eccc622f
25 #include <unistd.h> 25 #include <unistd.h>
26 26
27 #include "avcodec.h" 27 #include "avcodec.h"
28 #include "dsputil.h" 28 #include "dsputil.h"
29 #include "mpegvideo.h" 29 #include "mpegvideo.h"
30 #include "bytestream.h"
30 31
31 #include "indeo3data.h" 32 #include "indeo3data.h"
32 33
33 typedef struct 34 typedef struct
34 { 35 {
184 const unsigned char *hdr_pos, *buf_pos; 185 const unsigned char *hdr_pos, *buf_pos;
185 186
186 buf_pos = buf; 187 buf_pos = buf;
187 buf_pos += 18; 188 buf_pos += 18;
188 189
189 fflags1 = le2me_16(*(uint16_t *)buf_pos); 190 fflags1 = bytestream_get_le16(&buf_pos);
190 buf_pos += 2; 191 fflags3 = bytestream_get_le32(&buf_pos);
191 fflags3 = le2me_32(*(uint32_t *)buf_pos);
192 buf_pos += 4;
193 fflags2 = *buf_pos++; 192 fflags2 = *buf_pos++;
194 buf_pos += 3; 193 buf_pos += 3;
195 hdr_height = le2me_16(*(uint16_t *)buf_pos); 194 hdr_height = bytestream_get_le16(&buf_pos);
196 buf_pos += 2; 195 hdr_width = bytestream_get_le16(&buf_pos);
197 hdr_width = le2me_16(*(uint16_t *)buf_pos);
198 196
199 if(avcodec_check_dimensions(NULL, hdr_width, hdr_height)) 197 if(avcodec_check_dimensions(NULL, hdr_width, hdr_height))
200 return -1; 198 return -1;
201 199
202 buf_pos += 2;
203 chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc; 200 chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc;
204 chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc; 201 chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc;
205 offs1 = le2me_32(*(uint32_t *)buf_pos); 202 offs1 = bytestream_get_le32(&buf_pos);
203 offs2 = bytestream_get_le32(&buf_pos);
204 offs3 = bytestream_get_le32(&buf_pos);
206 buf_pos += 4; 205 buf_pos += 4;
207 offs2 = le2me_32(*(uint32_t *)buf_pos);
208 buf_pos += 4;
209 offs3 = le2me_32(*(uint32_t *)buf_pos);
210 buf_pos += 8;
211 hdr_pos = buf_pos; 206 hdr_pos = buf_pos;
212 if(fflags3 == 0x80) return 4; 207 if(fflags3 == 0x80) return 4;
213 208
214 if(fflags1 & 0x200) { 209 if(fflags1 & 0x200) {
215 s->cur_frame = s->iv_frame + 1; 210 s->cur_frame = s->iv_frame + 1;
218 s->cur_frame = s->iv_frame; 213 s->cur_frame = s->iv_frame;
219 s->ref_frame = s->iv_frame + 1; 214 s->ref_frame = s->iv_frame + 1;
220 } 215 }
221 216
222 buf_pos = buf + 16 + offs1; 217 buf_pos = buf + 16 + offs1;
223 offs = le2me_32(*(uint32_t *)buf_pos); 218 offs = bytestream_get_le32(&buf_pos);
224 buf_pos += 4;
225 219
226 iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width, 220 iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width,
227 hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 221 hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
228 FFMIN(hdr_width, 160)); 222 FFMIN(hdr_width, 160));
229 223
230 if (!(s->avctx->flags & CODEC_FLAG_GRAY)) 224 if (!(s->avctx->flags & CODEC_FLAG_GRAY))
231 { 225 {
232 226
233 buf_pos = buf + 16 + offs2; 227 buf_pos = buf + 16 + offs2;
234 offs = le2me_32(*(uint32_t *)buf_pos); 228 offs = bytestream_get_le32(&buf_pos);
235 buf_pos += 4;
236 229
237 iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, 230 iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width,
238 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 231 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
239 FFMIN(chroma_width, 40)); 232 FFMIN(chroma_width, 40));
240 233
241 buf_pos = buf + 16 + offs3; 234 buf_pos = buf + 16 + offs3;
242 offs = le2me_32(*(uint32_t *)buf_pos); 235 offs = bytestream_get_le32(&buf_pos);
243 buf_pos += 4;
244 236
245 iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, 237 iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width,
246 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 238 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
247 FFMIN(chroma_width, 40)); 239 FFMIN(chroma_width, 40));
248 240