LCOV - code coverage report
Current view: top level - libswscale - input.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 749 874 85.7 %
Date: 2017-10-24 00:14:43 Functions: 127 153 83.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2001-2012 Michael Niedermayer <michaelni@gmx.at>
       3             :  *
       4             :  * This file is part of FFmpeg.
       5             :  *
       6             :  * FFmpeg is free software; you can redistribute it and/or
       7             :  * modify it under the terms of the GNU Lesser General Public
       8             :  * License as published by the Free Software Foundation; either
       9             :  * version 2.1 of the License, or (at your option) any later version.
      10             :  *
      11             :  * FFmpeg is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :  * Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with FFmpeg; if not, write to the Free Software
      18             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      19             :  */
      20             : 
      21             : #include <math.h>
      22             : #include <stdint.h>
      23             : #include <stdio.h>
      24             : #include <string.h>
      25             : 
      26             : #include "libavutil/avutil.h"
      27             : #include "libavutil/bswap.h"
      28             : #include "libavutil/cpu.h"
      29             : #include "libavutil/intreadwrite.h"
      30             : #include "libavutil/mathematics.h"
      31             : #include "libavutil/pixdesc.h"
      32             : #include "libavutil/avassert.h"
      33             : #include "config.h"
      34             : #include "rgb2rgb.h"
      35             : #include "swscale.h"
      36             : #include "swscale_internal.h"
      37             : 
      38             : #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
      39             : 
      40             : #define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? b_r : r_b)
      41             : #define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? r_b : b_r)
      42             : 
      43             : static av_always_inline void
      44        1280 : rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width,
      45             :                     enum AVPixelFormat origin, int32_t *rgb2yuv)
      46             : {
      47        1280 :     int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
      48             :     int i;
      49      423168 :     for (i = 0; i < width; i++) {
      50      421888 :         unsigned int r_b = input_pixel(&src[i*4+0]);
      51      421888 :         unsigned int   g = input_pixel(&src[i*4+1]);
      52      421888 :         unsigned int b_r = input_pixel(&src[i*4+2]);
      53             : 
      54      421888 :         dst[i] = (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
      55             :     }
      56        1280 : }
      57             : 
      58             : static av_always_inline void
      59        1280 : rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV,
      60             :                     const uint16_t *src1, const uint16_t *src2,
      61             :                     int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
      62             : {
      63             :     int i;
      64        1280 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
      65        1280 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
      66             :     av_assert1(src1==src2);
      67      423168 :     for (i = 0; i < width; i++) {
      68      421888 :         int r_b = input_pixel(&src1[i*4+0]);
      69      421888 :         int   g = input_pixel(&src1[i*4+1]);
      70      421888 :         int b_r = input_pixel(&src1[i*4+2]);
      71             : 
      72      421888 :         dstU[i] = (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
      73      421888 :         dstV[i] = (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
      74             :     }
      75        1280 : }
      76             : 
      77             : static av_always_inline void
      78           0 : rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV,
      79             :                           const uint16_t *src1, const uint16_t *src2,
      80             :                           int width, enum AVPixelFormat origin, int32_t *rgb2yuv)
      81             : {
      82             :     int i;
      83           0 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
      84           0 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
      85             :     av_assert1(src1==src2);
      86           0 :     for (i = 0; i < width; i++) {
      87           0 :         int r_b = (input_pixel(&src1[8 * i + 0]) + input_pixel(&src1[8 * i + 4]) + 1) >> 1;
      88           0 :         int   g = (input_pixel(&src1[8 * i + 1]) + input_pixel(&src1[8 * i + 5]) + 1) >> 1;
      89           0 :         int b_r = (input_pixel(&src1[8 * i + 2]) + input_pixel(&src1[8 * i + 6]) + 1) >> 1;
      90             : 
      91           0 :         dstU[i]= (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
      92           0 :         dstV[i]= (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
      93             :     }
      94           0 : }
      95             : 
      96             : #define rgb64funcs(pattern, BE_LE, origin) \
      97             : static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
      98             :                                     int width, uint32_t *rgb2yuv) \
      99             : { \
     100             :     const uint16_t *src = (const uint16_t *) _src; \
     101             :     uint16_t *dst = (uint16_t *) _dst; \
     102             :     rgb64ToY_c_template(dst, src, width, origin, rgb2yuv); \
     103             : } \
     104             :  \
     105             : static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
     106             :                                     const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
     107             :                                     int width, uint32_t *rgb2yuv) \
     108             : { \
     109             :     const uint16_t *src1 = (const uint16_t *) _src1, \
     110             :                    *src2 = (const uint16_t *) _src2; \
     111             :     uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
     112             :     rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
     113             : } \
     114             :  \
     115             : static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
     116             :                                     const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
     117             :                                     int width, uint32_t *rgb2yuv) \
     118             : { \
     119             :     const uint16_t *src1 = (const uint16_t *) _src1, \
     120             :                    *src2 = (const uint16_t *) _src2; \
     121             :     uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
     122             :     rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
     123             : }
     124             : 
     125         576 : rgb64funcs(rgb, LE, AV_PIX_FMT_RGBA64LE)
     126         832 : rgb64funcs(rgb, BE, AV_PIX_FMT_RGBA64BE)
     127         576 : rgb64funcs(bgr, LE, AV_PIX_FMT_BGRA64LE)
     128         576 : rgb64funcs(bgr, BE, AV_PIX_FMT_BGRA64BE)
     129             : 
     130       46756 : static av_always_inline void rgb48ToY_c_template(uint16_t *dst,
     131             :                                                  const uint16_t *src, int width,
     132             :                                                  enum AVPixelFormat origin,
     133             :                                                  int32_t *rgb2yuv)
     134             : {
     135       46756 :     int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
     136             :     int i;
     137    15935596 :     for (i = 0; i < width; i++) {
     138    15888840 :         unsigned int r_b = input_pixel(&src[i * 3 + 0]);
     139    15888840 :         unsigned int g   = input_pixel(&src[i * 3 + 1]);
     140    15888840 :         unsigned int b_r = input_pixel(&src[i * 3 + 2]);
     141             : 
     142    15888840 :         dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
     143             :     }
     144       46756 : }
     145             : 
     146        1856 : static av_always_inline void rgb48ToUV_c_template(uint16_t *dstU,
     147             :                                                   uint16_t *dstV,
     148             :                                                   const uint16_t *src1,
     149             :                                                   const uint16_t *src2,
     150             :                                                   int width,
     151             :                                                   enum AVPixelFormat origin,
     152             :                                                   int32_t *rgb2yuv)
     153             : {
     154             :     int i;
     155        1856 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     156        1856 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     157             :     av_assert1(src1 == src2);
     158      626496 :     for (i = 0; i < width; i++) {
     159      624640 :         int r_b = input_pixel(&src1[i * 3 + 0]);
     160      624640 :         int g   = input_pixel(&src1[i * 3 + 1]);
     161      624640 :         int b_r = input_pixel(&src1[i * 3 + 2]);
     162             : 
     163      624640 :         dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
     164      624640 :         dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
     165             :     }
     166        1856 : }
     167             : 
     168       44900 : static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU,
     169             :                                                        uint16_t *dstV,
     170             :                                                        const uint16_t *src1,
     171             :                                                        const uint16_t *src2,
     172             :                                                        int width,
     173             :                                                        enum AVPixelFormat origin,
     174             :                                                        int32_t *rgb2yuv)
     175             : {
     176             :     int i;
     177       44900 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     178       44900 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     179             :     av_assert1(src1 == src2);
     180     7677000 :     for (i = 0; i < width; i++) {
     181    22896300 :         int r_b = (input_pixel(&src1[6 * i + 0]) +
     182    15264200 :                    input_pixel(&src1[6 * i + 3]) + 1) >> 1;
     183    22896300 :         int g   = (input_pixel(&src1[6 * i + 1]) +
     184    15264200 :                    input_pixel(&src1[6 * i + 4]) + 1) >> 1;
     185    22896300 :         int b_r = (input_pixel(&src1[6 * i + 2]) +
     186    15264200 :                    input_pixel(&src1[6 * i + 5]) + 1) >> 1;
     187             : 
     188     7632100 :         dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
     189     7632100 :         dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
     190             :     }
     191       44900 : }
     192             : 
     193             : #undef r
     194             : #undef b
     195             : #undef input_pixel
     196             : 
     197             : #define rgb48funcs(pattern, BE_LE, origin)                              \
     198             : static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst,              \
     199             :                                             const uint8_t *_src,        \
     200             :                                             const uint8_t *unused0, const uint8_t *unused1,\
     201             :                                             int width,                  \
     202             :                                             uint32_t *rgb2yuv)          \
     203             : {                                                                       \
     204             :     const uint16_t *src = (const uint16_t *)_src;                       \
     205             :     uint16_t *dst       = (uint16_t *)_dst;                             \
     206             :     rgb48ToY_c_template(dst, src, width, origin, rgb2yuv);              \
     207             : }                                                                       \
     208             :                                                                         \
     209             : static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU,            \
     210             :                                              uint8_t *_dstV,            \
     211             :                                              const uint8_t *unused0,    \
     212             :                                              const uint8_t *_src1,      \
     213             :                                              const uint8_t *_src2,      \
     214             :                                              int width,                 \
     215             :                                              uint32_t *rgb2yuv)         \
     216             : {                                                                       \
     217             :     const uint16_t *src1 = (const uint16_t *)_src1,                     \
     218             :                    *src2 = (const uint16_t *)_src2;                     \
     219             :     uint16_t *dstU = (uint16_t *)_dstU,                                 \
     220             :              *dstV = (uint16_t *)_dstV;                                 \
     221             :     rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv);        \
     222             : }                                                                       \
     223             :                                                                         \
     224             : static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU,       \
     225             :                                                   uint8_t *_dstV,       \
     226             :                                                   const uint8_t *unused0,    \
     227             :                                                   const uint8_t *_src1, \
     228             :                                                   const uint8_t *_src2, \
     229             :                                                   int width,            \
     230             :                                                   uint32_t *rgb2yuv)    \
     231             : {                                                                       \
     232             :     const uint16_t *src1 = (const uint16_t *)_src1,                     \
     233             :                    *src2 = (const uint16_t *)_src2;                     \
     234             :     uint16_t *dstU = (uint16_t *)_dstU,                                 \
     235             :              *dstV = (uint16_t *)_dstV;                                 \
     236             :     rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv);   \
     237             : }
     238             : 
     239       90952 : rgb48funcs(rgb, LE, AV_PIX_FMT_RGB48LE)
     240        1408 : rgb48funcs(rgb, BE, AV_PIX_FMT_RGB48BE)
     241         576 : rgb48funcs(bgr, LE, AV_PIX_FMT_BGR48LE)
     242         576 : rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE)
     243             : 
     244             : #define input_pixel(i) ((origin == AV_PIX_FMT_RGBA ||                      \
     245             :                          origin == AV_PIX_FMT_BGRA ||                      \
     246             :                          origin == AV_PIX_FMT_ARGB ||                      \
     247             :                          origin == AV_PIX_FMT_ABGR)                        \
     248             :                         ? AV_RN32A(&src[(i) * 4])                       \
     249             :                         : (isBE(origin) ? AV_RB16(&src[(i) * 2])        \
     250             :                                         : AV_RL16(&src[(i) * 2])))
     251             : 
     252      725108 : static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
     253             :                                                     const uint8_t *src,
     254             :                                                     int width,
     255             :                                                     enum AVPixelFormat origin,
     256             :                                                     int shr, int shg,
     257             :                                                     int shb, int shp,
     258             :                                                     int maskr, int maskg,
     259             :                                                     int maskb, int rsh,
     260             :                                                     int gsh, int bsh, int S,
     261             :                                                     int32_t *rgb2yuv)
     262             : {
     263      725108 :     const int ry       = rgb2yuv[RY_IDX]<<rsh, gy = rgb2yuv[GY_IDX]<<gsh, by = rgb2yuv[BY_IDX]<<bsh;
     264      725108 :     const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
     265             :     int i;
     266             : 
     267   282327164 :     for (i = 0; i < width; i++) {
     268   281602056 :         int px = input_pixel(i) >> shp;
     269   281602056 :         int b  = (px & maskb) >> shb;
     270   281602056 :         int g  = (px & maskg) >> shg;
     271   281602056 :         int r  = (px & maskr) >> shr;
     272             : 
     273   281602056 :         dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
     274             :     }
     275      725108 : }
     276             : 
     277      247484 : static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU,
     278             :                                                      int16_t *dstV,
     279             :                                                      const uint8_t *src,
     280             :                                                      int width,
     281             :                                                      enum AVPixelFormat origin,
     282             :                                                      int shr, int shg,
     283             :                                                      int shb, int shp,
     284             :                                                      int maskr, int maskg,
     285             :                                                      int maskb, int rsh,
     286             :                                                      int gsh, int bsh, int S,
     287             :                                                      int32_t *rgb2yuv)
     288             : {
     289      247484 :     const int ru       = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
     290      247484 :               rv       = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh;
     291      247484 :     const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
     292             :     int i;
     293             : 
     294    57934356 :     for (i = 0; i < width; i++) {
     295    57686872 :         int px = input_pixel(i) >> shp;
     296    57686872 :         int b  = (px & maskb)   >> shb;
     297    57686872 :         int g  = (px & maskg)   >> shg;
     298    57686872 :         int r  = (px & maskr)   >> shr;
     299             : 
     300    57686872 :         dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
     301    57686872 :         dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
     302             :     }
     303      247484 : }
     304             : 
     305      410274 : static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU,
     306             :                                                           int16_t *dstV,
     307             :                                                           const uint8_t *src,
     308             :                                                           int width,
     309             :                                                           enum AVPixelFormat origin,
     310             :                                                           int shr, int shg,
     311             :                                                           int shb, int shp,
     312             :                                                           int maskr, int maskg,
     313             :                                                           int maskb, int rsh,
     314             :                                                           int gsh, int bsh, int S,
     315             :                                                           int32_t *rgb2yuv)
     316             : {
     317      410274 :     const int ru       = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
     318      410274 :               rv       = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh,
     319      410274 :               maskgx   = ~(maskr | maskb);
     320      410274 :     const unsigned rnd = (256U<<(S)) + (1<<(S-6));
     321             :     int i;
     322             : 
     323      410274 :     maskr |= maskr << 1;
     324      410274 :     maskb |= maskb << 1;
     325      410274 :     maskg |= maskg << 1;
     326   100919716 :     for (i = 0; i < width; i++) {
     327   100509442 :         unsigned px0 = input_pixel(2 * i + 0) >> shp;
     328   100509442 :         unsigned px1 = input_pixel(2 * i + 1) >> shp;
     329   100509442 :         int b, r, g = (px0 & maskgx) + (px1 & maskgx);
     330   100509442 :         int rb = px0 + px1 - g;
     331             : 
     332   100509442 :         b = (rb & maskb) >> shb;
     333   100509442 :         if (shp ||
     334   100425986 :             origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
     335    92692510 :             origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
     336     7867620 :             g >>= shg;
     337             :         } else {
     338    92641822 :             g = (g & maskg) >> shg;
     339             :         }
     340   100509442 :         r = (rb & maskr) >> shr;
     341             : 
     342   100509442 :         dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
     343   100509442 :         dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
     344             :     }
     345      410274 : }
     346             : 
     347             : #undef input_pixel
     348             : 
     349             : #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr,          \
     350             :                          maskg, maskb, rsh, gsh, bsh, S)                \
     351             : static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,            \
     352             :                           int width, uint32_t *tab)                     \
     353             : {                                                                       \
     354             :     rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp,    \
     355             :                            maskr, maskg, maskb, rsh, gsh, bsh, S, tab); \
     356             : }                                                                       \
     357             :                                                                         \
     358             : static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV,                \
     359             :                            const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy,    \
     360             :                            int width, uint32_t *tab)                    \
     361             : {                                                                       \
     362             :     rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt,                \
     363             :                             shr, shg, shb, shp,                         \
     364             :                             maskr, maskg, maskb, rsh, gsh, bsh, S, tab);\
     365             : }                                                                       \
     366             :                                                                         \
     367             : static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV,           \
     368             :                                 const uint8_t *unused0, const uint8_t *src,                     \
     369             :                                 const uint8_t *dummy,                   \
     370             :                                 int width, uint32_t *tab)               \
     371             : {                                                                       \
     372             :     rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt,           \
     373             :                                  shr, shg, shb, shp,                    \
     374             :                                  maskr, maskg, maskb,                   \
     375             :                                  rsh, gsh, bsh, S, tab);                \
     376             : }
     377             : 
     378     1012986 : rgb16_32_wrapper(AV_PIX_FMT_BGR32,    bgr32,  16, 0,  0, 0, 0xFF0000, 0xFF00,   0x00FF,  8, 0,  8, RGB2YUV_SHIFT + 8)
     379        1152 : rgb16_32_wrapper(AV_PIX_FMT_BGR32_1,  bgr321, 16, 0,  0, 8, 0xFF0000, 0xFF00,   0x00FF,  8, 0,  8, RGB2YUV_SHIFT + 8)
     380        3200 : rgb16_32_wrapper(AV_PIX_FMT_RGB32,    rgb32,   0, 0, 16, 0,   0x00FF, 0xFF00, 0xFF0000,  8, 0,  8, RGB2YUV_SHIFT + 8)
     381        1664 : rgb16_32_wrapper(AV_PIX_FMT_RGB32_1,  rgb321,  0, 0, 16, 8,   0x00FF, 0xFF00, 0xFF0000,  8, 0,  8, RGB2YUV_SHIFT + 8)
     382         576 : rgb16_32_wrapper(AV_PIX_FMT_BGR565LE, bgr16le, 0, 0,  0, 0,   0x001F, 0x07E0,   0xF800, 11, 5,  0, RGB2YUV_SHIFT + 8)
     383         576 : rgb16_32_wrapper(AV_PIX_FMT_BGR555LE, bgr15le, 0, 0,  0, 0,   0x001F, 0x03E0,   0x7C00, 10, 5,  0, RGB2YUV_SHIFT + 7)
     384         576 : rgb16_32_wrapper(AV_PIX_FMT_BGR444LE, bgr12le, 0, 0,  0, 0,   0x000F, 0x00F0,   0x0F00,  8, 4,  0, RGB2YUV_SHIFT + 4)
     385       90952 : rgb16_32_wrapper(AV_PIX_FMT_RGB565LE, rgb16le, 0, 0,  0, 0,   0xF800, 0x07E0,   0x001F,  0, 5, 11, RGB2YUV_SHIFT + 8)
     386      267152 : rgb16_32_wrapper(AV_PIX_FMT_RGB555LE, rgb15le, 0, 0,  0, 0,   0x7C00, 0x03E0,   0x001F,  0, 5, 10, RGB2YUV_SHIFT + 7)
     387         576 : rgb16_32_wrapper(AV_PIX_FMT_RGB444LE, rgb12le, 0, 0,  0, 0,   0x0F00, 0x00F0,   0x000F,  0, 4,  8, RGB2YUV_SHIFT + 4)
     388         576 : rgb16_32_wrapper(AV_PIX_FMT_BGR565BE, bgr16be, 0, 0,  0, 0,   0x001F, 0x07E0,   0xF800, 11, 5,  0, RGB2YUV_SHIFT + 8)
     389         576 : rgb16_32_wrapper(AV_PIX_FMT_BGR555BE, bgr15be, 0, 0,  0, 0,   0x001F, 0x03E0,   0x7C00, 10, 5,  0, RGB2YUV_SHIFT + 7)
     390         576 : rgb16_32_wrapper(AV_PIX_FMT_BGR444BE, bgr12be, 0, 0,  0, 0,   0x000F, 0x00F0,   0x0F00,  8, 4,  0, RGB2YUV_SHIFT + 4)
     391         576 : rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0,  0, 0,   0xF800, 0x07E0,   0x001F,  0, 5, 11, RGB2YUV_SHIFT + 8)
     392         576 : rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0,  0, 0,   0x7C00, 0x03E0,   0x001F,  0, 5, 10, RGB2YUV_SHIFT + 7)
     393         576 : rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0,  0, 0,   0x0F00, 0x00F0,   0x000F,  0, 4,  8, RGB2YUV_SHIFT + 4)
     394             : 
     395           0 : static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
     396             :                          const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
     397             :                          int width, uint32_t *rgb2yuv)
     398             : {
     399           0 :     uint16_t *dstU = (uint16_t *)_dstU;
     400           0 :     uint16_t *dstV = (uint16_t *)_dstV;
     401           0 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     402           0 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     403             : 
     404             :     int i;
     405           0 :     for (i = 0; i < width; i++) {
     406           0 :         unsigned int g   = gsrc[2*i] + gsrc[2*i+1];
     407           0 :         unsigned int b   = bsrc[2*i] + bsrc[2*i+1];
     408           0 :         unsigned int r   = rsrc[2*i] + rsrc[2*i+1];
     409             : 
     410           0 :         dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
     411           0 :         dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
     412             :     }
     413           0 : }
     414             : 
     415         576 : static void rgba64leToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
     416             :                           const uint8_t *unused2, int width, uint32_t *unused)
     417             : {
     418         576 :     int16_t *dst = (int16_t *)_dst;
     419         576 :     const uint16_t *src = (const uint16_t *)_src;
     420             :     int i;
     421      203328 :     for (i = 0; i < width; i++)
     422      202752 :         dst[i] = AV_RL16(src + 4 * i + 3);
     423         576 : }
     424             : 
     425         576 : static void rgba64beToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
     426             :                           const uint8_t *unused2, int width, uint32_t *unused)
     427             : {
     428         576 :     int16_t *dst = (int16_t *)_dst;
     429         576 :     const uint16_t *src = (const uint16_t *)_src;
     430             :     int i;
     431      203328 :     for (i = 0; i < width; i++)
     432      202752 :         dst[i] = AV_RB16(src + 4 * i + 3);
     433         576 : }
     434             : 
     435        1408 : static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
     436             : {
     437        1408 :     int16_t *dst = (int16_t *)_dst;
     438             :     int i;
     439      472448 :     for (i=0; i<width; i++) {
     440      471040 :         dst[i]= src[4*i]<<6;
     441             :     }
     442        1408 : }
     443             : 
     444      167314 : static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
     445             : {
     446      167314 :     int16_t *dst = (int16_t *)_dst;
     447             :     int i;
     448   119051868 :     for (i=0; i<width; i++) {
     449   118884554 :         dst[i]= src[4*i+3]<<6;
     450             :     }
     451      167314 : }
     452             : 
     453           0 : static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
     454             : {
     455           0 :     int16_t *dst = (int16_t *)_dst;
     456             :     int i;
     457           0 :     for (i=0; i<width; i++) {
     458           0 :         int d= src[i];
     459             : 
     460           0 :         dst[i]= (pal[d] >> 24)<<6;
     461             :     }
     462           0 : }
     463             : 
     464       94340 : static void palToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
     465             : {
     466       94340 :     int16_t *dst = (int16_t *)_dst;
     467             :     int i;
     468    32607820 :     for (i = 0; i < width; i++) {
     469    32513480 :         int d = src[i];
     470             : 
     471    32513480 :         dst[i] = (pal[d] & 0xFF)<<6;
     472             :     }
     473       94340 : }
     474             : 
     475       94340 : static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV,
     476             :                            const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
     477             :                       int width, uint32_t *pal)
     478             : {
     479       94340 :     uint16_t *dstU = (uint16_t *)_dstU;
     480       94340 :     int16_t *dstV = (int16_t *)_dstV;
     481             :     int i;
     482             :     av_assert1(src1 == src2);
     483    32607820 :     for (i = 0; i < width; i++) {
     484    32513480 :         int p = pal[src1[i]];
     485             : 
     486    32513480 :         dstU[i] = (uint8_t)(p>> 8)<<6;
     487    32513480 :         dstV[i] = (uint8_t)(p>>16)<<6;
     488             :     }
     489       94340 : }
     490             : 
     491       11926 : static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,  int width, uint32_t *unused)
     492             : {
     493       11926 :     int16_t *dst = (int16_t *)_dst;
     494             :     int i, j;
     495       11926 :     width = (width + 7) >> 3;
     496      105370 :     for (i = 0; i < width; i++) {
     497       93444 :         int d = ~src[i];
     498      840996 :         for (j = 0; j < 8; j++)
     499      747552 :             dst[8*i+j]= ((d>>(7-j))&1) * 16383;
     500             :     }
     501       11926 :     if(width&7){
     502       11926 :         int d= ~src[i];
     503       82330 :         for (j = 0; j < (width&7); j++)
     504       70404 :             dst[8*i+j]= ((d>>(7-j))&1) * 16383;
     505             :     }
     506       11926 : }
     507             : 
     508         576 : static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,  int width, uint32_t *unused)
     509             : {
     510         576 :     int16_t *dst = (int16_t *)_dst;
     511             :     int i, j;
     512         576 :     width = (width + 7) >> 3;
     513       25920 :     for (i = 0; i < width; i++) {
     514       25344 :         int d = src[i];
     515      228096 :         for (j = 0; j < 8; j++)
     516      202752 :             dst[8*i+j]= ((d>>(7-j))&1) * 16383;
     517             :     }
     518         576 :     if(width&7){
     519         576 :         int d = src[i];
     520        2880 :         for (j = 0; j < (width&7); j++)
     521        2304 :             dst[8*i+j] = ((d>>(7-j))&1) * 16383;
     522             :     }
     523         576 : }
     524             : 
     525        1408 : static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,  int width,
     526             :                       uint32_t *unused)
     527             : {
     528             :     int i;
     529      439680 :     for (i = 0; i < width; i++)
     530      438272 :         dst[i] = src[2 * i];
     531        1408 : }
     532             : 
     533         576 : static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
     534             :                        const uint8_t *src2, int width, uint32_t *unused)
     535             : {
     536             :     int i;
     537      101952 :     for (i = 0; i < width; i++) {
     538      101376 :         dstU[i] = src1[4 * i + 1];
     539      101376 :         dstV[i] = src1[4 * i + 3];
     540             :     }
     541             :     av_assert1(src1 == src2);
     542         576 : }
     543             : 
     544         288 : static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
     545             :                        const uint8_t *src2, int width, uint32_t *unused)
     546             : {
     547             :     int i;
     548       50976 :     for (i = 0; i < width; i++) {
     549       50688 :         dstV[i] = src1[4 * i + 1];
     550       50688 :         dstU[i] = src1[4 * i + 3];
     551             :     }
     552             :     av_assert1(src1 == src2);
     553         288 : }
     554             : 
     555       11488 : static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
     556             :                        uint32_t *unused)
     557             : {
     558             :     int i;
     559       11488 :     const uint16_t *src = (const uint16_t *)_src;
     560       11488 :     uint16_t *dst       = (uint16_t *)_dst;
     561     3997920 :     for (i = 0; i < width; i++)
     562     3986432 :         dst[i] = av_bswap16(src[i]);
     563       11488 : }
     564             : 
     565        6048 : static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
     566             :                         const uint8_t *_src2, int width, uint32_t *unused)
     567             : {
     568             :     int i;
     569        6048 :     const uint16_t *src1 = (const uint16_t *)_src1,
     570        6048 :     *src2                = (const uint16_t *)_src2;
     571        6048 :     uint16_t *dstU       = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
     572     1526688 :     for (i = 0; i < width; i++) {
     573     1520640 :         dstU[i] = av_bswap16(src1[i]);
     574     1520640 :         dstV[i] = av_bswap16(src2[i]);
     575             :     }
     576        6048 : }
     577             : 
     578           0 : static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
     579             :                                uint32_t *unused)
     580             : {
     581             :     int i;
     582           0 :     for (i = 0; i < width; i++)
     583           0 :         AV_WN16(dst + i * 2, AV_RL16(src + i * 4));
     584           0 : }
     585             : 
     586           0 : static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
     587             :                                 uint32_t *unused)
     588             : {
     589             :     int i;
     590           0 :     for (i = 0; i < width; i++)
     591           0 :         AV_WN16(dst + i * 2, AV_RL16(src + i * 4 + 2));
     592           0 : }
     593             : 
     594         256 : static void read_ya16be_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
     595             :                                uint32_t *unused)
     596             : {
     597             :     int i;
     598       33024 :     for (i = 0; i < width; i++)
     599       32768 :         AV_WN16(dst + i * 2, AV_RB16(src + i * 4));
     600         256 : }
     601             : 
     602           0 : static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
     603             :                                 uint32_t *unused)
     604             : {
     605             :     int i;
     606           0 :     for (i = 0; i < width; i++)
     607           0 :         AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2));
     608           0 : }
     609             : 
     610         288 : static void read_ayuv64le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
     611             :                                uint32_t *unused2)
     612             : {
     613             :     int i;
     614      101664 :     for (i = 0; i < width; i++)
     615      101376 :         AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2));
     616         288 : }
     617             : 
     618             : 
     619         288 : static void read_ayuv64le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
     620             :                                const uint8_t *unused1, int width, uint32_t *unused2)
     621             : {
     622             :     int i;
     623      101664 :     for (i = 0; i < width; i++) {
     624      101376 :         AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 4));
     625      101376 :         AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6));
     626             :     }
     627         288 : }
     628             : 
     629         288 : static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
     630             :                                 uint32_t *unused2)
     631             : {
     632             :     int i;
     633      101664 :     for (i = 0; i < width; i++)
     634      101376 :         AV_WN16(dst + i * 2, AV_RL16(src + i * 8));
     635         288 : }
     636             : 
     637             : /* This is almost identical to the previous, end exists only because
     638             :  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
     639         576 : static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,  int width,
     640             :                       uint32_t *unused)
     641             : {
     642             :     int i;
     643      203328 :     for (i = 0; i < width; i++)
     644      202752 :         dst[i] = src[2 * i + 1];
     645         576 : }
     646             : 
     647         288 : static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
     648             :                        const uint8_t *src2, int width, uint32_t *unused)
     649             : {
     650             :     int i;
     651       50976 :     for (i = 0; i < width; i++) {
     652       50688 :         dstU[i] = src1[4 * i + 0];
     653       50688 :         dstV[i] = src1[4 * i + 2];
     654             :     }
     655             :     av_assert1(src1 == src2);
     656         288 : }
     657             : 
     658         288 : static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
     659             :                                         const uint8_t *src, int width)
     660             : {
     661             :     int i;
     662       50976 :     for (i = 0; i < width; i++) {
     663       50688 :         dst1[i] = src[2 * i + 0];
     664       50688 :         dst2[i] = src[2 * i + 1];
     665             :     }
     666         288 : }
     667             : 
     668         144 : static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
     669             :                        const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
     670             :                        int width, uint32_t *unused)
     671             : {
     672         144 :     nvXXtoUV_c(dstU, dstV, src1, width);
     673         144 : }
     674             : 
     675         144 : static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
     676             :                        const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
     677             :                        int width, uint32_t *unused)
     678             : {
     679         144 :     nvXXtoUV_c(dstV, dstU, src1, width);
     680         144 : }
     681             : 
     682         288 : static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
     683             :                         const uint8_t *unused2, int width, uint32_t *unused)
     684             : {
     685             :     int i;
     686      101664 :     for (i = 0; i < width; i++) {
     687      101376 :         AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> 6);
     688             :     }
     689         288 : }
     690             : 
     691         288 : static void p010BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
     692             :                         const uint8_t *unused2, int width, uint32_t *unused)
     693             : {
     694             :     int i;
     695      101664 :     for (i = 0; i < width; i++) {
     696      101376 :         AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> 6);
     697             :     }
     698         288 : }
     699             : 
     700         144 : static void p010LEToUV_c(uint8_t *dstU, uint8_t *dstV,
     701             :                        const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
     702             :                        int width, uint32_t *unused)
     703             : {
     704             :     int i;
     705       25488 :     for (i = 0; i < width; i++) {
     706       25344 :         AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> 6);
     707       25344 :         AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> 6);
     708             :     }
     709         144 : }
     710             : 
     711         144 : static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV,
     712             :                        const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
     713             :                        int width, uint32_t *unused)
     714             : {
     715             :     int i;
     716       25488 :     for (i = 0; i < width; i++) {
     717       25344 :         AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> 6);
     718       25344 :         AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> 6);
     719             :     }
     720         144 : }
     721             : 
     722           0 : static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV,
     723             :                        const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
     724             :                        int width, uint32_t *unused)
     725             : {
     726             :     int i;
     727           0 :     for (i = 0; i < width; i++) {
     728           0 :         AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0));
     729           0 :         AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2));
     730             :     }
     731           0 : }
     732             : 
     733           0 : static void p016BEToUV_c(uint8_t *dstU, uint8_t *dstV,
     734             :                        const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
     735             :                        int width, uint32_t *unused)
     736             : {
     737             :     int i;
     738           0 :     for (i = 0; i < width; i++) {
     739           0 :         AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0));
     740           0 :         AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2));
     741             :     }
     742           0 : }
     743             : 
     744             : #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
     745             : 
     746      225076 : static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
     747             :                        int width, uint32_t *rgb2yuv)
     748             : {
     749      225076 :     int16_t *dst = (int16_t *)_dst;
     750      225076 :     int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
     751             :     int i;
     752    76748828 :     for (i = 0; i < width; i++) {
     753    76523752 :         int b = src[i * 3 + 0];
     754    76523752 :         int g = src[i * 3 + 1];
     755    76523752 :         int r = src[i * 3 + 2];
     756             : 
     757    76523752 :         dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
     758             :     }
     759      225076 : }
     760             : 
     761         576 : static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
     762             :                         const uint8_t *src2, int width, uint32_t *rgb2yuv)
     763             : {
     764         576 :     int16_t *dstU = (int16_t *)_dstU;
     765         576 :     int16_t *dstV = (int16_t *)_dstV;
     766         576 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     767         576 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     768             :     int i;
     769      203328 :     for (i = 0; i < width; i++) {
     770      202752 :         int b = src1[3 * i + 0];
     771      202752 :         int g = src1[3 * i + 1];
     772      202752 :         int r = src1[3 * i + 2];
     773             : 
     774      202752 :         dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
     775      202752 :         dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
     776             :     }
     777             :     av_assert1(src1 == src2);
     778         576 : }
     779             : 
     780      224500 : static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
     781             :                              const uint8_t *src2, int width, uint32_t *rgb2yuv)
     782             : {
     783      224500 :     int16_t *dstU = (int16_t *)_dstU;
     784      224500 :     int16_t *dstV = (int16_t *)_dstV;
     785             :     int i;
     786      224500 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     787      224500 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     788    38385000 :     for (i = 0; i < width; i++) {
     789    38160500 :         int b = src1[6 * i + 0] + src1[6 * i + 3];
     790    38160500 :         int g = src1[6 * i + 1] + src1[6 * i + 4];
     791    38160500 :         int r = src1[6 * i + 2] + src1[6 * i + 5];
     792             : 
     793    38160500 :         dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
     794    38160500 :         dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
     795             :     }
     796             :     av_assert1(src1 == src2);
     797      224500 : }
     798             : 
     799      260560 : static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
     800             :                        uint32_t *rgb2yuv)
     801             : {
     802      260560 :     int16_t *dst = (int16_t *)_dst;
     803      260560 :     int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
     804             :     int i;
     805    81675080 :     for (i = 0; i < width; i++) {
     806    81414520 :         int r = src[i * 3 + 0];
     807    81414520 :         int g = src[i * 3 + 1];
     808    81414520 :         int b = src[i * 3 + 2];
     809             : 
     810    81414520 :         dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
     811             :     }
     812      260560 : }
     813             : 
     814         976 : static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
     815             :                         const uint8_t *src2, int width, uint32_t *rgb2yuv)
     816             : {
     817         976 :     int16_t *dstU = (int16_t *)_dstU;
     818         976 :     int16_t *dstV = (int16_t *)_dstV;
     819             :     int i;
     820         976 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     821         976 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     822             :     av_assert1(src1 == src2);
     823      256928 :     for (i = 0; i < width; i++) {
     824      255952 :         int r = src1[3 * i + 0];
     825      255952 :         int g = src1[3 * i + 1];
     826      255952 :         int b = src1[3 * i + 2];
     827             : 
     828      255952 :         dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
     829      255952 :         dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
     830             :     }
     831         976 : }
     832             : 
     833      293184 : static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
     834             :                              const uint8_t *src2, int width, uint32_t *rgb2yuv)
     835             : {
     836      293184 :     int16_t *dstU = (int16_t *)_dstU;
     837      293184 :     int16_t *dstV = (int16_t *)_dstV;
     838             :     int i;
     839      293184 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     840      293184 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     841             :     av_assert1(src1 == src2);
     842    46248468 :     for (i = 0; i < width; i++) {
     843    45955284 :         int r = src1[6 * i + 0] + src1[6 * i + 3];
     844    45955284 :         int g = src1[6 * i + 1] + src1[6 * i + 4];
     845    45955284 :         int b = src1[6 * i + 2] + src1[6 * i + 5];
     846             : 
     847    45955284 :         dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
     848    45955284 :         dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
     849             :     }
     850      293184 : }
     851             : 
     852        1424 : static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
     853             : {
     854        1424 :     uint16_t *dst = (uint16_t *)_dst;
     855        1424 :     int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
     856             :     int i;
     857      272400 :     for (i = 0; i < width; i++) {
     858      270976 :         int g = src[0][i];
     859      270976 :         int b = src[1][i];
     860      270976 :         int r = src[2][i];
     861             : 
     862      270976 :         dst[i] = (ry*r + gy*g + by*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
     863             :     }
     864        1424 : }
     865             : 
     866         468 : static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused)
     867             : {
     868         468 :     uint16_t *dst = (uint16_t *)_dst;
     869             :     int i;
     870      114804 :     for (i = 0; i < width; i++)
     871      114336 :         dst[i] = src[3][i] << 6;
     872         468 : }
     873             : 
     874        1424 : static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
     875             : {
     876        1424 :     uint16_t *dstU = (uint16_t *)_dstU;
     877        1424 :     uint16_t *dstV = (uint16_t *)_dstV;
     878        1424 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     879        1424 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     880             :     int i;
     881      272400 :     for (i = 0; i < width; i++) {
     882      270976 :         int g = src[0][i];
     883      270976 :         int b = src[1][i];
     884      270976 :         int r = src[2][i];
     885             : 
     886      270976 :         dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
     887      270976 :         dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
     888             :     }
     889        1424 : }
     890             : 
     891             : #define rdpx(src) \
     892             :     is_be ? AV_RB16(src) : AV_RL16(src)
     893       49764 : static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
     894             :                                                int width, int bpc, int is_be, int32_t *rgb2yuv)
     895             : {
     896             :     int i;
     897       49764 :     const uint16_t **src = (const uint16_t **)_src;
     898       49764 :     uint16_t *dst        = (uint16_t *)_dst;
     899       49764 :     int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
     900       49764 :     int shift = bpc < 16 ? bpc : 14;
     901    16968748 :     for (i = 0; i < width; i++) {
     902    16918984 :         int g = rdpx(src[0] + i);
     903    16918984 :         int b = rdpx(src[1] + i);
     904    16918984 :         int r = rdpx(src[2] + i);
     905             : 
     906    16918984 :         dst[i] = ((ry*r + gy*g + by*b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14));
     907             :     }
     908       49764 : }
     909             : 
     910        1728 : static av_always_inline void planar_rgb16_to_a(uint8_t *_dst, const uint8_t *_src[4],
     911             :                                                int width, int bpc, int is_be, int32_t *rgb2yuv)
     912             : {
     913             :     int i;
     914        1728 :     const uint16_t **src = (const uint16_t **)_src;
     915        1728 :     uint16_t *dst        = (uint16_t *)_dst;
     916        1728 :     int shift = bpc < 16 ? bpc : 14;
     917             : 
     918      609984 :     for (i = 0; i < width; i++) {
     919      608256 :         dst[i] = rdpx(src[3] + i) << (14 - shift);
     920             :     }
     921        1728 : }
     922             : 
     923       27314 : static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
     924             :                                                 const uint8_t *_src[4], int width,
     925             :                                                 int bpc, int is_be, int32_t *rgb2yuv)
     926             : {
     927             :     int i;
     928       27314 :     const uint16_t **src = (const uint16_t **)_src;
     929       27314 :     uint16_t *dstU       = (uint16_t *)_dstU;
     930       27314 :     uint16_t *dstV       = (uint16_t *)_dstV;
     931       27314 :     int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
     932       27314 :     int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
     933       27314 :     int shift = bpc < 16 ? bpc : 14;
     934     9314198 :     for (i = 0; i < width; i++) {
     935     9286884 :         int g = rdpx(src[0] + i);
     936     9286884 :         int b = rdpx(src[1] + i);
     937     9286884 :         int r = rdpx(src[2] + i);
     938             : 
     939     9286884 :         dstU[i] = (ru*r + gu*g + bu*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
     940     9286884 :         dstV[i] = (rv*r + gv*g + bv*b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + shift - 14);
     941             :     }
     942       27314 : }
     943             : #undef rdpx
     944             : 
     945             : #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian)                                    \
     946             : static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4],              \
     947             :                                                   int w, int32_t *rgb2yuv)                          \
     948             : {                                                                                                   \
     949             :     planar_rgb16_to_y(dst, src, w, nbits, endian, rgb2yuv);                                         \
     950             : }                                                                                                   \
     951             : static void planar_rgb##nbits##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV,                    \
     952             :                                                    const uint8_t *src[4], int w, int32_t *rgb2yuv)  \
     953             : {                                                                                                   \
     954             :     planar_rgb16_to_uv(dstU, dstV, src, w, nbits, endian, rgb2yuv);                                 \
     955             : }                                                                                                   \
     956             : 
     957             : #define rgb9plus_planar_transparency_funcs(nbits)                           \
     958             : static void planar_rgb##nbits##le_to_a(uint8_t *dst, const uint8_t *src[4], \
     959             :                                        int w, int32_t *rgb2yuv)             \
     960             : {                                                                           \
     961             :     planar_rgb16_to_a(dst, src, w, nbits, 0, rgb2yuv);                      \
     962             : }                                                                           \
     963             : static void planar_rgb##nbits##be_to_a(uint8_t *dst, const uint8_t *src[4], \
     964             :                                        int w, int32_t *rgb2yuv)             \
     965             : {                                                                           \
     966             :     planar_rgb16_to_a(dst, src, w, nbits, 1, rgb2yuv);                      \
     967             : }
     968             : 
     969             : #define rgb9plus_planar_funcs(nbits)            \
     970             :     rgb9plus_planar_funcs_endian(nbits, le, 0)  \
     971             :     rgb9plus_planar_funcs_endian(nbits, be, 1)
     972             : 
     973        1152 : rgb9plus_planar_funcs(9)
     974        2304 : rgb9plus_planar_funcs(10)
     975        2304 : rgb9plus_planar_funcs(12)
     976        1152 : rgb9plus_planar_funcs(14)
     977       70166 : rgb9plus_planar_funcs(16)
     978             : 
     979         576 : rgb9plus_planar_transparency_funcs(10)
     980         576 : rgb9plus_planar_transparency_funcs(12)
     981         576 : rgb9plus_planar_transparency_funcs(16)
     982             : 
     983        2406 : av_cold void ff_sws_init_input_funcs(SwsContext *c)
     984             : {
     985        2406 :     enum AVPixelFormat srcFormat = c->srcFormat;
     986             : 
     987        2406 :     c->chrToYV12 = NULL;
     988        2406 :     switch (srcFormat) {
     989           2 :     case AV_PIX_FMT_YUYV422:
     990           2 :         c->chrToYV12 = yuy2ToUV_c;
     991           2 :         break;
     992           1 :     case AV_PIX_FMT_YVYU422:
     993           1 :         c->chrToYV12 = yvy2ToUV_c;
     994           1 :         break;
     995           1 :     case AV_PIX_FMT_UYVY422:
     996           1 :         c->chrToYV12 = uyvyToUV_c;
     997           1 :         break;
     998           1 :     case AV_PIX_FMT_NV12:
     999           1 :         c->chrToYV12 = nv12ToUV_c;
    1000           1 :         break;
    1001           1 :     case AV_PIX_FMT_NV21:
    1002           1 :         c->chrToYV12 = nv21ToUV_c;
    1003           1 :         break;
    1004          13 :     case AV_PIX_FMT_RGB8:
    1005             :     case AV_PIX_FMT_BGR8:
    1006             :     case AV_PIX_FMT_PAL8:
    1007             :     case AV_PIX_FMT_BGR4_BYTE:
    1008             :     case AV_PIX_FMT_RGB4_BYTE:
    1009          13 :         c->chrToYV12 = palToUV_c;
    1010          13 :         break;
    1011           1 :     case AV_PIX_FMT_GBRP9LE:
    1012           1 :         c->readChrPlanar = planar_rgb9le_to_uv;
    1013           1 :         break;
    1014           2 :     case AV_PIX_FMT_GBRAP10LE:
    1015             :     case AV_PIX_FMT_GBRP10LE:
    1016           2 :         c->readChrPlanar = planar_rgb10le_to_uv;
    1017           2 :         break;
    1018           2 :     case AV_PIX_FMT_GBRAP12LE:
    1019             :     case AV_PIX_FMT_GBRP12LE:
    1020           2 :         c->readChrPlanar = planar_rgb12le_to_uv;
    1021           2 :         break;
    1022           1 :     case AV_PIX_FMT_GBRP14LE:
    1023           1 :         c->readChrPlanar = planar_rgb14le_to_uv;
    1024           1 :         break;
    1025           6 :     case AV_PIX_FMT_GBRAP16LE:
    1026             :     case AV_PIX_FMT_GBRP16LE:
    1027           6 :         c->readChrPlanar = planar_rgb16le_to_uv;
    1028           6 :         break;
    1029           1 :     case AV_PIX_FMT_GBRP9BE:
    1030           1 :         c->readChrPlanar = planar_rgb9be_to_uv;
    1031           1 :         break;
    1032           2 :     case AV_PIX_FMT_GBRAP10BE:
    1033             :     case AV_PIX_FMT_GBRP10BE:
    1034           2 :         c->readChrPlanar = planar_rgb10be_to_uv;
    1035           2 :         break;
    1036           2 :     case AV_PIX_FMT_GBRAP12BE:
    1037             :     case AV_PIX_FMT_GBRP12BE:
    1038           2 :         c->readChrPlanar = planar_rgb12be_to_uv;
    1039           2 :         break;
    1040           1 :     case AV_PIX_FMT_GBRP14BE:
    1041           1 :         c->readChrPlanar = planar_rgb14be_to_uv;
    1042           1 :         break;
    1043           4 :     case AV_PIX_FMT_GBRAP16BE:
    1044             :     case AV_PIX_FMT_GBRP16BE:
    1045           4 :         c->readChrPlanar = planar_rgb16be_to_uv;
    1046           4 :         break;
    1047           7 :     case AV_PIX_FMT_GBRAP:
    1048             :     case AV_PIX_FMT_GBRP:
    1049           7 :         c->readChrPlanar = planar_rgb_to_uv;
    1050           7 :         break;
    1051             : #if HAVE_BIGENDIAN
    1052             :     case AV_PIX_FMT_YUV420P9LE:
    1053             :     case AV_PIX_FMT_YUV422P9LE:
    1054             :     case AV_PIX_FMT_YUV444P9LE:
    1055             :     case AV_PIX_FMT_YUV420P10LE:
    1056             :     case AV_PIX_FMT_YUV422P10LE:
    1057             :     case AV_PIX_FMT_YUV440P10LE:
    1058             :     case AV_PIX_FMT_YUV444P10LE:
    1059             :     case AV_PIX_FMT_YUV420P12LE:
    1060             :     case AV_PIX_FMT_YUV422P12LE:
    1061             :     case AV_PIX_FMT_YUV440P12LE:
    1062             :     case AV_PIX_FMT_YUV444P12LE:
    1063             :     case AV_PIX_FMT_YUV420P14LE:
    1064             :     case AV_PIX_FMT_YUV422P14LE:
    1065             :     case AV_PIX_FMT_YUV444P14LE:
    1066             :     case AV_PIX_FMT_YUV420P16LE:
    1067             :     case AV_PIX_FMT_YUV422P16LE:
    1068             :     case AV_PIX_FMT_YUV444P16LE:
    1069             : 
    1070             :     case AV_PIX_FMT_YUVA420P9LE:
    1071             :     case AV_PIX_FMT_YUVA422P9LE:
    1072             :     case AV_PIX_FMT_YUVA444P9LE:
    1073             :     case AV_PIX_FMT_YUVA420P10LE:
    1074             :     case AV_PIX_FMT_YUVA422P10LE:
    1075             :     case AV_PIX_FMT_YUVA444P10LE:
    1076             :     case AV_PIX_FMT_YUVA420P16LE:
    1077             :     case AV_PIX_FMT_YUVA422P16LE:
    1078             :     case AV_PIX_FMT_YUVA444P16LE:
    1079             :         c->chrToYV12 = bswap16UV_c;
    1080             :         break;
    1081             : #else
    1082          26 :     case AV_PIX_FMT_YUV420P9BE:
    1083             :     case AV_PIX_FMT_YUV422P9BE:
    1084             :     case AV_PIX_FMT_YUV444P9BE:
    1085             :     case AV_PIX_FMT_YUV420P10BE:
    1086             :     case AV_PIX_FMT_YUV422P10BE:
    1087             :     case AV_PIX_FMT_YUV440P10BE:
    1088             :     case AV_PIX_FMT_YUV444P10BE:
    1089             :     case AV_PIX_FMT_YUV420P12BE:
    1090             :     case AV_PIX_FMT_YUV422P12BE:
    1091             :     case AV_PIX_FMT_YUV440P12BE:
    1092             :     case AV_PIX_FMT_YUV444P12BE:
    1093             :     case AV_PIX_FMT_YUV420P14BE:
    1094             :     case AV_PIX_FMT_YUV422P14BE:
    1095             :     case AV_PIX_FMT_YUV444P14BE:
    1096             :     case AV_PIX_FMT_YUV420P16BE:
    1097             :     case AV_PIX_FMT_YUV422P16BE:
    1098             :     case AV_PIX_FMT_YUV444P16BE:
    1099             : 
    1100             :     case AV_PIX_FMT_YUVA420P9BE:
    1101             :     case AV_PIX_FMT_YUVA422P9BE:
    1102             :     case AV_PIX_FMT_YUVA444P9BE:
    1103             :     case AV_PIX_FMT_YUVA420P10BE:
    1104             :     case AV_PIX_FMT_YUVA422P10BE:
    1105             :     case AV_PIX_FMT_YUVA444P10BE:
    1106             :     case AV_PIX_FMT_YUVA420P16BE:
    1107             :     case AV_PIX_FMT_YUVA422P16BE:
    1108             :     case AV_PIX_FMT_YUVA444P16BE:
    1109          26 :         c->chrToYV12 = bswap16UV_c;
    1110          26 :         break;
    1111             : #endif
    1112           1 :     case AV_PIX_FMT_AYUV64LE:
    1113           1 :         c->chrToYV12 = read_ayuv64le_UV_c;
    1114           1 :         break;
    1115           1 :     case AV_PIX_FMT_P010LE:
    1116           1 :         c->chrToYV12 = p010LEToUV_c;
    1117           1 :         break;
    1118           1 :     case AV_PIX_FMT_P010BE:
    1119           1 :         c->chrToYV12 = p010BEToUV_c;
    1120           1 :         break;
    1121           0 :     case AV_PIX_FMT_P016LE:
    1122           0 :         c->chrToYV12 = p016LEToUV_c;
    1123           0 :         break;
    1124           0 :     case AV_PIX_FMT_P016BE:
    1125           0 :         c->chrToYV12 = p016BEToUV_c;
    1126           0 :         break;
    1127             :     }
    1128        2406 :     if (c->chrSrcHSubSample) {
    1129        2217 :         switch (srcFormat) {
    1130           0 :         case AV_PIX_FMT_RGBA64BE:
    1131           0 :             c->chrToYV12 = rgb64BEToUV_half_c;
    1132           0 :             break;
    1133           0 :         case AV_PIX_FMT_RGBA64LE:
    1134           0 :             c->chrToYV12 = rgb64LEToUV_half_c;
    1135           0 :             break;
    1136           0 :         case AV_PIX_FMT_BGRA64BE:
    1137           0 :             c->chrToYV12 = bgr64BEToUV_half_c;
    1138           0 :             break;
    1139           0 :         case AV_PIX_FMT_BGRA64LE:
    1140           0 :             c->chrToYV12 = bgr64LEToUV_half_c;
    1141           0 :             break;
    1142           0 :         case AV_PIX_FMT_RGB48BE:
    1143           0 :             c->chrToYV12 = rgb48BEToUV_half_c;
    1144           0 :             break;
    1145           4 :         case AV_PIX_FMT_RGB48LE:
    1146           4 :             c->chrToYV12 = rgb48LEToUV_half_c;
    1147           4 :             break;
    1148           0 :         case AV_PIX_FMT_BGR48BE:
    1149           0 :             c->chrToYV12 = bgr48BEToUV_half_c;
    1150           0 :             break;
    1151           0 :         case AV_PIX_FMT_BGR48LE:
    1152           0 :             c->chrToYV12 = bgr48LEToUV_half_c;
    1153           0 :             break;
    1154          14 :         case AV_PIX_FMT_RGB32:
    1155          14 :             c->chrToYV12 = bgr32ToUV_half_c;
    1156          14 :             break;
    1157           0 :         case AV_PIX_FMT_RGB32_1:
    1158           0 :             c->chrToYV12 = bgr321ToUV_half_c;
    1159           0 :             break;
    1160          20 :         case AV_PIX_FMT_BGR24:
    1161          20 :             c->chrToYV12 = bgr24ToUV_half_c;
    1162          20 :             break;
    1163           1 :         case AV_PIX_FMT_BGR565LE:
    1164           1 :             c->chrToYV12 = bgr16leToUV_half_c;
    1165           1 :             break;
    1166           1 :         case AV_PIX_FMT_BGR565BE:
    1167           1 :             c->chrToYV12 = bgr16beToUV_half_c;
    1168           1 :             break;
    1169           1 :         case AV_PIX_FMT_BGR555LE:
    1170           1 :             c->chrToYV12 = bgr15leToUV_half_c;
    1171           1 :             break;
    1172           1 :         case AV_PIX_FMT_BGR555BE:
    1173           1 :             c->chrToYV12 = bgr15beToUV_half_c;
    1174           1 :             break;
    1175           0 :         case AV_PIX_FMT_GBRAP:
    1176             :         case AV_PIX_FMT_GBRP:
    1177           0 :             c->chrToYV12 = gbr24pToUV_half_c;
    1178           0 :             break;
    1179           1 :         case AV_PIX_FMT_BGR444LE:
    1180           1 :             c->chrToYV12 = bgr12leToUV_half_c;
    1181           1 :             break;
    1182           1 :         case AV_PIX_FMT_BGR444BE:
    1183           1 :             c->chrToYV12 = bgr12beToUV_half_c;
    1184           1 :             break;
    1185           4 :         case AV_PIX_FMT_BGR32:
    1186           4 :             c->chrToYV12 = rgb32ToUV_half_c;
    1187           4 :             break;
    1188           1 :         case AV_PIX_FMT_BGR32_1:
    1189           1 :             c->chrToYV12 = rgb321ToUV_half_c;
    1190           1 :             break;
    1191          30 :         case AV_PIX_FMT_RGB24:
    1192          30 :             c->chrToYV12 = rgb24ToUV_half_c;
    1193          30 :             break;
    1194           5 :         case AV_PIX_FMT_RGB565LE:
    1195           5 :             c->chrToYV12 = rgb16leToUV_half_c;
    1196           5 :             break;
    1197           1 :         case AV_PIX_FMT_RGB565BE:
    1198           1 :             c->chrToYV12 = rgb16beToUV_half_c;
    1199           1 :             break;
    1200          12 :         case AV_PIX_FMT_RGB555LE:
    1201          12 :             c->chrToYV12 = rgb15leToUV_half_c;
    1202          12 :             break;
    1203           1 :         case AV_PIX_FMT_RGB555BE:
    1204           1 :             c->chrToYV12 = rgb15beToUV_half_c;
    1205           1 :             break;
    1206           1 :         case AV_PIX_FMT_RGB444LE:
    1207           1 :             c->chrToYV12 = rgb12leToUV_half_c;
    1208           1 :             break;
    1209           1 :         case AV_PIX_FMT_RGB444BE:
    1210           1 :             c->chrToYV12 = rgb12beToUV_half_c;
    1211           1 :             break;
    1212             :         }
    1213             :     } else {
    1214         189 :         switch (srcFormat) {
    1215           2 :         case AV_PIX_FMT_RGBA64BE:
    1216           2 :             c->chrToYV12 = rgb64BEToUV_c;
    1217           2 :             break;
    1218           1 :         case AV_PIX_FMT_RGBA64LE:
    1219           1 :             c->chrToYV12 = rgb64LEToUV_c;
    1220           1 :             break;
    1221           1 :         case AV_PIX_FMT_BGRA64BE:
    1222           1 :             c->chrToYV12 = bgr64BEToUV_c;
    1223           1 :             break;
    1224           1 :         case AV_PIX_FMT_BGRA64LE:
    1225           1 :             c->chrToYV12 = bgr64LEToUV_c;
    1226           1 :             break;
    1227           3 :         case AV_PIX_FMT_RGB48BE:
    1228           3 :             c->chrToYV12 = rgb48BEToUV_c;
    1229           3 :             break;
    1230           2 :         case AV_PIX_FMT_RGB48LE:
    1231           2 :             c->chrToYV12 = rgb48LEToUV_c;
    1232           2 :             break;
    1233           1 :         case AV_PIX_FMT_BGR48BE:
    1234           1 :             c->chrToYV12 = bgr48BEToUV_c;
    1235           1 :             break;
    1236           1 :         case AV_PIX_FMT_BGR48LE:
    1237           1 :             c->chrToYV12 = bgr48LEToUV_c;
    1238           1 :             break;
    1239          17 :         case AV_PIX_FMT_RGB32:
    1240          17 :             c->chrToYV12 = bgr32ToUV_c;
    1241          17 :             break;
    1242           2 :         case AV_PIX_FMT_RGB32_1:
    1243           2 :             c->chrToYV12 = bgr321ToUV_c;
    1244           2 :             break;
    1245           2 :         case AV_PIX_FMT_BGR24:
    1246           2 :             c->chrToYV12 = bgr24ToUV_c;
    1247           2 :             break;
    1248           0 :         case AV_PIX_FMT_BGR565LE:
    1249           0 :             c->chrToYV12 = bgr16leToUV_c;
    1250           0 :             break;
    1251           0 :         case AV_PIX_FMT_BGR565BE:
    1252           0 :             c->chrToYV12 = bgr16beToUV_c;
    1253           0 :             break;
    1254           0 :         case AV_PIX_FMT_BGR555LE:
    1255           0 :             c->chrToYV12 = bgr15leToUV_c;
    1256           0 :             break;
    1257           0 :         case AV_PIX_FMT_BGR555BE:
    1258           0 :             c->chrToYV12 = bgr15beToUV_c;
    1259           0 :             break;
    1260           0 :         case AV_PIX_FMT_BGR444LE:
    1261           0 :             c->chrToYV12 = bgr12leToUV_c;
    1262           0 :             break;
    1263           0 :         case AV_PIX_FMT_BGR444BE:
    1264           0 :             c->chrToYV12 = bgr12beToUV_c;
    1265           0 :             break;
    1266           6 :         case AV_PIX_FMT_BGR32:
    1267           6 :             c->chrToYV12 = rgb32ToUV_c;
    1268           6 :             break;
    1269           2 :         case AV_PIX_FMT_BGR32_1:
    1270           2 :             c->chrToYV12 = rgb321ToUV_c;
    1271           2 :             break;
    1272           5 :         case AV_PIX_FMT_RGB24:
    1273           5 :             c->chrToYV12 = rgb24ToUV_c;
    1274           5 :             break;
    1275           1 :         case AV_PIX_FMT_RGB565LE:
    1276           1 :             c->chrToYV12 = rgb16leToUV_c;
    1277           1 :             break;
    1278           0 :         case AV_PIX_FMT_RGB565BE:
    1279           0 :             c->chrToYV12 = rgb16beToUV_c;
    1280           0 :             break;
    1281           1 :         case AV_PIX_FMT_RGB555LE:
    1282           1 :             c->chrToYV12 = rgb15leToUV_c;
    1283           1 :             break;
    1284           0 :         case AV_PIX_FMT_RGB555BE:
    1285           0 :             c->chrToYV12 = rgb15beToUV_c;
    1286           0 :             break;
    1287           0 :         case AV_PIX_FMT_RGB444LE:
    1288           0 :             c->chrToYV12 = rgb12leToUV_c;
    1289           0 :             break;
    1290           0 :         case AV_PIX_FMT_RGB444BE:
    1291           0 :             c->chrToYV12 = rgb12beToUV_c;
    1292           0 :             break;
    1293             :         }
    1294             :     }
    1295             : 
    1296        2406 :     c->lumToYV12 = NULL;
    1297        2406 :     c->alpToYV12 = NULL;
    1298        2406 :     switch (srcFormat) {
    1299           1 :     case AV_PIX_FMT_GBRP9LE:
    1300           1 :         c->readLumPlanar = planar_rgb9le_to_y;
    1301           1 :         break;
    1302           1 :     case AV_PIX_FMT_GBRAP10LE:
    1303           1 :         c->readAlpPlanar = planar_rgb10le_to_a;
    1304           2 :     case AV_PIX_FMT_GBRP10LE:
    1305           2 :         c->readLumPlanar = planar_rgb10le_to_y;
    1306           2 :         break;
    1307           1 :     case AV_PIX_FMT_GBRAP12LE:
    1308           1 :         c->readAlpPlanar = planar_rgb12le_to_a;
    1309           2 :     case AV_PIX_FMT_GBRP12LE:
    1310           2 :         c->readLumPlanar = planar_rgb12le_to_y;
    1311           2 :         break;
    1312           1 :     case AV_PIX_FMT_GBRP14LE:
    1313           1 :         c->readLumPlanar = planar_rgb14le_to_y;
    1314           1 :         break;
    1315           1 :     case AV_PIX_FMT_GBRAP16LE:
    1316           1 :         c->readAlpPlanar = planar_rgb16le_to_a;
    1317           6 :     case AV_PIX_FMT_GBRP16LE:
    1318           6 :         c->readLumPlanar = planar_rgb16le_to_y;
    1319           6 :         break;
    1320           1 :     case AV_PIX_FMT_GBRP9BE:
    1321           1 :         c->readLumPlanar = planar_rgb9be_to_y;
    1322           1 :         break;
    1323           1 :     case AV_PIX_FMT_GBRAP10BE:
    1324           1 :         c->readAlpPlanar = planar_rgb10be_to_a;
    1325           2 :     case AV_PIX_FMT_GBRP10BE:
    1326           2 :         c->readLumPlanar = planar_rgb10be_to_y;
    1327           2 :         break;
    1328           1 :     case AV_PIX_FMT_GBRAP12BE:
    1329           1 :         c->readAlpPlanar = planar_rgb12be_to_a;
    1330           2 :     case AV_PIX_FMT_GBRP12BE:
    1331           2 :         c->readLumPlanar = planar_rgb12be_to_y;
    1332           2 :         break;
    1333           1 :     case AV_PIX_FMT_GBRP14BE:
    1334           1 :         c->readLumPlanar = planar_rgb14be_to_y;
    1335           1 :         break;
    1336           2 :     case AV_PIX_FMT_GBRAP16BE:
    1337           2 :         c->readAlpPlanar = planar_rgb16be_to_a;
    1338           4 :     case AV_PIX_FMT_GBRP16BE:
    1339           4 :         c->readLumPlanar = planar_rgb16be_to_y;
    1340           4 :         break;
    1341           6 :     case AV_PIX_FMT_GBRAP:
    1342           6 :         c->readAlpPlanar = planar_rgb_to_a;
    1343           7 :     case AV_PIX_FMT_GBRP:
    1344           7 :         c->readLumPlanar = planar_rgb_to_y;
    1345           7 :         break;
    1346             : #if HAVE_BIGENDIAN
    1347             :     case AV_PIX_FMT_YUV420P9LE:
    1348             :     case AV_PIX_FMT_YUV422P9LE:
    1349             :     case AV_PIX_FMT_YUV444P9LE:
    1350             :     case AV_PIX_FMT_YUV420P10LE:
    1351             :     case AV_PIX_FMT_YUV422P10LE:
    1352             :     case AV_PIX_FMT_YUV440P10LE:
    1353             :     case AV_PIX_FMT_YUV444P10LE:
    1354             :     case AV_PIX_FMT_YUV420P12LE:
    1355             :     case AV_PIX_FMT_YUV422P12LE:
    1356             :     case AV_PIX_FMT_YUV440P12LE:
    1357             :     case AV_PIX_FMT_YUV444P12LE:
    1358             :     case AV_PIX_FMT_YUV420P14LE:
    1359             :     case AV_PIX_FMT_YUV422P14LE:
    1360             :     case AV_PIX_FMT_YUV444P14LE:
    1361             :     case AV_PIX_FMT_YUV420P16LE:
    1362             :     case AV_PIX_FMT_YUV422P16LE:
    1363             :     case AV_PIX_FMT_YUV444P16LE:
    1364             : 
    1365             :     case AV_PIX_FMT_GRAY9LE:
    1366             :     case AV_PIX_FMT_GRAY10LE:
    1367             :     case AV_PIX_FMT_GRAY12LE:
    1368             :     case AV_PIX_FMT_GRAY16LE:
    1369             : 
    1370             :     case AV_PIX_FMT_P016LE:
    1371             :         c->lumToYV12 = bswap16Y_c;
    1372             :         break;
    1373             :     case AV_PIX_FMT_YUVA420P9LE:
    1374             :     case AV_PIX_FMT_YUVA422P9LE:
    1375             :     case AV_PIX_FMT_YUVA444P9LE:
    1376             :     case AV_PIX_FMT_YUVA420P10LE:
    1377             :     case AV_PIX_FMT_YUVA422P10LE:
    1378             :     case AV_PIX_FMT_YUVA444P10LE:
    1379             :     case AV_PIX_FMT_YUVA420P16LE:
    1380             :     case AV_PIX_FMT_YUVA422P16LE:
    1381             :     case AV_PIX_FMT_YUVA444P16LE:
    1382             :         c->lumToYV12 = bswap16Y_c;
    1383             :         c->alpToYV12 = bswap16Y_c;
    1384             :         break;
    1385             : #else
    1386          23 :     case AV_PIX_FMT_YUV420P9BE:
    1387             :     case AV_PIX_FMT_YUV422P9BE:
    1388             :     case AV_PIX_FMT_YUV444P9BE:
    1389             :     case AV_PIX_FMT_YUV420P10BE:
    1390             :     case AV_PIX_FMT_YUV422P10BE:
    1391             :     case AV_PIX_FMT_YUV440P10BE:
    1392             :     case AV_PIX_FMT_YUV444P10BE:
    1393             :     case AV_PIX_FMT_YUV420P12BE:
    1394             :     case AV_PIX_FMT_YUV422P12BE:
    1395             :     case AV_PIX_FMT_YUV440P12BE:
    1396             :     case AV_PIX_FMT_YUV444P12BE:
    1397             :     case AV_PIX_FMT_YUV420P14BE:
    1398             :     case AV_PIX_FMT_YUV422P14BE:
    1399             :     case AV_PIX_FMT_YUV444P14BE:
    1400             :     case AV_PIX_FMT_YUV420P16BE:
    1401             :     case AV_PIX_FMT_YUV422P16BE:
    1402             :     case AV_PIX_FMT_YUV444P16BE:
    1403             : 
    1404             :     case AV_PIX_FMT_GRAY9BE:
    1405             :     case AV_PIX_FMT_GRAY10BE:
    1406             :     case AV_PIX_FMT_GRAY12BE:
    1407             :     case AV_PIX_FMT_GRAY16BE:
    1408             : 
    1409             :     case AV_PIX_FMT_P016BE:
    1410          23 :         c->lumToYV12 = bswap16Y_c;
    1411          23 :         break;
    1412           9 :     case AV_PIX_FMT_YUVA420P9BE:
    1413             :     case AV_PIX_FMT_YUVA422P9BE:
    1414             :     case AV_PIX_FMT_YUVA444P9BE:
    1415             :     case AV_PIX_FMT_YUVA420P10BE:
    1416             :     case AV_PIX_FMT_YUVA422P10BE:
    1417             :     case AV_PIX_FMT_YUVA444P10BE:
    1418             :     case AV_PIX_FMT_YUVA420P16BE:
    1419             :     case AV_PIX_FMT_YUVA422P16BE:
    1420             :     case AV_PIX_FMT_YUVA444P16BE:
    1421           9 :         c->lumToYV12 = bswap16Y_c;
    1422           9 :         c->alpToYV12 = bswap16Y_c;
    1423           9 :         break;
    1424             : #endif
    1425           0 :     case AV_PIX_FMT_YA16LE:
    1426           0 :         c->lumToYV12 = read_ya16le_gray_c;
    1427           0 :         break;
    1428           2 :     case AV_PIX_FMT_YA16BE:
    1429           2 :         c->lumToYV12 = read_ya16be_gray_c;
    1430           2 :         break;
    1431           1 :     case AV_PIX_FMT_AYUV64LE:
    1432           1 :         c->lumToYV12 = read_ayuv64le_Y_c;
    1433           1 :         break;
    1434           6 :     case AV_PIX_FMT_YUYV422:
    1435             :     case AV_PIX_FMT_YVYU422:
    1436             :     case AV_PIX_FMT_YA8:
    1437           6 :         c->lumToYV12 = yuy2ToY_c;
    1438           6 :         break;
    1439           1 :     case AV_PIX_FMT_UYVY422:
    1440           1 :         c->lumToYV12 = uyvyToY_c;
    1441           1 :         break;
    1442          22 :     case AV_PIX_FMT_BGR24:
    1443          22 :         c->lumToYV12 = bgr24ToY_c;
    1444          22 :         break;
    1445           1 :     case AV_PIX_FMT_BGR565LE:
    1446           1 :         c->lumToYV12 = bgr16leToY_c;
    1447           1 :         break;
    1448           1 :     case AV_PIX_FMT_BGR565BE:
    1449           1 :         c->lumToYV12 = bgr16beToY_c;
    1450           1 :         break;
    1451           1 :     case AV_PIX_FMT_BGR555LE:
    1452           1 :         c->lumToYV12 = bgr15leToY_c;
    1453           1 :         break;
    1454           1 :     case AV_PIX_FMT_BGR555BE:
    1455           1 :         c->lumToYV12 = bgr15beToY_c;
    1456           1 :         break;
    1457           1 :     case AV_PIX_FMT_BGR444LE:
    1458           1 :         c->lumToYV12 = bgr12leToY_c;
    1459           1 :         break;
    1460           1 :     case AV_PIX_FMT_BGR444BE:
    1461           1 :         c->lumToYV12 = bgr12beToY_c;
    1462           1 :         break;
    1463          35 :     case AV_PIX_FMT_RGB24:
    1464          35 :         c->lumToYV12 = rgb24ToY_c;
    1465          35 :         break;
    1466           6 :     case AV_PIX_FMT_RGB565LE:
    1467           6 :         c->lumToYV12 = rgb16leToY_c;
    1468           6 :         break;
    1469           1 :     case AV_PIX_FMT_RGB565BE:
    1470           1 :         c->lumToYV12 = rgb16beToY_c;
    1471           1 :         break;
    1472          13 :     case AV_PIX_FMT_RGB555LE:
    1473          13 :         c->lumToYV12 = rgb15leToY_c;
    1474          13 :         break;
    1475           1 :     case AV_PIX_FMT_RGB555BE:
    1476           1 :         c->lumToYV12 = rgb15beToY_c;
    1477           1 :         break;
    1478           1 :     case AV_PIX_FMT_RGB444LE:
    1479           1 :         c->lumToYV12 = rgb12leToY_c;
    1480           1 :         break;
    1481           1 :     case AV_PIX_FMT_RGB444BE:
    1482           1 :         c->lumToYV12 = rgb12beToY_c;
    1483           1 :         break;
    1484          13 :     case AV_PIX_FMT_RGB8:
    1485             :     case AV_PIX_FMT_BGR8:
    1486             :     case AV_PIX_FMT_PAL8:
    1487             :     case AV_PIX_FMT_BGR4_BYTE:
    1488             :     case AV_PIX_FMT_RGB4_BYTE:
    1489          13 :         c->lumToYV12 = palToY_c;
    1490          13 :         break;
    1491           2 :     case AV_PIX_FMT_MONOBLACK:
    1492           2 :         c->lumToYV12 = monoblack2Y_c;
    1493           2 :         break;
    1494           6 :     case AV_PIX_FMT_MONOWHITE:
    1495           6 :         c->lumToYV12 = monowhite2Y_c;
    1496           6 :         break;
    1497          31 :     case AV_PIX_FMT_RGB32:
    1498          31 :         c->lumToYV12 = bgr32ToY_c;
    1499          31 :         break;
    1500           2 :     case AV_PIX_FMT_RGB32_1:
    1501           2 :         c->lumToYV12 = bgr321ToY_c;
    1502           2 :         break;
    1503          10 :     case AV_PIX_FMT_BGR32:
    1504          10 :         c->lumToYV12 = rgb32ToY_c;
    1505          10 :         break;
    1506           3 :     case AV_PIX_FMT_BGR32_1:
    1507           3 :         c->lumToYV12 = rgb321ToY_c;
    1508           3 :         break;
    1509           3 :     case AV_PIX_FMT_RGB48BE:
    1510           3 :         c->lumToYV12 = rgb48BEToY_c;
    1511           3 :         break;
    1512           6 :     case AV_PIX_FMT_RGB48LE:
    1513           6 :         c->lumToYV12 = rgb48LEToY_c;
    1514           6 :         break;
    1515           1 :     case AV_PIX_FMT_BGR48BE:
    1516           1 :         c->lumToYV12 = bgr48BEToY_c;
    1517           1 :         break;
    1518           1 :     case AV_PIX_FMT_BGR48LE:
    1519           1 :         c->lumToYV12 = bgr48LEToY_c;
    1520           1 :         break;
    1521           2 :     case AV_PIX_FMT_RGBA64BE:
    1522           2 :         c->lumToYV12 = rgb64BEToY_c;
    1523           2 :         break;
    1524           1 :     case AV_PIX_FMT_RGBA64LE:
    1525           1 :         c->lumToYV12 = rgb64LEToY_c;
    1526           1 :         break;
    1527           1 :     case AV_PIX_FMT_BGRA64BE:
    1528           1 :         c->lumToYV12 = bgr64BEToY_c;
    1529           1 :         break;
    1530           1 :     case AV_PIX_FMT_BGRA64LE:
    1531           1 :         c->lumToYV12 = bgr64LEToY_c;
    1532           1 :         break;
    1533           1 :     case AV_PIX_FMT_P010LE:
    1534           1 :         c->lumToYV12 = p010LEToY_c;
    1535           1 :         break;
    1536           1 :     case AV_PIX_FMT_P010BE:
    1537           1 :         c->lumToYV12 = p010BEToY_c;
    1538           1 :         break;
    1539             :     }
    1540        2406 :     if (c->needAlpha) {
    1541          61 :         if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
    1542          29 :             if (HAVE_BIGENDIAN == !isBE(srcFormat) && !c->readAlpPlanar)
    1543          11 :                 c->alpToYV12 = bswap16Y_c;
    1544             :         }
    1545          61 :         switch (srcFormat) {
    1546           2 :         case AV_PIX_FMT_BGRA64LE:
    1547           2 :         case AV_PIX_FMT_RGBA64LE:  c->alpToYV12 = rgba64leToA_c; break;
    1548           2 :         case AV_PIX_FMT_BGRA64BE:
    1549           2 :         case AV_PIX_FMT_RGBA64BE:  c->alpToYV12 = rgba64beToA_c; break;
    1550          21 :         case AV_PIX_FMT_BGRA:
    1551             :         case AV_PIX_FMT_RGBA:
    1552          21 :             c->alpToYV12 = rgbaToA_c;
    1553          21 :             break;
    1554           5 :         case AV_PIX_FMT_ABGR:
    1555             :         case AV_PIX_FMT_ARGB:
    1556           5 :             c->alpToYV12 = abgrToA_c;
    1557           5 :             break;
    1558           1 :         case AV_PIX_FMT_YA8:
    1559           1 :             c->alpToYV12 = uyvyToY_c;
    1560           1 :             break;
    1561           0 :         case AV_PIX_FMT_YA16LE:
    1562           0 :             c->alpToYV12 = read_ya16le_alpha_c;
    1563           0 :             break;
    1564           0 :         case AV_PIX_FMT_YA16BE:
    1565           0 :             c->alpToYV12 = read_ya16be_alpha_c;
    1566           0 :             break;
    1567           1 :         case AV_PIX_FMT_AYUV64LE:
    1568           1 :             c->alpToYV12 = read_ayuv64le_A_c;
    1569           1 :             break;
    1570           0 :         case AV_PIX_FMT_PAL8 :
    1571           0 :             c->alpToYV12 = palToA_c;
    1572           0 :             break;
    1573             :         }
    1574             :     }
    1575        2406 : }

Generated by: LCOV version 1.13