[FFmpeg-devel] [PATCH v2] avfilter/lut: change to support native endian only
Muhammad Faiz
mfcc64 at gmail.com
Wed Jun 29 20:35:19 CEST 2016
On Thu, Jun 30, 2016 at 1:24 AM, Muhammad Faiz <mfcc64 at gmail.com> wrote:
> previously support little endian only because of fate problem
> generally native endian code is faster
>
> require 'tests/fate-run: support both le/be formats on pixfmts'
> need someone tests it on BE machine
>
> Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>
> ---
> libavfilter/vf_lut.c | 85 +++++++++++++++++++++++-----------------------------
> 1 file changed, 38 insertions(+), 47 deletions(-)
>
> diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
> index 5148663..75960b5 100644
> --- a/libavfilter/vf_lut.c
> +++ b/libavfilter/vf_lut.c
> @@ -69,6 +69,7 @@ typedef struct LutContext {
> int is_16bit;
> int step;
> int negate_alpha; /* only used by negate */
> + int color_mask;
> } LutContext;
>
> #define Y 0
> @@ -115,18 +116,18 @@ static av_cold void uninit(AVFilterContext *ctx)
> AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P, \
> AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, \
> AV_PIX_FMT_YUVJ440P, \
> - AV_PIX_FMT_YUV444P9LE, AV_PIX_FMT_YUV422P9LE, AV_PIX_FMT_YUV420P9LE, \
> - AV_PIX_FMT_YUV444P10LE, AV_PIX_FMT_YUV422P10LE, AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUV440P10LE, \
> - AV_PIX_FMT_YUV444P12LE, AV_PIX_FMT_YUV422P12LE, AV_PIX_FMT_YUV420P12LE, AV_PIX_FMT_YUV440P12LE, \
> - AV_PIX_FMT_YUV444P14LE, AV_PIX_FMT_YUV422P14LE, AV_PIX_FMT_YUV420P14LE, \
> - AV_PIX_FMT_YUV444P16LE, AV_PIX_FMT_YUV422P16LE, AV_PIX_FMT_YUV420P16LE, \
> - AV_PIX_FMT_YUVA444P16LE, AV_PIX_FMT_YUVA422P16LE, AV_PIX_FMT_YUVA420P16LE
> + AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV420P9, \
> + AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV440P10, \
> + AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV440P12, \
> + AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14, \
> + AV_PIX_FMT_YUV444P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV420P16, \
> + AV_PIX_FMT_YUVA444P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA420P16
>
> #define RGB_FORMATS \
> AV_PIX_FMT_ARGB, AV_PIX_FMT_RGBA, \
> AV_PIX_FMT_ABGR, AV_PIX_FMT_BGRA, \
> AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, \
> - AV_PIX_FMT_RGB48LE, AV_PIX_FMT_RGBA64LE
> + AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64
>
> static const enum AVPixelFormat yuv_pix_fmts[] = { YUV_FORMATS, AV_PIX_FMT_NONE };
> static const enum AVPixelFormat rgb_pix_fmts[] = { RGB_FORMATS, AV_PIX_FMT_NONE };
> @@ -226,32 +227,32 @@ static int config_props(AVFilterLink *inlink)
> case AV_PIX_FMT_YUVA420P:
> case AV_PIX_FMT_YUVA422P:
> case AV_PIX_FMT_YUVA444P:
> - case AV_PIX_FMT_YUV420P9LE:
> - case AV_PIX_FMT_YUV422P9LE:
> - case AV_PIX_FMT_YUV444P9LE:
> - case AV_PIX_FMT_YUVA420P9LE:
> - case AV_PIX_FMT_YUVA422P9LE:
> - case AV_PIX_FMT_YUVA444P9LE:
> - case AV_PIX_FMT_YUV420P10LE:
> - case AV_PIX_FMT_YUV422P10LE:
> - case AV_PIX_FMT_YUV440P10LE:
> - case AV_PIX_FMT_YUV444P10LE:
> - case AV_PIX_FMT_YUVA420P10LE:
> - case AV_PIX_FMT_YUVA422P10LE:
> - case AV_PIX_FMT_YUVA444P10LE:
> - case AV_PIX_FMT_YUV420P12LE:
> - case AV_PIX_FMT_YUV422P12LE:
> - case AV_PIX_FMT_YUV440P12LE:
> - case AV_PIX_FMT_YUV444P12LE:
> - case AV_PIX_FMT_YUV420P14LE:
> - case AV_PIX_FMT_YUV422P14LE:
> - case AV_PIX_FMT_YUV444P14LE:
> - case AV_PIX_FMT_YUV420P16LE:
> - case AV_PIX_FMT_YUV422P16LE:
> - case AV_PIX_FMT_YUV444P16LE:
> - case AV_PIX_FMT_YUVA420P16LE:
> - case AV_PIX_FMT_YUVA422P16LE:
> - case AV_PIX_FMT_YUVA444P16LE:
> + case AV_PIX_FMT_YUV420P9:
> + case AV_PIX_FMT_YUV422P9:
> + case AV_PIX_FMT_YUV444P9:
> + case AV_PIX_FMT_YUVA420P9:
> + case AV_PIX_FMT_YUVA422P9:
> + case AV_PIX_FMT_YUVA444P9:
> + case AV_PIX_FMT_YUV420P10:
> + case AV_PIX_FMT_YUV422P10:
> + case AV_PIX_FMT_YUV440P10:
> + case AV_PIX_FMT_YUV444P10:
> + case AV_PIX_FMT_YUVA420P10:
> + case AV_PIX_FMT_YUVA422P10:
> + case AV_PIX_FMT_YUVA444P10:
> + case AV_PIX_FMT_YUV420P12:
> + case AV_PIX_FMT_YUV422P12:
> + case AV_PIX_FMT_YUV440P12:
> + case AV_PIX_FMT_YUV444P12:
> + case AV_PIX_FMT_YUV420P14:
> + case AV_PIX_FMT_YUV422P14:
> + case AV_PIX_FMT_YUV444P14:
> + case AV_PIX_FMT_YUV420P16:
> + case AV_PIX_FMT_YUV422P16:
> + case AV_PIX_FMT_YUV444P16:
> + case AV_PIX_FMT_YUVA420P16:
> + case AV_PIX_FMT_YUVA422P16:
> + case AV_PIX_FMT_YUVA444P16:
> min[Y] = 16 * (1 << (desc->comp[0].depth - 8));
> min[U] = 16 * (1 << (desc->comp[1].depth - 8));
> min[V] = 16 * (1 << (desc->comp[2].depth - 8));
> @@ -261,8 +262,8 @@ static int config_props(AVFilterLink *inlink)
> max[V] = 240 * (1 << (desc->comp[2].depth - 8));
> max[A] = (1 << desc->comp[3].depth) - 1;
> break;
> - case AV_PIX_FMT_RGB48LE:
> - case AV_PIX_FMT_RGBA64LE:
> + case AV_PIX_FMT_RGB48:
> + case AV_PIX_FMT_RGBA64:
> min[0] = min[1] = min[2] = min[3] = 0;
> max[0] = max[1] = max[2] = max[3] = 65535;
> break;
> @@ -271,6 +272,7 @@ static int config_props(AVFilterLink *inlink)
> max[0] = max[1] = max[2] = max[3] = 255;
> }
>
> + s->color_mask = (1 << desc->comp[0].depth) - 1;
> s->is_yuv = s->is_rgb = 0;
> if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) s->is_yuv = 1;
> else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) s->is_rgb = 1;
> @@ -364,17 +366,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
> for (j = 0; j < w; j++) {
>
> switch (step) {
> -#if HAVE_BIGENDIAN
> - case 4: outrow[3] = av_bswap16(tab[3][av_bswap16(inrow[3])]); // Fall-through
> - case 3: outrow[2] = av_bswap16(tab[2][av_bswap16(inrow[2])]); // Fall-through
> - case 2: outrow[1] = av_bswap16(tab[1][av_bswap16(inrow[1])]); // Fall-through
> - default: outrow[0] = av_bswap16(tab[0][av_bswap16(inrow[0])]);
> -#else
> case 4: outrow[3] = tab[3][inrow[3]]; // Fall-through
> case 3: outrow[2] = tab[2][inrow[2]]; // Fall-through
> case 2: outrow[1] = tab[1][inrow[1]]; // Fall-through
> default: outrow[0] = tab[0][inrow[0]];
> -#endif
> }
> outrow += step;
> inrow += step;
> @@ -429,11 +424,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>
> for (i = 0; i < h; i++) {
> for (j = 0; j < w; j++) {
> -#if HAVE_BIGENDIAN
> - outrow[j] = av_bswap16(tab[av_bswap16(inrow[j])]);
> -#else
> outrow[j] = tab[inrow[j]];
> -#endif
> }
> inrow += in_linesize;
> outrow += out_linesize;
> @@ -457,7 +448,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>
> for (i = 0; i < h; i++) {
> for (j = 0; j < w; j++)
> - outrow[j] = tab[inrow[j]];
> + outrow[j] = tab[inrow[j] & s->color_mask];
> inrow += in_linesize;
> outrow += out_linesize;
> }
> --
> 2.5.0
>
This is wrong.
Dropped
Thank's
More information about the ffmpeg-devel
mailing list