Mercurial > libavcodec.hg
comparison svq1.c @ 2979:bfabfdf9ce55 libavcodec
COSMETICS: tabs --> spaces, some prettyprinting
author | diego |
---|---|
date | Thu, 22 Dec 2005 01:10:11 +0000 |
parents | ef2149182f1c |
children | 0b546eab515d |
comparison
equal
deleted
inserted
replaced
2978:403183bbb505 | 2979:bfabfdf9ce55 |
---|---|
55 static VLC svq1_intra_multistage[6]; | 55 static VLC svq1_intra_multistage[6]; |
56 static VLC svq1_inter_multistage[6]; | 56 static VLC svq1_inter_multistage[6]; |
57 static VLC svq1_intra_mean; | 57 static VLC svq1_intra_mean; |
58 static VLC svq1_inter_mean; | 58 static VLC svq1_inter_mean; |
59 | 59 |
60 #define SVQ1_BLOCK_SKIP 0 | 60 #define SVQ1_BLOCK_SKIP 0 |
61 #define SVQ1_BLOCK_INTER 1 | 61 #define SVQ1_BLOCK_INTER 1 |
62 #define SVQ1_BLOCK_INTER_4V 2 | 62 #define SVQ1_BLOCK_INTER_4V 2 |
63 #define SVQ1_BLOCK_INTRA 3 | 63 #define SVQ1_BLOCK_INTRA 3 |
64 | 64 |
65 typedef struct SVQ1Context { | 65 typedef struct SVQ1Context { |
66 MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independant of MpegEncContext, so this will be removed then (FIXME/XXX) | 66 MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independant of MpegEncContext, so this will be removed then (FIXME/XXX) |
67 AVCodecContext *avctx; | 67 AVCodecContext *avctx; |
68 DSPContext dsp; | 68 DSPContext dsp; |
93 int64_t rd_total; | 93 int64_t rd_total; |
94 } SVQ1Context; | 94 } SVQ1Context; |
95 | 95 |
96 /* motion vector (prediction) */ | 96 /* motion vector (prediction) */ |
97 typedef struct svq1_pmv_s { | 97 typedef struct svq1_pmv_s { |
98 int x; | 98 int x; |
99 int y; | 99 int y; |
100 } svq1_pmv_t; | 100 } svq1_pmv_t; |
101 | 101 |
102 #include "svq1_cb.h" | 102 #include "svq1_cb.h" |
103 #include "svq1_vlc.h" | 103 #include "svq1_vlc.h" |
104 | 104 |
174 | 174 |
175 #define SVQ1_PROCESS_VECTOR()\ | 175 #define SVQ1_PROCESS_VECTOR()\ |
176 for (; level > 0; i++) {\ | 176 for (; level > 0; i++) {\ |
177 /* process next depth */\ | 177 /* process next depth */\ |
178 if (i == m) {\ | 178 if (i == m) {\ |
179 m = n;\ | 179 m = n;\ |
180 if (--level == 0)\ | 180 if (--level == 0)\ |
181 break;\ | 181 break;\ |
182 }\ | 182 }\ |
183 /* divide block if next bit set */\ | 183 /* divide block if next bit set */\ |
184 if (get_bits (bitbuf, 1) == 0)\ | 184 if (get_bits (bitbuf, 1) == 0)\ |
185 break;\ | 185 break;\ |
186 /* add child nodes */\ | 186 /* add child nodes */\ |
187 list[n++] = list[i];\ | 187 list[n++] = list[i];\ |
188 list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level / 2) + 1));\ | 188 list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level / 2) + 1));\ |
189 } | 189 } |
190 | 190 |
191 #define SVQ1_ADD_CODEBOOK()\ | 191 #define SVQ1_ADD_CODEBOOK()\ |
192 /* add codebook entries to vector */\ | 192 /* add codebook entries to vector */\ |
193 for (j=0; j < stages; j++) {\ | 193 for (j=0; j < stages; j++) {\ |
194 n3 = codebook[entries[j]] ^ 0x80808080;\ | 194 n3 = codebook[entries[j]] ^ 0x80808080;\ |
195 n1 += ((n3 & 0xFF00FF00) >> 8);\ | 195 n1 += ((n3 & 0xFF00FF00) >> 8);\ |
196 n2 += (n3 & 0x00FF00FF);\ | 196 n2 += (n3 & 0x00FF00FF);\ |
197 }\ | 197 }\ |
198 \ | 198 \ |
199 /* clip to [0..255] */\ | 199 /* clip to [0..255] */\ |
200 if (n1 & 0xFF00FF00) {\ | 200 if (n1 & 0xFF00FF00) {\ |
201 n3 = ((( n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;\ | 201 n3 = ((( n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;\ |
202 n1 += 0x7F007F00;\ | 202 n1 += 0x7F007F00;\ |
203 n1 |= (((~n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;\ | 203 n1 |= (((~n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;\ |
204 n1 &= (n3 & 0x00FF00FF);\ | 204 n1 &= (n3 & 0x00FF00FF);\ |
205 }\ | 205 }\ |
206 \ | 206 \ |
207 if (n2 & 0xFF00FF00) {\ | 207 if (n2 & 0xFF00FF00) {\ |
208 n3 = ((( n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;\ | 208 n3 = ((( n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;\ |
209 n2 += 0x7F007F00;\ | 209 n2 += 0x7F007F00;\ |
210 n2 |= (((~n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;\ | 210 n2 |= (((~n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;\ |
211 n2 &= (n3 & 0x00FF00FF);\ | 211 n2 &= (n3 & 0x00FF00FF);\ |
212 } | 212 } |
213 | 213 |
214 #define SVQ1_DO_CODEBOOK_INTRA()\ | 214 #define SVQ1_DO_CODEBOOK_INTRA()\ |
215 for (y=0; y < height; y++) {\ | 215 for (y=0; y < height; y++) {\ |
216 for (x=0; x < (width / 4); x++, codebook++) {\ | 216 for (x=0; x < (width / 4); x++, codebook++) {\ |
217 n1 = n4;\ | 217 n1 = n4;\ |
218 n2 = n4;\ | 218 n2 = n4;\ |
219 SVQ1_ADD_CODEBOOK()\ | 219 SVQ1_ADD_CODEBOOK()\ |
220 /* store result */\ | 220 /* store result */\ |
221 dst[x] = (n1 << 8) | n2;\ | 221 dst[x] = (n1 << 8) | n2;\ |
222 }\ | 222 }\ |
223 dst += (pitch / 4);\ | 223 dst += (pitch / 4);\ |
224 } | 224 } |
225 | 225 |
226 #define SVQ1_DO_CODEBOOK_NONINTRA()\ | 226 #define SVQ1_DO_CODEBOOK_NONINTRA()\ |
227 for (y=0; y < height; y++) {\ | 227 for (y=0; y < height; y++) {\ |
228 for (x=0; x < (width / 4); x++, codebook++) {\ | 228 for (x=0; x < (width / 4); x++, codebook++) {\ |
229 n3 = dst[x];\ | 229 n3 = dst[x];\ |
230 /* add mean value to vector */\ | 230 /* add mean value to vector */\ |
231 n1 = ((n3 & 0xFF00FF00) >> 8) + n4;\ | 231 n1 = ((n3 & 0xFF00FF00) >> 8) + n4;\ |
232 n2 = (n3 & 0x00FF00FF) + n4;\ | 232 n2 = (n3 & 0x00FF00FF) + n4;\ |
233 SVQ1_ADD_CODEBOOK()\ | 233 SVQ1_ADD_CODEBOOK()\ |
234 /* store result */\ | 234 /* store result */\ |
235 dst[x] = (n1 << 8) | n2;\ | 235 dst[x] = (n1 << 8) | n2;\ |
236 }\ | 236 }\ |
237 dst += (pitch / 4);\ | 237 dst += (pitch / 4);\ |
238 } | 238 } |
239 | 239 |
240 #define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)\ | 240 #define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)\ |
241 codebook = (const uint32_t *) cbook[level];\ | 241 codebook = (const uint32_t *) cbook[level];\ |
242 bit_cache = get_bits (bitbuf, 4*stages);\ | 242 bit_cache = get_bits (bitbuf, 4*stages);\ |
243 /* calculate codebook entries for this vector */\ | 243 /* calculate codebook entries for this vector */\ |
244 for (j=0; j < stages; j++) {\ | 244 for (j=0; j < stages; j++) {\ |
245 entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1);\ | 245 entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1);\ |
246 }\ | 246 }\ |
247 mean -= (stages * 128);\ | 247 mean -= (stages * 128);\ |
248 n4 = ((mean + (mean >> 31)) << 16) | (mean & 0xFFFF); | 248 n4 = ((mean + (mean >> 31)) << 16) | (mean & 0xFFFF); |
249 | 249 |
250 static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch ) { | 250 static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch ) { |
251 uint32_t bit_cache; | 251 uint32_t bit_cache; |
252 uint8_t *list[63]; | 252 uint8_t *list[63]; |
253 uint32_t *dst; | 253 uint32_t *dst; |
254 const uint32_t *codebook; | 254 const uint32_t *codebook; |
255 int entries[6]; | 255 int entries[6]; |
256 int i, j, m, n; | 256 int i, j, m, n; |
257 int mean, stages; | 257 int mean, stages; |
258 unsigned x, y, width, height, level; | 258 unsigned x, y, width, height, level; |
259 uint32_t n1, n2, n3, n4; | 259 uint32_t n1, n2, n3, n4; |
260 | 260 |
261 /* initialize list for breadth first processing of vectors */ | 261 /* initialize list for breadth first processing of vectors */ |
262 list[0] = pixels; | 262 list[0] = pixels; |
272 | 272 |
273 /* get number of stages (-1 skips vector, 0 for mean only) */ | 273 /* get number of stages (-1 skips vector, 0 for mean only) */ |
274 stages = get_vlc2(bitbuf, svq1_intra_multistage[level].table, 3, 3) - 1; | 274 stages = get_vlc2(bitbuf, svq1_intra_multistage[level].table, 3, 3) - 1; |
275 | 275 |
276 if (stages == -1) { | 276 if (stages == -1) { |
277 for (y=0; y < height; y++) { | 277 for (y=0; y < height; y++) { |
278 memset (&dst[y*(pitch / 4)], 0, width); | 278 memset (&dst[y*(pitch / 4)], 0, width); |
279 } | 279 } |
280 continue; /* skip vector */ | 280 continue; /* skip vector */ |
281 } | 281 } |
282 | 282 |
283 if ((stages > 0) && (level >= 4)) { | 283 if ((stages > 0) && (level >= 4)) { |
284 #ifdef DEBUG_SVQ1 | 284 #ifdef DEBUG_SVQ1 |
285 av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",stages,level); | 285 av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",stages,level); |
286 #endif | 286 #endif |
287 return -1; /* invalid vector */ | 287 return -1; /* invalid vector */ |
288 } | 288 } |
289 | 289 |
290 mean = get_vlc2(bitbuf, svq1_intra_mean.table, 8, 3); | 290 mean = get_vlc2(bitbuf, svq1_intra_mean.table, 8, 3); |
291 | 291 |
292 if (stages == 0) { | 292 if (stages == 0) { |
293 for (y=0; y < height; y++) { | 293 for (y=0; y < height; y++) { |
294 memset (&dst[y*(pitch / 4)], mean, width); | 294 memset (&dst[y*(pitch / 4)], mean, width); |
295 } | 295 } |
296 } else { | 296 } else { |
297 SVQ1_CALC_CODEBOOK_ENTRIES(svq1_intra_codebooks); | 297 SVQ1_CALC_CODEBOOK_ENTRIES(svq1_intra_codebooks); |
298 SVQ1_DO_CODEBOOK_INTRA() | 298 SVQ1_DO_CODEBOOK_INTRA() |
299 } | 299 } |
305 static int svq1_decode_block_non_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch ) { | 305 static int svq1_decode_block_non_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch ) { |
306 uint32_t bit_cache; | 306 uint32_t bit_cache; |
307 uint8_t *list[63]; | 307 uint8_t *list[63]; |
308 uint32_t *dst; | 308 uint32_t *dst; |
309 const uint32_t *codebook; | 309 const uint32_t *codebook; |
310 int entries[6]; | 310 int entries[6]; |
311 int i, j, m, n; | 311 int i, j, m, n; |
312 int mean, stages; | 312 int mean, stages; |
313 int x, y, width, height, level; | 313 int x, y, width, height, level; |
314 uint32_t n1, n2, n3, n4; | 314 uint32_t n1, n2, n3, n4; |
315 | 315 |
316 /* initialize list for breadth first processing of vectors */ | 316 /* initialize list for breadth first processing of vectors */ |
317 list[0] = pixels; | 317 list[0] = pixels; |
318 | 318 |
326 height = 1 << ((3 + level) /2); | 326 height = 1 << ((3 + level) /2); |
327 | 327 |
328 /* get number of stages (-1 skips vector, 0 for mean only) */ | 328 /* get number of stages (-1 skips vector, 0 for mean only) */ |
329 stages = get_vlc2(bitbuf, svq1_inter_multistage[level].table, 3, 2) - 1; | 329 stages = get_vlc2(bitbuf, svq1_inter_multistage[level].table, 3, 2) - 1; |
330 | 330 |
331 if (stages == -1) continue; /* skip vector */ | 331 if (stages == -1) continue; /* skip vector */ |
332 | 332 |
333 if ((stages > 0) && (level >= 4)) { | 333 if ((stages > 0) && (level >= 4)) { |
334 #ifdef DEBUG_SVQ1 | 334 #ifdef DEBUG_SVQ1 |
335 av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",stages,level); | 335 av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",stages,level); |
336 #endif | 336 #endif |
337 return -1; /* invalid vector */ | 337 return -1; /* invalid vector */ |
338 } | 338 } |
339 | 339 |
340 mean = get_vlc2(bitbuf, svq1_inter_mean.table, 9, 3) - 256; | 340 mean = get_vlc2(bitbuf, svq1_inter_mean.table, 9, 3) - 256; |
341 | 341 |
342 SVQ1_CALC_CODEBOOK_ENTRIES(svq1_inter_codebooks); | 342 SVQ1_CALC_CODEBOOK_ENTRIES(svq1_inter_codebooks); |
344 } | 344 } |
345 return 0; | 345 return 0; |
346 } | 346 } |
347 | 347 |
348 static int svq1_decode_motion_vector (GetBitContext *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) { | 348 static int svq1_decode_motion_vector (GetBitContext *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) { |
349 int diff; | 349 int diff; |
350 int i; | 350 int i; |
351 | 351 |
352 for (i=0; i < 2; i++) { | 352 for (i=0; i < 2; i++) { |
353 | 353 |
354 /* get motion code */ | 354 /* get motion code */ |
355 diff = get_vlc2(bitbuf, svq1_motion_component.table, 7, 2); | 355 diff = get_vlc2(bitbuf, svq1_motion_component.table, 7, 2); |
370 } | 370 } |
371 | 371 |
372 static void svq1_skip_block (uint8_t *current, uint8_t *previous, int pitch, int x, int y) { | 372 static void svq1_skip_block (uint8_t *current, uint8_t *previous, int pitch, int x, int y) { |
373 uint8_t *src; | 373 uint8_t *src; |
374 uint8_t *dst; | 374 uint8_t *dst; |
375 int i; | 375 int i; |
376 | 376 |
377 src = &previous[x + y*pitch]; | 377 src = &previous[x + y*pitch]; |
378 dst = current; | 378 dst = current; |
379 | 379 |
380 for (i=0; i < 16; i++) { | 380 for (i=0; i < 16; i++) { |
383 dst += pitch; | 383 dst += pitch; |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 static int svq1_motion_inter_block (MpegEncContext *s, GetBitContext *bitbuf, | 387 static int svq1_motion_inter_block (MpegEncContext *s, GetBitContext *bitbuf, |
388 uint8_t *current, uint8_t *previous, int pitch, | 388 uint8_t *current, uint8_t *previous, int pitch, |
389 svq1_pmv_t *motion, int x, int y) { | 389 svq1_pmv_t *motion, int x, int y) { |
390 uint8_t *src; | 390 uint8_t *src; |
391 uint8_t *dst; | 391 uint8_t *dst; |
392 svq1_pmv_t mv; | 392 svq1_pmv_t mv; |
393 svq1_pmv_t *pmv[3]; | 393 svq1_pmv_t *pmv[3]; |
394 int result; | 394 int result; |
395 | 395 |
396 /* predict and decode motion vector */ | 396 /* predict and decode motion vector */ |
397 pmv[0] = &motion[0]; | 397 pmv[0] = &motion[0]; |
398 if (y == 0) { | 398 if (y == 0) { |
399 pmv[1] = | 399 pmv[1] = |
407 result = svq1_decode_motion_vector (bitbuf, &mv, pmv); | 407 result = svq1_decode_motion_vector (bitbuf, &mv, pmv); |
408 | 408 |
409 if (result != 0) | 409 if (result != 0) |
410 return result; | 410 return result; |
411 | 411 |
412 motion[0].x = | 412 motion[0].x = |
413 motion[(x / 8) + 2].x = | 413 motion[(x / 8) + 2].x = |
414 motion[(x / 8) + 3].x = mv.x; | 414 motion[(x / 8) + 3].x = mv.x; |
415 motion[0].y = | 415 motion[0].y = |
416 motion[(x / 8) + 2].y = | 416 motion[(x / 8) + 2].y = |
417 motion[(x / 8) + 3].y = mv.y; | 417 motion[(x / 8) + 3].y = mv.y; |
418 | 418 |
419 if(y + (mv.y >> 1)<0) | 419 if(y + (mv.y >> 1)<0) |
420 mv.y= 0; | 420 mv.y= 0; |
421 if(x + (mv.x >> 1)<0) | 421 if(x + (mv.x >> 1)<0) |
422 mv.x= 0; | 422 mv.x= 0; |
435 | 435 |
436 return 0; | 436 return 0; |
437 } | 437 } |
438 | 438 |
439 static int svq1_motion_inter_4v_block (MpegEncContext *s, GetBitContext *bitbuf, | 439 static int svq1_motion_inter_4v_block (MpegEncContext *s, GetBitContext *bitbuf, |
440 uint8_t *current, uint8_t *previous, int pitch, | 440 uint8_t *current, uint8_t *previous, int pitch, |
441 svq1_pmv_t *motion,int x, int y) { | 441 svq1_pmv_t *motion,int x, int y) { |
442 uint8_t *src; | 442 uint8_t *src; |
443 uint8_t *dst; | 443 uint8_t *dst; |
444 svq1_pmv_t mv; | 444 svq1_pmv_t mv; |
445 svq1_pmv_t *pmv[4]; | 445 svq1_pmv_t *pmv[4]; |
446 int i, result; | 446 int i, result; |
447 | 447 |
448 /* predict and decode motion vector (0) */ | 448 /* predict and decode motion vector (0) */ |
449 pmv[0] = &motion[0]; | 449 pmv[0] = &motion[0]; |
450 if (y == 0) { | 450 if (y == 0) { |
451 pmv[1] = | 451 pmv[1] = |
525 | 525 |
526 return 0; | 526 return 0; |
527 } | 527 } |
528 | 528 |
529 static int svq1_decode_delta_block (MpegEncContext *s, GetBitContext *bitbuf, | 529 static int svq1_decode_delta_block (MpegEncContext *s, GetBitContext *bitbuf, |
530 uint8_t *current, uint8_t *previous, int pitch, | 530 uint8_t *current, uint8_t *previous, int pitch, |
531 svq1_pmv_t *motion, int x, int y) { | 531 svq1_pmv_t *motion, int x, int y) { |
532 uint32_t block_type; | 532 uint32_t block_type; |
533 int result = 0; | 533 int result = 0; |
534 | 534 |
535 /* get block type */ | 535 /* get block type */ |
536 block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2); | 536 block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2); |
537 | 537 |
538 /* reset motion vectors */ | 538 /* reset motion vectors */ |
539 if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) { | 539 if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) { |
540 motion[0].x = | 540 motion[0].x = |
541 motion[0].y = | 541 motion[0].y = |
542 motion[(x / 8) + 2].x = | 542 motion[(x / 8) + 2].x = |
543 motion[(x / 8) + 2].y = | 543 motion[(x / 8) + 2].y = |
544 motion[(x / 8) + 3].x = | 544 motion[(x / 8) + 3].x = |
545 motion[(x / 8) + 3].y = 0; | 545 motion[(x / 8) + 3].y = 0; |
546 } | 546 } |
709 static int svq1_decode_frame(AVCodecContext *avctx, | 709 static int svq1_decode_frame(AVCodecContext *avctx, |
710 void *data, int *data_size, | 710 void *data, int *data_size, |
711 uint8_t *buf, int buf_size) | 711 uint8_t *buf, int buf_size) |
712 { | 712 { |
713 MpegEncContext *s=avctx->priv_data; | 713 MpegEncContext *s=avctx->priv_data; |
714 uint8_t *current, *previous; | 714 uint8_t *current, *previous; |
715 int result, i, x, y, width, height; | 715 int result, i, x, y, width, height; |
716 AVFrame *pict = data; | 716 AVFrame *pict = data; |
717 | 717 |
718 /* initialize bit buffer */ | 718 /* initialize bit buffer */ |
719 init_get_bits(&s->gb,buf,buf_size*8); | 719 init_get_bits(&s->gb,buf,buf_size*8); |
720 | 720 |
779 } | 779 } |
780 | 780 |
781 if (s->pict_type == I_TYPE) { | 781 if (s->pict_type == I_TYPE) { |
782 /* keyframe */ | 782 /* keyframe */ |
783 for (y=0; y < height; y+=16) { | 783 for (y=0; y < height; y+=16) { |
784 for (x=0; x < width; x+=16) { | 784 for (x=0; x < width; x+=16) { |
785 result = svq1_decode_block_intra (&s->gb, ¤t[x], linesize); | 785 result = svq1_decode_block_intra (&s->gb, ¤t[x], linesize); |
786 if (result != 0) | 786 if (result != 0) |
787 { | 787 { |
788 //#ifdef DEBUG_SVQ1 | 788 //#ifdef DEBUG_SVQ1 |
789 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result); | 789 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result); |
790 //#endif | 790 //#endif |
791 return result; | 791 return result; |
792 } | 792 } |
793 } | 793 } |
794 current += 16*linesize; | 794 current += 16*linesize; |
795 } | 795 } |
796 } else { | 796 } else { |
797 svq1_pmv_t pmv[width/8+3]; | 797 svq1_pmv_t pmv[width/8+3]; |
798 /* delta frame */ | 798 /* delta frame */ |
799 memset (pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv_t)); | 799 memset (pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv_t)); |
800 | 800 |
801 for (y=0; y < height; y+=16) { | 801 for (y=0; y < height; y+=16) { |
802 for (x=0; x < width; x+=16) { | 802 for (x=0; x < width; x+=16) { |
803 result = svq1_decode_delta_block (s, &s->gb, ¤t[x], previous, | 803 result = svq1_decode_delta_block (s, &s->gb, ¤t[x], previous, |
804 linesize, pmv, x, y); | 804 linesize, pmv, x, y); |
805 if (result != 0) | 805 if (result != 0) |
806 { | 806 { |
807 #ifdef DEBUG_SVQ1 | 807 #ifdef DEBUG_SVQ1 |
808 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_delta_block %i\n",result); | 808 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_delta_block %i\n",result); |
809 #endif | 809 #endif |
810 return result; | 810 return result; |
811 } | 811 } |
812 } | 812 } |
813 | 813 |
814 pmv[0].x = | 814 pmv[0].x = |
815 pmv[0].y = 0; | 815 pmv[0].y = 0; |
816 | 816 |
817 current += 16*linesize; | 817 current += 16*linesize; |
818 } | 818 } |
819 } | 819 } |
820 } | 820 } |
821 | 821 |
822 *pict = *(AVFrame*)&s->current_picture; | 822 *pict = *(AVFrame*)&s->current_picture; |
900 /* no embedded string either */ | 900 /* no embedded string either */ |
901 | 901 |
902 /* output 5 unknown bits (2 + 2 + 1) */ | 902 /* output 5 unknown bits (2 + 2 + 1) */ |
903 put_bits(&s->pb, 5, 0); | 903 put_bits(&s->pb, 5, 0); |
904 | 904 |
905 for (i = 0; i < 7; i++) | 905 for (i = 0; i < 7; i++) |
906 { | 906 { |
907 if ((svq1_frame_size_table[i].width == s->frame_width) && | 907 if ((svq1_frame_size_table[i].width == s->frame_width) && |
908 (svq1_frame_size_table[i].height == s->frame_height)) | 908 (svq1_frame_size_table[i].height == s->frame_height)) |
909 { | 909 { |
910 put_bits(&s->pb, 3, i); | 910 put_bits(&s->pb, 3, i); |
911 break; | 911 break; |
912 } | 912 } |
913 } | 913 } |
914 | 914 |
915 if (i == 7) | 915 if (i == 7) |
916 { | 916 { |
917 put_bits(&s->pb, 3, 7); | 917 put_bits(&s->pb, 3, 7); |
918 put_bits(&s->pb, 12, s->frame_width); | 918 put_bits(&s->pb, 12, s->frame_width); |
919 put_bits(&s->pb, 12, s->frame_height); | 919 put_bits(&s->pb, 12, s->frame_height); |
920 } | 920 } |
921 } | 921 } |
922 | 922 |
923 /* no checksum or extra data (next 2 bits get 0) */ | 923 /* no checksum or extra data (next 2 bits get 0) */ |
924 put_bits(&s->pb, 2, 0); | 924 put_bits(&s->pb, 2, 0); |
925 } | 925 } |