2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Library <2002> Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
29 #include "video-format.h"
30 #include "video-orc.h"
33 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
34 /* restrict should be available */
35 #elif defined(__GNUC__) && __GNUC__ >= 4
36 #define restrict __restrict__
37 #elif defined(_MSC_VER) && _MSC_VER >= 1500
38 #define restrict __restrict
40 #define restrict /* no op */
44 /* Line conversion to AYUV */
46 #define GET_PLANE_STRIDE(plane) (stride(plane))
47 #define GET_PLANE_LINE(plane, line) \
48 (gpointer)(((guint8*)(data[plane])) + stride[plane] * (line))
50 #define GET_COMP_STRIDE(comp) \
51 GST_VIDEO_FORMAT_INFO_STRIDE (info, stride, comp)
52 #define GET_COMP_DATA(comp) \
53 GST_VIDEO_FORMAT_INFO_DATA (info, data, comp)
55 #define GET_COMP_LINE(comp, line) \
56 (gpointer)(((guint8*)GET_COMP_DATA (comp)) + \
57 GET_COMP_STRIDE(comp) * (line))
59 #define GET_LINE(line) GET_PLANE_LINE (0, line)
61 #define GET_Y_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_Y, line)
62 #define GET_U_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_U, line)
63 #define GET_V_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_V, line)
65 #define GET_R_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_R, line)
66 #define GET_G_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_G, line)
67 #define GET_B_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_B, line)
69 #define GET_A_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_A, line)
71 #define GET_UV_420(line, flags) \
72 (flags & GST_VIDEO_PACK_FLAG_INTERLACED ? \
73 ((line & ~3) >> 1) + (line & 1) : \
75 #define GET_UV_410(line, flags) \
76 (flags & GST_VIDEO_PACK_FLAG_INTERLACED ? \
77 ((line & ~7) >> 2) + (line & 1) : \
80 #define IS_CHROMA_LINE_420(line, flags) \
81 (flags & GST_VIDEO_PACK_FLAG_INTERLACED ? \
82 !(line & 2) : !(line & 1))
83 #define IS_CHROMA_LINE_410(line, flags) \
84 (flags & GST_VIDEO_PACK_FLAG_INTERLACED ? \
85 !(line & 6) : !(line & 3))
87 #define IS_ALIGNED(x,n) ((((guintptr)(x)&((n)-1))) == 0)
89 #define PACK_420 GST_VIDEO_FORMAT_AYUV, unpack_planar_420, 1, pack_planar_420
91 unpack_planar_420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
92 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
93 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
95 gint uv = GET_UV_420 (y, flags);
96 const guint8 *restrict sy = GET_Y_LINE (y);
97 const guint8 *restrict su = GET_U_LINE (uv);
98 const guint8 *restrict sv = GET_V_LINE (uv);
99 guint8 *restrict d = dest;
113 video_orc_unpack_I420 (d, sy, su, sv, width);
117 pack_planar_420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
118 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
119 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
122 gint uv = GET_UV_420 (y, flags);
123 guint8 *dy = GET_Y_LINE (y);
124 guint8 *du = GET_U_LINE (uv);
125 guint8 *dv = GET_V_LINE (uv);
126 const guint8 *s = src;
128 if (IS_CHROMA_LINE_420 (y, flags)) {
129 if (IS_ALIGNED (s, 8))
130 video_orc_pack_I420 (dy, du, dv, s, width / 2);
134 for (i = 0; i < width / 2; i++) {
135 dy[i * 2 + 0] = s[i * 8 + 1];
136 dy[i * 2 + 1] = s[i * 8 + 5];
137 du[i] = s[i * 8 + 2];
138 dv[i] = s[i * 8 + 3];
144 dy[i] = s[i * 4 + 1];
145 du[i >> 1] = s[i * 4 + 2];
146 dv[i >> 1] = s[i * 4 + 3];
149 video_orc_pack_Y (dy, s, width);
152 #define PACK_YUY2 GST_VIDEO_FORMAT_AYUV, unpack_YUY2, 1, pack_YUY2
154 unpack_YUY2 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
155 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
156 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
158 const guint8 *restrict s = GET_LINE (y);
159 guint8 *restrict d = dest;
172 if (IS_ALIGNED (d, 8))
173 video_orc_unpack_YUY2 (d, s, width / 2);
177 for (i = 0; i < width / 2; i++) {
179 d[i * 8 + 1] = s[i * 4 + 0];
180 d[i * 8 + 2] = s[i * 4 + 1];
181 d[i * 8 + 3] = s[i * 4 + 3];
183 d[i * 8 + 5] = s[i * 4 + 2];
184 d[i * 8 + 6] = s[i * 4 + 1];
185 d[i * 8 + 7] = s[i * 4 + 3];
193 d[i * 4 + 1] = s[i * 2 + 0];
194 d[i * 4 + 2] = s[i * 2 + 1];
195 d[i * 4 + 3] = s[i * 2 + 3];
200 pack_YUY2 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
201 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
202 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
205 guint8 *restrict d = GET_LINE (y);
206 const guint8 *restrict s = src;
208 if (IS_ALIGNED (s, 8))
209 video_orc_pack_YUY2 (d, s, width / 2);
212 for (i = 0; i < width / 2; i++) {
213 d[i * 4 + 0] = s[i * 8 + 1];
214 d[i * 4 + 1] = s[i * 8 + 2];
215 d[i * 4 + 2] = s[i * 8 + 5];
216 d[i * 4 + 3] = s[i * 8 + 3];
223 d[i * 2 + 0] = s[i * 4 + 1];
224 d[i * 2 + 1] = s[i * 4 + 2];
225 d[i * 2 + 3] = s[i * 4 + 3];
229 #define PACK_UYVY GST_VIDEO_FORMAT_AYUV, unpack_UYVY, 1, pack_UYVY
231 unpack_UYVY (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
232 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
233 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
235 const guint8 *s = GET_LINE (y);
249 if (IS_ALIGNED (d, 8))
250 video_orc_unpack_UYVY (d, s, width / 2);
254 for (i = 0; i < width / 2; i++) {
256 d[i * 8 + 1] = s[i * 4 + 1];
257 d[i * 8 + 2] = s[i * 4 + 0];
258 d[i * 8 + 3] = s[i * 4 + 2];
260 d[i * 8 + 5] = s[i * 4 + 3];
261 d[i * 8 + 6] = s[i * 4 + 0];
262 d[i * 8 + 7] = s[i * 4 + 2];
270 d[i * 4 + 1] = s[i * 2 + 1];
271 d[i * 4 + 2] = s[i * 2 + 0];
272 d[i * 4 + 3] = s[i * 2 + 2];
277 pack_UYVY (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
278 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
279 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
282 guint8 *restrict d = GET_LINE (y);
283 const guint8 *restrict s = src;
285 if (IS_ALIGNED (s, 8))
286 video_orc_pack_UYVY (d, s, width / 2);
289 for (i = 0; i < width / 2; i++) {
290 d[i * 4 + 0] = s[i * 8 + 2];
291 d[i * 4 + 1] = s[i * 8 + 1];
292 d[i * 4 + 2] = s[i * 8 + 3];
293 d[i * 4 + 3] = s[i * 8 + 5];
299 d[i * 2 + 0] = s[i * 4 + 2];
300 d[i * 2 + 1] = s[i * 4 + 1];
301 d[i * 2 + 2] = s[i * 4 + 3];
305 #define PACK_VYUY GST_VIDEO_FORMAT_AYUV, unpack_VYUY, 1, pack_VYUY
307 unpack_VYUY (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
308 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
309 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
311 const guint8 *s = GET_LINE (y);
325 if (IS_ALIGNED (d, 8))
326 video_orc_unpack_VYUY (d, s, width / 2);
330 for (i = 0; i < width / 2; i++) {
332 d[i * 8 + 1] = s[i * 4 + 1];
333 d[i * 8 + 2] = s[i * 4 + 0];
334 d[i * 8 + 3] = s[i * 4 + 2];
336 d[i * 8 + 5] = s[i * 4 + 3];
337 d[i * 8 + 6] = s[i * 4 + 0];
338 d[i * 8 + 7] = s[i * 4 + 2];
346 d[i * 4 + 1] = s[i * 2 + 1];
347 d[i * 4 + 2] = s[i * 2 + 0];
348 d[i * 4 + 3] = s[i * 2 + 2];
353 pack_VYUY (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
354 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
355 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
358 guint8 *restrict d = GET_LINE (y);
359 const guint8 *restrict s = src;
361 if (IS_ALIGNED (s, 8))
362 video_orc_pack_VYUY (d, s, width / 2);
365 for (i = 0; i < width / 2; i++) {
366 d[i * 4 + 0] = s[i * 8 + 2];
367 d[i * 4 + 1] = s[i * 8 + 1];
368 d[i * 4 + 2] = s[i * 8 + 3];
369 d[i * 4 + 3] = s[i * 8 + 5];
375 d[i * 2 + 0] = s[i * 4 + 2];
376 d[i * 2 + 1] = s[i * 4 + 1];
377 d[i * 2 + 2] = s[i * 4 + 3];
381 #define PACK_YVYU GST_VIDEO_FORMAT_AYUV, unpack_YVYU, 1, pack_YVYU
383 unpack_YVYU (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
384 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
385 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
387 const guint8 *restrict s = GET_LINE (y);
388 guint8 *restrict d = dest;
401 if (IS_ALIGNED (d, 8))
402 video_orc_unpack_YVYU (d, s, width / 2);
406 for (i = 0; i < width / 2; i++) {
408 d[i * 8 + 1] = s[i * 4 + 0];
409 d[i * 8 + 2] = s[i * 4 + 3];
410 d[i * 8 + 3] = s[i * 4 + 1];
412 d[i * 8 + 5] = s[i * 4 + 2];
413 d[i * 8 + 6] = s[i * 4 + 3];
414 d[i * 8 + 7] = s[i * 4 + 1];
422 d[i * 4 + 1] = s[i * 2 + 0];
423 d[i * 4 + 2] = s[i * 2 + 3];
424 d[i * 4 + 3] = s[i * 2 + 1];
429 pack_YVYU (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
430 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
431 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
434 guint8 *restrict d = GET_LINE (y);
435 const guint8 *restrict s = src;
437 if (IS_ALIGNED (s, 8))
438 video_orc_pack_YVYU (d, s, width / 2);
441 for (i = 0; i < width / 2; i++) {
442 d[i * 4 + 0] = s[i * 8 + 1];
443 d[i * 4 + 1] = s[i * 8 + 3];
444 d[i * 4 + 2] = s[i * 8 + 5];
445 d[i * 4 + 3] = s[i * 8 + 2];
452 d[i * 2 + 0] = s[i * 4 + 1];
453 d[i * 2 + 1] = s[i * 4 + 3];
454 d[i * 2 + 3] = s[i * 4 + 2];
458 #define PACK_v308 GST_VIDEO_FORMAT_AYUV, unpack_v308, 1, pack_v308
460 unpack_v308 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
461 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
462 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
465 const guint8 *restrict s = GET_LINE (y);
466 guint8 *restrict d = dest;
470 for (i = 0; i < width; i++) {
472 d[i * 4 + 1] = s[i * 3 + 0];
473 d[i * 4 + 2] = s[i * 3 + 1];
474 d[i * 4 + 3] = s[i * 3 + 2];
479 pack_v308 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
480 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
481 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
485 guint8 *restrict d = GET_LINE (y);
486 const guint8 *restrict s = src;
488 for (i = 0; i < width; i++) {
489 d[i * 3 + 0] = s[i * 4 + 1];
490 d[i * 3 + 1] = s[i * 4 + 2];
491 d[i * 3 + 2] = s[i * 4 + 3];
495 #define PACK_IYU2 GST_VIDEO_FORMAT_AYUV, unpack_IYU2, 1, pack_IYU2
497 unpack_IYU2 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
498 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
499 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
502 const guint8 *restrict s = GET_LINE (y);
503 guint8 *restrict d = dest;
507 for (i = 0; i < width; i++) {
509 d[i * 4 + 1] = s[i * 3 + 1];
510 d[i * 4 + 2] = s[i * 3 + 0];
511 d[i * 4 + 3] = s[i * 3 + 2];
516 pack_IYU2 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
517 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
518 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
522 guint8 *restrict d = GET_LINE (y);
523 const guint8 *restrict s = src;
525 for (i = 0; i < width; i++) {
526 d[i * 3 + 0] = s[i * 4 + 2];
527 d[i * 3 + 1] = s[i * 4 + 1];
528 d[i * 3 + 2] = s[i * 4 + 3];
532 #define PACK_AYUV GST_VIDEO_FORMAT_AYUV, unpack_copy4, 1, pack_copy4
533 #define PACK_ARGB GST_VIDEO_FORMAT_ARGB, unpack_copy4, 1, pack_copy4
535 unpack_copy4 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
536 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
537 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
539 const guint8 *restrict s = GET_LINE (y);
543 memcpy (dest, s, width * 4);
547 pack_copy4 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
548 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
549 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
552 guint8 *restrict d = GET_LINE (y);
554 memcpy (d, src, width * 4);
557 #define PACK_v210 GST_VIDEO_FORMAT_AYUV64, unpack_v210, 1, pack_v210
559 unpack_v210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
560 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
561 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
564 const guint8 *restrict s = GET_LINE (y);
565 guint16 *restrict d = dest;
566 guint32 a0, a1, a2, a3;
567 guint16 y0, y1, y2, y3, y4, y5;
574 for (i = 0; i < width; i += 6) {
575 a0 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 0);
576 a1 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 4);
577 a2 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 8);
578 a3 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 12);
580 u0 = ((a0 >> 0) & 0x3ff) << 6;
581 y0 = ((a0 >> 10) & 0x3ff) << 6;
582 v0 = ((a0 >> 20) & 0x3ff) << 6;
583 y1 = ((a1 >> 0) & 0x3ff) << 6;
585 u2 = ((a1 >> 10) & 0x3ff) << 6;
586 y2 = ((a1 >> 20) & 0x3ff) << 6;
587 v2 = ((a2 >> 0) & 0x3ff) << 6;
588 y3 = ((a2 >> 10) & 0x3ff) << 6;
590 u4 = ((a2 >> 20) & 0x3ff) << 6;
591 y4 = ((a3 >> 0) & 0x3ff) << 6;
592 v4 = ((a3 >> 10) & 0x3ff) << 6;
593 y5 = ((a3 >> 20) & 0x3ff) << 6;
595 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
612 d[4 * (i + 0) + 0] = 0xffff;
613 d[4 * (i + 0) + 1] = y0;
614 d[4 * (i + 0) + 2] = u0;
615 d[4 * (i + 0) + 3] = v0;
618 d[4 * (i + 1) + 0] = 0xffff;
619 d[4 * (i + 1) + 1] = y1;
620 d[4 * (i + 1) + 2] = u0;
621 d[4 * (i + 1) + 3] = v0;
624 d[4 * (i + 2) + 0] = 0xffff;
625 d[4 * (i + 2) + 1] = y2;
626 d[4 * (i + 2) + 2] = u2;
627 d[4 * (i + 2) + 3] = v2;
630 d[4 * (i + 3) + 0] = 0xffff;
631 d[4 * (i + 3) + 1] = y3;
632 d[4 * (i + 3) + 2] = u2;
633 d[4 * (i + 3) + 3] = v2;
636 d[4 * (i + 4) + 0] = 0xffff;
637 d[4 * (i + 4) + 1] = y4;
638 d[4 * (i + 4) + 2] = u4;
639 d[4 * (i + 4) + 3] = v4;
642 d[4 * (i + 5) + 0] = 0xffff;
643 d[4 * (i + 5) + 1] = y5;
644 d[4 * (i + 5) + 2] = u4;
645 d[4 * (i + 5) + 3] = v4;
651 pack_v210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
652 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
653 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
657 guint8 *restrict d = GET_LINE (y);
658 const guint16 *restrict s = src;
659 guint32 a0, a1, a2, a3;
660 guint16 y0, y1, y2, y3, y4, y5;
664 for (i = 0; i < width - 5; i += 6) {
665 y0 = s[4 * (i + 0) + 1] >> 6;
666 y1 = s[4 * (i + 1) + 1] >> 6;
667 y2 = s[4 * (i + 2) + 1] >> 6;
668 y3 = s[4 * (i + 3) + 1] >> 6;
669 y4 = s[4 * (i + 4) + 1] >> 6;
670 y5 = s[4 * (i + 5) + 1] >> 6;
672 u0 = s[4 * (i + 0) + 2] >> 6;
673 u1 = s[4 * (i + 2) + 2] >> 6;
674 u2 = s[4 * (i + 4) + 2] >> 6;
676 v0 = s[4 * (i + 0) + 3] >> 6;
677 v1 = s[4 * (i + 2) + 3] >> 6;
678 v2 = s[4 * (i + 4) + 3] >> 6;
680 a0 = u0 | (y0 << 10) | (v0 << 20);
681 a1 = y1 | (u1 << 10) | (y2 << 20);
682 a2 = v1 | (y3 << 10) | (u2 << 20);
683 a3 = y4 | (v2 << 10) | (y5 << 20);
685 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 0, a0);
686 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 4, a1);
687 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 8, a2);
688 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 12, a3);
691 y0 = s[4 * (i + 0) + 1] >> 6;
692 u0 = s[4 * (i + 0) + 2] >> 6;
693 v0 = s[4 * (i + 0) + 3] >> 6;
695 y1 = s[4 * (i + 1) + 1] >> 6;
699 y2 = s[4 * (i + 2) + 1] >> 6;
700 u1 = s[4 * (i + 2) + 2] >> 6;
701 v1 = s[4 * (i + 2) + 3] >> 6;
708 y3 = s[4 * (i + 3) + 1] >> 6;
712 y4 = s[4 * (i + 4) + 1] >> 6;
713 u2 = s[4 * (i + 4) + 2] >> 6;
714 v2 = s[4 * (i + 4) + 3] >> 6;
722 a0 = u0 | (y0 << 10) | (v0 << 20);
723 a1 = y1 | (u1 << 10) | (y2 << 20);
724 a2 = v1 | (y3 << 10) | (u2 << 20);
725 a3 = y4 | (v2 << 10) | (y5 << 20);
727 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 0, a0);
728 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 4, a1);
729 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 8, a2);
730 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 12, a3);
734 #define PACK_v216 GST_VIDEO_FORMAT_AYUV64, unpack_v216, 1, pack_v216
736 unpack_v216 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
737 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
738 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
741 const guint8 *restrict s = GET_LINE (y);
742 guint16 *restrict d = dest;
747 d[1] = GST_READ_UINT16_LE (s + 6);
748 d[2] = GST_READ_UINT16_LE (s + 0);
749 d[3] = GST_READ_UINT16_LE (s + 4);
755 for (i = 0; i < width; i++) {
756 d[i * 4 + 0] = 0xffff;
757 d[i * 4 + 1] = GST_READ_UINT16_LE (s + i * 4 + 2);
758 d[i * 4 + 2] = GST_READ_UINT16_LE (s + (i >> 1) * 8 + 0);
759 d[i * 4 + 3] = GST_READ_UINT16_LE (s + (i >> 1) * 8 + 4);
764 pack_v216 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
765 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
766 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
770 guint8 *restrict d = GET_LINE (y);
771 const guint16 *restrict s = src;
773 for (i = 0; i < width - 1; i += 2) {
774 GST_WRITE_UINT16_LE (d + i * 4 + 0, s[(i + 0) * 4 + 2]);
775 GST_WRITE_UINT16_LE (d + i * 4 + 2, s[(i + 0) * 4 + 1]);
776 GST_WRITE_UINT16_LE (d + i * 4 + 4, s[(i + 0) * 4 + 3]);
777 GST_WRITE_UINT16_LE (d + i * 4 + 6, s[(i + 1) * 4 + 1]);
779 if (i == width - 1) {
780 GST_WRITE_UINT16_LE (d + i * 4 + 0, s[i * 4 + 2]);
781 GST_WRITE_UINT16_LE (d + i * 4 + 2, s[i * 4 + 1]);
782 GST_WRITE_UINT16_LE (d + i * 4 + 4, s[i * 4 + 3]);
783 GST_WRITE_UINT16_LE (d + i * 4 + 6, s[i * 4 + 1]);
787 #define PACK_Y210 GST_VIDEO_FORMAT_AYUV64, unpack_Y210, 1, pack_Y210
789 unpack_Y210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
790 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
791 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
794 const guint8 *restrict s = GET_LINE (y);
795 guint16 *restrict d = dest;
798 s += GST_ROUND_DOWN_2 (x) * 4;
801 Y1 = GST_READ_UINT16_LE (s + 4);
802 U = GST_READ_UINT16_LE (s + 2);
803 V = GST_READ_UINT16_LE (s + 6);
805 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
820 for (i = 0; i < width / 2; i++) {
821 Y0 = GST_READ_UINT16_LE (s + i * 8 + 0);
822 U = GST_READ_UINT16_LE (s + i * 8 + 2);
823 V = GST_READ_UINT16_LE (s + i * 8 + 6);
824 Y1 = GST_READ_UINT16_LE (s + i * 8 + 4);
826 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
832 d[i * 8 + 0] = 0xffff;
837 d[i * 8 + 4] = 0xffff;
846 Y0 = GST_READ_UINT16_LE (s + i * 4 + 0);
847 U = GST_READ_UINT16_LE (s + i * 4 + 2);
848 V = GST_READ_UINT16_LE (s + i * 4 + 6);
850 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
856 d[i * 4 + 0] = 0xffff;
864 pack_Y210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
865 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
866 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
870 guint16 Y0, Y1, U, V;
871 guint8 *restrict d = GET_LINE (y);
872 const guint16 *restrict s = src;
874 for (i = 0; i < width; i += 2) {
875 Y0 = s[i * 4 + 1] & 0xffc0;
876 U = s[i * 4 + 2] & 0xffc0;
877 V = s[i * 4 + 3] & 0xffc0;
879 Y1 = s[i * 4 + 1] & 0xffc0;
881 Y1 = s[(i + 1) * 4 + 1] & 0xffc0;
883 GST_WRITE_UINT16_LE (d + i * 4 + 0, Y0);
884 GST_WRITE_UINT16_LE (d + i * 4 + 2, U);
885 GST_WRITE_UINT16_LE (d + i * 4 + 4, Y1);
886 GST_WRITE_UINT16_LE (d + i * 4 + 6, V);
890 #define PACK_Y410 GST_VIDEO_FORMAT_AYUV64, unpack_Y410, 1, pack_Y410
892 unpack_Y410 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
893 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
894 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
897 const guint8 *restrict s = GET_LINE (y);
898 guint16 *restrict d = dest;
904 for (i = 0; i < width; i++) {
905 AVYU = GST_READ_UINT32_LE (s + 4 * i);
907 U = ((AVYU >> 0) & 0x3ff) << 6;
908 Y = ((AVYU >> 10) & 0x3ff) << 6;
909 V = ((AVYU >> 20) & 0x3ff) << 6;
910 A = ((AVYU >> 30) & 0x03) << 14;
912 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
927 pack_Y410 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
928 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
929 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
933 guint32 *restrict d = GET_LINE (y);
934 const guint16 *restrict s = src;
938 for (i = 0; i < width; i++) {
939 A = s[4 * i] & 0xc000;
940 Y = s[4 * i + 1] & 0xffc0;
941 U = s[4 * i + 2] & 0xffc0;
942 V = s[4 * i + 3] & 0xffc0;
944 AVYU = (U >> 6) | (Y << 4) | (V << 14) | (A << 16);
946 GST_WRITE_UINT32_LE (d + i, AVYU);
950 #define PACK_Y41B GST_VIDEO_FORMAT_AYUV, unpack_Y41B, 1, pack_Y41B
952 unpack_Y41B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
953 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
954 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
956 const guint8 *restrict sy = GET_Y_LINE (y);
957 const guint8 *restrict su = GET_U_LINE (y);
958 const guint8 *restrict sv = GET_V_LINE (y);
959 guint8 *restrict d = dest;
978 if (IS_ALIGNED (d, 8))
979 video_orc_unpack_YUV9 (d, sy, su, sv, width / 2);
982 for (i = 0; i < width / 2; i++) {
984 d[i * 8 + 1] = sy[i * 2 + 0];
985 d[i * 8 + 2] = su[i >> 1];
986 d[i * 8 + 3] = sv[i >> 1];
988 d[i * 8 + 5] = sy[i * 2 + 1];
989 d[i * 8 + 6] = su[i >> 1];
990 d[i * 8 + 7] = sv[i >> 1];
998 d[i * 4 + 1] = sy[i];
999 d[i * 4 + 2] = su[i >> 2];
1000 d[i * 4 + 3] = sv[i >> 2];
1005 pack_Y41B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1006 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1007 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1011 guint8 *restrict dy = GET_Y_LINE (y);
1012 guint8 *restrict du = GET_U_LINE (y);
1013 guint8 *restrict dv = GET_V_LINE (y);
1014 const guint8 *restrict s = src;
1016 for (i = 0; i < width - 3; i += 4) {
1017 dy[i] = s[i * 4 + 1];
1018 dy[i + 1] = s[i * 4 + 5];
1019 dy[i + 2] = s[i * 4 + 9];
1020 dy[i + 3] = s[i * 4 + 13];
1022 du[i >> 2] = s[i * 4 + 2];
1023 dv[i >> 2] = s[i * 4 + 3];
1026 dy[i] = s[i * 4 + 1];
1027 du[i >> 2] = s[i * 4 + 2];
1028 dv[i >> 2] = s[i * 4 + 3];
1030 dy[i + 1] = s[i * 4 + 5];
1032 dy[i + 2] = s[i * 4 + 9];
1036 #define PACK_Y42B GST_VIDEO_FORMAT_AYUV, unpack_Y42B, 1, pack_Y42B
1038 unpack_Y42B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1039 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1040 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1042 const guint8 *restrict sy = GET_Y_LINE (y);
1043 const guint8 *restrict su = GET_U_LINE (y);
1044 const guint8 *restrict sv = GET_V_LINE (y);
1045 guint8 *restrict d = dest;
1060 if (IS_ALIGNED (d, 8))
1061 video_orc_unpack_Y42B (d, sy, su, sv, width / 2);
1064 for (i = 0; i < width / 2; i++) {
1065 d[i * 8 + 0] = 0xff;
1066 d[i * 8 + 1] = sy[i * 2 + 0];
1067 d[i * 8 + 2] = su[i];
1068 d[i * 8 + 3] = sv[i];
1069 d[i * 8 + 4] = 0xff;
1070 d[i * 8 + 5] = sy[i * 2 + 1];
1071 d[i * 8 + 6] = su[i];
1072 d[i * 8 + 7] = sv[i];
1079 d[i * 4 + 0] = 0xff;
1080 d[i * 4 + 1] = sy[i];
1081 d[i * 4 + 2] = su[i >> 1];
1082 d[i * 4 + 3] = sv[i >> 1];
1087 pack_Y42B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1088 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1089 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1092 guint8 *restrict dy = GET_Y_LINE (y);
1093 guint8 *restrict du = GET_U_LINE (y);
1094 guint8 *restrict dv = GET_V_LINE (y);
1095 const guint8 *restrict s = src;
1097 if (IS_ALIGNED (s, 8))
1098 video_orc_pack_Y42B (dy, du, dv, s, width / 2);
1101 for (i = 0; i < width / 2; i++) {
1102 dy[i * 2 + 0] = s[i * 8 + 1];
1103 dy[i * 2 + 1] = s[i * 8 + 5];
1104 du[i] = s[i * 8 + 2];
1105 dv[i] = s[i * 8 + 3];
1112 dy[i] = s[i * 4 + 1];
1113 du[i >> 1] = s[i * 4 + 2];
1114 dv[i >> 1] = s[i * 4 + 3];
1118 #define PACK_Y444 GST_VIDEO_FORMAT_AYUV, unpack_Y444, 1, pack_Y444
1120 unpack_Y444 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1121 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1122 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1124 const guint8 *restrict sy = GET_Y_LINE (y);
1125 const guint8 *restrict su = GET_U_LINE (y);
1126 const guint8 *restrict sv = GET_V_LINE (y);
1132 video_orc_unpack_Y444 (dest, sy, su, sv, width);
1136 pack_Y444 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1137 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1138 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1141 guint8 *restrict dy = GET_Y_LINE (y);
1142 guint8 *restrict du = GET_U_LINE (y);
1143 guint8 *restrict dv = GET_V_LINE (y);
1145 video_orc_pack_Y444 (dy, du, dv, src, width);
1148 #define PACK_GBR GST_VIDEO_FORMAT_ARGB, unpack_GBR, 1, pack_GBR
1150 unpack_GBR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1151 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1152 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1154 const guint8 *restrict sr = GET_R_LINE (y);
1155 const guint8 *restrict sg = GET_G_LINE (y);
1156 const guint8 *restrict sb = GET_B_LINE (y);
1162 video_orc_unpack_Y444 (dest, sr, sg, sb, width);
1166 pack_GBR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1167 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1168 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1171 guint8 *restrict dr = GET_R_LINE (y);
1172 guint8 *restrict dg = GET_G_LINE (y);
1173 guint8 *restrict db = GET_B_LINE (y);
1175 video_orc_pack_Y444 (dr, dg, db, src, width);
1178 #define PACK_GBRA GST_VIDEO_FORMAT_ARGB, unpack_GBRA, 1, pack_GBRA
1180 unpack_GBRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1181 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1182 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1185 const guint8 *sg = GET_G_LINE (y);
1186 const guint8 *sb = GET_B_LINE (y);
1187 const guint8 *sr = GET_R_LINE (y);
1188 const guint8 *sa = GET_A_LINE (y);
1189 guint8 *d = dest, G, B, R, A;
1196 for (i = 0; i < width; i++) {
1197 G = GST_READ_UINT8 (sg + i);
1198 B = GST_READ_UINT8 (sb + i);
1199 R = GST_READ_UINT8 (sr + i);
1200 A = GST_READ_UINT8 (sa + i);
1210 pack_GBRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1211 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1212 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1216 guint8 *restrict dg = GET_G_LINE (y);
1217 guint8 *restrict db = GET_B_LINE (y);
1218 guint8 *restrict dr = GET_R_LINE (y);
1219 guint8 *restrict da = GET_A_LINE (y);
1221 const guint8 *restrict s = src;
1223 for (i = 0; i < width; i++) {
1229 GST_WRITE_UINT8 (dg + i, G);
1230 GST_WRITE_UINT8 (db + i, B);
1231 GST_WRITE_UINT8 (dr + i, R);
1232 GST_WRITE_UINT8 (da + i, A);
1236 #define PACK_GRAY8 GST_VIDEO_FORMAT_AYUV, unpack_GRAY8, 1, pack_GRAY8
1238 unpack_GRAY8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1239 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1240 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1242 const guint8 *restrict s = GET_LINE (y);
1246 video_orc_unpack_GRAY8 (dest, s, width);
1250 pack_GRAY8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1251 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1252 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1255 guint8 *restrict d = GET_LINE (y);
1257 video_orc_pack_GRAY8 (d, src, width);
1260 #define PACK_GRAY16_BE GST_VIDEO_FORMAT_AYUV64, unpack_GRAY16_BE, 1, pack_GRAY16_BE
1262 unpack_GRAY16_BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1263 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1264 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1267 const guint16 *restrict s = GET_LINE (y);
1268 guint16 *restrict d = dest;
1272 for (i = 0; i < width; i++) {
1273 d[i * 4 + 0] = 0xffff;
1274 d[i * 4 + 1] = GST_READ_UINT16_BE (s + i);
1275 d[i * 4 + 2] = 0x8000;
1276 d[i * 4 + 3] = 0x8000;
1281 pack_GRAY16_BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1282 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1283 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1287 guint16 *restrict d = GET_LINE (y);
1288 const guint16 *restrict s = src;
1290 for (i = 0; i < width; i++) {
1291 GST_WRITE_UINT16_BE (d + i, s[i * 4 + 1]);
1295 #define PACK_GRAY16_LE GST_VIDEO_FORMAT_AYUV64, unpack_GRAY16_LE, 1, pack_GRAY16_LE
1297 unpack_GRAY16_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1298 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1299 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1302 const guint16 *restrict s = GET_LINE (y);
1303 guint16 *restrict d = dest;
1307 for (i = 0; i < width; i++) {
1308 d[i * 4 + 0] = 0xffff;
1309 d[i * 4 + 1] = GST_READ_UINT16_LE (s + i);
1310 d[i * 4 + 2] = 0x8000;
1311 d[i * 4 + 3] = 0x8000;
1316 pack_GRAY16_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1317 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1318 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1322 guint16 *restrict d = GET_LINE (y);
1323 const guint16 *restrict s = src;
1325 for (i = 0; i < width; i++) {
1326 GST_WRITE_UINT16_LE (d + i, s[i * 4 + 1]);
1330 #define PACK_RGB16 GST_VIDEO_FORMAT_ARGB, unpack_RGB16, 1, pack_RGB16
1332 unpack_RGB16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1333 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1334 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1336 const guint16 *restrict s = GET_LINE (y);
1338 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1339 video_orc_unpack_RGB16_trunc (dest, s + x, width);
1341 video_orc_unpack_RGB16 (dest, s + x, width);
1345 pack_RGB16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1346 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1347 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1350 guint16 *restrict d = GET_LINE (y);
1352 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1353 video_orc_pack_RGB16_le (d, src, width);
1355 video_orc_pack_RGB16_be (d, src, width);
1359 #define PACK_BGR16 GST_VIDEO_FORMAT_ARGB, unpack_BGR16, 1, pack_BGR16
1361 unpack_BGR16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1362 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1363 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1365 const guint16 *restrict s = GET_LINE (y);
1367 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1368 video_orc_unpack_BGR16_trunc (dest, s + x, width);
1370 video_orc_unpack_BGR16 (dest, s + x, width);
1374 pack_BGR16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1375 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1376 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1379 guint16 *restrict d = GET_LINE (y);
1381 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1382 video_orc_pack_BGR16_le (d, src, width);
1384 video_orc_pack_BGR16_be (d, src, width);
1388 #define PACK_RGB15 GST_VIDEO_FORMAT_ARGB, unpack_RGB15, 1, pack_RGB15
1390 unpack_RGB15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1391 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1392 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1394 const guint16 *restrict s = GET_LINE (y);
1396 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1397 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1398 video_orc_unpack_RGB15_le_trunc (dest, s + x, width);
1400 video_orc_unpack_RGB15_le (dest, s + x, width);
1402 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1403 video_orc_unpack_RGB15_be_trunc (dest, s + x, width);
1405 video_orc_unpack_RGB15_be (dest, s + x, width);
1410 pack_RGB15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1411 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1412 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1415 guint16 *restrict d = GET_LINE (y);
1417 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1418 video_orc_pack_RGB15_le (d, src, width);
1420 video_orc_pack_RGB15_be (d, src, width);
1424 #define PACK_BGR15 GST_VIDEO_FORMAT_ARGB, unpack_BGR15, 1, pack_BGR15
1426 unpack_BGR15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1427 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1428 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1430 const guint16 *restrict s = GET_LINE (y);
1432 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1433 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1434 video_orc_unpack_BGR15_le_trunc (dest, s + x, width);
1436 video_orc_unpack_BGR15_le (dest, s + x, width);
1438 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1439 video_orc_unpack_BGR15_be_trunc (dest, s + x, width);
1441 video_orc_unpack_BGR15_be (dest, s + x, width);
1446 pack_BGR15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1447 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1448 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1451 guint16 *restrict d = GET_LINE (y);
1453 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1454 video_orc_pack_BGR15_le (d, src, width);
1456 video_orc_pack_BGR15_be (d, src, width);
1460 #define PACK_BGRA GST_VIDEO_FORMAT_ARGB, unpack_BGRA, 1, pack_BGRA
1462 unpack_BGRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1463 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1464 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1466 const guint8 *restrict s = GET_LINE (y);
1470 video_orc_unpack_BGRA (dest, s, width);
1474 pack_BGRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1475 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1476 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1479 guint8 *restrict d = GET_LINE (y);
1481 video_orc_pack_BGRA (d, src, width);
1484 #define PACK_ABGR GST_VIDEO_FORMAT_ARGB, unpack_ABGR, 1, pack_ABGR
1486 unpack_ABGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1487 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1488 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1490 const guint8 *restrict s = GET_LINE (y);
1494 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1495 video_orc_unpack_ABGR_le (dest, s, width);
1497 video_orc_unpack_ABGR_be (dest, s, width);
1502 pack_ABGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1503 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1504 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1507 guint8 *restrict d = GET_LINE (y);
1509 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1510 video_orc_pack_ABGR_le (d, src, width);
1512 video_orc_pack_ABGR_be (d, src, width);
1516 #define PACK_RGBA GST_VIDEO_FORMAT_ARGB, unpack_RGBA, 1, pack_RGBA
1518 unpack_RGBA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1519 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1520 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1522 const guint8 *restrict s = GET_LINE (y);
1526 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1527 video_orc_unpack_RGBA_le (dest, s, width);
1529 video_orc_unpack_RGBA_be (dest, s, width);
1534 pack_RGBA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1535 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1536 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1539 guint8 *restrict d = GET_LINE (y);
1541 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1542 video_orc_pack_RGBA_le (d, src, width);
1544 video_orc_pack_RGBA_be (d, src, width);
1548 #define PACK_RGB GST_VIDEO_FORMAT_ARGB, unpack_RGB, 1, pack_RGB
1550 unpack_RGB (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1551 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1552 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1555 const guint8 *restrict s = GET_LINE (y);
1556 guint8 *restrict d = dest;
1560 for (i = 0; i < width; i++) {
1561 d[i * 4 + 0] = 0xff;
1562 d[i * 4 + 1] = s[i * 3 + 0];
1563 d[i * 4 + 2] = s[i * 3 + 1];
1564 d[i * 4 + 3] = s[i * 3 + 2];
1569 pack_RGB (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1570 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1571 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1575 guint8 *restrict d = GET_LINE (y);
1576 const guint8 *restrict s = src;
1578 for (i = 0; i < width; i++) {
1579 d[i * 3 + 0] = s[i * 4 + 1];
1580 d[i * 3 + 1] = s[i * 4 + 2];
1581 d[i * 3 + 2] = s[i * 4 + 3];
1585 #define PACK_BGR GST_VIDEO_FORMAT_ARGB, unpack_BGR, 1, pack_BGR
1587 unpack_BGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1588 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1589 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1592 const guint8 *restrict s = GET_LINE (y);
1593 guint8 *restrict d = dest;
1597 for (i = 0; i < width; i++) {
1598 d[i * 4 + 0] = 0xff;
1599 d[i * 4 + 1] = s[i * 3 + 2];
1600 d[i * 4 + 2] = s[i * 3 + 1];
1601 d[i * 4 + 3] = s[i * 3 + 0];
1606 pack_BGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1607 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1608 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1612 guint8 *restrict d = GET_LINE (y);
1613 const guint8 *restrict s = src;
1615 for (i = 0; i < width; i++) {
1616 d[i * 3 + 0] = s[i * 4 + 3];
1617 d[i * 3 + 1] = s[i * 4 + 2];
1618 d[i * 3 + 2] = s[i * 4 + 1];
1622 #define PACK_NV12 GST_VIDEO_FORMAT_AYUV, unpack_NV12, 1, pack_NV12
1624 unpack_NV12 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1625 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1626 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1628 gint uv = GET_UV_420 (y, flags);
1629 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1630 const guint8 *restrict suv = GET_PLANE_LINE (1, uv);
1631 guint8 *restrict d = dest;
1646 if (IS_ALIGNED (d, 8))
1647 video_orc_unpack_NV12 (d, sy, suv, width / 2);
1650 for (i = 0; i < width / 2; i++) {
1651 d[i * 8 + 0] = 0xff;
1652 d[i * 8 + 1] = sy[i * 2 + 0];
1653 d[i * 8 + 2] = suv[i * 2 + 0];
1654 d[i * 8 + 3] = suv[i * 2 + 1];
1655 d[i * 8 + 4] = 0xff;
1656 d[i * 8 + 5] = sy[i * 2 + 1];
1657 d[i * 8 + 6] = suv[i * 2 + 0];
1658 d[i * 8 + 7] = suv[i * 2 + 1];
1665 d[i * 4 + 0] = 0xff;
1666 d[i * 4 + 1] = sy[i];
1667 d[i * 4 + 2] = suv[i + 0];
1668 d[i * 4 + 3] = suv[i + 1];
1673 pack_NV12 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1674 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1675 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1678 gint uv = GET_UV_420 (y, flags);
1679 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1680 guint8 *restrict duv = GET_PLANE_LINE (1, uv);
1681 const guint8 *restrict s = src;
1683 if (IS_CHROMA_LINE_420 (y, flags)) {
1684 if (IS_ALIGNED (s, 8))
1685 video_orc_pack_NV12 (dy, duv, s, width / 2);
1688 for (i = 0; i < width / 2; i++) {
1689 dy[i * 2 + 0] = s[i * 8 + 1];
1690 dy[i * 2 + 1] = s[i * 8 + 5];
1691 duv[i * 2 + 0] = s[i * 8 + 2];
1692 duv[i * 2 + 1] = s[i * 8 + 3];
1698 dy[i] = s[i * 4 + 1];
1699 duv[i + 0] = s[i * 4 + 2];
1700 duv[i + 1] = s[i * 4 + 3];
1703 video_orc_pack_Y (dy, s, width);
1706 #define PACK_NV21 GST_VIDEO_FORMAT_AYUV, unpack_NV21, 1, pack_NV21
1708 unpack_NV21 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1709 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1710 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1712 gint uv = GET_UV_420 (y, flags);
1713 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1714 const guint8 *restrict suv = GET_PLANE_LINE (1, uv);
1715 guint8 *restrict d = dest;
1730 if (IS_ALIGNED (d, 8))
1731 video_orc_unpack_NV21 (d, sy, suv, width / 2);
1734 for (i = 0; i < width / 2; i++) {
1735 d[i * 8 + 0] = 0xff;
1736 d[i * 8 + 1] = sy[i * 2 + 0];
1737 d[i * 8 + 2] = suv[i * 2 + 1];
1738 d[i * 8 + 3] = suv[i * 2 + 0];
1739 d[i * 8 + 4] = 0xff;
1740 d[i * 8 + 5] = sy[i * 2 + 1];
1741 d[i * 8 + 6] = suv[i * 2 + 1];
1742 d[i * 8 + 7] = suv[i * 2 + 0];
1749 d[i * 4 + 0] = 0xff;
1750 d[i * 4 + 1] = sy[i];
1751 d[i * 4 + 2] = suv[i + 1];
1752 d[i * 4 + 3] = suv[i + 0];
1757 pack_NV21 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1758 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1759 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1762 gint uv = GET_UV_420 (y, flags);
1763 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1764 guint8 *restrict duv = GET_PLANE_LINE (1, uv);
1765 const guint8 *restrict s = src;
1767 if (IS_CHROMA_LINE_420 (y, flags)) {
1768 if (IS_ALIGNED (s, 8))
1769 video_orc_pack_NV21 (dy, duv, s, width / 2);
1772 for (i = 0; i < width / 2; i++) {
1773 dy[i * 2 + 0] = s[i * 8 + 1];
1774 dy[i * 2 + 1] = s[i * 8 + 5];
1775 duv[i * 2 + 0] = s[i * 8 + 3];
1776 duv[i * 2 + 1] = s[i * 8 + 2];
1782 dy[i] = s[i * 4 + 1];
1783 duv[i + 0] = s[i * 4 + 3];
1784 duv[i + 1] = s[i * 4 + 2];
1787 video_orc_pack_Y (dy, s, width);
1790 #define PACK_NV16 GST_VIDEO_FORMAT_AYUV, unpack_NV16, 1, pack_NV16
1792 unpack_NV16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1793 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1794 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1796 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1797 const guint8 *restrict suv = GET_PLANE_LINE (1, y);
1798 guint8 *restrict d = dest;
1813 if (IS_ALIGNED (d, 8))
1814 video_orc_unpack_NV12 (d, sy, suv, width / 2);
1817 for (i = 0; i < width / 2; i++) {
1818 d[i * 8 + 0] = 0xff;
1819 d[i * 8 + 1] = sy[i * 2 + 0];
1820 d[i * 8 + 2] = suv[i * 2 + 0];
1821 d[i * 8 + 3] = suv[i * 2 + 1];
1822 d[i * 8 + 4] = 0xff;
1823 d[i * 8 + 5] = sy[i * 2 + 1];
1824 d[i * 8 + 6] = suv[i * 2 + 0];
1825 d[i * 8 + 7] = suv[i * 2 + 1];
1832 d[i * 4 + 0] = 0xff;
1833 d[i * 4 + 1] = sy[i];
1834 d[i * 4 + 2] = suv[i + 0];
1835 d[i * 4 + 3] = suv[i + 1];
1840 pack_NV16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1841 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1842 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1845 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1846 guint8 *restrict duv = GET_PLANE_LINE (1, y);
1847 const guint8 *restrict s = src;
1849 if (IS_ALIGNED (s, 8))
1850 video_orc_pack_NV12 (dy, duv, s, width / 2);
1853 for (i = 0; i < width / 2; i++) {
1854 dy[i * 2 + 0] = s[i * 8 + 1];
1855 dy[i * 2 + 1] = s[i * 8 + 5];
1856 duv[i * 2 + 0] = s[i * 8 + 2];
1857 duv[i * 2 + 1] = s[i * 8 + 3];
1864 dy[i] = s[i * 4 + 1];
1865 duv[i + 0] = s[i * 4 + 2];
1866 duv[i + 1] = s[i * 4 + 3];
1870 #define PACK_NV61 GST_VIDEO_FORMAT_AYUV, unpack_NV61, 1, pack_NV61
1872 unpack_NV61 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1873 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1874 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1876 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1877 const guint8 *restrict svu = GET_PLANE_LINE (1, y);
1878 guint8 *restrict d = dest;
1893 if (IS_ALIGNED (d, 8)) {
1894 video_orc_unpack_NV21 (d, sy, svu, width / 2);
1898 for (i = 0; i < width / 2; i++) {
1899 d[i * 8 + 0] = 0xff;
1900 d[i * 8 + 1] = sy[i * 2 + 0];
1901 d[i * 8 + 2] = svu[i * 2 + 1];
1902 d[i * 8 + 3] = svu[i * 2 + 0];
1903 d[i * 8 + 4] = 0xff;
1904 d[i * 8 + 5] = sy[i * 2 + 1];
1905 d[i * 8 + 6] = svu[i * 2 + 1];
1906 d[i * 8 + 7] = svu[i * 2 + 0];
1913 d[i * 4 + 0] = 0xff;
1914 d[i * 4 + 1] = sy[i];
1915 d[i * 4 + 2] = svu[i + 1];
1916 d[i * 4 + 3] = svu[i + 0];
1921 pack_NV61 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1922 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1923 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1926 const guint8 *restrict s = src;
1927 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1928 guint8 *restrict dvu = GET_PLANE_LINE (1, y);
1930 if (IS_ALIGNED (s, 8)) {
1931 video_orc_pack_NV21 (dy, dvu, s, width / 2);
1935 for (i = 0; i < width / 2; i++) {
1936 dy[i * 2 + 0] = s[i * 8 + 1];
1937 dy[i * 2 + 1] = s[i * 8 + 5];
1938 dvu[i * 2 + 0] = s[i * 8 + 3];
1939 dvu[i * 2 + 1] = s[i * 8 + 2];
1946 dy[i] = s[i * 4 + 1];
1947 dvu[i + 0] = s[i * 4 + 2];
1948 dvu[i + 1] = s[i * 4 + 3];
1952 #define PACK_NV24 GST_VIDEO_FORMAT_AYUV, unpack_NV24, 1, pack_NV24
1954 unpack_NV24 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1955 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1956 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1958 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1959 const guint8 *restrict suv = GET_PLANE_LINE (1, y);
1964 video_orc_unpack_NV24 (dest, sy, suv, width);
1968 pack_NV24 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1969 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1970 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1973 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1974 guint8 *restrict duv = GET_PLANE_LINE (1, y);
1976 video_orc_pack_NV24 (dy, duv, src, width);
1979 #define PACK_UYVP GST_VIDEO_FORMAT_AYUV64, unpack_UYVP, 1, pack_UYVP
1981 unpack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1982 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1983 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1986 const guint8 *restrict s = GET_LINE (y);
1987 guint16 *restrict d = dest;
1992 for (i = 0; i < width; i += 2) {
1997 u0 = ((s[(i / 2) * 5 + 0] << 2) | (s[(i / 2) * 5 + 1] >> 6)) << 6;
1998 y0 = (((s[(i / 2) * 5 + 1] & 0x3f) << 4) | (s[(i / 2) * 5 + 2] >> 4)) << 6;
1999 v0 = (((s[(i / 2) * 5 + 2] & 0x0f) << 6) | (s[(i / 2) * 5 + 3] >> 2)) << 6;
2000 y1 = (((s[(i / 2) * 5 + 3] & 0x03) << 8) | s[(i / 2) * 5 + 4]) << 6;
2002 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2009 d[i * 4 + 0] = 0xffff;
2014 if (i < width - 1) {
2015 d[i * 4 + 4] = 0xffff;
2024 pack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2025 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2026 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2030 guint8 *restrict d = GET_LINE (y);
2031 const guint16 *restrict s = src;
2033 for (i = 0; i < width; i += 2) {
2038 y0 = s[4 * (i + 0) + 1];
2040 y1 = s[4 * (i + 1) + 1];
2044 u0 = s[4 * (i + 0) + 2];
2045 v0 = s[4 * (i + 0) + 3];
2047 d[(i / 2) * 5 + 0] = u0 >> 8;
2048 d[(i / 2) * 5 + 1] = (u0 & 0xc0) | y0 >> 10;
2049 d[(i / 2) * 5 + 2] = ((y0 & 0x3c0) >> 2) | (v0 >> 12);
2050 d[(i / 2) * 5 + 3] = ((v0 & 0xfc0) >> 4) | (y1 >> 14);
2051 d[(i / 2) * 5 + 4] = (y1 >> 6);
2055 #define PACK_A420 GST_VIDEO_FORMAT_AYUV, unpack_A420, 1, pack_A420
2057 unpack_A420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2058 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2059 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2061 gint uv = GET_UV_420 (y, flags);
2062 const guint8 *restrict sy = GET_Y_LINE (y);
2063 const guint8 *restrict su = GET_U_LINE (uv);
2064 const guint8 *restrict sv = GET_V_LINE (uv);
2065 const guint8 *restrict sa = GET_A_LINE (y);
2066 guint8 *restrict d = dest;
2081 video_orc_unpack_A420 (d, sy, su, sv, sa, width);
2085 pack_A420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2086 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2087 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2090 gint uv = GET_UV_420 (y, flags);
2091 guint8 *restrict dy = GET_Y_LINE (y);
2092 guint8 *restrict du = GET_U_LINE (uv);
2093 guint8 *restrict dv = GET_V_LINE (uv);
2094 guint8 *restrict da = GET_A_LINE (y);
2095 const guint8 *restrict s = src;
2097 if (IS_CHROMA_LINE_420 (y, flags)) {
2098 if (IS_ALIGNED (s, 8))
2099 video_orc_pack_A420 (dy, du, dv, da, s, width / 2);
2102 for (i = 0; i < width / 2; i++) {
2103 da[i * 2 + 0] = s[i * 8 + 0];
2104 dy[i * 2 + 0] = s[i * 8 + 1];
2105 da[i * 2 + 1] = s[i * 8 + 4];
2106 dy[i * 2 + 1] = s[i * 8 + 5];
2107 du[i] = s[i * 8 + 2];
2108 dv[i] = s[i * 8 + 3];
2115 da[i] = s[i * 4 + 0];
2116 dy[i] = s[i * 4 + 1];
2117 du[i >> 1] = s[i * 4 + 2];
2118 dv[i >> 1] = s[i * 4 + 3];
2121 video_orc_pack_AY (dy, da, s, width);
2124 #define PACK_RGB8P GST_VIDEO_FORMAT_ARGB, unpack_RGB8P, 1, pack_RGB8P
2126 unpack_RGB8P (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2127 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2128 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2131 const guint8 *restrict s = GET_LINE (y);
2132 const guint32 *restrict p = data[1];
2133 guint8 *restrict d = dest;
2137 for (i = 0; i < width; i++) {
2138 guint32 v = p[s[i]];
2139 d[i * 4 + 0] = (v >> 24) & 0xff;
2140 d[i * 4 + 1] = (v >> 16) & 0xff;
2141 d[i * 4 + 2] = (v >> 8) & 0xff;
2142 d[i * 4 + 3] = (v) & 0xff;
2146 static const guint32 std_palette_RGB8P[] = {
2147 0xff000000, 0xff000033, 0xff000066, 0xff000099, 0xff0000cc, 0xff0000ff,
2148 0xff003300, 0xff003333, 0xff003366, 0xff003399, 0xff0033cc, 0xff0033ff,
2149 0xff006600, 0xff006633, 0xff006666, 0xff006699, 0xff0066cc, 0xff0066ff,
2150 0xff009900, 0xff009933, 0xff009966, 0xff009999, 0xff0099cc, 0xff0099ff,
2151 0xff00cc00, 0xff00cc33, 0xff00cc66, 0xff00cc99, 0xff00cccc, 0xff00ccff,
2152 0xff00ff00, 0xff00ff33, 0xff00ff66, 0xff00ff99, 0xff00ffcc, 0xff00ffff,
2153 0xff330000, 0xff330033, 0xff330066, 0xff330099, 0xff3300cc, 0xff3300ff,
2154 0xff333300, 0xff333333, 0xff333366, 0xff333399, 0xff3333cc, 0xff3333ff,
2155 0xff336600, 0xff336633, 0xff336666, 0xff336699, 0xff3366cc, 0xff3366ff,
2156 0xff339900, 0xff339933, 0xff339966, 0xff339999, 0xff3399cc, 0xff3399ff,
2157 0xff33cc00, 0xff33cc33, 0xff33cc66, 0xff33cc99, 0xff33cccc, 0xff33ccff,
2158 0xff33ff00, 0xff33ff33, 0xff33ff66, 0xff33ff99, 0xff33ffcc, 0xff33ffff,
2159 0xff660000, 0xff660033, 0xff660066, 0xff660099, 0xff6600cc, 0xff6600ff,
2160 0xff663300, 0xff663333, 0xff663366, 0xff663399, 0xff6633cc, 0xff6633ff,
2161 0xff666600, 0xff666633, 0xff666666, 0xff666699, 0xff6666cc, 0xff6666ff,
2162 0xff669900, 0xff669933, 0xff669966, 0xff669999, 0xff6699cc, 0xff6699ff,
2163 0xff66cc00, 0xff66cc33, 0xff66cc66, 0xff66cc99, 0xff66cccc, 0xff66ccff,
2164 0xff66ff00, 0xff66ff33, 0xff66ff66, 0xff66ff99, 0xff66ffcc, 0xff66ffff,
2165 0xff990000, 0xff990033, 0xff990066, 0xff990099, 0xff9900cc, 0xff9900ff,
2166 0xff993300, 0xff993333, 0xff993366, 0xff993399, 0xff9933cc, 0xff9933ff,
2167 0xff996600, 0xff996633, 0xff996666, 0xff996699, 0xff9966cc, 0xff9966ff,
2168 0xff999900, 0xff999933, 0xff999966, 0xff999999, 0xff9999cc, 0xff9999ff,
2169 0xff99cc00, 0xff99cc33, 0xff99cc66, 0xff99cc99, 0xff99cccc, 0xff99ccff,
2170 0xff99ff00, 0xff99ff33, 0xff99ff66, 0xff99ff99, 0xff99ffcc, 0xff99ffff,
2171 0xffcc0000, 0xffcc0033, 0xffcc0066, 0xffcc0099, 0xffcc00cc, 0xffcc00ff,
2172 0xffcc3300, 0xffcc3333, 0xffcc3366, 0xffcc3399, 0xffcc33cc, 0xffcc33ff,
2173 0xffcc6600, 0xffcc6633, 0xffcc6666, 0xffcc6699, 0xffcc66cc, 0xffcc66ff,
2174 0xffcc9900, 0xffcc9933, 0xffcc9966, 0xffcc9999, 0xffcc99cc, 0xffcc99ff,
2175 0xffcccc00, 0xffcccc33, 0xffcccc66, 0xffcccc99, 0xffcccccc, 0xffccccff,
2176 0xffccff00, 0xffccff33, 0xffccff66, 0xffccff99, 0xffccffcc, 0xffccffff,
2177 0xffff0000, 0xffff0033, 0xffff0066, 0xffff0099, 0xffff00cc, 0xffff00ff,
2178 0xffff3300, 0xffff3333, 0xffff3366, 0xffff3399, 0xffff33cc, 0xffff33ff,
2179 0xffff6600, 0xffff6633, 0xffff6666, 0xffff6699, 0xffff66cc, 0xffff66ff,
2180 0xffff9900, 0xffff9933, 0xffff9966, 0xffff9999, 0xffff99cc, 0xffff99ff,
2181 0xffffcc00, 0xffffcc33, 0xffffcc66, 0xffffcc99, 0xffffcccc, 0xffffccff,
2182 0xffffff00, 0xffffff33, 0xffffff66, 0xffffff99, 0xffffffcc, 0xffffffff,
2183 0x00000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2184 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2185 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2186 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2187 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2188 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2189 0xff000000, 0xff000000, 0xff000000, 0xff000000
2193 pack_RGB8P (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2194 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2195 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2199 guint8 *restrict d = GET_LINE (y);
2200 const guint8 *restrict s = src;
2202 /* Use our poor man's palette, taken from ffmpegcolorspace too */
2203 for (i = 0; i < width; i++) {
2204 /* crude approximation for alpha ! */
2205 if (s[i * 4 + 0] < 0x80)
2209 ((((s[i * 4 + 1]) / 47) % 6) * 6 * 6 + (((s[i * 4 +
2210 2]) / 47) % 6) * 6 + (((s[i * 4 + 3]) / 47) % 6));
2214 #define PACK_410 GST_VIDEO_FORMAT_AYUV, unpack_410, 1, pack_410
2216 unpack_410 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2217 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2218 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2220 gint uv = GET_UV_410 (y, flags);
2221 const guint8 *restrict sy = GET_Y_LINE (y);
2222 const guint8 *restrict su = GET_U_LINE (uv);
2223 const guint8 *restrict sv = GET_V_LINE (uv);
2224 guint8 *restrict d = dest;
2231 for (; x & 3; x++) {
2243 if (IS_ALIGNED (d, 8))
2244 video_orc_unpack_YUV9 (d, sy, su, sv, width / 2);
2247 for (i = 0; i < width / 2; i++) {
2248 d[i * 8 + 0] = 0xff;
2249 d[i * 8 + 1] = sy[i * 2 + 0];
2250 d[i * 8 + 2] = su[i >> 1];
2251 d[i * 8 + 3] = sv[i >> 1];
2252 d[i * 8 + 4] = 0xff;
2253 d[i * 8 + 5] = sy[i * 2 + 1];
2254 d[i * 8 + 6] = su[i >> 1];
2255 d[i * 8 + 7] = sv[i >> 1];
2262 d[i * 4 + 0] = 0xff;
2263 d[i * 4 + 1] = sy[i];
2264 d[i * 4 + 2] = su[i >> 2];
2265 d[i * 4 + 3] = sv[i >> 2];
2270 pack_410 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2271 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2272 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2276 gint uv = GET_UV_410 (y, flags);
2277 guint8 *restrict dy = GET_Y_LINE (y);
2278 guint8 *restrict du = GET_U_LINE (uv);
2279 guint8 *restrict dv = GET_V_LINE (uv);
2280 const guint8 *restrict s = src;
2282 for (i = 0; i < width - 3; i += 4) {
2283 dy[i] = s[i * 4 + 1];
2284 dy[i + 1] = s[i * 4 + 5];
2285 dy[i + 2] = s[i * 4 + 9];
2286 dy[i + 3] = s[i * 4 + 13];
2287 if (IS_CHROMA_LINE_410 (y, flags)) {
2288 du[i >> 2] = s[i * 4 + 2];
2289 dv[i >> 2] = s[i * 4 + 3];
2293 dy[i] = s[i * 4 + 1];
2294 if (IS_CHROMA_LINE_410 (y, flags)) {
2295 du[i >> 2] = s[i * 4 + 2];
2296 dv[i >> 2] = s[i * 4 + 3];
2299 dy[i + 1] = s[i * 4 + 5];
2301 dy[i + 2] = s[i * 4 + 9];
2305 #define PACK_IYU1 GST_VIDEO_FORMAT_AYUV, unpack_IYU1, 1, pack_IYU1
2307 unpack_IYU1 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2308 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2309 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2312 const guint8 *restrict s = GET_LINE (y);
2313 guint8 *restrict d = dest;
2314 guint8 y0, y1, y2, y3;
2321 for (i = 0; i < width - 3; i += 4) {
2322 y0 = s[(i >> 2) * 6 + 1];
2323 y1 = s[(i >> 2) * 6 + 2];
2324 y2 = s[(i >> 2) * 6 + 4];
2325 y3 = s[(i >> 2) * 6 + 5];
2327 u0 = s[(i >> 2) * 6 + 0];
2328 v0 = s[(i >> 2) * 6 + 3];
2330 d[i * 4 + 0] = 0xff;
2335 d[i * 4 + 4] = 0xff;
2340 d[i * 4 + 8] = 0xff;
2345 d[i * 4 + 12] = 0xff;
2351 u0 = s[(i >> 2) * 6 + 0];
2352 v0 = s[(i >> 2) * 6 + 3];
2354 d[i * 4 + 0] = 0xff;
2355 d[i * 4 + 1] = s[(i >> 2) * 6 + 1];
2359 if (i < width - 1) {
2360 d[i * 4 + 4] = 0xff;
2361 d[i * 4 + 5] = s[(i >> 2) * 6 + 2];
2365 if (i < width - 2) {
2366 d[i * 4 + 8] = 0xff;
2367 d[i * 4 + 9] = s[(i >> 2) * 6 + 4];
2375 pack_IYU1 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2376 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2377 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2381 guint8 *restrict d = GET_LINE (y);
2382 const guint8 *restrict s = src;
2384 for (i = 0; i < width - 3; i += 4) {
2385 d[(i >> 2) * 6 + 0] = s[i * 4 + 2];
2386 d[(i >> 2) * 6 + 1] = s[i * 4 + 1];
2387 d[(i >> 2) * 6 + 2] = s[i * 4 + 5];
2388 d[(i >> 2) * 6 + 3] = s[i * 4 + 3];
2389 d[(i >> 2) * 6 + 4] = s[i * 4 + 9];
2390 d[(i >> 2) * 6 + 5] = s[i * 4 + 13];
2393 d[(i >> 2) * 6 + 1] = s[i * 4 + 1];
2394 d[(i >> 2) * 6 + 0] = s[i * 4 + 2];
2395 d[(i >> 2) * 6 + 3] = s[i * 4 + 3];
2397 d[(i >> 2) * 6 + 2] = s[i * 4 + 5];
2399 d[(i >> 2) * 6 + 4] = s[i * 4 + 9];
2403 #define PACK_ARGB64 GST_VIDEO_FORMAT_ARGB64, unpack_copy8, 1, pack_copy8
2404 #define PACK_AYUV64 GST_VIDEO_FORMAT_AYUV64, unpack_copy8, 1, pack_copy8
2406 unpack_copy8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2407 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2408 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2410 const guint8 *s = GET_LINE (y);
2414 memcpy (dest, s, width * 8);
2418 pack_copy8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2419 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2420 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2423 guint8 *restrict d = GET_LINE (y);
2425 memcpy (d, src, width * 8);
2428 #define PACK_r210 GST_VIDEO_FORMAT_ARGB64, unpack_r210, 1, pack_r210
2430 unpack_r210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2431 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2432 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2435 const guint8 *restrict s = GET_LINE (y);
2436 guint16 *restrict d = dest, R, G, B;
2440 for (i = 0; i < width; i++) {
2441 guint32 x = GST_READ_UINT32_BE (s + i * 4);
2443 R = ((x >> 14) & 0xffc0);
2444 G = ((x >> 4) & 0xffc0);
2445 B = ((x << 6) & 0xffc0);
2447 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2453 d[i * 4 + 0] = 0xffff;
2461 pack_r210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2462 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2463 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2467 guint8 *restrict d = GET_LINE (y);
2468 const guint16 *restrict s = src;
2470 for (i = 0; i < width; i++) {
2472 x |= (s[i * 4 + 1] & 0xffc0) << 14;
2473 x |= (s[i * 4 + 2] & 0xffc0) << 4;
2474 x |= (s[i * 4 + 3] & 0xffc0) >> 6;
2475 GST_WRITE_UINT32_BE (d + i * 4, x);
2479 #define PACK_GBR_10LE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_10LE, 1, pack_GBR_10LE
2481 unpack_GBR_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2482 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2483 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2486 const guint16 *sg = GET_G_LINE (y);
2487 const guint16 *sb = GET_B_LINE (y);
2488 const guint16 *sr = GET_R_LINE (y);
2489 guint16 *d = dest, G, B, R;
2495 for (i = 0; i < width; i++) {
2496 G = GST_READ_UINT16_LE (sg + i) << 6;
2497 B = GST_READ_UINT16_LE (sb + i) << 6;
2498 R = GST_READ_UINT16_LE (sr + i) << 6;
2500 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2506 d[i * 4 + 0] = 0xffff;
2514 pack_GBR_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2515 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2516 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2520 guint16 *restrict dg = GET_G_LINE (y);
2521 guint16 *restrict db = GET_B_LINE (y);
2522 guint16 *restrict dr = GET_R_LINE (y);
2524 const guint16 *restrict s = src;
2526 for (i = 0; i < width; i++) {
2527 G = (s[i * 4 + 2]) >> 6;
2528 B = (s[i * 4 + 3]) >> 6;
2529 R = (s[i * 4 + 1]) >> 6;
2531 GST_WRITE_UINT16_LE (dg + i, G);
2532 GST_WRITE_UINT16_LE (db + i, B);
2533 GST_WRITE_UINT16_LE (dr + i, R);
2537 #define PACK_GBR_10BE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_10BE, 1, pack_GBR_10BE
2539 unpack_GBR_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2540 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2541 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2544 const guint16 *restrict sg = GET_G_LINE (y);
2545 const guint16 *restrict sb = GET_B_LINE (y);
2546 const guint16 *restrict sr = GET_R_LINE (y);
2547 guint16 *restrict d = dest, G, B, R;
2553 for (i = 0; i < width; i++) {
2554 G = GST_READ_UINT16_BE (sg + i) << 6;
2555 B = GST_READ_UINT16_BE (sb + i) << 6;
2556 R = GST_READ_UINT16_BE (sr + i) << 6;
2558 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2564 d[i * 4 + 0] = 0xffff;
2572 pack_GBR_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2573 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2574 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2578 guint16 *restrict dg = GET_G_LINE (y);
2579 guint16 *restrict db = GET_B_LINE (y);
2580 guint16 *restrict dr = GET_R_LINE (y);
2582 const guint16 *restrict s = src;
2584 for (i = 0; i < width; i++) {
2585 G = s[i * 4 + 2] >> 6;
2586 B = s[i * 4 + 3] >> 6;
2587 R = s[i * 4 + 1] >> 6;
2589 GST_WRITE_UINT16_BE (dg + i, G);
2590 GST_WRITE_UINT16_BE (db + i, B);
2591 GST_WRITE_UINT16_BE (dr + i, R);
2595 #define PACK_GBRA_10LE GST_VIDEO_FORMAT_ARGB64, unpack_GBRA_10LE, 1, pack_GBRA_10LE
2597 unpack_GBRA_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2598 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2599 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2602 const guint16 *sg = GET_G_LINE (y);
2603 const guint16 *sb = GET_B_LINE (y);
2604 const guint16 *sr = GET_R_LINE (y);
2605 const guint16 *sa = GET_A_LINE (y);
2606 guint16 *d = dest, G, B, R, A;
2613 for (i = 0; i < width; i++) {
2614 G = GST_READ_UINT16_LE (sg + i) << 6;
2615 B = GST_READ_UINT16_LE (sb + i) << 6;
2616 R = GST_READ_UINT16_LE (sr + i) << 6;
2617 A = GST_READ_UINT16_LE (sa + i) << 6;
2619 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2634 pack_GBRA_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2635 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2636 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2640 guint16 *restrict dg = GET_G_LINE (y);
2641 guint16 *restrict db = GET_B_LINE (y);
2642 guint16 *restrict dr = GET_R_LINE (y);
2643 guint16 *restrict da = GET_A_LINE (y);
2645 const guint16 *restrict s = src;
2647 for (i = 0; i < width; i++) {
2648 G = (s[i * 4 + 2]) >> 6;
2649 B = (s[i * 4 + 3]) >> 6;
2650 R = (s[i * 4 + 1]) >> 6;
2651 A = (s[i * 4 + 0]) >> 6;
2653 GST_WRITE_UINT16_LE (dg + i, G);
2654 GST_WRITE_UINT16_LE (db + i, B);
2655 GST_WRITE_UINT16_LE (dr + i, R);
2656 GST_WRITE_UINT16_LE (da + i, A);
2660 #define PACK_GBRA_10BE GST_VIDEO_FORMAT_ARGB64, unpack_GBRA_10BE, 1, pack_GBRA_10BE
2662 unpack_GBRA_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2663 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2664 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2667 const guint16 *restrict sg = GET_G_LINE (y);
2668 const guint16 *restrict sb = GET_B_LINE (y);
2669 const guint16 *restrict sr = GET_R_LINE (y);
2670 const guint16 *restrict sa = GET_A_LINE (y);
2671 guint16 *restrict d = dest, G, B, R, A;
2678 for (i = 0; i < width; i++) {
2679 G = GST_READ_UINT16_BE (sg + i) << 6;
2680 B = GST_READ_UINT16_BE (sb + i) << 6;
2681 R = GST_READ_UINT16_BE (sr + i) << 6;
2682 A = GST_READ_UINT16_BE (sa + i) << 6;
2684 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2699 pack_GBRA_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2700 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2701 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2705 guint16 *restrict dg = GET_G_LINE (y);
2706 guint16 *restrict db = GET_B_LINE (y);
2707 guint16 *restrict dr = GET_R_LINE (y);
2708 guint16 *restrict da = GET_A_LINE (y);
2710 const guint16 *restrict s = src;
2712 for (i = 0; i < width; i++) {
2713 G = s[i * 4 + 2] >> 6;
2714 B = s[i * 4 + 3] >> 6;
2715 R = s[i * 4 + 1] >> 6;
2716 A = s[i * 4 + 0] >> 6;
2718 GST_WRITE_UINT16_BE (dg + i, G);
2719 GST_WRITE_UINT16_BE (db + i, B);
2720 GST_WRITE_UINT16_BE (dr + i, R);
2721 GST_WRITE_UINT16_BE (da + i, A);
2725 #define PACK_GBR_12LE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_12LE, 1, pack_GBR_12LE
2727 unpack_GBR_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2728 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2729 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2732 const guint16 *sg = GET_G_LINE (y);
2733 const guint16 *sb = GET_B_LINE (y);
2734 const guint16 *sr = GET_R_LINE (y);
2735 guint16 *d = dest, G, B, R;
2741 for (i = 0; i < width; i++) {
2742 G = GST_READ_UINT16_LE (sg + i) << 4;
2743 B = GST_READ_UINT16_LE (sb + i) << 4;
2744 R = GST_READ_UINT16_LE (sr + i) << 4;
2746 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2752 d[i * 4 + 0] = 0xffff;
2760 pack_GBR_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2761 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2762 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2766 guint16 *restrict dg = GET_G_LINE (y);
2767 guint16 *restrict db = GET_B_LINE (y);
2768 guint16 *restrict dr = GET_R_LINE (y);
2770 const guint16 *restrict s = src;
2772 for (i = 0; i < width; i++) {
2773 G = (s[i * 4 + 2]) >> 4;
2774 B = (s[i * 4 + 3]) >> 4;
2775 R = (s[i * 4 + 1]) >> 4;
2777 GST_WRITE_UINT16_LE (dg + i, G);
2778 GST_WRITE_UINT16_LE (db + i, B);
2779 GST_WRITE_UINT16_LE (dr + i, R);
2783 #define PACK_GBR_12BE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_12BE, 1, pack_GBR_12BE
2785 unpack_GBR_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2786 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2787 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2790 const guint16 *restrict sg = GET_G_LINE (y);
2791 const guint16 *restrict sb = GET_B_LINE (y);
2792 const guint16 *restrict sr = GET_R_LINE (y);
2793 guint16 *restrict d = dest, G, B, R;
2799 for (i = 0; i < width; i++) {
2800 G = GST_READ_UINT16_BE (sg + i) << 4;
2801 B = GST_READ_UINT16_BE (sb + i) << 4;
2802 R = GST_READ_UINT16_BE (sr + i) << 4;
2804 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2810 d[i * 4 + 0] = 0xffff;
2818 pack_GBR_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2819 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2820 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2824 guint16 *restrict dg = GET_G_LINE (y);
2825 guint16 *restrict db = GET_B_LINE (y);
2826 guint16 *restrict dr = GET_R_LINE (y);
2828 const guint16 *restrict s = src;
2830 for (i = 0; i < width; i++) {
2831 G = s[i * 4 + 2] >> 4;
2832 B = s[i * 4 + 3] >> 4;
2833 R = s[i * 4 + 1] >> 4;
2835 GST_WRITE_UINT16_BE (dg + i, G);
2836 GST_WRITE_UINT16_BE (db + i, B);
2837 GST_WRITE_UINT16_BE (dr + i, R);
2841 #define PACK_GBRA_12LE GST_VIDEO_FORMAT_ARGB64, unpack_GBRA_12LE, 1, pack_GBRA_12LE
2843 unpack_GBRA_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2844 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2845 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2848 const guint16 *sg = GET_G_LINE (y);
2849 const guint16 *sb = GET_B_LINE (y);
2850 const guint16 *sr = GET_R_LINE (y);
2851 const guint16 *sa = GET_A_LINE (y);
2852 guint16 *d = dest, G, B, R, A;
2859 for (i = 0; i < width; i++) {
2860 G = GST_READ_UINT16_LE (sg + i) << 4;
2861 B = GST_READ_UINT16_LE (sb + i) << 4;
2862 R = GST_READ_UINT16_LE (sr + i) << 4;
2863 A = GST_READ_UINT16_LE (sa + i) << 4;
2865 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2880 pack_GBRA_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2881 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2882 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2886 guint16 *restrict dg = GET_G_LINE (y);
2887 guint16 *restrict db = GET_B_LINE (y);
2888 guint16 *restrict dr = GET_R_LINE (y);
2889 guint16 *restrict da = GET_A_LINE (y);
2891 const guint16 *restrict s = src;
2893 for (i = 0; i < width; i++) {
2894 G = (s[i * 4 + 2]) >> 4;
2895 B = (s[i * 4 + 3]) >> 4;
2896 R = (s[i * 4 + 1]) >> 4;
2897 A = (s[i * 4 + 0]) >> 4;
2899 GST_WRITE_UINT16_LE (dg + i, G);
2900 GST_WRITE_UINT16_LE (db + i, B);
2901 GST_WRITE_UINT16_LE (dr + i, R);
2902 GST_WRITE_UINT16_LE (da + i, A);
2906 #define PACK_GBRA_12BE GST_VIDEO_FORMAT_ARGB64, unpack_GBRA_12BE, 1, pack_GBRA_12BE
2908 unpack_GBRA_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2909 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2910 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2913 const guint16 *restrict sg = GET_G_LINE (y);
2914 const guint16 *restrict sb = GET_B_LINE (y);
2915 const guint16 *restrict sr = GET_R_LINE (y);
2916 const guint16 *restrict sa = GET_A_LINE (y);
2917 guint16 *restrict d = dest, G, B, R, A;
2924 for (i = 0; i < width; i++) {
2925 G = GST_READ_UINT16_BE (sg + i) << 4;
2926 B = GST_READ_UINT16_BE (sb + i) << 4;
2927 R = GST_READ_UINT16_BE (sr + i) << 4;
2928 A = GST_READ_UINT16_BE (sa + i) << 4;
2930 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2945 pack_GBRA_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2946 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2947 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2951 guint16 *restrict dg = GET_G_LINE (y);
2952 guint16 *restrict db = GET_B_LINE (y);
2953 guint16 *restrict dr = GET_R_LINE (y);
2954 guint16 *restrict da = GET_A_LINE (y);
2956 const guint16 *restrict s = src;
2958 for (i = 0; i < width; i++) {
2959 G = s[i * 4 + 2] >> 4;
2960 B = s[i * 4 + 3] >> 4;
2961 R = s[i * 4 + 1] >> 4;
2962 A = s[i * 4 + 0] >> 4;
2964 GST_WRITE_UINT16_BE (dg + i, G);
2965 GST_WRITE_UINT16_BE (db + i, B);
2966 GST_WRITE_UINT16_BE (dr + i, R);
2967 GST_WRITE_UINT16_BE (da + i, A);
2971 #define PACK_Y444_10LE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_10LE, 1, pack_Y444_10LE
2973 unpack_Y444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2974 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2975 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2978 guint16 *restrict sy = GET_Y_LINE (y);
2979 guint16 *restrict su = GET_U_LINE (y);
2980 guint16 *restrict sv = GET_V_LINE (y);
2981 guint16 *restrict d = dest, Y, U, V;
2987 for (i = 0; i < width; i++) {
2988 Y = GST_READ_UINT16_LE (sy + i) << 6;
2989 U = GST_READ_UINT16_LE (su + i) << 6;
2990 V = GST_READ_UINT16_LE (sv + i) << 6;
2992 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2998 d[i * 4 + 0] = 0xffff;
3006 pack_Y444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3007 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3008 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3012 guint16 *restrict dy = GET_Y_LINE (y);
3013 guint16 *restrict du = GET_U_LINE (y);
3014 guint16 *restrict dv = GET_V_LINE (y);
3016 const guint16 *restrict s = src;
3018 for (i = 0; i < width; i++) {
3019 Y = (s[i * 4 + 1]) >> 6;
3020 U = (s[i * 4 + 2]) >> 6;
3021 V = (s[i * 4 + 3]) >> 6;
3023 GST_WRITE_UINT16_LE (dy + i, Y);
3024 GST_WRITE_UINT16_LE (du + i, U);
3025 GST_WRITE_UINT16_LE (dv + i, V);
3029 #define PACK_Y444_10BE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_10BE, 1, pack_Y444_10BE
3031 unpack_Y444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3032 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3033 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3036 const guint16 *restrict sy = GET_Y_LINE (y);
3037 const guint16 *restrict su = GET_U_LINE (y);
3038 const guint16 *restrict sv = GET_V_LINE (y);
3039 guint16 *restrict d = dest, Y, U, V;
3045 for (i = 0; i < width; i++) {
3046 Y = GST_READ_UINT16_BE (sy + i) << 6;
3047 U = GST_READ_UINT16_BE (su + i) << 6;
3048 V = GST_READ_UINT16_BE (sv + i) << 6;
3050 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3056 d[i * 4 + 0] = 0xffff;
3064 pack_Y444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3065 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3066 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3070 guint16 *restrict dy = GET_Y_LINE (y);
3071 guint16 *restrict du = GET_U_LINE (y);
3072 guint16 *restrict dv = GET_V_LINE (y);
3074 const guint16 *restrict s = src;
3076 for (i = 0; i < width; i++) {
3077 Y = s[i * 4 + 1] >> 6;
3078 U = s[i * 4 + 2] >> 6;
3079 V = s[i * 4 + 3] >> 6;
3081 GST_WRITE_UINT16_BE (dy + i, Y);
3082 GST_WRITE_UINT16_BE (du + i, U);
3083 GST_WRITE_UINT16_BE (dv + i, V);
3087 #define PACK_I420_10LE GST_VIDEO_FORMAT_AYUV64, unpack_I420_10LE, 1, pack_I420_10LE
3089 unpack_I420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3090 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3091 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3094 gint uv = GET_UV_420 (y, flags);
3095 const guint16 *restrict sy = GET_Y_LINE (y);
3096 const guint16 *restrict su = GET_U_LINE (uv);
3097 const guint16 *restrict sv = GET_V_LINE (uv);
3098 guint16 *restrict d = dest, Y, U, V;
3104 for (i = 0; i < width; i++) {
3105 Y = GST_READ_UINT16_LE (sy + i) << 6;
3106 U = GST_READ_UINT16_LE (su + (i >> 1)) << 6;
3107 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 6;
3109 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3115 d[i * 4 + 0] = 0xffff;
3129 pack_I420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3130 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3131 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3135 gint uv = GET_UV_420 (y, flags);
3136 guint16 *restrict dy = GET_Y_LINE (y);
3137 guint16 *restrict du = GET_U_LINE (uv);
3138 guint16 *restrict dv = GET_V_LINE (uv);
3139 guint16 Y0, Y1, U, V;
3140 const guint16 *restrict s = src;
3142 if (IS_CHROMA_LINE_420 (y, flags)) {
3143 for (i = 0; i < width - 1; i += 2) {
3144 Y0 = s[i * 4 + 1] >> 6;
3145 Y1 = s[i * 4 + 5] >> 6;
3146 U = s[i * 4 + 2] >> 6;
3147 V = s[i * 4 + 3] >> 6;
3149 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3150 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3151 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3152 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3154 if (i == width - 1) {
3155 Y0 = s[i * 4 + 1] >> 6;
3156 U = s[i * 4 + 2] >> 6;
3157 V = s[i * 4 + 3] >> 6;
3159 GST_WRITE_UINT16_LE (dy + i, Y0);
3160 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3161 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3164 for (i = 0; i < width; i++) {
3165 Y0 = s[i * 4 + 1] >> 6;
3166 GST_WRITE_UINT16_LE (dy + i, Y0);
3171 #define PACK_I420_10BE GST_VIDEO_FORMAT_AYUV64, unpack_I420_10BE, 1, pack_I420_10BE
3173 unpack_I420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3174 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3175 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3178 gint uv = GET_UV_420 (y, flags);
3179 const guint16 *restrict sy = GET_Y_LINE (y);
3180 const guint16 *restrict su = GET_U_LINE (uv);
3181 const guint16 *restrict sv = GET_V_LINE (uv);
3182 guint16 *restrict d = dest, Y, U, V;
3188 for (i = 0; i < width; i++) {
3189 Y = GST_READ_UINT16_BE (sy + i) << 6;
3190 U = GST_READ_UINT16_BE (su + (i >> 1)) << 6;
3191 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 6;
3193 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3199 d[i * 4 + 0] = 0xffff;
3213 pack_I420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3214 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3215 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3219 gint uv = GET_UV_420 (y, flags);
3220 guint16 *restrict dy = GET_Y_LINE (y);
3221 guint16 *restrict du = GET_U_LINE (uv);
3222 guint16 *restrict dv = GET_V_LINE (uv);
3223 guint16 Y0, Y1, U, V;
3224 const guint16 *restrict s = src;
3226 if (IS_CHROMA_LINE_420 (y, flags)) {
3227 for (i = 0; i < width - 1; i += 2) {
3228 Y0 = s[i * 4 + 1] >> 6;
3229 Y1 = s[i * 4 + 5] >> 6;
3230 U = s[i * 4 + 2] >> 6;
3231 V = s[i * 4 + 3] >> 6;
3233 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
3234 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
3235 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3236 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3238 if (i == width - 1) {
3239 Y0 = s[i * 4 + 1] >> 6;
3240 U = s[i * 4 + 2] >> 6;
3241 V = s[i * 4 + 3] >> 6;
3243 GST_WRITE_UINT16_BE (dy + i, Y0);
3244 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3245 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3248 for (i = 0; i < width; i++) {
3249 Y0 = s[i * 4 + 1] >> 6;
3250 GST_WRITE_UINT16_BE (dy + i, Y0);
3255 #define PACK_I422_10LE GST_VIDEO_FORMAT_AYUV64, unpack_I422_10LE, 1, pack_I422_10LE
3257 unpack_I422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3258 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3259 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3262 const guint16 *restrict sy = GET_Y_LINE (y);
3263 const guint16 *restrict su = GET_U_LINE (y);
3264 const guint16 *restrict sv = GET_V_LINE (y);
3265 guint16 *restrict d = dest, Y, U, V;
3271 for (i = 0; i < width; i++) {
3272 Y = GST_READ_UINT16_LE (sy + i) << 6;
3273 U = GST_READ_UINT16_LE (su + (i >> 1)) << 6;
3274 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 6;
3276 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3282 d[i * 4 + 0] = 0xffff;
3296 pack_I422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3297 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3298 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3302 guint16 *restrict dy = GET_Y_LINE (y);
3303 guint16 *restrict du = GET_U_LINE (y);
3304 guint16 *restrict dv = GET_V_LINE (y);
3305 guint16 Y0, Y1, U, V;
3306 const guint16 *restrict s = src;
3308 for (i = 0; i < width - 1; i += 2) {
3309 Y0 = s[i * 4 + 1] >> 6;
3310 Y1 = s[i * 4 + 5] >> 6;
3311 U = s[i * 4 + 2] >> 6;
3312 V = s[i * 4 + 3] >> 6;
3314 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3315 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3316 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3317 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3319 if (i == width - 1) {
3320 Y0 = s[i * 4 + 1] >> 6;
3321 U = s[i * 4 + 2] >> 6;
3322 V = s[i * 4 + 3] >> 6;
3324 GST_WRITE_UINT16_LE (dy + i, Y0);
3325 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3326 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3330 #define PACK_I422_10BE GST_VIDEO_FORMAT_AYUV64, unpack_I422_10BE, 1, pack_I422_10BE
3332 unpack_I422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3333 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3334 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3337 const guint16 *restrict sy = GET_Y_LINE (y);
3338 const guint16 *restrict su = GET_U_LINE (y);
3339 const guint16 *restrict sv = GET_V_LINE (y);
3340 guint16 *restrict d = dest, Y, U, V;
3346 for (i = 0; i < width; i++) {
3347 Y = GST_READ_UINT16_BE (sy + i) << 6;
3348 U = GST_READ_UINT16_BE (su + (i >> 1)) << 6;
3349 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 6;
3351 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3357 d[i * 4 + 0] = 0xffff;
3371 pack_I422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3372 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3373 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3377 guint16 *restrict dy = GET_Y_LINE (y);
3378 guint16 *restrict du = GET_U_LINE (y);
3379 guint16 *restrict dv = GET_V_LINE (y);
3380 guint16 Y0, Y1, U, V;
3381 const guint16 *restrict s = src;
3383 for (i = 0; i < width - 1; i += 2) {
3384 Y0 = s[i * 4 + 1] >> 6;
3385 Y1 = s[i * 4 + 5] >> 6;
3386 U = s[i * 4 + 2] >> 6;
3387 V = s[i * 4 + 3] >> 6;
3389 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
3390 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
3391 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3392 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3394 if (i == width - 1) {
3395 Y0 = s[i * 4 + 1] >> 6;
3396 U = s[i * 4 + 2] >> 6;
3397 V = s[i * 4 + 3] >> 6;
3399 GST_WRITE_UINT16_BE (dy + i, Y0);
3400 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3401 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3405 #define PACK_Y444_12LE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_12LE, 1, pack_Y444_12LE
3407 unpack_Y444_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3408 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3409 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3412 guint16 *restrict sy = GET_Y_LINE (y);
3413 guint16 *restrict su = GET_U_LINE (y);
3414 guint16 *restrict sv = GET_V_LINE (y);
3415 guint16 *restrict d = dest, Y, U, V;
3421 for (i = 0; i < width; i++) {
3422 Y = GST_READ_UINT16_LE (sy + i) << 4;
3423 U = GST_READ_UINT16_LE (su + i) << 4;
3424 V = GST_READ_UINT16_LE (sv + i) << 4;
3426 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3432 d[i * 4 + 0] = 0xffff;
3440 pack_Y444_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3441 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3442 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3446 guint16 *restrict dy = GET_Y_LINE (y);
3447 guint16 *restrict du = GET_U_LINE (y);
3448 guint16 *restrict dv = GET_V_LINE (y);
3450 const guint16 *restrict s = src;
3452 for (i = 0; i < width; i++) {
3453 Y = (s[i * 4 + 1]) >> 4;
3454 U = (s[i * 4 + 2]) >> 4;
3455 V = (s[i * 4 + 3]) >> 4;
3457 GST_WRITE_UINT16_LE (dy + i, Y);
3458 GST_WRITE_UINT16_LE (du + i, U);
3459 GST_WRITE_UINT16_LE (dv + i, V);
3463 #define PACK_Y444_12BE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_12BE, 1, pack_Y444_12BE
3465 unpack_Y444_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3466 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3467 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3470 const guint16 *restrict sy = GET_Y_LINE (y);
3471 const guint16 *restrict su = GET_U_LINE (y);
3472 const guint16 *restrict sv = GET_V_LINE (y);
3473 guint16 *restrict d = dest, Y, U, V;
3479 for (i = 0; i < width; i++) {
3480 Y = GST_READ_UINT16_BE (sy + i) << 4;
3481 U = GST_READ_UINT16_BE (su + i) << 4;
3482 V = GST_READ_UINT16_BE (sv + i) << 4;
3484 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3490 d[i * 4 + 0] = 0xffff;
3498 pack_Y444_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3499 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3500 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3504 guint16 *restrict dy = GET_Y_LINE (y);
3505 guint16 *restrict du = GET_U_LINE (y);
3506 guint16 *restrict dv = GET_V_LINE (y);
3508 const guint16 *restrict s = src;
3510 for (i = 0; i < width; i++) {
3511 Y = s[i * 4 + 1] >> 4;
3512 U = s[i * 4 + 2] >> 4;
3513 V = s[i * 4 + 3] >> 4;
3515 GST_WRITE_UINT16_BE (dy + i, Y);
3516 GST_WRITE_UINT16_BE (du + i, U);
3517 GST_WRITE_UINT16_BE (dv + i, V);
3521 #define PACK_I420_12LE GST_VIDEO_FORMAT_AYUV64, unpack_I420_12LE, 1, pack_I420_12LE
3523 unpack_I420_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3524 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3525 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3528 gint uv = GET_UV_420 (y, flags);
3529 const guint16 *restrict sy = GET_Y_LINE (y);
3530 const guint16 *restrict su = GET_U_LINE (uv);
3531 const guint16 *restrict sv = GET_V_LINE (uv);
3532 guint16 *restrict d = dest, Y, U, V;
3538 for (i = 0; i < width; i++) {
3539 Y = GST_READ_UINT16_LE (sy + i) << 4;
3540 U = GST_READ_UINT16_LE (su + (i >> 1)) << 4;
3541 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 4;
3543 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3549 d[i * 4 + 0] = 0xffff;
3563 pack_I420_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3564 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3565 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3569 gint uv = GET_UV_420 (y, flags);
3570 guint16 *restrict dy = GET_Y_LINE (y);
3571 guint16 *restrict du = GET_U_LINE (uv);
3572 guint16 *restrict dv = GET_V_LINE (uv);
3573 guint16 Y0, Y1, U, V;
3574 const guint16 *restrict s = src;
3576 if (IS_CHROMA_LINE_420 (y, flags)) {
3577 for (i = 0; i < width - 1; i += 2) {
3578 Y0 = s[i * 4 + 1] >> 4;
3579 Y1 = s[i * 4 + 5] >> 4;
3580 U = s[i * 4 + 2] >> 4;
3581 V = s[i * 4 + 3] >> 4;
3583 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3584 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3585 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3586 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3588 if (i == width - 1) {
3589 Y0 = s[i * 4 + 1] >> 4;
3590 U = s[i * 4 + 2] >> 4;
3591 V = s[i * 4 + 3] >> 4;
3593 GST_WRITE_UINT16_LE (dy + i, Y0);
3594 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3595 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3598 for (i = 0; i < width; i++) {
3599 Y0 = s[i * 4 + 1] >> 4;
3600 GST_WRITE_UINT16_LE (dy + i, Y0);
3605 #define PACK_I420_12BE GST_VIDEO_FORMAT_AYUV64, unpack_I420_12BE, 1, pack_I420_12BE
3607 unpack_I420_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3608 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3609 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3612 gint uv = GET_UV_420 (y, flags);
3613 const guint16 *restrict sy = GET_Y_LINE (y);
3614 const guint16 *restrict su = GET_U_LINE (uv);
3615 const guint16 *restrict sv = GET_V_LINE (uv);
3616 guint16 *restrict d = dest, Y, U, V;
3622 for (i = 0; i < width; i++) {
3623 Y = GST_READ_UINT16_BE (sy + i) << 4;
3624 U = GST_READ_UINT16_BE (su + (i >> 1)) << 4;
3625 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 4;
3627 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3633 d[i * 4 + 0] = 0xffff;
3647 pack_I420_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3648 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3649 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3653 gint uv = GET_UV_420 (y, flags);
3654 guint16 *restrict dy = GET_Y_LINE (y);
3655 guint16 *restrict du = GET_U_LINE (uv);
3656 guint16 *restrict dv = GET_V_LINE (uv);
3657 guint16 Y0, Y1, U, V;
3658 const guint16 *restrict s = src;
3660 if (IS_CHROMA_LINE_420 (y, flags)) {
3661 for (i = 0; i < width - 1; i += 2) {
3662 Y0 = s[i * 4 + 1] >> 4;
3663 Y1 = s[i * 4 + 5] >> 4;
3664 U = s[i * 4 + 2] >> 4;
3665 V = s[i * 4 + 3] >> 4;
3667 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
3668 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
3669 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3670 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3672 if (i == width - 1) {
3673 Y0 = s[i * 4 + 1] >> 4;
3674 U = s[i * 4 + 2] >> 4;
3675 V = s[i * 4 + 3] >> 4;
3677 GST_WRITE_UINT16_BE (dy + i, Y0);
3678 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3679 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3682 for (i = 0; i < width; i++) {
3683 Y0 = s[i * 4 + 1] >> 4;
3684 GST_WRITE_UINT16_BE (dy + i, Y0);
3689 #define PACK_I422_12LE GST_VIDEO_FORMAT_AYUV64, unpack_I422_12LE, 1, pack_I422_12LE
3691 unpack_I422_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3692 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3693 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3696 const guint16 *restrict sy = GET_Y_LINE (y);
3697 const guint16 *restrict su = GET_U_LINE (y);
3698 const guint16 *restrict sv = GET_V_LINE (y);
3699 guint16 *restrict d = dest, Y, U, V;
3705 for (i = 0; i < width; i++) {
3706 Y = GST_READ_UINT16_LE (sy + i) << 4;
3707 U = GST_READ_UINT16_LE (su + (i >> 1)) << 4;
3708 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 4;
3710 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3716 d[i * 4 + 0] = 0xffff;
3730 pack_I422_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3731 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3732 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3736 guint16 *restrict dy = GET_Y_LINE (y);
3737 guint16 *restrict du = GET_U_LINE (y);
3738 guint16 *restrict dv = GET_V_LINE (y);
3739 guint16 Y0, Y1, U, V;
3740 const guint16 *restrict s = src;
3742 for (i = 0; i < width - 1; i += 2) {
3743 Y0 = s[i * 4 + 1] >> 4;
3744 Y1 = s[i * 4 + 5] >> 4;
3745 U = s[i * 4 + 2] >> 4;
3746 V = s[i * 4 + 3] >> 4;
3748 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3749 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3750 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3751 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3753 if (i == width - 1) {
3754 Y0 = s[i * 4 + 1] >> 4;
3755 U = s[i * 4 + 2] >> 4;
3756 V = s[i * 4 + 3] >> 4;
3758 GST_WRITE_UINT16_LE (dy + i, Y0);
3759 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3760 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3764 #define PACK_I422_12BE GST_VIDEO_FORMAT_AYUV64, unpack_I422_12BE, 1, pack_I422_12BE
3766 unpack_I422_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3767 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3768 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3771 const guint16 *restrict sy = GET_Y_LINE (y);
3772 const guint16 *restrict su = GET_U_LINE (y);
3773 const guint16 *restrict sv = GET_V_LINE (y);
3774 guint16 *restrict d = dest, Y, U, V;
3780 for (i = 0; i < width; i++) {
3781 Y = GST_READ_UINT16_BE (sy + i) << 4;
3782 U = GST_READ_UINT16_BE (su + (i >> 1)) << 4;
3783 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 4;
3785 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3791 d[i * 4 + 0] = 0xffff;
3805 pack_I422_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3806 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3807 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3811 guint16 *restrict dy = GET_Y_LINE (y);
3812 guint16 *restrict du = GET_U_LINE (y);
3813 guint16 *restrict dv = GET_V_LINE (y);
3814 guint16 Y0, Y1, U, V;
3815 const guint16 *restrict s = src;
3817 for (i = 0; i < width - 1; i += 2) {
3818 Y0 = s[i * 4 + 1] >> 4;
3819 Y1 = s[i * 4 + 5] >> 4;
3820 U = s[i * 4 + 2] >> 4;
3821 V = s[i * 4 + 3] >> 4;
3823 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
3824 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
3825 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3826 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3828 if (i == width - 1) {
3829 Y0 = s[i * 4 + 1] >> 4;
3830 U = s[i * 4 + 2] >> 4;
3831 V = s[i * 4 + 3] >> 4;
3833 GST_WRITE_UINT16_BE (dy + i, Y0);
3834 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3835 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3839 #define PACK_A444_10LE GST_VIDEO_FORMAT_AYUV64, unpack_A444_10LE, 1, pack_A444_10LE
3841 unpack_A444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3842 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3843 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3846 guint16 *restrict sa = GET_A_LINE (y);
3847 guint16 *restrict sy = GET_Y_LINE (y);
3848 guint16 *restrict su = GET_U_LINE (y);
3849 guint16 *restrict sv = GET_V_LINE (y);
3850 guint16 *restrict d = dest, A, Y, U, V;
3857 for (i = 0; i < width; i++) {
3858 A = GST_READ_UINT16_LE (sa + i) << 6;
3859 Y = GST_READ_UINT16_LE (sy + i) << 6;
3860 U = GST_READ_UINT16_LE (su + i) << 6;
3861 V = GST_READ_UINT16_LE (sv + i) << 6;
3863 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3878 pack_A444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3879 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3880 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3884 guint16 *restrict da = GET_A_LINE (y);
3885 guint16 *restrict dy = GET_Y_LINE (y);
3886 guint16 *restrict du = GET_U_LINE (y);
3887 guint16 *restrict dv = GET_V_LINE (y);
3889 const guint16 *restrict s = src;
3891 for (i = 0; i < width; i++) {
3892 A = (s[i * 4 + 0]) >> 6;
3893 Y = (s[i * 4 + 1]) >> 6;
3894 U = (s[i * 4 + 2]) >> 6;
3895 V = (s[i * 4 + 3]) >> 6;
3897 GST_WRITE_UINT16_LE (da + i, A);
3898 GST_WRITE_UINT16_LE (dy + i, Y);
3899 GST_WRITE_UINT16_LE (du + i, U);
3900 GST_WRITE_UINT16_LE (dv + i, V);
3904 #define PACK_A444_10BE GST_VIDEO_FORMAT_AYUV64, unpack_A444_10BE, 1, pack_A444_10BE
3906 unpack_A444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3907 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3908 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3911 const guint16 *restrict sa = GET_A_LINE (y);
3912 const guint16 *restrict sy = GET_Y_LINE (y);
3913 const guint16 *restrict su = GET_U_LINE (y);
3914 const guint16 *restrict sv = GET_V_LINE (y);
3915 guint16 *restrict d = dest, A, Y, U, V;
3922 for (i = 0; i < width; i++) {
3923 A = GST_READ_UINT16_BE (sa + i) << 6;
3924 Y = GST_READ_UINT16_BE (sy + i) << 6;
3925 U = GST_READ_UINT16_BE (su + i) << 6;
3926 V = GST_READ_UINT16_BE (sv + i) << 6;
3928 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3943 pack_A444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3944 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3945 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3949 guint16 *restrict da = GET_A_LINE (y);
3950 guint16 *restrict dy = GET_Y_LINE (y);
3951 guint16 *restrict du = GET_U_LINE (y);
3952 guint16 *restrict dv = GET_V_LINE (y);
3954 const guint16 *restrict s = src;
3956 for (i = 0; i < width; i++) {
3957 A = s[i * 4 + 0] >> 6;
3958 Y = s[i * 4 + 1] >> 6;
3959 U = s[i * 4 + 2] >> 6;
3960 V = s[i * 4 + 3] >> 6;
3962 GST_WRITE_UINT16_BE (da + i, A);
3963 GST_WRITE_UINT16_BE (dy + i, Y);
3964 GST_WRITE_UINT16_BE (du + i, U);
3965 GST_WRITE_UINT16_BE (dv + i, V);
3969 #define PACK_A420_10LE GST_VIDEO_FORMAT_AYUV64, unpack_A420_10LE, 1, pack_A420_10LE
3971 unpack_A420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3972 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3973 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3976 gint uv = GET_UV_420 (y, flags);
3977 const guint16 *restrict sa = GET_A_LINE (y);
3978 const guint16 *restrict sy = GET_Y_LINE (y);
3979 const guint16 *restrict su = GET_U_LINE (uv);
3980 const guint16 *restrict sv = GET_V_LINE (uv);
3981 guint16 *restrict d = dest, A, Y, U, V;
3988 for (i = 0; i < width; i++) {
3989 A = GST_READ_UINT16_LE (sa + i) << 6;
3990 Y = GST_READ_UINT16_LE (sy + i) << 6;
3991 U = GST_READ_UINT16_LE (su + (i >> 1)) << 6;
3992 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 6;
3994 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4015 pack_A420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4016 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4017 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4021 gint uv = GET_UV_420 (y, flags);
4022 guint16 *restrict da = GET_A_LINE (y);
4023 guint16 *restrict dy = GET_Y_LINE (y);
4024 guint16 *restrict du = GET_U_LINE (uv);
4025 guint16 *restrict dv = GET_V_LINE (uv);
4026 guint16 A0, Y0, A1, Y1, U, V;
4027 const guint16 *restrict s = src;
4029 if (IS_CHROMA_LINE_420 (y, flags)) {
4030 for (i = 0; i < width - 1; i += 2) {
4031 A0 = s[i * 4 + 0] >> 6;
4032 Y0 = s[i * 4 + 1] >> 6;
4033 A1 = s[i * 4 + 4] >> 6;
4034 Y1 = s[i * 4 + 5] >> 6;
4035 U = s[i * 4 + 2] >> 6;
4036 V = s[i * 4 + 3] >> 6;
4038 GST_WRITE_UINT16_LE (da + i + 0, A0);
4039 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
4040 GST_WRITE_UINT16_LE (da + i + 1, A1);
4041 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
4042 GST_WRITE_UINT16_LE (du + (i >> 1), U);
4043 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
4045 if (i == width - 1) {
4046 A0 = s[i * 4 + 0] >> 6;
4047 Y0 = s[i * 4 + 1] >> 6;
4048 U = s[i * 4 + 2] >> 6;
4049 V = s[i * 4 + 3] >> 6;
4051 GST_WRITE_UINT16_LE (da + i, A0);
4052 GST_WRITE_UINT16_LE (dy + i, Y0);
4053 GST_WRITE_UINT16_LE (du + (i >> 1), U);
4054 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
4057 for (i = 0; i < width; i++) {
4058 A0 = s[i * 4 + 0] >> 6;
4059 Y0 = s[i * 4 + 1] >> 6;
4060 GST_WRITE_UINT16_LE (da + i, A0);
4061 GST_WRITE_UINT16_LE (dy + i, Y0);
4066 #define PACK_A420_10BE GST_VIDEO_FORMAT_AYUV64, unpack_A420_10BE, 1, pack_A420_10BE
4068 unpack_A420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4069 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4070 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4073 gint uv = GET_UV_420 (y, flags);
4074 const guint16 *restrict sa = GET_A_LINE (y);
4075 const guint16 *restrict sy = GET_Y_LINE (y);
4076 const guint16 *restrict su = GET_U_LINE (uv);
4077 const guint16 *restrict sv = GET_V_LINE (uv);
4078 guint16 *restrict d = dest, A, Y, U, V;
4085 for (i = 0; i < width; i++) {
4086 A = GST_READ_UINT16_BE (sa + i) << 6;
4087 Y = GST_READ_UINT16_BE (sy + i) << 6;
4088 U = GST_READ_UINT16_BE (su + (i >> 1)) << 6;
4089 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 6;
4091 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4112 pack_A420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4113 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4114 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4118 gint uv = GET_UV_420 (y, flags);
4119 guint16 *restrict da = GET_A_LINE (y);
4120 guint16 *restrict dy = GET_Y_LINE (y);
4121 guint16 *restrict du = GET_U_LINE (uv);
4122 guint16 *restrict dv = GET_V_LINE (uv);
4123 guint16 A0, Y0, A1, Y1, U, V;
4124 const guint16 *restrict s = src;
4126 if (IS_CHROMA_LINE_420 (y, flags)) {
4127 for (i = 0; i < width - 1; i += 2) {
4128 A0 = s[i * 4 + 0] >> 6;
4129 Y0 = s[i * 4 + 1] >> 6;
4130 A1 = s[i * 4 + 4] >> 6;
4131 Y1 = s[i * 4 + 5] >> 6;
4132 U = s[i * 4 + 2] >> 6;
4133 V = s[i * 4 + 3] >> 6;
4135 GST_WRITE_UINT16_BE (da + i + 0, A0);
4136 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
4137 GST_WRITE_UINT16_BE (da + i + 1, A1);
4138 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
4139 GST_WRITE_UINT16_BE (du + (i >> 1), U);
4140 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
4142 if (i == width - 1) {
4143 A0 = s[i * 4 + 0] >> 6;
4144 Y0 = s[i * 4 + 1] >> 6;
4145 U = s[i * 4 + 2] >> 6;
4146 V = s[i * 4 + 3] >> 6;
4148 GST_WRITE_UINT16_BE (da + i, A0);
4149 GST_WRITE_UINT16_BE (dy + i, Y0);
4150 GST_WRITE_UINT16_BE (du + (i >> 1), U);
4151 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
4154 for (i = 0; i < width; i++) {
4155 A0 = s[i * 4 + 0] >> 6;
4156 Y0 = s[i * 4 + 1] >> 6;
4157 GST_WRITE_UINT16_BE (da + i, A0);
4158 GST_WRITE_UINT16_BE (dy + i, Y0);
4163 #define PACK_A422_10LE GST_VIDEO_FORMAT_AYUV64, unpack_A422_10LE, 1, pack_A422_10LE
4165 unpack_A422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4166 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4167 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4170 const guint16 *restrict sa = GET_A_LINE (y);
4171 const guint16 *restrict sy = GET_Y_LINE (y);
4172 const guint16 *restrict su = GET_U_LINE (y);
4173 const guint16 *restrict sv = GET_V_LINE (y);
4174 guint16 *restrict d = dest, A, Y, U, V;
4181 for (i = 0; i < width; i++) {
4182 A = GST_READ_UINT16_LE (sa + i) << 6;
4183 Y = GST_READ_UINT16_LE (sy + i) << 6;
4184 U = GST_READ_UINT16_LE (su + (i >> 1)) << 6;
4185 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 6;
4187 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4208 pack_A422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4209 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4210 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4214 guint16 *restrict da = GET_A_LINE (y);
4215 guint16 *restrict dy = GET_Y_LINE (y);
4216 guint16 *restrict du = GET_U_LINE (y);
4217 guint16 *restrict dv = GET_V_LINE (y);
4218 guint16 A0, Y0, A1, Y1, U, V;
4219 const guint16 *restrict s = src;
4221 for (i = 0; i < width - 1; i += 2) {
4222 A0 = s[i * 4 + 0] >> 6;
4223 Y0 = s[i * 4 + 1] >> 6;
4224 A1 = s[i * 4 + 4] >> 6;
4225 Y1 = s[i * 4 + 5] >> 6;
4226 U = s[i * 4 + 2] >> 6;
4227 V = s[i * 4 + 3] >> 6;
4229 GST_WRITE_UINT16_LE (da + i + 0, A0);
4230 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
4231 GST_WRITE_UINT16_LE (da + i + 1, A1);
4232 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
4233 GST_WRITE_UINT16_LE (du + (i >> 1), U);
4234 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
4236 if (i == width - 1) {
4237 A0 = s[i * 4 + 0] >> 6;
4238 Y0 = s[i * 4 + 1] >> 6;
4239 U = s[i * 4 + 2] >> 6;
4240 V = s[i * 4 + 3] >> 6;
4242 GST_WRITE_UINT16_LE (da + i, A0);
4243 GST_WRITE_UINT16_LE (dy + i, Y0);
4244 GST_WRITE_UINT16_LE (du + (i >> 1), U);
4245 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
4249 #define PACK_A422_10BE GST_VIDEO_FORMAT_AYUV64, unpack_A422_10BE, 1, pack_A422_10BE
4251 unpack_A422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4252 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4253 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4256 const guint16 *restrict sa = GET_A_LINE (y);
4257 const guint16 *restrict sy = GET_Y_LINE (y);
4258 const guint16 *restrict su = GET_U_LINE (y);
4259 const guint16 *restrict sv = GET_V_LINE (y);
4260 guint16 *restrict d = dest, A, Y, U, V;
4267 for (i = 0; i < width; i++) {
4268 A = GST_READ_UINT16_BE (sa + i) << 6;
4269 Y = GST_READ_UINT16_BE (sy + i) << 6;
4270 U = GST_READ_UINT16_BE (su + (i >> 1)) << 6;
4271 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 6;
4273 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4294 pack_A422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4295 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4296 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4300 guint16 *restrict da = GET_A_LINE (y);
4301 guint16 *restrict dy = GET_Y_LINE (y);
4302 guint16 *restrict du = GET_U_LINE (y);
4303 guint16 *restrict dv = GET_V_LINE (y);
4304 guint16 A0, Y0, A1, Y1, U, V;
4305 const guint16 *restrict s = src;
4307 for (i = 0; i < width - 1; i += 2) {
4308 A0 = s[i * 4 + 0] >> 6;
4309 Y0 = s[i * 4 + 1] >> 6;
4310 A1 = s[i * 4 + 4] >> 6;
4311 Y1 = s[i * 4 + 5] >> 6;
4312 U = s[i * 4 + 2] >> 6;
4313 V = s[i * 4 + 3] >> 6;
4315 GST_WRITE_UINT16_BE (da + i + 0, A0);
4316 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
4317 GST_WRITE_UINT16_BE (da + i + 1, A1);
4318 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
4319 GST_WRITE_UINT16_BE (du + (i >> 1), U);
4320 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
4322 if (i == width - 1) {
4323 A0 = s[i * 4 + 0] >> 6;
4324 Y0 = s[i * 4 + 1] >> 6;
4325 U = s[i * 4 + 2] >> 6;
4326 V = s[i * 4 + 3] >> 6;
4328 GST_WRITE_UINT16_BE (da + i, A0);
4329 GST_WRITE_UINT16_BE (dy + i, Y0);
4330 GST_WRITE_UINT16_BE (du + (i >> 1), U);
4331 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
4336 get_tile_NV12 (gint tile_width, gint ts, gint tx, gint ty,
4337 const gpointer data[GST_VIDEO_MAX_PLANES],
4338 const gint stride[GST_VIDEO_MAX_PLANES],
4339 gpointer tile_data[GST_VIDEO_MAX_PLANES],
4340 gint tile_stride[GST_VIDEO_MAX_PLANES])
4344 /* index of Y tile */
4345 offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
4346 tx, ty, GST_VIDEO_TILE_X_TILES (stride[0]),
4347 GST_VIDEO_TILE_Y_TILES (stride[0]));
4349 tile_data[0] = ((guint8 *) data[0]) + offset;
4351 /* index of UV tile */
4352 offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
4353 tx, ty >> 1, GST_VIDEO_TILE_X_TILES (stride[1]),
4354 GST_VIDEO_TILE_Y_TILES (stride[1]));
4356 /* On odd rows we return the second part of the UV tile */
4357 offset |= (ty & 1) << (ts - 1);
4358 tile_data[1] = ((guint8 *) data[1]) + offset;
4360 tile_stride[0] = tile_stride[1] = tile_width;
4363 #define PACK_NV12_64Z32 GST_VIDEO_FORMAT_AYUV, unpack_NV12_64Z32, 1, pack_NV12_64Z32
4365 unpack_NV12_64Z32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4366 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4367 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4369 const GstVideoFormatInfo *unpack_info, *finfo;
4370 guint8 *line = dest;
4371 gint ws, hs, ts, tile_width;
4373 gint unpack_pstride;
4375 ws = GST_VIDEO_FORMAT_INFO_TILE_WS (info);
4376 hs = GST_VIDEO_FORMAT_INFO_TILE_HS (info);
4379 tile_width = 1 << ws;
4381 /* we reuse these unpack functions */
4382 finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_NV12);
4384 /* get pstride of unpacked format */
4385 unpack_info = gst_video_format_get_info (info->unpack_format);
4386 unpack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (unpack_info, 0);
4388 /* first x tile to convert */
4390 /* Last tile to convert */
4391 ntx = ((x + width - 1) >> ws) + 1;
4392 /* The row we are going to convert */
4395 /* y position in a tile */
4396 y = y & ((1 << hs) - 1);
4397 /* x position in a tile */
4398 x = x & (tile_width - 1);
4400 for (; tx < ntx; tx++) {
4401 gpointer tdata[GST_VIDEO_MAX_PLANES];
4402 gint tstride[GST_VIDEO_MAX_PLANES];
4405 get_tile_NV12 (tile_width, ts, tx, ty, data, stride, tdata, tstride);
4407 /* the number of bytes left to unpack */
4408 unpack_width = MIN (width - x, tile_width - x);
4410 finfo->unpack_func (finfo, flags, line, tdata, tstride, x, y, unpack_width);
4413 width -= unpack_width;
4414 line += unpack_width * unpack_pstride;
4419 pack_NV12_64Z32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4420 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4421 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4424 const GstVideoFormatInfo *pack_info, *finfo;
4426 gint ws, hs, ts, tile_width;
4430 ws = GST_VIDEO_FORMAT_INFO_TILE_WS (info);
4431 hs = GST_VIDEO_FORMAT_INFO_TILE_HS (info);
4434 tile_width = 1 << ws;
4436 /* we reuse these pack functions */
4437 finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_NV12);
4439 /* get pstride of packed format */
4440 pack_info = gst_video_format_get_info (info->unpack_format);
4441 pack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (pack_info, 0);
4443 /* Last tile to convert */
4444 ntx = ((width - 1) >> ws) + 1;
4445 /* The row we are going to convert */
4448 /* y position in a tile */
4449 y = y & ((1 << hs) - 1);
4451 for (tx = 0; tx < ntx; tx++) {
4452 gpointer tdata[GST_VIDEO_MAX_PLANES];
4453 gint tstride[GST_VIDEO_MAX_PLANES];
4456 get_tile_NV12 (tile_width, ts, tx, ty, data, stride, tdata, tstride);
4458 /* the number of bytes left to pack */
4459 pack_width = MIN (width, tile_width);
4461 finfo->pack_func (finfo, flags, line, sstride, tdata, tstride,
4462 chroma_site, y, pack_width);
4464 width -= pack_width;
4465 line += pack_width * pack_pstride;
4469 #define PACK_P010_10BE GST_VIDEO_FORMAT_AYUV64, unpack_P010_10BE, 1, pack_P010_10BE
4471 unpack_P010_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4472 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4473 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4476 gint uv = GET_UV_420 (y, flags);
4477 const guint16 *restrict sy = GET_PLANE_LINE (0, y);
4478 const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
4479 guint16 *restrict d = dest, Y0, Y1, U, V;
4485 Y0 = GST_READ_UINT16_BE (sy);
4486 U = GST_READ_UINT16_BE (suv);
4487 V = GST_READ_UINT16_BE (suv + 1);
4489 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4505 for (i = 0; i < width / 2; i++) {
4506 Y0 = GST_READ_UINT16_BE (sy + 2 * i);
4507 Y1 = GST_READ_UINT16_BE (sy + 2 * i + 1);
4508 U = GST_READ_UINT16_BE (suv + 2 * i);
4509 V = GST_READ_UINT16_BE (suv + 2 * i + 1);
4511 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4518 d[i * 8 + 0] = 0xffff;
4522 d[i * 8 + 4] = 0xffff;
4531 Y0 = GST_READ_UINT16_BE (sy + i);
4532 U = GST_READ_UINT16_BE (suv + i);
4533 V = GST_READ_UINT16_BE (suv + i + 1);
4535 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4541 d[i * 4 + 0] = 0xffff;
4549 pack_P010_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4550 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4551 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4555 gint uv = GET_UV_420 (y, flags);
4556 guint16 *restrict dy = GET_PLANE_LINE (0, y);
4557 guint16 *restrict duv = GET_PLANE_LINE (1, uv);
4558 guint16 Y0, Y1, U, V;
4559 const guint16 *restrict s = src;
4561 if (IS_CHROMA_LINE_420 (y, flags)) {
4562 for (i = 0; i < width / 2; i++) {
4563 Y0 = s[i * 8 + 1] & 0xffc0;
4564 Y1 = s[i * 8 + 5] & 0xffc0;
4565 U = s[i * 8 + 2] & 0xffc0;
4566 V = s[i * 8 + 3] & 0xffc0;
4568 GST_WRITE_UINT16_BE (dy + i * 2 + 0, Y0);
4569 GST_WRITE_UINT16_BE (dy + i * 2 + 1, Y1);
4570 GST_WRITE_UINT16_BE (duv + i * 2 + 0, U);
4571 GST_WRITE_UINT16_BE (duv + i * 2 + 1, V);
4576 Y0 = s[i * 4 + 1] & 0xffc0;
4577 U = s[i * 4 + 2] & 0xffc0;
4578 V = s[i * 4 + 3] & 0xffc0;
4580 GST_WRITE_UINT16_BE (dy + i, Y0);
4581 GST_WRITE_UINT16_BE (duv + i + 0, U);
4582 GST_WRITE_UINT16_BE (duv + i + 1, V);
4585 for (i = 0; i < width; i++) {
4586 Y0 = s[i * 4 + 1] & 0xffc0;
4587 GST_WRITE_UINT16_BE (dy + i, Y0);
4592 #define PACK_P010_10LE GST_VIDEO_FORMAT_AYUV64, unpack_P010_10LE, 1, pack_P010_10LE
4594 unpack_P010_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4595 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4596 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4599 gint uv = GET_UV_420 (y, flags);
4600 const guint16 *restrict sy = GET_PLANE_LINE (0, y);
4601 const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
4602 guint16 *restrict d = dest, Y0, Y1, U, V;
4608 Y0 = GST_READ_UINT16_LE (sy);
4609 U = GST_READ_UINT16_LE (suv);
4610 V = GST_READ_UINT16_LE (suv + 1);
4612 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4628 for (i = 0; i < width / 2; i++) {
4629 Y0 = GST_READ_UINT16_LE (sy + 2 * i);
4630 Y1 = GST_READ_UINT16_LE (sy + 2 * i + 1);
4631 U = GST_READ_UINT16_LE (suv + 2 * i);
4632 V = GST_READ_UINT16_LE (suv + 2 * i + 1);
4634 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4641 d[i * 8 + 0] = 0xffff;
4645 d[i * 8 + 4] = 0xffff;
4654 Y0 = GST_READ_UINT16_LE (sy + i);
4655 U = GST_READ_UINT16_LE (suv + i);
4656 V = GST_READ_UINT16_LE (suv + i + 1);
4658 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4664 d[i * 4 + 0] = 0xffff;
4672 pack_P010_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4673 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4674 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4678 gint uv = GET_UV_420 (y, flags);
4679 guint16 *restrict dy = GET_PLANE_LINE (0, y);
4680 guint16 *restrict duv = GET_PLANE_LINE (1, uv);
4681 guint16 Y0, Y1, U, V;
4682 const guint16 *restrict s = src;
4684 if (IS_CHROMA_LINE_420 (y, flags)) {
4685 for (i = 0; i < width / 2; i++) {
4686 Y0 = s[i * 8 + 1] & 0xffc0;
4687 Y1 = s[i * 8 + 5] & 0xffc0;
4688 U = s[i * 8 + 2] & 0xffc0;
4689 V = s[i * 8 + 3] & 0xffc0;
4691 GST_WRITE_UINT16_LE (dy + i * 2 + 0, Y0);
4692 GST_WRITE_UINT16_LE (dy + i * 2 + 1, Y1);
4693 GST_WRITE_UINT16_LE (duv + i * 2 + 0, U);
4694 GST_WRITE_UINT16_LE (duv + i * 2 + 1, V);
4699 Y0 = s[i * 4 + 1] & 0xffc0;
4700 U = s[i * 4 + 2] & 0xffc0;
4701 V = s[i * 4 + 3] & 0xffc0;
4703 GST_WRITE_UINT16_LE (dy + i, Y0);
4704 GST_WRITE_UINT16_LE (duv + i + 0, U);
4705 GST_WRITE_UINT16_LE (duv + i + 1, V);
4708 for (i = 0; i < width; i++) {
4709 Y0 = s[i * 4 + 1] & 0xffc0;
4710 GST_WRITE_UINT16_LE (dy + i, Y0);
4715 #define PACK_GRAY10_LE32 GST_VIDEO_FORMAT_AYUV64, unpack_GRAY10_LE32, 1, pack_GRAY10_LE32
4717 unpack_GRAY10_LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4718 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4719 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4722 const guint32 *restrict sy = GET_PLANE_LINE (0, y);
4723 guint16 *restrict d = dest;
4724 gint num_words = (width + 2) / 3;
4726 /* Y data is packed into little endian 32bit words, with the 2 MSB being
4727 * padding. There is only 1 pattern.
4728 * -> padding | Y1 | Y2 | Y3
4731 for (i = 0; i < num_words; i++) {
4732 gint num_comps = MIN (3, width - i * 3);
4734 gsize doff = pix * 4;
4738 Y = GST_READ_UINT32_LE (sy + i);
4740 for (c = 0; c < num_comps; c++) {
4743 /* For Y, we simply read 10 bit and shift it out */
4744 Yn = (Y & 0x03ff) << 6;
4747 if (G_UNLIKELY (pix + c < x))
4750 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE))
4753 d[doff + 0] = 0xffff;
4755 d[doff + 2] = 0x8000;
4756 d[doff + 3] = 0x8000;
4764 pack_GRAY10_LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4765 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4766 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4770 guint32 *restrict dy = GET_PLANE_LINE (0, y);
4771 const guint16 *restrict s = src;
4772 gint num_words = (width + 2) / 3;
4774 for (i = 0; i < num_words; i++) {
4775 gint num_comps = MIN (3, width - i * 3);
4777 gsize soff = pix * 4;
4781 for (c = 0; c < num_comps; c++) {
4782 Y |= s[soff + 1] >> 6 << (10 * c);
4786 GST_WRITE_UINT32_LE (dy + i, Y);
4790 #define PACK_NV12_10LE32 GST_VIDEO_FORMAT_AYUV64, unpack_NV12_10LE32, 1, pack_NV12_10LE32
4792 unpack_NV12_10LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4793 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4794 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4797 gint uv = GET_UV_420 (y, flags);
4798 const guint32 *restrict sy = GET_PLANE_LINE (0, y);
4799 const guint32 *restrict suv = GET_PLANE_LINE (1, uv);
4800 guint16 *restrict d = dest;
4801 gint num_words = (width + 2) / 3;
4803 guint16 Un = 0, Vn = 0;
4805 /* Y data is packed into little endian 32bit words, with the 2 MSB being
4806 * padding. There is only 1 pattern.
4807 * -> padding | Y1 | Y2 | Y3
4809 * UV is packed the same way, though we end up with 2 patterns:
4810 * -> U | V | U | padding
4811 * -> V | U | V | padding
4814 /* FIXME unroll the 6 states ? */
4816 for (i = 0; i < num_words; i++) {
4817 gint num_comps = MIN (3, width - i * 3);
4819 gsize doff = pix * 4;
4823 Y = GST_READ_UINT32_LE (sy + i);
4825 for (c = 0; c < num_comps; c++) {
4828 /* For Y, we simply read 10 bit and shift it out */
4829 Yn = (Y & 0x03ff) << 6;
4832 /* Unpacking UV has been reduced to a cycle of 6 states. The following
4833 * code is a reduce version of:
4834 * 0: - Read first UV word (UVU)
4836 * 1: - Resued U/V from 1 (sub-sampling)
4837 * 2: - Unpack remaining U value
4838 * - Read following UV word (VUV)
4840 * 3: - Reuse U/V from 2 (sub-sampling)
4841 * 4: - Unpack remaining U
4842 * - Unpack remaining V
4843 * 5: - Reuse UV/V from 4 (sub-sampling)
4845 switch ((pix + c) % 6) {
4847 UV = GST_READ_UINT32_LE (suv + i);
4850 Un = (UV & 0x03ff) << 6;
4852 Vn = (UV & 0x03ff) << 6;
4856 Un = (UV & 0x03ff) << 6;
4857 UV = GST_READ_UINT32_LE (suv + i + 1);
4858 Vn = (UV & 0x03ff) << 6;
4866 if (G_UNLIKELY (pix + c < x))
4869 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4875 d[doff + 0] = 0xffff;
4886 pack_NV12_10LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4887 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4888 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4892 gint uv = GET_UV_420 (y, flags);
4893 guint32 *restrict dy = GET_PLANE_LINE (0, y);
4894 guint32 *restrict duv = GET_PLANE_LINE (1, uv);
4895 const guint16 *restrict s = src;
4896 gint num_words = (width + 2) / 3;
4899 /* FIXME unroll the 6 states ? */
4901 for (i = 0; i < num_words; i++) {
4902 gint num_comps = MIN (3, width - i * 3);
4904 gsize soff = pix * 4;
4908 for (c = 0; c < num_comps; c++) {
4909 Y |= s[soff + 1] >> 6 << (10 * c);
4911 if (IS_CHROMA_LINE_420 (y, flags)) {
4912 switch ((pix + c) % 6) {
4914 UV = s[soff + 2] >> 6;
4915 UV |= s[soff + 3] >> 6 << 10;
4918 UV |= s[soff + 2] >> 6 << 20;
4919 GST_WRITE_UINT32_LE (duv + i, UV);
4920 UV = s[soff + 3] >> 6;
4923 UV |= s[soff + 2] >> 6 << 10;
4924 UV |= s[soff + 3] >> 6 << 20;
4925 GST_WRITE_UINT32_LE (duv + i, UV);
4936 GST_WRITE_UINT32_LE (dy + i, Y);
4938 if (IS_CHROMA_LINE_420 (y, flags) && num_comps < 3)
4939 GST_WRITE_UINT32_LE (duv + i, UV);
4944 #define PACK_NV16_10LE32 GST_VIDEO_FORMAT_AYUV64, unpack_NV16_10LE32, 1, pack_NV16_10LE32
4946 unpack_NV16_10LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4947 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4948 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4951 const guint32 *restrict sy = GET_PLANE_LINE (0, y);
4952 const guint32 *restrict suv = GET_PLANE_LINE (1, y);
4953 guint16 *restrict d = dest;
4954 gint num_words = (width + 2) / 3;
4956 guint16 Un = 0, Vn = 0;
4958 /* Y data is packed into little endian 32bit words, with the 2 MSB being
4959 * padding. There is only 1 pattern.
4960 * -> padding | Y1 | Y2 | Y3
4962 * UV is packed the same way, though we end up with 2 patterns:
4963 * -> U | V | U | padding
4964 * -> V | U | V | padding
4967 /* FIXME unroll the 6 states ? */
4969 for (i = 0; i < num_words; i++) {
4970 gint num_comps = MIN (3, width - i * 3);
4972 gsize doff = pix * 4;
4976 Y = GST_READ_UINT32_LE (sy + i);
4978 for (c = 0; c < num_comps; c++) {
4981 /* For Y, we simply read 10 bit and shift it out */
4982 Yn = (Y & 0x03ff) << 6;
4985 /* Unpacking UV has been reduced to a cycle of 6 states. The following
4986 * code is a reduce version of:
4987 * 0: - Read first UV word (UVU)
4989 * 1: - Resued U/V from 1 (sub-sampling)
4990 * 2: - Unpack remaining U value
4991 * - Read following UV word (VUV)
4993 * 3: - Reuse U/V from 2 (sub-sampling)
4994 * 4: - Unpack remaining U
4995 * - Unpack remaining V
4996 * 5: - Reuse UV/V from 4 (sub-sampling)
4998 switch ((pix + c) % 6) {
5000 UV = GST_READ_UINT32_LE (suv + i);
5003 Un = (UV & 0x03ff) << 6;
5005 Vn = (UV & 0x03ff) << 6;
5009 Un = (UV & 0x03ff) << 6;
5010 UV = GST_READ_UINT32_LE (suv + i + 1);
5011 Vn = (UV & 0x03ff) << 6;
5019 if (G_UNLIKELY (pix + c < x))
5022 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
5028 d[doff + 0] = 0xffff;
5039 pack_NV16_10LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5040 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5041 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5045 guint32 *restrict dy = GET_PLANE_LINE (0, y);
5046 guint32 *restrict duv = GET_PLANE_LINE (1, y);
5047 const guint16 *restrict s = src;
5048 gint num_words = (width + 2) / 3;
5051 /* FIXME unroll the 6 states ? */
5053 for (i = 0; i < num_words; i++) {
5054 gint num_comps = MIN (3, width - i * 3);
5056 gsize soff = pix * 4;
5060 for (c = 0; c < num_comps; c++) {
5061 Y |= s[soff + 1] >> 6 << (10 * c);
5063 switch ((pix + c) % 6) {
5065 UV = s[soff + 2] >> 6;
5066 UV |= s[soff + 3] >> 6 << 10;
5069 UV |= s[soff + 2] >> 6 << 20;
5070 GST_WRITE_UINT32_LE (duv + i, UV);
5071 UV = s[soff + 3] >> 6;
5074 UV |= s[soff + 2] >> 6 << 10;
5075 UV |= s[soff + 3] >> 6 << 20;
5076 GST_WRITE_UINT32_LE (duv + i, UV);
5086 GST_WRITE_UINT32_LE (dy + i, Y);
5089 GST_WRITE_UINT32_LE (duv + i, UV);
5093 #define PACK_NV12_10LE40 GST_VIDEO_FORMAT_AYUV64, unpack_NV12_10LE40, 1, pack_NV12_10LE40
5095 unpack_NV12_10LE40 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5096 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
5097 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
5100 gint uv = GET_UV_420 (y, flags);
5101 guint16 *restrict d = dest;
5102 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
5103 const guint8 *restrict suv = GET_PLANE_LINE (1, uv);
5104 guint16 Y0 = 0, Y1 = 0, Yn = 0, Un = 0, Vn = 0;
5107 for (i = 0; i < width; i++) {
5108 gboolean update_c = FALSE;
5112 Y0 = GST_READ_UINT16_LE (sy);
5116 UV = GST_READ_UINT32_LE (suv);
5118 Vn = (UV >> 10) & 0x3ff;
5127 Y1 = GST_READ_UINT16_LE (sy);
5128 Yn = (Y0 >> 10) | ((Y1 & 0xf) << 6);
5134 Yn = (Y1 >> 4) & 0x3ff;
5136 Un = (UV >> 20) & 0x3ff;
5138 UV = GST_READ_UINT8 (suv);
5148 Y0 = GST_READ_UINT8 (sy);
5149 Yn = (Y1 >> 14) | (Y0 << 2);
5156 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
5164 d[i * 4 + 0] = 0xffff;
5172 pack_NV12_10LE40 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5173 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5174 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5178 gint uv = GET_UV_420 (y, flags);
5179 guint8 *restrict dy = GET_PLANE_LINE (0, y);
5180 guint8 *restrict duv = GET_PLANE_LINE (1, uv);
5181 guint16 Y0 = 0, Y1 = 0, Y2 = 0, Y3 = 0, U0, V0 = 0, U1 = 0, V1 = 0;
5182 const guint16 *restrict s = src;
5184 for (i = 0; i < width; i++) {
5187 Y0 = s[i * 4 + 1] >> 6;
5188 GST_WRITE_UINT8 (dy, Y0 & 0xff);
5191 if (IS_CHROMA_LINE_420 (y, flags)) {
5192 U0 = s[i * 4 + 2] >> 6;
5193 V0 = s[i * 4 + 3] >> 6;
5195 GST_WRITE_UINT8 (duv, U0 & 0xff);
5198 GST_WRITE_UINT8 (duv, (U0 >> 8) | ((V0 & 0x3f) << 2));
5203 Y1 = s[i * 4 + 1] >> 6;
5204 GST_WRITE_UINT8 (dy, (Y0 >> 8) | ((Y1 & 0x3f) << 2));
5208 Y2 = s[i * 4 + 1] >> 6;
5209 GST_WRITE_UINT8 (dy, (Y1 >> 6) | ((Y2 & 0xf) << 4));
5212 if (IS_CHROMA_LINE_420 (y, flags)) {
5213 U1 = s[i * 4 + 2] >> 6;
5214 V1 = s[i * 4 + 3] >> 6;
5216 GST_WRITE_UINT8 (duv, (V0 >> 6) | ((U1 & 0xf) << 4));
5219 GST_WRITE_UINT8 (duv, (U1 >> 4) | ((V1 & 0x3) << 6));
5222 GST_WRITE_UINT8 (duv, V1 >> 2);
5227 Y3 = s[i * 4 + 1] >> 6;
5228 GST_WRITE_UINT8 (dy, (Y2 >> 4) | ((Y3 & 0x3) << 6));
5230 GST_WRITE_UINT8 (dy, (Y3 >> 2));
5236 switch (width & 3) {
5240 GST_WRITE_UINT8 (dy, Y0 >> 8);
5241 if (IS_CHROMA_LINE_420 (y, flags))
5242 GST_WRITE_UINT8 (duv, V0 >> 6);
5245 GST_WRITE_UINT8 (dy, Y1 >> 6);
5246 if (IS_CHROMA_LINE_420 (y, flags))
5247 GST_WRITE_UINT8 (duv, V0 >> 6);
5250 GST_WRITE_UINT8 (dy, Y2 >> 4);
5255 #define PACK_VUYA GST_VIDEO_FORMAT_AYUV, unpack_VUYA, 1, pack_VUYA
5257 unpack_VUYA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5258 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
5259 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
5261 const guint8 *restrict s = GET_LINE (y);
5262 guint8 *restrict d = dest;
5266 video_orc_unpack_VUYA (d, s, width);
5270 pack_VUYA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5271 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5272 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5275 const guint8 *restrict s = src;
5276 guint8 *restrict d = GET_LINE (y);
5278 video_orc_pack_VUYA (d, s, width);
5281 #define PACK_BGR10A2_LE GST_VIDEO_FORMAT_ARGB64, unpack_bgr10a2_le, 1, pack_bgr10a2_le
5283 unpack_bgr10a2_le (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5284 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
5285 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
5288 const guint8 *restrict s = GET_LINE (y);
5289 guint16 *restrict d = dest;
5295 for (i = 0; i < width; i++) {
5296 ARGB = GST_READ_UINT32_LE (s + 4 * i);
5298 B = ((ARGB >> 0) & 0x3ff) << 6;
5299 G = ((ARGB >> 10) & 0x3ff) << 6;
5300 R = ((ARGB >> 20) & 0x3ff) << 6;
5301 A = ((ARGB >> 30) & 0x03) << 14;
5303 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
5318 pack_bgr10a2_le (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5319 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5320 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5324 guint32 *restrict d = GET_LINE (y);
5325 const guint16 *restrict s = src;
5329 for (i = 0; i < width; i++) {
5330 A = s[4 * i] & 0xc000;
5331 R = s[4 * i + 1] & 0xffc0;
5332 G = s[4 * i + 2] & 0xffc0;
5333 B = s[4 * i + 3] & 0xffc0;
5335 ARGB = (B >> 6) | (G << 4) | (R << 14) | (A << 16);
5337 GST_WRITE_UINT32_LE (d + i, ARGB);
5341 #define PACK_RGB10A2_LE GST_VIDEO_FORMAT_ARGB64, unpack_rgb10a2_le, 1, pack_rgb10a2_le
5343 unpack_rgb10a2_le (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5344 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
5345 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
5348 const guint8 *restrict s = GET_LINE (y);
5349 guint16 *restrict d = dest;
5355 for (i = 0; i < width; i++) {
5356 ARGB = GST_READ_UINT32_LE (s + 4 * i);
5358 R = ((ARGB >> 0) & 0x3ff) << 6;
5359 G = ((ARGB >> 10) & 0x3ff) << 6;
5360 B = ((ARGB >> 20) & 0x3ff) << 6;
5361 A = ((ARGB >> 30) & 0x03) << 14;
5363 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
5378 pack_rgb10a2_le (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5379 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5380 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5384 guint32 *restrict d = GET_LINE (y);
5385 const guint16 *restrict s = src;
5389 for (i = 0; i < width; i++) {
5390 A = s[4 * i] & 0xc000;
5391 R = s[4 * i + 1] & 0xffc0;
5392 G = s[4 * i + 2] & 0xffc0;
5393 B = s[4 * i + 3] & 0xffc0;
5395 ARGB = (R >> 6) | (G << 4) | (B << 14) | (A << 16);
5397 GST_WRITE_UINT32_LE (d + i, ARGB);
5404 GstVideoFormatInfo info;
5407 /* depths: bits, n_components, shift, depth */
5408 #define DPTH0 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5409 #define DPTH8 8, 1, { 0, 0, 0, 0 }, { 8, 0, 0, 0 }
5410 #define DPTH8_32 8, 2, { 0, 0, 0, 0 }, { 8, 32, 0, 0 }
5411 #define DPTH888 8, 3, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
5412 #define DPTH8888 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 8 }
5413 #define DPTH8880 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
5414 #define DPTH10 10, 1, { 0, 0, 0, 0 }, { 10, 0, 0, 0 }
5415 #define DPTH10_10_10 10, 3, { 0, 0, 0, 0 }, { 10, 10, 10, 0 }
5416 #define DPTH10_10_10_10 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 10 }
5417 #define DPTH10_10_10_HI 16, 3, { 6, 6, 6, 0 }, { 10, 10, 10, 0 }
5418 #define DPTH10_10_10_2 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 2}
5419 #define DPTH12_12_12 12, 3, { 0, 0, 0, 0 }, { 12, 12, 12, 0 }
5420 #define DPTH12_12_12_12 12, 4, { 0, 0, 0, 0 }, { 12, 12, 12, 12 }
5421 #define DPTH16 16, 1, { 0, 0, 0, 0 }, { 16, 0, 0, 0 }
5422 #define DPTH16_16_16 16, 3, { 0, 0, 0, 0 }, { 16, 16, 16, 0 }
5423 #define DPTH16_16_16_16 16, 4, { 0, 0, 0, 0 }, { 16, 16, 16, 16 }
5424 #define DPTH555 16, 3, { 10, 5, 0, 0 }, { 5, 5, 5, 0 }
5425 #define DPTH565 16, 3, { 11, 5, 0, 0 }, { 5, 6, 5, 0 }
5428 #define PSTR0 { 0, 0, 0, 0 }
5429 #define PSTR1 { 1, 0, 0, 0 }
5430 #define PSTR14 { 1, 4, 0, 0 }
5431 #define PSTR111 { 1, 1, 1, 0 }
5432 #define PSTR1111 { 1, 1, 1, 1 }
5433 #define PSTR122 { 1, 2, 2, 0 }
5434 #define PSTR2 { 2, 0, 0, 0 }
5435 #define PSTR222 { 2, 2, 2, 0 }
5436 #define PSTR2222 { 2, 2, 2, 2 }
5437 #define PSTR244 { 2, 4, 4, 0 }
5438 #define PSTR444 { 4, 4, 4, 0 }
5439 #define PSTR4444 { 4, 4, 4, 4 }
5440 #define PSTR333 { 3, 3, 3, 0 }
5441 #define PSTR488 { 4, 8, 8, 0 }
5442 #define PSTR8888 { 8, 8, 8, 8 }
5444 /* planes, in what plane do we find component N */
5445 #define PLANE_NA 0, { 0, 0, 0, 0 }
5446 #define PLANE0 1, { 0, 0, 0, 0 }
5447 #define PLANE01 2, { 0, 1, 0, 0 }
5448 #define PLANE011 2, { 0, 1, 1, 0 }
5449 #define PLANE012 3, { 0, 1, 2, 0 }
5450 #define PLANE0123 4, { 0, 1, 2, 3 }
5451 #define PLANE021 3, { 0, 2, 1, 0 }
5452 #define PLANE201 3, { 2, 0, 1, 0 }
5453 #define PLANE2013 4, { 2, 0, 1, 3 }
5456 #define OFFS0 { 0, 0, 0, 0 }
5457 #define OFFS013 { 0, 1, 3, 0 }
5458 #define OFFS102 { 1, 0, 2, 0 }
5459 #define OFFS1230 { 1, 2, 3, 0 }
5460 #define OFFS012 { 0, 1, 2, 0 }
5461 #define OFFS210 { 2, 1, 0, 0 }
5462 #define OFFS123 { 1, 2, 3, 0 }
5463 #define OFFS321 { 3, 2, 1, 0 }
5464 #define OFFS0123 { 0, 1, 2, 3 }
5465 #define OFFS2103 { 2, 1, 0, 3 }
5466 #define OFFS3210 { 3, 2, 1, 0 }
5467 #define OFFS031 { 0, 3, 1, 0 }
5468 #define OFFS204 { 2, 0, 4, 0 }
5469 #define OFFS001 { 0, 0, 1, 0 }
5470 #define OFFS010 { 0, 1, 0, 0 }
5471 #define OFFS104 { 1, 0, 4, 0 }
5472 #define OFFS2460 { 2, 4, 6, 0 }
5474 /* subsampling, w_sub, h_sub */
5475 #define SUB410 { 0, 2, 2, 0 }, { 0, 2, 2, 0 }
5476 #define SUB411 { 0, 2, 2, 0 }, { 0, 0, 0, 0 }
5477 #define SUB420 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
5478 #define SUB422 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
5479 #define SUB4 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5480 #define SUB44 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5481 #define SUB444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5482 #define SUB4444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5483 #define SUB4204 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
5484 #define SUB4224 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
5486 /* tile_mode, tile_width, tile_height */
5487 #define TILE_64x32(mode) GST_VIDEO_TILE_MODE_ ##mode, 6, 5
5489 #define MAKE_YUV_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5490 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV, depth, pstride, plane, offs, sub, pack } }
5491 #define MAKE_YUV_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5492 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5493 #define MAKE_YUVA_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5494 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA, depth, pstride, plane, offs, sub, pack } }
5495 #define MAKE_YUVA_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5496 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5497 #define MAKE_YUVA_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5498 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK, depth, pstride, plane, offs, sub, pack } }
5499 #define MAKE_YUVA_LE_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5500 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5501 #define MAKE_YUV_C_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5502 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX, depth, pstride, plane, offs, sub, pack } }
5503 #define MAKE_YUV_C_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5504 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5505 #define MAKE_YUV_T_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack, tile) \
5506 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV | GST_VIDEO_FORMAT_FLAG_COMPLEX | GST_VIDEO_FORMAT_FLAG_TILED, depth, pstride, plane, offs, sub, pack, tile } }
5508 #define MAKE_RGB_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5509 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB, depth, pstride, plane, offs, sub, pack } }
5510 #define MAKE_RGB_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5511 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5512 #define MAKE_RGBA_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5513 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA, depth, pstride, plane, offs, sub, pack } }
5514 #define MAKE_RGBA_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5515 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5516 #define MAKE_RGBAP_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5517 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_PALETTE, depth, pstride, plane, offs, sub, pack } }
5518 #define MAKE_RGBA_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5519 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK, depth, pstride, plane, offs, sub, pack } }
5520 #define MAKE_RGBA_LE_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5521 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB | GST_VIDEO_FORMAT_FLAG_ALPHA | GST_VIDEO_FORMAT_FLAG_UNPACK | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5523 #define MAKE_GRAY_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5524 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY, depth, pstride, plane, offs, sub, pack } }
5525 #define MAKE_GRAY_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5526 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5527 #define MAKE_GRAY_C_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5528 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY | GST_VIDEO_FORMAT_FLAG_COMPLEX | GST_VIDEO_FORMAT_FLAG_LE, depth, pstride, plane, offs, sub, pack } }
5530 static const VideoFormat formats[] = {
5531 {0x00000000, {GST_VIDEO_FORMAT_UNKNOWN, "UNKNOWN", "unknown video", 0, DPTH0,
5532 PSTR0, PLANE_NA, OFFS0}},
5533 {0x00000000, {GST_VIDEO_FORMAT_ENCODED, "ENCODED", "encoded video",
5534 GST_VIDEO_FORMAT_FLAG_COMPLEX, DPTH0, PSTR0, PLANE_NA, OFFS0}},
5536 MAKE_YUV_FORMAT (I420, "raw video", GST_MAKE_FOURCC ('I', '4', '2', '0'),
5537 DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
5538 MAKE_YUV_FORMAT (YV12, "raw video", GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
5539 DPTH888, PSTR111, PLANE021, OFFS0, SUB420, PACK_420),
5540 MAKE_YUV_FORMAT (YUY2, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
5541 DPTH888, PSTR244, PLANE0, OFFS013, SUB422, PACK_YUY2),
5542 MAKE_YUV_FORMAT (UYVY, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'),
5543 DPTH888, PSTR244, PLANE0, OFFS102, SUB422, PACK_UYVY),
5544 MAKE_YUVA_PACK_FORMAT (AYUV, "raw video", GST_MAKE_FOURCC ('A', 'Y', 'U',
5545 'V'), DPTH8888, PSTR4444, PLANE0, OFFS1230, SUB4444, PACK_AYUV),
5546 MAKE_RGB_FORMAT (RGBx, "raw video", DPTH888, PSTR444, PLANE0, OFFS012,
5548 MAKE_RGB_FORMAT (BGRx, "raw video", DPTH888, PSTR444, PLANE0, OFFS210,
5550 MAKE_RGB_FORMAT (xRGB, "raw video", DPTH888, PSTR444, PLANE0, OFFS123,
5552 MAKE_RGB_FORMAT (xBGR, "raw video", DPTH888, PSTR444, PLANE0, OFFS321,
5554 MAKE_RGBA_FORMAT (RGBA, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS0123,
5555 SUB4444, PACK_RGBA),
5556 MAKE_RGBA_FORMAT (BGRA, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS2103,
5557 SUB4444, PACK_BGRA),
5558 MAKE_RGBA_PACK_FORMAT (ARGB, "raw video", DPTH8888, PSTR4444, PLANE0,
5559 OFFS1230, SUB4444, PACK_ARGB),
5560 MAKE_RGBA_FORMAT (ABGR, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS3210,
5561 SUB4444, PACK_ABGR),
5562 MAKE_RGB_FORMAT (RGB, "raw video", DPTH888, PSTR333, PLANE0, OFFS012, SUB444,
5564 MAKE_RGB_FORMAT (BGR, "raw video", DPTH888, PSTR333, PLANE0, OFFS210, SUB444,
5567 MAKE_YUV_FORMAT (Y41B, "raw video", GST_MAKE_FOURCC ('Y', '4', '1', 'B'),
5568 DPTH888, PSTR111, PLANE012, OFFS0, SUB411, PACK_Y41B),
5569 MAKE_YUV_FORMAT (Y42B, "raw video", GST_MAKE_FOURCC ('Y', '4', '2', 'B'),
5570 DPTH888, PSTR111, PLANE012, OFFS0, SUB422, PACK_Y42B),
5571 MAKE_YUV_FORMAT (YVYU, "raw video", GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'),
5572 DPTH888, PSTR244, PLANE0, OFFS031, SUB422, PACK_YVYU),
5573 MAKE_YUV_FORMAT (Y444, "raw video", GST_MAKE_FOURCC ('Y', '4', '4', '4'),
5574 DPTH888, PSTR111, PLANE012, OFFS0, SUB444, PACK_Y444),
5575 MAKE_YUV_C_FORMAT (v210, "raw video", GST_MAKE_FOURCC ('v', '2', '1', '0'),
5576 DPTH10_10_10, PSTR0, PLANE0, OFFS0, SUB422, PACK_v210),
5577 MAKE_YUV_FORMAT (v216, "raw video", GST_MAKE_FOURCC ('v', '2', '1', '6'),
5578 DPTH16_16_16, PSTR488, PLANE0, OFFS204, SUB422, PACK_v216),
5579 MAKE_YUV_FORMAT (NV12, "raw video", GST_MAKE_FOURCC ('N', 'V', '1', '2'),
5580 DPTH888, PSTR122, PLANE011, OFFS001, SUB420, PACK_NV12),
5581 MAKE_YUV_FORMAT (NV21, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '1'),
5582 DPTH888, PSTR122, PLANE011, OFFS010, SUB420, PACK_NV21),
5584 MAKE_GRAY_FORMAT (GRAY8, "raw video", DPTH8, PSTR1, PLANE0, OFFS0, SUB4,
5586 MAKE_GRAY_FORMAT (GRAY16_BE, "raw video", DPTH16, PSTR2, PLANE0, OFFS0, SUB4,
5588 MAKE_GRAY_LE_FORMAT (GRAY16_LE, "raw video", DPTH16, PSTR2, PLANE0, OFFS0,
5589 SUB4, PACK_GRAY16_LE),
5591 MAKE_YUV_FORMAT (v308, "raw video", GST_MAKE_FOURCC ('v', '3', '0', '8'),
5592 DPTH888, PSTR333, PLANE0, OFFS012, SUB444, PACK_v308),
5594 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
5595 MAKE_RGB_LE_FORMAT (RGB16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0,
5596 SUB444, PACK_RGB16),
5597 MAKE_RGB_LE_FORMAT (BGR16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0,
5598 SUB444, PACK_BGR16),
5599 MAKE_RGB_LE_FORMAT (RGB15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0,
5600 SUB444, PACK_RGB15),
5601 MAKE_RGB_LE_FORMAT (BGR15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0,
5602 SUB444, PACK_BGR15),
5604 MAKE_RGB_FORMAT (RGB16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0, SUB444,
5606 MAKE_RGB_FORMAT (BGR16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0, SUB444,
5608 MAKE_RGB_FORMAT (RGB15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0, SUB444,
5610 MAKE_RGB_FORMAT (BGR15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0, SUB444,
5614 MAKE_YUV_C_FORMAT (UYVP, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'),
5615 DPTH10_10_10, PSTR0, PLANE0, OFFS0, SUB422, PACK_UYVP),
5616 MAKE_YUVA_FORMAT (A420, "raw video", GST_MAKE_FOURCC ('A', '4', '2', '0'),
5617 DPTH8888, PSTR1111, PLANE0123, OFFS0, SUB4204, PACK_A420),
5618 MAKE_RGBAP_FORMAT (RGB8P, "raw video", DPTH8_32, PSTR14, PLANE01,
5619 OFFS0, SUB44, PACK_RGB8P),
5620 MAKE_YUV_FORMAT (YUV9, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'V', '9'),
5621 DPTH888, PSTR111, PLANE012, OFFS0, SUB410, PACK_410),
5622 MAKE_YUV_FORMAT (YVU9, "raw video", GST_MAKE_FOURCC ('Y', 'V', 'U', '9'),
5623 DPTH888, PSTR111, PLANE021, OFFS0, SUB410, PACK_410),
5624 MAKE_YUV_FORMAT (IYU1, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '1'),
5625 DPTH888, PSTR0, PLANE0, OFFS104, SUB411, PACK_IYU1),
5626 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
5627 MAKE_RGBA_LE_PACK_FORMAT (ARGB64, "raw video", DPTH16_16_16_16, PSTR8888,
5629 OFFS2460, SUB444, PACK_ARGB64),
5630 MAKE_YUVA_LE_PACK_FORMAT (AYUV64, "raw video", 0x00000000, DPTH16_16_16_16,
5631 PSTR8888, PLANE0, OFFS2460, SUB444, PACK_AYUV64),
5633 MAKE_RGBA_PACK_FORMAT (ARGB64, "raw video", DPTH16_16_16_16, PSTR8888, PLANE0,
5634 OFFS2460, SUB444, PACK_ARGB64),
5635 MAKE_YUVA_PACK_FORMAT (AYUV64, "raw video", 0x00000000, DPTH16_16_16_16,
5636 PSTR8888, PLANE0, OFFS2460, SUB444, PACK_AYUV64),
5638 MAKE_RGB_FORMAT (r210, "raw video", DPTH10_10_10, PSTR444, PLANE0, OFFS0,
5640 MAKE_YUV_FORMAT (I420_10BE, "raw video", 0x00000000, DPTH10_10_10,
5641 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10BE),
5642 MAKE_YUV_LE_FORMAT (I420_10LE, "raw video", 0x00000000, DPTH10_10_10,
5643 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10LE),
5644 MAKE_YUV_FORMAT (I422_10BE, "raw video", 0x00000000, DPTH10_10_10,
5645 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10BE),
5646 MAKE_YUV_LE_FORMAT (I422_10LE, "raw video", 0x00000000, DPTH10_10_10,
5647 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10LE),
5648 MAKE_YUV_FORMAT (Y444_10BE, "raw video", 0x00000000, DPTH10_10_10,
5649 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10BE),
5650 MAKE_YUV_LE_FORMAT (Y444_10LE, "raw video", 0x00000000, DPTH10_10_10,
5651 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10LE),
5652 MAKE_RGB_FORMAT (GBR, "raw video", DPTH888, PSTR111, PLANE201, OFFS0, SUB444,
5654 MAKE_RGB_FORMAT (GBR_10BE, "raw video", DPTH10_10_10, PSTR222, PLANE201,
5655 OFFS0, SUB444, PACK_GBR_10BE),
5656 MAKE_RGB_LE_FORMAT (GBR_10LE, "raw video", DPTH10_10_10, PSTR222, PLANE201,
5657 OFFS0, SUB444, PACK_GBR_10LE),
5658 MAKE_YUV_FORMAT (NV16, "raw video", GST_MAKE_FOURCC ('N', 'V', '1', '6'),
5659 DPTH888, PSTR122, PLANE011, OFFS001, SUB422, PACK_NV16),
5660 MAKE_YUV_FORMAT (NV24, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '4'),
5661 DPTH888, PSTR122, PLANE011, OFFS001, SUB444, PACK_NV24),
5662 MAKE_YUV_T_FORMAT (NV12_64Z32, "raw video",
5663 GST_MAKE_FOURCC ('T', 'M', '1', '2'), DPTH8880, PSTR122, PLANE011,
5664 OFFS001, SUB420, PACK_NV12_64Z32, TILE_64x32 (ZFLIPZ_2X2)),
5665 MAKE_YUVA_FORMAT (A420_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5666 PSTR2222, PLANE0123, OFFS0, SUB4204, PACK_A420_10BE),
5667 MAKE_YUVA_LE_FORMAT (A420_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5668 PSTR2222, PLANE0123, OFFS0, SUB4204, PACK_A420_10LE),
5669 MAKE_YUVA_FORMAT (A422_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5670 PSTR2222, PLANE0123, OFFS0, SUB4224, PACK_A422_10BE),
5671 MAKE_YUVA_LE_FORMAT (A422_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5672 PSTR2222, PLANE0123, OFFS0, SUB4224, PACK_A422_10LE),
5673 MAKE_YUVA_FORMAT (A444_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5674 PSTR2222, PLANE0123, OFFS0, SUB4444, PACK_A444_10BE),
5675 MAKE_YUVA_LE_FORMAT (A444_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5676 PSTR2222, PLANE0123, OFFS0, SUB4444, PACK_A444_10LE),
5677 MAKE_YUV_FORMAT (NV61, "raw video", GST_MAKE_FOURCC ('N', 'V', '6', '1'),
5678 DPTH888, PSTR122, PLANE011, OFFS010, SUB422, PACK_NV61),
5679 MAKE_YUV_FORMAT (P010_10BE, "raw video", 0x00000000, DPTH10_10_10_HI,
5680 PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10BE),
5681 MAKE_YUV_LE_FORMAT (P010_10LE, "raw video", 0x00000000, DPTH10_10_10_HI,
5682 PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10LE),
5683 MAKE_YUV_FORMAT (IYU2, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '2'),
5684 DPTH888, PSTR333, PLANE0, OFFS102, SUB444, PACK_IYU2),
5685 MAKE_YUV_FORMAT (VYUY, "raw video", GST_MAKE_FOURCC ('V', 'Y', 'U', 'Y'),
5686 DPTH888, PSTR244, PLANE0, OFFS102, SUB422, PACK_VYUY),
5687 MAKE_RGBA_FORMAT (GBRA, "raw video", DPTH8888, PSTR1111, PLANE2013,
5688 OFFS0, SUB4444, PACK_GBRA),
5689 MAKE_RGBA_FORMAT (GBRA_10BE, "raw video", DPTH10_10_10_10, PSTR2222,
5690 PLANE2013, OFFS0, SUB4444, PACK_GBRA_10BE),
5691 MAKE_RGBA_LE_FORMAT (GBRA_10LE, "raw video", DPTH10_10_10_10, PSTR2222,
5692 PLANE2013, OFFS0, SUB4444, PACK_GBRA_10LE),
5693 MAKE_RGB_FORMAT (GBR_12BE, "raw video", DPTH12_12_12, PSTR222, PLANE201,
5694 OFFS0, SUB444, PACK_GBR_12BE),
5695 MAKE_RGB_LE_FORMAT (GBR_12LE, "raw video", DPTH12_12_12, PSTR222, PLANE201,
5696 OFFS0, SUB444, PACK_GBR_12LE),
5697 MAKE_RGBA_FORMAT (GBRA_12BE, "raw video", DPTH12_12_12_12, PSTR2222,
5698 PLANE2013, OFFS0, SUB4444, PACK_GBRA_12BE),
5699 MAKE_RGBA_LE_PACK_FORMAT (GBRA_12LE, "raw video", DPTH12_12_12_12, PSTR2222,
5700 PLANE2013, OFFS0, SUB4444, PACK_GBRA_12LE),
5701 MAKE_YUV_FORMAT (I420_12BE, "raw video", 0x00000000, DPTH12_12_12,
5702 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_12BE),
5703 MAKE_YUV_LE_FORMAT (I420_12LE, "raw video", 0x00000000, DPTH12_12_12,
5704 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_12LE),
5705 MAKE_YUV_FORMAT (I422_12BE, "raw video", 0x00000000, DPTH12_12_12,
5706 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_12BE),
5707 MAKE_YUV_LE_FORMAT (I422_12LE, "raw video", 0x00000000, DPTH12_12_12,
5708 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_12LE),
5709 MAKE_YUV_FORMAT (Y444_12BE, "raw video", 0x00000000, DPTH12_12_12,
5710 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_12BE),
5711 MAKE_YUV_LE_FORMAT (Y444_12LE, "raw video", 0x00000000, DPTH12_12_12,
5712 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_12LE),
5713 MAKE_GRAY_C_LE_FORMAT (GRAY10_LE32, "raw video", DPTH10, PSTR0, PLANE0, OFFS0,
5714 SUB4, PACK_GRAY10_LE32),
5715 MAKE_YUV_C_LE_FORMAT (NV12_10LE32, "raw video",
5716 GST_MAKE_FOURCC ('X', 'V', '1', '5'), DPTH10_10_10, PSTR0, PLANE011,
5717 OFFS001, SUB420, PACK_NV12_10LE32),
5718 MAKE_YUV_C_LE_FORMAT (NV16_10LE32, "raw video",
5719 GST_MAKE_FOURCC ('X', 'V', '2', '0'), DPTH10_10_10, PSTR0, PLANE011,
5720 OFFS001, SUB422, PACK_NV16_10LE32),
5721 MAKE_YUV_C_LE_FORMAT (NV12_10LE40, "raw video",
5722 GST_MAKE_FOURCC ('R', 'K', '2', '0'), DPTH10_10_10, PSTR0, PLANE011,
5723 OFFS0, SUB420, PACK_NV12_10LE40),
5724 MAKE_YUV_FORMAT (Y210, "raw video", GST_MAKE_FOURCC ('Y', '2', '1', '0'),
5725 DPTH10_10_10, PSTR488, PLANE0, OFFS0, SUB422, PACK_Y210),
5726 MAKE_YUV_FORMAT (Y410, "raw video", GST_MAKE_FOURCC ('Y', '4', '1', '0'),
5727 DPTH10_10_10_2, PSTR0, PLANE0, OFFS0, SUB4444, PACK_Y410),
5728 MAKE_YUVA_PACK_FORMAT (VUYA, "raw video", GST_MAKE_FOURCC ('V', 'U', 'Y',
5729 'A'), DPTH8888, PSTR4444, PLANE0, OFFS2103, SUB4444, PACK_VUYA),
5730 MAKE_RGBA_LE_PACK_FORMAT (BGR10A2_LE, "raw video", DPTH10_10_10_2, PSTR4444,
5732 OFFS0, SUB4444, PACK_BGR10A2_LE),
5733 MAKE_RGBA_LE_PACK_FORMAT (RGB10A2_LE, "raw video", DPTH10_10_10_2, PSTR4444,
5734 PLANE0, OFFS0, SUB4444, PACK_RGB10A2_LE),
5737 static GstVideoFormat
5738 gst_video_format_from_rgb32_masks (int red_mask, int green_mask, int blue_mask)
5740 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
5741 blue_mask == 0x0000ff00) {
5742 return GST_VIDEO_FORMAT_RGBx;
5744 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
5745 blue_mask == 0xff000000) {
5746 return GST_VIDEO_FORMAT_BGRx;
5748 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
5749 blue_mask == 0x000000ff) {
5750 return GST_VIDEO_FORMAT_xRGB;
5752 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
5753 blue_mask == 0x00ff0000) {
5754 return GST_VIDEO_FORMAT_xBGR;
5757 return GST_VIDEO_FORMAT_UNKNOWN;
5760 static GstVideoFormat
5761 gst_video_format_from_rgba32_masks (int red_mask, int green_mask,
5762 int blue_mask, int alpha_mask)
5764 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
5765 blue_mask == 0x0000ff00 && alpha_mask == 0x000000ff) {
5766 return GST_VIDEO_FORMAT_RGBA;
5768 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
5769 blue_mask == 0xff000000 && alpha_mask == 0x000000ff) {
5770 return GST_VIDEO_FORMAT_BGRA;
5772 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
5773 blue_mask == 0x000000ff && alpha_mask == 0xff000000) {
5774 return GST_VIDEO_FORMAT_ARGB;
5776 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
5777 blue_mask == 0x00ff0000 && alpha_mask == 0xff000000) {
5778 return GST_VIDEO_FORMAT_ABGR;
5780 return GST_VIDEO_FORMAT_UNKNOWN;
5783 static GstVideoFormat
5784 gst_video_format_from_rgb24_masks (int red_mask, int green_mask, int blue_mask)
5786 if (red_mask == 0xff0000 && green_mask == 0x00ff00 && blue_mask == 0x0000ff) {
5787 return GST_VIDEO_FORMAT_RGB;
5789 if (red_mask == 0x0000ff && green_mask == 0x00ff00 && blue_mask == 0xff0000) {
5790 return GST_VIDEO_FORMAT_BGR;
5793 return GST_VIDEO_FORMAT_UNKNOWN;
5796 #define GST_VIDEO_COMP1_MASK_16_INT 0xf800
5797 #define GST_VIDEO_COMP2_MASK_16_INT 0x07e0
5798 #define GST_VIDEO_COMP3_MASK_16_INT 0x001f
5800 #define GST_VIDEO_COMP1_MASK_15_INT 0x7c00
5801 #define GST_VIDEO_COMP2_MASK_15_INT 0x03e0
5802 #define GST_VIDEO_COMP3_MASK_15_INT 0x001f
5804 static GstVideoFormat
5805 gst_video_format_from_rgb16_masks (int red_mask, int green_mask, int blue_mask)
5807 if (red_mask == GST_VIDEO_COMP1_MASK_16_INT
5808 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
5809 && blue_mask == GST_VIDEO_COMP3_MASK_16_INT) {
5810 return GST_VIDEO_FORMAT_RGB16;
5812 if (red_mask == GST_VIDEO_COMP3_MASK_16_INT
5813 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
5814 && blue_mask == GST_VIDEO_COMP1_MASK_16_INT) {
5815 return GST_VIDEO_FORMAT_BGR16;
5817 if (red_mask == GST_VIDEO_COMP1_MASK_15_INT
5818 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
5819 && blue_mask == GST_VIDEO_COMP3_MASK_15_INT) {
5820 return GST_VIDEO_FORMAT_RGB15;
5822 if (red_mask == GST_VIDEO_COMP3_MASK_15_INT
5823 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
5824 && blue_mask == GST_VIDEO_COMP1_MASK_15_INT) {
5825 return GST_VIDEO_FORMAT_BGR15;
5827 return GST_VIDEO_FORMAT_UNKNOWN;
5831 * gst_video_format_from_masks:
5832 * @depth: the amount of bits used for a pixel
5833 * @bpp: the amount of bits used to store a pixel. This value is bigger than
5835 * @endianness: the endianness of the masks, #G_LITTLE_ENDIAN or #G_BIG_ENDIAN
5836 * @red_mask: the red mask
5837 * @green_mask: the green mask
5838 * @blue_mask: the blue mask
5839 * @alpha_mask: the alpha mask, or 0 if no alpha mask
5841 * Find the #GstVideoFormat for the given parameters.
5843 * Returns: a #GstVideoFormat or GST_VIDEO_FORMAT_UNKNOWN when the parameters to
5844 * not specify a known format.
5847 gst_video_format_from_masks (gint depth, gint bpp, gint endianness,
5848 guint red_mask, guint green_mask, guint blue_mask, guint alpha_mask)
5850 GstVideoFormat format;
5852 /* our caps system handles 24/32bpp RGB as big-endian. */
5853 if ((bpp == 24 || bpp == 32) && endianness == G_LITTLE_ENDIAN &&
5854 alpha_mask != 0xc0000000) {
5855 red_mask = GUINT32_TO_BE (red_mask);
5856 green_mask = GUINT32_TO_BE (green_mask);
5857 blue_mask = GUINT32_TO_BE (blue_mask);
5858 alpha_mask = GUINT32_TO_BE (alpha_mask);
5859 endianness = G_BIG_ENDIAN;
5867 if (depth == 32 && bpp == 32 && alpha_mask == 0xc0000000 &&
5868 endianness == G_LITTLE_ENDIAN) {
5869 if (red_mask == 0x3ff00000)
5870 format = GST_VIDEO_FORMAT_RGB10A2_LE;
5872 format = GST_VIDEO_FORMAT_BGR10A2_LE;
5873 } else if (depth == 30 && bpp == 32) {
5874 format = GST_VIDEO_FORMAT_r210;
5875 } else if (depth == 24 && bpp == 32) {
5876 format = gst_video_format_from_rgb32_masks (red_mask, green_mask,
5878 } else if (depth == 32 && bpp == 32 && alpha_mask) {
5879 format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
5880 blue_mask, alpha_mask);
5881 } else if (depth == 24 && bpp == 24) {
5882 format = gst_video_format_from_rgb24_masks (red_mask, green_mask,
5884 } else if ((depth == 15 || depth == 16) && bpp == 16 &&
5885 endianness == G_BYTE_ORDER) {
5886 format = gst_video_format_from_rgb16_masks (red_mask, green_mask,
5888 } else if (depth == 8 && bpp == 8) {
5889 format = GST_VIDEO_FORMAT_RGB8P;
5890 } else if (depth == 64 && bpp == 64) {
5891 format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
5892 blue_mask, alpha_mask);
5893 if (format == GST_VIDEO_FORMAT_ARGB) {
5894 format = GST_VIDEO_FORMAT_ARGB64;
5896 format = GST_VIDEO_FORMAT_UNKNOWN;
5899 format = GST_VIDEO_FORMAT_UNKNOWN;
5905 * gst_video_format_from_fourcc:
5906 * @fourcc: a FOURCC value representing raw YUV video
5908 * Converts a FOURCC value into the corresponding #GstVideoFormat.
5909 * If the FOURCC cannot be represented by #GstVideoFormat,
5910 * #GST_VIDEO_FORMAT_UNKNOWN is returned.
5912 * Returns: the #GstVideoFormat describing the FOURCC value
5915 gst_video_format_from_fourcc (guint32 fourcc)
5918 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
5919 return GST_VIDEO_FORMAT_I420;
5920 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
5921 return GST_VIDEO_FORMAT_YV12;
5922 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
5923 return GST_VIDEO_FORMAT_YUY2;
5924 case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
5925 return GST_VIDEO_FORMAT_YVYU;
5926 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
5927 return GST_VIDEO_FORMAT_UYVY;
5928 case GST_MAKE_FOURCC ('V', 'Y', 'U', 'Y'):
5929 return GST_VIDEO_FORMAT_VYUY;
5930 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
5931 return GST_VIDEO_FORMAT_AYUV;
5932 case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
5933 return GST_VIDEO_FORMAT_Y41B;
5934 case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
5935 return GST_VIDEO_FORMAT_Y42B;
5936 case GST_MAKE_FOURCC ('Y', '4', '4', '4'):
5937 return GST_VIDEO_FORMAT_Y444;
5938 case GST_MAKE_FOURCC ('v', '2', '1', '0'):
5939 return GST_VIDEO_FORMAT_v210;
5940 case GST_MAKE_FOURCC ('v', '2', '1', '6'):
5941 return GST_VIDEO_FORMAT_v216;
5942 case GST_MAKE_FOURCC ('Y', '2', '1', '0'):
5943 return GST_VIDEO_FORMAT_Y210;
5944 case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
5945 return GST_VIDEO_FORMAT_NV12;
5946 case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
5947 return GST_VIDEO_FORMAT_NV21;
5948 case GST_MAKE_FOURCC ('N', 'V', '1', '6'):
5949 return GST_VIDEO_FORMAT_NV16;
5950 case GST_MAKE_FOURCC ('N', 'V', '6', '1'):
5951 return GST_VIDEO_FORMAT_NV61;
5952 case GST_MAKE_FOURCC ('N', 'V', '2', '4'):
5953 return GST_VIDEO_FORMAT_NV24;
5954 case GST_MAKE_FOURCC ('v', '3', '0', '8'):
5955 return GST_VIDEO_FORMAT_v308;
5956 case GST_MAKE_FOURCC ('I', 'Y', 'U', '2'):
5957 return GST_VIDEO_FORMAT_IYU2;
5958 case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
5959 case GST_MAKE_FOURCC ('Y', '8', ' ', ' '):
5960 case GST_MAKE_FOURCC ('G', 'R', 'E', 'Y'):
5961 return GST_VIDEO_FORMAT_GRAY8;
5962 case GST_MAKE_FOURCC ('Y', '1', '6', ' '):
5963 return GST_VIDEO_FORMAT_GRAY16_LE;
5964 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'):
5965 return GST_VIDEO_FORMAT_UYVP;
5966 case GST_MAKE_FOURCC ('A', '4', '2', '0'):
5967 return GST_VIDEO_FORMAT_A420;
5968 case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
5969 return GST_VIDEO_FORMAT_YUV9;
5970 case GST_MAKE_FOURCC ('Y', 'V', 'U', '9'):
5971 return GST_VIDEO_FORMAT_YVU9;
5972 case GST_MAKE_FOURCC ('I', 'Y', 'U', '1'):
5973 return GST_VIDEO_FORMAT_IYU1;
5974 case GST_MAKE_FOURCC ('A', 'Y', '6', '4'):
5975 return GST_VIDEO_FORMAT_AYUV64;
5976 case GST_MAKE_FOURCC ('X', 'V', '1', '0'):
5977 return GST_VIDEO_FORMAT_GRAY10_LE32;
5978 case GST_MAKE_FOURCC ('X', 'V', '1', '5'):
5979 return GST_VIDEO_FORMAT_NV12_10LE32;
5980 case GST_MAKE_FOURCC ('X', 'V', '2', '0'):
5981 return GST_VIDEO_FORMAT_NV16_10LE32;
5982 case GST_MAKE_FOURCC ('R', 'K', '2', '0'):
5983 return GST_VIDEO_FORMAT_NV12_10LE40;
5984 case GST_MAKE_FOURCC ('Y', '4', '1', '0'):
5985 return GST_VIDEO_FORMAT_Y410;
5986 case GST_MAKE_FOURCC ('V', 'U', 'Y', 'A'):
5987 return GST_VIDEO_FORMAT_VUYA;
5988 case GST_MAKE_FOURCC ('A', 'R', '3', '0'):
5989 return GST_VIDEO_FORMAT_BGR10A2_LE;
5992 return GST_VIDEO_FORMAT_UNKNOWN;
5997 * gst_video_format_from_string:
5998 * @format: a format string
6000 * Convert the @format string to its #GstVideoFormat.
6002 * Returns: the #GstVideoFormat for @format or GST_VIDEO_FORMAT_UNKNOWN when the
6003 * string is not a known format.
6006 gst_video_format_from_string (const gchar * format)
6010 g_return_val_if_fail (format != NULL, GST_VIDEO_FORMAT_UNKNOWN);
6012 for (i = 0; i < G_N_ELEMENTS (formats); i++) {
6013 if (strcmp (GST_VIDEO_FORMAT_INFO_NAME (&formats[i].info), format) == 0)
6014 return GST_VIDEO_FORMAT_INFO_FORMAT (&formats[i].info);
6016 return GST_VIDEO_FORMAT_UNKNOWN;
6021 * gst_video_format_to_fourcc:
6022 * @format: a #GstVideoFormat video format
6024 * Converts a #GstVideoFormat value into the corresponding FOURCC. Only
6025 * a few YUV formats have corresponding FOURCC values. If @format has
6026 * no corresponding FOURCC value, 0 is returned.
6028 * Returns: the FOURCC corresponding to @format
6031 gst_video_format_to_fourcc (GstVideoFormat format)
6033 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
6035 if ((gint) format >= G_N_ELEMENTS (formats))
6038 return formats[format].fourcc;
6042 * gst_video_format_to_string:
6043 * @format: a #GstVideoFormat video format
6045 * Returns a string containing a descriptive name for
6046 * the #GstVideoFormat if there is one, or NULL otherwise.
6048 * Returns: the name corresponding to @format
6051 gst_video_format_to_string (GstVideoFormat format)
6053 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
6055 if ((gint) format >= G_N_ELEMENTS (formats))
6058 return GST_VIDEO_FORMAT_INFO_NAME (&formats[format].info);
6062 * gst_video_format_get_info:
6063 * @format: a #GstVideoFormat
6065 * Get the #GstVideoFormatInfo for @format
6067 * Returns: The #GstVideoFormatInfo for @format.
6069 const GstVideoFormatInfo *
6070 gst_video_format_get_info (GstVideoFormat format)
6072 g_return_val_if_fail ((gint) format < G_N_ELEMENTS (formats), NULL);
6074 return &formats[format].info;
6078 * gst_video_format_get_palette:
6079 * @format: a #GstVideoFormat
6080 * @size: (out): size of the palette in bytes
6082 * Get the default palette of @format. This the palette used in the pack
6083 * function for paletted formats.
6085 * Returns: (transfer none): the default palette of @format or %NULL when
6086 * @format does not have a palette.
6091 gst_video_format_get_palette (GstVideoFormat format, gsize * size)
6093 g_return_val_if_fail ((gint) format < G_N_ELEMENTS (formats), NULL);
6094 g_return_val_if_fail (size != NULL, NULL);
6097 case GST_VIDEO_FORMAT_RGB8P:
6098 *size = sizeof (std_palette_RGB8P);
6099 return std_palette_RGB8P;
6106 * gst_video_format_info_component:
6107 * @info: #GstVideoFormatInfo
6108 * @plane: a plane number
6109 * @components: (out): array used to store component numbers
6111 * Fill @components with the number of all the components packed in plane @p
6112 * for the format @info. A value of -1 in @components indicates that no more
6113 * components are packed in the plane.
6118 gst_video_format_info_component (const GstVideoFormatInfo * info, guint plane,
6119 gint components[GST_VIDEO_MAX_COMPONENTS])
6123 /* Reverse mapping of info->plane */
6124 for (c = 0; c < GST_VIDEO_FORMAT_INFO_N_COMPONENTS (info); c++) {
6125 if (GST_VIDEO_FORMAT_INFO_PLANE (info, c) == plane) {
6131 for (c = i; c < GST_VIDEO_MAX_COMPONENTS; c++)