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 for (i = 0; i < width / 2; i++) {
799 Y0 = GST_READ_UINT16_LE (s + i * 8 + 0);
800 U = GST_READ_UINT16_LE (s + i * 8 + 2);
801 V = GST_READ_UINT16_LE (s + i * 8 + 6);
802 Y1 = GST_READ_UINT16_LE (s + i * 8 + 4);
804 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
810 d[i * 8 + 0] = 0xffff;
815 d[i * 8 + 4] = 0xffff;
823 pack_Y210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
824 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
825 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
829 guint16 Y0, Y1, U, V;
830 guint8 *restrict d = GET_LINE (y);
831 const guint16 *restrict s = src;
833 for (i = 0; i < width; i += 2) {
834 Y0 = s[i * 4 + 1] & 0xffc0;
835 U = s[i * 4 + 2] & 0xffc0;
836 V = s[i * 4 + 3] & 0xffc0;
838 Y1 = s[i * 4 + 1] & 0xffc0;
840 Y1 = s[(i + 1) * 4 + 1] & 0xffc0;
842 GST_WRITE_UINT16_LE (d + i * 4 + 0, Y0);
843 GST_WRITE_UINT16_LE (d + i * 4 + 2, U);
844 GST_WRITE_UINT16_LE (d + i * 4 + 4, Y1);
845 GST_WRITE_UINT16_LE (d + i * 4 + 6, V);
849 #define PACK_Y41B GST_VIDEO_FORMAT_AYUV, unpack_Y41B, 1, pack_Y41B
851 unpack_Y41B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
852 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
853 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
855 const guint8 *restrict sy = GET_Y_LINE (y);
856 const guint8 *restrict su = GET_U_LINE (y);
857 const guint8 *restrict sv = GET_V_LINE (y);
858 guint8 *restrict d = dest;
877 if (IS_ALIGNED (d, 8))
878 video_orc_unpack_YUV9 (d, sy, su, sv, width / 2);
881 for (i = 0; i < width / 2; i++) {
883 d[i * 8 + 1] = sy[i * 2 + 0];
884 d[i * 8 + 2] = su[i >> 1];
885 d[i * 8 + 3] = sv[i >> 1];
887 d[i * 8 + 5] = sy[i * 2 + 1];
888 d[i * 8 + 6] = su[i >> 1];
889 d[i * 8 + 7] = sv[i >> 1];
897 d[i * 4 + 1] = sy[i];
898 d[i * 4 + 2] = su[i >> 2];
899 d[i * 4 + 3] = sv[i >> 2];
904 pack_Y41B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
905 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
906 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
910 guint8 *restrict dy = GET_Y_LINE (y);
911 guint8 *restrict du = GET_U_LINE (y);
912 guint8 *restrict dv = GET_V_LINE (y);
913 const guint8 *restrict s = src;
915 for (i = 0; i < width - 3; i += 4) {
916 dy[i] = s[i * 4 + 1];
917 dy[i + 1] = s[i * 4 + 5];
918 dy[i + 2] = s[i * 4 + 9];
919 dy[i + 3] = s[i * 4 + 13];
921 du[i >> 2] = s[i * 4 + 2];
922 dv[i >> 2] = s[i * 4 + 3];
925 dy[i] = s[i * 4 + 1];
926 du[i >> 2] = s[i * 4 + 2];
927 dv[i >> 2] = s[i * 4 + 3];
929 dy[i + 1] = s[i * 4 + 5];
931 dy[i + 2] = s[i * 4 + 9];
935 #define PACK_Y42B GST_VIDEO_FORMAT_AYUV, unpack_Y42B, 1, pack_Y42B
937 unpack_Y42B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
938 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
939 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
941 const guint8 *restrict sy = GET_Y_LINE (y);
942 const guint8 *restrict su = GET_U_LINE (y);
943 const guint8 *restrict sv = GET_V_LINE (y);
944 guint8 *restrict d = dest;
959 if (IS_ALIGNED (d, 8))
960 video_orc_unpack_Y42B (d, sy, su, sv, width / 2);
963 for (i = 0; i < width / 2; i++) {
965 d[i * 8 + 1] = sy[i * 2 + 0];
966 d[i * 8 + 2] = su[i];
967 d[i * 8 + 3] = sv[i];
969 d[i * 8 + 5] = sy[i * 2 + 1];
970 d[i * 8 + 6] = su[i];
971 d[i * 8 + 7] = sv[i];
979 d[i * 4 + 1] = sy[i];
980 d[i * 4 + 2] = su[i >> 1];
981 d[i * 4 + 3] = sv[i >> 1];
986 pack_Y42B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
987 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
988 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
991 guint8 *restrict dy = GET_Y_LINE (y);
992 guint8 *restrict du = GET_U_LINE (y);
993 guint8 *restrict dv = GET_V_LINE (y);
994 const guint8 *restrict s = src;
996 if (IS_ALIGNED (s, 8))
997 video_orc_pack_Y42B (dy, du, dv, s, width / 2);
1000 for (i = 0; i < width / 2; i++) {
1001 dy[i * 2 + 0] = s[i * 8 + 1];
1002 dy[i * 2 + 1] = s[i * 8 + 5];
1003 du[i] = s[i * 8 + 2];
1004 dv[i] = s[i * 8 + 3];
1011 dy[i] = s[i * 4 + 1];
1012 du[i >> 1] = s[i * 4 + 2];
1013 dv[i >> 1] = s[i * 4 + 3];
1017 #define PACK_Y444 GST_VIDEO_FORMAT_AYUV, unpack_Y444, 1, pack_Y444
1019 unpack_Y444 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1020 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1021 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1023 const guint8 *restrict sy = GET_Y_LINE (y);
1024 const guint8 *restrict su = GET_U_LINE (y);
1025 const guint8 *restrict sv = GET_V_LINE (y);
1031 video_orc_unpack_Y444 (dest, sy, su, sv, width);
1035 pack_Y444 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1036 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1037 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1040 guint8 *restrict dy = GET_Y_LINE (y);
1041 guint8 *restrict du = GET_U_LINE (y);
1042 guint8 *restrict dv = GET_V_LINE (y);
1044 video_orc_pack_Y444 (dy, du, dv, src, width);
1047 #define PACK_GBR GST_VIDEO_FORMAT_ARGB, unpack_GBR, 1, pack_GBR
1049 unpack_GBR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1050 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1051 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1053 const guint8 *restrict sr = GET_R_LINE (y);
1054 const guint8 *restrict sg = GET_G_LINE (y);
1055 const guint8 *restrict sb = GET_B_LINE (y);
1061 video_orc_unpack_Y444 (dest, sr, sg, sb, width);
1065 pack_GBR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1066 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1067 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1070 guint8 *restrict dr = GET_R_LINE (y);
1071 guint8 *restrict dg = GET_G_LINE (y);
1072 guint8 *restrict db = GET_B_LINE (y);
1074 video_orc_pack_Y444 (dr, dg, db, src, width);
1077 #define PACK_GBRA GST_VIDEO_FORMAT_ARGB, unpack_GBRA, 1, pack_GBRA
1079 unpack_GBRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1080 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1081 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1084 const guint8 *sg = GET_G_LINE (y);
1085 const guint8 *sb = GET_B_LINE (y);
1086 const guint8 *sr = GET_R_LINE (y);
1087 const guint8 *sa = GET_A_LINE (y);
1088 guint8 *d = dest, G, B, R, A;
1095 for (i = 0; i < width; i++) {
1096 G = GST_READ_UINT8 (sg + i);
1097 B = GST_READ_UINT8 (sb + i);
1098 R = GST_READ_UINT8 (sr + i);
1099 A = GST_READ_UINT8 (sa + i);
1109 pack_GBRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1110 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1111 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1115 guint8 *restrict dg = GET_G_LINE (y);
1116 guint8 *restrict db = GET_B_LINE (y);
1117 guint8 *restrict dr = GET_R_LINE (y);
1118 guint8 *restrict da = GET_A_LINE (y);
1120 const guint8 *restrict s = src;
1122 for (i = 0; i < width; i++) {
1128 GST_WRITE_UINT8 (dg + i, G);
1129 GST_WRITE_UINT8 (db + i, B);
1130 GST_WRITE_UINT8 (dr + i, R);
1131 GST_WRITE_UINT8 (da + i, A);
1135 #define PACK_GRAY8 GST_VIDEO_FORMAT_AYUV, unpack_GRAY8, 1, pack_GRAY8
1137 unpack_GRAY8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1138 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1139 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1141 const guint8 *restrict s = GET_LINE (y);
1145 video_orc_unpack_GRAY8 (dest, s, width);
1149 pack_GRAY8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1150 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1151 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1154 guint8 *restrict d = GET_LINE (y);
1156 video_orc_pack_GRAY8 (d, src, width);
1159 #define PACK_GRAY16_BE GST_VIDEO_FORMAT_AYUV64, unpack_GRAY16_BE, 1, pack_GRAY16_BE
1161 unpack_GRAY16_BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1162 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1163 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1166 const guint16 *restrict s = GET_LINE (y);
1167 guint16 *restrict d = dest;
1171 for (i = 0; i < width; i++) {
1172 d[i * 4 + 0] = 0xffff;
1173 d[i * 4 + 1] = GST_READ_UINT16_BE (s + i);
1174 d[i * 4 + 2] = 0x8000;
1175 d[i * 4 + 3] = 0x8000;
1180 pack_GRAY16_BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1181 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1182 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1186 guint16 *restrict d = GET_LINE (y);
1187 const guint16 *restrict s = src;
1189 for (i = 0; i < width; i++) {
1190 GST_WRITE_UINT16_BE (d + i, s[i * 4 + 1]);
1194 #define PACK_GRAY16_LE GST_VIDEO_FORMAT_AYUV64, unpack_GRAY16_LE, 1, pack_GRAY16_LE
1196 unpack_GRAY16_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1197 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1198 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1201 const guint16 *restrict s = GET_LINE (y);
1202 guint16 *restrict d = dest;
1206 for (i = 0; i < width; i++) {
1207 d[i * 4 + 0] = 0xffff;
1208 d[i * 4 + 1] = GST_READ_UINT16_LE (s + i);
1209 d[i * 4 + 2] = 0x8000;
1210 d[i * 4 + 3] = 0x8000;
1215 pack_GRAY16_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1216 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1217 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1221 guint16 *restrict d = GET_LINE (y);
1222 const guint16 *restrict s = src;
1224 for (i = 0; i < width; i++) {
1225 GST_WRITE_UINT16_LE (d + i, s[i * 4 + 1]);
1229 #define PACK_RGB16 GST_VIDEO_FORMAT_ARGB, unpack_RGB16, 1, pack_RGB16
1231 unpack_RGB16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1232 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1233 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1235 const guint16 *restrict s = GET_LINE (y);
1237 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1238 video_orc_unpack_RGB16_trunc (dest, s + x, width);
1240 video_orc_unpack_RGB16 (dest, s + x, width);
1244 pack_RGB16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1245 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1246 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1249 guint16 *restrict d = GET_LINE (y);
1251 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1252 video_orc_pack_RGB16_le (d, src, width);
1254 video_orc_pack_RGB16_be (d, src, width);
1258 #define PACK_BGR16 GST_VIDEO_FORMAT_ARGB, unpack_BGR16, 1, pack_BGR16
1260 unpack_BGR16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1261 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1262 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1264 const guint16 *restrict s = GET_LINE (y);
1266 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1267 video_orc_unpack_BGR16_trunc (dest, s + x, width);
1269 video_orc_unpack_BGR16 (dest, s + x, width);
1273 pack_BGR16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1274 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1275 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1278 guint16 *restrict d = GET_LINE (y);
1280 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1281 video_orc_pack_BGR16_le (d, src, width);
1283 video_orc_pack_BGR16_be (d, src, width);
1287 #define PACK_RGB15 GST_VIDEO_FORMAT_ARGB, unpack_RGB15, 1, pack_RGB15
1289 unpack_RGB15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1290 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1291 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1293 const guint16 *restrict s = GET_LINE (y);
1295 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1296 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1297 video_orc_unpack_RGB15_le_trunc (dest, s + x, width);
1299 video_orc_unpack_RGB15_le (dest, s + x, width);
1301 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1302 video_orc_unpack_RGB15_be_trunc (dest, s + x, width);
1304 video_orc_unpack_RGB15_be (dest, s + x, width);
1309 pack_RGB15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1310 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1311 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1314 guint16 *restrict d = GET_LINE (y);
1316 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1317 video_orc_pack_RGB15_le (d, src, width);
1319 video_orc_pack_RGB15_be (d, src, width);
1323 #define PACK_BGR15 GST_VIDEO_FORMAT_ARGB, unpack_BGR15, 1, pack_BGR15
1325 unpack_BGR15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1326 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1327 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1329 const guint16 *restrict s = GET_LINE (y);
1331 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1332 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1333 video_orc_unpack_BGR15_le_trunc (dest, s + x, width);
1335 video_orc_unpack_BGR15_le (dest, s + x, width);
1337 if (flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)
1338 video_orc_unpack_BGR15_be_trunc (dest, s + x, width);
1340 video_orc_unpack_BGR15_be (dest, s + x, width);
1345 pack_BGR15 (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_BGR15_le (d, src, width);
1355 video_orc_pack_BGR15_be (d, src, width);
1359 #define PACK_BGRA GST_VIDEO_FORMAT_ARGB, unpack_BGRA, 1, pack_BGRA
1361 unpack_BGRA (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 guint8 *restrict s = GET_LINE (y);
1369 video_orc_unpack_BGRA (dest, s, width);
1373 pack_BGRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1374 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1375 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1378 guint8 *restrict d = GET_LINE (y);
1380 video_orc_pack_BGRA (d, src, width);
1383 #define PACK_ABGR GST_VIDEO_FORMAT_ARGB, unpack_ABGR, 1, pack_ABGR
1385 unpack_ABGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1386 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1387 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1389 const guint8 *restrict s = GET_LINE (y);
1393 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1394 video_orc_unpack_ABGR_le (dest, s, width);
1396 video_orc_unpack_ABGR_be (dest, s, width);
1401 pack_ABGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1402 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1403 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1406 guint8 *restrict d = GET_LINE (y);
1408 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1409 video_orc_pack_ABGR_le (d, src, width);
1411 video_orc_pack_ABGR_be (d, src, width);
1415 #define PACK_RGBA GST_VIDEO_FORMAT_ARGB, unpack_RGBA, 1, pack_RGBA
1417 unpack_RGBA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1418 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1419 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1421 const guint8 *restrict s = GET_LINE (y);
1425 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1426 video_orc_unpack_RGBA_le (dest, s, width);
1428 video_orc_unpack_RGBA_be (dest, s, width);
1433 pack_RGBA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1434 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1435 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1438 guint8 *restrict d = GET_LINE (y);
1440 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1441 video_orc_pack_RGBA_le (d, src, width);
1443 video_orc_pack_RGBA_be (d, src, width);
1447 #define PACK_RGB GST_VIDEO_FORMAT_ARGB, unpack_RGB, 1, pack_RGB
1449 unpack_RGB (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1450 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1451 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1454 const guint8 *restrict s = GET_LINE (y);
1455 guint8 *restrict d = dest;
1459 for (i = 0; i < width; i++) {
1460 d[i * 4 + 0] = 0xff;
1461 d[i * 4 + 1] = s[i * 3 + 0];
1462 d[i * 4 + 2] = s[i * 3 + 1];
1463 d[i * 4 + 3] = s[i * 3 + 2];
1468 pack_RGB (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1469 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1470 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1474 guint8 *restrict d = GET_LINE (y);
1475 const guint8 *restrict s = src;
1477 for (i = 0; i < width; i++) {
1478 d[i * 3 + 0] = s[i * 4 + 1];
1479 d[i * 3 + 1] = s[i * 4 + 2];
1480 d[i * 3 + 2] = s[i * 4 + 3];
1484 #define PACK_BGR GST_VIDEO_FORMAT_ARGB, unpack_BGR, 1, pack_BGR
1486 unpack_BGR (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)
1491 const guint8 *restrict s = GET_LINE (y);
1492 guint8 *restrict d = dest;
1496 for (i = 0; i < width; i++) {
1497 d[i * 4 + 0] = 0xff;
1498 d[i * 4 + 1] = s[i * 3 + 2];
1499 d[i * 4 + 2] = s[i * 3 + 1];
1500 d[i * 4 + 3] = s[i * 3 + 0];
1505 pack_BGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1506 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1507 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1511 guint8 *restrict d = GET_LINE (y);
1512 const guint8 *restrict s = src;
1514 for (i = 0; i < width; i++) {
1515 d[i * 3 + 0] = s[i * 4 + 3];
1516 d[i * 3 + 1] = s[i * 4 + 2];
1517 d[i * 3 + 2] = s[i * 4 + 1];
1521 #define PACK_NV12 GST_VIDEO_FORMAT_AYUV, unpack_NV12, 1, pack_NV12
1523 unpack_NV12 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1524 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1525 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1527 gint uv = GET_UV_420 (y, flags);
1528 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1529 const guint8 *restrict suv = GET_PLANE_LINE (1, uv);
1530 guint8 *restrict d = dest;
1545 if (IS_ALIGNED (d, 8))
1546 video_orc_unpack_NV12 (d, sy, suv, width / 2);
1549 for (i = 0; i < width / 2; i++) {
1550 d[i * 8 + 0] = 0xff;
1551 d[i * 8 + 1] = sy[i * 2 + 0];
1552 d[i * 8 + 2] = suv[i * 2 + 0];
1553 d[i * 8 + 3] = suv[i * 2 + 1];
1554 d[i * 8 + 4] = 0xff;
1555 d[i * 8 + 5] = sy[i * 2 + 1];
1556 d[i * 8 + 6] = suv[i * 2 + 0];
1557 d[i * 8 + 7] = suv[i * 2 + 1];
1564 d[i * 4 + 0] = 0xff;
1565 d[i * 4 + 1] = sy[i];
1566 d[i * 4 + 2] = suv[i + 0];
1567 d[i * 4 + 3] = suv[i + 1];
1572 pack_NV12 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1573 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1574 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1577 gint uv = GET_UV_420 (y, flags);
1578 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1579 guint8 *restrict duv = GET_PLANE_LINE (1, uv);
1580 const guint8 *restrict s = src;
1582 if (IS_CHROMA_LINE_420 (y, flags)) {
1583 if (IS_ALIGNED (s, 8))
1584 video_orc_pack_NV12 (dy, duv, s, width / 2);
1587 for (i = 0; i < width / 2; i++) {
1588 dy[i * 2 + 0] = s[i * 8 + 1];
1589 dy[i * 2 + 1] = s[i * 8 + 5];
1590 duv[i * 2 + 0] = s[i * 8 + 2];
1591 duv[i * 2 + 1] = s[i * 8 + 3];
1597 dy[i] = s[i * 4 + 1];
1598 duv[i + 0] = s[i * 4 + 2];
1599 duv[i + 1] = s[i * 4 + 3];
1602 video_orc_pack_Y (dy, s, width);
1605 #define PACK_NV21 GST_VIDEO_FORMAT_AYUV, unpack_NV21, 1, pack_NV21
1607 unpack_NV21 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1608 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1609 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1611 gint uv = GET_UV_420 (y, flags);
1612 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1613 const guint8 *restrict suv = GET_PLANE_LINE (1, uv);
1614 guint8 *restrict d = dest;
1629 if (IS_ALIGNED (d, 8))
1630 video_orc_unpack_NV21 (d, sy, suv, width / 2);
1633 for (i = 0; i < width / 2; i++) {
1634 d[i * 8 + 0] = 0xff;
1635 d[i * 8 + 1] = sy[i * 2 + 0];
1636 d[i * 8 + 2] = suv[i * 2 + 1];
1637 d[i * 8 + 3] = suv[i * 2 + 0];
1638 d[i * 8 + 4] = 0xff;
1639 d[i * 8 + 5] = sy[i * 2 + 1];
1640 d[i * 8 + 6] = suv[i * 2 + 1];
1641 d[i * 8 + 7] = suv[i * 2 + 0];
1648 d[i * 4 + 0] = 0xff;
1649 d[i * 4 + 1] = sy[i];
1650 d[i * 4 + 2] = suv[i + 1];
1651 d[i * 4 + 3] = suv[i + 0];
1656 pack_NV21 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1657 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1658 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1661 gint uv = GET_UV_420 (y, flags);
1662 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1663 guint8 *restrict duv = GET_PLANE_LINE (1, uv);
1664 const guint8 *restrict s = src;
1666 if (IS_CHROMA_LINE_420 (y, flags)) {
1667 if (IS_ALIGNED (s, 8))
1668 video_orc_pack_NV21 (dy, duv, s, width / 2);
1671 for (i = 0; i < width / 2; i++) {
1672 dy[i * 2 + 0] = s[i * 8 + 1];
1673 dy[i * 2 + 1] = s[i * 8 + 5];
1674 duv[i * 2 + 0] = s[i * 8 + 3];
1675 duv[i * 2 + 1] = s[i * 8 + 2];
1681 dy[i] = s[i * 4 + 1];
1682 duv[i + 0] = s[i * 4 + 3];
1683 duv[i + 1] = s[i * 4 + 2];
1686 video_orc_pack_Y (dy, s, width);
1689 #define PACK_NV16 GST_VIDEO_FORMAT_AYUV, unpack_NV16, 1, pack_NV16
1691 unpack_NV16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1692 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1693 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1695 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1696 const guint8 *restrict suv = GET_PLANE_LINE (1, y);
1697 guint8 *restrict d = dest;
1712 if (IS_ALIGNED (d, 8))
1713 video_orc_unpack_NV12 (d, sy, suv, width / 2);
1716 for (i = 0; i < width / 2; i++) {
1717 d[i * 8 + 0] = 0xff;
1718 d[i * 8 + 1] = sy[i * 2 + 0];
1719 d[i * 8 + 2] = suv[i * 2 + 0];
1720 d[i * 8 + 3] = suv[i * 2 + 1];
1721 d[i * 8 + 4] = 0xff;
1722 d[i * 8 + 5] = sy[i * 2 + 1];
1723 d[i * 8 + 6] = suv[i * 2 + 0];
1724 d[i * 8 + 7] = suv[i * 2 + 1];
1731 d[i * 4 + 0] = 0xff;
1732 d[i * 4 + 1] = sy[i];
1733 d[i * 4 + 2] = suv[i + 0];
1734 d[i * 4 + 3] = suv[i + 1];
1739 pack_NV16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1740 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1741 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1744 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1745 guint8 *restrict duv = GET_PLANE_LINE (1, y);
1746 const guint8 *restrict s = src;
1748 if (IS_ALIGNED (s, 8))
1749 video_orc_pack_NV12 (dy, duv, s, width / 2);
1752 for (i = 0; i < width / 2; i++) {
1753 dy[i * 2 + 0] = s[i * 8 + 1];
1754 dy[i * 2 + 1] = s[i * 8 + 5];
1755 duv[i * 2 + 0] = s[i * 8 + 2];
1756 duv[i * 2 + 1] = s[i * 8 + 3];
1763 dy[i] = s[i * 4 + 1];
1764 duv[i + 0] = s[i * 4 + 2];
1765 duv[i + 1] = s[i * 4 + 3];
1769 #define PACK_NV61 GST_VIDEO_FORMAT_AYUV, unpack_NV61, 1, pack_NV61
1771 unpack_NV61 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1772 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1773 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1775 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1776 const guint8 *restrict svu = GET_PLANE_LINE (1, y);
1777 guint8 *restrict d = dest;
1792 if (IS_ALIGNED (d, 8)) {
1793 video_orc_unpack_NV21 (d, sy, svu, width / 2);
1797 for (i = 0; i < width / 2; i++) {
1798 d[i * 8 + 0] = 0xff;
1799 d[i * 8 + 1] = sy[i * 2 + 0];
1800 d[i * 8 + 2] = svu[i * 2 + 1];
1801 d[i * 8 + 3] = svu[i * 2 + 0];
1802 d[i * 8 + 4] = 0xff;
1803 d[i * 8 + 5] = sy[i * 2 + 1];
1804 d[i * 8 + 6] = svu[i * 2 + 1];
1805 d[i * 8 + 7] = svu[i * 2 + 0];
1812 d[i * 4 + 0] = 0xff;
1813 d[i * 4 + 1] = sy[i];
1814 d[i * 4 + 2] = svu[i + 1];
1815 d[i * 4 + 3] = svu[i + 0];
1820 pack_NV61 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1821 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1822 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1825 const guint8 *restrict s = src;
1826 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1827 guint8 *restrict dvu = GET_PLANE_LINE (1, y);
1829 if (IS_ALIGNED (s, 8)) {
1830 video_orc_pack_NV21 (dy, dvu, s, width / 2);
1834 for (i = 0; i < width / 2; i++) {
1835 dy[i * 2 + 0] = s[i * 8 + 1];
1836 dy[i * 2 + 1] = s[i * 8 + 5];
1837 dvu[i * 2 + 0] = s[i * 8 + 3];
1838 dvu[i * 2 + 1] = s[i * 8 + 2];
1845 dy[i] = s[i * 4 + 1];
1846 dvu[i + 0] = s[i * 4 + 2];
1847 dvu[i + 1] = s[i * 4 + 3];
1851 #define PACK_NV24 GST_VIDEO_FORMAT_AYUV, unpack_NV24, 1, pack_NV24
1853 unpack_NV24 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1854 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1855 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1857 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
1858 const guint8 *restrict suv = GET_PLANE_LINE (1, y);
1863 video_orc_unpack_NV24 (dest, sy, suv, width);
1867 pack_NV24 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1868 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1869 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1872 guint8 *restrict dy = GET_PLANE_LINE (0, y);
1873 guint8 *restrict duv = GET_PLANE_LINE (1, y);
1875 video_orc_pack_NV24 (dy, duv, src, width);
1878 #define PACK_UYVP GST_VIDEO_FORMAT_AYUV64, unpack_UYVP, 1, pack_UYVP
1880 unpack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1881 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1882 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1885 const guint8 *restrict s = GET_LINE (y);
1886 guint16 *restrict d = dest;
1891 for (i = 0; i < width; i += 2) {
1896 u0 = ((s[(i / 2) * 5 + 0] << 2) | (s[(i / 2) * 5 + 1] >> 6)) << 6;
1897 y0 = (((s[(i / 2) * 5 + 1] & 0x3f) << 4) | (s[(i / 2) * 5 + 2] >> 4)) << 6;
1898 v0 = (((s[(i / 2) * 5 + 2] & 0x0f) << 6) | (s[(i / 2) * 5 + 3] >> 2)) << 6;
1899 y1 = (((s[(i / 2) * 5 + 3] & 0x03) << 8) | s[(i / 2) * 5 + 4]) << 6;
1901 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
1908 d[i * 4 + 0] = 0xffff;
1913 if (i < width - 1) {
1914 d[i * 4 + 4] = 0xffff;
1923 pack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1924 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1925 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1929 guint8 *restrict d = GET_LINE (y);
1930 const guint16 *restrict s = src;
1932 for (i = 0; i < width; i += 2) {
1937 y0 = s[4 * (i + 0) + 1];
1939 y1 = s[4 * (i + 1) + 1];
1943 u0 = s[4 * (i + 0) + 2];
1944 v0 = s[4 * (i + 0) + 3];
1946 d[(i / 2) * 5 + 0] = u0 >> 8;
1947 d[(i / 2) * 5 + 1] = (u0 & 0xc0) | y0 >> 10;
1948 d[(i / 2) * 5 + 2] = ((y0 & 0x3c0) >> 2) | (v0 >> 12);
1949 d[(i / 2) * 5 + 3] = ((v0 & 0xfc0) >> 4) | (y1 >> 14);
1950 d[(i / 2) * 5 + 4] = (y1 >> 6);
1954 #define PACK_A420 GST_VIDEO_FORMAT_AYUV, unpack_A420, 1, pack_A420
1956 unpack_A420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1957 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1958 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1960 gint uv = GET_UV_420 (y, flags);
1961 const guint8 *restrict sy = GET_Y_LINE (y);
1962 const guint8 *restrict su = GET_U_LINE (uv);
1963 const guint8 *restrict sv = GET_V_LINE (uv);
1964 const guint8 *restrict sa = GET_A_LINE (y);
1965 guint8 *restrict d = dest;
1980 video_orc_unpack_A420 (d, sy, su, sv, sa, width);
1984 pack_A420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1985 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1986 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1989 gint uv = GET_UV_420 (y, flags);
1990 guint8 *restrict dy = GET_Y_LINE (y);
1991 guint8 *restrict du = GET_U_LINE (uv);
1992 guint8 *restrict dv = GET_V_LINE (uv);
1993 guint8 *restrict da = GET_A_LINE (y);
1994 const guint8 *restrict s = src;
1996 if (IS_CHROMA_LINE_420 (y, flags)) {
1997 if (IS_ALIGNED (s, 8))
1998 video_orc_pack_A420 (dy, du, dv, da, s, width / 2);
2001 for (i = 0; i < width / 2; i++) {
2002 da[i * 2 + 0] = s[i * 8 + 0];
2003 dy[i * 2 + 0] = s[i * 8 + 1];
2004 da[i * 2 + 1] = s[i * 8 + 4];
2005 dy[i * 2 + 1] = s[i * 8 + 5];
2006 du[i] = s[i * 8 + 2];
2007 dv[i] = s[i * 8 + 3];
2014 da[i] = s[i * 4 + 0];
2015 dy[i] = s[i * 4 + 1];
2016 du[i >> 1] = s[i * 4 + 2];
2017 dv[i >> 1] = s[i * 4 + 3];
2020 video_orc_pack_AY (dy, da, s, width);
2023 #define PACK_RGB8P GST_VIDEO_FORMAT_ARGB, unpack_RGB8P, 1, pack_RGB8P
2025 unpack_RGB8P (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2026 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2027 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2030 const guint8 *restrict s = GET_LINE (y);
2031 const guint32 *restrict p = data[1];
2032 guint8 *restrict d = dest;
2036 for (i = 0; i < width; i++) {
2037 guint32 v = p[s[i]];
2038 d[i * 4 + 0] = (v >> 24) & 0xff;
2039 d[i * 4 + 1] = (v >> 16) & 0xff;
2040 d[i * 4 + 2] = (v >> 8) & 0xff;
2041 d[i * 4 + 3] = (v) & 0xff;
2045 static const guint32 std_palette_RGB8P[] = {
2046 0xff000000, 0xff000033, 0xff000066, 0xff000099, 0xff0000cc, 0xff0000ff,
2047 0xff003300, 0xff003333, 0xff003366, 0xff003399, 0xff0033cc, 0xff0033ff,
2048 0xff006600, 0xff006633, 0xff006666, 0xff006699, 0xff0066cc, 0xff0066ff,
2049 0xff009900, 0xff009933, 0xff009966, 0xff009999, 0xff0099cc, 0xff0099ff,
2050 0xff00cc00, 0xff00cc33, 0xff00cc66, 0xff00cc99, 0xff00cccc, 0xff00ccff,
2051 0xff00ff00, 0xff00ff33, 0xff00ff66, 0xff00ff99, 0xff00ffcc, 0xff00ffff,
2052 0xff330000, 0xff330033, 0xff330066, 0xff330099, 0xff3300cc, 0xff3300ff,
2053 0xff333300, 0xff333333, 0xff333366, 0xff333399, 0xff3333cc, 0xff3333ff,
2054 0xff336600, 0xff336633, 0xff336666, 0xff336699, 0xff3366cc, 0xff3366ff,
2055 0xff339900, 0xff339933, 0xff339966, 0xff339999, 0xff3399cc, 0xff3399ff,
2056 0xff33cc00, 0xff33cc33, 0xff33cc66, 0xff33cc99, 0xff33cccc, 0xff33ccff,
2057 0xff33ff00, 0xff33ff33, 0xff33ff66, 0xff33ff99, 0xff33ffcc, 0xff33ffff,
2058 0xff660000, 0xff660033, 0xff660066, 0xff660099, 0xff6600cc, 0xff6600ff,
2059 0xff663300, 0xff663333, 0xff663366, 0xff663399, 0xff6633cc, 0xff6633ff,
2060 0xff666600, 0xff666633, 0xff666666, 0xff666699, 0xff6666cc, 0xff6666ff,
2061 0xff669900, 0xff669933, 0xff669966, 0xff669999, 0xff6699cc, 0xff6699ff,
2062 0xff66cc00, 0xff66cc33, 0xff66cc66, 0xff66cc99, 0xff66cccc, 0xff66ccff,
2063 0xff66ff00, 0xff66ff33, 0xff66ff66, 0xff66ff99, 0xff66ffcc, 0xff66ffff,
2064 0xff990000, 0xff990033, 0xff990066, 0xff990099, 0xff9900cc, 0xff9900ff,
2065 0xff993300, 0xff993333, 0xff993366, 0xff993399, 0xff9933cc, 0xff9933ff,
2066 0xff996600, 0xff996633, 0xff996666, 0xff996699, 0xff9966cc, 0xff9966ff,
2067 0xff999900, 0xff999933, 0xff999966, 0xff999999, 0xff9999cc, 0xff9999ff,
2068 0xff99cc00, 0xff99cc33, 0xff99cc66, 0xff99cc99, 0xff99cccc, 0xff99ccff,
2069 0xff99ff00, 0xff99ff33, 0xff99ff66, 0xff99ff99, 0xff99ffcc, 0xff99ffff,
2070 0xffcc0000, 0xffcc0033, 0xffcc0066, 0xffcc0099, 0xffcc00cc, 0xffcc00ff,
2071 0xffcc3300, 0xffcc3333, 0xffcc3366, 0xffcc3399, 0xffcc33cc, 0xffcc33ff,
2072 0xffcc6600, 0xffcc6633, 0xffcc6666, 0xffcc6699, 0xffcc66cc, 0xffcc66ff,
2073 0xffcc9900, 0xffcc9933, 0xffcc9966, 0xffcc9999, 0xffcc99cc, 0xffcc99ff,
2074 0xffcccc00, 0xffcccc33, 0xffcccc66, 0xffcccc99, 0xffcccccc, 0xffccccff,
2075 0xffccff00, 0xffccff33, 0xffccff66, 0xffccff99, 0xffccffcc, 0xffccffff,
2076 0xffff0000, 0xffff0033, 0xffff0066, 0xffff0099, 0xffff00cc, 0xffff00ff,
2077 0xffff3300, 0xffff3333, 0xffff3366, 0xffff3399, 0xffff33cc, 0xffff33ff,
2078 0xffff6600, 0xffff6633, 0xffff6666, 0xffff6699, 0xffff66cc, 0xffff66ff,
2079 0xffff9900, 0xffff9933, 0xffff9966, 0xffff9999, 0xffff99cc, 0xffff99ff,
2080 0xffffcc00, 0xffffcc33, 0xffffcc66, 0xffffcc99, 0xffffcccc, 0xffffccff,
2081 0xffffff00, 0xffffff33, 0xffffff66, 0xffffff99, 0xffffffcc, 0xffffffff,
2082 0x00000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2083 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2084 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2085 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2086 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2087 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
2088 0xff000000, 0xff000000, 0xff000000, 0xff000000
2092 pack_RGB8P (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2093 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2094 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2098 guint8 *restrict d = GET_LINE (y);
2099 const guint8 *restrict s = src;
2101 /* Use our poor man's palette, taken from ffmpegcolorspace too */
2102 for (i = 0; i < width; i++) {
2103 /* crude approximation for alpha ! */
2104 if (s[i * 4 + 0] < 0x80)
2108 ((((s[i * 4 + 1]) / 47) % 6) * 6 * 6 + (((s[i * 4 +
2109 2]) / 47) % 6) * 6 + (((s[i * 4 + 3]) / 47) % 6));
2113 #define PACK_410 GST_VIDEO_FORMAT_AYUV, unpack_410, 1, pack_410
2115 unpack_410 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2116 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2117 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2119 gint uv = GET_UV_410 (y, flags);
2120 const guint8 *restrict sy = GET_Y_LINE (y);
2121 const guint8 *restrict su = GET_U_LINE (uv);
2122 const guint8 *restrict sv = GET_V_LINE (uv);
2123 guint8 *restrict d = dest;
2130 for (; x & 3; x++) {
2142 if (IS_ALIGNED (d, 8))
2143 video_orc_unpack_YUV9 (d, sy, su, sv, width / 2);
2146 for (i = 0; i < width / 2; i++) {
2147 d[i * 8 + 0] = 0xff;
2148 d[i * 8 + 1] = sy[i * 2 + 0];
2149 d[i * 8 + 2] = su[i >> 1];
2150 d[i * 8 + 3] = sv[i >> 1];
2151 d[i * 8 + 4] = 0xff;
2152 d[i * 8 + 5] = sy[i * 2 + 1];
2153 d[i * 8 + 6] = su[i >> 1];
2154 d[i * 8 + 7] = sv[i >> 1];
2161 d[i * 4 + 0] = 0xff;
2162 d[i * 4 + 1] = sy[i];
2163 d[i * 4 + 2] = su[i >> 2];
2164 d[i * 4 + 3] = sv[i >> 2];
2169 pack_410 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2170 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2171 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2175 gint uv = GET_UV_410 (y, flags);
2176 guint8 *restrict dy = GET_Y_LINE (y);
2177 guint8 *restrict du = GET_U_LINE (uv);
2178 guint8 *restrict dv = GET_V_LINE (uv);
2179 const guint8 *restrict s = src;
2181 for (i = 0; i < width - 3; i += 4) {
2182 dy[i] = s[i * 4 + 1];
2183 dy[i + 1] = s[i * 4 + 5];
2184 dy[i + 2] = s[i * 4 + 9];
2185 dy[i + 3] = s[i * 4 + 13];
2186 if (IS_CHROMA_LINE_410 (y, flags)) {
2187 du[i >> 2] = s[i * 4 + 2];
2188 dv[i >> 2] = s[i * 4 + 3];
2192 dy[i] = s[i * 4 + 1];
2193 if (IS_CHROMA_LINE_410 (y, flags)) {
2194 du[i >> 2] = s[i * 4 + 2];
2195 dv[i >> 2] = s[i * 4 + 3];
2198 dy[i + 1] = s[i * 4 + 5];
2200 dy[i + 2] = s[i * 4 + 9];
2204 #define PACK_IYU1 GST_VIDEO_FORMAT_AYUV, unpack_IYU1, 1, pack_IYU1
2206 unpack_IYU1 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2207 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2208 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2211 const guint8 *restrict s = GET_LINE (y);
2212 guint8 *restrict d = dest;
2213 guint8 y0, y1, y2, y3;
2220 for (i = 0; i < width - 3; i += 4) {
2221 y0 = s[(i >> 2) * 6 + 1];
2222 y1 = s[(i >> 2) * 6 + 2];
2223 y2 = s[(i >> 2) * 6 + 4];
2224 y3 = s[(i >> 2) * 6 + 5];
2226 u0 = s[(i >> 2) * 6 + 0];
2227 v0 = s[(i >> 2) * 6 + 3];
2229 d[i * 4 + 0] = 0xff;
2234 d[i * 4 + 4] = 0xff;
2239 d[i * 4 + 8] = 0xff;
2244 d[i * 4 + 12] = 0xff;
2250 u0 = s[(i >> 2) * 6 + 0];
2251 v0 = s[(i >> 2) * 6 + 3];
2253 d[i * 4 + 0] = 0xff;
2254 d[i * 4 + 1] = s[(i >> 2) * 6 + 1];
2258 if (i < width - 1) {
2259 d[i * 4 + 4] = 0xff;
2260 d[i * 4 + 5] = s[(i >> 2) * 6 + 2];
2264 if (i < width - 2) {
2265 d[i * 4 + 8] = 0xff;
2266 d[i * 4 + 9] = s[(i >> 2) * 6 + 4];
2274 pack_IYU1 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2275 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2276 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2280 guint8 *restrict d = GET_LINE (y);
2281 const guint8 *restrict s = src;
2283 for (i = 0; i < width - 3; i += 4) {
2284 d[(i >> 2) * 6 + 0] = s[i * 4 + 2];
2285 d[(i >> 2) * 6 + 1] = s[i * 4 + 1];
2286 d[(i >> 2) * 6 + 2] = s[i * 4 + 5];
2287 d[(i >> 2) * 6 + 3] = s[i * 4 + 3];
2288 d[(i >> 2) * 6 + 4] = s[i * 4 + 9];
2289 d[(i >> 2) * 6 + 5] = s[i * 4 + 13];
2292 d[(i >> 2) * 6 + 1] = s[i * 4 + 1];
2293 d[(i >> 2) * 6 + 0] = s[i * 4 + 2];
2294 d[(i >> 2) * 6 + 3] = s[i * 4 + 3];
2296 d[(i >> 2) * 6 + 2] = s[i * 4 + 5];
2298 d[(i >> 2) * 6 + 4] = s[i * 4 + 9];
2302 #define PACK_ARGB64 GST_VIDEO_FORMAT_ARGB64, unpack_copy8, 1, pack_copy8
2303 #define PACK_AYUV64 GST_VIDEO_FORMAT_AYUV64, unpack_copy8, 1, pack_copy8
2305 unpack_copy8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2306 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2307 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2309 const guint8 *s = GET_LINE (y);
2313 memcpy (dest, s, width * 8);
2317 pack_copy8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2318 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2319 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2322 guint8 *restrict d = GET_LINE (y);
2324 memcpy (d, src, width * 8);
2327 #define PACK_r210 GST_VIDEO_FORMAT_ARGB64, unpack_r210, 1, pack_r210
2329 unpack_r210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2330 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2331 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2334 const guint8 *restrict s = GET_LINE (y);
2335 guint16 *restrict d = dest, R, G, B;
2339 for (i = 0; i < width; i++) {
2340 guint32 x = GST_READ_UINT32_BE (s + i * 4);
2342 R = ((x >> 14) & 0xffc0);
2343 G = ((x >> 4) & 0xffc0);
2344 B = ((x << 6) & 0xffc0);
2346 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2352 d[i * 4 + 0] = 0xffff;
2360 pack_r210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2361 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2362 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2366 guint8 *restrict d = GET_LINE (y);
2367 const guint16 *restrict s = src;
2369 for (i = 0; i < width; i++) {
2371 x |= (s[i * 4 + 1] & 0xffc0) << 14;
2372 x |= (s[i * 4 + 2] & 0xffc0) << 4;
2373 x |= (s[i * 4 + 3] & 0xffc0) >> 6;
2374 GST_WRITE_UINT32_BE (d + i * 4, x);
2378 #define PACK_GBR_10LE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_10LE, 1, pack_GBR_10LE
2380 unpack_GBR_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2381 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2382 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2385 const guint16 *sg = GET_G_LINE (y);
2386 const guint16 *sb = GET_B_LINE (y);
2387 const guint16 *sr = GET_R_LINE (y);
2388 guint16 *d = dest, G, B, R;
2394 for (i = 0; i < width; i++) {
2395 G = GST_READ_UINT16_LE (sg + i) << 6;
2396 B = GST_READ_UINT16_LE (sb + i) << 6;
2397 R = GST_READ_UINT16_LE (sr + i) << 6;
2399 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2405 d[i * 4 + 0] = 0xffff;
2413 pack_GBR_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2414 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2415 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2419 guint16 *restrict dg = GET_G_LINE (y);
2420 guint16 *restrict db = GET_B_LINE (y);
2421 guint16 *restrict dr = GET_R_LINE (y);
2423 const guint16 *restrict s = src;
2425 for (i = 0; i < width; i++) {
2426 G = (s[i * 4 + 2]) >> 6;
2427 B = (s[i * 4 + 3]) >> 6;
2428 R = (s[i * 4 + 1]) >> 6;
2430 GST_WRITE_UINT16_LE (dg + i, G);
2431 GST_WRITE_UINT16_LE (db + i, B);
2432 GST_WRITE_UINT16_LE (dr + i, R);
2436 #define PACK_GBR_10BE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_10BE, 1, pack_GBR_10BE
2438 unpack_GBR_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2439 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2440 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2443 const guint16 *restrict sg = GET_G_LINE (y);
2444 const guint16 *restrict sb = GET_B_LINE (y);
2445 const guint16 *restrict sr = GET_R_LINE (y);
2446 guint16 *restrict d = dest, G, B, R;
2452 for (i = 0; i < width; i++) {
2453 G = GST_READ_UINT16_BE (sg + i) << 6;
2454 B = GST_READ_UINT16_BE (sb + i) << 6;
2455 R = GST_READ_UINT16_BE (sr + i) << 6;
2457 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2463 d[i * 4 + 0] = 0xffff;
2471 pack_GBR_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2472 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2473 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2477 guint16 *restrict dg = GET_G_LINE (y);
2478 guint16 *restrict db = GET_B_LINE (y);
2479 guint16 *restrict dr = GET_R_LINE (y);
2481 const guint16 *restrict s = src;
2483 for (i = 0; i < width; i++) {
2484 G = s[i * 4 + 2] >> 6;
2485 B = s[i * 4 + 3] >> 6;
2486 R = s[i * 4 + 1] >> 6;
2488 GST_WRITE_UINT16_BE (dg + i, G);
2489 GST_WRITE_UINT16_BE (db + i, B);
2490 GST_WRITE_UINT16_BE (dr + i, R);
2494 #define PACK_GBRA_10LE GST_VIDEO_FORMAT_ARGB64, unpack_GBRA_10LE, 1, pack_GBRA_10LE
2496 unpack_GBRA_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2497 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2498 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2501 const guint16 *sg = GET_G_LINE (y);
2502 const guint16 *sb = GET_B_LINE (y);
2503 const guint16 *sr = GET_R_LINE (y);
2504 const guint16 *sa = GET_A_LINE (y);
2505 guint16 *d = dest, G, B, R, A;
2512 for (i = 0; i < width; i++) {
2513 G = GST_READ_UINT16_LE (sg + i) << 6;
2514 B = GST_READ_UINT16_LE (sb + i) << 6;
2515 R = GST_READ_UINT16_LE (sr + i) << 6;
2516 A = GST_READ_UINT16_LE (sa + i) << 6;
2518 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2533 pack_GBRA_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2534 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2535 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2539 guint16 *restrict dg = GET_G_LINE (y);
2540 guint16 *restrict db = GET_B_LINE (y);
2541 guint16 *restrict dr = GET_R_LINE (y);
2542 guint16 *restrict da = GET_A_LINE (y);
2544 const guint16 *restrict s = src;
2546 for (i = 0; i < width; i++) {
2547 G = (s[i * 4 + 2]) >> 6;
2548 B = (s[i * 4 + 3]) >> 6;
2549 R = (s[i * 4 + 1]) >> 6;
2550 A = (s[i * 4 + 0]) >> 6;
2552 GST_WRITE_UINT16_LE (dg + i, G);
2553 GST_WRITE_UINT16_LE (db + i, B);
2554 GST_WRITE_UINT16_LE (dr + i, R);
2555 GST_WRITE_UINT16_LE (da + i, A);
2559 #define PACK_GBRA_10BE GST_VIDEO_FORMAT_ARGB64, unpack_GBRA_10BE, 1, pack_GBRA_10BE
2561 unpack_GBRA_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2562 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2563 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2566 const guint16 *restrict sg = GET_G_LINE (y);
2567 const guint16 *restrict sb = GET_B_LINE (y);
2568 const guint16 *restrict sr = GET_R_LINE (y);
2569 const guint16 *restrict sa = GET_A_LINE (y);
2570 guint16 *restrict d = dest, G, B, R, A;
2577 for (i = 0; i < width; i++) {
2578 G = GST_READ_UINT16_BE (sg + i) << 6;
2579 B = GST_READ_UINT16_BE (sb + i) << 6;
2580 R = GST_READ_UINT16_BE (sr + i) << 6;
2581 A = GST_READ_UINT16_BE (sa + i) << 6;
2583 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2598 pack_GBRA_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2599 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2600 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2604 guint16 *restrict dg = GET_G_LINE (y);
2605 guint16 *restrict db = GET_B_LINE (y);
2606 guint16 *restrict dr = GET_R_LINE (y);
2607 guint16 *restrict da = GET_A_LINE (y);
2609 const guint16 *restrict s = src;
2611 for (i = 0; i < width; i++) {
2612 G = s[i * 4 + 2] >> 6;
2613 B = s[i * 4 + 3] >> 6;
2614 R = s[i * 4 + 1] >> 6;
2615 A = s[i * 4 + 0] >> 6;
2617 GST_WRITE_UINT16_BE (dg + i, G);
2618 GST_WRITE_UINT16_BE (db + i, B);
2619 GST_WRITE_UINT16_BE (dr + i, R);
2620 GST_WRITE_UINT16_BE (da + i, A);
2624 #define PACK_GBR_12LE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_12LE, 1, pack_GBR_12LE
2626 unpack_GBR_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2627 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2628 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2631 const guint16 *sg = GET_G_LINE (y);
2632 const guint16 *sb = GET_B_LINE (y);
2633 const guint16 *sr = GET_R_LINE (y);
2634 guint16 *d = dest, G, B, R;
2640 for (i = 0; i < width; i++) {
2641 G = GST_READ_UINT16_LE (sg + i) << 4;
2642 B = GST_READ_UINT16_LE (sb + i) << 4;
2643 R = GST_READ_UINT16_LE (sr + i) << 4;
2645 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2651 d[i * 4 + 0] = 0xffff;
2659 pack_GBR_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2660 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2661 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2665 guint16 *restrict dg = GET_G_LINE (y);
2666 guint16 *restrict db = GET_B_LINE (y);
2667 guint16 *restrict dr = GET_R_LINE (y);
2669 const guint16 *restrict s = src;
2671 for (i = 0; i < width; i++) {
2672 G = (s[i * 4 + 2]) >> 4;
2673 B = (s[i * 4 + 3]) >> 4;
2674 R = (s[i * 4 + 1]) >> 4;
2676 GST_WRITE_UINT16_LE (dg + i, G);
2677 GST_WRITE_UINT16_LE (db + i, B);
2678 GST_WRITE_UINT16_LE (dr + i, R);
2682 #define PACK_GBR_12BE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_12BE, 1, pack_GBR_12BE
2684 unpack_GBR_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2685 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2686 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2689 const guint16 *restrict sg = GET_G_LINE (y);
2690 const guint16 *restrict sb = GET_B_LINE (y);
2691 const guint16 *restrict sr = GET_R_LINE (y);
2692 guint16 *restrict d = dest, G, B, R;
2698 for (i = 0; i < width; i++) {
2699 G = GST_READ_UINT16_BE (sg + i) << 4;
2700 B = GST_READ_UINT16_BE (sb + i) << 4;
2701 R = GST_READ_UINT16_BE (sr + i) << 4;
2703 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2709 d[i * 4 + 0] = 0xffff;
2717 pack_GBR_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2718 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2719 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2723 guint16 *restrict dg = GET_G_LINE (y);
2724 guint16 *restrict db = GET_B_LINE (y);
2725 guint16 *restrict dr = GET_R_LINE (y);
2727 const guint16 *restrict s = src;
2729 for (i = 0; i < width; i++) {
2730 G = s[i * 4 + 2] >> 4;
2731 B = s[i * 4 + 3] >> 4;
2732 R = s[i * 4 + 1] >> 4;
2734 GST_WRITE_UINT16_BE (dg + i, G);
2735 GST_WRITE_UINT16_BE (db + i, B);
2736 GST_WRITE_UINT16_BE (dr + i, R);
2740 #define PACK_GBRA_12LE GST_VIDEO_FORMAT_ARGB64, unpack_GBRA_12LE, 1, pack_GBRA_12LE
2742 unpack_GBRA_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2743 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2744 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2747 const guint16 *sg = GET_G_LINE (y);
2748 const guint16 *sb = GET_B_LINE (y);
2749 const guint16 *sr = GET_R_LINE (y);
2750 const guint16 *sa = GET_A_LINE (y);
2751 guint16 *d = dest, G, B, R, A;
2758 for (i = 0; i < width; i++) {
2759 G = GST_READ_UINT16_LE (sg + i) << 4;
2760 B = GST_READ_UINT16_LE (sb + i) << 4;
2761 R = GST_READ_UINT16_LE (sr + i) << 4;
2762 A = GST_READ_UINT16_LE (sa + i) << 4;
2764 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2779 pack_GBRA_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2780 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2781 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2785 guint16 *restrict dg = GET_G_LINE (y);
2786 guint16 *restrict db = GET_B_LINE (y);
2787 guint16 *restrict dr = GET_R_LINE (y);
2788 guint16 *restrict da = GET_A_LINE (y);
2790 const guint16 *restrict s = src;
2792 for (i = 0; i < width; i++) {
2793 G = (s[i * 4 + 2]) >> 4;
2794 B = (s[i * 4 + 3]) >> 4;
2795 R = (s[i * 4 + 1]) >> 4;
2796 A = (s[i * 4 + 0]) >> 4;
2798 GST_WRITE_UINT16_LE (dg + i, G);
2799 GST_WRITE_UINT16_LE (db + i, B);
2800 GST_WRITE_UINT16_LE (dr + i, R);
2801 GST_WRITE_UINT16_LE (da + i, A);
2805 #define PACK_GBRA_12BE GST_VIDEO_FORMAT_ARGB64, unpack_GBRA_12BE, 1, pack_GBRA_12BE
2807 unpack_GBRA_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2808 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2809 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2812 const guint16 *restrict sg = GET_G_LINE (y);
2813 const guint16 *restrict sb = GET_B_LINE (y);
2814 const guint16 *restrict sr = GET_R_LINE (y);
2815 const guint16 *restrict sa = GET_A_LINE (y);
2816 guint16 *restrict d = dest, G, B, R, A;
2823 for (i = 0; i < width; i++) {
2824 G = GST_READ_UINT16_BE (sg + i) << 4;
2825 B = GST_READ_UINT16_BE (sb + i) << 4;
2826 R = GST_READ_UINT16_BE (sr + i) << 4;
2827 A = GST_READ_UINT16_BE (sa + i) << 4;
2829 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2844 pack_GBRA_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2845 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2846 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2850 guint16 *restrict dg = GET_G_LINE (y);
2851 guint16 *restrict db = GET_B_LINE (y);
2852 guint16 *restrict dr = GET_R_LINE (y);
2853 guint16 *restrict da = GET_A_LINE (y);
2855 const guint16 *restrict s = src;
2857 for (i = 0; i < width; i++) {
2858 G = s[i * 4 + 2] >> 4;
2859 B = s[i * 4 + 3] >> 4;
2860 R = s[i * 4 + 1] >> 4;
2861 A = s[i * 4 + 0] >> 4;
2863 GST_WRITE_UINT16_BE (dg + i, G);
2864 GST_WRITE_UINT16_BE (db + i, B);
2865 GST_WRITE_UINT16_BE (dr + i, R);
2866 GST_WRITE_UINT16_BE (da + i, A);
2870 #define PACK_Y444_10LE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_10LE, 1, pack_Y444_10LE
2872 unpack_Y444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2873 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2874 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2877 guint16 *restrict sy = GET_Y_LINE (y);
2878 guint16 *restrict su = GET_U_LINE (y);
2879 guint16 *restrict sv = GET_V_LINE (y);
2880 guint16 *restrict d = dest, Y, U, V;
2886 for (i = 0; i < width; i++) {
2887 Y = GST_READ_UINT16_LE (sy + i) << 6;
2888 U = GST_READ_UINT16_LE (su + i) << 6;
2889 V = GST_READ_UINT16_LE (sv + i) << 6;
2891 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2897 d[i * 4 + 0] = 0xffff;
2905 pack_Y444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2906 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2907 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2911 guint16 *restrict dy = GET_Y_LINE (y);
2912 guint16 *restrict du = GET_U_LINE (y);
2913 guint16 *restrict dv = GET_V_LINE (y);
2915 const guint16 *restrict s = src;
2917 for (i = 0; i < width; i++) {
2918 Y = (s[i * 4 + 1]) >> 6;
2919 U = (s[i * 4 + 2]) >> 6;
2920 V = (s[i * 4 + 3]) >> 6;
2922 GST_WRITE_UINT16_LE (dy + i, Y);
2923 GST_WRITE_UINT16_LE (du + i, U);
2924 GST_WRITE_UINT16_LE (dv + i, V);
2928 #define PACK_Y444_10BE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_10BE, 1, pack_Y444_10BE
2930 unpack_Y444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2931 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2932 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2935 const guint16 *restrict sy = GET_Y_LINE (y);
2936 const guint16 *restrict su = GET_U_LINE (y);
2937 const guint16 *restrict sv = GET_V_LINE (y);
2938 guint16 *restrict d = dest, Y, U, V;
2944 for (i = 0; i < width; i++) {
2945 Y = GST_READ_UINT16_BE (sy + i) << 6;
2946 U = GST_READ_UINT16_BE (su + i) << 6;
2947 V = GST_READ_UINT16_BE (sv + i) << 6;
2949 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2955 d[i * 4 + 0] = 0xffff;
2963 pack_Y444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2964 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2965 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2969 guint16 *restrict dy = GET_Y_LINE (y);
2970 guint16 *restrict du = GET_U_LINE (y);
2971 guint16 *restrict dv = GET_V_LINE (y);
2973 const guint16 *restrict s = src;
2975 for (i = 0; i < width; i++) {
2976 Y = s[i * 4 + 1] >> 6;
2977 U = s[i * 4 + 2] >> 6;
2978 V = s[i * 4 + 3] >> 6;
2980 GST_WRITE_UINT16_BE (dy + i, Y);
2981 GST_WRITE_UINT16_BE (du + i, U);
2982 GST_WRITE_UINT16_BE (dv + i, V);
2986 #define PACK_I420_10LE GST_VIDEO_FORMAT_AYUV64, unpack_I420_10LE, 1, pack_I420_10LE
2988 unpack_I420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2989 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2990 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2993 gint uv = GET_UV_420 (y, flags);
2994 const guint16 *restrict sy = GET_Y_LINE (y);
2995 const guint16 *restrict su = GET_U_LINE (uv);
2996 const guint16 *restrict sv = GET_V_LINE (uv);
2997 guint16 *restrict d = dest, Y, U, V;
3003 for (i = 0; i < width; i++) {
3004 Y = GST_READ_UINT16_LE (sy + i) << 6;
3005 U = GST_READ_UINT16_LE (su + (i >> 1)) << 6;
3006 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 6;
3008 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3014 d[i * 4 + 0] = 0xffff;
3028 pack_I420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3029 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3030 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3034 gint uv = GET_UV_420 (y, flags);
3035 guint16 *restrict dy = GET_Y_LINE (y);
3036 guint16 *restrict du = GET_U_LINE (uv);
3037 guint16 *restrict dv = GET_V_LINE (uv);
3038 guint16 Y0, Y1, U, V;
3039 const guint16 *restrict s = src;
3041 if (IS_CHROMA_LINE_420 (y, flags)) {
3042 for (i = 0; i < width - 1; i += 2) {
3043 Y0 = s[i * 4 + 1] >> 6;
3044 Y1 = s[i * 4 + 5] >> 6;
3045 U = s[i * 4 + 2] >> 6;
3046 V = s[i * 4 + 3] >> 6;
3048 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3049 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3050 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3051 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3053 if (i == width - 1) {
3054 Y0 = s[i * 4 + 1] >> 6;
3055 U = s[i * 4 + 2] >> 6;
3056 V = s[i * 4 + 3] >> 6;
3058 GST_WRITE_UINT16_LE (dy + i, Y0);
3059 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3060 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3063 for (i = 0; i < width; i++) {
3064 Y0 = s[i * 4 + 1] >> 6;
3065 GST_WRITE_UINT16_LE (dy + i, Y0);
3070 #define PACK_I420_10BE GST_VIDEO_FORMAT_AYUV64, unpack_I420_10BE, 1, pack_I420_10BE
3072 unpack_I420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3073 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3074 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3077 gint uv = GET_UV_420 (y, flags);
3078 const guint16 *restrict sy = GET_Y_LINE (y);
3079 const guint16 *restrict su = GET_U_LINE (uv);
3080 const guint16 *restrict sv = GET_V_LINE (uv);
3081 guint16 *restrict d = dest, Y, U, V;
3087 for (i = 0; i < width; i++) {
3088 Y = GST_READ_UINT16_BE (sy + i) << 6;
3089 U = GST_READ_UINT16_BE (su + (i >> 1)) << 6;
3090 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 6;
3092 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3098 d[i * 4 + 0] = 0xffff;
3112 pack_I420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3113 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3114 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3118 gint uv = GET_UV_420 (y, flags);
3119 guint16 *restrict dy = GET_Y_LINE (y);
3120 guint16 *restrict du = GET_U_LINE (uv);
3121 guint16 *restrict dv = GET_V_LINE (uv);
3122 guint16 Y0, Y1, U, V;
3123 const guint16 *restrict s = src;
3125 if (IS_CHROMA_LINE_420 (y, flags)) {
3126 for (i = 0; i < width - 1; i += 2) {
3127 Y0 = s[i * 4 + 1] >> 6;
3128 Y1 = s[i * 4 + 5] >> 6;
3129 U = s[i * 4 + 2] >> 6;
3130 V = s[i * 4 + 3] >> 6;
3132 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
3133 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
3134 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3135 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3137 if (i == width - 1) {
3138 Y0 = s[i * 4 + 1] >> 6;
3139 U = s[i * 4 + 2] >> 6;
3140 V = s[i * 4 + 3] >> 6;
3142 GST_WRITE_UINT16_BE (dy + i, Y0);
3143 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3144 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3147 for (i = 0; i < width; i++) {
3148 Y0 = s[i * 4 + 1] >> 6;
3149 GST_WRITE_UINT16_BE (dy + i, Y0);
3154 #define PACK_I422_10LE GST_VIDEO_FORMAT_AYUV64, unpack_I422_10LE, 1, pack_I422_10LE
3156 unpack_I422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3157 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3158 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3161 const guint16 *restrict sy = GET_Y_LINE (y);
3162 const guint16 *restrict su = GET_U_LINE (y);
3163 const guint16 *restrict sv = GET_V_LINE (y);
3164 guint16 *restrict d = dest, Y, U, V;
3170 for (i = 0; i < width; i++) {
3171 Y = GST_READ_UINT16_LE (sy + i) << 6;
3172 U = GST_READ_UINT16_LE (su + (i >> 1)) << 6;
3173 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 6;
3175 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3181 d[i * 4 + 0] = 0xffff;
3195 pack_I422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3196 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3197 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3201 guint16 *restrict dy = GET_Y_LINE (y);
3202 guint16 *restrict du = GET_U_LINE (y);
3203 guint16 *restrict dv = GET_V_LINE (y);
3204 guint16 Y0, Y1, U, V;
3205 const guint16 *restrict s = src;
3207 for (i = 0; i < width - 1; i += 2) {
3208 Y0 = s[i * 4 + 1] >> 6;
3209 Y1 = s[i * 4 + 5] >> 6;
3210 U = s[i * 4 + 2] >> 6;
3211 V = s[i * 4 + 3] >> 6;
3213 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3214 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3215 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3216 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3218 if (i == width - 1) {
3219 Y0 = s[i * 4 + 1] >> 6;
3220 U = s[i * 4 + 2] >> 6;
3221 V = s[i * 4 + 3] >> 6;
3223 GST_WRITE_UINT16_LE (dy + i, Y0);
3224 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3225 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3229 #define PACK_I422_10BE GST_VIDEO_FORMAT_AYUV64, unpack_I422_10BE, 1, pack_I422_10BE
3231 unpack_I422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3232 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3233 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3236 const guint16 *restrict sy = GET_Y_LINE (y);
3237 const guint16 *restrict su = GET_U_LINE (y);
3238 const guint16 *restrict sv = GET_V_LINE (y);
3239 guint16 *restrict d = dest, Y, U, V;
3245 for (i = 0; i < width; i++) {
3246 Y = GST_READ_UINT16_BE (sy + i) << 6;
3247 U = GST_READ_UINT16_BE (su + (i >> 1)) << 6;
3248 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 6;
3250 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3256 d[i * 4 + 0] = 0xffff;
3270 pack_I422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3271 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3272 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3276 guint16 *restrict dy = GET_Y_LINE (y);
3277 guint16 *restrict du = GET_U_LINE (y);
3278 guint16 *restrict dv = GET_V_LINE (y);
3279 guint16 Y0, Y1, U, V;
3280 const guint16 *restrict s = src;
3282 for (i = 0; i < width - 1; i += 2) {
3283 Y0 = s[i * 4 + 1] >> 6;
3284 Y1 = s[i * 4 + 5] >> 6;
3285 U = s[i * 4 + 2] >> 6;
3286 V = s[i * 4 + 3] >> 6;
3288 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
3289 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
3290 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3291 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3293 if (i == width - 1) {
3294 Y0 = s[i * 4 + 1] >> 6;
3295 U = s[i * 4 + 2] >> 6;
3296 V = s[i * 4 + 3] >> 6;
3298 GST_WRITE_UINT16_BE (dy + i, Y0);
3299 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3300 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3304 #define PACK_Y444_12LE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_12LE, 1, pack_Y444_12LE
3306 unpack_Y444_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3307 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3308 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3311 guint16 *restrict sy = GET_Y_LINE (y);
3312 guint16 *restrict su = GET_U_LINE (y);
3313 guint16 *restrict sv = GET_V_LINE (y);
3314 guint16 *restrict d = dest, Y, U, V;
3320 for (i = 0; i < width; i++) {
3321 Y = GST_READ_UINT16_LE (sy + i) << 4;
3322 U = GST_READ_UINT16_LE (su + i) << 4;
3323 V = GST_READ_UINT16_LE (sv + i) << 4;
3325 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3331 d[i * 4 + 0] = 0xffff;
3339 pack_Y444_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3340 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3341 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3345 guint16 *restrict dy = GET_Y_LINE (y);
3346 guint16 *restrict du = GET_U_LINE (y);
3347 guint16 *restrict dv = GET_V_LINE (y);
3349 const guint16 *restrict s = src;
3351 for (i = 0; i < width; i++) {
3352 Y = (s[i * 4 + 1]) >> 4;
3353 U = (s[i * 4 + 2]) >> 4;
3354 V = (s[i * 4 + 3]) >> 4;
3356 GST_WRITE_UINT16_LE (dy + i, Y);
3357 GST_WRITE_UINT16_LE (du + i, U);
3358 GST_WRITE_UINT16_LE (dv + i, V);
3362 #define PACK_Y444_12BE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_12BE, 1, pack_Y444_12BE
3364 unpack_Y444_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3365 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3366 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3369 const guint16 *restrict sy = GET_Y_LINE (y);
3370 const guint16 *restrict su = GET_U_LINE (y);
3371 const guint16 *restrict sv = GET_V_LINE (y);
3372 guint16 *restrict d = dest, Y, U, V;
3378 for (i = 0; i < width; i++) {
3379 Y = GST_READ_UINT16_BE (sy + i) << 4;
3380 U = GST_READ_UINT16_BE (su + i) << 4;
3381 V = GST_READ_UINT16_BE (sv + i) << 4;
3383 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3389 d[i * 4 + 0] = 0xffff;
3397 pack_Y444_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3398 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3399 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3403 guint16 *restrict dy = GET_Y_LINE (y);
3404 guint16 *restrict du = GET_U_LINE (y);
3405 guint16 *restrict dv = GET_V_LINE (y);
3407 const guint16 *restrict s = src;
3409 for (i = 0; i < width; i++) {
3410 Y = s[i * 4 + 1] >> 4;
3411 U = s[i * 4 + 2] >> 4;
3412 V = s[i * 4 + 3] >> 4;
3414 GST_WRITE_UINT16_BE (dy + i, Y);
3415 GST_WRITE_UINT16_BE (du + i, U);
3416 GST_WRITE_UINT16_BE (dv + i, V);
3420 #define PACK_I420_12LE GST_VIDEO_FORMAT_AYUV64, unpack_I420_12LE, 1, pack_I420_12LE
3422 unpack_I420_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3423 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3424 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3427 gint uv = GET_UV_420 (y, flags);
3428 const guint16 *restrict sy = GET_Y_LINE (y);
3429 const guint16 *restrict su = GET_U_LINE (uv);
3430 const guint16 *restrict sv = GET_V_LINE (uv);
3431 guint16 *restrict d = dest, Y, U, V;
3437 for (i = 0; i < width; i++) {
3438 Y = GST_READ_UINT16_LE (sy + i) << 4;
3439 U = GST_READ_UINT16_LE (su + (i >> 1)) << 4;
3440 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 4;
3442 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3448 d[i * 4 + 0] = 0xffff;
3462 pack_I420_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3463 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3464 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3468 gint uv = GET_UV_420 (y, flags);
3469 guint16 *restrict dy = GET_Y_LINE (y);
3470 guint16 *restrict du = GET_U_LINE (uv);
3471 guint16 *restrict dv = GET_V_LINE (uv);
3472 guint16 Y0, Y1, U, V;
3473 const guint16 *restrict s = src;
3475 if (IS_CHROMA_LINE_420 (y, flags)) {
3476 for (i = 0; i < width - 1; i += 2) {
3477 Y0 = s[i * 4 + 1] >> 4;
3478 Y1 = s[i * 4 + 5] >> 4;
3479 U = s[i * 4 + 2] >> 4;
3480 V = s[i * 4 + 3] >> 4;
3482 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3483 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3484 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3485 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3487 if (i == width - 1) {
3488 Y0 = s[i * 4 + 1] >> 4;
3489 U = s[i * 4 + 2] >> 4;
3490 V = s[i * 4 + 3] >> 4;
3492 GST_WRITE_UINT16_LE (dy + i, Y0);
3493 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3494 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3497 for (i = 0; i < width; i++) {
3498 Y0 = s[i * 4 + 1] >> 4;
3499 GST_WRITE_UINT16_LE (dy + i, Y0);
3504 #define PACK_I420_12BE GST_VIDEO_FORMAT_AYUV64, unpack_I420_12BE, 1, pack_I420_12BE
3506 unpack_I420_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3507 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3508 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3511 gint uv = GET_UV_420 (y, flags);
3512 const guint16 *restrict sy = GET_Y_LINE (y);
3513 const guint16 *restrict su = GET_U_LINE (uv);
3514 const guint16 *restrict sv = GET_V_LINE (uv);
3515 guint16 *restrict d = dest, Y, U, V;
3521 for (i = 0; i < width; i++) {
3522 Y = GST_READ_UINT16_BE (sy + i) << 4;
3523 U = GST_READ_UINT16_BE (su + (i >> 1)) << 4;
3524 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 4;
3526 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3532 d[i * 4 + 0] = 0xffff;
3546 pack_I420_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3547 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3548 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3552 gint uv = GET_UV_420 (y, flags);
3553 guint16 *restrict dy = GET_Y_LINE (y);
3554 guint16 *restrict du = GET_U_LINE (uv);
3555 guint16 *restrict dv = GET_V_LINE (uv);
3556 guint16 Y0, Y1, U, V;
3557 const guint16 *restrict s = src;
3559 if (IS_CHROMA_LINE_420 (y, flags)) {
3560 for (i = 0; i < width - 1; i += 2) {
3561 Y0 = s[i * 4 + 1] >> 4;
3562 Y1 = s[i * 4 + 5] >> 4;
3563 U = s[i * 4 + 2] >> 4;
3564 V = s[i * 4 + 3] >> 4;
3566 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
3567 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
3568 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3569 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3571 if (i == width - 1) {
3572 Y0 = s[i * 4 + 1] >> 4;
3573 U = s[i * 4 + 2] >> 4;
3574 V = s[i * 4 + 3] >> 4;
3576 GST_WRITE_UINT16_BE (dy + i, Y0);
3577 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3578 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3581 for (i = 0; i < width; i++) {
3582 Y0 = s[i * 4 + 1] >> 4;
3583 GST_WRITE_UINT16_BE (dy + i, Y0);
3588 #define PACK_I422_12LE GST_VIDEO_FORMAT_AYUV64, unpack_I422_12LE, 1, pack_I422_12LE
3590 unpack_I422_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3591 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3592 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3595 const guint16 *restrict sy = GET_Y_LINE (y);
3596 const guint16 *restrict su = GET_U_LINE (y);
3597 const guint16 *restrict sv = GET_V_LINE (y);
3598 guint16 *restrict d = dest, Y, U, V;
3604 for (i = 0; i < width; i++) {
3605 Y = GST_READ_UINT16_LE (sy + i) << 4;
3606 U = GST_READ_UINT16_LE (su + (i >> 1)) << 4;
3607 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 4;
3609 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3615 d[i * 4 + 0] = 0xffff;
3629 pack_I422_12LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3630 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3631 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3635 guint16 *restrict dy = GET_Y_LINE (y);
3636 guint16 *restrict du = GET_U_LINE (y);
3637 guint16 *restrict dv = GET_V_LINE (y);
3638 guint16 Y0, Y1, U, V;
3639 const guint16 *restrict s = src;
3641 for (i = 0; i < width - 1; i += 2) {
3642 Y0 = s[i * 4 + 1] >> 4;
3643 Y1 = s[i * 4 + 5] >> 4;
3644 U = s[i * 4 + 2] >> 4;
3645 V = s[i * 4 + 3] >> 4;
3647 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3648 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3649 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3650 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3652 if (i == width - 1) {
3653 Y0 = s[i * 4 + 1] >> 4;
3654 U = s[i * 4 + 2] >> 4;
3655 V = s[i * 4 + 3] >> 4;
3657 GST_WRITE_UINT16_LE (dy + i, Y0);
3658 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3659 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3663 #define PACK_I422_12BE GST_VIDEO_FORMAT_AYUV64, unpack_I422_12BE, 1, pack_I422_12BE
3665 unpack_I422_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3666 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3667 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3670 const guint16 *restrict sy = GET_Y_LINE (y);
3671 const guint16 *restrict su = GET_U_LINE (y);
3672 const guint16 *restrict sv = GET_V_LINE (y);
3673 guint16 *restrict d = dest, Y, U, V;
3679 for (i = 0; i < width; i++) {
3680 Y = GST_READ_UINT16_BE (sy + i) << 4;
3681 U = GST_READ_UINT16_BE (su + (i >> 1)) << 4;
3682 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 4;
3684 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3690 d[i * 4 + 0] = 0xffff;
3704 pack_I422_12BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3705 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3706 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3710 guint16 *restrict dy = GET_Y_LINE (y);
3711 guint16 *restrict du = GET_U_LINE (y);
3712 guint16 *restrict dv = GET_V_LINE (y);
3713 guint16 Y0, Y1, U, V;
3714 const guint16 *restrict s = src;
3716 for (i = 0; i < width - 1; i += 2) {
3717 Y0 = s[i * 4 + 1] >> 4;
3718 Y1 = s[i * 4 + 5] >> 4;
3719 U = s[i * 4 + 2] >> 4;
3720 V = s[i * 4 + 3] >> 4;
3722 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
3723 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
3724 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3725 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3727 if (i == width - 1) {
3728 Y0 = s[i * 4 + 1] >> 4;
3729 U = s[i * 4 + 2] >> 4;
3730 V = s[i * 4 + 3] >> 4;
3732 GST_WRITE_UINT16_BE (dy + i, Y0);
3733 GST_WRITE_UINT16_BE (du + (i >> 1), U);
3734 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
3738 #define PACK_A444_10LE GST_VIDEO_FORMAT_AYUV64, unpack_A444_10LE, 1, pack_A444_10LE
3740 unpack_A444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3741 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3742 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3745 guint16 *restrict sa = GET_A_LINE (y);
3746 guint16 *restrict sy = GET_Y_LINE (y);
3747 guint16 *restrict su = GET_U_LINE (y);
3748 guint16 *restrict sv = GET_V_LINE (y);
3749 guint16 *restrict d = dest, A, Y, U, V;
3756 for (i = 0; i < width; i++) {
3757 A = GST_READ_UINT16_LE (sa + i) << 6;
3758 Y = GST_READ_UINT16_LE (sy + i) << 6;
3759 U = GST_READ_UINT16_LE (su + i) << 6;
3760 V = GST_READ_UINT16_LE (sv + i) << 6;
3762 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3777 pack_A444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3778 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3779 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3783 guint16 *restrict da = GET_A_LINE (y);
3784 guint16 *restrict dy = GET_Y_LINE (y);
3785 guint16 *restrict du = GET_U_LINE (y);
3786 guint16 *restrict dv = GET_V_LINE (y);
3788 const guint16 *restrict s = src;
3790 for (i = 0; i < width; i++) {
3791 A = (s[i * 4 + 0]) >> 6;
3792 Y = (s[i * 4 + 1]) >> 6;
3793 U = (s[i * 4 + 2]) >> 6;
3794 V = (s[i * 4 + 3]) >> 6;
3796 GST_WRITE_UINT16_LE (da + i, A);
3797 GST_WRITE_UINT16_LE (dy + i, Y);
3798 GST_WRITE_UINT16_LE (du + i, U);
3799 GST_WRITE_UINT16_LE (dv + i, V);
3803 #define PACK_A444_10BE GST_VIDEO_FORMAT_AYUV64, unpack_A444_10BE, 1, pack_A444_10BE
3805 unpack_A444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3806 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3807 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3810 const guint16 *restrict sa = GET_A_LINE (y);
3811 const guint16 *restrict sy = GET_Y_LINE (y);
3812 const guint16 *restrict su = GET_U_LINE (y);
3813 const guint16 *restrict sv = GET_V_LINE (y);
3814 guint16 *restrict d = dest, A, Y, U, V;
3821 for (i = 0; i < width; i++) {
3822 A = GST_READ_UINT16_BE (sa + i) << 6;
3823 Y = GST_READ_UINT16_BE (sy + i) << 6;
3824 U = GST_READ_UINT16_BE (su + i) << 6;
3825 V = GST_READ_UINT16_BE (sv + i) << 6;
3827 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3842 pack_A444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3843 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3844 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3848 guint16 *restrict da = GET_A_LINE (y);
3849 guint16 *restrict dy = GET_Y_LINE (y);
3850 guint16 *restrict du = GET_U_LINE (y);
3851 guint16 *restrict dv = GET_V_LINE (y);
3853 const guint16 *restrict s = src;
3855 for (i = 0; i < width; i++) {
3856 A = s[i * 4 + 0] >> 6;
3857 Y = s[i * 4 + 1] >> 6;
3858 U = s[i * 4 + 2] >> 6;
3859 V = s[i * 4 + 3] >> 6;
3861 GST_WRITE_UINT16_BE (da + i, A);
3862 GST_WRITE_UINT16_BE (dy + i, Y);
3863 GST_WRITE_UINT16_BE (du + i, U);
3864 GST_WRITE_UINT16_BE (dv + i, V);
3868 #define PACK_A420_10LE GST_VIDEO_FORMAT_AYUV64, unpack_A420_10LE, 1, pack_A420_10LE
3870 unpack_A420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3871 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3872 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3875 gint uv = GET_UV_420 (y, flags);
3876 const guint16 *restrict sa = GET_A_LINE (y);
3877 const guint16 *restrict sy = GET_Y_LINE (y);
3878 const guint16 *restrict su = GET_U_LINE (uv);
3879 const guint16 *restrict sv = GET_V_LINE (uv);
3880 guint16 *restrict d = dest, A, Y, U, V;
3887 for (i = 0; i < width; i++) {
3888 A = GST_READ_UINT16_LE (sa + i) << 6;
3889 Y = GST_READ_UINT16_LE (sy + i) << 6;
3890 U = GST_READ_UINT16_LE (su + (i >> 1)) << 6;
3891 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 6;
3893 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
3914 pack_A420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3915 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
3916 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
3920 gint uv = GET_UV_420 (y, flags);
3921 guint16 *restrict da = GET_A_LINE (y);
3922 guint16 *restrict dy = GET_Y_LINE (y);
3923 guint16 *restrict du = GET_U_LINE (uv);
3924 guint16 *restrict dv = GET_V_LINE (uv);
3925 guint16 A0, Y0, A1, Y1, U, V;
3926 const guint16 *restrict s = src;
3928 if (IS_CHROMA_LINE_420 (y, flags)) {
3929 for (i = 0; i < width - 1; i += 2) {
3930 A0 = s[i * 4 + 0] >> 6;
3931 Y0 = s[i * 4 + 1] >> 6;
3932 A1 = s[i * 4 + 4] >> 6;
3933 Y1 = s[i * 4 + 5] >> 6;
3934 U = s[i * 4 + 2] >> 6;
3935 V = s[i * 4 + 3] >> 6;
3937 GST_WRITE_UINT16_LE (da + i + 0, A0);
3938 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
3939 GST_WRITE_UINT16_LE (da + i + 1, A1);
3940 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
3941 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3942 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3944 if (i == width - 1) {
3945 A0 = s[i * 4 + 0] >> 6;
3946 Y0 = s[i * 4 + 1] >> 6;
3947 U = s[i * 4 + 2] >> 6;
3948 V = s[i * 4 + 3] >> 6;
3950 GST_WRITE_UINT16_LE (da + i, A0);
3951 GST_WRITE_UINT16_LE (dy + i, Y0);
3952 GST_WRITE_UINT16_LE (du + (i >> 1), U);
3953 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
3956 for (i = 0; i < width; i++) {
3957 A0 = s[i * 4 + 0] >> 6;
3958 Y0 = s[i * 4 + 1] >> 6;
3959 GST_WRITE_UINT16_LE (da + i, A0);
3960 GST_WRITE_UINT16_LE (dy + i, Y0);
3965 #define PACK_A420_10BE GST_VIDEO_FORMAT_AYUV64, unpack_A420_10BE, 1, pack_A420_10BE
3967 unpack_A420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
3968 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
3969 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
3972 gint uv = GET_UV_420 (y, flags);
3973 const guint16 *restrict sa = GET_A_LINE (y);
3974 const guint16 *restrict sy = GET_Y_LINE (y);
3975 const guint16 *restrict su = GET_U_LINE (uv);
3976 const guint16 *restrict sv = GET_V_LINE (uv);
3977 guint16 *restrict d = dest, A, Y, U, V;
3984 for (i = 0; i < width; i++) {
3985 A = GST_READ_UINT16_BE (sa + i) << 6;
3986 Y = GST_READ_UINT16_BE (sy + i) << 6;
3987 U = GST_READ_UINT16_BE (su + (i >> 1)) << 6;
3988 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 6;
3990 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4011 pack_A420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4012 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4013 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4017 gint uv = GET_UV_420 (y, flags);
4018 guint16 *restrict da = GET_A_LINE (y);
4019 guint16 *restrict dy = GET_Y_LINE (y);
4020 guint16 *restrict du = GET_U_LINE (uv);
4021 guint16 *restrict dv = GET_V_LINE (uv);
4022 guint16 A0, Y0, A1, Y1, U, V;
4023 const guint16 *restrict s = src;
4025 if (IS_CHROMA_LINE_420 (y, flags)) {
4026 for (i = 0; i < width - 1; i += 2) {
4027 A0 = s[i * 4 + 0] >> 6;
4028 Y0 = s[i * 4 + 1] >> 6;
4029 A1 = s[i * 4 + 4] >> 6;
4030 Y1 = s[i * 4 + 5] >> 6;
4031 U = s[i * 4 + 2] >> 6;
4032 V = s[i * 4 + 3] >> 6;
4034 GST_WRITE_UINT16_BE (da + i + 0, A0);
4035 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
4036 GST_WRITE_UINT16_BE (da + i + 1, A1);
4037 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
4038 GST_WRITE_UINT16_BE (du + (i >> 1), U);
4039 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
4041 if (i == width - 1) {
4042 A0 = s[i * 4 + 0] >> 6;
4043 Y0 = s[i * 4 + 1] >> 6;
4044 U = s[i * 4 + 2] >> 6;
4045 V = s[i * 4 + 3] >> 6;
4047 GST_WRITE_UINT16_BE (da + i, A0);
4048 GST_WRITE_UINT16_BE (dy + i, Y0);
4049 GST_WRITE_UINT16_BE (du + (i >> 1), U);
4050 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
4053 for (i = 0; i < width; i++) {
4054 A0 = s[i * 4 + 0] >> 6;
4055 Y0 = s[i * 4 + 1] >> 6;
4056 GST_WRITE_UINT16_BE (da + i, A0);
4057 GST_WRITE_UINT16_BE (dy + i, Y0);
4062 #define PACK_A422_10LE GST_VIDEO_FORMAT_AYUV64, unpack_A422_10LE, 1, pack_A422_10LE
4064 unpack_A422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4065 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4066 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4069 const guint16 *restrict sa = GET_A_LINE (y);
4070 const guint16 *restrict sy = GET_Y_LINE (y);
4071 const guint16 *restrict su = GET_U_LINE (y);
4072 const guint16 *restrict sv = GET_V_LINE (y);
4073 guint16 *restrict d = dest, A, Y, U, V;
4080 for (i = 0; i < width; i++) {
4081 A = GST_READ_UINT16_LE (sa + i) << 6;
4082 Y = GST_READ_UINT16_LE (sy + i) << 6;
4083 U = GST_READ_UINT16_LE (su + (i >> 1)) << 6;
4084 V = GST_READ_UINT16_LE (sv + (i >> 1)) << 6;
4086 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4107 pack_A422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4108 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4109 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4113 guint16 *restrict da = GET_A_LINE (y);
4114 guint16 *restrict dy = GET_Y_LINE (y);
4115 guint16 *restrict du = GET_U_LINE (y);
4116 guint16 *restrict dv = GET_V_LINE (y);
4117 guint16 A0, Y0, A1, Y1, U, V;
4118 const guint16 *restrict s = src;
4120 for (i = 0; i < width - 1; i += 2) {
4121 A0 = s[i * 4 + 0] >> 6;
4122 Y0 = s[i * 4 + 1] >> 6;
4123 A1 = s[i * 4 + 4] >> 6;
4124 Y1 = s[i * 4 + 5] >> 6;
4125 U = s[i * 4 + 2] >> 6;
4126 V = s[i * 4 + 3] >> 6;
4128 GST_WRITE_UINT16_LE (da + i + 0, A0);
4129 GST_WRITE_UINT16_LE (dy + i + 0, Y0);
4130 GST_WRITE_UINT16_LE (da + i + 1, A1);
4131 GST_WRITE_UINT16_LE (dy + i + 1, Y1);
4132 GST_WRITE_UINT16_LE (du + (i >> 1), U);
4133 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
4135 if (i == width - 1) {
4136 A0 = s[i * 4 + 0] >> 6;
4137 Y0 = s[i * 4 + 1] >> 6;
4138 U = s[i * 4 + 2] >> 6;
4139 V = s[i * 4 + 3] >> 6;
4141 GST_WRITE_UINT16_LE (da + i, A0);
4142 GST_WRITE_UINT16_LE (dy + i, Y0);
4143 GST_WRITE_UINT16_LE (du + (i >> 1), U);
4144 GST_WRITE_UINT16_LE (dv + (i >> 1), V);
4148 #define PACK_A422_10BE GST_VIDEO_FORMAT_AYUV64, unpack_A422_10BE, 1, pack_A422_10BE
4150 unpack_A422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4151 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4152 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4155 const guint16 *restrict sa = GET_A_LINE (y);
4156 const guint16 *restrict sy = GET_Y_LINE (y);
4157 const guint16 *restrict su = GET_U_LINE (y);
4158 const guint16 *restrict sv = GET_V_LINE (y);
4159 guint16 *restrict d = dest, A, Y, U, V;
4166 for (i = 0; i < width; i++) {
4167 A = GST_READ_UINT16_BE (sa + i) << 6;
4168 Y = GST_READ_UINT16_BE (sy + i) << 6;
4169 U = GST_READ_UINT16_BE (su + (i >> 1)) << 6;
4170 V = GST_READ_UINT16_BE (sv + (i >> 1)) << 6;
4172 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4193 pack_A422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4194 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4195 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4199 guint16 *restrict da = GET_A_LINE (y);
4200 guint16 *restrict dy = GET_Y_LINE (y);
4201 guint16 *restrict du = GET_U_LINE (y);
4202 guint16 *restrict dv = GET_V_LINE (y);
4203 guint16 A0, Y0, A1, Y1, U, V;
4204 const guint16 *restrict s = src;
4206 for (i = 0; i < width - 1; i += 2) {
4207 A0 = s[i * 4 + 0] >> 6;
4208 Y0 = s[i * 4 + 1] >> 6;
4209 A1 = s[i * 4 + 4] >> 6;
4210 Y1 = s[i * 4 + 5] >> 6;
4211 U = s[i * 4 + 2] >> 6;
4212 V = s[i * 4 + 3] >> 6;
4214 GST_WRITE_UINT16_BE (da + i + 0, A0);
4215 GST_WRITE_UINT16_BE (dy + i + 0, Y0);
4216 GST_WRITE_UINT16_BE (da + i + 1, A1);
4217 GST_WRITE_UINT16_BE (dy + i + 1, Y1);
4218 GST_WRITE_UINT16_BE (du + (i >> 1), U);
4219 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
4221 if (i == width - 1) {
4222 A0 = s[i * 4 + 0] >> 6;
4223 Y0 = s[i * 4 + 1] >> 6;
4224 U = s[i * 4 + 2] >> 6;
4225 V = s[i * 4 + 3] >> 6;
4227 GST_WRITE_UINT16_BE (da + i, A0);
4228 GST_WRITE_UINT16_BE (dy + i, Y0);
4229 GST_WRITE_UINT16_BE (du + (i >> 1), U);
4230 GST_WRITE_UINT16_BE (dv + (i >> 1), V);
4235 get_tile_NV12 (gint tile_width, gint ts, gint tx, gint ty,
4236 const gpointer data[GST_VIDEO_MAX_PLANES],
4237 const gint stride[GST_VIDEO_MAX_PLANES],
4238 gpointer tile_data[GST_VIDEO_MAX_PLANES],
4239 gint tile_stride[GST_VIDEO_MAX_PLANES])
4243 /* index of Y tile */
4244 offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
4245 tx, ty, GST_VIDEO_TILE_X_TILES (stride[0]),
4246 GST_VIDEO_TILE_Y_TILES (stride[0]));
4248 tile_data[0] = ((guint8 *) data[0]) + offset;
4250 /* index of UV tile */
4251 offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
4252 tx, ty >> 1, GST_VIDEO_TILE_X_TILES (stride[1]),
4253 GST_VIDEO_TILE_Y_TILES (stride[1]));
4255 /* On odd rows we return the second part of the UV tile */
4256 offset |= (ty & 1) << (ts - 1);
4257 tile_data[1] = ((guint8 *) data[1]) + offset;
4259 tile_stride[0] = tile_stride[1] = tile_width;
4262 #define PACK_NV12_64Z32 GST_VIDEO_FORMAT_AYUV, unpack_NV12_64Z32, 1, pack_NV12_64Z32
4264 unpack_NV12_64Z32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4265 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4266 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4268 const GstVideoFormatInfo *unpack_info, *finfo;
4269 guint8 *line = dest;
4270 gint ws, hs, ts, tile_width;
4272 gint unpack_pstride;
4274 ws = GST_VIDEO_FORMAT_INFO_TILE_WS (info);
4275 hs = GST_VIDEO_FORMAT_INFO_TILE_HS (info);
4278 tile_width = 1 << ws;
4280 /* we reuse these unpack functions */
4281 finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_NV12);
4283 /* get pstride of unpacked format */
4284 unpack_info = gst_video_format_get_info (info->unpack_format);
4285 unpack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (unpack_info, 0);
4287 /* first x tile to convert */
4289 /* Last tile to convert */
4290 ntx = ((x + width - 1) >> ws) + 1;
4291 /* The row we are going to convert */
4294 /* y position in a tile */
4295 y = y & ((1 << hs) - 1);
4296 /* x position in a tile */
4297 x = x & (tile_width - 1);
4299 for (; tx < ntx; tx++) {
4300 gpointer tdata[GST_VIDEO_MAX_PLANES];
4301 gint tstride[GST_VIDEO_MAX_PLANES];
4304 get_tile_NV12 (tile_width, ts, tx, ty, data, stride, tdata, tstride);
4306 /* the number of bytes left to unpack */
4307 unpack_width = MIN (width - x, tile_width - x);
4309 finfo->unpack_func (finfo, flags, line, tdata, tstride, x, y, unpack_width);
4312 width -= unpack_width;
4313 line += unpack_width * unpack_pstride;
4318 pack_NV12_64Z32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4319 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4320 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4323 const GstVideoFormatInfo *pack_info, *finfo;
4325 gint ws, hs, ts, tile_width;
4329 ws = GST_VIDEO_FORMAT_INFO_TILE_WS (info);
4330 hs = GST_VIDEO_FORMAT_INFO_TILE_HS (info);
4333 tile_width = 1 << ws;
4335 /* we reuse these pack functions */
4336 finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_NV12);
4338 /* get pstride of packed format */
4339 pack_info = gst_video_format_get_info (info->unpack_format);
4340 pack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (pack_info, 0);
4342 /* Last tile to convert */
4343 ntx = ((width - 1) >> ws) + 1;
4344 /* The row we are going to convert */
4347 /* y position in a tile */
4348 y = y & ((1 << hs) - 1);
4350 for (tx = 0; tx < ntx; tx++) {
4351 gpointer tdata[GST_VIDEO_MAX_PLANES];
4352 gint tstride[GST_VIDEO_MAX_PLANES];
4355 get_tile_NV12 (tile_width, ts, tx, ty, data, stride, tdata, tstride);
4357 /* the number of bytes left to pack */
4358 pack_width = MIN (width, tile_width);
4360 finfo->pack_func (finfo, flags, line, sstride, tdata, tstride,
4361 chroma_site, y, pack_width);
4363 width -= pack_width;
4364 line += pack_width * pack_pstride;
4368 #define PACK_P010_10BE GST_VIDEO_FORMAT_AYUV64, unpack_P010_10BE, 1, pack_P010_10BE
4370 unpack_P010_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4371 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4372 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4375 gint uv = GET_UV_420 (y, flags);
4376 const guint16 *restrict sy = GET_PLANE_LINE (0, y);
4377 const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
4378 guint16 *restrict d = dest, Y0, Y1, U, V;
4384 Y0 = GST_READ_UINT16_BE (sy);
4385 U = GST_READ_UINT16_BE (suv);
4386 V = GST_READ_UINT16_BE (suv + 1);
4388 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4404 for (i = 0; i < width / 2; i++) {
4405 Y0 = GST_READ_UINT16_BE (sy + 2 * i);
4406 Y1 = GST_READ_UINT16_BE (sy + 2 * i + 1);
4407 U = GST_READ_UINT16_BE (suv + 2 * i);
4408 V = GST_READ_UINT16_BE (suv + 2 * i + 1);
4410 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4417 d[i * 8 + 0] = 0xffff;
4421 d[i * 8 + 4] = 0xffff;
4430 Y0 = GST_READ_UINT16_BE (sy + i);
4431 U = GST_READ_UINT16_BE (suv + i);
4432 V = GST_READ_UINT16_BE (suv + i + 1);
4434 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4440 d[i * 4 + 0] = 0xffff;
4448 pack_P010_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4449 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4450 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4454 gint uv = GET_UV_420 (y, flags);
4455 guint16 *restrict dy = GET_PLANE_LINE (0, y);
4456 guint16 *restrict duv = GET_PLANE_LINE (1, uv);
4457 guint16 Y0, Y1, U, V;
4458 const guint16 *restrict s = src;
4460 if (IS_CHROMA_LINE_420 (y, flags)) {
4461 for (i = 0; i < width / 2; i++) {
4462 Y0 = s[i * 8 + 1] & 0xffc0;
4463 Y1 = s[i * 8 + 5] & 0xffc0;
4464 U = s[i * 8 + 2] & 0xffc0;
4465 V = s[i * 8 + 3] & 0xffc0;
4467 GST_WRITE_UINT16_BE (dy + i * 2 + 0, Y0);
4468 GST_WRITE_UINT16_BE (dy + i * 2 + 1, Y1);
4469 GST_WRITE_UINT16_BE (duv + i * 2 + 0, U);
4470 GST_WRITE_UINT16_BE (duv + i * 2 + 1, V);
4475 Y0 = s[i * 4 + 1] & 0xffc0;
4476 U = s[i * 4 + 2] & 0xffc0;
4477 V = s[i * 4 + 3] & 0xffc0;
4479 GST_WRITE_UINT16_BE (dy + i, Y0);
4480 GST_WRITE_UINT16_BE (duv + i + 0, U);
4481 GST_WRITE_UINT16_BE (duv + i + 1, V);
4484 for (i = 0; i < width; i++) {
4485 Y0 = s[i * 4 + 1] & 0xffc0;
4486 GST_WRITE_UINT16_BE (dy + i, Y0);
4491 #define PACK_P010_10LE GST_VIDEO_FORMAT_AYUV64, unpack_P010_10LE, 1, pack_P010_10LE
4493 unpack_P010_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4494 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4495 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4498 gint uv = GET_UV_420 (y, flags);
4499 const guint16 *restrict sy = GET_PLANE_LINE (0, y);
4500 const guint16 *restrict suv = GET_PLANE_LINE (1, uv);
4501 guint16 *restrict d = dest, Y0, Y1, U, V;
4507 Y0 = GST_READ_UINT16_LE (sy);
4508 U = GST_READ_UINT16_LE (suv);
4509 V = GST_READ_UINT16_LE (suv + 1);
4511 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4527 for (i = 0; i < width / 2; i++) {
4528 Y0 = GST_READ_UINT16_LE (sy + 2 * i);
4529 Y1 = GST_READ_UINT16_LE (sy + 2 * i + 1);
4530 U = GST_READ_UINT16_LE (suv + 2 * i);
4531 V = GST_READ_UINT16_LE (suv + 2 * i + 1);
4533 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4540 d[i * 8 + 0] = 0xffff;
4544 d[i * 8 + 4] = 0xffff;
4553 Y0 = GST_READ_UINT16_LE (sy + i);
4554 U = GST_READ_UINT16_LE (suv + i);
4555 V = GST_READ_UINT16_LE (suv + i + 1);
4557 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4563 d[i * 4 + 0] = 0xffff;
4571 pack_P010_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4572 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4573 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4577 gint uv = GET_UV_420 (y, flags);
4578 guint16 *restrict dy = GET_PLANE_LINE (0, y);
4579 guint16 *restrict duv = GET_PLANE_LINE (1, uv);
4580 guint16 Y0, Y1, U, V;
4581 const guint16 *restrict s = src;
4583 if (IS_CHROMA_LINE_420 (y, flags)) {
4584 for (i = 0; i < width / 2; i++) {
4585 Y0 = s[i * 8 + 1] & 0xffc0;
4586 Y1 = s[i * 8 + 5] & 0xffc0;
4587 U = s[i * 8 + 2] & 0xffc0;
4588 V = s[i * 8 + 3] & 0xffc0;
4590 GST_WRITE_UINT16_LE (dy + i * 2 + 0, Y0);
4591 GST_WRITE_UINT16_LE (dy + i * 2 + 1, Y1);
4592 GST_WRITE_UINT16_LE (duv + i * 2 + 0, U);
4593 GST_WRITE_UINT16_LE (duv + i * 2 + 1, V);
4598 Y0 = s[i * 4 + 1] & 0xffc0;
4599 U = s[i * 4 + 2] & 0xffc0;
4600 V = s[i * 4 + 3] & 0xffc0;
4602 GST_WRITE_UINT16_LE (dy + i, Y0);
4603 GST_WRITE_UINT16_LE (duv + i + 0, U);
4604 GST_WRITE_UINT16_LE (duv + i + 1, V);
4607 for (i = 0; i < width; i++) {
4608 Y0 = s[i * 4 + 1] & 0xffc0;
4609 GST_WRITE_UINT16_LE (dy + i, Y0);
4614 #define PACK_GRAY10_LE32 GST_VIDEO_FORMAT_AYUV64, unpack_GRAY10_LE32, 1, pack_GRAY10_LE32
4616 unpack_GRAY10_LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4617 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4618 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4621 const guint32 *restrict sy = GET_PLANE_LINE (0, y);
4622 guint16 *restrict d = dest;
4623 gint num_words = (width + 2) / 3;
4625 /* Y data is packed into little endian 32bit words, with the 2 MSB being
4626 * padding. There is only 1 pattern.
4627 * -> padding | Y1 | Y2 | Y3
4630 for (i = 0; i < num_words; i++) {
4631 gint num_comps = MIN (3, width - i * 3);
4633 gsize doff = pix * 4;
4637 Y = GST_READ_UINT32_LE (sy + i);
4639 for (c = 0; c < num_comps; c++) {
4642 /* For Y, we simply read 10 bit and shift it out */
4643 Yn = (Y & 0x03ff) << 6;
4646 if (G_UNLIKELY (pix + c < x))
4649 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE))
4652 d[doff + 0] = 0xffff;
4654 d[doff + 2] = 0x8000;
4655 d[doff + 3] = 0x8000;
4663 pack_GRAY10_LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4664 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4665 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4669 guint32 *restrict dy = GET_PLANE_LINE (0, y);
4670 const guint16 *restrict s = src;
4671 gint num_words = (width + 2) / 3;
4673 for (i = 0; i < num_words; i++) {
4674 gint num_comps = MIN (3, width - i * 3);
4676 gsize soff = pix * 4;
4680 for (c = 0; c < num_comps; c++) {
4681 Y |= s[soff + 1] >> 6 << (10 * c);
4685 GST_WRITE_UINT32_LE (dy + i, Y);
4689 #define PACK_NV12_10LE32 GST_VIDEO_FORMAT_AYUV64, unpack_NV12_10LE32, 1, pack_NV12_10LE32
4691 unpack_NV12_10LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4692 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4693 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4696 gint uv = GET_UV_420 (y, flags);
4697 const guint32 *restrict sy = GET_PLANE_LINE (0, y);
4698 const guint32 *restrict suv = GET_PLANE_LINE (1, uv);
4699 guint16 *restrict d = dest;
4700 gint num_words = (width + 2) / 3;
4702 guint16 Un = 0, Vn = 0;
4704 /* Y data is packed into little endian 32bit words, with the 2 MSB being
4705 * padding. There is only 1 pattern.
4706 * -> padding | Y1 | Y2 | Y3
4708 * UV is packed the same way, though we end up with 2 patterns:
4709 * -> U | V | U | padding
4710 * -> V | U | V | padding
4713 /* FIXME unroll the 6 states ? */
4715 for (i = 0; i < num_words; i++) {
4716 gint num_comps = MIN (3, width - i * 3);
4718 gsize doff = pix * 4;
4722 Y = GST_READ_UINT32_LE (sy + i);
4724 for (c = 0; c < num_comps; c++) {
4727 /* For Y, we simply read 10 bit and shift it out */
4728 Yn = (Y & 0x03ff) << 6;
4731 /* Unpacking UV has been reduced to a cycle of 6 states. The following
4732 * code is a reduce version of:
4733 * 0: - Read first UV word (UVU)
4735 * 1: - Resued U/V from 1 (sub-sampling)
4736 * 2: - Unpack remaining U value
4737 * - Read following UV word (VUV)
4739 * 3: - Reuse U/V from 2 (sub-sampling)
4740 * 4: - Unpack remaining U
4741 * - Unpack remaining V
4742 * 5: - Reuse UV/V from 4 (sub-sampling)
4744 switch ((pix + c) % 6) {
4746 UV = GST_READ_UINT32_LE (suv + i);
4749 Un = (UV & 0x03ff) << 6;
4751 Vn = (UV & 0x03ff) << 6;
4755 Un = (UV & 0x03ff) << 6;
4756 UV = GST_READ_UINT32_LE (suv + i + 1);
4757 Vn = (UV & 0x03ff) << 6;
4765 if (G_UNLIKELY (pix + c < x))
4768 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4774 d[doff + 0] = 0xffff;
4785 pack_NV12_10LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4786 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4787 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4791 gint uv = GET_UV_420 (y, flags);
4792 guint32 *restrict dy = GET_PLANE_LINE (0, y);
4793 guint32 *restrict duv = GET_PLANE_LINE (1, uv);
4794 const guint16 *restrict s = src;
4795 gint num_words = (width + 2) / 3;
4798 /* FIXME unroll the 6 states ? */
4800 for (i = 0; i < num_words; i++) {
4801 gint num_comps = MIN (3, width - i * 3);
4803 gsize soff = pix * 4;
4807 for (c = 0; c < num_comps; c++) {
4808 Y |= s[soff + 1] >> 6 << (10 * c);
4810 if (IS_CHROMA_LINE_420 (y, flags)) {
4811 switch ((pix + c) % 6) {
4813 UV = s[soff + 2] >> 6;
4814 UV |= s[soff + 3] >> 6 << 10;
4817 UV |= s[soff + 2] >> 6 << 20;
4818 GST_WRITE_UINT32_LE (duv + i, UV);
4819 UV = s[soff + 3] >> 6;
4822 UV |= s[soff + 2] >> 6 << 10;
4823 UV |= s[soff + 3] >> 6 << 20;
4824 GST_WRITE_UINT32_LE (duv + i, UV);
4835 GST_WRITE_UINT32_LE (dy + i, Y);
4837 if (IS_CHROMA_LINE_420 (y, flags) && num_comps < 3)
4838 GST_WRITE_UINT32_LE (duv + i, UV);
4843 #define PACK_NV16_10LE32 GST_VIDEO_FORMAT_AYUV64, unpack_NV16_10LE32, 1, pack_NV16_10LE32
4845 unpack_NV16_10LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4846 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4847 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4850 const guint32 *restrict sy = GET_PLANE_LINE (0, y);
4851 const guint32 *restrict suv = GET_PLANE_LINE (1, y);
4852 guint16 *restrict d = dest;
4853 gint num_words = (width + 2) / 3;
4855 guint16 Un = 0, Vn = 0;
4857 /* Y data is packed into little endian 32bit words, with the 2 MSB being
4858 * padding. There is only 1 pattern.
4859 * -> padding | Y1 | Y2 | Y3
4861 * UV is packed the same way, though we end up with 2 patterns:
4862 * -> U | V | U | padding
4863 * -> V | U | V | padding
4866 /* FIXME unroll the 6 states ? */
4868 for (i = 0; i < num_words; i++) {
4869 gint num_comps = MIN (3, width - i * 3);
4871 gsize doff = pix * 4;
4875 Y = GST_READ_UINT32_LE (sy + i);
4877 for (c = 0; c < num_comps; c++) {
4880 /* For Y, we simply read 10 bit and shift it out */
4881 Yn = (Y & 0x03ff) << 6;
4884 /* Unpacking UV has been reduced to a cycle of 6 states. The following
4885 * code is a reduce version of:
4886 * 0: - Read first UV word (UVU)
4888 * 1: - Resued U/V from 1 (sub-sampling)
4889 * 2: - Unpack remaining U value
4890 * - Read following UV word (VUV)
4892 * 3: - Reuse U/V from 2 (sub-sampling)
4893 * 4: - Unpack remaining U
4894 * - Unpack remaining V
4895 * 5: - Reuse UV/V from 4 (sub-sampling)
4897 switch ((pix + c) % 6) {
4899 UV = GST_READ_UINT32_LE (suv + i);
4902 Un = (UV & 0x03ff) << 6;
4904 Vn = (UV & 0x03ff) << 6;
4908 Un = (UV & 0x03ff) << 6;
4909 UV = GST_READ_UINT32_LE (suv + i + 1);
4910 Vn = (UV & 0x03ff) << 6;
4918 if (G_UNLIKELY (pix + c < x))
4921 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
4927 d[doff + 0] = 0xffff;
4938 pack_NV16_10LE32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4939 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
4940 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
4944 guint32 *restrict dy = GET_PLANE_LINE (0, y);
4945 guint32 *restrict duv = GET_PLANE_LINE (1, y);
4946 const guint16 *restrict s = src;
4947 gint num_words = (width + 2) / 3;
4950 /* FIXME unroll the 6 states ? */
4952 for (i = 0; i < num_words; i++) {
4953 gint num_comps = MIN (3, width - i * 3);
4955 gsize soff = pix * 4;
4959 for (c = 0; c < num_comps; c++) {
4960 Y |= s[soff + 1] >> 6 << (10 * c);
4962 switch ((pix + c) % 6) {
4964 UV = s[soff + 2] >> 6;
4965 UV |= s[soff + 3] >> 6 << 10;
4968 UV |= s[soff + 2] >> 6 << 20;
4969 GST_WRITE_UINT32_LE (duv + i, UV);
4970 UV = s[soff + 3] >> 6;
4973 UV |= s[soff + 2] >> 6 << 10;
4974 UV |= s[soff + 3] >> 6 << 20;
4975 GST_WRITE_UINT32_LE (duv + i, UV);
4985 GST_WRITE_UINT32_LE (dy + i, Y);
4988 GST_WRITE_UINT32_LE (duv + i, UV);
4992 #define PACK_NV12_10LE40 GST_VIDEO_FORMAT_AYUV64, unpack_NV12_10LE40, 1, pack_NV12_10LE40
4994 unpack_NV12_10LE40 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
4995 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
4996 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
4999 gint uv = GET_UV_420 (y, flags);
5000 guint16 *restrict d = dest;
5001 const guint8 *restrict sy = GET_PLANE_LINE (0, y);
5002 const guint8 *restrict suv = GET_PLANE_LINE (1, uv);
5003 guint16 Y0 = 0, Y1 = 0, Yn = 0, Un = 0, Vn = 0;
5006 for (i = 0; i < width; i++) {
5007 gboolean update_c = FALSE;
5011 Y0 = GST_READ_UINT16_LE (sy);
5015 UV = GST_READ_UINT32_LE (suv);
5017 Vn = (UV >> 10) & 0x3ff;
5026 Y1 = GST_READ_UINT16_LE (sy);
5027 Yn = (Y0 >> 10) | ((Y1 & 0xf) << 6);
5033 Yn = (Y1 >> 4) & 0x3ff;
5035 Un = (UV >> 20) & 0x3ff;
5037 UV = GST_READ_UINT8 (suv);
5047 Y0 = GST_READ_UINT8 (sy);
5048 Yn = (Y1 >> 14) | (Y0 << 2);
5055 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
5063 d[i * 4 + 0] = 0xffff;
5071 pack_NV12_10LE40 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
5072 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
5073 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
5077 gint uv = GET_UV_420 (y, flags);
5078 guint8 *restrict dy = GET_PLANE_LINE (0, y);
5079 guint8 *restrict duv = GET_PLANE_LINE (1, uv);
5080 guint16 Y0 = 0, Y1 = 0, Y2 = 0, Y3 = 0, U0, V0 = 0, U1 = 0, V1 = 0;
5081 const guint16 *restrict s = src;
5083 for (i = 0; i < width; i++) {
5086 Y0 = s[i * 4 + 1] >> 6;
5087 GST_WRITE_UINT8 (dy, Y0 & 0xff);
5090 if (IS_CHROMA_LINE_420 (y, flags)) {
5091 U0 = s[i * 4 + 2] >> 6;
5092 V0 = s[i * 4 + 3] >> 6;
5094 GST_WRITE_UINT8 (duv, U0 & 0xff);
5097 GST_WRITE_UINT8 (duv, (U0 >> 8) | ((V0 & 0x3f) << 2));
5102 Y1 = s[i * 4 + 1] >> 6;
5103 GST_WRITE_UINT8 (dy, (Y0 >> 8) | ((Y1 & 0x3f) << 2));
5107 Y2 = s[i * 4 + 1] >> 6;
5108 GST_WRITE_UINT8 (dy, (Y1 >> 6) | ((Y2 & 0xf) << 4));
5111 if (IS_CHROMA_LINE_420 (y, flags)) {
5112 U1 = s[i * 4 + 2] >> 6;
5113 V1 = s[i * 4 + 3] >> 6;
5115 GST_WRITE_UINT8 (duv, (V0 >> 6) | ((U1 & 0xf) << 4));
5118 GST_WRITE_UINT8 (duv, (U1 >> 4) | ((V1 & 0x3) << 6));
5121 GST_WRITE_UINT8 (duv, V1 >> 2);
5126 Y3 = s[i * 4 + 1] >> 6;
5127 GST_WRITE_UINT8 (dy, (Y2 >> 4) | ((Y3 & 0x3) << 6));
5129 GST_WRITE_UINT8 (dy, (Y3 >> 2));
5135 switch (width & 3) {
5139 GST_WRITE_UINT8 (dy, Y0 >> 8);
5140 if (IS_CHROMA_LINE_420 (y, flags))
5141 GST_WRITE_UINT8 (duv, V0 >> 6);
5144 GST_WRITE_UINT8 (dy, Y1 >> 6);
5145 if (IS_CHROMA_LINE_420 (y, flags))
5146 GST_WRITE_UINT8 (duv, V0 >> 6);
5149 GST_WRITE_UINT8 (dy, Y2 >> 4);
5157 GstVideoFormatInfo info;
5160 /* depths: bits, n_components, shift, depth */
5161 #define DPTH0 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5162 #define DPTH8 8, 1, { 0, 0, 0, 0 }, { 8, 0, 0, 0 }
5163 #define DPTH8_32 8, 2, { 0, 0, 0, 0 }, { 8, 32, 0, 0 }
5164 #define DPTH888 8, 3, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
5165 #define DPTH8888 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 8 }
5166 #define DPTH8880 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
5167 #define DPTH10 10, 1, { 0, 0, 0, 0 }, { 10, 0, 0, 0 }
5168 #define DPTH10_10_10 10, 3, { 0, 0, 0, 0 }, { 10, 10, 10, 0 }
5169 #define DPTH10_10_10_10 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 10 }
5170 #define DPTH10_10_10_HI 16, 3, { 6, 6, 6, 0 }, { 10, 10, 10, 0 }
5171 #define DPTH12_12_12 12, 3, { 0, 0, 0, 0 }, { 12, 12, 12, 0 }
5172 #define DPTH12_12_12_12 12, 4, { 0, 0, 0, 0 }, { 12, 12, 12, 12 }
5173 #define DPTH16 16, 1, { 0, 0, 0, 0 }, { 16, 0, 0, 0 }
5174 #define DPTH16_16_16 16, 3, { 0, 0, 0, 0 }, { 16, 16, 16, 0 }
5175 #define DPTH16_16_16_16 16, 4, { 0, 0, 0, 0 }, { 16, 16, 16, 16 }
5176 #define DPTH555 16, 3, { 10, 5, 0, 0 }, { 5, 5, 5, 0 }
5177 #define DPTH565 16, 3, { 11, 5, 0, 0 }, { 5, 6, 5, 0 }
5180 #define PSTR0 { 0, 0, 0, 0 }
5181 #define PSTR1 { 1, 0, 0, 0 }
5182 #define PSTR14 { 1, 4, 0, 0 }
5183 #define PSTR111 { 1, 1, 1, 0 }
5184 #define PSTR1111 { 1, 1, 1, 1 }
5185 #define PSTR122 { 1, 2, 2, 0 }
5186 #define PSTR2 { 2, 0, 0, 0 }
5187 #define PSTR222 { 2, 2, 2, 0 }
5188 #define PSTR2222 { 2, 2, 2, 2 }
5189 #define PSTR244 { 2, 4, 4, 0 }
5190 #define PSTR444 { 4, 4, 4, 0 }
5191 #define PSTR4444 { 4, 4, 4, 4 }
5192 #define PSTR333 { 3, 3, 3, 0 }
5193 #define PSTR488 { 4, 8, 8, 0 }
5194 #define PSTR8888 { 8, 8, 8, 8 }
5196 /* planes, in what plane do we find component N */
5197 #define PLANE_NA 0, { 0, 0, 0, 0 }
5198 #define PLANE0 1, { 0, 0, 0, 0 }
5199 #define PLANE01 2, { 0, 1, 0, 0 }
5200 #define PLANE011 2, { 0, 1, 1, 0 }
5201 #define PLANE012 3, { 0, 1, 2, 0 }
5202 #define PLANE0123 4, { 0, 1, 2, 3 }
5203 #define PLANE021 3, { 0, 2, 1, 0 }
5204 #define PLANE201 3, { 2, 0, 1, 0 }
5205 #define PLANE2013 4, { 2, 0, 1, 3 }
5208 #define OFFS0 { 0, 0, 0, 0 }
5209 #define OFFS013 { 0, 1, 3, 0 }
5210 #define OFFS102 { 1, 0, 2, 0 }
5211 #define OFFS1230 { 1, 2, 3, 0 }
5212 #define OFFS012 { 0, 1, 2, 0 }
5213 #define OFFS210 { 2, 1, 0, 0 }
5214 #define OFFS123 { 1, 2, 3, 0 }
5215 #define OFFS321 { 3, 2, 1, 0 }
5216 #define OFFS0123 { 0, 1, 2, 3 }
5217 #define OFFS2103 { 2, 1, 0, 3 }
5218 #define OFFS3210 { 3, 2, 1, 0 }
5219 #define OFFS031 { 0, 3, 1, 0 }
5220 #define OFFS204 { 2, 0, 4, 0 }
5221 #define OFFS001 { 0, 0, 1, 0 }
5222 #define OFFS010 { 0, 1, 0, 0 }
5223 #define OFFS104 { 1, 0, 4, 0 }
5224 #define OFFS2460 { 2, 4, 6, 0 }
5226 /* subsampling, w_sub, h_sub */
5227 #define SUB410 { 0, 2, 2, 0 }, { 0, 2, 2, 0 }
5228 #define SUB411 { 0, 2, 2, 0 }, { 0, 0, 0, 0 }
5229 #define SUB420 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
5230 #define SUB422 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
5231 #define SUB4 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5232 #define SUB44 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5233 #define SUB444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5234 #define SUB4444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
5235 #define SUB4204 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
5236 #define SUB4224 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
5238 /* tile_mode, tile_width, tile_height */
5239 #define TILE_64x32(mode) GST_VIDEO_TILE_MODE_ ##mode, 6, 5
5241 #define MAKE_YUV_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5242 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV, depth, pstride, plane, offs, sub, pack } }
5243 #define MAKE_YUV_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5244 { 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 } }
5245 #define MAKE_YUVA_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5246 { 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 } }
5247 #define MAKE_YUVA_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
5248 { 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 } }
5249 #define MAKE_YUVA_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5250 { 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 } }
5251 #define MAKE_YUVA_LE_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5252 { 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 } }
5253 #define MAKE_YUV_C_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5254 { 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 } }
5255 #define MAKE_YUV_C_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
5256 { 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 } }
5257 #define MAKE_YUV_T_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack, tile) \
5258 { 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 } }
5260 #define MAKE_RGB_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5261 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB, depth, pstride, plane, offs, sub, pack } }
5262 #define MAKE_RGB_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5263 { 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 } }
5264 #define MAKE_RGBA_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5265 { 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 } }
5266 #define MAKE_RGBA_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5267 { 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 } }
5268 #define MAKE_RGBAP_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5269 { 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 } }
5270 #define MAKE_RGBA_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5271 { 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 } }
5272 #define MAKE_RGBA_LE_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5273 { 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 } }
5275 #define MAKE_GRAY_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5276 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY, depth, pstride, plane, offs, sub, pack } }
5277 #define MAKE_GRAY_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5278 { 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 } }
5279 #define MAKE_GRAY_C_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
5280 { 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 } }
5282 static const VideoFormat formats[] = {
5283 {0x00000000, {GST_VIDEO_FORMAT_UNKNOWN, "UNKNOWN", "unknown video", 0, DPTH0,
5284 PSTR0, PLANE_NA, OFFS0}},
5285 {0x00000000, {GST_VIDEO_FORMAT_ENCODED, "ENCODED", "encoded video",
5286 GST_VIDEO_FORMAT_FLAG_COMPLEX, DPTH0, PSTR0, PLANE_NA, OFFS0}},
5288 MAKE_YUV_FORMAT (I420, "raw video", GST_MAKE_FOURCC ('I', '4', '2', '0'),
5289 DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
5290 MAKE_YUV_FORMAT (YV12, "raw video", GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
5291 DPTH888, PSTR111, PLANE021, OFFS0, SUB420, PACK_420),
5292 MAKE_YUV_FORMAT (YUY2, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
5293 DPTH888, PSTR244, PLANE0, OFFS013, SUB422, PACK_YUY2),
5294 MAKE_YUV_FORMAT (UYVY, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'),
5295 DPTH888, PSTR244, PLANE0, OFFS102, SUB422, PACK_UYVY),
5296 MAKE_YUVA_PACK_FORMAT (AYUV, "raw video", GST_MAKE_FOURCC ('A', 'Y', 'U',
5297 'V'), DPTH8888, PSTR4444, PLANE0, OFFS1230, SUB4444, PACK_AYUV),
5298 MAKE_RGB_FORMAT (RGBx, "raw video", DPTH888, PSTR444, PLANE0, OFFS012,
5300 MAKE_RGB_FORMAT (BGRx, "raw video", DPTH888, PSTR444, PLANE0, OFFS210,
5302 MAKE_RGB_FORMAT (xRGB, "raw video", DPTH888, PSTR444, PLANE0, OFFS123,
5304 MAKE_RGB_FORMAT (xBGR, "raw video", DPTH888, PSTR444, PLANE0, OFFS321,
5306 MAKE_RGBA_FORMAT (RGBA, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS0123,
5307 SUB4444, PACK_RGBA),
5308 MAKE_RGBA_FORMAT (BGRA, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS2103,
5309 SUB4444, PACK_BGRA),
5310 MAKE_RGBA_PACK_FORMAT (ARGB, "raw video", DPTH8888, PSTR4444, PLANE0,
5311 OFFS1230, SUB4444, PACK_ARGB),
5312 MAKE_RGBA_FORMAT (ABGR, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS3210,
5313 SUB4444, PACK_ABGR),
5314 MAKE_RGB_FORMAT (RGB, "raw video", DPTH888, PSTR333, PLANE0, OFFS012, SUB444,
5316 MAKE_RGB_FORMAT (BGR, "raw video", DPTH888, PSTR333, PLANE0, OFFS210, SUB444,
5319 MAKE_YUV_FORMAT (Y41B, "raw video", GST_MAKE_FOURCC ('Y', '4', '1', 'B'),
5320 DPTH888, PSTR111, PLANE012, OFFS0, SUB411, PACK_Y41B),
5321 MAKE_YUV_FORMAT (Y42B, "raw video", GST_MAKE_FOURCC ('Y', '4', '2', 'B'),
5322 DPTH888, PSTR111, PLANE012, OFFS0, SUB422, PACK_Y42B),
5323 MAKE_YUV_FORMAT (YVYU, "raw video", GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'),
5324 DPTH888, PSTR244, PLANE0, OFFS031, SUB422, PACK_YVYU),
5325 MAKE_YUV_FORMAT (Y444, "raw video", GST_MAKE_FOURCC ('Y', '4', '4', '4'),
5326 DPTH888, PSTR111, PLANE012, OFFS0, SUB444, PACK_Y444),
5327 MAKE_YUV_C_FORMAT (v210, "raw video", GST_MAKE_FOURCC ('v', '2', '1', '0'),
5328 DPTH10_10_10, PSTR0, PLANE0, OFFS0, SUB422, PACK_v210),
5329 MAKE_YUV_FORMAT (v216, "raw video", GST_MAKE_FOURCC ('v', '2', '1', '6'),
5330 DPTH16_16_16, PSTR488, PLANE0, OFFS204, SUB422, PACK_v216),
5331 MAKE_YUV_FORMAT (Y210, "raw video", GST_MAKE_FOURCC ('Y', '2', '1', '0'),
5332 DPTH10_10_10, PSTR488, PLANE0, OFFS0, SUB422, PACK_Y210),
5333 MAKE_YUV_FORMAT (NV12, "raw video", GST_MAKE_FOURCC ('N', 'V', '1', '2'),
5334 DPTH888, PSTR122, PLANE011, OFFS001, SUB420, PACK_NV12),
5335 MAKE_YUV_FORMAT (NV21, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '1'),
5336 DPTH888, PSTR122, PLANE011, OFFS010, SUB420, PACK_NV21),
5338 MAKE_GRAY_FORMAT (GRAY8, "raw video", DPTH8, PSTR1, PLANE0, OFFS0, SUB4,
5340 MAKE_GRAY_FORMAT (GRAY16_BE, "raw video", DPTH16, PSTR2, PLANE0, OFFS0, SUB4,
5342 MAKE_GRAY_LE_FORMAT (GRAY16_LE, "raw video", DPTH16, PSTR2, PLANE0, OFFS0,
5343 SUB4, PACK_GRAY16_LE),
5345 MAKE_YUV_FORMAT (v308, "raw video", GST_MAKE_FOURCC ('v', '3', '0', '8'),
5346 DPTH888, PSTR333, PLANE0, OFFS012, SUB444, PACK_v308),
5348 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
5349 MAKE_RGB_LE_FORMAT (RGB16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0,
5350 SUB444, PACK_RGB16),
5351 MAKE_RGB_LE_FORMAT (BGR16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0,
5352 SUB444, PACK_BGR16),
5353 MAKE_RGB_LE_FORMAT (RGB15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0,
5354 SUB444, PACK_RGB15),
5355 MAKE_RGB_LE_FORMAT (BGR15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0,
5356 SUB444, PACK_BGR15),
5358 MAKE_RGB_FORMAT (RGB16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0, SUB444,
5360 MAKE_RGB_FORMAT (BGR16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0, SUB444,
5362 MAKE_RGB_FORMAT (RGB15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0, SUB444,
5364 MAKE_RGB_FORMAT (BGR15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0, SUB444,
5368 MAKE_YUV_C_FORMAT (UYVP, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'),
5369 DPTH10_10_10, PSTR0, PLANE0, OFFS0, SUB422, PACK_UYVP),
5370 MAKE_YUVA_FORMAT (A420, "raw video", GST_MAKE_FOURCC ('A', '4', '2', '0'),
5371 DPTH8888, PSTR1111, PLANE0123, OFFS0, SUB4204, PACK_A420),
5372 MAKE_RGBAP_FORMAT (RGB8P, "raw video", DPTH8_32, PSTR14, PLANE01,
5373 OFFS0, SUB44, PACK_RGB8P),
5374 MAKE_YUV_FORMAT (YUV9, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'V', '9'),
5375 DPTH888, PSTR111, PLANE012, OFFS0, SUB410, PACK_410),
5376 MAKE_YUV_FORMAT (YVU9, "raw video", GST_MAKE_FOURCC ('Y', 'V', 'U', '9'),
5377 DPTH888, PSTR111, PLANE021, OFFS0, SUB410, PACK_410),
5378 MAKE_YUV_FORMAT (IYU1, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '1'),
5379 DPTH888, PSTR0, PLANE0, OFFS104, SUB411, PACK_IYU1),
5380 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
5381 MAKE_RGBA_LE_PACK_FORMAT (ARGB64, "raw video", DPTH16_16_16_16, PSTR8888,
5383 OFFS2460, SUB444, PACK_ARGB64),
5384 MAKE_YUVA_LE_PACK_FORMAT (AYUV64, "raw video", 0x00000000, DPTH16_16_16_16,
5385 PSTR8888, PLANE0, OFFS2460, SUB444, PACK_AYUV64),
5387 MAKE_RGBA_PACK_FORMAT (ARGB64, "raw video", DPTH16_16_16_16, PSTR8888, PLANE0,
5388 OFFS2460, SUB444, PACK_ARGB64),
5389 MAKE_YUVA_PACK_FORMAT (AYUV64, "raw video", 0x00000000, DPTH16_16_16_16,
5390 PSTR8888, PLANE0, OFFS2460, SUB444, PACK_AYUV64),
5392 MAKE_RGB_FORMAT (r210, "raw video", DPTH10_10_10, PSTR444, PLANE0, OFFS0,
5394 MAKE_YUV_FORMAT (I420_10BE, "raw video", 0x00000000, DPTH10_10_10,
5395 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10BE),
5396 MAKE_YUV_LE_FORMAT (I420_10LE, "raw video", 0x00000000, DPTH10_10_10,
5397 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10LE),
5398 MAKE_YUV_FORMAT (I422_10BE, "raw video", 0x00000000, DPTH10_10_10,
5399 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10BE),
5400 MAKE_YUV_LE_FORMAT (I422_10LE, "raw video", 0x00000000, DPTH10_10_10,
5401 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10LE),
5402 MAKE_YUV_FORMAT (Y444_10BE, "raw video", 0x00000000, DPTH10_10_10,
5403 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10BE),
5404 MAKE_YUV_LE_FORMAT (Y444_10LE, "raw video", 0x00000000, DPTH10_10_10,
5405 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10LE),
5406 MAKE_RGB_FORMAT (GBR, "raw video", DPTH888, PSTR111, PLANE201, OFFS0, SUB444,
5408 MAKE_RGB_FORMAT (GBR_10BE, "raw video", DPTH10_10_10, PSTR222, PLANE201,
5409 OFFS0, SUB444, PACK_GBR_10BE),
5410 MAKE_RGB_LE_FORMAT (GBR_10LE, "raw video", DPTH10_10_10, PSTR222, PLANE201,
5411 OFFS0, SUB444, PACK_GBR_10LE),
5412 MAKE_YUV_FORMAT (NV16, "raw video", GST_MAKE_FOURCC ('N', 'V', '1', '6'),
5413 DPTH888, PSTR122, PLANE011, OFFS001, SUB422, PACK_NV16),
5414 MAKE_YUV_FORMAT (NV24, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '4'),
5415 DPTH888, PSTR122, PLANE011, OFFS001, SUB444, PACK_NV24),
5416 MAKE_YUV_T_FORMAT (NV12_64Z32, "raw video",
5417 GST_MAKE_FOURCC ('T', 'M', '1', '2'), DPTH8880, PSTR122, PLANE011,
5418 OFFS001, SUB420, PACK_NV12_64Z32, TILE_64x32 (ZFLIPZ_2X2)),
5419 MAKE_YUVA_FORMAT (A420_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5420 PSTR2222, PLANE0123, OFFS0, SUB4204, PACK_A420_10BE),
5421 MAKE_YUVA_LE_FORMAT (A420_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5422 PSTR2222, PLANE0123, OFFS0, SUB4204, PACK_A420_10LE),
5423 MAKE_YUVA_FORMAT (A422_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5424 PSTR2222, PLANE0123, OFFS0, SUB4224, PACK_A422_10BE),
5425 MAKE_YUVA_LE_FORMAT (A422_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5426 PSTR2222, PLANE0123, OFFS0, SUB4224, PACK_A422_10LE),
5427 MAKE_YUVA_FORMAT (A444_10BE, "raw video", 0x00000000, DPTH10_10_10_10,
5428 PSTR2222, PLANE0123, OFFS0, SUB4444, PACK_A444_10BE),
5429 MAKE_YUVA_LE_FORMAT (A444_10LE, "raw video", 0x00000000, DPTH10_10_10_10,
5430 PSTR2222, PLANE0123, OFFS0, SUB4444, PACK_A444_10LE),
5431 MAKE_YUV_FORMAT (NV61, "raw video", GST_MAKE_FOURCC ('N', 'V', '6', '1'),
5432 DPTH888, PSTR122, PLANE011, OFFS010, SUB422, PACK_NV61),
5433 MAKE_YUV_FORMAT (P010_10BE, "raw video", 0x00000000, DPTH10_10_10_HI,
5434 PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10BE),
5435 MAKE_YUV_LE_FORMAT (P010_10LE, "raw video", 0x00000000, DPTH10_10_10_HI,
5436 PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10LE),
5437 MAKE_YUV_FORMAT (IYU2, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '2'),
5438 DPTH888, PSTR333, PLANE0, OFFS102, SUB444, PACK_IYU2),
5439 MAKE_YUV_FORMAT (VYUY, "raw video", GST_MAKE_FOURCC ('V', 'Y', 'U', 'Y'),
5440 DPTH888, PSTR244, PLANE0, OFFS102, SUB422, PACK_VYUY),
5441 MAKE_RGBA_FORMAT (GBRA, "raw video", DPTH8888, PSTR1111, PLANE2013,
5442 OFFS0, SUB4444, PACK_GBRA),
5443 MAKE_RGBA_FORMAT (GBRA_10BE, "raw video", DPTH10_10_10_10, PSTR222, PLANE2013,
5444 OFFS0, SUB4444, PACK_GBRA_10BE),
5445 MAKE_RGBA_LE_FORMAT (GBRA_10LE, "raw video", DPTH10_10_10_10, PSTR222,
5447 OFFS0, SUB4444, PACK_GBRA_10LE),
5448 MAKE_RGB_FORMAT (GBR_12BE, "raw video", DPTH12_12_12, PSTR222, PLANE201,
5449 OFFS0, SUB444, PACK_GBR_12BE),
5450 MAKE_RGB_LE_FORMAT (GBR_12LE, "raw video", DPTH12_12_12, PSTR222, PLANE201,
5451 OFFS0, SUB444, PACK_GBR_12LE),
5452 MAKE_RGBA_FORMAT (GBRA_12BE, "raw video", DPTH12_12_12_12, PSTR222, PLANE2013,
5453 OFFS0, SUB4444, PACK_GBRA_12BE),
5454 MAKE_RGBA_LE_PACK_FORMAT (GBRA_12LE, "raw video", DPTH12_12_12_12, PSTR222,
5455 PLANE2013, OFFS0, SUB4444, PACK_GBRA_12LE),
5456 MAKE_YUV_FORMAT (I420_12BE, "raw video", 0x00000000, DPTH12_12_12,
5457 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_12BE),
5458 MAKE_YUV_LE_FORMAT (I420_12LE, "raw video", 0x00000000, DPTH12_12_12,
5459 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_12LE),
5460 MAKE_YUV_FORMAT (I422_12BE, "raw video", 0x00000000, DPTH12_12_12,
5461 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_12BE),
5462 MAKE_YUV_LE_FORMAT (I422_12LE, "raw video", 0x00000000, DPTH12_12_12,
5463 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_12LE),
5464 MAKE_YUV_FORMAT (Y444_12BE, "raw video", 0x00000000, DPTH12_12_12,
5465 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_12BE),
5466 MAKE_YUV_LE_FORMAT (Y444_12LE, "raw video", 0x00000000, DPTH12_12_12,
5467 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_12LE),
5468 MAKE_GRAY_C_LE_FORMAT (GRAY10_LE32, "raw video", DPTH10, PSTR0, PLANE0, OFFS0,
5469 SUB4, PACK_GRAY10_LE32),
5470 MAKE_YUV_C_LE_FORMAT (NV12_10LE32, "raw video",
5471 GST_MAKE_FOURCC ('X', 'V', '1', '5'), DPTH10_10_10, PSTR0, PLANE011,
5472 OFFS001, SUB420, PACK_NV12_10LE32),
5473 MAKE_YUV_C_LE_FORMAT (NV16_10LE32, "raw video",
5474 GST_MAKE_FOURCC ('X', 'V', '2', '0'), DPTH10_10_10, PSTR0, PLANE011,
5475 OFFS001, SUB422, PACK_NV16_10LE32),
5476 MAKE_YUV_C_LE_FORMAT (NV12_10LE40, "raw video",
5477 GST_MAKE_FOURCC ('R', 'K', '2', '0'), DPTH10_10_10, PSTR0, PLANE011,
5478 OFFS0, SUB420, PACK_NV12_10LE40),
5481 static GstVideoFormat
5482 gst_video_format_from_rgb32_masks (int red_mask, int green_mask, int blue_mask)
5484 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
5485 blue_mask == 0x0000ff00) {
5486 return GST_VIDEO_FORMAT_RGBx;
5488 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
5489 blue_mask == 0xff000000) {
5490 return GST_VIDEO_FORMAT_BGRx;
5492 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
5493 blue_mask == 0x000000ff) {
5494 return GST_VIDEO_FORMAT_xRGB;
5496 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
5497 blue_mask == 0x00ff0000) {
5498 return GST_VIDEO_FORMAT_xBGR;
5501 return GST_VIDEO_FORMAT_UNKNOWN;
5504 static GstVideoFormat
5505 gst_video_format_from_rgba32_masks (int red_mask, int green_mask,
5506 int blue_mask, int alpha_mask)
5508 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
5509 blue_mask == 0x0000ff00 && alpha_mask == 0x000000ff) {
5510 return GST_VIDEO_FORMAT_RGBA;
5512 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
5513 blue_mask == 0xff000000 && alpha_mask == 0x000000ff) {
5514 return GST_VIDEO_FORMAT_BGRA;
5516 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
5517 blue_mask == 0x000000ff && alpha_mask == 0xff000000) {
5518 return GST_VIDEO_FORMAT_ARGB;
5520 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
5521 blue_mask == 0x00ff0000 && alpha_mask == 0xff000000) {
5522 return GST_VIDEO_FORMAT_ABGR;
5524 return GST_VIDEO_FORMAT_UNKNOWN;
5527 static GstVideoFormat
5528 gst_video_format_from_rgb24_masks (int red_mask, int green_mask, int blue_mask)
5530 if (red_mask == 0xff0000 && green_mask == 0x00ff00 && blue_mask == 0x0000ff) {
5531 return GST_VIDEO_FORMAT_RGB;
5533 if (red_mask == 0x0000ff && green_mask == 0x00ff00 && blue_mask == 0xff0000) {
5534 return GST_VIDEO_FORMAT_BGR;
5537 return GST_VIDEO_FORMAT_UNKNOWN;
5540 #define GST_VIDEO_COMP1_MASK_16_INT 0xf800
5541 #define GST_VIDEO_COMP2_MASK_16_INT 0x07e0
5542 #define GST_VIDEO_COMP3_MASK_16_INT 0x001f
5544 #define GST_VIDEO_COMP1_MASK_15_INT 0x7c00
5545 #define GST_VIDEO_COMP2_MASK_15_INT 0x03e0
5546 #define GST_VIDEO_COMP3_MASK_15_INT 0x001f
5548 static GstVideoFormat
5549 gst_video_format_from_rgb16_masks (int red_mask, int green_mask, int blue_mask)
5551 if (red_mask == GST_VIDEO_COMP1_MASK_16_INT
5552 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
5553 && blue_mask == GST_VIDEO_COMP3_MASK_16_INT) {
5554 return GST_VIDEO_FORMAT_RGB16;
5556 if (red_mask == GST_VIDEO_COMP3_MASK_16_INT
5557 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
5558 && blue_mask == GST_VIDEO_COMP1_MASK_16_INT) {
5559 return GST_VIDEO_FORMAT_BGR16;
5561 if (red_mask == GST_VIDEO_COMP1_MASK_15_INT
5562 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
5563 && blue_mask == GST_VIDEO_COMP3_MASK_15_INT) {
5564 return GST_VIDEO_FORMAT_RGB15;
5566 if (red_mask == GST_VIDEO_COMP3_MASK_15_INT
5567 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
5568 && blue_mask == GST_VIDEO_COMP1_MASK_15_INT) {
5569 return GST_VIDEO_FORMAT_BGR15;
5571 return GST_VIDEO_FORMAT_UNKNOWN;
5575 * gst_video_format_from_masks:
5576 * @depth: the amount of bits used for a pixel
5577 * @bpp: the amount of bits used to store a pixel. This value is bigger than
5579 * @endianness: the endianness of the masks, #G_LITTLE_ENDIAN or #G_BIG_ENDIAN
5580 * @red_mask: the red mask
5581 * @green_mask: the green mask
5582 * @blue_mask: the blue mask
5583 * @alpha_mask: the alpha mask, or 0 if no alpha mask
5585 * Find the #GstVideoFormat for the given parameters.
5587 * Returns: a #GstVideoFormat or GST_VIDEO_FORMAT_UNKNOWN when the parameters to
5588 * not specify a known format.
5591 gst_video_format_from_masks (gint depth, gint bpp, gint endianness,
5592 guint red_mask, guint green_mask, guint blue_mask, guint alpha_mask)
5594 GstVideoFormat format;
5596 /* our caps system handles 24/32bpp RGB as big-endian. */
5597 if ((bpp == 24 || bpp == 32) && endianness == G_LITTLE_ENDIAN) {
5598 red_mask = GUINT32_TO_BE (red_mask);
5599 green_mask = GUINT32_TO_BE (green_mask);
5600 blue_mask = GUINT32_TO_BE (blue_mask);
5601 alpha_mask = GUINT32_TO_BE (alpha_mask);
5602 endianness = G_BIG_ENDIAN;
5610 if (depth == 30 && bpp == 32) {
5611 format = GST_VIDEO_FORMAT_r210;
5612 } else if (depth == 24 && bpp == 32) {
5613 format = gst_video_format_from_rgb32_masks (red_mask, green_mask,
5615 } else if (depth == 32 && bpp == 32 && alpha_mask) {
5616 format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
5617 blue_mask, alpha_mask);
5618 } else if (depth == 24 && bpp == 24) {
5619 format = gst_video_format_from_rgb24_masks (red_mask, green_mask,
5621 } else if ((depth == 15 || depth == 16) && bpp == 16 &&
5622 endianness == G_BYTE_ORDER) {
5623 format = gst_video_format_from_rgb16_masks (red_mask, green_mask,
5625 } else if (depth == 8 && bpp == 8) {
5626 format = GST_VIDEO_FORMAT_RGB8P;
5627 } else if (depth == 64 && bpp == 64) {
5628 format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
5629 blue_mask, alpha_mask);
5630 if (format == GST_VIDEO_FORMAT_ARGB) {
5631 format = GST_VIDEO_FORMAT_ARGB64;
5633 format = GST_VIDEO_FORMAT_UNKNOWN;
5636 format = GST_VIDEO_FORMAT_UNKNOWN;
5642 * gst_video_format_from_fourcc:
5643 * @fourcc: a FOURCC value representing raw YUV video
5645 * Converts a FOURCC value into the corresponding #GstVideoFormat.
5646 * If the FOURCC cannot be represented by #GstVideoFormat,
5647 * #GST_VIDEO_FORMAT_UNKNOWN is returned.
5649 * Returns: the #GstVideoFormat describing the FOURCC value
5652 gst_video_format_from_fourcc (guint32 fourcc)
5655 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
5656 return GST_VIDEO_FORMAT_I420;
5657 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
5658 return GST_VIDEO_FORMAT_YV12;
5659 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
5660 return GST_VIDEO_FORMAT_YUY2;
5661 case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
5662 return GST_VIDEO_FORMAT_YVYU;
5663 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
5664 return GST_VIDEO_FORMAT_UYVY;
5665 case GST_MAKE_FOURCC ('V', 'Y', 'U', 'Y'):
5666 return GST_VIDEO_FORMAT_VYUY;
5667 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
5668 return GST_VIDEO_FORMAT_AYUV;
5669 case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
5670 return GST_VIDEO_FORMAT_Y41B;
5671 case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
5672 return GST_VIDEO_FORMAT_Y42B;
5673 case GST_MAKE_FOURCC ('Y', '4', '4', '4'):
5674 return GST_VIDEO_FORMAT_Y444;
5675 case GST_MAKE_FOURCC ('v', '2', '1', '0'):
5676 return GST_VIDEO_FORMAT_v210;
5677 case GST_MAKE_FOURCC ('v', '2', '1', '6'):
5678 return GST_VIDEO_FORMAT_v216;
5679 case GST_MAKE_FOURCC ('Y', '2', '1', '0'):
5680 return GST_VIDEO_FORMAT_Y210;
5681 case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
5682 return GST_VIDEO_FORMAT_NV12;
5683 case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
5684 return GST_VIDEO_FORMAT_NV21;
5685 case GST_MAKE_FOURCC ('N', 'V', '1', '6'):
5686 return GST_VIDEO_FORMAT_NV16;
5687 case GST_MAKE_FOURCC ('N', 'V', '6', '1'):
5688 return GST_VIDEO_FORMAT_NV61;
5689 case GST_MAKE_FOURCC ('N', 'V', '2', '4'):
5690 return GST_VIDEO_FORMAT_NV24;
5691 case GST_MAKE_FOURCC ('v', '3', '0', '8'):
5692 return GST_VIDEO_FORMAT_v308;
5693 case GST_MAKE_FOURCC ('I', 'Y', 'U', '2'):
5694 return GST_VIDEO_FORMAT_IYU2;
5695 case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
5696 case GST_MAKE_FOURCC ('Y', '8', ' ', ' '):
5697 case GST_MAKE_FOURCC ('G', 'R', 'E', 'Y'):
5698 return GST_VIDEO_FORMAT_GRAY8;
5699 case GST_MAKE_FOURCC ('Y', '1', '6', ' '):
5700 return GST_VIDEO_FORMAT_GRAY16_LE;
5701 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'):
5702 return GST_VIDEO_FORMAT_UYVP;
5703 case GST_MAKE_FOURCC ('A', '4', '2', '0'):
5704 return GST_VIDEO_FORMAT_A420;
5705 case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
5706 return GST_VIDEO_FORMAT_YUV9;
5707 case GST_MAKE_FOURCC ('Y', 'V', 'U', '9'):
5708 return GST_VIDEO_FORMAT_YVU9;
5709 case GST_MAKE_FOURCC ('I', 'Y', 'U', '1'):
5710 return GST_VIDEO_FORMAT_IYU1;
5711 case GST_MAKE_FOURCC ('A', 'Y', '6', '4'):
5712 return GST_VIDEO_FORMAT_AYUV64;
5713 case GST_MAKE_FOURCC ('X', 'V', '1', '0'):
5714 return GST_VIDEO_FORMAT_GRAY10_LE32;
5715 case GST_MAKE_FOURCC ('X', 'V', '1', '5'):
5716 return GST_VIDEO_FORMAT_NV12_10LE32;
5717 case GST_MAKE_FOURCC ('X', 'V', '2', '0'):
5718 return GST_VIDEO_FORMAT_NV16_10LE32;
5719 case GST_MAKE_FOURCC ('R', 'K', '2', '0'):
5720 return GST_VIDEO_FORMAT_NV12_10LE40;
5722 return GST_VIDEO_FORMAT_UNKNOWN;
5727 * gst_video_format_from_string:
5728 * @format: a format string
5730 * Convert the @format string to its #GstVideoFormat.
5732 * Returns: the #GstVideoFormat for @format or GST_VIDEO_FORMAT_UNKNOWN when the
5733 * string is not a known format.
5736 gst_video_format_from_string (const gchar * format)
5740 g_return_val_if_fail (format != NULL, GST_VIDEO_FORMAT_UNKNOWN);
5742 for (i = 0; i < G_N_ELEMENTS (formats); i++) {
5743 if (strcmp (GST_VIDEO_FORMAT_INFO_NAME (&formats[i].info), format) == 0)
5744 return GST_VIDEO_FORMAT_INFO_FORMAT (&formats[i].info);
5746 return GST_VIDEO_FORMAT_UNKNOWN;
5751 * gst_video_format_to_fourcc:
5752 * @format: a #GstVideoFormat video format
5754 * Converts a #GstVideoFormat value into the corresponding FOURCC. Only
5755 * a few YUV formats have corresponding FOURCC values. If @format has
5756 * no corresponding FOURCC value, 0 is returned.
5758 * Returns: the FOURCC corresponding to @format
5761 gst_video_format_to_fourcc (GstVideoFormat format)
5763 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
5765 if ((gint) format >= G_N_ELEMENTS (formats))
5768 return formats[format].fourcc;
5772 * gst_video_format_to_string:
5773 * @format: a #GstVideoFormat video format
5775 * Returns a string containing a descriptive name for
5776 * the #GstVideoFormat if there is one, or NULL otherwise.
5778 * Returns: the name corresponding to @format
5781 gst_video_format_to_string (GstVideoFormat format)
5783 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
5785 if ((gint) format >= G_N_ELEMENTS (formats))
5788 return GST_VIDEO_FORMAT_INFO_NAME (&formats[format].info);
5792 * gst_video_format_get_info:
5793 * @format: a #GstVideoFormat
5795 * Get the #GstVideoFormatInfo for @format
5797 * Returns: The #GstVideoFormatInfo for @format.
5799 const GstVideoFormatInfo *
5800 gst_video_format_get_info (GstVideoFormat format)
5802 g_return_val_if_fail ((gint) format < G_N_ELEMENTS (formats), NULL);
5804 return &formats[format].info;
5808 * gst_video_format_get_palette:
5809 * @format: a #GstVideoFormat
5810 * @size: (out): size of the palette in bytes
5812 * Get the default palette of @format. This the palette used in the pack
5813 * function for paletted formats.
5815 * Returns: (transfer none): the default palette of @format or %NULL when
5816 * @format does not have a palette.
5821 gst_video_format_get_palette (GstVideoFormat format, gsize * size)
5823 g_return_val_if_fail ((gint) format < G_N_ELEMENTS (formats), NULL);
5824 g_return_val_if_fail (size != NULL, NULL);
5827 case GST_VIDEO_FORMAT_RGB8P:
5828 *size = sizeof (std_palette_RGB8P);
5829 return std_palette_RGB8P;