diff --git a/src/libavcodec/from_lavc_vid_conv.c b/src/libavcodec/from_lavc_vid_conv.c index 7b04d9482..f3af49a97 100644 --- a/src/libavcodec/from_lavc_vid_conv.c +++ b/src/libavcodec/from_lavc_vid_conv.c @@ -62,6 +62,7 @@ #include "libavcodec/from_lavc_vid_conv_cuda.h" #include "libavcodec/lavc_common.h" #include "pixfmt_conv.h" +#include "types.h" #include "utils/macros.h" // OPTIMIZED_FOR #include "utils/misc.h" // get_cpu_core_count #include "utils/worker.h" // task_run_parallel @@ -99,7 +100,8 @@ struct conv_data { int rgb_shift[3]; }; -static void nv12_to_uyvy(struct conv_data d) +static void +nv12_to_uyvy(struct conv_data d) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -119,7 +121,8 @@ static void nv12_to_uyvy(struct conv_data d) } } -static void rgb24_to_uyvy(struct conv_data d) +static void +rgb24_to_uyvy(struct conv_data d) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -134,7 +137,8 @@ static void rgb24_to_uyvy(struct conv_data d) } static void memcpy_data(struct conv_data d) __attribute__((unused)); -static void memcpy_data(struct conv_data d) +static void +memcpy_data(struct conv_data d) { const int height = d.in_frame->height; const AVFrame *frame = d.in_frame; @@ -151,7 +155,8 @@ static void memcpy_data(struct conv_data d) } } -static void rgb24_to_rgb32(struct conv_data d) +static void +rgb24_to_rgb32(struct conv_data d) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -166,7 +171,8 @@ static void rgb24_to_rgb32(struct conv_data d) } } -static void gbrp_to_rgb(struct conv_data d) +static void +gbrp_to_rgb(struct conv_data d) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -183,13 +189,13 @@ static void gbrp_to_rgb(struct conv_data d) } } -static void gbrp_to_rgba(struct conv_data d) +static void +gbrp_to_rgba(struct conv_data d) { assert((uintptr_t) d.dst_buffer % 4 == 0); uint32_t alpha_mask = 0xFFFFFFFFU ^ (0xFFU << d.rgb_shift[R]) ^ (0xFFU << d.rgb_shift[G]) ^ (0xFFU << d.rgb_shift[B]); - const int width = d.in_frame->width; const int height = d.in_frame->height; const AVFrame *frame = d.in_frame; @@ -212,7 +218,8 @@ static void gbrp_to_rgba(struct conv_data d) static inline void gbrap_to_rgb_rgba(struct conv_data d, int comp_count) __attribute__((always_inline)); #endif -static inline void gbrap_to_rgb_rgba(struct conv_data d, int comp_count) +static inline void +gbrap_to_rgb_rgba(struct conv_data d, int comp_count) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -236,12 +243,14 @@ static inline void gbrap_to_rgb_rgba(struct conv_data d, int comp_count) } } -static void gbrap_to_rgba(struct conv_data d) +static void +gbrap_to_rgba(struct conv_data d) { gbrap_to_rgb_rgba(d, 4); } -static void gbrap_to_rgb(struct conv_data d) +static void +gbrap_to_rgb(struct conv_data d) { gbrap_to_rgb_rgba(d, 3); } @@ -250,7 +259,8 @@ static void gbrap_to_rgb(struct conv_data d) static inline void gbrpXXle_to_r10k(struct conv_data d, unsigned int in_depth) __attribute__((always_inline)); #endif -static inline void gbrpXXle_to_r10k(struct conv_data d, unsigned int in_depth) +static inline void +gbrpXXle_to_r10k(struct conv_data d, unsigned int in_depth) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -275,21 +285,24 @@ static inline void gbrpXXle_to_r10k(struct conv_data d, unsigned int in_depth) } } -static void gbrp10le_to_r10k(struct conv_data d) +static void +gbrp10le_to_r10k(struct conv_data d) { - gbrpXXle_to_r10k(d, 10U); + gbrpXXle_to_r10k(d, DEPTH10); } -static void gbrp16le_to_r10k(struct conv_data d) +static void +gbrp16le_to_r10k(struct conv_data d) { - gbrpXXle_to_r10k(d, 16U); + gbrpXXle_to_r10k(d, DEPTH16); } #if defined __GNUC__ static inline void yuv444pXXle_to_r10k(struct conv_data d, int depth) __attribute__((always_inline)); #endif -static inline void yuv444pXXle_to_r10k(struct conv_data d, int depth) +static inline void +yuv444pXXle_to_r10k(struct conv_data d, int depth) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -329,26 +342,30 @@ static inline void yuv444pXXle_to_r10k(struct conv_data d, int depth) } } -static void yuv444p10le_to_r10k(struct conv_data d) +static void +yuv444p10le_to_r10k(struct conv_data d) { - yuv444pXXle_to_r10k(d, 10); + yuv444pXXle_to_r10k(d, DEPTH10); } -static void yuv444p12le_to_r10k(struct conv_data d) +static void +yuv444p12le_to_r10k(struct conv_data d) { - yuv444pXXle_to_r10k(d, 12); + yuv444pXXle_to_r10k(d, DEPTH12); } -static void yuv444p16le_to_r10k(struct conv_data d) +static void +yuv444p16le_to_r10k(struct conv_data d) { - yuv444pXXle_to_r10k(d, 16); + yuv444pXXle_to_r10k(d, DEPTH16); } #if defined __GNUC__ static inline void yuv444pXXle_to_r12l(struct conv_data d, int depth) __attribute__((always_inline)); #endif -static inline void yuv444pXXle_to_r12l(struct conv_data d, int depth) +static inline void +yuv444pXXle_to_r12l(struct conv_data d, int depth) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -423,26 +440,30 @@ static inline void yuv444pXXle_to_r12l(struct conv_data d, int depth) } } -static void yuv444p10le_to_r12l(struct conv_data d) +static void +yuv444p10le_to_r12l(struct conv_data d) { - yuv444pXXle_to_r12l(d, 10); + yuv444pXXle_to_r12l(d, DEPTH10); } -static void yuv444p12le_to_r12l(struct conv_data d) +static void +yuv444p12le_to_r12l(struct conv_data d) { - yuv444pXXle_to_r12l(d, 12); + yuv444pXXle_to_r12l(d, DEPTH12); } -static void yuv444p16le_to_r12l(struct conv_data d) +static void +yuv444p16le_to_r12l(struct conv_data d) { - yuv444pXXle_to_r12l(d, 16); + yuv444pXXle_to_r12l(d, DEPTH16); } #if defined __GNUC__ static inline void yuv444pXXle_to_rg48(struct conv_data d, int depth) __attribute__((always_inline)); #endif -static inline void yuv444pXXle_to_rg48(struct conv_data d, int depth) +static inline void +yuv444pXXle_to_rg48(struct conv_data d, int depth) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -478,26 +499,30 @@ static inline void yuv444pXXle_to_rg48(struct conv_data d, int depth) } } -static void yuv444p10le_to_rg48(struct conv_data d) +static void +yuv444p10le_to_rg48(struct conv_data d) { - yuv444pXXle_to_rg48(d, 10); + yuv444pXXle_to_rg48(d, DEPTH10); } -static void yuv444p12le_to_rg48(struct conv_data d) +static void +yuv444p12le_to_rg48(struct conv_data d) { - yuv444pXXle_to_rg48(d, 12); + yuv444pXXle_to_rg48(d, DEPTH12); } -static void yuv444p16le_to_rg48(struct conv_data d) +static void +yuv444p16le_to_rg48(struct conv_data d) { - yuv444pXXle_to_rg48(d, 16); + yuv444pXXle_to_rg48(d, DEPTH16); } #if defined __GNUC__ static inline void gbrpXXle_to_r12l(struct conv_data d, unsigned int in_depth) __attribute__((always_inline)); #endif -static inline void gbrpXXle_to_r12l(struct conv_data d, unsigned int in_depth) +static inline void +gbrpXXle_to_r12l(struct conv_data d, unsigned int in_depth) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -563,7 +588,8 @@ static inline void gbrpXXle_to_r12l(struct conv_data d, unsigned int in_depth) static inline void gbrpXXle_to_rgb(struct conv_data d, unsigned int in_depth) __attribute__((always_inline)); #endif -static inline void gbrpXXle_to_rgb(struct conv_data d, unsigned int in_depth) +static inline void +gbrpXXle_to_rgb(struct conv_data d, unsigned int in_depth) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -592,7 +618,8 @@ static inline void gbrpXXle_to_rgb(struct conv_data d, unsigned int in_depth) static inline void gbrpXXle_to_rgba(struct conv_data d, unsigned int in_depth) __attribute__((always_inline)); #endif -static inline void gbrpXXle_to_rgba(struct conv_data d, unsigned int in_depth) +static inline void +gbrpXXle_to_rgba(struct conv_data d, unsigned int in_depth) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -623,56 +650,66 @@ static inline void gbrpXXle_to_rgba(struct conv_data d, unsigned int in_depth) } } -static void gbrp10le_to_rgb(struct conv_data d) +static void +gbrp10le_to_rgb(struct conv_data d) { - gbrpXXle_to_rgb(d, 10); + gbrpXXle_to_rgb(d, DEPTH10); } -static void gbrp10le_to_rgba(struct conv_data d) +static void +gbrp10le_to_rgba(struct conv_data d) { - gbrpXXle_to_rgba(d, 10); + gbrpXXle_to_rgba(d, DEPTH10); } -static void gbrp12le_to_r12l(struct conv_data d) +static void +gbrp12le_to_r12l(struct conv_data d) { - gbrpXXle_to_r12l(d, 12U); + gbrpXXle_to_r12l(d, DEPTH12); } -static void gbrp12le_to_r10k(struct conv_data d) +static void +gbrp12le_to_r10k(struct conv_data d) { - gbrpXXle_to_r10k(d, 12U); + gbrpXXle_to_r10k(d, DEPTH12); } -static void gbrp12le_to_rgb(struct conv_data d) +static void +gbrp12le_to_rgb(struct conv_data d) { - gbrpXXle_to_rgb(d, 12U); + gbrpXXle_to_rgb(d, DEPTH12); } -static void gbrp12le_to_rgba(struct conv_data d) +static void +gbrp12le_to_rgba(struct conv_data d) { - gbrpXXle_to_rgba(d, 12U); + gbrpXXle_to_rgba(d, DEPTH12); } -static void gbrp16le_to_r12l(struct conv_data d) +static void +gbrp16le_to_r12l(struct conv_data d) { - gbrpXXle_to_r12l(d, 16U); + gbrpXXle_to_r12l(d, DEPTH16); } -static void gbrp16le_to_rgb(struct conv_data d) +static void +gbrp16le_to_rgb(struct conv_data d) { - gbrpXXle_to_rgb(d, 16U); + gbrpXXle_to_rgb(d, DEPTH16); } -static void gbrp16le_to_rgba(struct conv_data d) +static void +gbrp16le_to_rgba(struct conv_data d) { - gbrpXXle_to_rgba(d, 16U); + gbrpXXle_to_rgba(d, DEPTH16); } #if defined __GNUC__ static inline void gbrpXXle_to_rg48(struct conv_data d, unsigned int in_depth) __attribute__((always_inline)); #endif -static inline void gbrpXXle_to_rg48(struct conv_data d, unsigned int in_depth) +static inline void +gbrpXXle_to_rg48(struct conv_data d, unsigned int in_depth) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -697,22 +734,26 @@ static inline void gbrpXXle_to_rg48(struct conv_data d, unsigned int in_depth) } } -static void gbrp10le_to_rg48(struct conv_data d) +static void +gbrp10le_to_rg48(struct conv_data d) { - gbrpXXle_to_rg48(d, 10); + gbrpXXle_to_rg48(d, DEPTH10); } -static void gbrp12le_to_rg48(struct conv_data d) +static void +gbrp12le_to_rg48(struct conv_data d) { - gbrpXXle_to_rg48(d, 12); + gbrpXXle_to_rg48(d, DEPTH12); } -static void gbrp16le_to_rg48(struct conv_data d) +static void +gbrp16le_to_rg48(struct conv_data d) { - gbrpXXle_to_rg48(d, 16); + gbrpXXle_to_rg48(d, DEPTH16); } -static void rgb48le_to_rgba(struct conv_data d) +static void +rgb48le_to_rgba(struct conv_data d) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -728,7 +769,8 @@ static void rgb48le_to_rgba(struct conv_data d) } } -static void rgb48le_to_r12l(struct conv_data d) +static void +rgb48le_to_r12l(struct conv_data d) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -745,7 +787,8 @@ static void rgb48le_to_r12l(struct conv_data d) } } -static void yuv420p_to_uyvy(struct conv_data d) +static void +yuv420p_to_uyvy(struct conv_data d) { const int width = d.in_frame->width; const int height = d.in_frame->height; @@ -861,7 +904,6 @@ yuv420p_to_v210(struct conv_data d) uint8_t *src_y2 = (in_frame->data[0] + in_frame->linesize[0] * (y * 2 + 1)); uint8_t *src_cb = (in_frame->data[1] + in_frame->linesize[1] * y); uint8_t *src_cr = (in_frame->data[2] + in_frame->linesize[2] * y); - uint32_t *dst1 = (uint32_t *) (void *) (d.dst_buffer + (y * 2) * d.pitch); uint32_t *dst2 = @@ -992,7 +1034,6 @@ yuv444p_to_uyvy(struct conv_data d) char *src_y = (char *) in_frame->data[0] + in_frame->linesize[0] * y; unsigned char *src_cb = (unsigned char *) in_frame->data[1] + in_frame->linesize[1] * y; unsigned char *src_cr = (unsigned char *) in_frame->data[2] + in_frame->linesize[2] * y; - char *dst = d.dst_buffer + d.pitch * y; OPTIMIZED_FOR (int x = 0; x < width / 2; ++x) { @@ -1017,7 +1058,6 @@ yuv444p16le_to_uyvy(struct conv_data d) unsigned char *src_y = (unsigned char *) in_frame->data[0] + in_frame->linesize[0] * y + 1; unsigned char *src_cb = (unsigned char *) in_frame->data[1] + in_frame->linesize[1] * y + 1; unsigned char *src_cr = (unsigned char *) in_frame->data[2] + in_frame->linesize[2] * y + 1; - unsigned char *dst = (unsigned char *) d.dst_buffer + d.pitch * y; @@ -1045,7 +1085,6 @@ yuv444p_to_v210(struct conv_data d) uint8_t *src_y = (in_frame->data[0] + in_frame->linesize[0] * y); uint8_t *src_cb = (in_frame->data[1] + in_frame->linesize[1] * y); uint8_t *src_cr = (in_frame->data[2] + in_frame->linesize[2] * y); - uint32_t *dst = (uint32_t *) (void *) (d.dst_buffer + y * d.pitch); @@ -1110,7 +1149,6 @@ nv12_to_rgb(struct conv_data d, bool rgba) for(int y = 0; y < height; ++y) { unsigned char *src_y = (unsigned char *) in_frame->data[0] + in_frame->linesize[0] * y; unsigned char *src_cbcr = (unsigned char *) in_frame->data[1] + in_frame->linesize[1] * (y / 2); - unsigned char *dst = (unsigned char *) d.dst_buffer + d.pitch * y; @@ -1400,6 +1438,10 @@ yuv420p10le_to_v210(struct conv_data d) static void yuv422p10le_to_v210(struct conv_data d) { + const int width = d.in_frame->width; + const int height = d.in_frame->height; + const AVFrame *in_frame = d.in_frame; + for(int y = 0; y < height; ++y) { uint16_t *src_y = (uint16_t *)(void *)(in_frame->data[0] + in_frame->linesize[0] * y); uint16_t *src_cb = (uint16_t *)(void *)(in_frame->data[1] + in_frame->linesize[1] * y); @@ -1487,19 +1529,19 @@ static inline void yuv444p1Xle_to_v210(struct conv_data d, int in_depth) static void yuv444p10le_to_v210(struct conv_data d) { - yuv444p1Xle_to_v210(d, 10); + yuv444p1Xle_to_v210(d, DEPTH10); } static void yuv444p12le_to_v210(struct conv_data d) { - yuv444p1Xle_to_v210(d, 12); + yuv444p1Xle_to_v210(d, DEPTH12); } static void yuv444p16le_to_v210(struct conv_data d) { - yuv444p1Xle_to_v210(d, 16); + yuv444p1Xle_to_v210(d, DEPTH16); } static void yuv420p10le_to_uyvy(struct conv_data d) @@ -1592,12 +1634,12 @@ yuv444p1Xle_to_uyvy(struct conv_data d, int in_depth) static void yuv444p10le_to_uyvy(struct conv_data d) { - yuv444p1Xle_to_uyvy(d, 10); + yuv444p1Xle_to_uyvy(d, DEPTH10); } static void yuv444p12le_to_uyvy(struct conv_data d) { - yuv444p1Xle_to_uyvy(d, 12); + yuv444p1Xle_to_uyvy(d, DEPTH12); } #if defined __GNUC__ @@ -1634,19 +1676,19 @@ yuv444p1Xle_to_y416(struct conv_data d, int in_depth) static void yuv444p10le_to_y416(struct conv_data d) { - yuv444p1Xle_to_y416(d, 10); + yuv444p1Xle_to_y416(d, DEPTH10); } static void yuv444p12le_to_y416(struct conv_data d) { - yuv444p1Xle_to_y416(d, 12); + yuv444p1Xle_to_y416(d, DEPTH12); } static void yuv444p16le_to_y416(struct conv_data d) { - yuv444p1Xle_to_y416(d, 16); + yuv444p1Xle_to_y416(d, DEPTH16); } #if defined __GNUC__ @@ -1773,7 +1815,8 @@ MAKE_YUV_TO_RGB_FUNCTION(422, 32) static inline void yuv444p10le_to_rgb(struct conv_data d, bool rgba) __attribute__((always_inline)); #endif -static inline void yuv444p10le_to_rgb(struct conv_data d, bool rgba) +static inline void +yuv444p10le_to_rgb(struct conv_data d, bool rgba) { const int width = d.in_frame->width; const int height = d.in_frame->height;