Mercurial > libavcodec.hg
comparison indeo3.c @ 7957:fbe8fabdbc63 libavcodec
Move iv_decode_frame function to remove a forward declaration.
author | benoit |
---|---|
date | Tue, 30 Sep 2008 14:43:55 +0000 |
parents | eb16a37644a5 |
children | 474794ff86df |
comparison
equal
deleted
inserted
replaced
7956:eb16a37644a5 | 7957:fbe8fabdbc63 |
---|---|
94 } | 94 } |
95 | 95 |
96 return 0; | 96 return 0; |
97 } | 97 } |
98 | 98 |
99 static void iv_Decode_Chunk(Indeo3DecodeContext *s, uint8_t *cur, | |
100 uint8_t *ref, int width, int height, const uint8_t *buf1, | |
101 long fflags2, const uint8_t *hdr, | |
102 const uint8_t *buf2, int min_width_160); | |
103 | |
104 static av_cold int iv_alloc_frames(Indeo3DecodeContext *s) | 99 static av_cold int iv_alloc_frames(Indeo3DecodeContext *s) |
105 { | 100 { |
106 int luma_width, luma_height, luma_pixels, chroma_width, chroma_height, | 101 int luma_width, luma_height, luma_pixels, chroma_width, chroma_height, |
107 chroma_pixels, i; | 102 chroma_pixels, i; |
108 unsigned int bufsize; | 103 unsigned int bufsize; |
154 static av_cold void iv_free_func(Indeo3DecodeContext *s) | 149 static av_cold void iv_free_func(Indeo3DecodeContext *s) |
155 { | 150 { |
156 av_free(s->buf); | 151 av_free(s->buf); |
157 av_free(s->ModPred); | 152 av_free(s->ModPred); |
158 av_free(s->corrector_type); | 153 av_free(s->corrector_type); |
159 } | |
160 | |
161 static unsigned long iv_decode_frame(Indeo3DecodeContext *s, | |
162 const uint8_t *buf, int buf_size) | |
163 { | |
164 unsigned int hdr_width, hdr_height, | |
165 chroma_width, chroma_height; | |
166 unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs; | |
167 const uint8_t *hdr_pos, *buf_pos; | |
168 | |
169 buf_pos = buf; | |
170 buf_pos += 18; | |
171 | |
172 fflags1 = bytestream_get_le16(&buf_pos); | |
173 fflags3 = bytestream_get_le32(&buf_pos); | |
174 fflags2 = *buf_pos++; | |
175 buf_pos += 3; | |
176 hdr_height = bytestream_get_le16(&buf_pos); | |
177 hdr_width = bytestream_get_le16(&buf_pos); | |
178 | |
179 if(avcodec_check_dimensions(NULL, hdr_width, hdr_height)) | |
180 return -1; | |
181 | |
182 chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc; | |
183 chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc; | |
184 offs1 = bytestream_get_le32(&buf_pos); | |
185 offs2 = bytestream_get_le32(&buf_pos); | |
186 offs3 = bytestream_get_le32(&buf_pos); | |
187 buf_pos += 4; | |
188 hdr_pos = buf_pos; | |
189 if(fflags3 == 0x80) return 4; | |
190 | |
191 if(fflags1 & 0x200) { | |
192 s->cur_frame = s->iv_frame + 1; | |
193 s->ref_frame = s->iv_frame; | |
194 } else { | |
195 s->cur_frame = s->iv_frame; | |
196 s->ref_frame = s->iv_frame + 1; | |
197 } | |
198 | |
199 buf_pos = buf + 16 + offs1; | |
200 offs = bytestream_get_le32(&buf_pos); | |
201 | |
202 iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width, | |
203 hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, | |
204 FFMIN(hdr_width, 160)); | |
205 | |
206 if (!(s->avctx->flags & CODEC_FLAG_GRAY)) | |
207 { | |
208 | |
209 buf_pos = buf + 16 + offs2; | |
210 offs = bytestream_get_le32(&buf_pos); | |
211 | |
212 iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, | |
213 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, | |
214 FFMIN(chroma_width, 40)); | |
215 | |
216 buf_pos = buf + 16 + offs3; | |
217 offs = bytestream_get_le32(&buf_pos); | |
218 | |
219 iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, | |
220 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, | |
221 FFMIN(chroma_width, 40)); | |
222 | |
223 } | |
224 | |
225 return 8; | |
226 } | 154 } |
227 | 155 |
228 typedef struct { | 156 typedef struct { |
229 long xpos; | 157 long xpos; |
230 long ypos; | 158 long ypos; |
1046 iv_free_func(s); | 974 iv_free_func(s); |
1047 | 975 |
1048 return ret; | 976 return ret; |
1049 } | 977 } |
1050 | 978 |
979 static unsigned long iv_decode_frame(Indeo3DecodeContext *s, | |
980 const uint8_t *buf, int buf_size) | |
981 { | |
982 unsigned int hdr_width, hdr_height, | |
983 chroma_width, chroma_height; | |
984 unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs; | |
985 const uint8_t *hdr_pos, *buf_pos; | |
986 | |
987 buf_pos = buf; | |
988 buf_pos += 18; | |
989 | |
990 fflags1 = bytestream_get_le16(&buf_pos); | |
991 fflags3 = bytestream_get_le32(&buf_pos); | |
992 fflags2 = *buf_pos++; | |
993 buf_pos += 3; | |
994 hdr_height = bytestream_get_le16(&buf_pos); | |
995 hdr_width = bytestream_get_le16(&buf_pos); | |
996 | |
997 if(avcodec_check_dimensions(NULL, hdr_width, hdr_height)) | |
998 return -1; | |
999 | |
1000 chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc; | |
1001 chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc; | |
1002 offs1 = bytestream_get_le32(&buf_pos); | |
1003 offs2 = bytestream_get_le32(&buf_pos); | |
1004 offs3 = bytestream_get_le32(&buf_pos); | |
1005 buf_pos += 4; | |
1006 hdr_pos = buf_pos; | |
1007 if(fflags3 == 0x80) return 4; | |
1008 | |
1009 if(fflags1 & 0x200) { | |
1010 s->cur_frame = s->iv_frame + 1; | |
1011 s->ref_frame = s->iv_frame; | |
1012 } else { | |
1013 s->cur_frame = s->iv_frame; | |
1014 s->ref_frame = s->iv_frame + 1; | |
1015 } | |
1016 | |
1017 buf_pos = buf + 16 + offs1; | |
1018 offs = bytestream_get_le32(&buf_pos); | |
1019 | |
1020 iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width, | |
1021 hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, | |
1022 FFMIN(hdr_width, 160)); | |
1023 | |
1024 if (!(s->avctx->flags & CODEC_FLAG_GRAY)) | |
1025 { | |
1026 | |
1027 buf_pos = buf + 16 + offs2; | |
1028 offs = bytestream_get_le32(&buf_pos); | |
1029 | |
1030 iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, | |
1031 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, | |
1032 FFMIN(chroma_width, 40)); | |
1033 | |
1034 buf_pos = buf + 16 + offs3; | |
1035 offs = bytestream_get_le32(&buf_pos); | |
1036 | |
1037 iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, | |
1038 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, | |
1039 FFMIN(chroma_width, 40)); | |
1040 | |
1041 } | |
1042 | |
1043 return 8; | |
1044 } | |
1045 | |
1051 static int indeo3_decode_frame(AVCodecContext *avctx, | 1046 static int indeo3_decode_frame(AVCodecContext *avctx, |
1052 void *data, int *data_size, | 1047 void *data, int *data_size, |
1053 const uint8_t *buf, int buf_size) | 1048 const uint8_t *buf, int buf_size) |
1054 { | 1049 { |
1055 Indeo3DecodeContext *s=avctx->priv_data; | 1050 Indeo3DecodeContext *s=avctx->priv_data; |