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

📄 yuv2rgb.c

📁 symbian 下的helix player源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
                d0+=BPP(df);                                \
                STORE(df,d01,a11);                          \
                d01+=BPP(df);                               \
                STORE(df,d12,a21);                          \
                d12+=BPP(df);                               \
                /* inverted Bresenham stepping: */          \
                do {                                        \
                    /* skip odd source pixel: */            \
                    sy1++; sy2++;                           \
                    su++; sv++; /* next chroma: */          \
                    if ((limit -= step) < 0)                \
                        goto cont_even;                     \
                    /* skip even source pixel: */           \
                    sy1++; sy2++;                           \
                } while ((limit -= step) >= 0);             \
cont_odd:       limit += src_dx;                            \
            } while (--count);                              \
done:       ;                                               \
        }                                                   \
    }

/*
 * Generic YUVtoRGB double-row copy converter:
 */
#define DBLROW2X_COPY(cc,df,d0,d01,d1,d12,d2,dest_x,dest_dx,sy1,sy2,su,sv,src_x,src_dx) \
    {                                                       \
        register int count = dest_dx;                       \
        /* convert first 2x1 block: */                      \
        if ((src_x & 1) && count) {                         \
            YUV_LOAD_CONVERT_AVERAGE_STORE_2x1(cc,df,d0,d01,d1,d12,d2,sy1,sy2,su,sv); \
            count--;                                        \
        }                                                   \
        /* convert all integral 2x2 blocks: */              \
        while (count >= 2) {                                \
            YUV_LOAD_CONVERT_AVERAGE_DITHER_STORE_2x2(cc,df,d0,d01,d1,d12,d2,sy1,sy2,su,sv); \
            count -= 2;                                     \
        }                                                   \
        /* convert last 2x1 block: */                       \
        if (count) {                                        \
            YUV_LOAD_CONVERT_AVERAGE_STORE_2x1(cc,df,d0,d01,d1,d12,d2,sy1,sy2,su,sv); \
        }                                                   \
    }

/*
 * Generic YUVtoRGB double row stretching converter:
 */
#define DBLROW2X_STRETCH(cc,df,d0,d01,d1,d12,d2,dest_x,dest_dx,sy1,sy2,su,sv,src_x,src_dx) \
    {                                                       \
        /* initialize local variables: */                   \
        register int count = dest_dx;                       \
        register int limit = dest_dx >> 1; /* !!! */        \
        register int step = src_dx;                         \
        /* # of pixels to be processed separately: */       \
        int remainder = dest_dx - limit;                    \
        if ((src_x + src_dx) & 1) remainder += dest_dx;     \
        remainder /= step;                                  \
        /* check row length: */                             \
        if (count) {                                        \
            PIXEL(df,a11); PIXEL(df,a12);                   \
            PIXEL(df,a21); PIXEL(df,a22);                   \
            PIXEL(df,a01x);PIXEL(df,a12x);                  \
            /* update count: */                             \
            if ((count -= remainder) <= 0)                  \
                goto convert_last;                          \
            /* check if we have an odd first block: */      \
            if (src_x & 1) {                                \
                /* convert first 2x1 block: */              \
                YUV_LOAD_CONVERT_2x1(cc,df,a12,a22,sy1,sy2,su,sv); \
                sy1++; sy2++; su++; sv++;                   \
                goto rep_odd;                               \
            }                                               \
            /* the main loop: */                            \
            while (1) {                                     \
                /* load & convert next 2x2 pixels: */       \
                YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a12,a21,a22,sy1,sy2,su,sv); \
                sy1+=2; sy2+=2; su++; sv++;                 \
                /* average and replicate even pixels: */    \
                LOAD_AVERAGE(df,a01x,a11,d0);               \
                AVERAGE(df,a12x,a11,a21);                   \
                do {                                        \
                    d0+=BPP(df);                            \
                    STORE(df,d01,a01x);                     \
                    d01+=BPP(df);                           \
                    STORE(df,d1,a11);                       \
                    d1+=BPP(df);                            \
                    STORE(df,d12,a12x);                     \
                    d12+=BPP(df);                           \
                    STORE(df,d2,a21);                       \
                    d2+=BPP(df);                            \
                    if (!(--count))                         \
                        goto rep_last;                      \
                } while ((limit -= step) >= 0);             \
                limit += dest_dx;                           \
rep_odd:        /* average & replicate odd pixels: */       \
                LOAD_AVERAGE(df,a01x,a12,d0);               \
                AVERAGE(df,a12x,a12,a22);                   \
                do {                                        \
                    d0+=BPP(df);                            \
                    STORE(df,d01,a01x);                     \
                    d01+=BPP(df);                           \
                    STORE(df,d1,a12);                       \
                    d1+=BPP(df);                            \
                    STORE(df,d12,a12x);                     \
                    d12+=BPP(df);                           \
                    STORE(df,d2,a22);                       \
                    d2+=BPP(df);                            \
                    if (!(--count))                         \
                        goto check_last;                    \
                } while ((limit -= step) >= 0);             \
                limit += dest_dx;                           \
            }                                               \
check_last: /* check if we need to convert one more pixel:*/\
            if ((src_x + src_dx) & 1) {                     \
convert_last:   /* last 2x1 block: */                       \
                YUV_LOAD_CONVERT_2x1(cc,df,a12,a22,sy1,sy2,su,sv); \
                /* calc. average pixels: */                 \
                LOAD_AVERAGE(df,a01x,a12,d0);               \
                AVERAGE(df,a12x,a12,a22);                   \
            }                                               \
            /* restore the number of remaining pixels: */   \
rep_last:   count += remainder;                             \
            while (count --) {                              \
                /* replicate them: */                       \
                STORE(df,d01,a01x);                         \
                d01+=BPP(df);                               \
                STORE(df,d1,a12);                           \
                d1+=BPP(df);                                \
                STORE(df,d12,a12x);                         \
                d12+=BPP(df);                               \
                STORE(df,d2,a22);                           \
                d2+=BPP(df);                                \
            }                                               \
        }                                                   \
    }

