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"
32 /* Line conversion to AYUV */
34 #define GET_PLANE_STRIDE(plane) (stride(plane))
35 #define GET_PLANE_LINE(plane, line) \
36 (gpointer)(((guint8*)(data[plane])) + stride[plane] * (line))
38 #define GET_COMP_STRIDE(comp) \
39 GST_VIDEO_FORMAT_INFO_STRIDE (info, stride, comp)
40 #define GET_COMP_DATA(comp) \
41 GST_VIDEO_FORMAT_INFO_DATA (info, data, comp)
43 #define GET_COMP_LINE(comp, line) \
44 (gpointer)(((guint8*)GET_COMP_DATA (comp)) + \
45 GET_COMP_STRIDE(comp) * (line))
47 #define GET_LINE(line) GET_PLANE_LINE (0, line)
49 #define GET_Y_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_Y, line)
50 #define GET_U_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_U, line)
51 #define GET_V_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_V, line)
53 #define GET_R_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_R, line)
54 #define GET_G_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_G, line)
55 #define GET_B_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_B, line)
57 #define GET_A_LINE(line) GET_COMP_LINE(GST_VIDEO_COMP_A, line)
59 #define GET_UV_420(line, flags) \
60 (flags & GST_VIDEO_PACK_FLAG_INTERLACED ? \
61 ((line & ~3) >> 1) + (line & 1) : \
63 #define GET_UV_410(line, flags) \
64 (flags & GST_VIDEO_PACK_FLAG_INTERLACED ? \
65 ((line & ~7) >> 2) + (line & 1) : \
68 #define IS_ALIGNED(x,n) ((((guintptr)(x)&((n)-1))) == 0)
70 #define PACK_420 GST_VIDEO_FORMAT_AYUV, unpack_planar_420, 1, pack_planar_420
72 unpack_planar_420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
73 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
74 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
76 gint uv = GET_UV_420 (y, flags);
77 guint8 *y_line = GET_Y_LINE (y);
78 guint8 *u_line = GET_U_LINE (uv);
79 guint8 *v_line = GET_V_LINE (uv);
82 video_orc_unpack_I420 (dest, y_line, u_line, v_line, width);
87 ayuv[i * 4 + 2] = u_line[i >> 1];
88 ayuv[i * 4 + 3] = v_line[i >> 1];
93 pack_planar_420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
94 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
95 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
98 gint uv = GET_UV_420 (y, flags);
99 guint8 *y_line = GET_Y_LINE (y);
100 guint8 *u_line = GET_U_LINE (uv);
101 guint8 *v_line = GET_V_LINE (uv);
102 const guint8 *ayuv = src;
104 g_return_if_fail (IS_ALIGNED (src, 8));
106 video_orc_pack_I420 (y_line, u_line, v_line, src, width / 2);
111 y_line[i] = ayuv[i * 4 + 1];
112 u_line[i >> 1] = ayuv[i * 4 + 2];
113 v_line[i >> 1] = ayuv[i * 4 + 3];
117 #define PACK_YUY2 GST_VIDEO_FORMAT_AYUV, unpack_YUY2, 1, pack_YUY2
119 unpack_YUY2 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
120 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
121 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
123 guint8 *line = GET_LINE (y);
126 g_return_if_fail (IS_ALIGNED (dest, 8));
128 video_orc_unpack_YUY2 (dest, line, width / 2);
134 d[i * 4 + 1] = line[i * 2 + 0];
135 d[i * 4 + 2] = line[i * 2 + 1];
136 d[i * 4 + 3] = line[i * 2 + 3];
141 pack_YUY2 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
142 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
143 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
146 guint8 *line = GET_LINE (y);
147 const guint8 *ayuv = src;
149 g_return_if_fail (IS_ALIGNED (src, 8));
151 video_orc_pack_YUY2 (line, src, width / 2);
156 line[i * 2 + 0] = ayuv[i * 4 + 1];
157 line[i * 2 + 1] = ayuv[i * 4 + 2];
158 line[i * 2 + 3] = ayuv[i * 4 + 3];
162 #define PACK_UYVY GST_VIDEO_FORMAT_AYUV, unpack_UYVY, 1, pack_UYVY
164 unpack_UYVY (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
165 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
166 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
168 guint8 *line = GET_LINE (y);
171 g_return_if_fail (IS_ALIGNED (dest, 8));
173 video_orc_unpack_UYVY (dest, line, width / 2);
179 d[i * 4 + 1] = line[i * 2 + 1];
180 d[i * 4 + 2] = line[i * 2 + 0];
181 d[i * 4 + 3] = line[i * 2 + 2];
186 pack_UYVY (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
187 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
188 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
191 guint8 *line = GET_LINE (y);
192 const guint8 *ayuv = src;
194 g_return_if_fail (IS_ALIGNED (src, 8));
196 video_orc_pack_UYVY (line, src, width / 2);
201 line[i * 2 + 0] = ayuv[i * 4 + 2];
202 line[i * 2 + 1] = ayuv[i * 4 + 1];
203 line[i * 2 + 2] = ayuv[i * 4 + 3];
207 #define PACK_YVYU GST_VIDEO_FORMAT_AYUV, unpack_YVYU, 1, pack_YVYU
209 unpack_YVYU (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
210 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
211 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
213 guint8 *line = GET_LINE (y);
216 g_return_if_fail (IS_ALIGNED (dest, 8));
218 video_orc_unpack_YVYU (dest, line, width / 2);
224 d[i * 4 + 1] = line[i * 2 + 0];
225 d[i * 4 + 2] = line[i * 2 + 3];
226 d[i * 4 + 3] = line[i * 2 + 1];
231 pack_YVYU (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
232 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
233 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
236 guint8 *line = GET_LINE (y);
237 const guint8 *ayuv = src;
239 g_return_if_fail (IS_ALIGNED (src, 8));
241 video_orc_pack_YVYU (line, src, width / 2);
246 line[i * 2 + 0] = ayuv[i * 4 + 1];
247 line[i * 2 + 1] = ayuv[i * 4 + 3];
248 line[i * 2 + 3] = ayuv[i * 4 + 2];
252 #define PACK_v308 GST_VIDEO_FORMAT_AYUV, unpack_v308, 1, pack_v308
254 unpack_v308 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
255 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
256 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
259 const guint8 *s = GET_LINE (y);
262 for (i = 0; i < width; i++) {
264 d[i * 4 + 1] = s[i * 3 + 0];
265 d[i * 4 + 2] = s[i * 3 + 1];
266 d[i * 4 + 3] = s[i * 3 + 2];
271 pack_v308 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
272 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
273 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
277 guint8 *d = GET_LINE (y);
278 const guint8 *s = src;
280 for (i = 0; i < width; i++) {
281 d[i * 3 + 0] = s[i * 4 + 1];
282 d[i * 3 + 1] = s[i * 4 + 2];
283 d[i * 3 + 2] = s[i * 4 + 3];
287 #define PACK_AYUV GST_VIDEO_FORMAT_AYUV, unpack_copy4, 1, pack_copy4
288 #define PACK_ARGB GST_VIDEO_FORMAT_ARGB, unpack_copy4, 1, pack_copy4
290 unpack_copy4 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
291 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
292 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
294 memcpy (dest, GET_LINE (y), width * 4);
298 pack_copy4 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
299 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
300 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
303 memcpy (GET_LINE (y), src, width * 4);
306 #define PACK_v210 GST_VIDEO_FORMAT_AYUV64, unpack_v210, 1, pack_v210
308 unpack_v210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
309 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
310 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
313 const guint8 *s = GET_LINE (y);
315 guint32 a0, a1, a2, a3;
316 guint16 y0, y1, y2, y3, y4, y5;
320 for (i = 0; i < width; i += 6) {
321 a0 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 0);
322 a1 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 4);
323 a2 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 8);
324 a3 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 12);
326 u0 = ((a0 >> 0) & 0x3ff) << 6;
327 y0 = ((a0 >> 10) & 0x3ff) << 6;
328 v0 = ((a0 >> 20) & 0x3ff) << 6;
329 y1 = ((a1 >> 0) & 0x3ff) << 6;
331 u2 = ((a1 >> 10) & 0x3ff) << 6;
332 y2 = ((a1 >> 20) & 0x3ff) << 6;
333 v2 = ((a2 >> 0) & 0x3ff) << 6;
334 y3 = ((a2 >> 10) & 0x3ff) << 6;
336 u4 = ((a2 >> 20) & 0x3ff) << 6;
337 y4 = ((a3 >> 0) & 0x3ff) << 6;
338 v4 = ((a3 >> 10) & 0x3ff) << 6;
339 y5 = ((a3 >> 20) & 0x3ff) << 6;
341 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
358 d[4 * (i + 0) + 0] = 0xffff;
359 d[4 * (i + 0) + 1] = y0;
360 d[4 * (i + 0) + 2] = u0;
361 d[4 * (i + 0) + 3] = v0;
364 d[4 * (i + 1) + 0] = 0xffff;
365 d[4 * (i + 1) + 1] = y1;
366 d[4 * (i + 1) + 2] = u0;
367 d[4 * (i + 1) + 3] = v0;
370 d[4 * (i + 2) + 0] = 0xffff;
371 d[4 * (i + 2) + 1] = y2;
372 d[4 * (i + 2) + 2] = u2;
373 d[4 * (i + 2) + 3] = v2;
376 d[4 * (i + 3) + 0] = 0xffff;
377 d[4 * (i + 3) + 1] = y3;
378 d[4 * (i + 3) + 2] = u2;
379 d[4 * (i + 3) + 3] = v2;
382 d[4 * (i + 4) + 0] = 0xffff;
383 d[4 * (i + 4) + 1] = y4;
384 d[4 * (i + 4) + 2] = u4;
385 d[4 * (i + 4) + 3] = v4;
388 d[4 * (i + 5) + 0] = 0xffff;
389 d[4 * (i + 5) + 1] = y5;
390 d[4 * (i + 5) + 2] = u4;
391 d[4 * (i + 5) + 3] = v4;
397 pack_v210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
398 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
399 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
403 guint8 *d = GET_LINE (y);
404 const guint16 *s = src;
405 guint32 a0, a1, a2, a3;
406 guint16 y0, y1, y2, y3, y4, y5;
410 for (i = 0; i < width - 5; i += 6) {
411 y0 = s[4 * (i + 0) + 1] >> 6;
412 y1 = s[4 * (i + 1) + 1] >> 6;
413 y2 = s[4 * (i + 2) + 1] >> 6;
414 y3 = s[4 * (i + 3) + 1] >> 6;
415 y4 = s[4 * (i + 4) + 1] >> 6;
416 y5 = s[4 * (i + 5) + 1] >> 6;
418 u0 = s[4 * (i + 0) + 2] >> 6;
419 u1 = s[4 * (i + 2) + 2] >> 6;
420 u2 = s[4 * (i + 4) + 2] >> 6;
422 v0 = s[4 * (i + 0) + 3] >> 6;
423 v1 = s[4 * (i + 2) + 3] >> 6;
424 v2 = s[4 * (i + 4) + 3] >> 6;
426 a0 = u0 | (y0 << 10) | (v0 << 20);
427 a1 = y1 | (u1 << 10) | (y2 << 20);
428 a2 = v1 | (y3 << 10) | (u2 << 20);
429 a3 = y4 | (v2 << 10) | (y5 << 20);
431 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 0, a0);
432 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 4, a1);
433 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 8, a2);
434 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 12, a3);
437 y0 = s[4 * (i + 0) + 1] >> 6;
438 u0 = s[4 * (i + 0) + 2] >> 6;
439 v0 = s[4 * (i + 0) + 3] >> 6;
441 y1 = s[4 * (i + 1) + 1] >> 6;
445 y2 = s[4 * (i + 2) + 1] >> 6;
446 u1 = s[4 * (i + 2) + 2] >> 6;
447 v1 = s[4 * (i + 2) + 3] >> 6;
454 y3 = s[4 * (i + 3) + 1] >> 6;
458 y4 = s[4 * (i + 4) + 1] >> 6;
459 u2 = s[4 * (i + 4) + 2] >> 6;
460 v2 = s[4 * (i + 4) + 3] >> 6;
468 a0 = u0 | (y0 << 10) | (v0 << 20);
469 a1 = y1 | (u1 << 10) | (y2 << 20);
470 a2 = v1 | (y3 << 10) | (u2 << 20);
471 a3 = y4 | (v2 << 10) | (y5 << 20);
473 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 0, a0);
474 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 4, a1);
475 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 8, a2);
476 GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 12, a3);
480 #define PACK_v216 GST_VIDEO_FORMAT_AYUV64, unpack_v216, 1, pack_v216
482 unpack_v216 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
483 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
484 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
487 const guint8 *s = GET_LINE (y);
490 for (i = 0; i < width; i++) {
491 d[i * 4 + 0] = 0xffff;
492 d[i * 4 + 1] = GST_READ_UINT16_LE (s + i * 4 + 2);
493 d[i * 4 + 2] = GST_READ_UINT16_LE (s + (i >> 1) * 8 + 0);
494 d[i * 4 + 3] = GST_READ_UINT16_LE (s + (i >> 1) * 8 + 4);
499 pack_v216 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
500 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
501 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
505 guint8 *d = GET_LINE (y);
506 const guint16 *s = src;
508 for (i = 0; i < width - 1; i += 2) {
509 GST_WRITE_UINT16_LE (d + i * 4 + 0, s[(i + 0) * 4 + 2]);
510 GST_WRITE_UINT16_LE (d + i * 4 + 2, s[(i + 0) * 4 + 1]);
511 GST_WRITE_UINT16_LE (d + i * 4 + 4, s[(i + 0) * 4 + 3]);
512 GST_WRITE_UINT16_LE (d + i * 4 + 6, s[(i + 1) * 4 + 1]);
514 if (i == width - 1) {
515 GST_WRITE_UINT16_LE (d + i * 4 + 0, s[i * 4 + 2]);
516 GST_WRITE_UINT16_LE (d + i * 4 + 2, s[i * 4 + 1]);
517 GST_WRITE_UINT16_LE (d + i * 4 + 4, s[i * 4 + 3]);
518 GST_WRITE_UINT16_LE (d + i * 4 + 6, s[i * 4 + 1]);
522 #define PACK_Y41B GST_VIDEO_FORMAT_AYUV, unpack_Y41B, 1, pack_Y41B
524 unpack_Y41B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
525 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
526 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
528 guint8 *y_line = GET_Y_LINE (y);
529 guint8 *u_line = GET_U_LINE (y);
530 guint8 *v_line = GET_V_LINE (y);
533 g_return_if_fail (IS_ALIGNED (dest, 8));
535 video_orc_unpack_YUV9 (dest, y_line, u_line, v_line, width / 2);
541 d[i * 4 + 1] = y_line[i];
542 d[i * 4 + 2] = u_line[i >> 2];
543 d[i * 4 + 3] = v_line[i >> 2];
548 pack_Y41B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
549 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
550 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
554 guint8 *destY = GET_Y_LINE (y);
555 guint8 *destU = GET_U_LINE (y);
556 guint8 *destV = GET_V_LINE (y);
557 const guint8 *s = src;
559 for (i = 0; i < width - 3; i += 4) {
560 destY[i] = s[i * 4 + 1];
561 destY[i + 1] = s[i * 4 + 5];
562 destY[i + 2] = s[i * 4 + 9];
563 destY[i + 3] = s[i * 4 + 13];
565 destU[i >> 2] = s[i * 4 + 2];
566 destV[i >> 2] = s[i * 4 + 3];
569 destY[i] = s[i * 4 + 1];
570 destU[i >> 2] = s[i * 4 + 2];
571 destV[i >> 2] = s[i * 4 + 3];
573 destY[i + 1] = s[i * 4 + 5];
575 destY[i + 2] = s[i * 4 + 9];
579 #define PACK_Y42B GST_VIDEO_FORMAT_AYUV, unpack_Y42B, 1, pack_Y42B
581 unpack_Y42B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
582 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
583 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
585 guint8 *y_line = GET_Y_LINE (y);
586 guint8 *u_line = GET_U_LINE (y);
587 guint8 *v_line = GET_V_LINE (y);
590 g_return_if_fail (IS_ALIGNED (dest, 8));
592 video_orc_unpack_Y42B (dest, y_line, u_line, v_line, width / 2);
598 d[i * 4 + 1] = y_line[i];
599 d[i * 4 + 2] = u_line[i >> 1];
600 d[i * 4 + 3] = v_line[i >> 1];
605 pack_Y42B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
606 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
607 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
610 guint8 *y_line = GET_Y_LINE (y);
611 guint8 *u_line = GET_U_LINE (y);
612 guint8 *v_line = GET_V_LINE (y);
613 const guint8 *ayuv = src;
615 g_return_if_fail (IS_ALIGNED (src, 8));
617 video_orc_pack_Y42B (y_line, u_line, v_line, src, width / 2);
622 y_line[i] = ayuv[i * 4 + 1];
623 u_line[i >> 1] = ayuv[i * 4 + 2];
624 v_line[i >> 1] = ayuv[i * 4 + 3];
628 #define PACK_Y444 GST_VIDEO_FORMAT_AYUV, unpack_Y444, 1, pack_Y444
630 unpack_Y444 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
631 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
632 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
634 video_orc_unpack_Y444 (dest, GET_Y_LINE (y), GET_U_LINE (y),
635 GET_V_LINE (y), width);
639 pack_Y444 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
640 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
641 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
644 video_orc_pack_Y444 (GET_Y_LINE (y), GET_U_LINE (y), GET_V_LINE (y), src,
648 #define PACK_GBR GST_VIDEO_FORMAT_ARGB, unpack_GBR, 1, pack_GBR
650 unpack_GBR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
651 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
652 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
654 video_orc_unpack_Y444 (dest, GET_R_LINE (y), GET_G_LINE (y),
655 GET_B_LINE (y), width);
659 pack_GBR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
660 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
661 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
664 video_orc_pack_Y444 (GET_R_LINE (y), GET_G_LINE (y), GET_B_LINE (y), src,
668 #define PACK_GRAY8 GST_VIDEO_FORMAT_AYUV, unpack_GRAY8, 1, pack_GRAY8
670 unpack_GRAY8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
671 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
672 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
674 video_orc_unpack_GRAY8 (dest, GET_LINE (y), width);
678 pack_GRAY8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
679 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
680 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
683 video_orc_pack_GRAY8 (GET_LINE (y), src, width);
686 #define PACK_GRAY16_BE GST_VIDEO_FORMAT_AYUV64, unpack_GRAY16_BE, 1, pack_GRAY16_BE
688 unpack_GRAY16_BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
689 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
690 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
693 const guint16 *s = GET_LINE (y);
696 for (i = 0; i < width; i++) {
697 d[i * 4 + 0] = 0xffff;
698 d[i * 4 + 1] = GST_READ_UINT16_BE (s + i);
699 d[i * 4 + 2] = 0x8000;
700 d[i * 4 + 3] = 0x8000;
705 pack_GRAY16_BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
706 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
707 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
711 guint16 *d = GET_LINE (y);
712 const guint16 *s = src;
714 for (i = 0; i < width; i++) {
715 GST_WRITE_UINT16_BE (d + i, s[i * 4 + 1]);
719 #define PACK_GRAY16_LE GST_VIDEO_FORMAT_AYUV64, unpack_GRAY16_LE, 1, pack_GRAY16_LE
721 unpack_GRAY16_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
722 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
723 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
726 const guint16 *s = GET_LINE (y);
729 for (i = 0; i < width; i++) {
730 d[i * 4 + 0] = 0xffff;
731 d[i * 4 + 1] = GST_READ_UINT16_LE (s + i);
732 d[i * 4 + 2] = 0x8000;
733 d[i * 4 + 3] = 0x8000;
738 pack_GRAY16_LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
739 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
740 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
744 guint16 *d = GET_LINE (y);
745 const guint16 *s = src;
747 for (i = 0; i < width; i++) {
748 GST_WRITE_UINT16_LE (d + i, s[i * 4 + 1]);
752 #define PACK_RGB16 GST_VIDEO_FORMAT_ARGB, unpack_RGB16, 1, pack_RGB16
754 unpack_RGB16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
755 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
756 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
759 const guint16 *s = GET_LINE (y);
760 guint8 *d = dest, r, g, b;
762 for (i = 0; i < width; i++) {
763 r = ((s[i] >> 11) & 0x1f) << 3;
764 g = ((s[i] >> 5) & 0x3f) << 2;
765 b = ((s[i]) & 0x1f) << 3;
767 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
781 pack_RGB16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
782 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
783 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
787 guint16 *d = GET_LINE (y);
788 const guint8 *s = src;
790 for (i = 0; i < width; i++) {
791 d[i] = ((s[i * 4 + 1] >> 3) << 11) |
792 ((s[i * 4 + 2] >> 2) << 5) | (s[i * 4 + 3] >> 3);
796 #define PACK_BGR16 GST_VIDEO_FORMAT_ARGB, unpack_BGR16, 1, pack_BGR16
798 unpack_BGR16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
799 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
800 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
803 const guint16 *s = GET_LINE (y);
804 guint8 *d = dest, r, g, b;
806 for (i = 0; i < width; i++) {
807 b = ((s[i] >> 11) & 0x1f) << 3;
808 g = ((s[i] >> 5) & 0x3f) << 2;
809 r = ((s[i]) & 0x1f) << 3;
811 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
825 pack_BGR16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
826 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
827 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
831 guint16 *d = GET_LINE (y);
832 const guint8 *s = src;
834 for (i = 0; i < width; i++) {
835 d[i] = ((s[i * 4 + 3] >> 3) << 11) |
836 ((s[i * 4 + 2] >> 2) << 5) | (s[i * 4 + 1] >> 3);
840 #define PACK_RGB15 GST_VIDEO_FORMAT_ARGB, unpack_RGB15, 1, pack_RGB15
842 unpack_RGB15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
843 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
844 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
847 const guint16 *s = GET_LINE (y);
848 guint8 *d = dest, r, g, b;
850 for (i = 0; i < width; i++) {
851 r = ((s[i] >> 10) & 0x1f) << 3;
852 g = ((s[i] >> 5) & 0x1f) << 3;
853 b = ((s[i]) & 0x1f) << 3;
855 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
869 pack_RGB15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
870 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
871 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
875 guint16 *d = GET_LINE (y);
876 const guint8 *s = src;
878 for (i = 0; i < width; i++) {
879 d[i] = ((s[i * 4 + 1] >> 3) << 10) |
880 ((s[i * 4 + 2] >> 3) << 5) | (s[i * 4 + 3] >> 3);
884 #define PACK_BGR15 GST_VIDEO_FORMAT_ARGB, unpack_BGR15, 1, pack_BGR15
886 unpack_BGR15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
887 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
888 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
891 const guint16 *s = GET_LINE (y);
892 guint8 *d = dest, r, g, b;
894 for (i = 0; i < width; i++) {
895 b = ((s[i] >> 10) & 0x1f) << 3;
896 g = ((s[i] >> 5) & 0x1f) << 3;
897 r = ((s[i]) & 0x1f) << 3;
899 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
913 pack_BGR15 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
914 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
915 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
919 guint16 *d = GET_LINE (y);
920 const guint8 *s = src;
922 for (i = 0; i < width; i++) {
923 d[i] = ((s[i * 4 + 3] >> 3) << 10) |
924 ((s[i * 4 + 2] >> 3) << 5) | (s[i * 4 + 1] >> 3);
928 #define PACK_BGRA GST_VIDEO_FORMAT_ARGB, unpack_BGRA, 1, pack_BGRA
930 unpack_BGRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
931 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
932 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
934 video_orc_unpack_BGRA (dest, GET_LINE (y), width);
938 pack_BGRA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
939 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
940 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
943 video_orc_pack_BGRA (GET_LINE (y), src, width);
946 #define PACK_ABGR GST_VIDEO_FORMAT_ARGB, unpack_ABGR, 1, pack_ABGR
948 unpack_ABGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
949 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
950 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
952 video_orc_unpack_ABGR (dest, GET_LINE (y), width);
956 pack_ABGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
957 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
958 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
961 video_orc_pack_ABGR (GET_LINE (y), src, width);
964 #define PACK_RGBA GST_VIDEO_FORMAT_ARGB, unpack_RGBA, 1, pack_RGBA
966 unpack_RGBA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
967 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
968 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
970 video_orc_unpack_RGBA (dest, GET_LINE (y), width);
974 pack_RGBA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
975 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
976 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
979 video_orc_pack_RGBA (GET_LINE (y), src, width);
982 #define PACK_RGB GST_VIDEO_FORMAT_ARGB, unpack_RGB, 1, pack_RGB
984 unpack_RGB (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
985 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
986 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
989 const guint8 *s = GET_LINE (y);
992 for (i = 0; i < width; i++) {
994 d[i * 4 + 1] = s[i * 3 + 0];
995 d[i * 4 + 2] = s[i * 3 + 1];
996 d[i * 4 + 3] = s[i * 3 + 2];
1001 pack_RGB (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1002 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1003 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1007 guint8 *d = GET_LINE (y);
1008 const guint8 *s = src;
1010 for (i = 0; i < width; i++) {
1011 d[i * 3 + 0] = s[i * 4 + 1];
1012 d[i * 3 + 1] = s[i * 4 + 2];
1013 d[i * 3 + 2] = s[i * 4 + 3];
1017 #define PACK_BGR GST_VIDEO_FORMAT_ARGB, unpack_BGR, 1, pack_BGR
1019 unpack_BGR (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)
1024 const guint8 *s = GET_LINE (y);
1027 for (i = 0; i < width; i++) {
1028 d[i * 4 + 0] = 0xff;
1029 d[i * 4 + 1] = s[i * 3 + 2];
1030 d[i * 4 + 2] = s[i * 3 + 1];
1031 d[i * 4 + 3] = s[i * 3 + 0];
1036 pack_BGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1037 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1038 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1042 guint8 *d = GET_LINE (y);
1043 const guint8 *s = src;
1045 for (i = 0; i < width; i++) {
1046 d[i * 3 + 0] = s[i * 4 + 3];
1047 d[i * 3 + 1] = s[i * 4 + 2];
1048 d[i * 3 + 2] = s[i * 4 + 1];
1052 #define PACK_NV12 GST_VIDEO_FORMAT_AYUV, unpack_NV12, 1, pack_NV12
1054 unpack_NV12 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1055 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1056 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1058 gint uv = GET_UV_420 (y, flags);
1059 guint8 *y_line = GET_PLANE_LINE (0, y);
1060 guint8 *uv_line = GET_PLANE_LINE (1, uv);
1063 g_return_if_fail (IS_ALIGNED (dest, 8));
1065 video_orc_unpack_NV12 (dest, y_line, uv_line, width / 2);
1070 d[i * 4 + 0] = 0xff;
1071 d[i * 4 + 1] = y_line[i];
1072 d[i * 4 + 2] = uv_line[i + 0];
1073 d[i * 4 + 3] = uv_line[i + 1];
1078 pack_NV12 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1079 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1080 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1083 gint uv = GET_UV_420 (y, flags);
1084 guint8 *y_line = GET_PLANE_LINE (0, y);
1085 guint8 *uv_line = GET_PLANE_LINE (1, uv);
1086 const guint8 *ayuv = src;
1088 g_return_if_fail (IS_ALIGNED (src, 8));
1090 video_orc_pack_NV12 (y_line, uv_line, src, width / 2);
1095 y_line[i] = ayuv[i * 4 + 1];
1096 uv_line[i + 0] = ayuv[i * 4 + 2];
1097 uv_line[i + 1] = ayuv[i * 4 + 3];
1101 #define PACK_NV21 GST_VIDEO_FORMAT_AYUV, unpack_NV21, 1, pack_NV21
1103 unpack_NV21 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1104 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1105 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1107 gint uv = GET_UV_420 (y, flags);
1108 guint8 *y_line = GET_PLANE_LINE (0, y);
1109 guint8 *uv_line = GET_PLANE_LINE (1, uv);
1112 g_return_if_fail (IS_ALIGNED (dest, 8));
1114 video_orc_unpack_NV21 (dest, y_line, uv_line, width / 2);
1119 d[i * 4 + 0] = 0xff;
1120 d[i * 4 + 1] = y_line[i];
1121 d[i * 4 + 2] = uv_line[i + 1];
1122 d[i * 4 + 3] = uv_line[i + 0];
1127 pack_NV21 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1128 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1129 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1132 gint uv = GET_UV_420 (y, flags);
1133 guint8 *y_line = GET_PLANE_LINE (0, y);
1134 guint8 *uv_line = GET_PLANE_LINE (1, uv);
1135 const guint8 *ayuv = src;
1137 g_return_if_fail (IS_ALIGNED (src, 8));
1139 video_orc_pack_NV21 (y_line, uv_line, src, width / 2);
1144 y_line[i] = ayuv[i * 4 + 1];
1145 uv_line[i + 0] = ayuv[i * 4 + 3];
1146 uv_line[i + 1] = ayuv[i * 4 + 2];
1150 #define PACK_NV16 GST_VIDEO_FORMAT_AYUV, unpack_NV16, 1, pack_NV16
1152 unpack_NV16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1153 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1154 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1156 guint8 *y_line = GET_PLANE_LINE (0, y);
1157 guint8 *uv_line = GET_PLANE_LINE (1, y);
1160 g_return_if_fail (IS_ALIGNED (dest, 8));
1162 video_orc_unpack_NV12 (dest, y_line, uv_line, width / 2);
1167 d[i * 4 + 0] = 0xff;
1168 d[i * 4 + 1] = y_line[i];
1169 d[i * 4 + 2] = uv_line[i + 0];
1170 d[i * 4 + 3] = uv_line[i + 1];
1175 pack_NV16 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1176 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1177 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1180 guint8 *y_line = GET_PLANE_LINE (0, y);
1181 guint8 *uv_line = GET_PLANE_LINE (1, y);
1182 const guint8 *ayuv = src;
1184 g_return_if_fail (IS_ALIGNED (src, 8));
1186 video_orc_pack_NV12 (y_line, uv_line, src, width / 2);
1191 y_line[i] = ayuv[i * 4 + 1];
1192 uv_line[i + 0] = ayuv[i * 4 + 2];
1193 uv_line[i + 1] = ayuv[i * 4 + 3];
1197 #define PACK_NV24 GST_VIDEO_FORMAT_AYUV, unpack_NV24, 1, pack_NV24
1199 unpack_NV24 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1200 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1201 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1203 video_orc_unpack_NV24 (dest,
1204 GET_PLANE_LINE (0, y), GET_PLANE_LINE (1, y), width);
1208 pack_NV24 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1209 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1210 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1213 video_orc_pack_NV24 (GET_PLANE_LINE (0, y),
1214 GET_PLANE_LINE (1, y), src, width);
1217 #define PACK_UYVP GST_VIDEO_FORMAT_AYUV64, unpack_UYVP, 1, pack_UYVP
1219 unpack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1220 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1221 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1224 const guint8 *s = GET_LINE (y);
1227 for (i = 0; i < width; i += 2) {
1232 u0 = ((s[(i / 2) * 5 + 0] << 2) | (s[(i / 2) * 5 + 1] >> 6)) << 6;
1233 y0 = (((s[(i / 2) * 5 + 1] & 0x3f) << 4) | (s[(i / 2) * 5 + 2] >> 4)) << 6;
1234 v0 = (((s[(i / 2) * 5 + 2] & 0x0f) << 6) | (s[(i / 2) * 5 + 3] >> 2)) << 6;
1235 y1 = (((s[(i / 2) * 5 + 3] & 0x03) << 8) | s[(i / 2) * 5 + 4]) << 6;
1237 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
1244 d[i * 4 + 0] = 0xffff;
1249 if (i < width - 1) {
1250 d[i * 4 + 4] = 0xffff;
1259 pack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1260 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1261 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1265 guint8 *d = GET_LINE (y);
1266 const guint16 *s = src;
1268 for (i = 0; i < width; i += 2) {
1273 y0 = s[4 * (i + 0) + 1];
1275 y1 = s[4 * (i + 1) + 1];
1279 u0 = s[4 * (i + 0) + 2];
1280 v0 = s[4 * (i + 0) + 3];
1282 d[(i / 2) * 5 + 0] = u0 >> 8;
1283 d[(i / 2) * 5 + 1] = (u0 & 0xc0) | y0 >> 10;
1284 d[(i / 2) * 5 + 2] = ((y0 & 0x3c0) >> 2) | (v0 >> 12);
1285 d[(i / 2) * 5 + 3] = ((v0 & 0xfc0) >> 4) | (y1 >> 14);
1286 d[(i / 2) * 5 + 4] = (y1 >> 6);
1290 #define PACK_A420 GST_VIDEO_FORMAT_AYUV, unpack_A420, 1, pack_A420
1292 unpack_A420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1293 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1294 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1296 gint uv = GET_UV_420 (y, flags);
1298 video_orc_unpack_A420 (dest, GET_Y_LINE (y), GET_U_LINE (uv),
1299 GET_V_LINE (uv), GET_A_LINE (y), width);
1303 pack_A420 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1304 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1305 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1308 gint uv = GET_UV_420 (y, flags);
1309 guint8 *y_line = GET_Y_LINE (y);
1310 guint8 *u_line = GET_U_LINE (uv);
1311 guint8 *v_line = GET_V_LINE (uv);
1312 guint8 *a_line = GET_A_LINE (y);
1313 const guint8 *ayuv = src;
1315 g_return_if_fail (IS_ALIGNED (src, 8));
1317 video_orc_pack_A420 (y_line, u_line, v_line, a_line, src, width / 2);
1322 a_line[i] = ayuv[i * 4 + 0];
1323 y_line[i] = ayuv[i * 4 + 1];
1324 u_line[i >> 1] = ayuv[i * 4 + 2];
1325 v_line[i >> 1] = ayuv[i * 4 + 3];
1329 #define PACK_RGB8P GST_VIDEO_FORMAT_ARGB, unpack_RGB8P, 1, pack_RGB8P
1331 unpack_RGB8P (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1332 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1333 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1336 const guint8 *s = GET_LINE (y);
1337 const guint32 *p = data[1];
1340 for (i = 0; i < width; i++) {
1341 guint32 v = p[s[i]];
1342 d[i * 4 + 0] = (v >> 24) & 0xff;
1343 d[i * 4 + 1] = (v >> 16) & 0xff;
1344 d[i * 4 + 2] = (v >> 8) & 0xff;
1345 d[i * 4 + 3] = (v) & 0xff;
1349 static const guint32 std_palette_RGB8P[] = {
1350 0xff000000, 0xff000033, 0xff000066, 0xff000099, 0xff0000cc, 0xff0000ff,
1351 0xff003300, 0xff003333, 0xff003366, 0xff003399, 0xff0033cc, 0xff0033ff,
1352 0xff006600, 0xff006633, 0xff006666, 0xff006699, 0xff0066cc, 0xff0066ff,
1353 0xff009900, 0xff009933, 0xff009966, 0xff009999, 0xff0099cc, 0xff0099ff,
1354 0xff00cc00, 0xff00cc33, 0xff00cc66, 0xff00cc99, 0xff00cccc, 0xff00ccff,
1355 0xff00ff00, 0xff00ff33, 0xff00ff66, 0xff00ff99, 0xff00ffcc, 0xff00ffff,
1356 0xff330000, 0xff330033, 0xff330066, 0xff330099, 0xff3300cc, 0xff3300ff,
1357 0xff333300, 0xff333333, 0xff333366, 0xff333399, 0xff3333cc, 0xff3333ff,
1358 0xff336600, 0xff336633, 0xff336666, 0xff336699, 0xff3366cc, 0xff3366ff,
1359 0xff339900, 0xff339933, 0xff339966, 0xff339999, 0xff3399cc, 0xff3399ff,
1360 0xff33cc00, 0xff33cc33, 0xff33cc66, 0xff33cc99, 0xff33cccc, 0xff33ccff,
1361 0xff33ff00, 0xff33ff33, 0xff33ff66, 0xff33ff99, 0xff33ffcc, 0xff33ffff,
1362 0xff660000, 0xff660033, 0xff660066, 0xff660099, 0xff6600cc, 0xff6600ff,
1363 0xff663300, 0xff663333, 0xff663366, 0xff663399, 0xff6633cc, 0xff6633ff,
1364 0xff666600, 0xff666633, 0xff666666, 0xff666699, 0xff6666cc, 0xff6666ff,
1365 0xff669900, 0xff669933, 0xff669966, 0xff669999, 0xff6699cc, 0xff6699ff,
1366 0xff66cc00, 0xff66cc33, 0xff66cc66, 0xff66cc99, 0xff66cccc, 0xff66ccff,
1367 0xff66ff00, 0xff66ff33, 0xff66ff66, 0xff66ff99, 0xff66ffcc, 0xff66ffff,
1368 0xff990000, 0xff990033, 0xff990066, 0xff990099, 0xff9900cc, 0xff9900ff,
1369 0xff993300, 0xff993333, 0xff993366, 0xff993399, 0xff9933cc, 0xff9933ff,
1370 0xff996600, 0xff996633, 0xff996666, 0xff996699, 0xff9966cc, 0xff9966ff,
1371 0xff999900, 0xff999933, 0xff999966, 0xff999999, 0xff9999cc, 0xff9999ff,
1372 0xff99cc00, 0xff99cc33, 0xff99cc66, 0xff99cc99, 0xff99cccc, 0xff99ccff,
1373 0xff99ff00, 0xff99ff33, 0xff99ff66, 0xff99ff99, 0xff99ffcc, 0xff99ffff,
1374 0xffcc0000, 0xffcc0033, 0xffcc0066, 0xffcc0099, 0xffcc00cc, 0xffcc00ff,
1375 0xffcc3300, 0xffcc3333, 0xffcc3366, 0xffcc3399, 0xffcc33cc, 0xffcc33ff,
1376 0xffcc6600, 0xffcc6633, 0xffcc6666, 0xffcc6699, 0xffcc66cc, 0xffcc66ff,
1377 0xffcc9900, 0xffcc9933, 0xffcc9966, 0xffcc9999, 0xffcc99cc, 0xffcc99ff,
1378 0xffcccc00, 0xffcccc33, 0xffcccc66, 0xffcccc99, 0xffcccccc, 0xffccccff,
1379 0xffccff00, 0xffccff33, 0xffccff66, 0xffccff99, 0xffccffcc, 0xffccffff,
1380 0xffff0000, 0xffff0033, 0xffff0066, 0xffff0099, 0xffff00cc, 0xffff00ff,
1381 0xffff3300, 0xffff3333, 0xffff3366, 0xffff3399, 0xffff33cc, 0xffff33ff,
1382 0xffff6600, 0xffff6633, 0xffff6666, 0xffff6699, 0xffff66cc, 0xffff66ff,
1383 0xffff9900, 0xffff9933, 0xffff9966, 0xffff9999, 0xffff99cc, 0xffff99ff,
1384 0xffffcc00, 0xffffcc33, 0xffffcc66, 0xffffcc99, 0xffffcccc, 0xffffccff,
1385 0xffffff00, 0xffffff33, 0xffffff66, 0xffffff99, 0xffffffcc, 0xffffffff,
1386 0x00000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1387 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1388 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1389 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1390 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1391 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
1392 0xff000000, 0xff000000, 0xff000000, 0xff000000
1396 pack_RGB8P (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1397 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1398 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1402 guint8 *d = GET_LINE (y);
1403 const guint8 *s = src;
1405 /* Use our poor man's palette, taken from ffmpegcolorspace too */
1406 for (i = 0; i < width; i++) {
1407 /* crude approximation for alpha ! */
1408 if (s[i * 4 + 0] < 0x80)
1412 ((((s[i * 4 + 1]) / 47) % 6) * 6 * 6 + (((s[i * 4 +
1413 2]) / 47) % 6) * 6 + (((s[i * 4 + 3]) / 47) % 6));
1417 #define PACK_410 GST_VIDEO_FORMAT_AYUV, unpack_410, 1, pack_410
1419 unpack_410 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1420 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1421 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1423 gint uv = GET_UV_410 (y, flags);
1424 guint8 *y_line = GET_Y_LINE (y);
1425 guint8 *u_line = GET_U_LINE (uv);
1426 guint8 *v_line = GET_V_LINE (uv);
1429 g_return_if_fail (IS_ALIGNED (dest, 8));
1431 video_orc_unpack_YUV9 (dest, y_line, u_line, v_line, width / 2);
1436 d[i * 4 + 0] = 0xff;
1437 d[i * 4 + 1] = y_line[i];
1438 d[i * 4 + 2] = u_line[i >> 2];
1439 d[i * 4 + 3] = v_line[i >> 2];
1444 pack_410 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1445 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1446 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1450 gint uv = GET_UV_410 (y, flags);
1451 guint8 *destY = GET_Y_LINE (y);
1452 guint8 *destU = GET_U_LINE (uv);
1453 guint8 *destV = GET_V_LINE (uv);
1454 const guint8 *s = src;
1456 for (i = 0; i < width - 3; i += 4) {
1457 destY[i] = s[i * 4 + 1];
1458 destY[i + 1] = s[i * 4 + 5];
1459 destY[i + 2] = s[i * 4 + 9];
1460 destY[i + 3] = s[i * 4 + 13];
1462 destU[i >> 2] = s[i * 4 + 2];
1463 destV[i >> 2] = s[i * 4 + 3];
1467 destY[i] = s[i * 4 + 1];
1469 destU[i >> 2] = s[i * 4 + 2];
1470 destV[i >> 2] = s[i * 4 + 3];
1473 destY[i + 1] = s[i * 4 + 5];
1475 destY[i + 2] = s[i * 4 + 9];
1479 #define PACK_IYU1 GST_VIDEO_FORMAT_AYUV, unpack_IYU1, 1, pack_IYU1
1481 unpack_IYU1 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1482 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1483 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1486 const guint8 *s = GET_LINE (y);
1488 guint8 y0, y1, y2, y3;
1492 for (i = 0; i < width - 3; i += 4) {
1493 y0 = s[(i >> 2) * 6 + 1];
1494 y1 = s[(i >> 2) * 6 + 2];
1495 y2 = s[(i >> 2) * 6 + 4];
1496 y3 = s[(i >> 2) * 6 + 5];
1498 u0 = s[(i >> 2) * 6 + 0];
1499 v0 = s[(i >> 2) * 6 + 3];
1501 d[i * 4 + 0] = 0xff;
1506 d[i * 4 + 4] = 0xff;
1511 d[i * 4 + 8] = 0xff;
1516 d[i * 4 + 12] = 0xff;
1522 u0 = s[(i >> 2) * 6 + 0];
1523 v0 = s[(i >> 2) * 6 + 3];
1525 d[i * 4 + 0] = 0xff;
1526 d[i * 4 + 1] = s[(i >> 2) * 6 + 1];
1530 if (i < width - 1) {
1531 d[i * 4 + 4] = 0xff;
1532 d[i * 4 + 5] = s[(i >> 2) * 6 + 2];
1536 if (i < width - 2) {
1537 d[i * 4 + 8] = 0xff;
1538 d[i * 4 + 9] = s[(i >> 2) * 6 + 4];
1546 pack_IYU1 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1547 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1548 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1552 guint8 *d = GET_LINE (y);
1553 const guint8 *s = src;
1555 for (i = 0; i < width - 3; i += 4) {
1556 d[(i >> 2) * 6 + 0] = s[i * 4 + 2];
1557 d[(i >> 2) * 6 + 1] = s[i * 4 + 1];
1558 d[(i >> 2) * 6 + 2] = s[i * 4 + 5];
1559 d[(i >> 2) * 6 + 3] = s[i * 4 + 3];
1560 d[(i >> 2) * 6 + 4] = s[i * 4 + 9];
1561 d[(i >> 2) * 6 + 5] = s[i * 4 + 13];
1564 d[(i >> 2) * 6 + 1] = s[i * 4 + 1];
1565 d[(i >> 2) * 6 + 0] = s[i * 4 + 2];
1566 d[(i >> 2) * 6 + 3] = s[i * 4 + 3];
1568 d[(i >> 2) * 6 + 2] = s[i * 4 + 5];
1570 d[(i >> 2) * 6 + 4] = s[i * 4 + 9];
1574 #define PACK_ARGB64 GST_VIDEO_FORMAT_ARGB64, unpack_copy8, 1, pack_copy8
1575 #define PACK_AYUV64 GST_VIDEO_FORMAT_AYUV64, unpack_copy8, 1, pack_copy8
1577 unpack_copy8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1578 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1579 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1581 memcpy (dest, GET_LINE (y), width * 8);
1585 pack_copy8 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1586 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1587 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1590 memcpy (GET_LINE (y), src, width * 8);
1593 #define PACK_r210 GST_VIDEO_FORMAT_ARGB64, unpack_r210, 1, pack_r210
1595 unpack_r210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1596 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1597 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1600 const guint8 *s = GET_LINE (y);
1601 guint16 *d = dest, R, G, B;
1603 for (i = 0; i < width; i++) {
1604 guint32 x = GST_READ_UINT32_BE (s + i * 4);
1606 R = ((x >> 14) & 0xffc0);
1607 G = ((x >> 4) & 0xffc0);
1608 B = ((x << 6) & 0xffc0);
1610 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
1616 d[i * 4 + 0] = 0xffff;
1624 pack_r210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1625 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1626 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1630 guint8 *d = GET_LINE (y);
1631 const guint16 *s = src;
1633 for (i = 0; i < width; i++) {
1635 x |= (s[i * 4 + 1] & 0xffc0) << 14;
1636 x |= (s[i * 4 + 2] & 0xffc0) << 4;
1637 x |= (s[i * 4 + 3] & 0xffc0) >> 6;
1638 GST_WRITE_UINT32_BE (d + i * 4, x);
1642 #define PACK_GBR_10LE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_10LE, 1, pack_GBR_10LE
1644 unpack_GBR_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1645 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1646 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1649 guint16 *srcG = GET_G_LINE (y);
1650 guint16 *srcB = GET_B_LINE (y);
1651 guint16 *srcR = GET_R_LINE (y);
1652 guint16 *d = dest, G, B, R;
1654 for (i = 0; i < width; i++) {
1655 G = GST_READ_UINT16_LE (srcG + i) << 6;
1656 B = GST_READ_UINT16_LE (srcB + i) << 6;
1657 R = GST_READ_UINT16_LE (srcR + i) << 6;
1659 d[i * 4 + 0] = 0xffff;
1667 pack_GBR_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1668 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1669 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1673 guint16 *destG = GET_G_LINE (y);
1674 guint16 *destB = GET_B_LINE (y);
1675 guint16 *destR = GET_R_LINE (y);
1677 const guint16 *s = src;
1679 for (i = 0; i < width; i++) {
1680 G = (s[i * 4 + 2]) >> 6;
1681 B = (s[i * 4 + 3]) >> 6;
1682 R = (s[i * 4 + 1]) >> 6;
1684 GST_WRITE_UINT16_LE (destG + i, G);
1685 GST_WRITE_UINT16_LE (destB + i, B);
1686 GST_WRITE_UINT16_LE (destR + i, R);
1690 #define PACK_GBR_10BE GST_VIDEO_FORMAT_ARGB64, unpack_GBR_10BE, 1, pack_GBR_10BE
1692 unpack_GBR_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1693 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1694 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1697 guint16 *srcG = GET_G_LINE (y);
1698 guint16 *srcB = GET_B_LINE (y);
1699 guint16 *srcR = GET_R_LINE (y);
1700 guint16 *d = dest, G, B, R;
1702 for (i = 0; i < width; i++) {
1703 G = GST_READ_UINT16_BE (srcG + i) << 6;
1704 B = GST_READ_UINT16_BE (srcB + i) << 6;
1705 R = GST_READ_UINT16_BE (srcR + i) << 6;
1707 d[i * 4 + 0] = 0xffff;
1715 pack_GBR_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1716 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1717 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1721 guint16 *destG = GET_G_LINE (y);
1722 guint16 *destB = GET_B_LINE (y);
1723 guint16 *destR = GET_R_LINE (y);
1725 const guint16 *s = src;
1727 for (i = 0; i < width; i++) {
1728 G = s[i * 4 + 2] >> 6;
1729 B = s[i * 4 + 3] >> 6;
1730 R = s[i * 4 + 1] >> 6;
1732 GST_WRITE_UINT16_BE (destG + i, G);
1733 GST_WRITE_UINT16_BE (destB + i, B);
1734 GST_WRITE_UINT16_BE (destR + i, R);
1738 #define PACK_Y444_10LE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_10LE, 1, pack_Y444_10LE
1740 unpack_Y444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1741 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1742 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1745 guint16 *srcY = GET_Y_LINE (y);
1746 guint16 *srcU = GET_U_LINE (y);
1747 guint16 *srcV = GET_V_LINE (y);
1748 guint16 *d = dest, Y, U, V;
1750 for (i = 0; i < width; i++) {
1751 Y = GST_READ_UINT16_LE (srcY + i) << 6;
1752 U = GST_READ_UINT16_LE (srcU + i) << 6;
1753 V = GST_READ_UINT16_LE (srcV + i) << 6;
1755 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
1761 d[i * 4 + 0] = 0xffff;
1769 pack_Y444_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1770 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1771 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1775 guint16 *destY = GET_Y_LINE (y);
1776 guint16 *destU = GET_U_LINE (y);
1777 guint16 *destV = GET_V_LINE (y);
1779 const guint16 *s = src;
1781 for (i = 0; i < width; i++) {
1782 Y = (s[i * 4 + 1]) >> 6;
1783 U = (s[i * 4 + 2]) >> 6;
1784 V = (s[i * 4 + 3]) >> 6;
1786 GST_WRITE_UINT16_LE (destY + i, Y);
1787 GST_WRITE_UINT16_LE (destU + i, U);
1788 GST_WRITE_UINT16_LE (destV + i, V);
1792 #define PACK_Y444_10BE GST_VIDEO_FORMAT_AYUV64, unpack_Y444_10BE, 1, pack_Y444_10BE
1794 unpack_Y444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1795 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1796 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1799 guint16 *srcY = GET_Y_LINE (y);
1800 guint16 *srcU = GET_U_LINE (y);
1801 guint16 *srcV = GET_V_LINE (y);
1802 guint16 *d = dest, Y, U, V;
1804 for (i = 0; i < width; i++) {
1805 Y = GST_READ_UINT16_BE (srcY + i) << 6;
1806 U = GST_READ_UINT16_BE (srcU + i) << 6;
1807 V = GST_READ_UINT16_BE (srcV + i) << 6;
1809 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
1815 d[i * 4 + 0] = 0xffff;
1823 pack_Y444_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1824 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1825 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1829 guint16 *destY = GET_Y_LINE (y);
1830 guint16 *destU = GET_U_LINE (y);
1831 guint16 *destV = GET_V_LINE (y);
1833 const guint16 *s = src;
1835 for (i = 0; i < width; i++) {
1836 Y = s[i * 4 + 1] >> 6;
1837 U = s[i * 4 + 2] >> 6;
1838 V = s[i * 4 + 3] >> 6;
1840 GST_WRITE_UINT16_BE (destY + i, Y);
1841 GST_WRITE_UINT16_BE (destU + i, U);
1842 GST_WRITE_UINT16_BE (destV + i, V);
1846 #define PACK_I420_10LE GST_VIDEO_FORMAT_AYUV64, unpack_I420_10LE, 1, pack_I420_10LE
1848 unpack_I420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1849 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1850 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1853 gint uv = GET_UV_420 (y, flags);
1854 guint16 *srcY = GET_Y_LINE (y);
1855 guint16 *srcU = GET_U_LINE (uv);
1856 guint16 *srcV = GET_V_LINE (uv);
1857 guint16 *d = dest, Y, U, V;
1859 for (i = 0; i < width; i++) {
1860 Y = GST_READ_UINT16_LE (srcY + i) << 6;
1861 U = GST_READ_UINT16_LE (srcU + (i >> 1)) << 6;
1862 V = GST_READ_UINT16_LE (srcV + (i >> 1)) << 6;
1864 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
1870 d[i * 4 + 0] = 0xffff;
1878 pack_I420_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1879 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1880 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1884 gint uv = GET_UV_420 (y, flags);
1885 guint16 *destY = GET_Y_LINE (y);
1886 guint16 *destU = GET_U_LINE (uv);
1887 guint16 *destV = GET_V_LINE (uv);
1888 guint16 Y0, Y1, U, V;
1889 const guint16 *s = src;
1891 for (i = 0; i < width - 1; i += 2) {
1892 Y0 = s[i * 4 + 1] >> 6;
1893 Y1 = s[i * 4 + 5] >> 6;
1894 U = s[i * 4 + 2] >> 6;
1895 V = s[i * 4 + 3] >> 6;
1897 GST_WRITE_UINT16_LE (destY + i + 0, Y0);
1898 GST_WRITE_UINT16_LE (destY + i + 1, Y1);
1899 GST_WRITE_UINT16_LE (destU + (i >> 1), U);
1900 GST_WRITE_UINT16_LE (destV + (i >> 1), V);
1902 if (i == width - 1) {
1903 Y0 = s[i * 4 + 1] >> 6;
1904 U = s[i * 4 + 2] >> 6;
1905 V = s[i * 4 + 3] >> 6;
1907 GST_WRITE_UINT16_LE (destY + i, Y0);
1908 GST_WRITE_UINT16_LE (destU + (i >> 1), U);
1909 GST_WRITE_UINT16_LE (destV + (i >> 1), V);
1913 #define PACK_I420_10BE GST_VIDEO_FORMAT_AYUV64, unpack_I420_10BE, 1, pack_I420_10BE
1915 unpack_I420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1916 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1917 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1920 gint uv = GET_UV_420 (y, flags);
1921 guint16 *srcY = GET_Y_LINE (y);
1922 guint16 *srcU = GET_U_LINE (uv);
1923 guint16 *srcV = GET_V_LINE (uv);
1924 guint16 *d = dest, Y, U, V;
1926 for (i = 0; i < width; i++) {
1927 Y = GST_READ_UINT16_BE (srcY + i) << 6;
1928 U = GST_READ_UINT16_BE (srcU + (i >> 1)) << 6;
1929 V = GST_READ_UINT16_BE (srcV + (i >> 1)) << 6;
1931 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
1937 d[i * 4 + 0] = 0xffff;
1945 pack_I420_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1946 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
1947 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
1951 gint uv = GET_UV_420 (y, flags);
1952 guint16 *destY = GET_Y_LINE (y);
1953 guint16 *destU = GET_U_LINE (uv);
1954 guint16 *destV = GET_V_LINE (uv);
1955 guint16 Y0, Y1, U, V;
1956 const guint16 *s = src;
1958 for (i = 0; i < width - 1; i += 2) {
1959 Y0 = s[i * 4 + 1] >> 6;
1960 Y1 = s[i * 4 + 5] >> 6;
1961 U = s[i * 4 + 2] >> 6;
1962 V = s[i * 4 + 3] >> 6;
1964 GST_WRITE_UINT16_BE (destY + i + 0, Y0);
1965 GST_WRITE_UINT16_BE (destY + i + 1, Y1);
1966 GST_WRITE_UINT16_BE (destU + (i >> 1), U);
1967 GST_WRITE_UINT16_BE (destV + (i >> 1), V);
1969 if (i == width - 1) {
1970 Y0 = s[i * 4 + 1] >> 6;
1971 U = s[i * 4 + 2] >> 6;
1972 V = s[i * 4 + 3] >> 6;
1974 GST_WRITE_UINT16_BE (destY + i, Y0);
1975 GST_WRITE_UINT16_BE (destU + (i >> 1), U);
1976 GST_WRITE_UINT16_BE (destV + (i >> 1), V);
1980 #define PACK_I422_10LE GST_VIDEO_FORMAT_AYUV64, unpack_I422_10LE, 1, pack_I422_10LE
1982 unpack_I422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
1983 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
1984 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
1987 guint16 *srcY = GET_Y_LINE (y);
1988 guint16 *srcU = GET_U_LINE (y);
1989 guint16 *srcV = GET_V_LINE (y);
1990 guint16 *d = dest, Y, U, V;
1992 for (i = 0; i < width; i++) {
1993 Y = GST_READ_UINT16_LE (srcY + i) << 6;
1994 U = GST_READ_UINT16_LE (srcU + (i >> 1)) << 6;
1995 V = GST_READ_UINT16_LE (srcV + (i >> 1)) << 6;
1997 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2003 d[i * 4 + 0] = 0xffff;
2011 pack_I422_10LE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2012 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2013 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2017 guint16 *destY = GET_Y_LINE (y);
2018 guint16 *destU = GET_U_LINE (y);
2019 guint16 *destV = GET_V_LINE (y);
2020 guint16 Y0, Y1, U, V;
2021 const guint16 *s = src;
2023 for (i = 0; i < width - 1; i += 2) {
2024 Y0 = s[i * 4 + 1] >> 6;
2025 Y1 = s[i * 4 + 5] >> 6;
2026 U = s[i * 4 + 2] >> 6;
2027 V = s[i * 4 + 3] >> 6;
2029 GST_WRITE_UINT16_LE (destY + i + 0, Y0);
2030 GST_WRITE_UINT16_LE (destY + i + 1, Y1);
2031 GST_WRITE_UINT16_LE (destU + (i >> 1), U);
2032 GST_WRITE_UINT16_LE (destV + (i >> 1), V);
2034 if (i == width - 1) {
2035 Y0 = s[i * 4 + 1] >> 6;
2036 U = s[i * 4 + 2] >> 6;
2037 V = s[i * 4 + 3] >> 6;
2039 GST_WRITE_UINT16_LE (destY + i, Y0);
2040 GST_WRITE_UINT16_LE (destU + (i >> 1), U);
2041 GST_WRITE_UINT16_LE (destV + (i >> 1), V);
2045 #define PACK_I422_10BE GST_VIDEO_FORMAT_AYUV64, unpack_I422_10BE, 1, pack_I422_10BE
2047 unpack_I422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2048 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2049 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2052 guint16 *srcY = GET_Y_LINE (y);
2053 guint16 *srcU = GET_U_LINE (y);
2054 guint16 *srcV = GET_V_LINE (y);
2055 guint16 *d = dest, Y, U, V;
2057 for (i = 0; i < width; i++) {
2058 Y = GST_READ_UINT16_BE (srcY + i) << 6;
2059 U = GST_READ_UINT16_BE (srcU + (i >> 1)) << 6;
2060 V = GST_READ_UINT16_BE (srcV + (i >> 1)) << 6;
2062 if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
2068 d[i * 4 + 0] = 0xffff;
2076 pack_I422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2077 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2078 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2082 guint16 *destY = GET_Y_LINE (y);
2083 guint16 *destU = GET_U_LINE (y);
2084 guint16 *destV = GET_V_LINE (y);
2085 guint16 Y0, Y1, U, V;
2086 const guint16 *s = src;
2088 for (i = 0; i < width - 1; i += 2) {
2089 Y0 = s[i * 4 + 1] >> 6;
2090 Y1 = s[i * 4 + 5] >> 6;
2091 U = s[i * 4 + 2] >> 6;
2092 V = s[i * 4 + 3] >> 6;
2094 GST_WRITE_UINT16_BE (destY + i + 0, Y0);
2095 GST_WRITE_UINT16_BE (destY + i + 1, Y1);
2096 GST_WRITE_UINT16_BE (destU + (i >> 1), U);
2097 GST_WRITE_UINT16_BE (destV + (i >> 1), V);
2099 if (i == width - 1) {
2100 Y0 = s[i * 4 + 1] >> 6;
2101 U = s[i * 4 + 2] >> 6;
2102 V = s[i * 4 + 3] >> 6;
2104 GST_WRITE_UINT16_BE (destY + i, Y0);
2105 GST_WRITE_UINT16_BE (destU + (i >> 1), U);
2106 GST_WRITE_UINT16_BE (destV + (i >> 1), V);
2111 get_tile_NV12 (gint tile_width, gint ts, gint tx, gint ty,
2112 const gpointer data[GST_VIDEO_MAX_PLANES],
2113 const gint stride[GST_VIDEO_MAX_PLANES],
2114 gpointer tile_data[GST_VIDEO_MAX_PLANES],
2115 gint tile_stride[GST_VIDEO_MAX_PLANES])
2119 /* index of Y tile */
2120 offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
2121 tx, ty, GST_VIDEO_TILE_X_TILES (stride[0]),
2122 GST_VIDEO_TILE_Y_TILES (stride[0]));
2124 tile_data[0] = ((guint8 *) data[0]) + offset;
2126 /* index of UV tile */
2127 offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
2128 tx, ty >> 1, GST_VIDEO_TILE_X_TILES (stride[1]),
2129 GST_VIDEO_TILE_Y_TILES (stride[1]));
2131 /* On odd rows we return the second part of the UV tile */
2132 offset |= (ty & 1) << (ts - 1);
2133 tile_data[1] = ((guint8 *) data[1]) + offset;
2135 tile_stride[0] = tile_stride[1] = tile_width;
2138 #define PACK_NV12_64Z32 GST_VIDEO_FORMAT_AYUV, unpack_NV12_64Z32, 1, pack_NV12_64Z32
2140 unpack_NV12_64Z32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2141 gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
2142 const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
2144 const GstVideoFormatInfo *unpack_info, *finfo;
2145 guint8 *line = dest;
2146 gint ws, hs, ts, tile_width;
2148 gint unpack_pstride;
2150 ws = GST_VIDEO_FORMAT_INFO_TILE_WS (info);
2151 hs = GST_VIDEO_FORMAT_INFO_TILE_HS (info);
2154 tile_width = 1 << ws;
2156 /* we reuse these unpack functions */
2157 finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_NV12);
2159 /* get pstride of unpacked format */
2160 unpack_info = gst_video_format_get_info (info->unpack_format);
2161 unpack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (unpack_info, 0);
2163 /* first x tile to convert */
2165 /* Last tile to convert */
2166 ntx = ((x + width - 1) >> ws) + 1;
2167 /* The row we are going to convert */
2170 /* y position in a tile */
2171 y = y & ((1 << hs) - 1);
2172 /* x position in a tile */
2173 x = x & (tile_width - 1);
2175 for (; tx < ntx; tx++) {
2176 gpointer tdata[GST_VIDEO_MAX_PLANES];
2177 gint tstride[GST_VIDEO_MAX_PLANES];
2180 get_tile_NV12 (tile_width, ts, tx, ty, data, stride, tdata, tstride);
2182 /* the number of bytes left to unpack */
2183 unpack_width = MIN (width - x, tile_width - x);
2185 finfo->unpack_func (finfo, flags, line, tdata, tstride, x, y, unpack_width);
2188 width -= unpack_width;
2189 line += unpack_width * unpack_pstride;
2194 pack_NV12_64Z32 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
2195 const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
2196 const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
2199 const GstVideoFormatInfo *pack_info, *finfo;
2201 gint ws, hs, ts, tile_width;
2205 ws = GST_VIDEO_FORMAT_INFO_TILE_WS (info);
2206 hs = GST_VIDEO_FORMAT_INFO_TILE_HS (info);
2209 tile_width = 1 << ws;
2211 /* we reuse these pack functions */
2212 finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_NV12);
2214 /* get pstride of packed format */
2215 pack_info = gst_video_format_get_info (info->unpack_format);
2216 pack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (pack_info, 0);
2218 /* Last tile to convert */
2219 ntx = ((width - 1) >> ws) + 1;
2220 /* The row we are going to convert */
2223 /* y position in a tile */
2224 y = y & ((1 << hs) - 1);
2226 for (tx = 0; tx < ntx; tx++) {
2227 gpointer tdata[GST_VIDEO_MAX_PLANES];
2228 gint tstride[GST_VIDEO_MAX_PLANES];
2231 get_tile_NV12 (tile_width, ts, tx, ty, data, stride, tdata, tstride);
2233 /* the number of bytes left to pack */
2234 pack_width = MIN (width, tile_width);
2236 finfo->pack_func (finfo, flags, line, sstride, tdata, tstride,
2237 chroma_site, y, pack_width);
2239 width -= pack_width;
2240 line += pack_width * pack_pstride;
2247 GstVideoFormatInfo info;
2250 /* depths: bits, n_components, shift, depth */
2251 #define DPTH0 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
2252 #define DPTH8 8, 1, { 0, 0, 0, 0 }, { 8, 0, 0, 0 }
2253 #define DPTH8_32 8, 2, { 0, 0, 0, 0 }, { 8, 32, 0, 0 }
2254 #define DPTH888 8, 3, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
2255 #define DPTH8888 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 8 }
2256 #define DPTH8880 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
2257 #define DPTH10_10_10 10, 3, { 0, 0, 0, 0 }, { 10, 10, 10, 0 }
2258 #define DPTH16 16, 1, { 0, 0, 0, 0 }, { 16, 0, 0, 0 }
2259 #define DPTH16_16_16 16, 3, { 0, 0, 0, 0 }, { 16, 16, 16, 0 }
2260 #define DPTH16_16_16_16 16, 4, { 0, 0, 0, 0 }, { 16, 16, 16, 16 }
2261 #define DPTH555 16, 3, { 10, 5, 0, 0 }, { 5, 5, 5, 0 }
2262 #define DPTH565 16, 3, { 11, 5, 0, 0 }, { 5, 6, 5, 0 }
2265 #define PSTR0 { 0, 0, 0, 0 }
2266 #define PSTR1 { 1, 0, 0, 0 }
2267 #define PSTR14 { 1, 4, 0, 0 }
2268 #define PSTR111 { 1, 1, 1, 0 }
2269 #define PSTR1111 { 1, 1, 1, 1 }
2270 #define PSTR122 { 1, 2, 2, 0 }
2271 #define PSTR2 { 2, 0, 0, 0 }
2272 #define PSTR222 { 2, 2, 2, 0 }
2273 #define PSTR244 { 2, 4, 4, 0 }
2274 #define PSTR444 { 4, 4, 4, 0 }
2275 #define PSTR4444 { 4, 4, 4, 4 }
2276 #define PSTR333 { 3, 3, 3, 0 }
2277 #define PSTR488 { 4, 8, 8, 0 }
2278 #define PSTR8888 { 8, 8, 8, 8 }
2280 /* planes, in what plane do we find component N */
2281 #define PLANE_NA 0, { 0, 0, 0, 0 }
2282 #define PLANE0 1, { 0, 0, 0, 0 }
2283 #define PLANE01 2, { 0, 1, 0, 0 }
2284 #define PLANE011 2, { 0, 1, 1, 0 }
2285 #define PLANE012 3, { 0, 1, 2, 0 }
2286 #define PLANE0123 4, { 0, 1, 2, 3 }
2287 #define PLANE021 3, { 0, 2, 1, 0 }
2288 #define PLANE201 3, { 2, 0, 1, 0 }
2291 #define OFFS0 { 0, 0, 0, 0 }
2292 #define OFFS013 { 0, 1, 3, 0 }
2293 #define OFFS102 { 1, 0, 2, 0 }
2294 #define OFFS1230 { 1, 2, 3, 0 }
2295 #define OFFS012 { 0, 1, 2, 0 }
2296 #define OFFS210 { 2, 1, 0, 0 }
2297 #define OFFS123 { 1, 2, 3, 0 }
2298 #define OFFS321 { 3, 2, 1, 0 }
2299 #define OFFS0123 { 0, 1, 2, 3 }
2300 #define OFFS2103 { 2, 1, 0, 3 }
2301 #define OFFS3210 { 3, 2, 1, 0 }
2302 #define OFFS031 { 0, 3, 1, 0 }
2303 #define OFFS204 { 2, 0, 4, 0 }
2304 #define OFFS001 { 0, 0, 1, 0 }
2305 #define OFFS010 { 0, 1, 0, 0 }
2306 #define OFFS104 { 1, 0, 4, 0 }
2307 #define OFFS2460 { 2, 4, 6, 0 }
2309 /* subsampling, w_sub, h_sub */
2310 #define SUB410 { 0, 2, 2, 0 }, { 0, 2, 2, 0 }
2311 #define SUB411 { 0, 2, 2, 0 }, { 0, 0, 0, 0 }
2312 #define SUB420 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
2313 #define SUB422 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
2314 #define SUB4 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
2315 #define SUB44 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
2316 #define SUB444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
2317 #define SUB4444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
2318 #define SUB4204 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
2320 /* tile_mode, tile_width, tile_height */
2321 #define TILE_64x32(mode) GST_VIDEO_TILE_MODE_ ##mode, 6, 5
2323 #define MAKE_YUV_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
2324 { fourcc, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_YUV, depth, pstride, plane, offs, sub, pack } }
2325 #define MAKE_YUV_LE_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack ) \
2326 { 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 } }
2327 #define MAKE_YUVA_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
2328 { 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 } }
2329 #define MAKE_YUVA_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
2330 { 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 } }
2331 #define MAKE_YUVA_LE_PACK_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
2332 { 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 } }
2333 #define MAKE_YUV_C_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack) \
2334 { 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 } }
2335 #define MAKE_YUV_T_FORMAT(name, desc, fourcc, depth, pstride, plane, offs, sub, pack, tile) \
2336 { 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 } }
2338 #define MAKE_RGB_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
2339 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_RGB, depth, pstride, plane, offs, sub, pack } }
2340 #define MAKE_RGB_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
2341 { 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 } }
2342 #define MAKE_RGBA_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
2343 { 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 } }
2344 #define MAKE_RGBAP_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
2345 { 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 } }
2346 #define MAKE_RGBA_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
2347 { 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 } }
2348 #define MAKE_RGBA_LE_PACK_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
2349 { 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 } }
2351 #define MAKE_GRAY_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
2352 { 0x00000000, {GST_VIDEO_FORMAT_ ##name, G_STRINGIFY(name), desc, GST_VIDEO_FORMAT_FLAG_GRAY, depth, pstride, plane, offs, sub, pack } }
2353 #define MAKE_GRAY_LE_FORMAT(name, desc, depth, pstride, plane, offs, sub, pack) \
2354 { 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 } }
2356 static VideoFormat formats[] = {
2357 {0x00000000, {GST_VIDEO_FORMAT_UNKNOWN, "UNKNOWN", "unknown video", 0, DPTH0,
2358 PSTR0, PLANE_NA, OFFS0}},
2359 {0x00000000, {GST_VIDEO_FORMAT_ENCODED, "ENCODED", "encoded video",
2360 GST_VIDEO_FORMAT_FLAG_COMPLEX, DPTH0, PSTR0, PLANE_NA, OFFS0}},
2362 MAKE_YUV_FORMAT (I420, "raw video", GST_MAKE_FOURCC ('I', '4', '2', '0'),
2363 DPTH888, PSTR111, PLANE012, OFFS0, SUB420, PACK_420),
2364 MAKE_YUV_FORMAT (YV12, "raw video", GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
2365 DPTH888, PSTR111, PLANE021, OFFS0, SUB420, PACK_420),
2366 MAKE_YUV_FORMAT (YUY2, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
2367 DPTH888, PSTR244, PLANE0, OFFS013, SUB422, PACK_YUY2),
2368 MAKE_YUV_FORMAT (UYVY, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'),
2369 DPTH888, PSTR244, PLANE0, OFFS102, SUB422, PACK_UYVY),
2370 MAKE_YUVA_PACK_FORMAT (AYUV, "raw video", GST_MAKE_FOURCC ('A', 'Y', 'U',
2371 'V'), DPTH8888, PSTR4444, PLANE0, OFFS1230, SUB4444, PACK_AYUV),
2372 MAKE_RGB_FORMAT (RGBx, "raw video", DPTH888, PSTR444, PLANE0, OFFS012,
2374 MAKE_RGB_FORMAT (BGRx, "raw video", DPTH888, PSTR444, PLANE0, OFFS210,
2376 MAKE_RGB_FORMAT (xRGB, "raw video", DPTH888, PSTR444, PLANE0, OFFS123,
2378 MAKE_RGB_FORMAT (xBGR, "raw video", DPTH888, PSTR444, PLANE0, OFFS321,
2380 MAKE_RGBA_FORMAT (RGBA, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS0123,
2381 SUB4444, PACK_RGBA),
2382 MAKE_RGBA_FORMAT (BGRA, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS2103,
2383 SUB4444, PACK_BGRA),
2384 MAKE_RGBA_PACK_FORMAT (ARGB, "raw video", DPTH8888, PSTR4444, PLANE0,
2385 OFFS1230, SUB4444, PACK_ARGB),
2386 MAKE_RGBA_FORMAT (ABGR, "raw video", DPTH8888, PSTR4444, PLANE0, OFFS3210,
2387 SUB4444, PACK_ABGR),
2388 MAKE_RGB_FORMAT (RGB, "raw video", DPTH888, PSTR333, PLANE0, OFFS012, SUB444,
2390 MAKE_RGB_FORMAT (BGR, "raw video", DPTH888, PSTR333, PLANE0, OFFS210, SUB444,
2393 MAKE_YUV_FORMAT (Y41B, "raw video", GST_MAKE_FOURCC ('Y', '4', '1', 'B'),
2394 DPTH888, PSTR111, PLANE012, OFFS0, SUB411, PACK_Y41B),
2395 MAKE_YUV_FORMAT (Y42B, "raw video", GST_MAKE_FOURCC ('Y', '4', '2', 'B'),
2396 DPTH888, PSTR111, PLANE012, OFFS0, SUB422, PACK_Y42B),
2397 MAKE_YUV_FORMAT (YVYU, "raw video", GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'),
2398 DPTH888, PSTR244, PLANE0, OFFS031, SUB422, PACK_YVYU),
2399 MAKE_YUV_FORMAT (Y444, "raw video", GST_MAKE_FOURCC ('Y', '4', '4', '4'),
2400 DPTH888, PSTR111, PLANE012, OFFS0, SUB444, PACK_Y444),
2401 MAKE_YUV_C_FORMAT (v210, "raw video", GST_MAKE_FOURCC ('v', '2', '1', '0'),
2402 DPTH10_10_10, PSTR0, PLANE0, OFFS0, SUB422, PACK_v210),
2403 MAKE_YUV_FORMAT (v216, "raw video", GST_MAKE_FOURCC ('v', '2', '1', '6'),
2404 DPTH16_16_16, PSTR488, PLANE0, OFFS204, SUB422, PACK_v216),
2405 MAKE_YUV_FORMAT (NV12, "raw video", GST_MAKE_FOURCC ('N', 'V', '1', '2'),
2406 DPTH888, PSTR122, PLANE011, OFFS001, SUB420, PACK_NV12),
2407 MAKE_YUV_FORMAT (NV21, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '1'),
2408 DPTH888, PSTR122, PLANE011, OFFS010, SUB420, PACK_NV21),
2410 MAKE_GRAY_FORMAT (GRAY8, "raw video", DPTH8, PSTR1, PLANE0, OFFS0, SUB4,
2412 MAKE_GRAY_FORMAT (GRAY16_BE, "raw video", DPTH16, PSTR2, PLANE0, OFFS0, SUB4,
2414 MAKE_GRAY_LE_FORMAT (GRAY16_LE, "raw video", DPTH16, PSTR2, PLANE0, OFFS0,
2415 SUB4, PACK_GRAY16_LE),
2417 MAKE_YUV_FORMAT (v308, "raw video", GST_MAKE_FOURCC ('v', '3', '0', '8'),
2418 DPTH888, PSTR333, PLANE0, OFFS012, SUB444, PACK_v308),
2420 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
2421 MAKE_RGB_LE_FORMAT (RGB16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0,
2422 SUB444, PACK_RGB16),
2423 MAKE_RGB_LE_FORMAT (BGR16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0,
2424 SUB444, PACK_BGR16),
2425 MAKE_RGB_LE_FORMAT (RGB15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0,
2426 SUB444, PACK_RGB15),
2427 MAKE_RGB_LE_FORMAT (BGR15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0,
2428 SUB444, PACK_BGR15),
2430 MAKE_RGB_FORMAT (RGB16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0, SUB444,
2432 MAKE_RGB_FORMAT (BGR16, "raw video", DPTH565, PSTR222, PLANE0, OFFS0, SUB444,
2434 MAKE_RGB_FORMAT (RGB15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0, SUB444,
2436 MAKE_RGB_FORMAT (BGR15, "raw video", DPTH555, PSTR222, PLANE0, OFFS0, SUB444,
2440 MAKE_YUV_C_FORMAT (UYVP, "raw video", GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'),
2441 DPTH10_10_10, PSTR0, PLANE0, OFFS0, SUB422, PACK_UYVP),
2442 MAKE_YUVA_FORMAT (A420, "raw video", GST_MAKE_FOURCC ('A', '4', '2', '0'),
2443 DPTH8888, PSTR1111, PLANE0123, OFFS0, SUB4204, PACK_A420),
2444 MAKE_RGBAP_FORMAT (RGB8P, "raw video", DPTH8_32, PSTR14, PLANE01,
2445 OFFS0, SUB44, PACK_RGB8P),
2446 MAKE_YUV_FORMAT (YUV9, "raw video", GST_MAKE_FOURCC ('Y', 'U', 'V', '9'),
2447 DPTH888, PSTR111, PLANE012, OFFS0, SUB410, PACK_410),
2448 MAKE_YUV_FORMAT (YVU9, "raw video", GST_MAKE_FOURCC ('Y', 'V', 'U', '9'),
2449 DPTH888, PSTR111, PLANE021, OFFS0, SUB410, PACK_410),
2450 MAKE_YUV_FORMAT (IYU1, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '1'),
2451 DPTH888, PSTR0, PLANE0, OFFS104, SUB411, PACK_IYU1),
2452 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
2453 MAKE_RGBA_LE_PACK_FORMAT (ARGB64, "raw video", DPTH16_16_16_16, PSTR8888,
2455 OFFS2460, SUB444, PACK_ARGB64),
2456 MAKE_YUVA_LE_PACK_FORMAT (AYUV64, "raw video", 0x00000000, DPTH16_16_16_16,
2457 PSTR8888, PLANE0, OFFS2460, SUB444, PACK_AYUV64),
2459 MAKE_RGBA_PACK_FORMAT (ARGB64, "raw video", DPTH16_16_16_16, PSTR8888, PLANE0,
2460 OFFS2460, SUB444, PACK_ARGB64),
2461 MAKE_YUVA_PACK_FORMAT (AYUV64, "raw video", 0x00000000, DPTH16_16_16_16,
2462 PSTR8888, PLANE0, OFFS2460, SUB444, PACK_AYUV64),
2464 MAKE_RGB_FORMAT (r210, "raw video", DPTH10_10_10, PSTR444, PLANE0, OFFS0,
2466 MAKE_YUV_FORMAT (I420_10BE, "raw video", 0x00000000, DPTH10_10_10,
2467 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10BE),
2468 MAKE_YUV_LE_FORMAT (I420_10LE, "raw video", 0x00000000, DPTH10_10_10,
2469 PSTR222, PLANE012, OFFS0, SUB420, PACK_I420_10LE),
2470 MAKE_YUV_FORMAT (I422_10BE, "raw video", 0x00000000, DPTH10_10_10,
2471 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10BE),
2472 MAKE_YUV_LE_FORMAT (I422_10LE, "raw video", 0x00000000, DPTH10_10_10,
2473 PSTR222, PLANE012, OFFS0, SUB422, PACK_I422_10LE),
2474 MAKE_YUV_FORMAT (Y444_10BE, "raw video", 0x00000000, DPTH10_10_10,
2475 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10BE),
2476 MAKE_YUV_LE_FORMAT (Y444_10LE, "raw video", 0x00000000, DPTH10_10_10,
2477 PSTR222, PLANE012, OFFS0, SUB444, PACK_Y444_10LE),
2478 MAKE_RGB_FORMAT (GBR, "raw video", DPTH888, PSTR111, PLANE201, OFFS0, SUB444,
2480 MAKE_RGB_FORMAT (GBR_10BE, "raw video", DPTH10_10_10, PSTR222, PLANE201,
2483 MAKE_RGB_LE_FORMAT (GBR_10LE, "raw video", DPTH10_10_10, PSTR222, PLANE201,
2486 MAKE_YUV_FORMAT (NV16, "raw video", GST_MAKE_FOURCC ('N', 'V', '1', '6'),
2487 DPTH888, PSTR111, PLANE011, OFFS001, SUB422, PACK_NV16),
2488 MAKE_YUV_FORMAT (NV24, "raw video", GST_MAKE_FOURCC ('N', 'V', '2', '4'),
2489 DPTH888, PSTR111, PLANE011, OFFS001, SUB444, PACK_NV24),
2490 MAKE_YUV_T_FORMAT (NV12_64Z32, "raw video",
2491 GST_MAKE_FOURCC ('T', 'M', '1', '2'), DPTH8880, PSTR122, PLANE011,
2492 OFFS001, SUB420, PACK_NV12_64Z32, TILE_64x32 (ZFLIPZ_2X2)),
2495 static GstVideoFormat
2496 gst_video_format_from_rgb32_masks (int red_mask, int green_mask, int blue_mask)
2498 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
2499 blue_mask == 0x0000ff00) {
2500 return GST_VIDEO_FORMAT_RGBx;
2502 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
2503 blue_mask == 0xff000000) {
2504 return GST_VIDEO_FORMAT_BGRx;
2506 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
2507 blue_mask == 0x000000ff) {
2508 return GST_VIDEO_FORMAT_xRGB;
2510 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
2511 blue_mask == 0x00ff0000) {
2512 return GST_VIDEO_FORMAT_xBGR;
2515 return GST_VIDEO_FORMAT_UNKNOWN;
2518 static GstVideoFormat
2519 gst_video_format_from_rgba32_masks (int red_mask, int green_mask,
2520 int blue_mask, int alpha_mask)
2522 if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
2523 blue_mask == 0x0000ff00 && alpha_mask == 0x000000ff) {
2524 return GST_VIDEO_FORMAT_RGBA;
2526 if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
2527 blue_mask == 0xff000000 && alpha_mask == 0x000000ff) {
2528 return GST_VIDEO_FORMAT_BGRA;
2530 if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
2531 blue_mask == 0x000000ff && alpha_mask == 0xff000000) {
2532 return GST_VIDEO_FORMAT_ARGB;
2534 if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
2535 blue_mask == 0x00ff0000 && alpha_mask == 0xff000000) {
2536 return GST_VIDEO_FORMAT_ABGR;
2538 return GST_VIDEO_FORMAT_UNKNOWN;
2541 static GstVideoFormat
2542 gst_video_format_from_rgb24_masks (int red_mask, int green_mask, int blue_mask)
2544 if (red_mask == 0xff0000 && green_mask == 0x00ff00 && blue_mask == 0x0000ff) {
2545 return GST_VIDEO_FORMAT_RGB;
2547 if (red_mask == 0x0000ff && green_mask == 0x00ff00 && blue_mask == 0xff0000) {
2548 return GST_VIDEO_FORMAT_BGR;
2551 return GST_VIDEO_FORMAT_UNKNOWN;
2554 #define GST_VIDEO_COMP1_MASK_16_INT 0xf800
2555 #define GST_VIDEO_COMP2_MASK_16_INT 0x07e0
2556 #define GST_VIDEO_COMP3_MASK_16_INT 0x001f
2558 #define GST_VIDEO_COMP1_MASK_15_INT 0x7c00
2559 #define GST_VIDEO_COMP2_MASK_15_INT 0x03e0
2560 #define GST_VIDEO_COMP3_MASK_15_INT 0x001f
2562 static GstVideoFormat
2563 gst_video_format_from_rgb16_masks (int red_mask, int green_mask, int blue_mask)
2565 if (red_mask == GST_VIDEO_COMP1_MASK_16_INT
2566 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
2567 && blue_mask == GST_VIDEO_COMP3_MASK_16_INT) {
2568 return GST_VIDEO_FORMAT_RGB16;
2570 if (red_mask == GST_VIDEO_COMP3_MASK_16_INT
2571 && green_mask == GST_VIDEO_COMP2_MASK_16_INT
2572 && blue_mask == GST_VIDEO_COMP1_MASK_16_INT) {
2573 return GST_VIDEO_FORMAT_BGR16;
2575 if (red_mask == GST_VIDEO_COMP1_MASK_15_INT
2576 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
2577 && blue_mask == GST_VIDEO_COMP3_MASK_15_INT) {
2578 return GST_VIDEO_FORMAT_RGB15;
2580 if (red_mask == GST_VIDEO_COMP3_MASK_15_INT
2581 && green_mask == GST_VIDEO_COMP2_MASK_15_INT
2582 && blue_mask == GST_VIDEO_COMP1_MASK_15_INT) {
2583 return GST_VIDEO_FORMAT_BGR15;
2585 return GST_VIDEO_FORMAT_UNKNOWN;
2589 * gst_video_format_from_masks:
2590 * @depth: the amount of bits used for a pixel
2591 * @bpp: the amount of bits used to store a pixel. This value is bigger than
2593 * @endianness: the endianness of the masks, #G_LITTLE_ENDIAN or #G_BIG_ENDIAN
2594 * @red_mask: the red mask
2595 * @green_mask: the green mask
2596 * @blue_mask: the blue mask
2597 * @alpha_mask: the alpha mask, or 0 if no alpha mask
2599 * Find the #GstVideoFormat for the given parameters.
2601 * Returns: a #GstVideoFormat or GST_VIDEO_FORMAT_UNKNOWN when the parameters to
2602 * not specify a known format.
2605 gst_video_format_from_masks (gint depth, gint bpp, gint endianness,
2606 guint red_mask, guint green_mask, guint blue_mask, guint alpha_mask)
2608 GstVideoFormat format;
2610 /* our caps system handles 24/32bpp RGB as big-endian. */
2611 if ((bpp == 24 || bpp == 32) && endianness == G_LITTLE_ENDIAN) {
2612 red_mask = GUINT32_TO_BE (red_mask);
2613 green_mask = GUINT32_TO_BE (green_mask);
2614 blue_mask = GUINT32_TO_BE (blue_mask);
2615 alpha_mask = GUINT32_TO_BE (alpha_mask);
2616 endianness = G_BIG_ENDIAN;
2624 if (depth == 30 && bpp == 32) {
2625 format = GST_VIDEO_FORMAT_r210;
2626 } else if (depth == 24 && bpp == 32) {
2627 format = gst_video_format_from_rgb32_masks (red_mask, green_mask,
2629 } else if (depth == 32 && bpp == 32 && alpha_mask) {
2630 format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
2631 blue_mask, alpha_mask);
2632 } else if (depth == 24 && bpp == 24) {
2633 format = gst_video_format_from_rgb24_masks (red_mask, green_mask,
2635 } else if ((depth == 15 || depth == 16) && bpp == 16 &&
2636 endianness == G_BYTE_ORDER) {
2637 format = gst_video_format_from_rgb16_masks (red_mask, green_mask,
2639 } else if (depth == 8 && bpp == 8) {
2640 format = GST_VIDEO_FORMAT_RGB8P;
2641 } else if (depth == 64 && bpp == 64) {
2642 format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
2643 blue_mask, alpha_mask);
2644 if (format == GST_VIDEO_FORMAT_ARGB) {
2645 format = GST_VIDEO_FORMAT_ARGB64;
2647 format = GST_VIDEO_FORMAT_UNKNOWN;
2650 format = GST_VIDEO_FORMAT_UNKNOWN;
2656 * gst_video_format_from_fourcc:
2657 * @fourcc: a FOURCC value representing raw YUV video
2659 * Converts a FOURCC value into the corresponding #GstVideoFormat.
2660 * If the FOURCC cannot be represented by #GstVideoFormat,
2661 * #GST_VIDEO_FORMAT_UNKNOWN is returned.
2663 * Returns: the #GstVideoFormat describing the FOURCC value
2666 gst_video_format_from_fourcc (guint32 fourcc)
2669 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
2670 return GST_VIDEO_FORMAT_I420;
2671 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
2672 return GST_VIDEO_FORMAT_YV12;
2673 case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
2674 return GST_VIDEO_FORMAT_YUY2;
2675 case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
2676 return GST_VIDEO_FORMAT_YVYU;
2677 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
2678 return GST_VIDEO_FORMAT_UYVY;
2679 case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
2680 return GST_VIDEO_FORMAT_AYUV;
2681 case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
2682 return GST_VIDEO_FORMAT_Y41B;
2683 case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
2684 return GST_VIDEO_FORMAT_Y42B;
2685 case GST_MAKE_FOURCC ('Y', '4', '4', '4'):
2686 return GST_VIDEO_FORMAT_Y444;
2687 case GST_MAKE_FOURCC ('v', '2', '1', '0'):
2688 return GST_VIDEO_FORMAT_v210;
2689 case GST_MAKE_FOURCC ('v', '2', '1', '6'):
2690 return GST_VIDEO_FORMAT_v216;
2691 case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
2692 return GST_VIDEO_FORMAT_NV12;
2693 case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
2694 return GST_VIDEO_FORMAT_NV21;
2695 case GST_MAKE_FOURCC ('N', 'V', '1', '6'):
2696 return GST_VIDEO_FORMAT_NV16;
2697 case GST_MAKE_FOURCC ('N', 'V', '2', '4'):
2698 return GST_VIDEO_FORMAT_NV24;
2699 case GST_MAKE_FOURCC ('v', '3', '0', '8'):
2700 return GST_VIDEO_FORMAT_v308;
2701 case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
2702 case GST_MAKE_FOURCC ('Y', '8', ' ', ' '):
2703 case GST_MAKE_FOURCC ('G', 'R', 'E', 'Y'):
2704 return GST_VIDEO_FORMAT_GRAY8;
2705 case GST_MAKE_FOURCC ('Y', '1', '6', ' '):
2706 return GST_VIDEO_FORMAT_GRAY16_LE;
2707 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'):
2708 return GST_VIDEO_FORMAT_UYVP;
2709 case GST_MAKE_FOURCC ('A', '4', '2', '0'):
2710 return GST_VIDEO_FORMAT_A420;
2711 case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
2712 return GST_VIDEO_FORMAT_YUV9;
2713 case GST_MAKE_FOURCC ('Y', 'V', 'U', '9'):
2714 return GST_VIDEO_FORMAT_YVU9;
2715 case GST_MAKE_FOURCC ('I', 'Y', 'U', '1'):
2716 return GST_VIDEO_FORMAT_IYU1;
2717 case GST_MAKE_FOURCC ('A', 'Y', '6', '4'):
2718 return GST_VIDEO_FORMAT_AYUV64;
2720 return GST_VIDEO_FORMAT_UNKNOWN;
2725 * gst_video_format_from_string:
2726 * @format: a format string
2728 * Convert the @format string to its #GstVideoFormat.
2730 * Returns: the #GstVideoFormat for @format or GST_VIDEO_FORMAT_UNKNOWN when the
2731 * string is not a known format.
2734 gst_video_format_from_string (const gchar * format)
2738 g_return_val_if_fail (format != NULL, GST_VIDEO_FORMAT_UNKNOWN);
2740 for (i = 0; i < G_N_ELEMENTS (formats); i++) {
2741 if (strcmp (GST_VIDEO_FORMAT_INFO_NAME (&formats[i].info), format) == 0)
2742 return GST_VIDEO_FORMAT_INFO_FORMAT (&formats[i].info);
2744 return GST_VIDEO_FORMAT_UNKNOWN;
2749 * gst_video_format_to_fourcc:
2750 * @format: a #GstVideoFormat video format
2752 * Converts a #GstVideoFormat value into the corresponding FOURCC. Only
2753 * a few YUV formats have corresponding FOURCC values. If @format has
2754 * no corresponding FOURCC value, 0 is returned.
2756 * Returns: the FOURCC corresponding to @format
2759 gst_video_format_to_fourcc (GstVideoFormat format)
2761 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
2763 if (format >= G_N_ELEMENTS (formats))
2766 return formats[format].fourcc;
2770 * gst_video_format_to_string:
2771 * @format: a #GstVideoFormat video format
2773 * Returns a string containing a descriptive name for
2774 * the #GstVideoFormat if there is one, or NULL otherwise.
2776 * Returns: the name corresponding to @format
2779 gst_video_format_to_string (GstVideoFormat format)
2781 g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
2783 if (format >= G_N_ELEMENTS (formats))
2786 return GST_VIDEO_FORMAT_INFO_NAME (&formats[format].info);
2790 * gst_video_format_get_info:
2791 * @format: a #GstVideoFormat
2793 * Get the #GstVideoFormatInfo for @format
2795 * Returns: The #GstVideoFormatInfo for @format.
2797 const GstVideoFormatInfo *
2798 gst_video_format_get_info (GstVideoFormat format)
2800 g_return_val_if_fail (format < G_N_ELEMENTS (formats), NULL);
2802 return &formats[format].info;
2806 * gst_video_format_get_palette:
2807 * @format: a #GstVideoFormat
2808 * @size: (out): size of the palette in bytes
2810 * Get the default palette of @format. This the palette used in the pack
2811 * function for paletted formats.
2813 * Returns: (transfer none): the default palette of @format or %NULL when
2814 * @format does not have a palette.
2819 gst_video_format_get_palette (GstVideoFormat format, gsize * size)
2821 g_return_val_if_fail (format < G_N_ELEMENTS (formats), NULL);
2822 g_return_val_if_fail (size != NULL, NULL);
2825 case GST_VIDEO_FORMAT_RGB8P:
2826 *size = sizeof (std_palette_RGB8P);
2827 return std_palette_RGB8P;