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

📄 yuv2rgb.c

📁 视频的h263解码
💻 C
📖 第 1 页 / 共 2 页
字号:
      g_2_pix_alloc[i + 256] <<= free_bits_at_bottom(green_mask);      b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(blue_mask));      b_2_pix_alloc[i + 256] <<= free_bits_at_bottom(blue_mask);      /*       * If we have 16-bit output depth, then we double the value       * in the top word. This means that we can write out both       * pixels in the pixel doubling mode with one op. It is        * harmless in the normal case as storing a 32-bit value       * through a short pointer will lose the top bits anyway.       * A similar optimisation for Alpha for 64 bit has been       * prepared for, but is not yet implemented.       */      if(!thirty2) {        r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16;        g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16;        b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16;      }#ifdef SIXTYFOUR_BIT      if(thirty2) {        r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 32;        g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 32;        b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 32;      }#endif    }    /*     * Spread out the values we have to the rest of the array so that     * we do not need to check for overflow.     */    for (i = 0; i < 256; i++) {      r_2_pix_alloc[i] = r_2_pix_alloc[256];      r_2_pix_alloc[i+ 512] = r_2_pix_alloc[511];      g_2_pix_alloc[i] = g_2_pix_alloc[256];      g_2_pix_alloc[i+ 512] = g_2_pix_alloc[511];      b_2_pix_alloc[i] = b_2_pix_alloc[256];      b_2_pix_alloc[i+ 512] = b_2_pix_alloc[511];    }    r_2_pix = r_2_pix_alloc + 256;    g_2_pix = g_2_pix_alloc + 256;    b_2_pix = b_2_pix_alloc + 256;}/* *-------------------------------------------------------------- * * Color16DitherImage -- * *	Converts image into 16 bit color. * * Results: *	None. * * Side effects: *	None. * *-------------------------------------------------------------- */void Color16DitherImage(src, out)unsigned char *src[];unsigned char *out;{    unsigned char *lum = src[0];    unsigned char *cb = src[1];    unsigned char *cr = src[2];    int cols;    int rows;        int L, CR, CB;    unsigned short *row1, *row2;    unsigned char *lum2;    int x, y;    int cr_r;    int cr_g;    int cb_g;    int cb_b;    int cols_2;    cols = coded_picture_width;    rows = coded_picture_height;    if (expand) {      cols *= 2;      rows *= 2;    }    cols_2 = cols/2;    row1 = (unsigned short *)out;    row2 = row1 + cols_2 + cols_2;    lum2 = lum + cols_2 + cols_2;    for (y=0; y<rows; y+=2) {        for (x=0; x<cols_2; x++) {            int R, G, B;            CR = *cr++;            CB = *cb++;            cr_r = Cr_r_tab[CR];            cr_g = Cr_g_tab[CR];            cb_g = Cb_g_tab[CB];            cb_b = Cb_b_tab[CB];            L = L_tab[(int) *lum++];            R = L + cr_r;            G = L + cr_g + cb_g;            B = L + cb_b;            *row1++ = (r_2_pix[R] | g_2_pix[G] | b_2_pix[B]);#ifdef INTERPOLATE            if(x != cols_2 - 1) {              CR = (CR + *cr) >> 1;              CB = (CB + *cb) >> 1;              cr_r = Cr_r_tab[CR];              cr_g = Cr_g_tab[CR];              cb_g = Cb_g_tab[CB];              cb_b = Cb_b_tab[CB];            }#endif            L = L_tab[(int) *lum++];            R = L + cr_r;            G = L + cr_g + cb_g;            B = L + cb_b;            *row1++ = (r_2_pix[R] | g_2_pix[G] | b_2_pix[B]);            /*             * Now, do second row.             */#ifdef INTERPOLATE            if(y != rows - 2) {              CR = (CR + *(cr + cols_2 - 1)) >> 1;              CB = (CB + *(cb + cols_2 - 1)) >> 1;              cr_r = Cr_r_tab[CR];              cr_g = Cr_g_tab[CR];              cb_g = Cb_g_tab[CB];              cb_b = Cb_b_tab[CB];            }#endif            L = L_tab[(int) *lum2++];            R = L + cr_r;            G = L + cr_g + cb_g;            B = L + cb_b;            *row2++ = (r_2_pix[R] | g_2_pix[G] | b_2_pix[B]);            L = L_tab[(int) *lum2++];            R = L + cr_r;            G = L + cr_g + cb_g;            B = L + cb_b;            *row2++ = (r_2_pix[R] | g_2_pix[G] | b_2_pix[B]);        }        /*         * These values are at the start of the next line, (due         * to the ++'s above),but they need to be at the start         * of the line after that.         */        lum += cols_2 + cols_2;        lum2 += cols_2 + cols_2;        row1 += cols_2 + cols_2;        row2 += cols_2 + cols_2;    }}/* *-------------------------------------------------------------- * * Color32DitherImage -- * *	Converts image into 32 bit color (or 24-bit non-packed). * * Results: *	None. * * Side effects: *	None. * *-------------------------------------------------------------- *//* * This is a copysoft version of the function above with ints instead * of shorts to cause a 4-byte pixel size */voidColor32DitherImage(src, out)unsigned char *src[];unsigned char *out;{    unsigned char *lum = src[0];    unsigned char *cb = src[1];    unsigned char *cr = src[2];    int cols;    int rows;    int L, CR, CB;    unsigned int *row1, *row2;    unsigned char *lum2;    int x, y;    int cr_r;    int cr_g;    int cb_g;    int cb_b;    int cols_2;    cols = coded_picture_width;    rows = coded_picture_height;    if (expand) {      cols *= 2;      rows *= 2;    }    cols_2 = cols/2;    row1 = (unsigned int *)out;    row2 = row1 + cols_2 + cols_2;    lum2 = lum + cols_2 + cols_2;    for (y=0; y<rows; y+=2) {        for (x=0; x<cols_2; x++) {            int R, G, B;            CR = *cr++;            CB = *cb++;            cr_r = Cr_r_tab[CR];            cr_g = Cr_g_tab[CR];            cb_g = Cb_g_tab[CB];            cb_b = Cb_b_tab[CB];            L = L_tab[(int) *lum++];            R = L + cr_r;            G = L + cr_g + cb_g;            B = L + cb_b;            *row1++ = (r_2_pix[R] | g_2_pix[G] | b_2_pix[B]);#ifdef INTERPOLATE            if(x != cols_2 - 1) {              CR = (CR + *cr) >> 1;              CB = (CB + *cb) >> 1;              cr_r = Cr_r_tab[CR];              cr_g = Cr_g_tab[CR];              cb_g = Cb_g_tab[CB];              cb_b = Cb_b_tab[CB];            }#endif            L = L_tab[(int) *lum++];            R = L + cr_r;            G = L + cr_g + cb_g;            B = L + cb_b;            *row1++ = (r_2_pix[R] | g_2_pix[G] | b_2_pix[B]);            /*             * Now, do second row.             */#ifdef INTERPOLATE            if(y != rows - 2) {              CR = (CR + *(cr + cols_2 - 1)) >> 1;              CB = (CB + *(cb + cols_2 - 1)) >> 1;              cr_r = Cr_r_tab[CR];              cr_g = Cr_g_tab[CR];              cb_g = Cb_g_tab[CB];              cb_b = Cb_b_tab[CB];            }#endif            L = L_tab [(int) *lum2++];            R = L + cr_r;            G = L + cr_g + cb_g;            B = L + cb_b;            *row2++ = (r_2_pix[R] | g_2_pix[G] | b_2_pix[B]);            L = L_tab [(int) *lum2++];            R = L + cr_r;            G = L + cr_g + cb_g;            B = L + cb_b;            *row2++ = (r_2_pix[R] | g_2_pix[G] | b_2_pix[B]);        }        lum += cols_2 + cols_2;        lum2 += cols_2 + cols_2;        row1 += cols_2 + cols_2;        row2 += cols_2 + cols_2;    }}#endif

⌨️ 快捷键说明

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