Mercurial > libavcodec.hg
comparison cavsdec.c @ 8795:e18df4791658 libavcodec
fix multiple slices per frame
author | stefang |
---|---|
date | Tue, 10 Feb 2009 20:51:35 +0000 |
parents | 1f98fc269920 |
children | c6dd98bff427 |
comparison
equal
deleted
inserted
replaced
8794:1f98fc269920 | 8795:e18df4791658 |
---|---|
413 | 413 |
414 static inline int decode_slice_header(AVSContext *h, GetBitContext *gb) { | 414 static inline int decode_slice_header(AVSContext *h, GetBitContext *gb) { |
415 if(h->stc > 0xAF) | 415 if(h->stc > 0xAF) |
416 av_log(h->s.avctx, AV_LOG_ERROR, "unexpected start code 0x%02x\n", h->stc); | 416 av_log(h->s.avctx, AV_LOG_ERROR, "unexpected start code 0x%02x\n", h->stc); |
417 h->mby = h->stc; | 417 h->mby = h->stc; |
418 | |
419 /* mark top macroblocks as unavailable */ | |
420 h->flags &= ~(B_AVAIL|C_AVAIL); | |
418 if((h->mby == 0) && (!h->qp_fixed)){ | 421 if((h->mby == 0) && (!h->qp_fixed)){ |
419 h->qp_fixed = get_bits1(gb); | 422 h->qp_fixed = get_bits1(gb); |
420 h->qp = get_bits(gb,6); | 423 h->qp = get_bits(gb,6); |
421 } | 424 } |
422 /* inter frame or second slice can have weighting params */ | 425 /* inter frame or second slice can have weighting params */ |
429 } | 432 } |
430 | 433 |
431 static inline void check_for_slice(AVSContext *h) { | 434 static inline void check_for_slice(AVSContext *h) { |
432 GetBitContext *gb = &h->s.gb; | 435 GetBitContext *gb = &h->s.gb; |
433 int align; | 436 int align; |
437 | |
438 if(h->mbx) | |
439 return; | |
434 align = (-get_bits_count(gb)) & 7; | 440 align = (-get_bits_count(gb)) & 7; |
435 if((show_bits_long(gb,24+align) & 0xFFFFFF) == 0x000001) { | 441 if((show_bits_long(gb,24+align) & 0xFFFFFF) == 0x000001) { |
436 skip_bits_long(gb,24+align); | 442 skip_bits_long(gb,24+align); |
437 h->stc = get_bits(gb,8); | 443 h->stc = get_bits(gb,8); |
438 decode_slice_header(h,gb); | 444 decode_slice_header(h,gb); |
523 h->alpha_offset = get_se_golomb(&s->gb); | 529 h->alpha_offset = get_se_golomb(&s->gb); |
524 h->beta_offset = get_se_golomb(&s->gb); | 530 h->beta_offset = get_se_golomb(&s->gb); |
525 } else { | 531 } else { |
526 h->alpha_offset = h->beta_offset = 0; | 532 h->alpha_offset = h->beta_offset = 0; |
527 } | 533 } |
528 check_for_slice(h); | |
529 if(h->pic_type == FF_I_TYPE) { | 534 if(h->pic_type == FF_I_TYPE) { |
530 do { | 535 do { |
536 check_for_slice(h); | |
531 decode_mb_i(h, 0); | 537 decode_mb_i(h, 0); |
532 } while(ff_cavs_next_mb(h)); | 538 } while(ff_cavs_next_mb(h)); |
533 } else if(h->pic_type == FF_P_TYPE) { | 539 } else if(h->pic_type == FF_P_TYPE) { |
534 do { | 540 do { |
541 check_for_slice(h); | |
535 if(h->skip_mode_flag) { | 542 if(h->skip_mode_flag) { |
536 skip_count = get_ue_golomb(&s->gb); | 543 skip_count = get_ue_golomb(&s->gb); |
537 while(skip_count--) { | 544 while(skip_count--) { |
538 decode_mb_p(h,P_SKIP); | 545 decode_mb_p(h,P_SKIP); |
539 if(!ff_cavs_next_mb(h)) | 546 if(!ff_cavs_next_mb(h)) |
540 goto done; | 547 goto done; |
541 } | 548 } |
549 check_for_slice(h); | |
542 mb_type = get_ue_golomb(&s->gb) + P_16X16; | 550 mb_type = get_ue_golomb(&s->gb) + P_16X16; |
543 } else | 551 } else |
544 mb_type = get_ue_golomb(&s->gb) + P_SKIP; | 552 mb_type = get_ue_golomb(&s->gb) + P_SKIP; |
545 if(mb_type > P_8X8) { | 553 if(mb_type > P_8X8) { |
546 decode_mb_i(h, mb_type - P_8X8 - 1); | 554 decode_mb_i(h, mb_type - P_8X8 - 1); |
547 } else | 555 } else |
548 decode_mb_p(h,mb_type); | 556 decode_mb_p(h,mb_type); |
549 } while(ff_cavs_next_mb(h)); | 557 } while(ff_cavs_next_mb(h)); |
550 } else { /* FF_B_TYPE */ | 558 } else { /* FF_B_TYPE */ |
551 do { | 559 do { |
560 check_for_slice(h); | |
552 if(h->skip_mode_flag) { | 561 if(h->skip_mode_flag) { |
553 skip_count = get_ue_golomb(&s->gb); | 562 skip_count = get_ue_golomb(&s->gb); |
554 while(skip_count--) { | 563 while(skip_count--) { |
555 decode_mb_b(h,B_SKIP); | 564 decode_mb_b(h,B_SKIP); |
556 if(!ff_cavs_next_mb(h)) | 565 if(!ff_cavs_next_mb(h)) |
557 goto done; | 566 goto done; |
558 } | 567 } |
568 check_for_slice(h); | |
559 mb_type = get_ue_golomb(&s->gb) + B_DIRECT; | 569 mb_type = get_ue_golomb(&s->gb) + B_DIRECT; |
560 } else | 570 } else |
561 mb_type = get_ue_golomb(&s->gb) + B_SKIP; | 571 mb_type = get_ue_golomb(&s->gb) + B_SKIP; |
562 if(mb_type > B_8X8) { | 572 if(mb_type > B_8X8) { |
563 decode_mb_i(h, mb_type - B_8X8 - 1); | 573 decode_mb_i(h, mb_type - B_8X8 - 1); |