/*
 * Generic row 2x-stretching converter:
 */
#define DBLROW2X_STRETCH2X(cc,df,d0,d01,d1,d12,d2,dest_x,dest_dx,sy1,sy2,su,sv,src_x,src_dx) \
    {                                                       \
        /* initialize local variables: */                   \
        register int count = src_dx;                        \
        /* check row length: */                             \
        if (count) {                                        \
            PIXEL(df,a011);PIXEL(df,a012);                  \
            PIXEL(df,a11); PIXEL(df,a12);                   \
            PIXEL(df,a121);PIXEL(df,a122);                  \
            PIXEL(df,a21); PIXEL(df,a22);                   \
            /* check if we have an odd or single pixel: */  \
            if ((src_x & 1) || count < 2) {                 \
                /* process first 2x1 block: */              \
                YUV_LOAD_CONVERT_2x1(cc,df,a12,a22,sy1,sy2,su,sv); \
                sy1++; sy2++; su++; sv++;                   \
                STORE(df,d1+0*BPP(df),a12);                 \
                STORE(df,d2+0*BPP(df),a22);                 \
                /* process vertical half-pixels: */         \
                LOAD_AVERAGE(df,a012,a12,d0);               \
                STORE(df,d01+0*BPP(df),a012);               \
                AVERAGE(df,a122,a12,a22);                   \
                STORE(df,d12+0*BPP(df),a122);               \
                /* shift pointers: */                       \
                d0  += BPP(df);                             \
                d01 += BPP(df);                             \
                d1  += BPP(df);                             \
                d12 += BPP(df);                             \
                d2  += BPP(df);                             \
                count -= 1;                                 \
            } else {                                         \
                /* process first 2x2 block: */              \
                YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a12,a21,a22,sy1,sy2,su,sv); \
                sy1+=2; sy2+=2; su++; sv++;                 \
                STORE(df,d1+0*BPP(df),a11);                 \
                STORE(df,d2+0*BPP(df),a21);                 \
                STORE(df,d1+2*BPP(df),a12);                 \
                STORE(df,d2+2*BPP(df),a22);                 \
                /* process vertical half-pixels: */         \
                LOAD_AVERAGE(df,a011,a11,d0);               \
                STORE(df,d01+0*BPP(df),a011);               \
                AVERAGE(df,a121,a11,a21);                   \
                STORE(df,d12+0*BPP(df),a121);               \
                LOAD_AVERAGE(df,a012,a12,d0+2*BPP(df));     \
                STORE(df,d01+2*BPP(df),a012);               \
                AVERAGE(df,a122,a12,a22);                   \
                STORE(df,d12+2*BPP(df),a122);               \
                /* process horisontal half-pixels: */       \
                AVERAGE(df,a011,a011,a012);                 \
                STORE(df,d01+1*BPP(df),a011);               \
                AVERAGE(df,a11,a11,a12);                    \
                STORE(df,d1+1*BPP(df),a11);                 \
                AVERAGE(df,a121,a121,a122);                 \
                STORE(df,d12+1*BPP(df),a121);               \
                AVERAGE(df,a21,a21,a22);                    \
                STORE(df,d2+1*BPP(df),a21);                 \
                /* shift pointers: */                       \
                d0  += 3*BPP(df);                           \
                d01 += 3*BPP(df);                           \
                d1  += 3*BPP(df);                           \
                d12 += 3*BPP(df);                           \
                d2  += 3*BPP(df);                           \
                count -= 2;                                 \
            }                                               \
            /* process all internal 4x2 blocks: */          \
            while (count >= 4) {                            \
                /* process second 2x2 block: */             \
                PIXEL(df,a013); PIXEL(df,a13);              \
                PIXEL(df,a123); PIXEL(df,a23);              \
                YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a13,a21,a23,sy1,sy2,su,sv); \
                sy1+=2; sy2+=2; su++; sv++;                 \
                STORE(df,d1+1*BPP(df),a11);                 \
                STORE(df,d2+1*BPP(df),a21);                 \
                STORE(df,d1+3*BPP(df),a13);                 \
                STORE(df,d2+3*BPP(df),a23);                 \
                /* process vertical half-pixels: */         \
                LOAD_AVERAGE(df,a011,a11,d0+1*BPP(df));     \
                STORE(df,d01+1*BPP(df),a011);               \
                AVERAGE(df,a121,a11,a21);                   \
                STORE(df,d12+1*BPP(df),a121);               \
                LOAD_AVERAGE(df,a013,a13,d0+3*BPP(df));     \
                STORE(df,d01+3*BPP(df),a013);               \
                AVERAGE(df,a123,a13,a23);                   \
                STORE(df,d12+3*BPP(df),a123);               \
                /* process horisontal half-pixels: */       \
                AVERAGE(df,a012,a012,a011);                 \
                STORE(df,d01+0*BPP(df),a012);               \
                AVERAGE(df,a12,a12,a11);                

⌨️ 快捷键说明

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