comparison vp3.c @ 11351:0f55f380a1b2 libavcodec

Explictly separate decoding whether fragments are coded by plane
author conrad
date Wed, 03 Mar 2010 23:27:37 +0000
parents 5b39547c4ce1
children 6e0af2cfdcfe
comparison
equal deleted inserted replaced
11350:7d9a1a807e91 11351:0f55f380a1b2
142 int last_qps[3]; 142 int last_qps[3];
143 143
144 int superblock_count; 144 int superblock_count;
145 int y_superblock_width; 145 int y_superblock_width;
146 int y_superblock_height; 146 int y_superblock_height;
147 int y_superblock_count;
147 int c_superblock_width; 148 int c_superblock_width;
148 int c_superblock_height; 149 int c_superblock_height;
150 int c_superblock_count;
149 int u_superblock_start; 151 int u_superblock_start;
150 int v_superblock_start; 152 int v_superblock_start;
151 unsigned char *superblock_coding; 153 unsigned char *superblock_coding;
152 154
153 int macroblock_count; 155 int macroblock_count;
452 int num_partial_superblocks = 0; 454 int num_partial_superblocks = 0;
453 int first_c_fragment_seen; 455 int first_c_fragment_seen;
454 456
455 int i, j; 457 int i, j;
456 int current_fragment; 458 int current_fragment;
459 int plane;
457 460
458 if (s->keyframe) { 461 if (s->keyframe) {
459 memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count); 462 memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count);
460 463
461 } else { 464 } else {
537 s->next_coeff= s->coeffs + s->fragment_count; 540 s->next_coeff= s->coeffs + s->fragment_count;
538 s->first_coded_y_fragment = s->first_coded_c_fragment = 0; 541 s->first_coded_y_fragment = s->first_coded_c_fragment = 0;
539 s->last_coded_y_fragment = s->last_coded_c_fragment = -1; 542 s->last_coded_y_fragment = s->last_coded_c_fragment = -1;
540 first_c_fragment_seen = 0; 543 first_c_fragment_seen = 0;
541 memset(s->macroblock_coding, MODE_COPY, s->macroblock_count); 544 memset(s->macroblock_coding, MODE_COPY, s->macroblock_count);
542 for (i = 0; i < s->superblock_count; i++) { 545
546 for (plane = 0; plane < 3; plane++) {
547 int sb_start = (int[]){ 0, s->u_superblock_start, s->v_superblock_start }[plane];
548 int sb_end = sb_start + (plane ? s->c_superblock_count : s->y_superblock_count);
549
550 for (i = sb_start; i < sb_end; i++) {
543 551
544 /* iterate through all 16 fragments in a superblock */ 552 /* iterate through all 16 fragments in a superblock */
545 for (j = 0; j < 16; j++) { 553 for (j = 0; j < 16; j++) {
546 554
547 /* if the fragment is in bounds, check its coding status */ 555 /* if the fragment is in bounds, check its coding status */
572 s->all_fragments[current_fragment].coding_method = 580 s->all_fragments[current_fragment].coding_method =
573 MODE_INTER_NO_MV; 581 MODE_INTER_NO_MV;
574 s->all_fragments[current_fragment].next_coeff= s->coeffs + current_fragment; 582 s->all_fragments[current_fragment].next_coeff= s->coeffs + current_fragment;
575 s->coded_fragment_list[s->coded_fragment_list_index] = 583 s->coded_fragment_list[s->coded_fragment_list_index] =
576 current_fragment; 584 current_fragment;
577 if ((current_fragment >= s->fragment_start[1]) && 585 if (plane && !first_c_fragment_seen) {
578 (s->last_coded_y_fragment == -1) &&
579 (!first_c_fragment_seen)) {
580 s->first_coded_c_fragment = s->coded_fragment_list_index; 586 s->first_coded_c_fragment = s->coded_fragment_list_index;
581 s->last_coded_y_fragment = s->first_coded_c_fragment - 1; 587 s->last_coded_y_fragment = s->first_coded_c_fragment - 1;
582 first_c_fragment_seen = 1; 588 first_c_fragment_seen = 1;
583 } 589 }
584 s->coded_fragment_list_index++; 590 s->coded_fragment_list_index++;
587 s->all_fragments[current_fragment].coding_method = 593 s->all_fragments[current_fragment].coding_method =
588 MODE_COPY; 594 MODE_COPY;
589 } 595 }
590 } 596 }
591 } 597 }
598 }
592 } 599 }
593 600
594 if (!first_c_fragment_seen) 601 if (!first_c_fragment_seen)
595 /* only Y fragments coded in this frame */ 602 /* only Y fragments coded in this frame */
596 s->last_coded_y_fragment = s->coded_fragment_list_index - 1; 603 s->last_coded_y_fragment = s->coded_fragment_list_index - 1;
1547 { 1554 {
1548 Vp3DecodeContext *s = avctx->priv_data; 1555 Vp3DecodeContext *s = avctx->priv_data;
1549 int i, inter, plane; 1556 int i, inter, plane;
1550 int c_width; 1557 int c_width;
1551 int c_height; 1558 int c_height;
1552 int y_superblock_count;
1553 int c_superblock_count;
1554 1559
1555 if (avctx->codec_tag == MKTAG('V','P','3','0')) 1560 if (avctx->codec_tag == MKTAG('V','P','3','0'))
1556 s->version = 0; 1561 s->version = 0;
1557 else 1562 else
1558 s->version = 1; 1563 s->version = 1;
1573 for (i = 0; i < 3; i++) 1578 for (i = 0; i < 3; i++)
1574 s->qps[i] = -1; 1579 s->qps[i] = -1;
1575 1580
1576 s->y_superblock_width = (s->width + 31) / 32; 1581 s->y_superblock_width = (s->width + 31) / 32;
1577 s->y_superblock_height = (s->height + 31) / 32; 1582 s->y_superblock_height = (s->height + 31) / 32;
1578 y_superblock_count = s->y_superblock_width * s->y_superblock_height; 1583 s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;
1579 1584
1580 /* work out the dimensions for the C planes */ 1585 /* work out the dimensions for the C planes */
1581 c_width = s->width / 2; 1586 c_width = s->width / 2;
1582 c_height = s->height / 2; 1587 c_height = s->height / 2;
1583 s->c_superblock_width = (c_width + 31) / 32; 1588 s->c_superblock_width = (c_width + 31) / 32;
1584 s->c_superblock_height = (c_height + 31) / 32; 1589 s->c_superblock_height = (c_height + 31) / 32;
1585 c_superblock_count = s->c_superblock_width * s->c_superblock_height; 1590 s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;
1586 1591
1587 s->superblock_count = y_superblock_count + (c_superblock_count * 2); 1592 s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
1588 s->u_superblock_start = y_superblock_count; 1593 s->u_superblock_start = s->y_superblock_count;
1589 s->v_superblock_start = s->u_superblock_start + c_superblock_count; 1594 s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
1590 s->superblock_coding = av_malloc(s->superblock_count); 1595 s->superblock_coding = av_malloc(s->superblock_count);
1591 1596
1592 s->macroblock_width = (s->width + 15) / 16; 1597 s->macroblock_width = (s->width + 15) / 16;
1593 s->macroblock_height = (s->height + 15) / 16; 1598 s->macroblock_height = (s->height + 15) / 16;
1594 s->macroblock_count = s->macroblock_width * s->macroblock_height; 1599 s->macroblock_count = s->macroblock_width * s->macroblock_height;