48#include <libavutil/pixfmt.h>
49#include <libavutil/hwcontext_drm.h>
72#define MOD_NAME "[from_lavc_vid_conv] "
75#define BYTE_SWAP(x) (3 - x)
85#define MK_RGBA(r, g, b, alpha_mask, depth) \
86 FORMAT_RGBA((r), (g), (b), (rgb_shift)[R], (rgb_shift)[G], \
87 (rgb_shift)[B], (alpha_mask), (depth))
89#pragma GCC diagnostic push
90#pragma GCC diagnostic ignored "-Wunknown-pragmas"
91#pragma clang diagnostic warning "-Wpass-failed"
93static void nv12_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
94 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
97 for(
int y = 0; y < (int) height; ++y) {
98 char *src_y = (
char *) in_frame->data[0] + in_frame->linesize[0] * y;
99 char *src_cbcr = (
char *) in_frame->data[1] + in_frame->linesize[1] * (y / 2);
100 char *dst = dst_buffer + pitch * y;
103 *dst++ = *src_cbcr++;
105 *dst++ = *src_cbcr++;
112 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
116 for (
int y = 0; y < height; ++y) {
121static void memcpy_data(
char * __restrict dst_buffer, AVFrame * __restrict
frame,
122 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
__attribute__((unused));
124 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
128 for (
int comp = 0; comp < AV_NUM_DATA_POINTERS; ++comp) {
129 if (
frame->data[comp] == NULL) {
132 for (
int y = 0; y < height; ++y) {
133 memcpy(dst_buffer + y * pitch,
frame->data[comp] + y *
frame->linesize[comp],
134 frame->linesize[comp]);
140 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
142 for (
int y = 0; y < height; ++y) {
149 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
152 for (
int y = 0; y < height; ++y) {
155 uint8_t *buf = (uint8_t *) dst_buffer + y * pitch + x * 3;
156 int src_idx = y *
frame->linesize[0] + x;
157 buf[0] =
frame->data[2][src_idx];
158 buf[1] =
frame->data[0][src_idx];
159 buf[2] =
frame->data[1][src_idx];
165 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
167 assert((uintptr_t) dst_buffer % 4 == 0);
168 uint32_t alpha_mask = 0xFFFFFFFFU ^ (0xFFU << rgb_shift[
R]) ^ (0xFFU << rgb_shift[
G]) ^ (0xFFU << rgb_shift[
B]);
170 for (
int y = 0; y < height; ++y) {
171 uint32_t *line = (uint32_t *)(
void *) (dst_buffer + y * pitch);
172 int src_idx = y *
frame->linesize[0];
175 *line++ = alpha_mask |
176 frame->data[2][src_idx] << rgb_shift[
R] |
177 frame->data[0][src_idx] << rgb_shift[
G] |
178 frame->data[1][src_idx] << rgb_shift[
B];
186 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
int comp_count)
190 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
int comp_count)
193 for (
int y = 0; y < height; ++y) {
195 uint8_t *buf = (uint8_t *) dst_buffer + y * pitch + x * comp_count;
196 int src_idx = y *
frame->linesize[0] + x;
197 buf[0] =
frame->data[2][src_idx];
198 buf[1] =
frame->data[0][src_idx];
199 buf[2] =
frame->data[1][src_idx];
200 if (comp_count == 4) {
201 buf[3] =
frame->data[3][src_idx];
208 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
214 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
221 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
unsigned int in_depth)
225 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
unsigned int in_depth)
227 assert((uintptr_t)
frame->linesize[0] % 2 == 0);
228 assert((uintptr_t)
frame->linesize[1] % 2 == 0);
229 assert((uintptr_t)
frame->linesize[2] % 2 == 0);
232 for (
int y = 0; y < height; ++y) {
233 uint16_t *src_g = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * y);
234 uint16_t *src_b = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * y);
235 uint16_t *src_r = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * y);
236 unsigned char *dst = (
unsigned char *) dst_buffer + y * pitch;
239 *dst++ = *src_r >> (in_depth - 8U);
240 *dst++ = ((*src_r++ >> (in_depth - 10U)) & 0x3U) << 6U | *src_g >> (in_depth - 6U);
241 *dst++ = ((*src_g++ >> (in_depth - 10U)) & 0xFU) << 4U | *src_b >> (in_depth - 4U);
242 *dst++ = ((*src_b++ >> (in_depth - 10U)) & 0x3FU) << 2U | 0x3U;
248 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
254 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
261 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
265 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
267 assert((uintptr_t)
frame->linesize[0] % 2 == 0);
268 assert((uintptr_t)
frame->linesize[1] % 2 == 0);
269 assert((uintptr_t)
frame->linesize[2] % 2 == 0);
272 for (
int y = 0; y < height; ++y) {
273 uint16_t *src_y = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * y);
274 uint16_t *src_cb = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * y);
275 uint16_t *src_cr = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * y);
276 unsigned char *dst = (
unsigned char *) dst_buffer + y * pitch;
293 *dst++ = (r & 0x3) << 6 | g >> 4;
294 *dst++ = (g & 0xF) << 4 | b >> 6;
295 *dst++ = (b & 0x3F) << 2 | 0x3U;
301 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
307 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
313 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
320 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
324 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
326 assert((uintptr_t)
frame->linesize[0] % 2 == 0);
327 assert((uintptr_t)
frame->linesize[1] % 2 == 0);
328 assert((uintptr_t)
frame->linesize[2] % 2 == 0);
331 for (
int y = 0; y < height; ++y) {
332 uint16_t *src_y = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * y);
333 uint16_t *src_cb = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * y);
334 uint16_t *src_cr = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * y);
335 unsigned char *dst = (
unsigned char *) dst_buffer + y * pitch;
337 for (
int x = 0; x < width; x += 8) {
354 dst[
BYTE_SWAP(1)] = (g[0] & 0xf) << 4 | r[0] >> 8;
357 dst[4 +
BYTE_SWAP(0)] = (r[1] & 0xf) << 4 | b[0] >> 8;
360 dst[4 +
BYTE_SWAP(3)] = (b[1] & 0xf) << 4 | g[1] >> 8;
363 dst[8 +
BYTE_SWAP(2)] = (g[2] & 0xf) << 4 | r[2] >> 8;
366 dst[12 +
BYTE_SWAP(1)] = (r[3] & 0xf) << 4 | b[2] >> 8;
369 dst[16 +
BYTE_SWAP(0)] = (b[3] & 0xf) << 4 | g[3] >> 8;
372 dst[16 +
BYTE_SWAP(3)] = (g[4] & 0xf) << 4 | r[4] >> 8;
375 dst[20 +
BYTE_SWAP(2)] = (r[5] & 0xf) << 4 | b[4] >> 8;
378 dst[24 +
BYTE_SWAP(1)] = (b[5] & 0xf) << 4 | g[5] >> 8;
381 dst[28 +
BYTE_SWAP(0)] = (g[6] & 0xf) << 4 | r[6] >> 8;
384 dst[28 +
BYTE_SWAP(3)] = (r[7] & 0xf) << 4 | b[6] >> 8;
387 dst[32 +
BYTE_SWAP(2)] = (b[7] & 0xf) << 4 | g[7] >> 8;
395 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
401 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
407 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
414 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
418 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
420 assert((uintptr_t) dst_buffer % 2 == 0);
421 assert((uintptr_t)
frame->linesize[0] % 2 == 0);
422 assert((uintptr_t)
frame->linesize[1] % 2 == 0);
423 assert((uintptr_t)
frame->linesize[2] % 2 == 0);
426 for (
int y = 0; y < height; ++y) {
427 uint16_t *src_y = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * y);
428 uint16_t *src_cb = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * y);
429 uint16_t *src_cr = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * y);
430 uint16_t *dst = (uint16_t *)(
void *) (dst_buffer + y * pitch);
450 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
456 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
462 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
469 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
unsigned int in_depth)
473 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
unsigned int in_depth)
475 assert((uintptr_t)
frame->linesize[0] % 2 == 0);
476 assert((uintptr_t)
frame->linesize[1] % 2 == 0);
477 assert((uintptr_t)
frame->linesize[2] % 2 == 0);
480#define S(x) ((x) >> (in_depth - 12))
483 for (
int y = 0; y < height; ++y) {
484 uint16_t *src_g = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * y);
485 uint16_t *src_b = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * y);
486 uint16_t *src_r = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * y);
487 unsigned char *dst = (
unsigned char *) dst_buffer + y * pitch;
491 dst[
BYTE_SWAP(1)] = (
S(*src_g) & 0xf) << 4 |
S(*src_r++) >> 8;
494 dst[4 +
BYTE_SWAP(0)] = (
S(*src_r) & 0xf) << 4 |
S(*src_b++) >> 8;
497 dst[4 +
BYTE_SWAP(3)] = (
S(*src_b) & 0xf) << 4 |
S(*src_g++) >> 8;
500 dst[8 +
BYTE_SWAP(2)] = (
S(*src_g) & 0xf) << 4 |
S(*src_r++) >> 8;
503 dst[12 +
BYTE_SWAP(1)] = (
S(*src_r) & 0xf) << 4 |
S(*src_b++) >> 8;
506 dst[16 +
BYTE_SWAP(0)] = (
S(*src_b) & 0xf) << 4 |
S(*src_g++) >> 8;
509 dst[16 +
BYTE_SWAP(3)] = (
S(*src_g) & 0xf) << 4 |
S(*src_r++) >> 8;
512 dst[20 +
BYTE_SWAP(2)] = (
S(*src_r) & 0xf) << 4 |
S(*src_b++) >> 8;
515 dst[24 +
BYTE_SWAP(1)] = (
S(*src_b) & 0xf) << 4 |
S(*src_g++) >> 8;
518 dst[28 +
BYTE_SWAP(0)] = (
S(*src_g) & 0xf) << 4 |
S(*src_r++) >> 8;
521 dst[28 +
BYTE_SWAP(3)] = (
S(*src_r) & 0xf) << 4 |
S(*src_b++) >> 8;
524 dst[32 +
BYTE_SWAP(2)] = (
S(*src_b) & 0xf) << 4 |
S(*src_g++) >> 8;
533 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
unsigned int in_depth)
537 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
unsigned int in_depth)
539 assert((uintptr_t)
frame->linesize[0] % 2 == 0);
540 assert((uintptr_t)
frame->linesize[1] % 2 == 0);
541 assert((uintptr_t)
frame->linesize[2] % 2 == 0);
544 for (
int y = 0; y < height; ++y) {
545 uint16_t *src_g = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * y);
546 uint16_t *src_b = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * y);
547 uint16_t *src_r = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * y);
548 unsigned char *dst = (
unsigned char *) dst_buffer + y * pitch;
551 *dst++ = *src_r++ >> (in_depth - 8U);
552 *dst++ = *src_g++ >> (in_depth - 8U);
553 *dst++ = *src_b++ >> (in_depth - 8U);
560 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
unsigned int in_depth)
564 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
unsigned int in_depth)
566 assert((uintptr_t) dst_buffer % 4 == 0);
567 assert((uintptr_t)
frame->data[0] % 2 == 0);
568 assert((uintptr_t)
frame->data[1] % 2 == 0);
569 assert((uintptr_t)
frame->data[2] % 2 == 0);
571 uint32_t alpha_mask = 0xFFFFFFFFU ^ (0xFFU << rgb_shift[
R]) ^ (0xFFU << rgb_shift[
G]) ^ (0xFFU << rgb_shift[
B]);
573 for (
int y = 0; y < height; ++y) {
574 uint16_t *src_g = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * y);
575 uint16_t *src_b = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * y);
576 uint16_t *src_r = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * y);
577 uint32_t *dst = (uint32_t *)(
void *) (dst_buffer + y * pitch);
580 *dst++ = alpha_mask | (*src_r++ >> (in_depth - 8U)) << rgb_shift[0] | (*src_g++ >> (in_depth - 8U)) << rgb_shift[1] |
581 (*src_b++ >> (in_depth - 8U)) << rgb_shift[2];
587 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
593 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
599 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
605 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
611 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
617 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
623 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
629 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
635 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
642 int width,
int height,
int pitch,
unsigned int in_depth)
646 int width,
int height,
int pitch,
unsigned int in_depth)
648 assert((uintptr_t) dst_buffer % 2 == 0);
649 assert((uintptr_t)
frame->data[0] % 2 == 0);
650 assert((uintptr_t)
frame->data[1] % 2 == 0);
651 assert((uintptr_t)
frame->data[2] % 2 == 0);
653 for (ptrdiff_t y = 0; y < height; ++y) {
654 uint16_t *src_g = (
void *) (
frame->data[0] +
frame->linesize[0] * y);
655 uint16_t *src_b = (
void *) (
frame->data[1] +
frame->linesize[1] * y);
656 uint16_t *src_r = (
void *) (
frame->data[2] +
frame->linesize[2] * y);
657 uint16_t *dst = (
void *) (dst_buffer + y * pitch);
660 *dst++ = *src_r++ << (16U - in_depth);
661 *dst++ = *src_g++ << (16U - in_depth);
662 *dst++ = *src_b++ << (16U - in_depth);
668 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
675 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
682 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
689 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
692 for (
int y = 0; y < height; ++y) {
699 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
703 for (
int y = 0; y < height; ++y) {
709static void yuv420p_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
710 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
713 for(
int y = 0; y < (height + 1) / 2; ++y) {
714 int scnd_row = y * 2 + 1;
715 if (scnd_row == height) {
716 scnd_row = height - 1;
718 char *src_y1 = (
char *) in_frame->data[0] + in_frame->linesize[0] * y * 2;
719 char *src_y2 = (
char *) in_frame->data[0] + in_frame->linesize[0] * scnd_row;
720 char *src_cb = (
char *) in_frame->data[1] + in_frame->linesize[1] * y;
721 char *src_cr = (
char *) in_frame->data[2] + in_frame->linesize[2] * y;
722 char *dst1 = dst_buffer + (y * 2) * pitch;
723 char *dst2 = dst_buffer + scnd_row * pitch;
738 __m128i zero = _mm_set1_epi32(0);
740 for (; x < width - 15; x += 16){
741 y1 = _mm_lddqu_si128((__m128i
const*)(
const void *) src_y1);
742 y2 = _mm_lddqu_si128((__m128i
const*)(
const void *) src_y2);
746 out1l = _mm_unpacklo_epi8(zero, y1);
747 out1h = _mm_unpackhi_epi8(zero, y1);
748 out2l = _mm_unpacklo_epi8(zero, y2);
749 out2h = _mm_unpackhi_epi8(zero, y2);
751 u1 = _mm_lddqu_si128((__m128i
const*)(
const void *) src_cb);
752 v1 = _mm_lddqu_si128((__m128i
const*)(
const void *) src_cr);
756 u1 = _mm_unpacklo_epi8(u1, zero);
757 v1 = _mm_unpacklo_epi8(v1, zero);
758 u2 = _mm_unpackhi_epi8(u1, zero);
759 v2 = _mm_unpackhi_epi8(v1, zero);
760 u1 = _mm_unpacklo_epi8(u1, zero);
761 v1 = _mm_unpacklo_epi8(v1, zero);
763 v1 = _mm_bslli_si128(v1, 2);
764 v2 = _mm_bslli_si128(v2, 2);
766 u1 = _mm_or_si128(u1, v1);
767 u2 = _mm_or_si128(u2, v2);
769 out1l = _mm_or_si128(out1l, u1);
770 out1h = _mm_or_si128(out1h, u2);
771 out2l = _mm_or_si128(out2l, u1);
772 out2h = _mm_or_si128(out2h, u2);
774 _mm_storeu_si128((__m128i *)(
void *) dst1, out1l);
776 _mm_storeu_si128((__m128i *)(
void *) dst1, out1h);
778 _mm_storeu_si128((__m128i *)(
void *) dst2, out2l);
780 _mm_storeu_si128((__m128i *)(
void *) dst2, out2h);
811static void yuv420p_to_v210(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
812 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
815 for(
int y = 0; y < height / 2; ++y) {
816 uint8_t *src_y1 = (in_frame->data[0] + in_frame->linesize[0] * y * 2);
817 uint8_t *src_y2 = (in_frame->data[0] + in_frame->linesize[0] * (y * 2 + 1));
818 uint8_t *src_cb = (in_frame->data[1] + in_frame->linesize[1] * y);
819 uint8_t *src_cr = (in_frame->data[2] + in_frame->linesize[2] * y);
820 uint32_t *dst1 = (uint32_t *)(
void *)(dst_buffer + (y * 2) * pitch);
821 uint32_t *dst2 = (uint32_t *)(
void *)(dst_buffer + (y * 2 + 1) * pitch);
824 uint32_t w0_0, w0_1, w0_2, w0_3;
825 uint32_t w1_0, w1_1, w1_2, w1_3;
830 w0_0 = w0_0 | (*src_y1++ << 2) << 10;
831 w1_0 = w1_0 | (*src_y2++ << 2) << 10;
832 w0_0 = w0_0 | (*src_cr << 2) << 20;
833 w1_0 = w1_0 | (*src_cr << 2) << 20;
836 w0_1 = *src_y1++ << 2;
837 w1_1 = *src_y2++ << 2;
838 w0_1 = w0_1 | (*src_cb << 2) << 10;
839 w1_1 = w1_1 | (*src_cb << 2) << 10;
841 w0_1 = w0_1 | (*src_y1++ << 2) << 20;
842 w1_1 = w1_1 | (*src_y2++ << 2) << 20;
847 w0_2 = w0_2 | (*src_y1++ << 2) << 10;
848 w1_2 = w1_2 | (*src_y2++ << 2) << 10;
849 w0_2 = w0_2 | (*src_cb << 2) << 20;
850 w1_2 = w1_2 | (*src_cb << 2) << 20;
855 w0_3 = w0_3 | (*src_cr << 2) << 10;
856 w1_3 = w1_3 | (*src_cr << 2) << 10;
858 w0_3 = w0_3 | (*src_y1++ << 2) << 20;
859 w1_3 = w1_3 | (*src_y2++ << 2) << 20;
874static void yuv422p_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
875 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
878 for(
int y = 0; y < height; ++y) {
879 char *src_y = (
char *) in_frame->data[0] + in_frame->linesize[0] * y;
880 char *src_cb = (
char *) in_frame->data[1] + in_frame->linesize[1] * y;
881 char *src_cr = (
char *) in_frame->data[2] + in_frame->linesize[2] * y;
882 char *dst = dst_buffer + pitch * y;
893static void yuv422p_to_v210(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
894 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
897 for(
int y = 0; y < height; ++y) {
898 uint8_t *src_y = (in_frame->data[0] + in_frame->linesize[0] * y);
899 uint8_t *src_cb = (in_frame->data[1] + in_frame->linesize[1] * y);
900 uint8_t *src_cr = (in_frame->data[2] + in_frame->linesize[2] * y);
901 uint32_t *dst = (uint32_t *)(
void *)(dst_buffer + y * pitch);
904 uint32_t w0_0, w0_1, w0_2, w0_3;
906 w0_0 = *src_cb++ << 2;
907 w0_0 = w0_0 | (*src_y++ << 2) << 10;
908 w0_0 = w0_0 | (*src_cr++ << 2) << 20;
910 w0_1 = *src_y++ << 2;
911 w0_1 = w0_1 | (*src_cb++ << 2) << 10;
912 w0_1 = w0_1 | (*src_y++ << 2) << 20;
914 w0_2 = *src_cr++ << 2;
915 w0_2 = w0_2 | (*src_y++ << 2) << 10;
916 w0_2 = w0_2 | (*src_cb++ << 2) << 20;
918 w0_3 = *src_y++ << 2;
919 w0_3 = w0_3 | (*src_cr++ << 2) << 10;
920 w0_3 = w0_3 | (*src_y++ << 2) << 20;
930static void yuv444p_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
931 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
934 for(
int y = 0; y < height; ++y) {
935 char *src_y = (
char *) in_frame->data[0] + in_frame->linesize[0] * y;
936 unsigned char *src_cb = (
unsigned char *) in_frame->data[1] + in_frame->linesize[1] * y;
937 unsigned char *src_cr = (
unsigned char *) in_frame->data[2] + in_frame->linesize[2] * y;
938 char *dst = dst_buffer + pitch * y;
941 *dst++ = (*src_cb + *(src_cb + 1)) / 2;
944 *dst++ = (*src_cr + *(src_cr + 1)) / 2;
952 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
955 for(
int y = 0; y < height; ++y) {
956 unsigned char *src_y = (
unsigned char *) in_frame->data[0] + in_frame->linesize[0] * y + 1;
957 unsigned char *src_cb = (
unsigned char *) in_frame->data[1] + in_frame->linesize[1] * y + 1;
958 unsigned char *src_cr = (
unsigned char *) in_frame->data[2] + in_frame->linesize[2] * y + 1;
959 unsigned char *dst = (
unsigned char *) dst_buffer + pitch * y;
962 *dst++ = (*src_cb + *(src_cb + 2)) / 2;
966 *dst++ = (*src_cr + *(src_cr + 2)) / 2;
974static void yuv444p_to_v210(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
975 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
978 for(
int y = 0; y < height; ++y) {
979 uint8_t *src_y = (in_frame->data[0] + in_frame->linesize[0] * y);
980 uint8_t *src_cb = (in_frame->data[1] + in_frame->linesize[1] * y);
981 uint8_t *src_cr = (in_frame->data[2] + in_frame->linesize[2] * y);
982 uint32_t *dst = (uint32_t *)(
void *)(dst_buffer + y * pitch);
985 uint32_t w0_0, w0_1, w0_2, w0_3;
987 w0_0 = ((src_cb[0] << 2) + (src_cb[1] << 2)) / 2;
988 w0_0 = w0_0 | (*src_y++ << 2) << 10;
989 w0_0 = w0_0 | ((src_cr[0] << 2) + (src_cr[1] << 2)) / 2 << 20;
993 w0_1 = *src_y++ << 2;
994 w0_1 = w0_1 | ((src_cb[0] << 2) + (src_cb[1] << 2)) / 2 << 10;
995 w0_1 = w0_1 | (*src_y++ << 2) << 20;
998 w0_2 = ((src_cr[0] << 2) + (src_cr[1] << 2)) / 2;
999 w0_2 = w0_2 | (*src_y++ << 2) << 10;
1000 w0_2 = w0_2 | ((src_cb[0] << 2) + (src_cb[1] << 2)) / 2 << 20;
1004 w0_3 = *src_y++ << 2;
1005 w0_3 = w0_3 | ((src_cr[0] << 2) + (src_cr[1] << 2)) / 2 << 10;
1006 w0_3 = w0_3 | (*src_y++ << 2) << 20;
1022static inline void nv12_to_rgb(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1023 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
bool rgba)
1026static inline void nv12_to_rgb(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1027 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
bool rgba)
1032 assert((uintptr_t) dst_buffer % 4 == 0);
1034 uint32_t alpha_mask = 0xFFFFFFFFU ^ (0xFFU << rgb_shift[
R]) ^ (0xFFU << rgb_shift[
G]) ^ (0xFFU << rgb_shift[
B]);
1036 for(
int y = 0; y < height; ++y) {
1037 unsigned char *src_y = (
unsigned char *) in_frame->data[0] + in_frame->linesize[0] * y;
1038 unsigned char *src_cbcr = (
unsigned char *) in_frame->data[1] + in_frame->linesize[1] * (y / 2);
1039 unsigned char *dst = (
unsigned char *) dst_buffer + pitch * y;
1049 *((uint32_t *)(
void *) dst) =
MK_RGBA(r, g, b, alpha_mask, 8);
1057 y = (*src_y++ - 16) *
Y_SCALE(S_DEPTH);
1059 *((uint32_t *)(
void *) dst) =
MK_RGBA(r, g, b, alpha_mask, 8);
1070static void nv12_to_rgb24(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1071 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1073 nv12_to_rgb(dst_buffer, in_frame, width, height, pitch, rgb_shift,
false);
1076static void nv12_to_rgb32(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1077 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1079 nv12_to_rgb(dst_buffer, in_frame, width, height, pitch, rgb_shift,
true);
1084 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
bool rgba)
__attribute__((always_inline));
1091 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
bool rgba)
1096 uint32_t alpha_mask = 0xFFFFFFFFU ^ (0xFFU << rgb_shift[
R]) ^ (0xFFU << rgb_shift[
G]) ^ (0xFFU << rgb_shift[
B]);
1098 for(
int y = 0; y < height / 2; ++y) {
1099 unsigned char *src_y1 = (
unsigned char *) in_frame->data[0] + in_frame->linesize[0] * y * 2;
1100 unsigned char *src_y2 = (
unsigned char *) in_frame->data[0] + in_frame->linesize[0] * (y * 2 + 1);
1101 unsigned char *dst1 = (
unsigned char *) dst_buffer + pitch * (y * 2);
1102 unsigned char *dst2 = (
unsigned char *) dst_buffer + pitch * (y * 2 + 1);
1104 unsigned char *src_cb1 = NULL;
1105 unsigned char *src_cr1 = NULL;
1106 unsigned char *src_cb2 = NULL;
1107 unsigned char *src_cr2 = NULL;
1109 src_cb1 = (
unsigned char *) in_frame->data[1] + in_frame->linesize[1] * y;
1110 src_cr1 = (
unsigned char *) in_frame->data[2] + in_frame->linesize[2] * y;
1112 src_cb1 = (
unsigned char *) in_frame->data[1] + in_frame->linesize[1] * (y * 2);
1113 src_cr1 = (
unsigned char *) in_frame->data[2] + in_frame->linesize[2] * (y * 2);
1114 src_cb2 = (
unsigned char *) in_frame->data[1] + in_frame->linesize[1] * (y * 2 + 1);
1115 src_cr2 = (
unsigned char *) in_frame->data[2] + in_frame->linesize[2] * (y * 2 + 1);
1118#define WRITE_RES_YUV8P_TO_RGB(DST) {\
1123 *((uint32_t *)(void *) DST) = MK_RGBA(r, g, b, alpha_mask, 8);\
1126 *DST++ = CLAMP_FULL(r, 8);\
1127 *DST++ = CLAMP_FULL(g, 8);\
1128 *DST++ = CLAMP_FULL(b, 8);\
1141 y = (*src_y1++ - 16) *
Y_SCALE(S_DEPTH);
1148 cb = *src_cb2++ - 128;
1149 cr = *src_cr2++ - 128;
1151 y = (*src_y2++ - 16) *
Y_SCALE(S_DEPTH);
1157 y = (*src_y2++ - 16) *
Y_SCALE(S_DEPTH);
1167 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1169 yuv8p_to_rgb(420, dst_buffer, in_frame, width, height, pitch, rgb_shift,
false);
1173 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1175 yuv8p_to_rgb(420, dst_buffer, in_frame, width, height, pitch, rgb_shift,
true);
1179 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1181 yuv8p_to_rgb(422, dst_buffer, in_frame, width, height, pitch, rgb_shift,
false);
1185 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1187 yuv8p_to_rgb(422, dst_buffer, in_frame, width, height, pitch, rgb_shift,
true);
1195static inline void yuv444p_to_rgb(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1196 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
bool rgba)
1199static inline void yuv444p_to_rgb(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1200 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
bool rgba)
1205 assert((uintptr_t) dst_buffer % 4 == 0);
1207 uint32_t alpha_mask = 0xFFFFFFFFU ^ (0xFFU << rgb_shift[
R]) ^ (0xFFU << rgb_shift[
G]) ^ (0xFFU << rgb_shift[
B]);
1209 for(
int y = 0; y < height; ++y) {
1210 unsigned char *src_y = (
unsigned char *) in_frame->data[0] + in_frame->linesize[0] * y;
1211 unsigned char *src_cb = (
unsigned char *) in_frame->data[1] + in_frame->linesize[1] * y;
1212 unsigned char *src_cr = (
unsigned char *) in_frame->data[2] + in_frame->linesize[2] * y;
1213 unsigned char *dst = (
unsigned char *) dst_buffer + pitch * y;
1216 int cb = *src_cb++ - 128;
1217 int cr = *src_cr++ - 128;
1218 int y = *src_y++ *
Y_SCALE(S_DEPTH);
1223 *((uint32_t *)(
void *) dst) =
MK_RGBA(r, g, b, alpha_mask, 8);
1226 *dst++ =
CLAMP(r, 1, 254);
1227 *dst++ =
CLAMP(g, 1, 254);
1228 *dst++ =
CLAMP(b, 1, 254);
1235 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1237 yuv444p_to_rgb(dst_buffer, in_frame, width, height, pitch, rgb_shift,
false);
1241 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1243 yuv444p_to_rgb(dst_buffer, in_frame, width, height, pitch, rgb_shift,
true);
1247 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1250 for(
int y = 0; y < height / 2; ++y) {
1251 uint16_t *src_y1 = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y * 2);
1252 uint16_t *src_y2 = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * (y * 2 + 1));
1253 uint16_t *src_cb = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1254 uint16_t *src_cr = (uint16_t *)(
void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1255 uint32_t *dst1 = (uint32_t *)(
void *)(dst_buffer + (y * 2) * pitch);
1256 uint32_t *dst2 = (uint32_t *)(
void *)(dst_buffer + (y * 2 + 1) * pitch);
1259 uint32_t w0_0, w0_1, w0_2, w0_3;
1260 uint32_t w1_0, w1_1, w1_2, w1_3;
1265 w0_0 = w0_0 | (*src_y1++) << 10;
1266 w1_0 = w1_0 | (*src_y2++) << 10;
1267 w0_0 = w0_0 | (*src_cr) << 20;
1268 w1_0 = w1_0 | (*src_cr) << 20;
1273 w0_1 = w0_1 | (*src_cb) << 10;
1274 w1_1 = w1_1 | (*src_cb) << 10;
1276 w0_1 = w0_1 | (*src_y1++) << 20;
1277 w1_1 = w1_1 | (*src_y2++) << 20;
1282 w0_2 = w0_2 | (*src_y1++) << 10;
1283 w1_2 = w1_2 | (*src_y2++) << 10;
1284 w0_2 = w0_2 | (*src_cb) << 20;
1285 w1_2 = w1_2 | (*src_cb) << 20;
1290 w0_3 = w0_3 | (*src_cr) << 10;
1291 w1_3 = w1_3 | (*src_cr) << 10;
1293 w0_3 = w0_3 | (*src_y1++) << 20;
1294 w1_3 = w1_3 | (*src_y2++) << 20;
1310 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1313 for(
int y = 0; y < height; ++y) {
1314 uint16_t *src_y = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1315 uint16_t *src_cb = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1316 uint16_t *src_cr = (uint16_t *)(
void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1317 uint32_t *dst = (uint32_t *)(
void *)(dst_buffer + y * pitch);
1320 uint32_t w0_0, w0_1, w0_2, w0_3;
1323 w0_0 = w0_0 | (*src_y++) << 10;
1324 w0_0 = w0_0 | (*src_cr++) << 20;
1327 w0_1 = w0_1 | (*src_cb++) << 10;
1328 w0_1 = w0_1 | (*src_y++) << 20;
1331 w0_2 = w0_2 | (*src_y++) << 10;
1332 w0_2 = w0_2 | (*src_cb++) << 20;
1335 w0_3 = w0_3 | (*src_cr++) << 10;
1336 w0_3 = w0_3 | (*src_y++) << 20;
1347static inline void yuv444p1Xle_to_v210(
unsigned in_depth,
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1348 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1351static inline void yuv444p1Xle_to_v210(
unsigned in_depth,
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1352 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1355 for(
int y = 0; y < height; ++y) {
1356 uint16_t *src_y = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1357 uint16_t *src_cb = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1358 uint16_t *src_cr = (uint16_t *)(
void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1359 uint32_t *dst = (uint32_t *)(
void *)(dst_buffer + y * pitch);
1362 uint32_t w0_0, w0_1, w0_2, w0_3;
1364 w0_0 = ((src_cb[0] >> (in_depth - 10U)) + (src_cb[1] >> (in_depth - 10U))) / 2;
1365 w0_0 = w0_0 | (*src_y++ >> (in_depth - 10U)) << 10U;
1366 w0_0 = w0_0 | ((src_cr[0] >> (in_depth - 10U)) + (src_cr[1] >> (in_depth - 10U))) / 2 << 20U;
1371 w0_1 = w0_1 | ((src_cb[0] >> (in_depth - 10U)) + (src_cb[1] >> (in_depth - 10U))) / 2 << 10U;
1372 w0_1 = w0_1 | (*src_y++ >> (in_depth - 10U)) << 20U;
1375 w0_2 = ((src_cr[0] >> (in_depth - 10U)) + (src_cr[1] >> (in_depth - 10U))) / 2;
1376 w0_2 = w0_2 | (*src_y++ >> (in_depth - 10U)) << 10U;
1377 w0_2 = w0_2 | ((src_cb[0] >> (in_depth - 10U)) + (src_cb[1] >> (in_depth - 10U))) / 2 << 20U;
1382 w0_3 = w0_3 | ((src_cr[0] >> (in_depth - 10U)) + (src_cr[1] >> (in_depth - 10U))) / 2 << 10U;
1383 w0_3 = w0_3 | ((*src_y++ >> (in_depth - 10U))) << 20U;
1395 int width,
int height,
int pitch,
const int * __restrict rgb_shift) {
1400 int width,
int height,
int pitch,
const int * __restrict rgb_shift) {
1405 int width,
int height,
int pitch,
const int * __restrict rgb_shift) {
1410 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1413 for(
int y = 0; y < height / 2; ++y) {
1414 uint16_t *src_y1 = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y * 2);
1415 uint16_t *src_y2 = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * (y * 2 + 1));
1416 uint16_t *src_cb = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1417 uint16_t *src_cr = (uint16_t *)(
void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1418 uint8_t *dst1 = (uint8_t *)(
void *)(dst_buffer + (y * 2) * pitch);
1419 uint8_t *dst2 = (uint8_t *)(
void *)(dst_buffer + (y * 2 + 1) * pitch);
1424 tmp = *src_cb++ >> 2;
1428 *dst1++ = *src_y1++ >> 2;
1429 *dst2++ = *src_y2++ >> 2;
1431 tmp = *src_cr++ >> 2;
1435 *dst1++ = *src_y1++ >> 2;
1436 *dst2++ = *src_y2++ >> 2;
1442 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1445 for(
int y = 0; y < height; ++y) {
1446 uint16_t *src_y = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1447 uint16_t *src_cb = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1448 uint16_t *src_cr = (uint16_t *)(
void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1449 uint8_t *dst = (uint8_t *)(
void *)(dst_buffer + y * pitch);
1451 for(
int x = 0; x < width / 2; ++x) {
1452 *dst++ = *src_cb++ >> 2;
1453 *dst++ = *src_y++ >> 2;
1454 *dst++ = *src_cr++ >> 2;
1455 *dst++ = *src_y++ >> 2;
1461static inline void yuv444p1Xle_to_uyvy(
unsigned in_depth,
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1462 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1465static inline void yuv444p1Xle_to_uyvy(
unsigned in_depth,
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1466 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1469 for(
int y = 0; y < (int) height; ++y) {
1470 uint16_t *src_y = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1471 uint16_t *src_cb = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1472 uint16_t *src_cr = (uint16_t *)(
void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1473 uint8_t *dst = (uint8_t *)(
void *)(dst_buffer + y * pitch);
1476 *dst++ = (src_cb[0] + src_cb[1] + 1) / 2 >> (in_depth - 8U);
1477 *dst++ = *src_y++ >> (in_depth - 8U);
1478 *dst++ = (src_cr[0] + src_cr[1] + 1) / 2 >> (in_depth - 8U);
1479 *dst++ = *src_y++ >> (in_depth - 8U);
1487 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1493 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1499static inline void yuv444p1Xle_to_y416(
unsigned in_depth,
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1500 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1503static void yuv444p1Xle_to_y416(
unsigned in_depth,
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1504 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1506 assert((uintptr_t) dst_buffer % 2 == 0);
1507 assert((uintptr_t) in_frame->data[0] % 2 == 0);
1508 assert((uintptr_t) in_frame->data[1] % 2 == 0);
1509 assert((uintptr_t) in_frame->data[2] % 2 == 0);
1511 for(
int y = 0; y < (int) height; ++y) {
1512 uint16_t *src_y = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1513 uint16_t *src_cb = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1514 uint16_t *src_cr = (uint16_t *)(
void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1515 uint16_t *dst = (uint16_t *)(
void *)(dst_buffer + y * pitch);
1518 *dst++ = *src_cb++ << (16U - in_depth);
1519 *dst++ = *src_y++ << (16U - in_depth);
1520 *dst++ = *src_cr++ << (16U - in_depth);
1527 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1533 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1539 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1546 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
int out_bit_depth)
__attribute__((always_inline));
1549 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
int out_bit_depth)
1554 assert((uintptr_t) dst_buffer % 4 == 0);
1555 assert((uintptr_t)
frame->linesize[0] % 2 == 0);
1556 assert((uintptr_t)
frame->linesize[1] % 2 == 0);
1557 assert((uintptr_t)
frame->linesize[2] % 2 == 0);
1560 assert(out_bit_depth == 24 || out_bit_depth == 30 || out_bit_depth == 32);
1561 uint32_t alpha_mask = 0xFFFFFFFFU ^ (0xFFU << rgb_shift[
R]) ^ (0xFFU << rgb_shift[
G]) ^ (0xFFU << rgb_shift[
B]);
1562 const int bpp = out_bit_depth == 30 ? 10 : 8;
1564 for (
int y = 0; y < height / 2; ++y) {
1565 uint16_t * __restrict src_y1 = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * 2 * y);
1566 uint16_t * __restrict src_y2 = (uint16_t *)(
void *) (
frame->data[0] +
frame->linesize[0] * (2 * y + 1));
1567 uint16_t * __restrict src_cb1;
1568 uint16_t * __restrict src_cr1;
1569 uint16_t * __restrict src_cb2;
1570 uint16_t * __restrict src_cr2;
1572 src_cb1 = src_cb2 = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * y);
1573 src_cr1 = src_cr2 = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * y);
1575 src_cb1 = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * (2 * y));
1576 src_cb2 = (uint16_t *)(
void *) (
frame->data[1] +
frame->linesize[1] * (2 * y + 1));
1577 src_cr1 = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * (2 * y));
1578 src_cr2 = (uint16_t *)(
void *) (
frame->data[2] +
frame->linesize[2] * (2 * y + 1));
1580 unsigned char *dst1 = (
unsigned char *) dst_buffer + (2 * y) * pitch;
1581 unsigned char *dst2 = (
unsigned char *) dst_buffer + (2 * y + 1) * pitch;
1590# define WRITE_RES_YUV10P_TO_RGB(Y, DST) {\
1591 comp_type_t r = Y + rr;\
1592 comp_type_t g = Y + gg;\
1593 comp_type_t b = Y + bb;\
1594 r = CLAMP_FULL(r, bpp);\
1595 g = CLAMP_FULL(g, bpp);\
1596 b = CLAMP_FULL(b, bpp);\
1597 if (out_bit_depth == 32) {\
1598 *((uint32_t *)(void *) DST) = alpha_mask | (r << rgb_shift[R] | g << rgb_shift[G] | b << rgb_shift[B]);\
1600 } else if (out_bit_depth == 24) {\
1605 *((uint32_t *)(void *) (DST)) = r >> 2U | (r & 0x3U) << 14 | g >> 4U << 8U | (g & 0xFU) << 20U | b >> 6U << 16U | (b & 0x3FU) << 26U | 0x3U << 24U;\
1618 cr = *src_cr2++ - (1<<9);
1619 cb = *src_cb2++ - (1<<9);
1634#define MAKE_YUV_TO_RGB_FUNCTION_NAME(subs, out_bit_depth) yuv ## subs ## p10le_to_rgb ## out_bit_depth
1636#define MAKE_YUV_TO_RGB_FUNCTION(subs, out_bit_depth) static void MAKE_YUV_TO_RGB_FUNCTION_NAME(subs, out_bit_depth)(char * __restrict dst_buffer, AVFrame * __restrict in_frame,\
1637 int width, int height, int pitch, const int * __restrict rgb_shift) {\
1638 yuvp10le_to_rgb(subs, dst_buffer, in_frame, width, height, pitch, rgb_shift, out_bit_depth);\
1649static inline void yuv444p10le_to_rgb(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1650 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
bool rgba)
1654 int width,
int height,
int pitch,
const int * __restrict rgb_shift,
bool rgba)
1659 uint32_t alpha_mask = 0xFFFFFFFFU ^ (0xFFU << rgb_shift[
R]) ^ (0xFFU << rgb_shift[
G]) ^ (0xFFU << rgb_shift[
B]);
1661 for (
int y = 0; y < height; y++) {
1662 uint16_t *src_y = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1663 uint16_t *src_cb = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1664 uint16_t *src_cr = (uint16_t *)(
void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1665 uint8_t *dst = (uint8_t *)(
void *)(dst_buffer + y * pitch);
1668 comp_type_t cb = *src_cb++ - (1 << (S_DEPTH - 1));
1669 comp_type_t cr = *src_cr++ - (1 << (S_DEPTH - 1));
1671 (*src_y++ - (1 << (S_DEPTH - 4))) *
Y_SCALE(S_DEPTH);
1682 *(uint32_t *)(
void *) dst =
MK_RGBA(r, g, b, alpha_mask, 8);
1694 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1700 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1706static void p210le_to_v210(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1707 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1710 assert((uintptr_t) in_frame->data[0] % 2 == 0);
1711 assert((uintptr_t) in_frame->data[1] % 2 == 0);
1712 assert((uintptr_t) dst_buffer % 4 == 0);
1713 for(
int y = 0; y < height; ++y) {
1714 uint16_t *src_y = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1715 uint16_t *src_cbcr = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1716 uint32_t *dst = (uint32_t *)(
void *)(dst_buffer + y * pitch);
1719 uint32_t w0_0 = *src_cbcr >> 6;
1721 w0_0 = w0_0 | (*src_y++ >> 6) << 10;
1722 w0_0 = w0_0 | (*src_cbcr >> 6) << 20;
1725 uint32_t w0_1 = *src_y++ >> 6;
1726 w0_1 = w0_1 | (*src_cbcr >> 6) << 10;
1728 w0_1 = w0_1 | (*src_y++ >> 6) << 20;
1730 uint32_t w0_2 = *src_cbcr >> 6;
1732 w0_2 = w0_2 | (*src_y++ >> 6) << 10;
1733 w0_2 = w0_2 | (*src_cbcr >> 6) << 20;
1736 uint32_t w0_3 = *src_y++ >> 6;
1737 w0_3 = w0_3 | (*src_cbcr >> 6) << 10;
1739 w0_3 = w0_3 | (*src_y++ >> 6) << 20;
1750static void p010le_to_v210(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1751 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1754 assert((uintptr_t) in_frame->data[0] % 2 == 0);
1755 assert((uintptr_t) in_frame->data[1] % 2 == 0);
1756 assert((uintptr_t) dst_buffer % 4 == 0 && pitch % 4 == 0);
1757 for(
int y = 0; y < height / 2; ++y) {
1758 uint16_t *src_y1 = (uint16_t *)(
void *) (in_frame->data[0] + in_frame->linesize[0] * y * 2);
1759 uint16_t *src_y2 = (uint16_t *)(
void *) (in_frame->data[0] + in_frame->linesize[0] * (y * 2 + 1));
1760 uint16_t *src_cbcr = (uint16_t *)(
void *) (in_frame->data[1] + in_frame->linesize[1] * y);
1761 uint32_t *dst1 = (uint32_t *)(
void *)(dst_buffer + (y * 2) * pitch);
1762 uint32_t *dst2 = (uint32_t *)(
void *)(dst_buffer + (y * 2 + 1) * pitch);
1765 uint32_t w0_0, w0_1, w0_2, w0_3;
1766 uint32_t w1_0, w1_1, w1_2, w1_3;
1768 w0_0 = *src_cbcr >> 6;
1769 w1_0 = *src_cbcr >> 6;
1771 w0_0 = w0_0 | (*src_y1++ >> 6) << 10;
1772 w1_0 = w1_0 | (*src_y2++ >> 6) << 10;
1773 w0_0 = w0_0 | (*src_cbcr >> 6) << 20;
1774 w1_0 = w1_0 | (*src_cbcr >> 6) << 20;
1777 w0_1 = *src_y1++ >> 6;
1778 w1_1 = *src_y2++ >> 6;
1779 w0_1 = w0_1 | (*src_cbcr >> 6) << 10;
1780 w1_1 = w1_1 | (*src_cbcr >> 6) << 10;
1782 w0_1 = w0_1 | (*src_y1++ >> 6) << 20;
1783 w1_1 = w1_1 | (*src_y2++ >> 6) << 20;
1785 w0_2 = *src_cbcr >> 6;
1786 w1_2 = *src_cbcr >> 6;
1788 w0_2 = w0_2 | (*src_y1++ >> 6) << 10;
1789 w1_2 = w1_2 | (*src_y2++ >> 6) << 10;
1790 w0_2 = w0_2 | (*src_cbcr >> 6) << 20;
1791 w1_2 = w1_2 | (*src_cbcr >> 6) << 20;
1794 w0_3 = *src_y1++ >> 6;
1795 w1_3 = *src_y2++ >> 6;
1796 w0_3 = w0_3 | (*src_cbcr >> 6) << 10;
1797 w1_3 = w1_3 | (*src_cbcr >> 6) << 10;
1799 w0_3 = w0_3 | (*src_y1++ >> 6) << 20;
1800 w1_3 = w1_3 | (*src_y2++ >> 6) << 20;
1815static void p010le_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1816 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1819 for(
int y = 0; y < height / 2; ++y) {
1820 uint16_t *src_y1 = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y * 2);
1821 uint16_t *src_y2 = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * (y * 2 + 1));
1822 uint16_t *src_cbcr = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1823 uint8_t *dst1 = (uint8_t *)(
void *)(dst_buffer + (y * 2) * pitch);
1824 uint8_t *dst2 = (uint8_t *)(
void *)(dst_buffer + (y * 2 + 1) * pitch);
1829 tmp = *src_cbcr++ >> 8;
1833 *dst1++ = *src_y1++ >> 8;
1834 *dst2++ = *src_y2++ >> 8;
1836 tmp = *src_cbcr++ >> 8;
1840 *dst1++ = *src_y1++ >> 8;
1841 *dst2++ = *src_y2++ >> 8;
1847static void p210le_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1848 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1851 assert((uintptr_t) in_frame->data[0] % 2 == 0);
1852 assert((uintptr_t) in_frame->data[1] % 2 == 0);
1853 for(
int y = 0; y < height; ++y) {
1854 uint16_t *src_y = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1855 uint16_t *src_cbcr = (uint16_t *)(
void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1856 uint8_t *dst = (uint8_t *)(
void *)(dst_buffer + y * pitch);
1859 *dst = *src_cbcr++ >> 8;
1860 *dst++ = *src_y++ >> 8;
1861 *dst++ = *src_cbcr++ >> 8;
1862 *dst++ = *src_y++ >> 8;
1869static void xv30_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1870 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1873 assert((uintptr_t) in_frame->data[0] % 4 == 0);
1874 for (ptrdiff_t y = 0; y < height; ++y) {
1875 uint32_t *src = (
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1876 uint8_t *dst = (
void *)(dst_buffer + y * pitch);
1879 uint32_t in1 = *src++;
1880 uint32_t in2 = *src++;
1881 *dst++ = (((in1 >> 2U) & 0xFFU) + (((in2 >> 2U) & 0xFFU) + 1)) >> 1;
1882 *dst++ = (in1 >> 12U) & 0xFFU;
1883 *dst++ = (((in1 >> 22U) & 0xFFU) + (((in2 >> 22U) & 0xFFU) + 1)) >> 1;
1884 *dst++ = (in2 >> 12U) & 0xFFU;
1887 uint32_t last = *src++;
1888 *dst++ = (last >> 2U) & 0xFFU;
1889 *dst++ = (last >> 12U) & 0xFFU;
1890 *dst++ = (last >> 22U) & 0xFFU;
1896static void xv30_to_v210(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1897 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1900 assert((uintptr_t) in_frame->data[0] % 4 == 0);
1901 assert((uintptr_t) dst_buffer % 4 == 0 && pitch % 4 == 0);
1902 for(
int y = 0; y < height; ++y) {
1903 uint32_t *src = (uint32_t *)(
void *) (in_frame->data[0] + in_frame->linesize[0] * y);
1904 uint32_t *dst = (uint32_t *)(
void *)(dst_buffer + y * pitch);
1909 u = ((in0 & 0x3FFU) + (in1 & 0x3FFU) + 1) >> 1; \
1910 y0 = (in0 >> 10U) & 0x3FFU; \
1911 v = ((in0 >> 20U & 0x3FFU) + ((in1 >> 20U & 0x3FFU) + 1)) >> 1; \
1912 y1 = (in1 >> 10U) & 0x3FFU; \
1916 uint32_t u, y0, v, y1;
1919 *dst++ = v << 20U | y0 << 10U | u;
1922 *dst++ = y0 << 20U | u << 10U | tmp;
1923 tmp = y1 << 10U | v;
1925 *dst++ = u << 20U | tmp;
1926 *dst++ = y1 << 20U | v << 10U | y0;
1932static void xv30_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1933 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1936 assert((uintptr_t) in_frame->data[0] % 4 == 0);
1937 assert((uintptr_t) dst_buffer % 2 == 0 && pitch % 2 == 0);
1938 for (ptrdiff_t y = 0; y < height; ++y) {
1939 uint32_t *src = (
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1940 uint16_t *dst = (
void *)(dst_buffer + y * pitch);
1942 uint32_t in = *src++;
1943 *dst++ = (in & 0x3FFU) << 6U;
1944 *dst++ = ((in >> 10U) & 0x3FFU) << 6U;
1945 *dst++ = ((in >> 20U) & 0x3FFU) << 6U;
1953static void y210_to_v210(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1954 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1957 assert((uintptr_t) in_frame->data[0] % 2 == 0);
1958 assert((uintptr_t) dst_buffer % 4 == 0 && pitch % 4 == 0);
1959 for(
int y = 0; y < height; ++y) {
1960 uint16_t *src = (uint16_t *)(
void *) (in_frame->data[0] + in_frame->linesize[0] * y);
1961 uint32_t *dst = (uint32_t *)(
void *)(dst_buffer + y * pitch);
1965 y0 = *src++ >> 6U; \
1967 y1 = *src++ >> 6U; \
1971 unsigned y0, u, y1, v;
1975 *dst++ = v << 20U | y0 << 10U | u;
1978 *dst++ = y0 << 20U | u << 10U | tmp;
1979 tmp = y1 << 10U | v;
1981 *dst++ = u << 20U | tmp;
1982 *dst++ = y1 << 20U | v << 10U | y0;
1988static void y210_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1989 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
1992 assert((uintptr_t) in_frame->data[0] % 2 == 0);
1993 assert((uintptr_t) dst_buffer % 2 == 0 && pitch % 2 == 0);
1994 for(
int y = 0; y < height; ++y) {
1995 uint16_t *src = (
void *) (in_frame->data[0] + in_frame->linesize[0] * y);
1996 uint16_t *dst = (
void *) (dst_buffer + y * pitch);
1999 unsigned y0, u, y1, v;
2017static void y210_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2018 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
2021 for(
int y = 0; y < height; ++y) {
2022 uint8_t *src = (
void *) (in_frame->data[0] + in_frame->linesize[0] * y);
2023 uint8_t *dst = (
void *) (dst_buffer + y * pitch);
2026 unsigned y0, u, y1, v;
2043static void av_vdpau_to_ug_vdpau(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2044 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
2053 hw_vdpau_frame *out = (hw_vdpau_frame *)(
void *) dst_buffer;
2067 av_frame_free(&drm_frame->
av_frame);
2075 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
2088 AVDRMFrameDescriptor *av_drm_frame = (
struct AVDRMFrameDescriptor *) in_frame->data[0];
2089 assert(av_drm_frame->nb_layers == 1);
2090 AVDRMLayerDescriptor *layer = &av_drm_frame->layers[0];
2092 out->
fd_count = av_drm_frame->nb_objects;
2094 for(
int i = 0; i < av_drm_frame->nb_objects; i++){
2095 out->
dmabuf_fds[i] = av_drm_frame->objects[i].fd;
2098 out->
planes = layer->nb_planes;
2101 for(
int i = 0; i < layer->nb_planes; i++){
2102 out->
fd_indices[i] = layer->planes[i].object_index;
2103 out->
modifiers[i] = av_drm_frame->objects[layer->planes[i].object_index].format_modifier;
2104 out->
offsets[i] = layer->planes[i].offset;
2105 out->
pitches[i] = layer->planes[i].pitch;
2108 out->
av_frame = av_frame_clone(in_frame);
2112static void ayuv64_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2113 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
2116 for(
int y = 0; y < height; ++y) {
2117 uint8_t *src = (uint8_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
2118 uint8_t *dst = (uint8_t *)(
void *)(dst_buffer + y * pitch);
2121 *dst++ = (src[1] + src[9] / 2);
2123 *dst++ = (src[5] + src[13] / 2);
2129static void ayuv64_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2130 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
2133 assert((uintptr_t) in_frame->data[0] % 2 == 0);
2134 assert((uintptr_t) dst_buffer % 2 == 0);
2135 for(
int y = 0; y < height; ++y) {
2136 uint16_t *src = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
2137 uint16_t *dst = (uint16_t *)(
void *)(dst_buffer + y * pitch);
2149static void ayuv64_to_v210(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2150 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
2153 assert((uintptr_t) in_frame->data[0] % 2 == 0);
2154 assert((uintptr_t) dst_buffer % 4 == 0);
2155 for(
int y = 0; y < height; ++y) {
2156 uint16_t *src = (uint16_t *)(
void *)(in_frame->data[0] + in_frame->linesize[0] * y);
2157 uint32_t *dst = (uint32_t *)(
void *)(dst_buffer + y * pitch);
2162 w = ((src[2] >> 6U) + (src[6] >> 6U)) / 2;
2163 w = w | (src[1] >> 6U) << 10U;
2164 w = w | ((src[3] >> 6U) + (src[7] >> 6U)) / 2 << 20U;
2169 w = w | ((src[2] >> 6U) + (src[6] >> 6U)) / 2 << 10U;
2170 w = w | (src[1] >> 6U) << 20U;
2173 w = ((src[3] >> 6U) + (src[7] >> 6U)) / 2;
2174 w = w | (src[5] >> 6U) << 10U;
2176 w = w | ((src[2] >> 6U) + (src[6] >> 6U)) / 2 << 20U;
2180 w = w | ((src[3] >> 6U) + (src[7] >> 6U)) / 2 << 10U;
2181 w = w | ((src[5] >> 6U)) << 20U;
2188static void vuya_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2189 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
__attribute__((unused));
2190static void vuya_to_uyvy(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2191 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
2194 for (ptrdiff_t y = 0; y < height; ++y) {
2195 unsigned char *src = in_frame->data[0] + in_frame->linesize[0] * y;
2196 unsigned char *dst = (
void *) (dst_buffer + pitch * y);
2199 *dst++ = (src[1] + src[5] + 1U) >> 1U;
2201 *dst++ = (src[0] + src[4] + 1U) >> 1U;
2205 if (width % 2 == 1) {
2215static inline void vuyax_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2216 int width,
int height,
int pitch,
bool use_alpha)
2219static inline void vuyax_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2220 int width,
int height,
int pitch,
bool use_alpha)
2222 assert((uintptr_t) dst_buffer % 2 == 0);
2223 for (ptrdiff_t y = 0; y < height; ++y) {
2224 unsigned char *src = in_frame->data[0] + in_frame->linesize[0] * y;
2225 uint16_t *dst = (
void *) (dst_buffer + pitch * y);
2228 *dst++ = src[1] << 8U;
2229 *dst++ = src[2] << 8U;
2230 *dst++ = src[0] << 8U;
2231 *dst++ = use_alpha ? src[3] << 8U : 0xFFFF;
2236static void vuya_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2237 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
__attribute__((unused));
2238static void vuya_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2239 int width,
int height,
int pitch,
const int * __restrict rgb_shift) {
2241 vuyax_to_y416(dst_buffer, in_frame, width, height, pitch,
true);
2243static void vuyx_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2244 int width,
int height,
int pitch,
const int * __restrict rgb_shift)
__attribute__((unused));
2245static void vuyx_to_y416(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
2246 int width,
int height,
int pitch,
const int * __restrict rgb_shift) {
2248 vuyax_to_y416(dst_buffer, in_frame, width, height, pitch,
false);
2251typedef void av_to_uv_convert_f(
char * __restrict dst_buffer, AVFrame * __restrict in_frame,
int width,
int height,
int pitch,
const int * __restrict rgb_shift);
2272 {AV_PIX_FMT_YUV420P10LE,
RGB, yuv420p10le_to_rgb24},
2273 {AV_PIX_FMT_YUV420P10LE,
RGBA, yuv420p10le_to_rgb32},
2274 {AV_PIX_FMT_YUV420P10LE,
R10k, yuv420p10le_to_rgb30},
2277 {AV_PIX_FMT_YUV422P10LE,
RGB, yuv422p10le_to_rgb24},
2278 {AV_PIX_FMT_YUV422P10LE,
RGBA, yuv422p10le_to_rgb32},
2279 {AV_PIX_FMT_YUV422P10LE,
R10k, yuv422p10le_to_rgb30},
2289 {AV_PIX_FMT_P210LE,
v210, p210le_to_v210},
2290 {AV_PIX_FMT_P210LE,
UYVY, p210le_to_uyvy},
2293 {AV_PIX_FMT_XV30,
UYVY, xv30_to_uyvy},
2294 {AV_PIX_FMT_XV30,
v210, xv30_to_v210},
2295 {AV_PIX_FMT_XV30,
Y416, xv30_to_y416},
2296 {AV_PIX_FMT_Y212,
UYVY, y210_to_uyvy},
2297 {AV_PIX_FMT_Y212,
v210, y210_to_v210},
2298 {AV_PIX_FMT_Y212,
Y416, y210_to_y416},
2302 {AV_PIX_FMT_Y210,
UYVY, y210_to_uyvy},
2303 {AV_PIX_FMT_Y210,
v210, y210_to_v210},
2304 {AV_PIX_FMT_Y210,
Y416, y210_to_y416},
2389 {AV_PIX_FMT_VDPAU,
HW_VDPAU, av_vdpau_to_ug_vdpau},
2393#define AV_TO_UV_CONVERSION_COUNT (sizeof av_to_uv_conversions / sizeof av_to_uv_conversions[0])
2416 return ret != 0 ? ret : (int) *codec_a - (
int) *codec_b;
2422 size_t convs_count = 0;
2429 qsort_s(convs, convs_count,
sizeof convs[0], compare_convs, &src_desc);
2430 for (
size_t i = 0; i < convs_count; ++i) {
2434 *av_convert = convs[i].
convert;
2436 if (intermediate_c) {
2437 *intermediate_c = convs[i].
uv_codec;
2448 if (s == NULL || *s == NULL) {
2471static enum AVPixelFormat
2474 for (; *fmts != AV_PIX_FMT_NONE; fmts++) {
2475 for (
unsigned i = 0;
2484 return AV_PIX_FMT_NONE;
2492 enum AVPixelFormat f[2] = { av_codec, AV_PIX_FMT_NONE };
2497 MSG(NOTICE,
"Using CUDA FFmpeg conversions.\n");
2500 MSG(ERROR,
"Unable to initialize CUDA conv state!\n");
2505 if (mapped_pix_fmt == uv_codec) {
2513 if (mapped_pix_fmt !=
VC_NONE) {
2523 if (conversions->av_codec == av_codec &&
2524 conversions->uv_codec == uv_codec) {
2525 ret->
convert = conversions->convert;
2534 &intermediate, &av_convert);
2559 for (
const enum AVPixelFormat *fmt_it =
fmt; *fmt_it != AV_PIX_FMT_NONE; fmt_it++) {
2561 if (!use_hwaccel && (av_pix_fmt_desc_get(*fmt_it)->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
2568 *ugc = mapped_pix_fmt;
2569 return AV_PIX_FMT_NONE;
2578 if (c->av_codec == *fmt_it && *ugc == c->uv_codec) {
2592 int usable_convs_count = 0;
2594 if (c->av_codec == *fmt_it) {
2598 if (usable_convs_count == 0) {
2602 qsort_s(usable_convs, usable_convs_count,
sizeof usable_convs[0], compare_convs, &src_desc);
2604 return AV_PIX_FMT_NONE;
2607 return AV_PIX_FMT_NONE;
2614 if (sel_fmt == AV_PIX_FMT_NONE) {
2622 ug_codecs[ugc_count++] = c;
2628 qsort_s(ug_codecs, ugc_count,
sizeof ug_codecs[0], compare_codecs,
2630 return ug_codecs[0];
2653 *av_conv = calloc(1,
sizeof **av_conv);
2654 (*av_conv)->dst_pixfmt = color_spec;
2664 (*av_conv)->dec = dec;
2665 return AV_PIX_FMT_RGB48LE;
2667 (*av_conv)->dec = dec;
2668 return AV_PIX_FMT_RGB24;
2673 (*av_conv)->dec = dec;
2674 return AV_PIX_FMT_XV36;
2678 (*av_conv)->dec = dec;
2679 return AV_PIX_FMT_UYVY422;
2682 if (c->uv_codec == color_spec) {
2683 memset(*av_conv, 0,
sizeof **av_conv);
2684 (*av_conv)->convert = c->convert;
2690 return AV_PIX_FMT_NONE;
2695 AVFrame *__restrict in_frame,
int width,
int height,
int pitch,
2696 const int *__restrict rgb_shift)
2698 unsigned char *dec_input = in_frame->data[0];
2699 size_t src_linesize = in_frame->linesize[0];
2700 unsigned char *tmp = NULL;
2704 s->
convert(dst_buffer, in_frame, width, height, pitch, rgb_shift);
2709 dec_input = tmp = malloc(
2713 s->
convert((
char *) dec_input, in_frame, width, height,
2714 src_linesize, default_rgb_shift);
2720 for (ptrdiff_t i = 0; i < height; ++i) {
2721 s->
dec((
unsigned char *) dst_buffer + i * pitch,
2722 dec_input + i * src_linesize, dst_size,
2723 rgb_shift[0], rgb_shift[1], rgb_shift[2]);
2732 for (ptrdiff_t i = 0; i < height; ++i) {
2733 memcpy(dst_buffer + i * pitch, in_frame->data[0] + i * in_frame->linesize[0], linesize);
2761 if (
convert->cuda_conv_state != NULL) {
2776 AVFrame parts[cpu_count];
2777 for (
int i = 0; i < cpu_count; ++i) {
2778 int row_height = (
height / cpu_count) & ~1;
2779 unsigned char *part_dst =
2780 (
unsigned char *) dst + (
size_t) i * row_height *
pitch;
2781 memcpy(parts[i].linesize, in->linesize,
sizeof in->linesize);
2782 const AVPixFmtDescriptor *fmt_desc =
2783 av_pix_fmt_desc_get(in->format);
2784 for (
int plane = 0; plane < AV_NUM_DATA_POINTERS; ++plane) {
2785 if (in->data[plane] == NULL) {
2788 parts[i].data[plane] =
2790 ((i * row_height * in->linesize[plane]) >>
2791 (plane == 0 ? 0 : fmt_desc->log2_chroma_h));
2793 if (i == cpu_count - 1) {
2794 row_height =
height - row_height * (cpu_count - 1);
2804#pragma GCC diagnostic pop
struct video_frame * frame
int vc_get_linesize(unsigned int width, codec_t codec)
const char * get_codec_name(codec_t codec)
#define Y_SCALE(in_depth)
#define YCBCR_TO_R_709_SCALED(in_depth, y, cb, cr)
#define YCBCR_TO_G_709_SCALED(in_depth, y, cb, cr)
#define CLAMP_FULL(val, depth)
#define YCBCR_TO_B_709_SCALED(in_depth, y, cb, cr)
void log_msg(int level, const char *format,...)
#define DEBUG_TIMER_START(name)
#define DEBUG_TIMER_STOP(name)
#define LOG_LEVEL_ERROR
general errors
#define LOG_LEVEL_VERBOSE
static void gbrp16le_to_rgba(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv420p10le_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p10le_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift, bool rgba)
av_to_uv_convert_t * get_av_to_uv_conversion(int av_codec, codec_t uv_codec)
static decoder_t get_av_and_uv_conversion(enum AVPixelFormat av_codec, codec_t uv_codec, codec_t *intermediate_c, av_to_uv_convert_fp *av_convert)
static void * convert_task(void *arg)
void av_to_uv_convert_f(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
enum AVPixelFormat lavd_get_av_to_ug_codec(const enum AVPixelFormat *fmt, codec_t c, bool use_hwaccel)
codec_t get_best_ug_codec_to_av(const enum AVPixelFormat *fmt, bool use_hwaccel)
static void yuvp10le_to_rgb(int subsampling, char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift, int out_bit_depth)
static void yuv422p_to_rgb32(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
void av_to_uv_conversion_destroy(av_to_uv_convert_t **s)
static void gbrpXXle_to_rg48(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, unsigned int in_depth)
static void nv12_to_rgb24(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv422p10le_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p10le_to_rg48(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp16le_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
enum AVPixelFormat pick_av_convertible_to_ug(codec_t color_spec, av_to_uv_convert_t **av_conv)
static void yuv444p10le_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p12le_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp12le_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p10le_to_r10k(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
#define AV_TO_UV_CONVERSION_COUNT
static void yuv444p10le_to_r12l(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static const struct av_to_uv_conversion * av_to_uv_conversions_end
static void gbrp10le_to_rg48(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p12le_to_r10k(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p10le_to_rgb32(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void vuyx_to_y416(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift) __attribute__((unused))
static void rgb24_to_rgb32(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p16le_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv422p10le_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p12le_to_r12l(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static enum AVPixelFormat get_ug_codec_to_av(const enum AVPixelFormat *fmt, codec_t *ugc, bool use_hwaccel)
static void yuv444p16le_to_r12l(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void rgb48le_to_r12l(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444pXXle_to_rg48(int depth, char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p_to_rgb24(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp16le_to_rg48(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp10le_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static codec_t probe_cuda_ug_to_av(const enum AVPixelFormat *fmts)
#define MAKE_YUV_TO_RGB_FUNCTION(subs, out_bit_depth)
static void yuv420p_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void nv12_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift, bool rgba)
static void ayuv64_to_y416(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void hw_drm_recycle_callback(struct video_frame *frame)
static void yuv444p10le_to_y416(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrpXXle_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift, unsigned int in_depth)
static void vuya_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift) __attribute__((unused))
static void gbrap_to_rgb_rgba(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift, int comp_count)
static void yuv444p12le_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void nv12_to_rgb32(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p16le_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp16le_to_r12l(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void vuya_to_y416(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift) __attribute__((unused))
static const struct av_to_uv_conversion av_to_uv_conversions[]
static void memcpy_data(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift) __attribute__((unused))
static void yuv420p10le_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444pXXle_to_r10k(int depth, char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv420p_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void ayuv64_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv422p_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void vuyax_to_y416(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, bool use_alpha)
static void yuv444p16le_to_y416(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p1Xle_to_y416(unsigned in_depth, char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp_to_rgba(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static enum AVPixelFormat get_first_supported_cuda(const enum AVPixelFormat *fmts)
#define WRITE_RES_YUV8P_TO_RGB(DST)
static void yuv444p16le_to_rg48(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp10le_to_rgba(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void av_drm_prime_to_ug_drm_prime(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv420p_to_rgb24(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void nv12_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp16le_to_r10k(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p_to_rgb32(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static bool cuda_conv_enabled()
static void gbrp12le_to_rgba(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp12le_to_r10k(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift, bool rgba)
static void rgb24_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void ayuv64_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv420p_to_rgb32(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
#define WRITE_RES_YUV10P_TO_RGB(Y, DST)
static void yuv444p1Xle_to_v210(unsigned in_depth, char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv8p_to_rgb(int subsampling, char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift, bool rgba)
static void yuv444p_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp12le_to_rg48(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrap_to_rgba(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p12le_to_y416(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrpXXle_to_rgba(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift, unsigned int in_depth)
static void yuv444p16le_to_r10k(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrpXXle_to_r10k(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift, unsigned int in_depth)
static void yuv444p1Xle_to_uyvy(unsigned in_depth, char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void p010le_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
void av_to_uv_convert(const av_to_uv_convert_t *convert, char *dst, AVFrame *in, int width, int height, int pitch, const int rgb_shift[3])
#define MK_RGBA(r, g, b, alpha_mask, depth)
static void gbrap_to_rgb(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void do_av_to_uv_convert(const av_to_uv_convert_t *s, char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv422p_to_rgb24(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrp12le_to_r12l(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
av_to_uv_convert_f * av_to_uv_convert_fp
static void gbrp10le_to_r10k(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void p010le_to_v210(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p12le_to_rg48(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void gbrpXXle_to_r12l(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift, unsigned int in_depth)
static void yuv444p10le_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444pXXle_to_r12l(int depth, char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv422p_to_uyvy(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void rgb48le_to_rgba(char *__restrict dst_buffer, AVFrame *__restrict frame, int width, int height, int pitch, const int *__restrict rgb_shift)
static void yuv444p10le_to_rgb24(char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
void av_to_uv_convert_cuda(struct av_to_uv_convert_cuda *state, char *__restrict dst_buffer, AVFrame *__restrict in_frame, int width, int height, int pitch, const int *__restrict rgb_shift)
struct av_to_uv_convert_cuda * get_av_to_uv_cuda_conversion(enum AVPixelFormat av_codec, codec_t uv_codec)
void av_to_uv_conversion_cuda_destroy(struct av_to_uv_convert_cuda **s)
static enum AVPixelFormat from_lavc_cuda_supp_formats[]
bool cuda_devices_explicit
–cuda-device/-D specified expilcitly
void hw_vdpau_recycle_callback(struct video_frame *frame)
void hw_vdpau_copy_callback(struct video_frame *frame)
void hw_vdpau_frame_init(hw_vdpau_frame *frame)
hw_vdpau_frame * hw_vdpau_frame_from_avframe(hw_vdpau_frame *dst, const AVFrame *src)
This file contains functions related to hw acceleration.
struct pixfmt_desc av_pixfmt_get_desc(enum AVPixelFormat pixfmt)
#define CLAMP(x, low, high)
int get_cpu_core_count(void)
static void vc_copylineRGBtoUYVY(unsigned char *__restrict dst, const unsigned char *__restrict src, int dst_len, int rshift, int gshift, int bshift)
Converts RGB to UYVY.
decoder_t get_decoder_from_to(codec_t in, codec_t out)
static void vc_copylineRG48toR12L(unsigned char *__restrict dst, const unsigned char *__restrict src, int dst_len, int rshift, int gshift, int bshift)
Converts RG48 to R12L. Converts 16-bit RGB to 12-bit packed RGB in full range (compatible with SMPTE ...
static void vc_copylineRG48toRGBA(unsigned char *__restrict dst, const unsigned char *__restrict src, int dst_len, int rshift, int gshift, int bshift)
decoder_func_t vc_copylineRGBtoRGBA
decoder_func_t * decoder_t
#define QSORT_S_COMP_DEFINE(name, a, b, context)
struct __attribute__((packed))
av_to_uv_convert_fp convert
enum AVPixelFormat av_codec
av_to_uv_convert_fp convert
struct av_to_uv_convert_cuda * cuda_conv_state
const av_to_uv_convert_t * convert
struct AVFrame * av_frame
int depth
bit depth; 0 means that whole struct is undefined
char * data
Raw tile data. Pointer must be at least 4B aligned.
Struct containing callbacks of a video_frame.
void(* recycle)(struct video_frame *)
void(* copy)(struct video_frame *)
Struct video_frame represents a video frame and contains video description.
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
struct video_frame_callbacks callbacks
@ R10k
RGB 10-bit packed - RGBX, big-endian (2 bit padding)
@ RGB
RGB 8-bit (packed into 24-bit word)
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
@ VIDEO_CODEC_NONE
dummy color spec
@ HW_VDPAU
VDPAU hardware surface.
@ RG48
16-bit RGB little-endian (RlRhGl...)
@ Y416
interleaved little-endian YCbCr 4444 16-bit - UYVA
@ Y216
YCbCr 422 16-bit little-endian - Y0 Cb Y1 Cr.
@ R12L
RGB 12-bit packed, little-endian.
@ DRM_PRIME
DRM Prime buffer, data contains struct drm_prime_frame.
@ RGBA
RGBA 8-bit, big-endian.
@ v210
YCbCr 422 10-bit - xVY0U|xY2UY1|xUY3V|xY5VY4, little-endian (2 bit padding /'x'/),...
enum AVPixelFormat get_ug_to_av_pixfmt(codec_t ug_codec)
codec_t get_av_to_ug_pixfmt(enum AVPixelFormat av_pixfmt)
This is an umbrella header for video functions.
struct pixfmt_desc get_pixfmt_desc(codec_t pixfmt)
bool is_codec_opaque(codec_t codec)
int vc_get_size(unsigned int width, codec_t codec)
void watch_pixfmt_degrade(const char *mod_name, struct pixfmt_desc desc_src, struct pixfmt_desc desc_dst)
bool codec_is_const_size(codec_t codec)
Returns TRUE if specified pixelformat has constant size regardles of resolution. If so the block_size...
bool codec_is_planar(codec_t codec)
int compare_pixdesc(const struct pixfmt_desc *desc_a, const struct pixfmt_desc *desc_b, const struct pixfmt_desc *src_desc)
size_t vc_get_datalen(unsigned int width, unsigned int height, codec_t codec)
void task_run_parallel(runnable_t task, int worker_count, void *data, size_t data_size, void **res)