⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vp3.c

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 C
📖 第 1 页 / 共 5 页
字号:
            t2 = (int32_t)(xC2S6 * ip[6]);            t1 >>= 16;            t2 >>= 16;            H_ = t1 - t2;            _Ed = E_ - G_;            _Gd = E_ + G_;            _Add = F_ + _Ad;            _Bdd = _Bd - H_;            _Fd = F_ - _Ad;            _Hd = _Bd + H_;            /*  Final sequence of operations over-write original inputs. */            ip[0] = (int16_t)((_Gd + _Cd )   >> 0);            ip[7] = (int16_t)((_Gd - _Cd )   >> 0);            ip[1] = (int16_t)((_Add + _Hd )  >> 0);            ip[2] = (int16_t)((_Add - _Hd )  >> 0);            ip[3] = (int16_t)((_Ed + _Dd )   >> 0);            ip[4] = (int16_t)((_Ed - _Dd )   >> 0);            ip[5] = (int16_t)((_Fd + _Bdd )  >> 0);            ip[6] = (int16_t)((_Fd - _Bdd )  >> 0);        }        ip += 8;            /* next row */    }    ip = intermediate_data;    for ( i = 0; i < 8; i++) {        /* Check for non-zero values (bitwise or faster than ||) */        if ( ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |             ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {            t1 = (int32_t)(xC1S7 * ip[1*8]);            t2 = (int32_t)(xC7S1 * ip[7*8]);            t1 >>= 16;            t2 >>= 16;            A_ = t1 + t2;            t1 = (int32_t)(xC7S1 * ip[1*8]);            t2 = (int32_t)(xC1S7 * ip[7*8]);            t1 >>= 16;            t2 >>= 16;            B_ = t1 - t2;            t1 = (int32_t)(xC3S5 * ip[3*8]);            t2 = (int32_t)(xC5S3 * ip[5*8]);            t1 >>= 16;            t2 >>= 16;            C_ = t1 + t2;            t1 = (int32_t)(xC3S5 * ip[5*8]);            t2 = (int32_t)(xC5S3 * ip[3*8]);            t1 >>= 16;            t2 >>= 16;            D_ = t1 - t2;            t1 = (int32_t)(xC4S4 * (A_ - C_));            t1 >>= 16;            _Ad = t1;            t1 = (int32_t)(xC4S4 * (B_ - D_));            t1 >>= 16;            _Bd = t1;            _Cd = A_ + C_;            _Dd = B_ + D_;            t1 = (int32_t)(xC4S4 * (ip[0*8] + ip[4*8]));            t1 >>= 16;            E_ = t1;            t1 = (int32_t)(xC4S4 * (ip[0*8] - ip[4*8]));            t1 >>= 16;            F_ = t1;            t1 = (int32_t)(xC2S6 * ip[2*8]);            t2 = (int32_t)(xC6S2 * ip[6*8]);            t1 >>= 16;            t2 >>= 16;            G_ = t1 + t2;            t1 = (int32_t)(xC6S2 * ip[2*8]);            t2 = (int32_t)(xC2S6 * ip[6*8]);            t1 >>= 16;            t2 >>= 16;            H_ = t1 - t2;            _Ed = E_ - G_;            _Gd = E_ + G_;            _Add = F_ + _Ad;            _Bdd = _Bd - H_;            _Fd = F_ - _Ad;            _Hd = _Bd + H_;            _Gd += IdctAdjustBeforeShift;            _Add += IdctAdjustBeforeShift;            _Ed += IdctAdjustBeforeShift;            _Fd += IdctAdjustBeforeShift;            /* Final sequence of operations over-write original inputs. */            op[0*8] = (int16_t)((_Gd + _Cd )   >> 4);            op[7*8] = (int16_t)((_Gd - _Cd )   >> 4);            op[1*8] = (int16_t)((_Add + _Hd )  >> 4);            op[2*8] = (int16_t)((_Add - _Hd )  >> 4);            op[3*8] = (int16_t)((_Ed + _Dd )   >> 4);            op[4*8] = (int16_t)((_Ed - _Dd )   >> 4);            op[5*8] = (int16_t)((_Fd + _Bdd )  >> 4);            op[6*8] = (int16_t)((_Fd - _Bdd )  >> 4);        } else {            op[0*8] = 0;            op[7*8] = 0;            op[1*8] = 0;            op[2*8] = 0;            op[3*8] = 0;            op[4*8] = 0;            op[5*8] = 0;            op[6*8] = 0;        }        ip++;            /* next column */        op++;    }}void vp3_idct_put(int16_t *input_data, int16_t *dequant_matrix,     uint8_t *dest, int stride){    int16_t transformed_data[64];    int16_t *op;    int i, j;    vp3_idct_c(input_data, dequant_matrix, transformed_data);    /* place in final output */    op = transformed_data;    for (i = 0; i < 8; i++) {        for (j = 0; j < 8; j++) {            if (*op < -128)                *dest = 0;            else if (*op > 127)                *dest = 255;            else                *dest = (uint8_t)(*op + 128);            op++;            dest++;        }        dest += (stride - 8);    }}void vp3_idct_add(int16_t *input_data, int16_t *dequant_matrix,     uint8_t *dest, int stride){    int16_t transformed_data[64];    int16_t *op;    int i, j;    int16_t sample;    vp3_idct_c(input_data, dequant_matrix, transformed_data);    /* place in final output */    op = transformed_data;    for (i = 0; i < 8; i++) {        for (j = 0; j < 8; j++) {            sample = *dest + *op;            if (sample < 0)                *dest = 0;            else if (sample > 255)                *dest = 255;            else                *dest = (uint8_t)(sample & 0xFF);            op++;            dest++;        }        dest += (stride - 8);    }}/************************************************************************ * VP3 specific functions ************************************************************************//* * This function sets up all of the various blocks mappings: * superblocks <-> fragments, macroblocks <-> fragments, * superblocks <-> macroblocks * * Returns 0 is successful; returns 1 if *anything* went wrong. */static int init_block_mapping(Vp3DecodeContext *s) {    int i, j;    signed int hilbert_walk_y[16];    signed int hilbert_walk_c[16];    signed int hilbert_walk_mb[4];    int current_fragment = 0;    int current_width = 0;    int current_height = 0;    int right_edge = 0;    int bottom_edge = 0;    int superblock_row_inc = 0;    int *hilbert = NULL;    int mapping_index = 0;    int current_macroblock;    int c_fragment;    signed char travel_width[16] = {         1,  1,  0, -1,          0,  0,  1,  0,         1,  0,  1,  0,         0, -1,  0,  1    };    signed char travel_height[16] = {         0,  0,  1,  0,         1,  1,  0, -1,         0,  1,  0, -1,        -1,  0, -1,  0    };    signed char travel_width_mb[4] = {         1,  0,  1,  0    };    signed char travel_height_mb[4] = {         0,  1,  0, -1    };    debug_vp3("  vp3: initialize block mapping tables\n");    /* figure out hilbert pattern per these frame dimensions */    hilbert_walk_y[0]  = 1;    hilbert_walk_y[1]  = 1;    hilbert_walk_y[2]  = s->fragment_width;    hilbert_walk_y[3]  = -1;    hilbert_walk_y[4]  = s->fragment_width;    hilbert_walk_y[5]  = s->fragment_width;    hilbert_walk_y[6]  = 1;    hilbert_walk_y[7]  = -s->fragment_width;    hilbert_walk_y[8]  = 1;    hilbert_walk_y[9]  = s->fragment_width;    hilbert_walk_y[10]  = 1;    hilbert_walk_y[11] = -s->fragment_width;    hilbert_walk_y[12] = -s->fragment_width;    hilbert_walk_y[13] = -1;    hilbert_walk_y[14] = -s->fragment_width;    hilbert_walk_y[15] = 1;    hilbert_walk_c[0]  = 1;    hilbert_walk_c[1]  = 1;    hilbert_walk_c[2]  = s->fragment_width / 2;    hilbert_walk_c[3]  = -1;    hilbert_walk_c[4]  = s->fragment_width / 2;    hilbert_walk_c[5]  = s->fragment_width / 2;    hilbert_walk_c[6]  = 1;    hilbert_walk_c[7]  = -s->fragment_width / 2;    hilbert_walk_c[8]  = 1;    hilbert_walk_c[9]  = s->fragment_width / 2;    hilbert_walk_c[10]  = 1;    hilbert_walk_c[11] = -s->fragment_width / 2;    hilbert_walk_c[12] = -s->fragment_width / 2;    hilbert_walk_c[13] = -1;    hilbert_walk_c[14] = -s->fragment_width / 2;    hilbert_walk_c[15] = 1;    hilbert_walk_mb[0] = 1;    hilbert_walk_mb[1] = s->macroblock_width;    hilbert_walk_mb[2] = 1;    hilbert_walk_mb[3] = -s->macroblock_width;    /* iterate through each superblock (all planes) and map the fragments */    for (i = 0; i < s->superblock_count; i++) {        debug_init("    superblock %d (u starts @ %d, v starts @ %d)\n",            i, s->u_superblock_start, s->v_superblock_start);        /* time to re-assign the limits? */        if (i == 0) {            /* start of Y superblocks */            right_edge = s->fragment_width;            bottom_edge = s->fragment_height;            current_width = -1;            current_height = 0;            superblock_row_inc = 3 * s->fragment_width -                 (s->y_superblock_width * 4 - s->fragment_width);            hilbert = hilbert_walk_y;            /* the first operation for this variable is to advance by 1 */            current_fragment = -1;        } else if (i == s->u_superblock_start) {            /* start of U superblocks */            right_edge = s->fragment_width / 2;            bottom_edge = s->fragment_height / 2;            current_width = -1;            current_height = 0;            superblock_row_inc = 3 * (s->fragment_width / 2) -                 (s->c_superblock_width * 4 - s->fragment_width / 2);            hilbert = hilbert_walk_c;            /* the first operation for this variable is to advance by 1 */            current_fragment = s->u_fragment_start - 1;        } else if (i == s->v_superblock_start) {            /* start of V superblocks */            right_edge = s->fragment_width / 2;            bottom_edge = s->fragment_height / 2;            current_width = -1;            current_height = 0;            superblock_row_inc = 3 * (s->fragment_width / 2) -                 (s->c_superblock_width * 4 - s->fragment_width / 2);            hilbert = hilbert_walk_c;            /* the first operation for this variable is to advance by 1 */            current_fragment = s->v_fragment_start - 1;        }        if (current_width >= right_edge - 1) {            /* reset width and move to next superblock row */            current_width = -1;            current_height += 4;            /* fragment is now at the start of a new superblock row */            current_fragment += superblock_row_inc;        }        /* iterate through all 16 fragments in a superblock */        for (j = 0; j < 16; j++) {            current_fragment += hilbert[j];            current_width += travel_width[j];            current_height += travel_height[j];            /* check if the fragment is in bounds */            if ((current_width < right_edge) &&                (current_height < bottom_edge)) {                s->superblock_fragments[mapping_index] = current_fragment;                debug_init("    mapping fragment %d to superblock %d, position %d (%d/%d x %d/%d)\n",                     s->superblock_fragments[mapping_index], i, j,                    current_width, right_edge, current_height, bottom_edge);            } else {                s->superblock_fragments[mapping_index] = -1;                debug_init("    superblock %d, position %d has no fragment (%d/%d x %d/%d)\n",                     i, j,                    current_width, right_edge, current_height, bottom_edge);            }            mapping_index++;        }    }    /* initialize the superblock <-> macroblock mapping; iterate through     * all of the Y plane superblocks to build this mapping */    right_edge = s->macroblock_width;    bottom_edge = s->macroblock_height;    current_width = -1;    current_height = 0;    superblock_row_inc = s->macroblock_width -        (s->y_superblock_width * 2 - s->macroblock_width);;    hilbert = hilbert_walk_mb;    mapping_index = 0;    current_macroblock = -1;    for (i = 0; i < s->u_superblock_start; i++) {        if (current_width >= right_edge - 1) {            /* reset width and move to next superblock row */            current_width = -1;            current_height += 2;            /* macroblock is now at the start of a new superblock row */            current_macroblock += superblock_row_inc;        }        /* iterate through each potential macroblock in the superblock */        for (j = 0; j < 4; j++) {            current_macroblock += hilbert_walk_mb[j];            current_width += travel_width_mb[j];            current_height += travel_height_mb[j];            /* check if the macroblock is in bounds */            if ((current_width < right_edge) &&                (current_height < bottom_edge)) {                s->superblock_macroblocks[mapping_index] = current_macroblock;                debug_init("    mapping macroblock %d to superblock %d, position %d (%d/%d x %d/%d)\n",                    s->superblock_macroblocks[mapping_index], i, j,                    current_width, right_edge, current_height, bottom_edge);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -