📄 yuv2rgb.c
字号:
limit += dest_dx; \ /* replicate second even integral pixels: */\ do { \ STORE(df,d1,a11); \ d1+=BPP(df); \ STORE(df,d2,a21); \ d2+=BPP(df); \ if (!(--count)) \ goto rep_last_2; /* ??? */ \ } while ((limit -= step) >= 0); \ limit += dest_dx; \ /* calc. & replicate second half-pixels: */ \ AVERAGE(df,a11,a11,a13); \ AVERAGE(df,a21,a21,a23); \ do { \ STORE(df,d1,a11); \ d1+=BPP(df); \ STORE(df,d2,a21); \ d2+=BPP(df); \ if (!(--count)) \ goto rep_last_3; /* !!! */ \ } while ((limit -= step) >= 0); \ limit += dest_dx; \ /* replicate second odd integral pixels: */ \ do { \ STORE(df,d1,a13); \ d1+=BPP(df); \ STORE(df,d2,a23); \ d2+=BPP(df); \ if (!(--count)) \ goto last_pixel_2; /* !!! */ \ } while ((limit -= step) >= 0); \ limit += dest_dx; \ /* load & convert third 2x2 block: */ \ YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a12,a21,a22,sy1,sy2,su,sv); \ sy1+=2; sy2+=2; su++; sv++; \ /* calc. & replicate third half-pixels: */ \ AVERAGE(df,a13,a13,a11); \ AVERAGE(df,a23,a23,a21); \ do { \ STORE(df,d1,a13); \ d1+=BPP(df); \ STORE(df,d2,a23); \ d2+=BPP(df); \ if (!(--count)) \ goto rep_last_3; /* ??? */ \ } while ((limit -= step) >= 0); \ limit += dest_dx; \rep_even: /* replicate third even integral pixels: */ \ do { \ STORE(df,d1,a11); \ d1+=BPP(df); \ STORE(df,d2,a21); \ d2+=BPP(df); \ if (!(--count)) \ goto rep_last_2; /* ??? */ \ } while ((limit -= step) >= 0); \ limit += dest_dx; \ /* calc. & replicate fourth half-pixels: */ \ AVERAGE(df,a11,a11,a12); \ AVERAGE(df,a21,a21,a22); \ 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 third odd integral pixels: */ \ do { \ STORE(df,d1,a12); \ d1+=BPP(df); \ STORE(df,d2,a22); \ d2+=BPP(df); \ if (!(--count)) \ goto last_pixel; /* !!! */ \ } while ((limit -= step) >= 0); \ limit += dest_dx; \ } \last_pixel_2:/* store last integral pixels in a11/21: */ \ COPY(df,a11,a13); \ COPY(df,a21,a23); \last_pixel: /* check if we need to convert one more pixel:*/\ if ((src_x + src_dx) & 1) { \ /* update count & remainder: */ \ register int r2 = remainder >> 1; \ count += r2; remainder -= r2; \ if (count <= 0) \ goto rep_last; \ /* load & convert last 2x1 block: */ \ YUV_LOAD_CONVERT_2x1(cc,df,a12,a22,sy1,sy2,su,sv); \ /* calc. & replicate last half-pixels: */ \ AVERAGE(df,a11,a11,a12); \ AVERAGE(df,a21,a21,a22); \ do { \ STORE(df,d1,a11); \ d1+=BPP(df); \ STORE(df,d2,a21); \ d2+=BPP(df); \ if (!(--count)) \ goto rep_last; /* !!! */ \ } while ((limit -= step) >= 0); \ } \ goto rep_last; \rep_last_3: /* store last converted pixels in a12/22: */ \ COPY(df,a12,a13); \ COPY(df,a22,a23); \ goto rep_last; \rep_last_2: /* store last converted pixels in a12/22: */ \ COPY(df,a12,a11); \ COPY(df,a22,a21); \ /* 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 YUVtoRGB double-row 2x converters: ************//* * Generic YUVtoRGB double-row shrinking converter: * uses read-ahead optimization to process full 2x2 blocks * whenever possible. */#define DBLROW2X_SHRINK(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 = src_dx >> 1; /* -1 */ \ register int step = dest_dx; \ /* check row length: */ \ if (count) { \ /* check if we have an odd first block: */ \ if (src_x & 1) \ goto start_odd; \ /* process even pixels: */ \ do { \ PIXEL(df,a11); PIXEL(df,a12); \ PIXEL(df,a21); PIXEL(df,a22); \ /* make one Bresenham step ahead: */ \ if ((limit -= step) < 0) { \ limit += src_dx; \ /* can we process 2x2 pixels? */ \ if (!--count) \ goto last_pixel; \ /* process full 2x2 block: */ \ YUV_LOAD_CONVERT_2x2(cc,df,a11,a12,a21,a22,sy1,sy2,su,sv); \ sy1+=2; sy2+=2; su++; sv++; \ STORE(df,d1,a11); \ STORE(df,d1+BPP(df),a12); \ d1+=2*BPP(df); \ STORE(df,d2,a21); \ STORE(df,d2+BPP(df),a22); \ d2+=2*BPP(df); \ /* process average pixels: */ \ AVERAGE(df,a21,a11,a21); \ AVERAGE(df,a22,a12,a22); \ LOAD_AVERAGE(df,a11,a11,d0); \ LOAD_AVERAGE(df,a12,a12,d0+BPP(df)); \ d0+=2*BPP(df); \ STORE(df,d01,a11); \ STORE(df,d01+BPP(df),a12); \ d01+=2*BPP(df); \ STORE(df,d12,a21); \ STORE(df,d12+BPP(df),a22); \ d12+=2*BPP(df); \ } else { \ /* proc. first 2x1 block & skip next: */\ YUV_LOAD_CONVERT_2x1(cc,df,a11,a21,sy1,sy2,su,sv); \ sy1+=2; sy2+=2; su++; sv++; \ STORE(df,d1,a11); \ d1+=BPP(df); \ STORE(df,d2,a21); \ d2+=BPP(df); \ /* process average pixels: */ \ AVERAGE(df,a21,a11,a21); \ LOAD_AVERAGE(df,a11,a11,d0); \ d0+=BPP(df); \ STORE(df,d01,a11); \ d01+=BPP(df); \ STORE(df,d12,a21); \ d12+=BPP(df); \ } \ /* inverted Bresenham stepping: */ \ while ((limit -= step) >= 0) { \ /* skip next even source pixel: */ \ sy1++; sy2++; \ if ((limit -= step) < 0) \ goto cont_odd; \ /* skip odd source pixel: */ \ sy1++; sy2++; \ su++; sv++; /* next chroma: */ \ } \cont_even: /* continue loop with next even pixel: */ \ limit += src_dx; \ } while (--count); \ goto done; \last_pixel: /* use this branch to process last pixel:*/ \ count++; \start_odd: /* process odd pixels: */ \ do { \ /* convert 2x1 block: */ \ PIXEL(df,a11); PIXEL(df,a21); \ YUV_LOAD_CONVERT_2x1(cc,df,a11,a21,sy1,sy2,su,sv); \ STORE(df,d1,a11); \ d1+=BPP(df); \ STORE(df,d2,a21); \ d2+=BPP(df); \ /* process average pixels: */ \ AVERAGE(df,a21,a11,a21); \ LOAD_AVERAGE(df,a11,a11,d0); \ 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; \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -