53#define __STDC_WANT_LIB_EXT1__ 1
83#define BYTE_SWAP(x) (3 - x)
89static void vc_deinterlace_aligned(
unsigned char *src,
long src_linesize,
int lines);
90static void vc_deinterlace_unaligned(
unsigned char *src,
long src_linesize,
int lines);
116#define HW_VDPAU_FRAME_SZ sizeof(hw_vdpau_frame)
118#define HW_VDPAU_FRAME_SZ 0
123 0, 0, 0.0, 0, 0,
FALSE,
FALSE,
FALSE,
FALSE, 0, NULL},
124 [
RGBA] = {
"RGBA",
"Red Green Blue Alpha 32bit",
125 to_fourcc(
'R',
'G',
'B',
'A'), 4, 1, 1, 8,
TRUE,
FALSE,
FALSE,
FALSE, 4444,
"rgba"},
126 [
UYVY] = {
"UYVY",
"YUV 4:2:2",
127 to_fourcc(
'U',
'Y',
'V',
'Y'), 4, 2, 2, 8,
FALSE,
FALSE,
FALSE,
FALSE, 4220,
"yuv"},
128 [
YUYV] = {
"YUYV",
"YUV 4:2:2",
129 to_fourcc(
'Y',
'U',
'Y',
'V'), 4, 2, 2, 8,
FALSE,
FALSE,
FALSE,
FALSE, 4220,
"yuv"},
130 [
R10k] = {
"R10k",
"10-bit RGB 4:4:4",
131 to_fourcc(
'R',
'1',
'0',
'k'), 4, 1, 64, 10,
TRUE,
FALSE,
FALSE,
FALSE, 4440,
"r10k"},
132 [
R12L] = {
"R12L",
"12-bit packed RGB 4:4:4 little-endian",
133 to_fourcc(
'R',
'1',
'2',
'l'), 36, 8, 8, 12,
TRUE,
FALSE,
FALSE,
FALSE, 4440,
"r12l"},
134 [
v210] = {
"v210",
"10-bit YUV 4:2:2",
135 to_fourcc(
'v',
'2',
'1',
'0'), 16, 6, 48, 10,
FALSE,
FALSE,
FALSE,
FALSE, 4220,
"v210"},
136 [
DVS10] = {
"DVS10",
"Centaurus 10bit YUV 4:2:2",
137 to_fourcc(
'D',
'S',
'1',
'0'), 16, 6, 48, 10,
FALSE,
FALSE,
FALSE,
FALSE, 4220,
"dvs10"},
138 [
DXT1] = {
"DXT1",
"S3 Compressed Texture DXT1",
139 to_fourcc(
'D',
'X',
'T',
'1'), 1, 2, 0, 2,
TRUE,
TRUE,
FALSE,
FALSE, 0,
"dxt1"},
140 [
DXT1_YUV] = {
"DXT1_YUV",
"S3 Compressed Texture DXT1 YUV",
141 to_fourcc(
'D',
'X',
'T',
'Y'), 1, 2, 0, 2,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"dxt1y"},
142 [
DXT5] = {
"DXT5",
"S3 Compressed Texture DXT5 YCoCg",
143 to_fourcc(
'D',
'X',
'T',
'5'), 1, 1, 0, 4,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"yog"},
144 [
RGB] = {
"RGB",
"Red Green Blue 24bit",
145 to_fourcc(
'R',
'G',
'B',
'2'), 3, 1, 1, 8,
TRUE,
FALSE,
FALSE,
FALSE, 4440,
"rgb"},
146 [
JPEG] = {
"JPEG",
"JPEG",
147 to_fourcc(
'J',
'P',
'E',
'G'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"jpg"},
148 [
RAW] = {
"raw",
"Raw SDI video",
149 to_fourcc(
'r',
'a',
'w',
's'), 1, 1, 0, 0,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"raw"},
150 [
H264] = {
"H.264",
"H.264/AVC",
151 to_fourcc(
'A',
'V',
'C',
'1'), 1, 1, 0, 8,
FALSE,
TRUE,
TRUE,
FALSE, 0,
"h264"},
152 [
H265] = {
"H.265",
"H.265/HEVC",
153 to_fourcc(
'H',
'E',
'V',
'C'), 1, 1, 0, 8,
FALSE,
TRUE,
TRUE,
FALSE, 0,
"h265"},
154 [
MJPG] = {
"MJPEG",
"MJPEG",
155 to_fourcc(
'M',
'J',
'P',
'G'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"jpg"},
156 [
VP8] = {
"VP8",
"Google VP8",
157 to_fourcc(
'V',
'P',
'8',
'0'), 1, 1, 0, 8,
FALSE,
TRUE,
TRUE,
FALSE, 0,
"vp8"},
158 [
VP9] = {
"VP9",
"Google VP9",
159 to_fourcc(
'V',
'P',
'9',
'0'), 1, 1, 0, 8,
FALSE,
TRUE,
TRUE,
FALSE, 0,
"vp9"},
160 [
BGR] = {
"BGR",
"Blue Green Red 24bit",
161 to_fourcc(
'B',
'G',
'R',
'2'), 3, 1, 1, 8,
TRUE,
FALSE,
FALSE,
FALSE, 4440,
"bgr"},
162 [
J2K] = {
"J2K",
"JPEG 2000",
163 to_fourcc(
'M',
'J',
'2',
'C'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"j2k"},
164 [
J2KR] = {
"J2KR",
"JPEG 2000 RGB",
165 to_fourcc(
'M',
'J',
'2',
'R'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"j2k"},
166 [
HW_VDPAU] = {
"HW_VDPAU",
"VDPAU hardware surface",
167 to_fourcc(
'V',
'D',
'P',
'S'),
HW_VDPAU_FRAME_SZ, 1, 0, 8,
FALSE,
TRUE,
FALSE,
TRUE, 4440,
"vdpau"},
168 [
HFYU] = {
"HFYU",
"HuffYUV",
169 to_fourcc(
'H',
'F',
'Y',
'U'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"hfyu"},
170 [
FFV1] = {
"FFV1",
"FFV1",
171 to_fourcc(
'F',
'F',
'V',
'1'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"ffv1"},
172 [
CFHD] = {
"CFHD",
"Cineform",
173 to_fourcc(
'C',
'F',
'H',
'D'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"cfhd"},
174 [
RG48] = {
"RG48",
"16-bit RGB little-endian",
175 to_fourcc(
'R',
'G',
'4',
'8'), 6, 1, 1, 16,
TRUE,
FALSE,
FALSE,
FALSE, 4440,
"rg48"},
176 [
AV1] = {
"AV1",
"AOMedia Video 1",
177 to_fourcc(
'a',
'v',
'0',
'1'), 1, 1, 0, 8,
FALSE,
TRUE,
TRUE,
FALSE, 0,
"av1"},
178 [
I420] = {
"I420",
"planar YUV 4:2:0",
179 to_fourcc(
'I',
'4',
'2',
'0'), 3, 2, 2, 8,
FALSE,
FALSE,
FALSE,
FALSE, 4200,
"yuv"},
180 [
Y216] = {
"Y216",
"Packed 16-bit YUV 4:2:2 little-endian",
181 to_fourcc(
'Y',
'2',
'1',
'6'), 8, 2, 2, 16,
FALSE,
FALSE,
FALSE,
FALSE, 4220,
"y216"},
182 [
Y416] = {
"Y416",
"Packed 16-bit YUV 4:4:4:4 little-endian",
183 to_fourcc(
'Y',
'4',
'1',
'6'), 8, 1, 1, 16,
FALSE,
FALSE,
FALSE,
FALSE, 4444,
"y416"},
184 [
PRORES] = {
"PRORES",
"Apple ProRes",
185 0, 1, 1, 0, 8,
FALSE,
TRUE,
TRUE,
FALSE, 0,
"pror"},
186 [
PRORES_4444] = {
"PRORES_4444",
"Apple ProRes 4444",
187 to_fourcc(
'a',
'p',
'4',
'h'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"ap4h"},
189 to_fourcc(
'a',
'p',
'4',
'x'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"ap4x"},
191 to_fourcc(
'a',
'p',
'c',
'h'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"apch"},
192 [
PRORES_422] = {
"PRORES_422",
"Apple ProRes 422",
193 to_fourcc(
'a',
'p',
'c',
'n'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"apcn"},
195 to_fourcc(
'a',
'p',
'c',
'o'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"apco"},
197 to_fourcc(
'a',
'p',
'c',
's'), 1, 1, 0, 8,
FALSE,
TRUE,
FALSE,
FALSE, 0,
"apcs"},
198 [
DRM_PRIME] = {
"DRM_PRIME",
"DRM Prime buffer",
199 to_fourcc(
'D',
'R',
'M',
'P'),
sizeof(
struct drm_prime_frame), 1, 0, 8,
FALSE,
TRUE,
FALSE,
TRUE, 0,
"drm_prime"},
208 [
I420] = {{1, 1, 2, 2, 2, 2, 0, 0}},
252 printf(
"Supported codecs (%s):\n",
module);
264 printf(
"\t10bits\n");
272 printf(
"\t12+ bits\n");
282 unsigned int i = (
unsigned int)
codec;
303 unsigned int i = (
unsigned int)
codec;
307 bpp = (double)
codec_info[i].block_size_bytes /
316 unsigned int i = (
unsigned int)
codec;
328 unsigned int i = (
unsigned int)
codec;
329 const char *
name = NULL;
334 assert(
name != NULL);
340 unsigned int i = (
unsigned int)
codec;
341 const char *name_long = NULL;
346 assert(name_long != NULL);
408 unsigned int i = (
unsigned int)
codec;
434 unsigned int i = (
unsigned int)
codec;
450 unsigned int i = (
unsigned int)
codec;
465 unsigned int i = (
unsigned int)
codec;
481 unsigned int i = (
unsigned int)
codec;
544 for (
int i = 0; i < 4; ++i) {
545 if (sub[i * 2] == 0) {
548 ret += ((width + sub[i * 2] - 1) / sub[i * 2])
549 * ((height + sub[i * 2 + 1] - 1) / sub[i * 2 + 1]);
558 unsigned int i = (
unsigned int)
codec;
570 unsigned int i = (
unsigned int)
codec;
591 if(((uintptr_t) src & 0x0Fu) == 0u && src_linesize % 16 == 0) {
592 vc_deinterlace_aligned(src, src_linesize, lines);
594 vc_deinterlace_unaligned(src, src_linesize, lines);
597 for (
int y = 0; y < lines; y += 2) {
598 for (
int x = 0; x < src_linesize; ++x) {
599 int val = (*src + src[src_linesize] + 1) >> 1;
600 *src = src[src_linesize] =
val;
615static void vc_deinterlace_aligned(
unsigned char *src,
long src_linesize,
int lines)
618 long pitch = src_linesize;
619 register long pitch2 = pitch * 2;
620 unsigned char *bline1, *bline2, *bline3;
621 register unsigned char *line1, *line2, *line3;
624 bline2 = src + pitch;
625 bline3 = src + 3 * pitch;
626 for (i = 0; i < src_linesize; i += 16) {
628 asm volatile (
"movdqa (%0), %%xmm0\n"
629 "movdqa (%1), %%xmm1\n"::
"r" ((
unsigned long *)(
void *)
631 "r"((
unsigned long *)(
void *) bline2));
633 line2 = bline2 + pitch;
635 for (j = 0; j < lines - 4; j += 2) {
636 asm volatile (
"movdqa (%1), %%xmm2\n"
637 "pavgb %%xmm2, %%xmm0\n"
638 "pavgb %%xmm1, %%xmm0\n"
639 "movdqa (%2), %%xmm1\n"
640 "movdqa %%xmm0, (%0)\n"
641 "pavgb %%xmm1, %%xmm0\n"
642 "pavgb %%xmm2, %%xmm0\n"
643 "movdqa %%xmm0, (%1)\n"::
"r" ((
unsigned
644 long *) (
void *) line1),
645 "r"((
unsigned long *) (
void *) line2),
646 "r"((
unsigned long *) (
void *) line3)
663static void vc_deinterlace_unaligned(
unsigned char *src,
long src_linesize,
int lines)
666 long pitch = src_linesize;
667 register long pitch2 = pitch * 2;
668 unsigned char *bline1, *bline2, *bline3;
669 register unsigned char *line1, *line2, *line3;
672 bline2 = src + pitch;
673 bline3 = src + 3 * pitch;
674 for (i = 0; i < src_linesize; i += 16) {
676 asm volatile (
"movdqu (%0), %%xmm0\n"
677 "movdqu (%1), %%xmm1\n"::
"r" (bline1),
680 line2 = bline2 + pitch;
682 for (j = 0; j < lines - 4; j += 2) {
683 asm volatile (
"movdqu (%1), %%xmm2\n"
684 "pavgb %%xmm2, %%xmm0\n"
685 "pavgb %%xmm1, %%xmm0\n"
686 "movdqu (%2), %%xmm1\n"
687 "movdqu %%xmm0, (%0)\n"
688 "pavgb %%xmm1, %%xmm0\n"
689 "pavgb %%xmm2, %%xmm0\n"
690 "movdqu %%xmm0, (%1)\n"::
"r" (line1),
719 memcpy(dst, src, src_linesize);
724 for (
size_t y = 0; y < lines - 1; y += 1) {
725 unsigned char *s = src + y * src_linesize;
726 unsigned char *d = dst + y * dst_pitch;
727 if (bpp == 8 || bpp == 16) {
731 for ( ; x < src_linesize / 16; ++x) {
732 __m128i i1 = _mm_lddqu_si128((__m128i
const*)(
const void *) s);
733 __m128i i2 = _mm_lddqu_si128((__m128i
const*)(
const void *) (s + src_linesize));
734 __m128i res = _mm_avg_epu8(i1, i2);
735 _mm_storeu_si128((__m128i *)(
void *) d, res);
740 for ( ; x < src_linesize / 16; ++x) {
741 __m128i i1 = _mm_lddqu_si128((__m128i
const*)(
const void *) s);
742 __m128i i2 = _mm_lddqu_si128((__m128i
const*)(
const void *) (s + src_linesize));
743 __m128i res = _mm_avg_epu16(i1, i2);
744 _mm_storeu_si128((__m128i *)(
void *) d, res);
752 for ( ; x < src_linesize; ++x) {
753 int val = (*s + s[src_linesize] + 1) >> 1;
758 uint16_t *d16 = (
void *) d;
759 uint16_t *s16 = (
void *) s;
760 for ( ; x < src_linesize / 2; ++x) {
761 int val = (*s16 + s16[src_linesize / 2] + 1) >> 1;
767 uint32_t *s32 = (
void *) s;
768 uint32_t *d32 = (
void *) d;
769 for (
size_t x = 0; x < src_linesize / 16; ++x) {
771 for (
size_t y = 0; y < 4; ++y) {
773 uint32_t v2 = s32[src_linesize / 4];
775 (((v1 >> 20 ) + (v2 >> 20 ) + 1) / 2) << 20 |
776 (((v1 >> 10 & 0x3ff) + (v2 >> 10 & 0x3ff) + 1) / 2) << 10 |
777 (((v1 & 0x3ff) + (v2 & 0x3ff) + 1) / 2);
783 uint32_t *s32 = (
void *) s;
784 uint32_t *d32 = (
void *) d;
785 for (
size_t x = 0; x < src_linesize / 16; ++x) {
787 for (
size_t y = 0; y < 4; ++y) {
788 uint32_t v1 = ntohl(*s32);
789 uint32_t v2 = ntohl(s32[src_linesize / 4]);
791 (((v1 >> 22 ) + (v2 >> 22 ) + 1) / 2) << 22 |
792 (((v1 >> 12 & 0x3ff) + (v2 >> 12 & 0x3ff) + 1) / 2) << 12 |
793 (((v1 >> 2 & 0x3ff) + (v2 >> 2 & 0x3ff) + 1) / 2) << 2;
799 uint32_t *s32 = (
void *) s;
800 uint32_t *d32 = (
void *) d;
802 uint32_t remain1 = 0;
803 uint32_t remain2 = 0;
805 for (
size_t x = 0; x < src_linesize / 36; ++x) {
807 for (
size_t y = 0; y < 8; ++y) {
809 uint32_t in2 = s32[src_linesize / 4];
811 remain1 = remain1 | (in1 & ((1<<((shift + 12) % 32)) - 1)) << (32-shift);
812 remain2 = remain2 | (in2 & ((1<<((shift + 12) % 32)) - 1)) << (32-shift);
813 uint32_t ret = (remain1 + remain2 + 1) / 2;
816 out = ret >> (32-shift);
817 shift = (shift + 12) % 32;
821 while (shift <= 32 - 12) {
822 out |= ((((in1 & 0xfff) + (in2 & 0xfff)) + 1) / 2) << shift;
842 memcpy(dst + (lines - 1) * dst_pitch, dst + (lines - 2) * dst_pitch, src_linesize);
854 assert (set != NULL);
856 if (*(set++) ==
codec)
866 switch (color_spec) {
873 for (
int i = 0; i < 4; i++) {
885 memset(data, 0,
sizeof(hw_vdpau_frame));
892 for (
size_t y = 0; y < height; ++y) {
894 for( i = 0; i < (linesize & (~15)); i+=16)
898 for( ; i < linesize; i++ )
900 ((
char*)data)[i] = ((
char*)
pattern)[i&15];
925 for (
size_t i = 0; i < 8; ++i) {
941uyvy_to_i422(
int width,
int height,
const unsigned char *in,
unsigned char *out)
943 unsigned char *out_y = out;
944 unsigned char *out_cb = out + width * height;
945 unsigned char *out_cr =
946 out + width * height + ((width + 1) / 2) * height;
947 for (
int y = 0; y < height; ++y) {
948 for (
int x = 0; x < width / 2; ++x) {
954 if (width % 2 == 1) {
963y416_to_i444(
int width,
int height,
const unsigned char *in,
unsigned char *out,
966 const uint16_t *inp = (
const uint16_t *) (
const void *) in;
967 uint16_t *out_y = (uint16_t *) (
void *) out;
968 uint16_t *out_cb = (uint16_t *) (
void *) out + width * height;
969 uint16_t *out_cr = (uint16_t *) (
void *) out + 2 * width * height;
970 for (
int y = 0; y < height; ++y) {
971 for (
int x = 0; x < width; ++x) {
972 *out_cb++ = *inp++ >> (16 -
depth);
973 *out_y++ = *inp++ >> (16 -
depth);
974 *out_cr++ = *inp++ >> (16 -
depth);
982 unsigned char *out,
int in_depth)
984 const uint16_t *in_y = (
const uint16_t *)(
const void *) in;
985 const uint16_t *in_cb = (
const uint16_t *)(
const void *) in + width * height;
986 const uint16_t *in_cr = (
const uint16_t *)(
const void *) in + 2 * width * height;
987 uint16_t *outp = (uint16_t *)(
void *) out;
988 for (
int y = 0; y < height; ++y) {
989 for (
int x = 0; x < width; ++x) {
990 *outp++ = *in_cb++ << (16 - in_depth);
991 *outp++ = *in_y++ << (16 - in_depth);
992 *outp++ = *in_cr++ << (16 - in_depth);
1000 unsigned char *out,
int in_depth)
1002 enum { ALPHA16_OPAQUE = 0xFFFF };
1003 const uint16_t *in_y = (
const uint16_t *) (
const void *) in;
1004 const uint16_t *in_cb = in_y + (ptrdiff_t) width * height;
1005 const uint16_t *in_cr = in_cb + (ptrdiff_t) ((width + 1) / 2) * height;
1006 uint16_t *outp = (
void *) out;
1007 for (
int y = 0; y < height; ++y) {
1008 for (
int x = 0; x < (width + 1) / 2; ++x) {
1009 *outp++ = *in_cb << (
DEPTH16 - in_depth);
1010 *outp++ = *in_y++ << (
DEPTH16 - in_depth);
1011 *outp++ = *in_cr << (
DEPTH16 - in_depth);
1012 *outp++ = ALPHA16_OPAQUE;
1013 *outp++ = *in_cb++ << (
DEPTH16 - in_depth);
1014 *outp++ = *in_y++ << (
DEPTH16 - in_depth);
1015 *outp++ = *in_cr++ << (
DEPTH16 - in_depth);
1016 *outp++ = ALPHA16_OPAQUE;
1023 unsigned char *out,
int in_depth)
1025 enum { ALPHA16_OPAQUE = 0xFFFF };
1026 const uint16_t *in_y1 = (
const void *) in;
1027 const uint16_t *in_y2 = in_y1 + width;
1028 const uint16_t *in_cb =
1029 (
const uint16_t *) (
const void *) in + (ptrdiff_t) width * height;
1030 const uint16_t *in_cr =
1031 in_cb + (ptrdiff_t) ((width + 1) / 2) * ((height + 1) / 2);
1033 uint16_t *outp1 = (
void *) out;
1034 uint16_t *outp2 = outp1 + out_line_len;
1035 for (
int y = 0; y < (height + 1) / 2; ++y) {
1036 for (
int x = 0; x < (width + 1) / 2; ++x) {
1037 *outp1++ = *in_cb << (
DEPTH16 - in_depth);
1038 *outp1++ = *in_y1++ << (
DEPTH16 - in_depth);
1039 *outp1++ = *in_cr << (
DEPTH16 - in_depth);
1040 *outp1++ = ALPHA16_OPAQUE;
1042 *outp2++ = *in_cb << (
DEPTH16 - in_depth);
1043 *outp2++ = *in_y2++ << (
DEPTH16 - in_depth);
1044 *outp2++ = *in_cr << (
DEPTH16 - in_depth);
1045 *outp2++ = ALPHA16_OPAQUE;
1047 *outp1++ = *in_cb << (
DEPTH16 - in_depth);
1048 *outp1++ = *in_y1++ << (
DEPTH16 - in_depth);
1049 *outp1++ = *in_cr << (
DEPTH16 - in_depth);
1050 *outp1++ = ALPHA16_OPAQUE;
1052 *outp2++ = *in_cb++ << (
DEPTH16 - in_depth);
1053 *outp2++ = *in_y2++ << (
DEPTH16 - in_depth);
1054 *outp2++ = *in_cr++ << (
DEPTH16 - in_depth);
1055 *outp2++ = ALPHA16_OPAQUE;
1057 outp1 += out_line_len;
1058 outp2 += out_line_len;
1067 const unsigned char *
const cb = in + (ptrdiff_t) width * height;
1068 const unsigned char *
const cr =
1069 cb + (ptrdiff_t) (width / 2) * (height / 2);
1071 for (ptrdiff_t y = 0; y < height; ++y) {
1072 const unsigned char *src_y = in + width * y;
1073 const unsigned char *src_cb = cb + (width / 2) * (y / 2);
1074 const unsigned char *src_cr = cr + (width / 2) * (y / 2);
1075 unsigned char *dst = out + y * uyvy_linesize;
1091 const unsigned char *in_y = in;
1092 const unsigned char *in_cb = in + width * height;
1093 const unsigned char *in_cr = in_cb + (((width + 1) / 2) * height);
1094 unsigned char *outp = out;
1095 for (
int y = 0; y < height; ++y) {
1096 for (
int x = 0; x < (width + 1) / 2; ++x) {
1109 const unsigned char *in_y = in;
1110 const unsigned char *in_cb = in + width * height;
1111 const unsigned char *in_cr = in_cb + width * height;
1112 unsigned char *outp = out;
1113 for (
int y = 0; y < height; ++y) {
1114 for (
int x = 0; x < (width + 1) / 2; ++x) {
1155 if (desc_a->
rgb != desc_b->
rgb) {
1156 return desc_a->
rgb == src_desc->
rgb ? -1 : 1;
1189 snprintf(
message,
sizeof message,
"conversion is reducing bit depth from %d to %d", desc_src.
depth, desc_dst.
depth);
1205 if (
desc.depth == 0) {
1206 return "(undefined)";
1208 _Thread_local
static char buf[128];
1209 snprintf(buf,
sizeof buf,
"%s %d:%d:%d",
desc.rgb ?
"RGB" :
"YCbCr",
desc.subsampling / 1000,
desc.subsampling % 1000 / 100,
desc.subsampling % 100 / 10);
1210 if (
desc.subsampling % 10 != 0) {
1211 snprintf(buf + strlen(buf),
sizeof buf - strlen(buf),
":%d",
desc.subsampling % 10);
1213 snprintf(buf + strlen(buf),
sizeof buf - strlen(buf),
" %d bit",
desc.depth);
1220 desc_a.
rgb == desc_b.
rgb;
void log_msg(int level, const char *format,...)
#define DEBUG_TIMER_START(name)
#define DEBUG_TIMER_STOP(name)
#define LOG_LEVEL_WARNING
less severe errors
This file contains functions related to hw acceleration.
#define to_fourcc(a, b, c, d)
Creates FourCC word.
const char * primary_name
unsigned interframe
Indicates if compression is interframe.
const char * name
displayed name
int subsampling
Decimal representation of subsampling in format 'JabA', eg. 4440 (last number is alpha),...
const char * name_long
more descriptive name
int h_align
Number of pixels each line is aligned to.
unsigned const_size
Indicates if data length is constant for all resolutions (hw surfaces)
unsigned rgb
Whether pixelformat is RGB.
int block_size_pixels
Bytes per pixel block (packed pixelformats only, otherwise set to 1)
int bits_per_channel
Number of bits per color channel.
const char * file_extension
Extension that should be added to name if frame is saved to file.
unsigned opaque
If codec is opaque (= compressed)
int block_size_bytes
Bytes per pixel block (packed pixelformats only, otherwise set to 1)
int depth
bit depth; 0 means that whole struct is undefined
int subsampling
in 'JabA' format, eg. '4444'
int plane_info[8]
[1st comp H subsamp, 1st comp V subs., 2nd comp H....]
@ YUYV
YCbCr 422 8-bit - Y0 Cb Y1 Cr.
@ DXT1
S3 Texture Compression DXT1.
@ PRORES_422_LT
Apple ProRes 422 (LT)
@ 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
@ PRORES
abstract Apple ProRes, must not be used in transmit
@ PRORES_422_PROXY
Apple ProRes 422 (Proxy)
@ HW_VDPAU
VDPAU hardware surface.
@ RG48
16-bit RGB little-endian (RlRhGl...)
@ Y416
interleaved little-endian YCbCr 4444 16-bit - UYVA
@ PRORES_422_HQ
Apple ProRes 422 (HQ)
@ Y216
YCbCr 422 16-bit little-endian - Y0 Cb Y1 Cr.
@ PRORES_4444
Apple ProRes 4444.
@ JPEG
JPEG image, restart intervals may be used. Compatible with GPUJPEG.
@ MJPG
JPEG image, without restart intervals.
@ R12L
RGB 12-bit packed, little-endian.
@ PRORES_422
Apple ProRes 422.
@ DRM_PRIME
DRM Prime buffer, data contains struct drm_prime_frame.
@ DVS10
DVS 10-bit format.
@ DXT5
S3 Texture Compression DXT5.
@ PRORES_4444_XQ
Apple ProRes 4444 (XQ)
@ DXT1_YUV
Structure same as DXT1, instead of RGB, YCbCr values are stored.
@ RGBA
RGBA 8-bit, big-endian.
@ v210
YCbCr 422 10-bit - xVY0U|xY2UY1|xUY3V|xY5VY4, little-endian (2 bit padding /'x'/),...
void vc_deinterlace(unsigned char *src, long src_linesize, int lines)
Deinterlaces framebuffer.
void i420_8_to_uyvy(int width, int height, const unsigned char *in, unsigned char *out)
bool codec_is_hw_accelerated(codec_t codec)
static const struct alternative_fourcc fourcc_aliases[]
bool codec_is_in_set(codec_t codec, const codec_t *set)
const char * get_pixdesc_desc(struct pixfmt_desc desc)
void codec_get_planes_subsampling(codec_t pix_fmt, int *sub)
#define HW_VDPAU_FRAME_SZ
void y416_to_i444(int width, int height, const unsigned char *in, unsigned char *out, int depth)
struct pixfmt_desc get_pixfmt_desc(codec_t pixfmt)
bool is_codec_opaque(codec_t codec)
static codec_t get_codec_from_name_wo_alias(const char *name)
bool vc_deinterlace_ex(codec_t codec, unsigned char *src, size_t src_linesize, unsigned char *dst, size_t dst_pitch, size_t lines)
void uyvy_to_i422(int width, int height, const unsigned char *in, unsigned char *out)
bool codec_is_a_rgb(codec_t codec)
Returns TRUE if specified pixelformat is some form of RGB (not YUV).
void i444_8_to_uyvy(int width, int height, const unsigned char *in, unsigned char *out)
int vc_get_size(unsigned int width, codec_t codec)
void i422_16_to_y416(int width, int height, const unsigned char *in, unsigned char *out, int in_depth)
int vc_get_linesize(unsigned int width, codec_t codec)
bool pixdesc_equals(struct pixfmt_desc desc_a, struct pixfmt_desc desc_b)
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...
void i420_16_to_y416(int width, int height, const unsigned char *in, unsigned char *out, int in_depth)
bool is_codec_interframe(codec_t codec)
int get_pf_block_bytes(codec_t codec)
returns codec_info_t::block_size_bytes
double get_bpp(codec_t codec)
const char * get_codec_file_extension(codec_t codec)
void show_codec_help(const char *module, const codec_t *codecs8, const codec_t *codecs10, const codec_t *codecs_ge12)
Prints list of suppored codecs for video module.
uint32_t get_fourcc(codec_t codec)
char pixfmt_conv_pref[]
bitdepth, subsampling, color space
const char * get_codec_name(codec_t codec)
int get_subsampling(codec_t codec)
int get_pf_block_pixels(codec_t codec)
returns codec_info_t::block_size_pixels
void i422_8_to_uyvy(int width, int height, const unsigned char *in, unsigned char *out)
bool codec_is_planar(codec_t codec)
const char * get_codec_name_long(codec_t codec)
bool clear_video_buffer(unsigned char *data, size_t linesize, size_t pitch, size_t height, codec_t color_spec)
static const struct alternative_codec_name codec_name_aliases[]
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)
codec_t get_codec_from_name(const char *name)
int get_bits_per_component(codec_t codec)
static const struct pixfmt_plane_info_t pixfmt_plane_info[]
static const struct codec_info_t codec_info[]
codec_t get_codec_from_fcc(uint32_t fourcc)
codec_t get_codec_from_file_extension(const char *ext)
void i444_16_to_y416(int width, int height, const unsigned char *in, unsigned char *out, int in_depth)
bool codec_is_420(codec_t pix_fmt)