Skip to content

Commit dabcc0c

Browse files
committed
added convs from AV_PIX_FMT_YUV444P12LE to Y416,v210
+ added missing always_inline attributes
1 parent f99e011 commit dabcc0c

File tree

1 file changed

+37
-51
lines changed

1 file changed

+37
-51
lines changed

src/libavcodec/from_lavc_vid_conv.c

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,12 @@ static void yuv422p10le_to_v210(char * __restrict dst_buffer, AVFrame * __restri
12761276
}
12771277
}
12781278

1279-
static void yuv444p10le_to_v210(char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1279+
#if defined __GNUC__
1280+
static inline void yuv444p1Xle_to_v210(unsigned in_depth, char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1281+
int width, int height, int pitch, const int * __restrict rgb_shift)
1282+
__attribute__((always_inline));
1283+
#endif
1284+
static inline void yuv444p1Xle_to_v210(unsigned in_depth, char * __restrict dst_buffer, AVFrame * __restrict in_frame,
12801285
int width, int height, int pitch, const int * __restrict rgb_shift)
12811286
{
12821287
UNUSED(rgb_shift);
@@ -1289,26 +1294,26 @@ static void yuv444p10le_to_v210(char * __restrict dst_buffer, AVFrame * __restri
12891294
OPTIMIZED_FOR (int x = 0; x < width / 6; ++x) {
12901295
uint32_t w0_0, w0_1, w0_2, w0_3;
12911296

1292-
w0_0 = (src_cb[0] + src_cb[1]) / 2;
1293-
w0_0 = w0_0 | (*src_y++) << 10;
1294-
w0_0 = w0_0 | (src_cr[0] + src_cr[1]) / 2 << 20;
1297+
w0_0 = ((src_cb[0] >> (in_depth - 10U)) + (src_cb[1] >> (in_depth - 10U))) / 2;
1298+
w0_0 = w0_0 | (*src_y++ >> (in_depth - 10U)) << 10U;
1299+
w0_0 = w0_0 | ((src_cr[0] >> (in_depth - 10U)) + (src_cr[1] >> (in_depth - 10U))) / 2 << 20U;
12951300
src_cb += 2;
12961301
src_cr += 2;
12971302

12981303
w0_1 = *src_y++;
1299-
w0_1 = w0_1 | (src_cb[0] + src_cb[1]) / 2 << 10;
1300-
w0_1 = w0_1 | (*src_y++) << 20;
1304+
w0_1 = w0_1 | ((src_cb[0] >> (in_depth - 10U)) + (src_cb[1] >> (in_depth - 10U))) / 2 << 10U;
1305+
w0_1 = w0_1 | (*src_y++ >> (in_depth - 10U)) << 20U;
13011306
src_cb += 2;
13021307

1303-
w0_2 = (src_cr[0] + src_cr[1]) / 2;
1304-
w0_2 = w0_2 | (*src_y++) << 10;
1305-
w0_2 = w0_2 | (src_cb[0] + src_cb[1]) / 2 << 20;
1308+
w0_2 = ((src_cr[0] >> (in_depth - 10U)) + (src_cr[1] >> (in_depth - 10U))) / 2;
1309+
w0_2 = w0_2 | (*src_y++ >> (in_depth - 10U)) << 10U;
1310+
w0_2 = w0_2 | ((src_cb[0] >> (in_depth - 10U)) + (src_cb[1] >> (in_depth - 10U))) / 2 << 20U;
13061311
src_cr += 2;
13071312
src_cb += 2;
13081313

13091314
w0_3 = *src_y++;
1310-
w0_3 = w0_3 | (src_cr[0] + src_cr[1]) / 2 << 10;
1311-
w0_3 = w0_3 | (*src_y++) << 20;
1315+
w0_3 = w0_3 | ((src_cr[0] >> (in_depth - 10U)) + (src_cr[1] >> (in_depth - 10U))) / 2 << 10U;
1316+
w0_3 = w0_3 | ((*src_y++ >> (in_depth - 10U))) << 20U;
13121317
src_cr += 2;
13131318

13141319
*dst++ = w0_0;
@@ -1319,47 +1324,19 @@ static void yuv444p10le_to_v210(char * __restrict dst_buffer, AVFrame * __restri
13191324
}
13201325
}
13211326

1322-
static void yuv444p16le_to_v210(char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1323-
int width, int height, int pitch, const int * __restrict rgb_shift)
1324-
{
1325-
UNUSED(rgb_shift);
1326-
for(int y = 0; y < height; ++y) {
1327-
uint16_t *src_y = (uint16_t *)(void *)(in_frame->data[0] + in_frame->linesize[0] * y);
1328-
uint16_t *src_cb = (uint16_t *)(void *)(in_frame->data[1] + in_frame->linesize[1] * y);
1329-
uint16_t *src_cr = (uint16_t *)(void *)(in_frame->data[2] + in_frame->linesize[2] * y);
1330-
uint32_t *dst = (uint32_t *)(void *)(dst_buffer + y * pitch);
1331-
1332-
OPTIMIZED_FOR (int x = 0; x < width / 6; ++x) {
1333-
uint32_t w0_0, w0_1, w0_2, w0_3;
1334-
1335-
w0_0 = ((src_cb[0] >> 6U) + (src_cb[1] >> 6U)) / 2;
1336-
w0_0 = w0_0 | (*src_y++ >> 6U) << 10U;
1337-
w0_0 = w0_0 | ((src_cr[0] >> 6U) + (src_cr[1] >> 6U)) / 2 << 20U;
1338-
src_cb += 2;
1339-
src_cr += 2;
1340-
1341-
w0_1 = *src_y++;
1342-
w0_1 = w0_1 | ((src_cb[0] >> 6U) + (src_cb[1] >> 6U)) / 2 << 10U;
1343-
w0_1 = w0_1 | (*src_y++ >> 6U) << 20U;
1344-
src_cb += 2;
1345-
1346-
w0_2 = ((src_cr[0] >> 6U) + (src_cr[1] >> 6U)) / 2;
1347-
w0_2 = w0_2 | (*src_y++ >> 6U) << 10U;
1348-
w0_2 = w0_2 | ((src_cb[0] >> 6U) + (src_cb[1] >> 6U)) / 2 << 20U;
1349-
src_cr += 2;
1350-
src_cb += 2;
1327+
static void yuv444p10le_to_v210(char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1328+
int width, int height, int pitch, const int * __restrict rgb_shift) {
1329+
yuv444p1Xle_to_v210(10, dst_buffer, in_frame, width, height, pitch, rgb_shift);
1330+
}
13511331

1352-
w0_3 = *src_y++;
1353-
w0_3 = w0_3 | ((src_cr[0] >> 6U) + (src_cr[1] >> 6U)) / 2 << 10U;
1354-
w0_3 = w0_3 | ((*src_y++ >> 6U)) << 20U;
1355-
src_cr += 2;
1332+
static void yuv444p12le_to_v210(char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1333+
int width, int height, int pitch, const int * __restrict rgb_shift) {
1334+
yuv444p1Xle_to_v210(12, dst_buffer, in_frame, width, height, pitch, rgb_shift);
1335+
}
13561336

1357-
*dst++ = w0_0;
1358-
*dst++ = w0_1;
1359-
*dst++ = w0_2;
1360-
*dst++ = w0_3;
1361-
}
1362-
}
1337+
static void yuv444p16le_to_v210(char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1338+
int width, int height, int pitch, const int * __restrict rgb_shift) {
1339+
yuv444p1Xle_to_v210(16, dst_buffer, in_frame, width, height, pitch, rgb_shift);
13631340
}
13641341

13651342
static void yuv420p10le_to_uyvy(char * __restrict dst_buffer, AVFrame * __restrict in_frame,
@@ -1436,7 +1413,8 @@ static void yuv444p10le_to_uyvy(char * __restrict dst_buffer, AVFrame * __restri
14361413

14371414
#if defined __GNUC__
14381415
static inline void yuv444p1Xle_to_y416(unsigned in_depth, char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1439-
int width, int height, int pitch, const int * __restrict rgb_shift);
1416+
int width, int height, int pitch, const int * __restrict rgb_shift)
1417+
__attribute__((always_inline));
14401418
#endif
14411419
static void yuv444p1Xle_to_y416(unsigned in_depth, char * __restrict dst_buffer, AVFrame * __restrict in_frame,
14421420
int width, int height, int pitch, const int * __restrict rgb_shift)
@@ -1467,6 +1445,12 @@ static void yuv444p10le_to_y416(char * __restrict dst_buffer, AVFrame * __restri
14671445
yuv444p1Xle_to_y416(10, dst_buffer, in_frame, width, height, pitch, rgb_shift);
14681446
}
14691447

1448+
static void yuv444p12le_to_y416(char * __restrict dst_buffer, AVFrame * __restrict in_frame,
1449+
int width, int height, int pitch, const int * __restrict rgb_shift)
1450+
{
1451+
yuv444p1Xle_to_y416(12, dst_buffer, in_frame, width, height, pitch, rgb_shift);
1452+
}
1453+
14701454
static void yuv444p16le_to_y416(char * __restrict dst_buffer, AVFrame * __restrict in_frame,
14711455
int width, int height, int pitch, const int * __restrict rgb_shift)
14721456
{
@@ -1964,6 +1948,8 @@ const struct av_to_uv_conversion *get_av_to_uv_conversions() {
19641948
{AV_PIX_FMT_YUV444P12LE, R10k, yuv444p12le_to_r10k, false},
19651949
{AV_PIX_FMT_YUV444P12LE, R12L, yuv444p12le_to_r12l, false},
19661950
{AV_PIX_FMT_YUV444P12LE, RG48, yuv444p12le_to_rg48, false},
1951+
{AV_PIX_FMT_YUV444P12LE, v210, yuv444p12le_to_v210, false},
1952+
{AV_PIX_FMT_YUV444P12LE, Y416, yuv444p12le_to_y416, true},
19671953
// 16-bit YUV
19681954
{AV_PIX_FMT_YUV444P16LE, R10k, yuv444p16le_to_r10k, false},
19691955
{AV_PIX_FMT_YUV444P16LE, R12L, yuv444p16le_to_r12l, false},

0 commit comments

Comments
 (0)