Commit 389cc142 authored by Paul B Mahol's avatar Paul B Mahol

avcodec/cfhd: add x86 SIMD

Overall speed changes for 1920x1080, yuv422p10le, 60fps from: 0.19x to 0.343x
parent b9ea493a
......@@ -255,7 +255,7 @@ OBJS-$(CONFIG_CCAPTION_DECODER) += ccaption_dec.o ass.o
OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o
OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o
OBJS-$(CONFIG_CDXL_DECODER) += cdxl.o
OBJS-$(CONFIG_CFHD_DECODER) += cfhd.o cfhddata.o
OBJS-$(CONFIG_CFHD_DECODER) += cfhd.o cfhddata.o cfhddsp.o
OBJS-$(CONFIG_CFHD_ENCODER) += cfhdenc.o cfhddata.o
OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o
OBJS-$(CONFIG_CINEPAK_ENCODER) += cinepakenc.o elbg.o
......
This diff is collapsed.
......@@ -29,6 +29,7 @@
#include "bytestream.h"
#include "get_bits.h"
#include "vlc.h"
#include "cfhddsp.h"
enum CFHDParam {
SampleType = 1,
......@@ -178,6 +179,8 @@ typedef struct CFHDContext {
uint8_t prescale_table[8];
Plane plane[4];
Peak peak;
CFHDDSPContext dsp;
} CFHDContext;
int ff_cfhd_init_vlcs(CFHDContext *s);
......
/*
* Copyright (c) 2015-2016 Kieran Kunhya <kieran@kunhya.com>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/attributes.h"
#include "libavutil/common.h"
#include "libavutil/avassert.h"
#include "cfhddsp.h"
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride,
const int16_t *low, ptrdiff_t low_stride,
const int16_t *high, ptrdiff_t high_stride,
int len, int clip)
{
int16_t tmp;
int i;
tmp = (11*low[0*low_stride] - 4*low[1*low_stride] + low[2*low_stride] + 4) >> 3;
output[(2*0+0)*out_stride] = (tmp + high[0*high_stride]) >> 1;
if (clip)
output[(2*0+0)*out_stride] = av_clip_uintp2_c(output[(2*0+0)*out_stride], clip);
tmp = ( 5*low[0*low_stride] + 4*low[1*low_stride] - low[2*low_stride] + 4) >> 3;
output[(2*0+1)*out_stride] = (tmp - high[0*high_stride]) >> 1;
if (clip)
output[(2*0+1)*out_stride] = av_clip_uintp2_c(output[(2*0+1)*out_stride], clip);
for (i = 1; i < len - 1; i++) {
tmp = (low[(i-1)*low_stride] - low[(i+1)*low_stride] + 4) >> 3;
output[(2*i+0)*out_stride] = (tmp + low[i*low_stride] + high[i*high_stride]) >> 1;
if (clip)
output[(2*i+0)*out_stride] = av_clip_uintp2_c(output[(2*i+0)*out_stride], clip);
tmp = (low[(i+1)*low_stride] - low[(i-1)*low_stride] + 4) >> 3;
output[(2*i+1)*out_stride] = (tmp + low[i*low_stride] - high[i*high_stride]) >> 1;
if (clip)
output[(2*i+1)*out_stride] = av_clip_uintp2_c(output[(2*i+1)*out_stride], clip);
}
tmp = ( 5*low[i*low_stride] + 4*low[(i-1)*low_stride] - low[(i-2)*low_stride] + 4) >> 3;
output[(2*i+0)*out_stride] = (tmp + high[i*high_stride]) >> 1;
if (clip)
output[(2*i+0)*out_stride] = av_clip_uintp2_c(output[(2*i+0)*out_stride], clip);
tmp = (11*low[i*low_stride] - 4*low[(i-1)*low_stride] + low[(i-2)*low_stride] + 4) >> 3;
output[(2*i+1)*out_stride] = (tmp - high[i*high_stride]) >> 1;
if (clip)
output[(2*i+1)*out_stride] = av_clip_uintp2_c(output[(2*i+1)*out_stride], clip);
}
static void vert_filter(int16_t *output, ptrdiff_t out_stride,
const int16_t *low, ptrdiff_t low_stride,
const int16_t *high, ptrdiff_t high_stride,
int width, int height)
{
for (int i = 0; i < width; i++) {
filter(output, out_stride, low, low_stride, high, high_stride, height, 0);
low++;
high++;
output++;
}
}
static void horiz_filter(int16_t *output, ptrdiff_t ostride,
const int16_t *low, ptrdiff_t lstride,
const int16_t *high, ptrdiff_t hstride,
int width, int height)
{
for (int i = 0; i < height; i++) {
filter(output, 1, low, 1, high, 1, width, 0);
low += lstride;
high += hstride;
output += ostride * 2;
}
}
static void horiz_filter_clip(int16_t *output, const int16_t *low, const int16_t *high,
int width, int clip)
{
filter(output, 1, low, 1, high, 1, width, clip);
}
static void horiz_filter_clip_bayer(int16_t *output, const int16_t *low, const int16_t *high,
int width, int clip)
{
filter(output, 2, low, 1, high, 1, width, clip);
}
av_cold void ff_cfhddsp_init(CFHDDSPContext *c, int depth, int bayer)
{
c->horiz_filter = horiz_filter;
c->vert_filter = vert_filter;
if (bayer)
c->horiz_filter_clip = horiz_filter_clip_bayer;
else
c->horiz_filter_clip = horiz_filter_clip;
if (ARCH_X86)
ff_cfhddsp_init_x86(c, depth, bayer);
}
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_CFHDDSP_H
#define AVCODEC_CFHDDSP_H
#include <stddef.h>
#include <stdint.h>
typedef struct CFHDDSPContext {
void (*horiz_filter)(int16_t *output, ptrdiff_t out_stride,
const int16_t *low, ptrdiff_t low_stride,
const int16_t *high, ptrdiff_t high_stride,
int width, int height);
void (*vert_filter)(int16_t *output, ptrdiff_t out_stride,
const int16_t *low, ptrdiff_t low_stride,
const int16_t *high, ptrdiff_t high_stride,
int width, int height);
void (*horiz_filter_clip)(int16_t *output, const int16_t *low, const int16_t *high,
int width, int bpc);
} CFHDDSPContext;
void ff_cfhddsp_init(CFHDDSPContext *c, int format, int bayer);
void ff_cfhddsp_init_x86(CFHDDSPContext *c, int format, int bayer);
#endif /* AVCODEC_CFHDDSP_H */
......@@ -50,6 +50,7 @@ OBJS-$(CONFIG_ADPCM_G722_ENCODER) += x86/g722dsp_init.o
OBJS-$(CONFIG_ALAC_DECODER) += x86/alacdsp_init.o
OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp_init.o
OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp.o
OBJS-$(CONFIG_CFHD_DECODER) += x86/cfhddsp_init.o
OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o x86/synth_filter_init.o
OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc_init.o
OBJS-$(CONFIG_EXR_DECODER) += x86/exrdsp_init.o
......@@ -153,6 +154,7 @@ X86ASM-OBJS-$(CONFIG_ADPCM_G722_ENCODER) += x86/g722dsp.o
X86ASM-OBJS-$(CONFIG_ALAC_DECODER) += x86/alacdsp.o
X86ASM-OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp.o
X86ASM-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsidct.o
X86ASM-OBJS-$(CONFIG_CFHD_DECODER) += x86/cfhddsp.o
X86ASM-OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp.o x86/synth_filter.o
X86ASM-OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp.o \
x86/dirac_dwt.o
......
This diff is collapsed.
/*
* Copyright (c) 2020 Paul B Mahol
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/cfhddsp.h"
void ff_cfhd_horiz_filter_sse2(int16_t *output, ptrdiff_t out_stride,
const int16_t *low, ptrdiff_t low_stride,
const int16_t *high, ptrdiff_t high_stride,
int width, int height);
void ff_cfhd_vert_filter_sse2(int16_t *output, ptrdiff_t out_stride,
const int16_t *low, ptrdiff_t low_stride,
const int16_t *high, ptrdiff_t high_stride,
int width, int height);
void ff_cfhd_horiz_filter_clip10_sse2(int16_t *output, const int16_t *low, const int16_t *high, int width, int bpc);
void ff_cfhd_horiz_filter_clip12_sse2(int16_t *output, const int16_t *low, const int16_t *high, int width, int bpc);
av_cold void ff_cfhddsp_init_x86(CFHDDSPContext *c, int depth, int bayer)
{
int cpu_flags = av_get_cpu_flags();
if (EXTERNAL_SSE2(cpu_flags)) {
c->horiz_filter = ff_cfhd_horiz_filter_sse2;
c->vert_filter = ff_cfhd_vert_filter_sse2;
if (depth == 10 && !bayer)
c->horiz_filter_clip = ff_cfhd_horiz_filter_clip10_sse2;
if (depth == 12 && !bayer)
c->horiz_filter_clip = ff_cfhd_horiz_filter_clip12_sse2;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment