comparison indeo3.c @ 7975:d9faf3f9f379 libavcodec

Rename some variables and add some comments to try to be a bit more clear.
author benoit
date Thu, 02 Oct 2008 15:27:13 +0000
parents d4ae40057dd3
children e983153e2d72
comparison
equal deleted inserted replaced
7974:2b20ad98e424 7975:d9faf3f9f379
200 } \ 200 } \
201 lp2 = 4; 201 lp2 = 4;
202 202
203 static void iv_Decode_Chunk(Indeo3DecodeContext *s, 203 static void iv_Decode_Chunk(Indeo3DecodeContext *s,
204 uint8_t *cur, uint8_t *ref, int width, int height, 204 uint8_t *cur, uint8_t *ref, int width, int height,
205 const uint8_t *buf1, long fflags2, const uint8_t *hdr, 205 const uint8_t *buf1, long cb_offset, const uint8_t *hdr,
206 const uint8_t *buf2, int min_width_160) 206 const uint8_t *buf2, int min_width_160)
207 { 207 {
208 uint8_t bit_buf; 208 uint8_t bit_buf;
209 unsigned long bit_pos, lv, lv1, lv2; 209 unsigned long bit_pos, lv, lv1, lv2;
210 long *width_tbl, width_tbl_arr[10]; 210 long *width_tbl, width_tbl_arr[10];
312 return; 312 return;
313 } else { 313 } else {
314 k = *buf1 >> 4; 314 k = *buf1 >> 4;
315 j = *buf1 & 0x0f; 315 j = *buf1 & 0x0f;
316 buf1++; 316 buf1++;
317 lv = j + fflags2; 317 lv = j + cb_offset;
318 318
319 if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) { 319 if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) {
320 cp2 = s->ModPred + ((lv - 8) << 7); 320 cp2 = s->ModPred + ((lv - 8) << 7);
321 cp = ref_frm_pos; 321 cp = ref_frm_pos;
322 for(i = 0; i < blks_width << 2; i++) { 322 for(i = 0; i < blks_width << 2; i++) {
324 *(cp++) = cp2[v]; 324 *(cp++) = cp2[v];
325 } 325 }
326 } 326 }
327 327
328 if(k == 1 || k == 4) { 328 if(k == 1 || k == 4) {
329 lv = (hdr[j] & 0xf) + fflags2; 329 lv = (hdr[j] & 0xf) + cb_offset;
330 correction_type_sp[0] = s->corrector_type + (lv << 8); 330 correction_type_sp[0] = s->corrector_type + (lv << 8);
331 correction_lp[0] = correction + (lv << 8); 331 correction_lp[0] = correction + (lv << 8);
332 lv = (hdr[j] >> 4) + fflags2; 332 lv = (hdr[j] >> 4) + cb_offset;
333 correction_lp[1] = correction + (lv << 8); 333 correction_lp[1] = correction + (lv << 8);
334 correction_type_sp[1] = s->corrector_type + (lv << 8); 334 correction_type_sp[1] = s->corrector_type + (lv << 8);
335 } else { 335 } else {
336 correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8); 336 correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8);
337 correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8); 337 correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8);
971 } 971 }
972 972
973 static unsigned long iv_decode_frame(Indeo3DecodeContext *s, 973 static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
974 const uint8_t *buf, int buf_size) 974 const uint8_t *buf, int buf_size)
975 { 975 {
976 unsigned int hdr_width, hdr_height, 976 unsigned int image_width, image_height,
977 chroma_width, chroma_height; 977 chroma_width, chroma_height;
978 unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs; 978 unsigned long flags, cb_offset, data_size,
979 y_offset, v_offset, u_offset, mc_vector_count;
979 const uint8_t *hdr_pos, *buf_pos; 980 const uint8_t *hdr_pos, *buf_pos;
980 981
981 buf_pos = buf; 982 buf_pos = buf;
982 buf_pos += 18; 983 buf_pos += 18; /* skip OS header (16 bytes) and version number */
983 984
984 fflags1 = bytestream_get_le16(&buf_pos); 985 flags = bytestream_get_le16(&buf_pos);
985 fflags3 = bytestream_get_le32(&buf_pos); 986 data_size = bytestream_get_le32(&buf_pos);
986 fflags2 = *buf_pos++; 987 cb_offset = *buf_pos++;
987 buf_pos += 3; 988 buf_pos += 3; /* skip reserved byte and checksum */
988 hdr_height = bytestream_get_le16(&buf_pos); 989 image_height = bytestream_get_le16(&buf_pos);
989 hdr_width = bytestream_get_le16(&buf_pos); 990 image_width = bytestream_get_le16(&buf_pos);
990 991
991 if(avcodec_check_dimensions(NULL, hdr_width, hdr_height)) 992 if(avcodec_check_dimensions(NULL, image_width, image_height))
992 return -1; 993 return -1;
993 994
994 chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc; 995 chroma_height = ((image_height >> 2) + 3) & 0x7ffc;
995 chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc; 996 chroma_width = ((image_width >> 2) + 3) & 0x7ffc;
996 offs1 = bytestream_get_le32(&buf_pos); 997 y_offset = bytestream_get_le32(&buf_pos);
997 offs2 = bytestream_get_le32(&buf_pos); 998 v_offset = bytestream_get_le32(&buf_pos);
998 offs3 = bytestream_get_le32(&buf_pos); 999 u_offset = bytestream_get_le32(&buf_pos);
999 buf_pos += 4; 1000 buf_pos += 4; /* reserved */
1000 hdr_pos = buf_pos; 1001 hdr_pos = buf_pos;
1001 if(fflags3 == 0x80) return 4; 1002 if(data_size == 0x80) return 4;
1002 1003
1003 if(fflags1 & 0x200) { 1004 if(flags & 0x200) {
1004 s->cur_frame = s->iv_frame + 1; 1005 s->cur_frame = s->iv_frame + 1;
1005 s->ref_frame = s->iv_frame; 1006 s->ref_frame = s->iv_frame;
1006 } else { 1007 } else {
1007 s->cur_frame = s->iv_frame; 1008 s->cur_frame = s->iv_frame;
1008 s->ref_frame = s->iv_frame + 1; 1009 s->ref_frame = s->iv_frame + 1;
1009 } 1010 }
1010 1011
1011 buf_pos = buf + 16 + offs1; 1012 buf_pos = buf + 16 + y_offset;
1012 offs = bytestream_get_le32(&buf_pos); 1013 mc_vector_count = bytestream_get_le32(&buf_pos);
1013 1014
1014 iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width, 1015 iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, image_width,
1015 hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 1016 image_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
1016 FFMIN(hdr_width, 160)); 1017 FFMIN(image_width, 160));
1017 1018
1018 if (!(s->avctx->flags & CODEC_FLAG_GRAY)) 1019 if (!(s->avctx->flags & CODEC_FLAG_GRAY))
1019 { 1020 {
1020 1021
1021 buf_pos = buf + 16 + offs2; 1022 buf_pos = buf + 16 + v_offset;
1022 offs = bytestream_get_le32(&buf_pos); 1023 mc_vector_count = bytestream_get_le32(&buf_pos);
1023 1024
1024 iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, 1025 iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width,
1025 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 1026 chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
1026 FFMIN(chroma_width, 40)); 1027 FFMIN(chroma_width, 40));
1027 1028
1028 buf_pos = buf + 16 + offs3; 1029 buf_pos = buf + 16 + u_offset;
1029 offs = bytestream_get_le32(&buf_pos); 1030 mc_vector_count = bytestream_get_le32(&buf_pos);
1030 1031
1031 iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, 1032 iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width,
1032 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 1033 chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
1033 FFMIN(chroma_width, 40)); 1034 FFMIN(chroma_width, 40));
1034 1035
1035 } 1036 }
1036 1037
1037 return 8; 1038 return 8;