History

swscale/output: add missing yuv2packed1 and yuv2packed2 support for VUY{X,A}

James Almer committed 2 years ago

Commit 5f1bf3c1 parent 1eb026d1 file · +108 −0Browse files

Unified · Split

libswscale/output.c+108−0
@@ -2668,6 +2668,112 @@ yuv2xv36le_X_c(SwsContext *c, const int16_t *lumFilter, · 2667 unmodified lines
26682668 }
26692669 }
26702670
2671+static void
2672+yuv2vuyX_1_c(SwsContext *c, const int16_t *buf0,
2673+ const int16_t *ubuf[2], const int16_t *vbuf[2],
2674+ const int16_t *abuf0, uint8_t *dest, int dstW,
2675+ int uvalpha, int y)
2676+{
2677+ int hasAlpha = !!abuf0;
2678+ int i;
2679+
2680+ if (uvalpha < 2048) {
2681+ for (i = 0; i < dstW; i++) {
2682+ int Y = (buf0[i] + 64) >> 7;
2683+ int U = (ubuf[0][i] + 64) >> 7;
2684+ int V = (vbuf[0][i] + 64) >> 7;
2685+ int A = 255;
2686+
2687+ if (Y & 0x100)
2688+ Y = av_clip_uint8(Y);
2689+ if (U & 0x100)
2690+ U = av_clip_uint8(U);
2691+ if (V & 0x100)
2692+ V = av_clip_uint8(V);
2693+
2694+ if (hasAlpha) {
2695+ A = (abuf0[i] + 64) >> 7;
2696+ if (A & 0x100)
2697+ A = av_clip_uint8(A);
2698+ }
2699+
2700+ dest[4 * i ] = V;
2701+ dest[4 * i + 1] = U;
2702+ dest[4 * i + 2] = Y;
2703+ dest[4 * i + 3] = A;
2704+ }
2705+ } else {
2706+ for (i = 0; i < dstW; i++) {
2707+ int Y = (buf0[i] + 64) >> 7;
2708+ int U = (ubuf[0][i] + ubuf[1][i] + 128) >> 8;
2709+ int V = (vbuf[0][i] + vbuf[1][i] + 128) >> 8;
2710+ int A = 255;
2711+
2712+ if (Y & 0x100)
2713+ Y = av_clip_uint8(Y);
2714+ if (U & 0x100)
2715+ U = av_clip_uint8(U);
2716+ if (V & 0x100)
2717+ V = av_clip_uint8(V);
2718+
2719+ if (hasAlpha) {
2720+ A = (abuf0[i] + 64) >> 7;
2721+ if (A & 0x100)
2722+ A = av_clip_uint8(A);
2723+ }
2724+
2725+ dest[4 * i ] = V;
2726+ dest[4 * i + 1] = U;
2727+ dest[4 * i + 2] = Y;
2728+ dest[4 * i + 3] = A;
2729+ }
2730+ }
2731+}
2732+
2733+static void
2734+yuv2vuyX_2_c(SwsContext *c, const int16_t *buf[2],
2735+ const int16_t *ubuf[2], const int16_t *vbuf[2],
2736+ const int16_t *abuf[2], uint8_t *dest, int dstW,
2737+ int yalpha, int uvalpha, int y)
2738+{
2739+ int hasAlpha = abuf && abuf[0] && abuf[1];
2740+ const int16_t *buf0 = buf[0], *buf1 = buf[1],
2741+ *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
2742+ *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
2743+ *abuf0 = hasAlpha ? abuf[0] : NULL,
2744+ *abuf1 = hasAlpha ? abuf[1] : NULL;
2745+ int yalpha1 = 4096 - yalpha;
2746+ int uvalpha1 = 4096 - uvalpha;
2747+ int i;
2748+
2749+ av_assert2(yalpha <= 4096U);
2750+ av_assert2(uvalpha <= 4096U);
2751+
2752+ for (i = 0; i < dstW; i++) {
2753+ int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
2754+ int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
2755+ int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
2756+ int A = 255;
2757+
2758+ if (Y & 0x100)
2759+ Y = av_clip_uint8(Y);
2760+ if (U & 0x100)
2761+ U = av_clip_uint8(U);
2762+ if (V & 0x100)
2763+ V = av_clip_uint8(V);
2764+
2765+ if (hasAlpha) {
2766+ A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 19;
2767+ A = av_clip_uint8(A);
2768+ }
2769+
2770+ dest[4 * i ] = V;
2771+ dest[4 * i + 1] = U;
2772+ dest[4 * i + 2] = Y;
2773+ dest[4 * i + 3] = A;
2774+ }
2775+}
2776+
26712777 static void
26722778 yuv2vuyX_X_c(SwsContext *c, const int16_t *lumFilter,
26732779 const int16_t **lumSrc, int lumFilterSize,
@@ -3275,6 +3381,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 601 unmodified lines
32753381 break;
32763382 case AV_PIX_FMT_VUYA:
32773383 case AV_PIX_FMT_VUYX:
3384+ *yuv2packed1 = yuv2vuyX_1_c;
3385+ *yuv2packed2 = yuv2vuyX_2_c;
32783386 *yuv2packedX = yuv2vuyX_X_c;
32793387 break;
32803388 case AV_PIX_FMT_XV30LE:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t