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

📄 yuv2rgb.c

📁 linux下的一款播放器
💻 C
📖 第 1 页 / 共 5 页
字号:
                /* 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++;                 \                /* replicate even pixels: */                \                do {                                        \                    STORE(df,d1,a11);                       \                    d1+=BPP(df);                            \                    STORE(df,d2,a21);                       \                    d2+=BPP(df);                            \                    if (!(--count))                         \                        goto rep_last;                      \                } while ((limit -= step) >= 0);             \                limit += dest_dx;                           \rep_odd:        /* replicate odd pixels: */                 \                do {                                        \                    STORE(df,d1,a12);                       \                    d1+=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); \            }                                               \            /* restore the number of remaining pixels: */   \rep_last:   count += remainder;                             \            while (count --) {                              \                /* replicate them: */                       \                STORE(df,d1,a12);                           \                d1+=BPP(df);                                \                STORE(df,d2,a22);                           \                d2+=BPP(df);                                \            }                                               \        }                                                   \    }/* * Generic row 2x-stretching converter: */#define DBLROW_STRETCH2X(cc,df,d1,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,a11); PIXEL(df,a12);                   \            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,a12);                           \                STORE(df,d2,a22);                           \                d1 += 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,a11);                           \                STORE(df,d2,a21);                           \                /* calculate & store half-pixels: */        \                AVERAGE(df,a11,a11,a12);                    \                AVERAGE(df,a21,a21,a22);                    \                STORE(df,d1+BPP(df),a11);                   \                STORE(df,d1+2*BPP(df),a12);                 \                STORE(df,d2+BPP(df),a21);                   \                STORE(df,d2+2*BPP(df),a22);                 \                d1 += 3*BPP(df);                            \                d2 += 3*BPP(df);                            \                count -= 2;                                 \            }                                               \            /* process all internal 4x2 blocks: */          \            while (count >= 4) {                            \                /* process second 2x2 block: */             \                PIXEL(df,a13); PIXEL(df,a23);               \                YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a13,a21,a23,sy1,sy2,su,sv); \                sy1+=2; sy2+=2; su++; sv++;                 \                /* calculate & store first half-pixels: */  \                AVERAGE(df,a12,a12,a11);                    \                AVERAGE(df,a22,a22,a21);                    \                STORE(df,d1+0*BPP(df),a12);                 \                STORE(df,d1+1*BPP(df),a11);                 \                STORE(df,d2+0*BPP(df),a22);                 \                STORE(df,d2+1*BPP(df),a21);                 \                /* calculate & store second half-pixels: */ \                AVERAGE(df,a11,a11,a13);                    \                AVERAGE(df,a21,a21,a23);                    \                STORE(df,d1+2*BPP(df),a11);                 \                STORE(df,d1+3*BPP(df),a13);                 \                STORE(df,d2+2*BPP(df),a21);                 \                STORE(df,d2+3*BPP(df),a23);                 \                /* process third 2x2 block: */              \                YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a12,a21,a22,sy1,sy2,su,sv); \                sy1+=2; sy2+=2; su++; sv++;                 \                /* calculate & store third half-pixels: */  \                AVERAGE(df,a13,a13,a11);                    \                AVERAGE(df,a23,a23,a21);                    \                STORE(df,d1+4*BPP(df),a13);                 \                STORE(df,d1+5*BPP(df),a11);                 \                STORE(df,d2+4*BPP(df),a23);                 \                STORE(df,d2+5*BPP(df),a21);                 \                /* calculate & store fourth half-pixels: */ \                AVERAGE(df,a11,a11,a12);                    \                AVERAGE(df,a21,a21,a22);                    \                STORE(df,d1+6*BPP(df),a11);                 \                STORE(df,d1+7*BPP(df),a12);                 \                STORE(df,d2+6*BPP(df),a21);                 \                STORE(df,d2+7*BPP(df),a22);                 \                d1 += 8*BPP(df);                            \                d2 += 8*BPP(df);                            \                count -= 4;                                 \            }                                               \            /* check if we have one more 2x2 block: */      \            if (count >= 2) {                               \                /* process last 2x2 block: */               \                PIXEL(df,a13); PIXEL(df,a23);               \                YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a13,a21,a23,sy1,sy2,su,sv); \                sy1+=2; sy2+=2; su++; sv++;                 \                /* calculate & store first half-pixels: */  \                AVERAGE(df,a12,a12,a11);                    \                AVERAGE(df,a22,a22,a21);                    \                STORE(df,d1+0*BPP(df),a12);                 \                STORE(df,d1+1*BPP(df),a11);                 \                STORE(df,d2+0*BPP(df),a22);                 \                STORE(df,d2+1*BPP(df),a21);                 \                /* calculate & store second half-pixels: */ \                AVERAGE(df,a11,a11,a13);                    \                AVERAGE(df,a21,a21,a23);                    \                STORE(df,d1+2*BPP(df),a11);                 \                STORE(df,d1+3*BPP(df),a13);                 \                STORE(df,d2+2*BPP(df),a21);                 \                STORE(df,d2+3*BPP(df),a23);                 \                /* move last converted pixels to a12/22: */ \                COPY(df,a12,a13);                           \                COPY(df,a22,a23);                           \                d1 += 4*BPP(df);                            \                d2 += 4*BPP(df);                            \                count -= 2;                                 \            }                                               \            /* check if we have one more 2x1 block: */      \            if (count >= 1) {                               \                /* process last 2x1 block: */               \                YUV_LOAD_CONVERT_2x1(cc,df,a11,a21,sy1,sy2,su,sv); \                /* calculate & store last half-pixels: */   \                AVERAGE(df,a12,a12,a11);                    \                AVERAGE(df,a22,a22,a21);                    \                STORE(df,d1+0*BPP(df),a12);                 \                STORE(df,d1+1*BPP(df),a11);                 \                STORE(df,d1+2*BPP(df),a11);                 \                STORE(df,d2+0*BPP(df),a22);                 \                STORE(df,d2+1*BPP(df),a21);                 \                STORE(df,d2+2*BPP(df),a21);                 \            } else {                                        \                /* just replicate last pixels: */           \                STORE(df,d1,a12);                           \                STORE(df,d2,a22);                           \            }                                               \        }                                                   \    }/* * Generic row 2x+ stretching converter: *  "???" comments mean that under normal conditions these jumps *  should never be executed; nevertheless, I left these checks *  in place to guarantee the correct termination of the algorithm *  in all possible scenarios. */#define DBLROW_STRETCH2XPLUS(cc,df,d1,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 << 1;  /* !!! */         \        /* # of half-pixels to be processed separately: */  \        int remainder = 3*dest_dx - limit;                  \        if ((src_x + src_dx) & 1) remainder += 2*dest_dx;   \        remainder /= step;                                  \        /* check row length: */                             \        if (count) {                                        \            PIXEL(df,a11); PIXEL(df,a12);                   \            PIXEL(df,a21); PIXEL(df,a22);                   \            PIXEL(df,a13); PIXEL(df,a23);                   \            /* check if an odd or single 2x1 block: */      \            if ((src_x & 1) || src_dx < 2) {                \                /* convert first 2x1 block: */              \                YUV_LOAD_CONVERT_2x1(cc,df,a12,a22,sy1,sy2,su,sv); \                sy1++; sy2++; su++; sv++;                   \                /* update count: */                         \                if ((count -= remainder) <= 0)              \                    goto rep_last;                          \                goto rep_odd;                               \            } else {                                        \                /* convert first 2x2 block: */              \                YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a12,a21,a22,sy1,sy2,su,sv); \                sy1+=2; sy2+=2; su++; sv++;                 \                /* update count: */                         \                if ((count -= remainder) <= 0)              \                    goto rep_last_2;        /* ??? */       \                goto rep_even;                              \            }                                               \            /* the main loop: */                            \            while (1) {                                     \                /* load & convert second 2x2 block: */      \                YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a13,a21,a23,sy1,sy2,su,sv); \                sy1+=2; sy2+=2; su++; sv++;                 \                /* calc. & replicate first half-pixels: */  \                AVERAGE(df,a12,a12,a11);                    \                AVERAGE(df,a22,a22,a21);                    \                do {                                        \                    STORE(df,d1,a12);                       \                    d1+=BPP(df);                            \                    STORE(df,d2,a22);                       \                    d2+=BPP(df);                            \                    if (!(--count))                         \                        goto rep_last;      /* ??? */       \                } while ((limit -= step) >= 0);             \

⌨️ 快捷键说明

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