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: - Reused 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: - Reused 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);
5401 #define PACK_Y444_16BE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_16BE, 1, pack_Y444_16BE
5403 unpack_Y444_16BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5404 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
5405 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
5408 guint16 *restrict sy = GET_Y_LINE (y);
5409 guint16 *restrict su = GET_U_LINE (y);
5410 guint16 *restrict sv = GET_V_LINE (y);
5411 guint16 *restrict d = dest, Y, U, V;
5417 for (i = 0; i < width; i++) {
5418 Y = GST_READ_UINT16_BE (sy + i);
5419 U = GST_READ_UINT16_BE (su + i);
5420 V = GST_READ_UINT16_BE (sv + i);
5422 d[i * 4 + 0] = 0xffff;
5430 pack_Y444_16BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5431 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5432 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5436 guint16 *restrict dy = GET_Y_LINE (y);
5437 guint16 *restrict du = GET_U_LINE (y);
5438 guint16 *restrict dv = GET_V_LINE (y);
5440 const guint16 *restrict s = src;
5442 for (i = 0; i < width; i++) {
5447 GST_WRITE_UINT16_BE (dy + i, Y);
5448 GST_WRITE_UINT16_BE (du + i, U);
5449 GST_WRITE_UINT16_BE (dv + i, V);
5453 #define PACK_Y444_16LE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_16LE, 1, pack_Y444_16LE
5455 unpack_Y444_16LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5456 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
5457 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
5460 guint16 *restrict sy = GET_Y_LINE (y);
5461 guint16 *restrict su = GET_U_LINE (y);
5462 guint16 *restrict sv = GET_V_LINE (y);
5463 guint16 *restrict d = dest, Y, U, V;
5469 for (i = 0; i < width; i++) {
5470 Y = GST_READ_UINT16_LE (sy + i);
5471 U = GST_READ_UINT16_LE (su + i);
5472 V = GST_READ_UINT16_LE (sv + i);
5474 d[i * 4 + 0] = 0xffff;
5482 pack_Y444_16LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5483 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5484 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5488 guint16 *restrict dy = GET_Y_LINE (y);
5489 guint16 *restrict du = GET_U_LINE (y);
5490 guint16 *restrict dv = GET_V_LINE (y);
5492 const guint16 *restrict s = src;
5494 for (i = 0; i < width; i++) {
5499 GST_WRITE_UINT16_LE (dy + i, Y);
5500 GST_WRITE_UINT16_LE (du + i, U);
5501 GST_WRITE_UINT16_LE (dv + i, V);
5505 #define PACK_P016_BE GST_VIDEO_FORMAT_AYUV64, unpack_P016_BE, 1, pack_P016_BE
5507 unpack_P016_BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5508 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
5509 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
5512 gint uv = GET_UV_420 (y, flags);
5513 const guint16 *restrict sy = GET_PLANE_LINE (0, y);
5514 const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
5515 guint16 *restrict d = dest, Y0, Y1, U, V;
5521 Y0 = GST_READ_UINT16_BE (sy);
5522 U = GST_READ_UINT16_BE (suv);
5523 V = GST_READ_UINT16_BE (suv + 1);
5535 for (i = 0; i < width / 2; i++) {
5536 Y0 = GST_READ_UINT16_BE (sy + 2 * i);
5537 Y1 = GST_READ_UINT16_BE (sy + 2 * i + 1);
5538 U = GST_READ_UINT16_BE (suv + 2 * i);
5539 V = GST_READ_UINT16_BE (suv + 2 * i + 1);
5541 d[i * 8 + 0] = 0xffff;
5545 d[i * 8 + 4] = 0xffff;
5554 Y0 = GST_READ_UINT16_BE (sy + i);
5555 U = GST_READ_UINT16_BE (suv + i);
5556 V = GST_READ_UINT16_BE (suv + i + 1);
5558 d[i * 4 + 0] = 0xffff;
5566 pack_P016_BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5567 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5568 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5572 gint uv = GET_UV_420 (y, flags);
5573 guint16 *restrict dy = GET_PLANE_LINE (0, y);
5574 guint16 *restrict duv = GET_PLANE_LINE (1, uv);
5575 guint16 Y0, Y1, U, V;
5576 const guint16 *restrict s = src;
5578 if (IS_CHROMA_LINE_420 (y, flags)) {
5579 for (i = 0; i < width / 2; i++) {
5585 GST_WRITE_UINT16_BE (dy + i * 2 + 0, Y0);
5586 GST_WRITE_UINT16_BE (dy + i * 2 + 1, Y1);
5587 GST_WRITE_UINT16_BE (duv + i * 2 + 0, U);
5588 GST_WRITE_UINT16_BE (duv + i * 2 + 1, V);
5597 GST_WRITE_UINT16_BE (dy + i, Y0);
5598 GST_WRITE_UINT16_BE (duv + i + 0, U);
5599 GST_WRITE_UINT16_BE (duv + i + 1, V);
5602 for (i = 0; i < width; i++) {
5604 GST_WRITE_UINT16_BE (dy + i, Y0);
5609 #define PACK_P016_LE GST_VIDEO_FORMAT_AYUV64, unpack_P016_LE, 1, pack_P016_LE
5611 unpack_P016_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5612 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
5613 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
5616 gint uv = GET_UV_420 (y, flags);
5617 const guint16 *restrict sy = GET_PLANE_LINE (0, y);
5618 const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
5619 guint16 *restrict d = dest, Y0, Y1, U, V;
5625 Y0 = GST_READ_UINT16_LE (sy);
5626 U = GST_READ_UINT16_LE (suv);
5627 V = GST_READ_UINT16_LE (suv + 1);
5639 for (i = 0; i < width / 2; i++) {
5640 Y0 = GST_READ_UINT16_LE (sy + 2 * i);
5641 Y1 = GST_READ_UINT16_LE (sy + 2 * i + 1);
5642 U = GST_READ_UINT16_LE (suv + 2 * i);
5643 V = GST_READ_UINT16_LE (suv + 2 * i + 1);
5645 d[i * 8 + 0] = 0xffff;
5649 d[i * 8 + 4] = 0xffff;
5658 Y0 = GST_READ_UINT16_LE (sy + i);
5659 U = GST_READ_UINT16_LE (suv + i);
5660 V = GST_READ_UINT16_LE (suv + i + 1);
5662 d[i * 4 + 0] = 0xffff;
5670 pack_P016_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5671 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5672 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5676 gint uv = GET_UV_420 (y, flags);
5677 guint16 *restrict dy = GET_PLANE_LINE (0, y);
5678 guint16 *restrict duv = GET_PLANE_LINE (1, uv);
5679 guint16 Y0, Y1, U, V;
5680 const guint16 *restrict s = src;
5682 if (IS_CHROMA_LINE_420 (y, flags)) {
5683 for (i = 0; i < width / 2; i++) {
5689 GST_WRITE_UINT16_LE (dy + i * 2 + 0, Y0);
5690 GST_WRITE_UINT16_LE (dy + i * 2 + 1, Y1);
5691 GST_WRITE_UINT16_LE (duv + i * 2 + 0, U);
5692 GST_WRITE_UINT16_LE (duv + i * 2 + 1, V);
5701 GST_WRITE_UINT16_LE (dy + i, Y0);
5702 GST_WRITE_UINT16_LE (duv + i + 0, U);
5703 GST_WRITE_UINT16_LE (duv + i + 1, V);
5706 for (i = 0; i < width; i++) {
5708 GST_WRITE_UINT16_LE (dy + i, Y0);
5716 GstVideoFormatInfo info;
5719 /* depths: bits, n_components, shift, depth */
5720 #define DPTH0 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5721 #define DPTH8 8, 1, { 0, 0, 0, 0 }, { 8, 0, 0, 0 }
5722 #define DPTH8_32 8, 2, { 0, 0, 0, 0 }, { 8, 32, 0, 0 }
5723 #define DPTH888 8, 3, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
5724 #define DPTH8888 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 8 }
5725 #define DPTH8880 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
5726 #define DPTH10 10, 1, { 0, 0, 0, 0 }, { 10, 0, 0, 0 }
5727 #define DPTH10_10_10 10, 3, { 0, 0, 0, 0 }, { 10, 10, 10, 0 }
5728 #define DPTH10_10_10_10 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 10 }
5729 #define DPTH10_10_10_HI 16, 3, { 6, 6, 6, 0 }, { 10, 10, 10, 0 }
5730 #define DPTH10_10_10_2 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 2}
5731 #define DPTH12_12_12 12, 3, { 0, 0, 0, 0 }, { 12, 12, 12, 0 }
5732 #define DPTH12_12_12_12 12, 4, { 0, 0, 0, 0 }, { 12, 12, 12, 12 }
5733 #define DPTH16 16, 1, { 0, 0, 0, 0 }, { 16, 0, 0, 0 }
5734 #define DPTH16_16_16 16, 3, { 0, 0, 0, 0 }, { 16, 16, 16, 0 }
5735 #define DPTH16_16_16_16 16, 4, { 0, 0, 0, 0 }, { 16, 16, 16, 16 }
5736 #define DPTH555 16, 3, { 10, 5, 0, 0 }, { 5, 5, 5, 0 }
5737 #define DPTH565 16, 3, { 11, 5, 0, 0 }, { 5, 6, 5, 0 }
5740 #define PSTR0 { 0, 0, 0, 0 }
5741 #define PSTR1 { 1, 0, 0, 0 }
5742 #define PSTR14 { 1, 4, 0, 0 }
5743 #define PSTR111 { 1, 1, 1, 0 }
5744 #define PSTR1111 { 1, 1, 1, 1 }
5745 #define PSTR122 { 1, 2, 2, 0 }
5746 #define PSTR2 { 2, 0, 0, 0 }
5747 #define PSTR222 { 2, 2, 2, 0 }
5748 #define PSTR2222 { 2, 2, 2, 2 }
5749 #define PSTR244 { 2, 4, 4, 0 }
5750 #define PSTR444 { 4, 4, 4, 0 }
5751 #define PSTR4444 { 4, 4, 4, 4 }
5752 #define PSTR333 { 3, 3, 3, 0 }
5753 #define PSTR488 { 4, 8, 8, 0 }
5754 #define PSTR8888 { 8, 8, 8, 8 }
5756 /* planes, in what plane do we find component N */
5757 #define PLANE_NA 0, { 0, 0, 0, 0 }
5758 #define PLANE0 1, { 0, 0, 0, 0 }
5759 #define PLANE01 2, { 0, 1, 0, 0 }
5760 #define PLANE011 2, { 0, 1, 1, 0 }
5761 #define PLANE012 3, { 0, 1, 2, 0 }
5762 #define PLANE0123 4, { 0, 1, 2, 3 }
5763 #define PLANE021 3, { 0, 2, 1, 0 }
5764 #define PLANE201 3, { 2, 0, 1, 0 }
5765 #define PLANE2013 4, { 2, 0, 1, 3 }
5768 #define OFFS0 { 0, 0, 0, 0 }
5769 #define OFFS013 { 0, 1, 3, 0 }
5770 #define OFFS102 { 1, 0, 2, 0 }
5771 #define OFFS1230 { 1, 2, 3, 0 }
5772 #define OFFS012 { 0, 1, 2, 0 }
5773 #define OFFS210 { 2, 1, 0, 0 }
5774 #define OFFS123 { 1, 2, 3, 0 }
5775 #define OFFS321 { 3, 2, 1, 0 }
5776 #define OFFS0123 { 0, 1, 2, 3 }
5777 #define OFFS2103 { 2, 1, 0, 3 }
5778 #define OFFS3210 { 3, 2, 1, 0 }
5779 #define OFFS031 { 0, 3, 1, 0 }
5780 #define OFFS204 { 2, 0, 4, 0 }
5781 #define OFFS001 { 0, 0, 1, 0 }
5782 #define OFFS010 { 0, 1, 0, 0 }
5783 #define OFFS104 { 1, 0, 4, 0 }
5784 #define OFFS2460 { 2, 4, 6, 0 }
5786 /* subsampling, w_sub, h_sub */
5787 #define SUB410 { 0, 2, 2, 0 }, { 0, 2, 2, 0 }
5788 #define SUB411 { 0, 2, 2, 0 }, { 0, 0, 0, 0 }
5789 #define SUB420 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
5790 #define SUB422 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
5791 #define SUB4 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5792 #define SUB44 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5793 #define SUB444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5794 #define SUB4444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5795 #define SUB4204 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
5796 #define SUB4224 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
5798 /* tile_mode, tile_width, tile_height */
5799 #define TILE_64x32(mode) GST_VIDEO_TILE_MODE_ ##mode, 6, 5
5801 #define MAKE_YUV_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5802 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV, depth, pstride, plane, offs, sub, pack } }
5803 #define MAKE_YUV_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5804 { 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 } }
5805 #define MAKE_YUVA_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5806 { 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 } }
5807 #define MAKE_YUVA_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5808 { 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 } }
5809 #define MAKE_YUVA_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5810 { 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 } }
5811 #define MAKE_YUVA_LE_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5812 { 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 } }
5813 #define MAKE_YUV_C_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5814 { 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 } }
5815 #define MAKE_YUV_C_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5816 { 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 } }
5817 #define MAKE_YUV_T_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack, tile) \
5818 { 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 } }
5820 #define MAKE_RGB_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5821 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB, depth, pstride, plane, offs, sub, pack } }
5822 #define MAKE_RGB_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5823 { 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 } }
5824 #define MAKE_RGBA_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5825 { 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 } }
5826 #define MAKE_RGBA_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5827 { 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 } }
5828 #define MAKE_RGBAP_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5829 { 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 } }
5830 #define MAKE_RGBA_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5831 { 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 } }
5832 #define MAKE_RGBA_LE_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5833 { 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 } }
5835 #define MAKE_GRAY_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5836 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY, depth, pstride, plane, offs, sub, pack } }
5837 #define MAKE_GRAY_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5838 { 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 } }
5839 #define MAKE_GRAY_C_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5840 { 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 } }
5842 static const VideoFormat formats[] = {
5843 {0x00000000, {GST_VIDEO_FORMAT_UNKNOWN, "UNKNOWN", "unknown video", 0, DPTH0,
5844 PSTR0, PLANE_NA, OFFS0}},
5845 {0x00000000, {GST_VIDEO_FORMAT_ENCODED, "ENCODED", "encoded video",
5846 GST_VIDEO_FORMAT_FLAG_COMPLEX, DPTH0, PSTR0, PLANE_NA, OFFS0}},
5848 MAKE_YUV_FORMAT (I420, "raw video", GST_MAKE_FOURCC ('I', '4', '2', '0'),
5849 DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
5850 MAKE_YUV_FORMAT (YV12, "raw video", GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
5851 DPTH888, PSTR111, PLANE021, OFFS0, SUB420, PACK_420),
5852 MAKE_YUV_FORMAT (YUY2, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
5853 DPTH888, PSTR244, PLANE0, OFFS013, SUB422, PACK_YUY2),
5854 MAKE_YUV_FORMAT (UYVY, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'),
5855 DPTH888, PSTR244, PLANE0, OFFS102, SUB422, PACK_UYVY),
5856 MAKE_YUVA_PACK_FORMAT (AYUV, "raw video", GST_MAKE_FOURCC ('A', 'Y', 'U',
5857 'V'), DPTH8888, PSTR4444, PLANE0, OFFS1230, SUB4444, PACK_AYUV),
5858 MAKE_RGB_FORMAT (RGBx, "raw video", DPTH888, PSTR444, PLANE0, OFFS012,
5860 MAKE_RGB_FORMAT (BGRx, "raw video", DPTH888, PSTR444, PLANE0, OFFS210,
5862 MAKE_RGB_FORMAT (xRGB, "raw video", DPTH888, PSTR444, PLANE0, OFFS123,
5864 MAKE_RGB_FORMAT (xBGR, "raw video", DPTH888, PSTR444, PLANE0, OFFS321,
5866 MAKE_RGBA_FORMAT (RGBA, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS0123,
5867 SUB4444, PACK_RGBA),
5868 MAKE_RGBA_FORMAT (BGRA, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS2103,
5869 SUB4444, PACK_BGRA),
5870 MAKE_RGBA_PACK_FORMAT (ARGB, "raw video", DPTH8888, PSTR4444, PLANE0,
5871 OFFS1230, SUB4444, PACK_ARGB),
5872 MAKE_RGBA_FORMAT (ABGR, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS3210,
5873 SUB4444, PACK_ABGR),
5874 MAKE_RGB_FORMAT (RGB, "raw video", DPTH888, PSTR333, PLANE0, OFFS012, SUB444,
5876 MAKE_RGB_FORMAT (BGR, "raw video", DPTH888, PSTR333, PLANE0, OFFS210, SUB444,
5879 MAKE_YUV_FORMAT (Y41B, "raw video", GST_MAKE_FOURCC ('Y', '4', '1', 'B'),
5880 DPTH888, PSTR111, PLANE012, OFFS0, SUB411, PACK_Y41B),
5881 MAKE_YUV_FORMAT (Y42B, "raw video", GST_MAKE_FOURCC ('Y', '4', '2', 'B'),
5882 DPTH888, PSTR111, PLANE012, OFFS0, SUB422, PACK_Y42B),
5883 MAKE_YUV_FORMAT (YVYU, "raw video", GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'),
5884 DPTH888, PSTR244, PLANE0, OFFS031, SUB422, PACK_YVYU),
5885 MAKE_YUV_FORMAT (Y444, "raw video", GST_MAKE_FOURCC ('Y', '4', '4', '4'),
5886 DPTH888, PSTR111, PLANE012, OFFS0, SUB444, PACK_Y444),
5887 MAKE_YUV_C_FORMAT (v210, "raw video", GST_MAKE_FOURCC ('v', '2', '1', '0'),
5888 DPTH10_10_10, PSTR0, PLANE0, OFFS0, SUB422, PACK_v210),
5889 MAKE_YUV_FORMAT (v216, "raw video", GST_MAKE_FOURCC ('v', '2', '1', '6'),
5890 DPTH16_16_16, PSTR488, PLANE0, OFFS204, SUB422, PACK_v216),
5891 MAKE_YUV_FORMAT (NV12, "raw video", GST_MAKE_FOURCC ('N', 'V', '1', '2'),
5892 DPTH888, PSTR122, PLANE011, OFFS001, SUB420, PACK_NV12),
5893 MAKE_YUV_FORMAT (NV21, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '1'),
5894 DPTH888, PSTR122, PLANE011, OFFS010, SUB420, PACK_NV21),
5896 MAKE_GRAY_FORMAT (GRAY8, "raw video", DPTH8, PSTR1, PLANE0, OFFS0, SUB4,
5898 MAKE_GRAY_FORMAT (GRAY16_BE, "raw video", DPTH16, PSTR2, PLANE0, OFFS0, SUB4,
5900 MAKE_GRAY_LE_FORMAT (GRAY16_LE, "raw video", DPTH16, PSTR2, PLANE0, OFFS0,
5901 SUB4, PACK_GRAY16_LE),
5903 MAKE_YUV_FORMAT (v308, "raw video", GST_MAKE_FOURCC ('v', '3', '0', '8'),
5904 DPTH888, PSTR333, PLANE0, OFFS012, SUB444, PACK_v308),
5906 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
5907 MAKE_RGB_LE_FORMAT (RGB16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0,
5908 SUB444, PACK_RGB16),
5909 MAKE_RGB_LE_FORMAT (BGR16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0,
5910 SUB444, PACK_BGR16),
5911 MAKE_RGB_LE_FORMAT (RGB15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0,
5912 SUB444, PACK_RGB15),
5913 MAKE_RGB_LE_FORMAT (BGR15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0,
5914 SUB444, PACK_BGR15),
5916 MAKE_RGB_FORMAT (RGB16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0, SUB444,
5918 MAKE_RGB_FORMAT (BGR16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0, SUB444,
5920 MAKE_RGB_FORMAT (RGB15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0, SUB444,
5922 MAKE_RGB_FORMAT (BGR15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0, SUB444,
5926 MAKE_YUV_C_FORMAT (UYVP, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'),
5927 DPTH10_10_10, PSTR0, PLANE0, OFFS0, SUB422, PACK_UYVP),
5928 MAKE_YUVA_FORMAT (A420, "raw video", GST_MAKE_FOURCC ('A', '4', '2', '0'),
5929 DPTH8888, PSTR1111, PLANE0123, OFFS0, SUB4204, PACK_A420),
5930 MAKE_RGBAP_FORMAT (RGB8P, "raw video", DPTH8_32, PSTR14, PLANE01,
5931 OFFS0, SUB44, PACK_RGB8P),
5932 MAKE_YUV_FORMAT (YUV9, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'V', '9'),
5933 DPTH888, PSTR111, PLANE012, OFFS0, SUB410, PACK_410),
5934 MAKE_YUV_FORMAT (YVU9, "raw video", GST_MAKE_FOURCC ('Y', 'V', 'U', '9'),
5935 DPTH888, PSTR111, PLANE021, OFFS0, SUB410, PACK_410),
5936 MAKE_YUV_FORMAT (IYU1, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '1'),
5937 DPTH888, PSTR0, PLANE0, OFFS104, SUB411, PACK_IYU1),
5938 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
5939 MAKE_RGBA_LE_PACK_FORMAT (ARGB64, "raw video", DPTH16_16_16_16, PSTR8888,
5941 OFFS2460, SUB444, PACK_ARGB64),
5942 MAKE_YUVA_LE_PACK_FORMAT (AYUV64, "raw video", 0x00000000, DPTH16_16_16_16,
5943 PSTR8888, PLANE0, OFFS2460, SUB444, PACK_AYUV64),
5945 MAKE_RGBA_PACK_FORMAT (ARGB64, "raw video", DPTH16_16_16_16, PSTR8888, PLANE0,
5946 OFFS2460, SUB444, PACK_ARGB64),
5947 MAKE_YUVA_PACK_FORMAT (AYUV64, "raw video", 0x00000000, DPTH16_16_16_16,
5948 PSTR8888, PLANE0, OFFS2460, SUB444, PACK_AYUV64),
5950 MAKE_RGB_FORMAT (r210, "raw video", DPTH10_10_10, PSTR444, PLANE0, OFFS0,
5952 MAKE_YUV_FORMAT (I420_10BE, "raw video", 0x00000000, DPTH10_10_10,
5953 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10BE),
5954 MAKE_YUV_LE_FORMAT (I420_10LE, "raw video", 0x00000000, DPTH10_10_10,
5955 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10LE),
5956 MAKE_YUV_FORMAT (I422_10BE, "raw video", 0x00000000, DPTH10_10_10,
5957 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10BE),
5958 MAKE_YUV_LE_FORMAT (I422_10LE, "raw video", 0x00000000, DPTH10_10_10,
5959 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10LE),
5960 MAKE_YUV_FORMAT (Y444_10BE, "raw video", 0x00000000, DPTH10_10_10,
5961 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10BE),
5962 MAKE_YUV_LE_FORMAT (Y444_10LE, "raw video", 0x00000000, DPTH10_10_10,
5963 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10LE),
5964 MAKE_RGB_FORMAT (GBR, "raw video", DPTH888, PSTR111, PLANE201, OFFS0, SUB444,
5966 MAKE_RGB_FORMAT (GBR_10BE, "raw video", DPTH10_10_10, PSTR222, PLANE201,
5967 OFFS0, SUB444, PACK_GBR_10BE),
5968 MAKE_RGB_LE_FORMAT (GBR_10LE, "raw video", DPTH10_10_10, PSTR222, PLANE201,
5969 OFFS0, SUB444, PACK_GBR_10LE),
5970 MAKE_YUV_FORMAT (NV16, "raw video", GST_MAKE_FOURCC ('N', 'V', '1', '6'),
5971 DPTH888, PSTR122, PLANE011, OFFS001, SUB422, PACK_NV16),
5972 MAKE_YUV_FORMAT (NV24, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '4'),
5973 DPTH888, PSTR122, PLANE011, OFFS001, SUB444, PACK_NV24),
5974 MAKE_YUV_T_FORMAT (NV12_64Z32, "raw video",
5975 GST_MAKE_FOURCC ('T', 'M', '1', '2'), DPTH8880, PSTR122, PLANE011,
5976 OFFS001, SUB420, PACK_NV12_64Z32, TILE_64x32 (ZFLIPZ_2X2)),
5977 MAKE_YUVA_FORMAT (A420_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5978 PSTR2222, PLANE0123, OFFS0, SUB4204, PACK_A420_10BE),
5979 MAKE_YUVA_LE_FORMAT (A420_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5980 PSTR2222, PLANE0123, OFFS0, SUB4204, PACK_A420_10LE),
5981 MAKE_YUVA_FORMAT (A422_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5982 PSTR2222, PLANE0123, OFFS0, SUB4224, PACK_A422_10BE),
5983 MAKE_YUVA_LE_FORMAT (A422_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5984 PSTR2222, PLANE0123, OFFS0, SUB4224, PACK_A422_10LE),
5985 MAKE_YUVA_FORMAT (A444_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5986 PSTR2222, PLANE0123, OFFS0, SUB4444, PACK_A444_10BE),
5987 MAKE_YUVA_LE_FORMAT (A444_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5988 PSTR2222, PLANE0123, OFFS0, SUB4444, PACK_A444_10LE),
5989 MAKE_YUV_FORMAT (NV61, "raw video", GST_MAKE_FOURCC ('N', 'V', '6', '1'),
5990 DPTH888, PSTR122, PLANE011, OFFS010, SUB422, PACK_NV61),
5991 MAKE_YUV_FORMAT (P010_10BE, "raw video", 0x00000000, DPTH10_10_10_HI,
5992 PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10BE),
5993 MAKE_YUV_LE_FORMAT (P010_10LE, "raw video", 0x00000000, DPTH10_10_10_HI,
5994 PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10LE),
5995 MAKE_YUV_FORMAT (IYU2, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '2'),
5996 DPTH888, PSTR333, PLANE0, OFFS102, SUB444, PACK_IYU2),
5997 MAKE_YUV_FORMAT (VYUY, "raw video", GST_MAKE_FOURCC ('V', 'Y', 'U', 'Y'),
5998 DPTH888, PSTR244, PLANE0, OFFS102, SUB422, PACK_VYUY),
5999 MAKE_RGBA_FORMAT (GBRA, "raw video", DPTH8888, PSTR1111, PLANE2013,
6000 OFFS0, SUB4444, PACK_GBRA),
6001 MAKE_RGBA_FORMAT (GBRA_10BE, "raw video", DPTH10_10_10_10, PSTR2222,
6002 PLANE2013, OFFS0, SUB4444, PACK_GBRA_10BE),
6003 MAKE_RGBA_LE_FORMAT (GBRA_10LE, "raw video", DPTH10_10_10_10, PSTR2222,
6004 PLANE2013, OFFS0, SUB4444, PACK_GBRA_10LE),
6005 MAKE_RGB_FORMAT (GBR_12BE, "raw video", DPTH12_12_12, PSTR222, PLANE201,
6006 OFFS0, SUB444, PACK_GBR_12BE),
6007 MAKE_RGB_LE_FORMAT (GBR_12LE, "raw video", DPTH12_12_12, PSTR222, PLANE201,
6008 OFFS0, SUB444, PACK_GBR_12LE),
6009 MAKE_RGBA_FORMAT (GBRA_12BE, "raw video", DPTH12_12_12_12, PSTR2222,
6010 PLANE2013, OFFS0, SUB4444, PACK_GBRA_12BE),
6011 MAKE_RGBA_LE_PACK_FORMAT (GBRA_12LE, "raw video", DPTH12_12_12_12, PSTR2222,
6012 PLANE2013, OFFS0, SUB4444, PACK_GBRA_12LE),
6013 MAKE_YUV_FORMAT (I420_12BE, "raw video", 0x00000000, DPTH12_12_12,
6014 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_12BE),
6015 MAKE_YUV_LE_FORMAT (I420_12LE, "raw video", 0x00000000, DPTH12_12_12,
6016 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_12LE),
6017 MAKE_YUV_FORMAT (I422_12BE, "raw video", 0x00000000, DPTH12_12_12,
6018 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_12BE),
6019 MAKE_YUV_LE_FORMAT (I422_12LE, "raw video", 0x00000000, DPTH12_12_12,
6020 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_12LE),
6021 MAKE_YUV_FORMAT (Y444_12BE, "raw video", 0x00000000, DPTH12_12_12,
6022 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_12BE),
6023 MAKE_YUV_LE_FORMAT (Y444_12LE, "raw video", 0x00000000, DPTH12_12_12,
6024 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_12LE),
6025 MAKE_GRAY_C_LE_FORMAT (GRAY10_LE32, "raw video", DPTH10, PSTR0, PLANE0, OFFS0,
6026 SUB4, PACK_GRAY10_LE32),
6027 MAKE_YUV_C_LE_FORMAT (NV12_10LE32, "raw video",
6028 GST_MAKE_FOURCC ('X', 'V', '1', '5'), DPTH10_10_10, PSTR0, PLANE011,
6029 OFFS001, SUB420, PACK_NV12_10LE32),
6030 MAKE_YUV_C_LE_FORMAT (NV16_10LE32, "raw video",
6031 GST_MAKE_FOURCC ('X', 'V', '2', '0'), DPTH10_10_10, PSTR0, PLANE011,
6032 OFFS001, SUB422, PACK_NV16_10LE32),
6033 MAKE_YUV_C_LE_FORMAT (NV12_10LE40, "raw video",
6034 GST_MAKE_FOURCC ('R', 'K', '2', '0'), DPTH10_10_10, PSTR0, PLANE011,
6035 OFFS0, SUB420, PACK_NV12_10LE40),
6036 MAKE_YUV_FORMAT (Y210, "raw video", GST_MAKE_FOURCC ('Y', '2', '1', '0'),
6037 DPTH10_10_10, PSTR488, PLANE0, OFFS0, SUB422, PACK_Y210),
6038 MAKE_YUV_FORMAT (Y410, "raw video", GST_MAKE_FOURCC ('Y', '4', '1', '0'),
6039 DPTH10_10_10_2, PSTR4444, PLANE0, OFFS0, SUB4444, PACK_Y410),
6040 MAKE_YUVA_PACK_FORMAT (VUYA, "raw video", GST_MAKE_FOURCC ('V', 'U', 'Y',
6041 'A'), DPTH8888, PSTR4444, PLANE0, OFFS2103, SUB4444, PACK_VUYA),
6042 MAKE_RGBA_LE_PACK_FORMAT (BGR10A2_LE, "raw video", DPTH10_10_10_2, PSTR4444,
6044 OFFS0, SUB4444, PACK_BGR10A2_LE),
6045 MAKE_RGBA_LE_PACK_FORMAT (RGB10A2_LE, "raw video", DPTH10_10_10_2, PSTR4444,
6046 PLANE0, OFFS0, SUB4444, PACK_RGB10A2_LE),
6047 MAKE_YUV_FORMAT (Y444_16BE, "raw video", 0x00000000, DPTH16_16_16,
6048 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_16BE),
6049 MAKE_YUV_LE_FORMAT (Y444_16LE, "raw video", 0x00000000, DPTH16_16_16,
6050 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_16LE),
6051 MAKE_YUV_FORMAT (P016_BE, "raw video", 0x00000000, DPTH16_16_16,
6052 PSTR244, PLANE011, OFFS001, SUB420, PACK_P016_BE),
6053 MAKE_YUV_LE_FORMAT (P016_LE, "raw video", 0x00000000, DPTH16_16_16,
6054 PSTR244, PLANE011, OFFS001, SUB420, PACK_P016_LE),
6057 static GstVideoFormat
6058 gst_video_format_from_rgb32_masks (int red_mask, int green_mask, int blue_mask)
6060 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
6061 blue_mask == 0x0000ff00) {
6062 return GST_VIDEO_FORMAT_RGBx;
6064 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
6065 blue_mask == 0xff000000) {
6066 return GST_VIDEO_FORMAT_BGRx;
6068 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
6069 blue_mask == 0x000000ff) {
6070 return GST_VIDEO_FORMAT_xRGB;
6072 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
6073 blue_mask == 0x00ff0000) {
6074 return GST_VIDEO_FORMAT_xBGR;
6077 return GST_VIDEO_FORMAT_UNKNOWN;
6080 static GstVideoFormat
6081 gst_video_format_from_rgba32_masks (int red_mask, int green_mask,
6082 int blue_mask, int alpha_mask)
6084 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
6085 blue_mask == 0x0000ff00 && alpha_mask == 0x000000ff) {
6086 return GST_VIDEO_FORMAT_RGBA;
6088 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
6089 blue_mask == 0xff000000 && alpha_mask == 0x000000ff) {
6090 return GST_VIDEO_FORMAT_BGRA;
6092 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
6093 blue_mask == 0x000000ff && alpha_mask == 0xff000000) {
6094 return GST_VIDEO_FORMAT_ARGB;
6096 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
6097 blue_mask == 0x00ff0000 && alpha_mask == 0xff000000) {
6098 return GST_VIDEO_FORMAT_ABGR;
6100 return GST_VIDEO_FORMAT_UNKNOWN;
6103 static GstVideoFormat
6104 gst_video_format_from_rgb24_masks (int red_mask, int green_mask, int blue_mask)
6106 if (red_mask == 0xff0000 && green_mask == 0x00ff00 && blue_mask == 0x0000ff) {
6107 return GST_VIDEO_FORMAT_RGB;
6109 if (red_mask == 0x0000ff && green_mask == 0x00ff00 && blue_mask == 0xff0000) {
6110 return GST_VIDEO_FORMAT_BGR;
6113 return GST_VIDEO_FORMAT_UNKNOWN;
6116 #define GST_VIDEO_COMP1_MASK_16_INT 0xf800
6117 #define GST_VIDEO_COMP2_MASK_16_INT 0x07e0
6118 #define GST_VIDEO_COMP3_MASK_16_INT 0x001f
6120 #define GST_VIDEO_COMP1_MASK_15_INT 0x7c00
6121 #define GST_VIDEO_COMP2_MASK_15_INT 0x03e0
6122 #define GST_VIDEO_COMP3_MASK_15_INT 0x001f
6124 static GstVideoFormat
6125 gst_video_format_from_rgb16_masks (int red_mask, int green_mask, int blue_mask)
6127 if (red_mask == GST_VIDEO_COMP1_MASK_16_INT
6128 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
6129 && blue_mask == GST_VIDEO_COMP3_MASK_16_INT) {
6130 return GST_VIDEO_FORMAT_RGB16;
6132 if (red_mask == GST_VIDEO_COMP3_MASK_16_INT
6133 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
6134 && blue_mask == GST_VIDEO_COMP1_MASK_16_INT) {
6135 return GST_VIDEO_FORMAT_BGR16;
6137 if (red_mask == GST_VIDEO_COMP1_MASK_15_INT
6138 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
6139 && blue_mask == GST_VIDEO_COMP3_MASK_15_INT) {
6140 return GST_VIDEO_FORMAT_RGB15;
6142 if (red_mask == GST_VIDEO_COMP3_MASK_15_INT
6143 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
6144 && blue_mask == GST_VIDEO_COMP1_MASK_15_INT) {
6145 return GST_VIDEO_FORMAT_BGR15;
6147 return GST_VIDEO_FORMAT_UNKNOWN;
6151 * gst_video_format_from_masks:
6152 * @depth: the amount of bits used for a pixel
6153 * @bpp: the amount of bits used to store a pixel. This value is bigger than
6155 * @endianness: the endianness of the masks, #G_LITTLE_ENDIAN or #G_BIG_ENDIAN
6156 * @red_mask: the red mask
6157 * @green_mask: the green mask
6158 * @blue_mask: the blue mask
6159 * @alpha_mask: the alpha mask, or 0 if no alpha mask
6161 * Find the #GstVideoFormat for the given parameters.
6163 * Returns: a #GstVideoFormat or GST_VIDEO_FORMAT_UNKNOWN when the parameters to
6164 * not specify a known format.
6167 gst_video_format_from_masks (gint depth, gint bpp, gint endianness,
6168 guint red_mask, guint green_mask, guint blue_mask, guint alpha_mask)
6170 GstVideoFormat format;
6172 /* our caps system handles 24/32bpp RGB as big-endian. */
6173 if ((bpp == 24 || bpp == 32) && endianness == G_LITTLE_ENDIAN &&
6174 alpha_mask != 0xc0000000) {
6175 red_mask = GUINT32_TO_BE (red_mask);
6176 green_mask = GUINT32_TO_BE (green_mask);
6177 blue_mask = GUINT32_TO_BE (blue_mask);
6178 alpha_mask = GUINT32_TO_BE (alpha_mask);
6179 endianness = G_BIG_ENDIAN;
6187 if (depth == 32 && bpp == 32 && alpha_mask == 0xc0000000 &&
6188 endianness == G_LITTLE_ENDIAN) {
6189 if (red_mask == 0x3ff00000)
6190 format = GST_VIDEO_FORMAT_RGB10A2_LE;
6192 format = GST_VIDEO_FORMAT_BGR10A2_LE;
6193 } else if (depth == 30 && bpp == 32) {
6194 format = GST_VIDEO_FORMAT_r210;
6195 } else if (depth == 24 && bpp == 32) {
6196 format = gst_video_format_from_rgb32_masks (red_mask, green_mask,
6198 } else if (depth == 32 && bpp == 32 && alpha_mask) {
6199 format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
6200 blue_mask, alpha_mask);
6201 } else if (depth == 24 && bpp == 24) {
6202 format = gst_video_format_from_rgb24_masks (red_mask, green_mask,
6204 } else if ((depth == 15 || depth == 16) && bpp == 16 &&
6205 endianness == G_BYTE_ORDER) {
6206 format = gst_video_format_from_rgb16_masks (red_mask, green_mask,
6208 } else if (depth == 8 && bpp == 8) {
6209 format = GST_VIDEO_FORMAT_RGB8P;
6210 } else if (depth == 64 && bpp == 64) {
6211 format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
6212 blue_mask, alpha_mask);
6213 if (format == GST_VIDEO_FORMAT_ARGB) {
6214 format = GST_VIDEO_FORMAT_ARGB64;
6216 format = GST_VIDEO_FORMAT_UNKNOWN;
6219 format = GST_VIDEO_FORMAT_UNKNOWN;
6225 * gst_video_format_from_fourcc:
6226 * @fourcc: a FOURCC value representing raw YUV video
6228 * Converts a FOURCC value into the corresponding #GstVideoFormat.
6229 * If the FOURCC cannot be represented by #GstVideoFormat,
6230 * #GST_VIDEO_FORMAT_UNKNOWN is returned.
6232 * Returns: the #GstVideoFormat describing the FOURCC value
6235 gst_video_format_from_fourcc (guint32 fourcc)
6238 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
6239 return GST_VIDEO_FORMAT_I420;
6240 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
6241 return GST_VIDEO_FORMAT_YV12;
6242 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
6243 return GST_VIDEO_FORMAT_YUY2;
6244 case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
6245 return GST_VIDEO_FORMAT_YVYU;
6246 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
6247 return GST_VIDEO_FORMAT_UYVY;
6248 case GST_MAKE_FOURCC ('V', 'Y', 'U', 'Y'):
6249 return GST_VIDEO_FORMAT_VYUY;
6250 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
6251 return GST_VIDEO_FORMAT_AYUV;
6252 case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
6253 return GST_VIDEO_FORMAT_Y41B;
6254 case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
6255 return GST_VIDEO_FORMAT_Y42B;
6256 case GST_MAKE_FOURCC ('Y', '4', '4', '4'):
6257 return GST_VIDEO_FORMAT_Y444;
6258 case GST_MAKE_FOURCC ('v', '2', '1', '0'):
6259 return GST_VIDEO_FORMAT_v210;
6260 case GST_MAKE_FOURCC ('v', '2', '1', '6'):
6261 return GST_VIDEO_FORMAT_v216;
6262 case GST_MAKE_FOURCC ('Y', '2', '1', '0'):
6263 return GST_VIDEO_FORMAT_Y210;
6264 case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
6265 return GST_VIDEO_FORMAT_NV12;
6266 case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
6267 return GST_VIDEO_FORMAT_NV21;
6268 case GST_MAKE_FOURCC ('N', 'V', '1', '6'):
6269 return GST_VIDEO_FORMAT_NV16;
6270 case GST_MAKE_FOURCC ('N', 'V', '6', '1'):
6271 return GST_VIDEO_FORMAT_NV61;
6272 case GST_MAKE_FOURCC ('N', 'V', '2', '4'):
6273 return GST_VIDEO_FORMAT_NV24;
6274 case GST_MAKE_FOURCC ('v', '3', '0', '8'):
6275 return GST_VIDEO_FORMAT_v308;
6276 case GST_MAKE_FOURCC ('I', 'Y', 'U', '2'):
6277 return GST_VIDEO_FORMAT_IYU2;
6278 case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
6279 case GST_MAKE_FOURCC ('Y', '8', ' ', ' '):
6280 case GST_MAKE_FOURCC ('G', 'R', 'E', 'Y'):
6281 return GST_VIDEO_FORMAT_GRAY8;
6282 case GST_MAKE_FOURCC ('Y', '1', '6', ' '):
6283 return GST_VIDEO_FORMAT_GRAY16_LE;
6284 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'):
6285 return GST_VIDEO_FORMAT_UYVP;
6286 case GST_MAKE_FOURCC ('A', '4', '2', '0'):
6287 return GST_VIDEO_FORMAT_A420;
6288 case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
6289 return GST_VIDEO_FORMAT_YUV9;
6290 case GST_MAKE_FOURCC ('Y', 'V', 'U', '9'):
6291 return GST_VIDEO_FORMAT_YVU9;
6292 case GST_MAKE_FOURCC ('I', 'Y', 'U', '1'):
6293 return GST_VIDEO_FORMAT_IYU1;
6294 case GST_MAKE_FOURCC ('A', 'Y', '6', '4'):
6295 return GST_VIDEO_FORMAT_AYUV64;
6296 case GST_MAKE_FOURCC ('X', 'V', '1', '0'):
6297 return GST_VIDEO_FORMAT_GRAY10_LE32;
6298 case GST_MAKE_FOURCC ('X', 'V', '1', '5'):
6299 return GST_VIDEO_FORMAT_NV12_10LE32;
6300 case GST_MAKE_FOURCC ('X', 'V', '2', '0'):
6301 return GST_VIDEO_FORMAT_NV16_10LE32;
6302 case GST_MAKE_FOURCC ('R', 'K', '2', '0'):
6303 return GST_VIDEO_FORMAT_NV12_10LE40;
6304 case GST_MAKE_FOURCC ('Y', '4', '1', '0'):
6305 return GST_VIDEO_FORMAT_Y410;
6306 case GST_MAKE_FOURCC ('V', 'U', 'Y', 'A'):
6307 return GST_VIDEO_FORMAT_VUYA;
6308 case GST_MAKE_FOURCC ('A', 'R', '3', '0'):
6309 return GST_VIDEO_FORMAT_BGR10A2_LE;
6312 return GST_VIDEO_FORMAT_UNKNOWN;
6317 * gst_video_format_from_string:
6318 * @format: a format string
6320 * Convert the @format string to its #GstVideoFormat.
6322 * Returns: the #GstVideoFormat for @format or GST_VIDEO_FORMAT_UNKNOWN when the
6323 * string is not a known format.
6326 gst_video_format_from_string (const gchar * format)
6330 g_return_val_if_fail (format != NULL, GST_VIDEO_FORMAT_UNKNOWN);
6332 for (i = 0; i < G_N_ELEMENTS (formats); i++) {
6333 if (strcmp (GST_VIDEO_FORMAT_INFO_NAME (&formats[i].info), format) == 0)
6334 return GST_VIDEO_FORMAT_INFO_FORMAT (&formats[i].info);
6336 return GST_VIDEO_FORMAT_UNKNOWN;
6341 * gst_video_format_to_fourcc:
6342 * @format: a #GstVideoFormat video format
6344 * Converts a #GstVideoFormat value into the corresponding FOURCC. Only
6345 * a few YUV formats have corresponding FOURCC values. If @format has
6346 * no corresponding FOURCC value, 0 is returned.
6348 * Returns: the FOURCC corresponding to @format
6351 gst_video_format_to_fourcc (GstVideoFormat format)
6353 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
6355 if ((gint) format >= G_N_ELEMENTS (formats))
6358 return formats[format].fourcc;
6362 * gst_video_format_to_string:
6363 * @format: a #GstVideoFormat video format
6365 * Returns a string containing a descriptive name for
6366 * the #GstVideoFormat if there is one, or NULL otherwise.
6368 * Returns: the name corresponding to @format
6371 gst_video_format_to_string (GstVideoFormat format)
6373 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
6375 if ((gint) format >= G_N_ELEMENTS (formats))
6378 return GST_VIDEO_FORMAT_INFO_NAME (&formats[format].info);
6382 * gst_video_format_get_info:
6383 * @format: a #GstVideoFormat
6385 * Get the #GstVideoFormatInfo for @format
6387 * Returns: The #GstVideoFormatInfo for @format.
6389 const GstVideoFormatInfo *
6390 gst_video_format_get_info (GstVideoFormat format)
6392 g_return_val_if_fail ((gint) format < G_N_ELEMENTS (formats), NULL);
6394 return &formats[format].info;
6398 * gst_video_format_get_palette:
6399 * @format: a #GstVideoFormat
6400 * @size: (out): size of the palette in bytes
6402 * Get the default palette of @format. This the palette used in the pack
6403 * function for paletted formats.
6405 * Returns: (transfer none): the default palette of @format or %NULL when
6406 * @format does not have a palette.
6411 gst_video_format_get_palette (GstVideoFormat format, gsize * size)
6413 g_return_val_if_fail ((gint) format < G_N_ELEMENTS (formats), NULL);
6414 g_return_val_if_fail (size != NULL, NULL);
6417 case GST_VIDEO_FORMAT_RGB8P:
6418 *size = sizeof (std_palette_RGB8P);
6419 return std_palette_RGB8P;
6426 * gst_video_format_info_component:
6427 * @info: #GstVideoFormatInfo
6428 * @plane: a plane number
6429 * @components: (out): array used to store component numbers
6431 * Fill @components with the number of all the components packed in plane @p
6432 * for the format @info. A value of -1 in @components indicates that no more
6433 * components are packed in the plane.
6438 gst_video_format_info_component (const GstVideoFormatInfo * info, guint plane,
6439 gint components[GST_VIDEO_MAX_COMPONENTS])
6443 /* Reverse mapping of info->plane */
6444 for (c = 0; c < GST_VIDEO_FORMAT_INFO_N_COMPONENTS (info); c++) {
6445 if (GST_VIDEO_FORMAT_INFO_PLANE (info, c) == plane) {
6451 for (c = i; c < GST_VIDEO_MAX_COMPONENTS; c++)