1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit 'a9aee08d900f686e966c64afec5d88a7d9d130a3'

* commit 'a9aee08d900f686e966c64afec5d88a7d9d130a3':
  dsputil: Split off FDCT bits into their own context

Conflicts:
	configure
	libavcodec/Makefile
	libavcodec/asvenc.c
	libavcodec/dnxhdenc.c
	libavcodec/dsputil.c
	libavcodec/mpegvideo.h
	libavcodec/mpegvideo_enc.c
	libavcodec/x86/Makefile
	libavcodec/x86/dsputilenc_mmx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-07-08 03:12:10 +02:00
commit 14e2406de7
25 changed files with 253 additions and 102 deletions

13
configure vendored
View File

@ -1802,6 +1802,7 @@ CONFIG_EXTRA="
cabac
dsputil
exif
fdctdsp
frame_thread_encoder
gcrypt
golomb
@ -1995,7 +1996,7 @@ threads_if_any="$THREADS_LIST"
# subsystems
dct_select="rdft"
dsputil_select="idctdsp"
dsputil_select="fdctdsp idctdsp"
error_resilience_select="dsputil"
frame_thread_encoder_deps="encoders threads"
intrax8_select="error_resilience"
@ -2024,9 +2025,9 @@ amv_decoder_select="sp5x_decoder exif"
amv_encoder_select="aandcttables mpegvideoenc"
ape_decoder_select="bswapdsp llauddsp"
asv1_decoder_select="blockdsp bswapdsp idctdsp"
asv1_encoder_select="bswapdsp dsputil"
asv1_encoder_select="bswapdsp dsputil fdctdsp"
asv2_decoder_select="blockdsp bswapdsp idctdsp"
asv2_encoder_select="bswapdsp dsputil"
asv2_encoder_select="bswapdsp dsputil fdctdsp"
atrac1_decoder_select="mdct sinewin"
atrac3_decoder_select="mdct"
atrac3p_decoder_select="mdct sinewin"
@ -2043,9 +2044,9 @@ cscd_decoder_suggest="zlib"
dca_decoder_select="mdct"
dirac_decoder_select="dsputil dwt golomb videodsp"
dnxhd_decoder_select="blockdsp idctdsp"
dnxhd_encoder_select="aandcttables blockdsp dsputil idctdsp mpegvideoenc"
dnxhd_encoder_select="aandcttables blockdsp dsputil fdctdsp idctdsp mpegvideoenc"
dvvideo_decoder_select="idctdsp"
dvvideo_encoder_select="dsputil"
dvvideo_encoder_select="dsputil fdctdsp"
dxa_decoder_select="zlib"
eac3_decoder_select="ac3_decoder"
eac3_encoder_select="ac3_encoder"
@ -2134,7 +2135,7 @@ opus_decoder_deps="swresample"
png_decoder_select="zlib"
png_encoder_select="huffyuvencdsp zlib"
prores_decoder_select="blockdsp idctdsp"
prores_encoder_select="dsputil"
prores_encoder_select="fdctdsp"
qcelp_decoder_select="lsp"
qdm2_decoder_select="mdct rdft mpegaudiodsp"
ra_144_encoder_select="audio_frame_queue lpc audiodsp"

View File

@ -41,9 +41,10 @@ OBJS-$(CONFIG_CRYSTALHD) += crystalhd.o
OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
OBJS-$(CONFIG_DSPUTIL) += dsputil.o
OBJS-$(CONFIG_DXVA2) += dxva2.o
OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o
OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o
OBJS-$(CONFIG_EXIF) += exif.o tiff_common.o
OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o faandct.o \
jfdctfst.o jfdctint.o
FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o
OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \
fft_fixed_32.o fft_init_table.o \

View File

@ -34,6 +34,7 @@
#include "blockdsp.h"
#include "bswapdsp.h"
#include "dsputil.h"
#include "fdctdsp.h"
#include "idctdsp.h"
#include "get_bits.h"
#include "put_bits.h"
@ -43,6 +44,7 @@ typedef struct ASV1Context{
BlockDSPContext bdsp;
BswapDSPContext bbdsp;
DSPContext dsp;
FDCTDSPContext fdsp;
IDCTDSPContext idsp;
PutBitContext pb;
GetBitContext gb;

View File

@ -28,6 +28,7 @@
#include "asv.h"
#include "avcodec.h"
#include "fdctdsp.h"
#include "internal.h"
#include "mathops.h"
#include "mpeg12data.h"
@ -164,13 +165,13 @@ static inline void dct_get(ASV1Context *a, const AVFrame *frame,
a->dsp.get_pixels(block[2], ptr_y + 8*linesize , linesize);
a->dsp.get_pixels(block[3], ptr_y + 8*linesize + 8, linesize);
for(i=0; i<4; i++)
a->dsp.fdct(block[i]);
a->fdsp.fdct(block[i]);
if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
a->dsp.get_pixels(block[4], ptr_cb, frame->linesize[1]);
a->dsp.get_pixels(block[5], ptr_cr, frame->linesize[2]);
for(i=4; i<6; i++)
a->dsp.fdct(block[i]);
a->fdsp.fdct(block[i]);
}
}
@ -282,6 +283,7 @@ static av_cold int encode_init(AVCodecContext *avctx){
ff_asv_common_init(avctx);
ff_dsputil_init(&a->dsp, avctx);
ff_fdctdsp_init(&a->fdsp, avctx);
if(avctx->global_quality <= 0) avctx->global_quality= 4*FF_QUALITY_SCALE;

View File

@ -31,6 +31,7 @@
#include "avcodec.h"
#include "blockdsp.h"
#include "dsputil.h"
#include "fdctdsp.h"
#include "internal.h"
#include "mpegvideo.h"
#include "dnxhdenc.h"
@ -109,7 +110,7 @@ static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, int16_t *block,
int last_non_zero = 0;
int i;
ctx->dsp.fdct(block);
ctx->fdsp.fdct(block);
// Divide by 4 with rounding, to compensate scaling of DCT coefficients
block[0] = (block[0] + 2) >> 2;
@ -322,6 +323,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
avctx->bits_per_raw_sample = ctx->cid_table->bit_depth;
ff_blockdsp_init(&ctx->bdsp, avctx);
ff_fdctdsp_init(&ctx->m.fdsp, avctx);
ff_idctdsp_init(&ctx->m.idsp, avctx);
ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx);
ff_dct_common_init(&ctx->m);

View File

@ -29,10 +29,8 @@
#include "libavutil/internal.h"
#include "avcodec.h"
#include "copy_block.h"
#include "dct.h"
#include "dsputil.h"
#include "simple_idct.h"
#include "faandct.h"
#include "mpegvideo.h"
#include "config.h"
@ -589,7 +587,7 @@ static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
av_assert2(h == 8);
s->dsp.diff_pixels(temp, src1, src2, stride);
s->dsp.fdct(temp);
s->fdsp.fdct(temp);
return s->dsp.sum_abs_dctelem(temp);
}
@ -656,7 +654,7 @@ static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
av_assert2(h == 8);
s->dsp.diff_pixels(temp, src1, src2, stride);
s->dsp.fdct(temp);
s->fdsp.fdct(temp);
for (i = 0; i < 64; i++)
sum = FFMAX(sum, FFABS(temp[i]));
@ -973,24 +971,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
ff_check_alignment();
#if CONFIG_ENCODERS
if (avctx->bits_per_raw_sample == 10) {
c->fdct = ff_jpeg_fdct_islow_10;
c->fdct248 = ff_fdct248_islow_10;
} else {
if (avctx->dct_algo == FF_DCT_FASTINT) {
c->fdct = ff_fdct_ifast;
c->fdct248 = ff_fdct_ifast248;
} else if (avctx->dct_algo == FF_DCT_FAAN) {
c->fdct = ff_faandct;
c->fdct248 = ff_faandct248;
} else {
c->fdct = ff_jpeg_fdct_islow_8; // slow/accurate/default
c->fdct248 = ff_fdct248_islow_8;
}
}
#endif /* CONFIG_ENCODERS */
c->diff_pixels = diff_pixels_c;
c->sum_abs_dctelem = sum_abs_dctelem_c;

View File

@ -95,10 +95,6 @@ typedef struct DSPContext {
me_cmp_func frame_skip_cmp[6]; // only width 8 used
me_cmp_func pix_abs[2][4];
/* (I)DCT */
void (*fdct)(int16_t *block /* align 16 */);
void (*fdct248)(int16_t *block /* align 16 */);
} DSPContext;
void ff_dsputil_static_init(void);

View File

@ -29,6 +29,7 @@
#include "config.h"
#include "avcodec.h"
#include "dsputil.h"
#include "fdctdsp.h"
#include "internal.h"
#include "put_bits.h"
#include "dv.h"
@ -38,6 +39,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
{
DVVideoContext *s = avctx->priv_data;
DSPContext dsp;
FDCTDSPContext fdsp;
int ret;
s->sys = avpriv_dv_codec_profile(avctx);
@ -66,13 +68,14 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
memset(&dsp,0, sizeof(dsp));
ff_dsputil_init(&dsp, avctx);
ff_fdctdsp_init(&fdsp, avctx);
ff_set_cmp(&dsp, dsp.ildct_cmp, avctx->ildct_cmp);
s->get_pixels = dsp.get_pixels;
s->ildct_cmp = dsp.ildct_cmp[5];
s->fdct[0] = dsp.fdct;
s->fdct[1] = dsp.fdct248;
s->fdct[0] = fdsp.fdct;
s->fdct[1] = fdsp.fdct248;
return ff_dvvideo_init(avctx);
}

50
libavcodec/fdctdsp.c Normal file
View File

@ -0,0 +1,50 @@
/*
* 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 "avcodec.h"
#include "dct.h"
#include "faandct.h"
#include "fdctdsp.h"
#include "config.h"
av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx)
{
const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
if (avctx->bits_per_raw_sample == 10) {
c->fdct = ff_jpeg_fdct_islow_10;
c->fdct248 = ff_fdct248_islow_10;
} else {
if (avctx->dct_algo == FF_DCT_FASTINT) {
c->fdct = ff_fdct_ifast;
c->fdct248 = ff_fdct_ifast248;
} else if (avctx->dct_algo == FF_DCT_FAAN) {
c->fdct = ff_faandct;
c->fdct248 = ff_faandct248;
} else {
c->fdct = ff_jpeg_fdct_islow_8; // slow/accurate/default
c->fdct248 = ff_fdct248_islow_8;
}
}
if (ARCH_PPC)
ff_fdctdsp_init_ppc(c, avctx, high_bit_depth);
if (ARCH_X86)
ff_fdctdsp_init_x86(c, avctx, high_bit_depth);
}

37
libavcodec/fdctdsp.h Normal file
View File

@ -0,0 +1,37 @@
/*
* 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_FDCTDSP_H
#define AVCODEC_FDCTDSP_H
#include <stdint.h>
#include "avcodec.h"
typedef struct FDCTDSPContext {
void (*fdct)(int16_t *block /* align 16 */);
void (*fdct248)(int16_t *block /* align 16 */);
} FDCTDSPContext;
void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx);
void ff_fdctdsp_init_ppc(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth);
void ff_fdctdsp_init_x86(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth);
#endif /* AVCODEC_FDCTDSP_H */

View File

@ -28,5 +28,6 @@ LIBAVCODEC_$MAJOR {
ff_dnxhd_get_cid_table;
ff_dnxhd_cid_table;
ff_idctdsp_init;
ff_fdctdsp_init;
local: *;
};

View File

@ -32,6 +32,7 @@
#include "blockdsp.h"
#include "dsputil.h"
#include "error_resilience.h"
#include "fdctdsp.h"
#include "get_bits.h"
#include "h264chroma.h"
#include "h263dsp.h"
@ -364,6 +365,7 @@ typedef struct MpegEncContext {
BlockDSPContext bdsp;
DSPContext dsp; ///< pointers for accelerated dsp functions
FDCTDSPContext fdsp;
H264ChromaContext h264chroma;
HpelDSPContext hdsp;
IDCTDSPContext idsp;

View File

@ -78,15 +78,15 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
const uint16_t *quant_matrix,
int bias, int qmin, int qmax, int intra)
{
DSPContext *dsp = &s->dsp;
FDCTDSPContext *fdsp = &s->fdsp;
int qscale;
int shift = 0;
for (qscale = qmin; qscale <= qmax; qscale++) {
int i;
if (dsp->fdct == ff_jpeg_fdct_islow_8 ||
dsp->fdct == ff_jpeg_fdct_islow_10 ||
dsp->fdct == ff_faandct) {
if (fdsp->fdct == ff_jpeg_fdct_islow_8 ||
fdsp->fdct == ff_jpeg_fdct_islow_10 ||
fdsp->fdct == ff_faandct) {
for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i];
/* 16 <= qscale * quant_matrix[i] <= 7905
@ -98,7 +98,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) /
(qscale * quant_matrix[j]));
}
} else if (dsp->fdct == ff_fdct_ifast) {
} else if (fdsp->fdct == ff_fdct_ifast) {
for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i];
/* 16 <= qscale * quant_matrix[i] <= 7905
@ -136,7 +136,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
for (i = intra; i < 64; i++) {
int64_t max = 8191;
if (dsp->fdct == ff_fdct_ifast) {
if (fdsp->fdct == ff_fdct_ifast) {
max = (8191LL * ff_aanscales[i]) >> 14;
}
while (((max * qmat[qscale][i]) >> shift) > INT_MAX) {
@ -818,6 +818,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
if (ff_MPV_common_init(s) < 0)
return -1;
ff_fdctdsp_init(&s->fdsp, avctx);
ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
ff_qpeldsp_init(&s->qdsp);
@ -3714,7 +3715,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
uint8_t * last_length;
const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
s->dsp.fdct (block);
s->fdsp.fdct(block);
if(s->dct_error_sum)
s->denoise_dct(s, block);
@ -3809,7 +3810,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
int dct_coeff= FFABS(block[ scantable[i] ]);
int best_score=256*256*256*120;
if (s->dsp.fdct == ff_fdct_ifast)
if (s->fdsp.fdct == ff_fdct_ifast)
dct_coeff= (dct_coeff*ff_inv_aanscales[ scantable[i] ]) >> 12;
zero_distortion= dct_coeff*dct_coeff;
@ -4141,7 +4142,7 @@ STOP_TIMER("init rem[]")
STOP_TIMER("rem*w*w")}
{START_TIMER
#endif
s->dsp.fdct(d1);
s->fdsp.fdct(d1);
#ifdef REFINE_STATS
STOP_TIMER("dct")}
#endif
@ -4388,7 +4389,7 @@ int ff_dct_quantize_c(MpegEncContext *s,
int max=0;
unsigned int threshold1, threshold2;
s->dsp.fdct (block);
s->fdsp.fdct(block);
if(s->dct_error_sum)
s->denoise_dct(s, block);

View File

@ -9,6 +9,7 @@ OBJS-$(CONFIG_H264DSP) += ppc/h264dsp.o ppc/hpeldsp_altivec.o
OBJS-$(CONFIG_H264QPEL) += ppc/h264qpel.o
OBJS-$(CONFIG_HPELDSP) += ppc/hpeldsp_altivec.o
OBJS-$(CONFIG_HUFFYUVDSP) += ppc/huffyuvdsp_altivec.o
OBJS-$(CONFIG_FDCTDSP) += ppc/fdctdsp.o
OBJS-$(CONFIG_IDCTDSP) += ppc/idctdsp.o
OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o
OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \
@ -25,7 +26,6 @@ OBJS-$(CONFIG_VP7_DECODER) += ppc/vp8dsp_altivec.o
OBJS-$(CONFIG_VP8_DECODER) += ppc/vp8dsp_altivec.o
ALTIVEC-OBJS-$(CONFIG_DSPUTIL) += ppc/dsputil_altivec.o \
ppc/fdct_altivec.o \
FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o
FFT-OBJS-$(HAVE_VSX) += ppc/fft_vsx.o

View File

@ -27,8 +27,6 @@
#include "libavcodec/dsputil.h"
void ff_fdct_altivec(int16_t *block);
void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth);

View File

@ -35,14 +35,5 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx,
int mm_flags = av_get_cpu_flags();
if (PPC_ALTIVEC(mm_flags)) {
ff_dsputil_init_altivec(c, avctx, high_bit_depth);
if (!high_bit_depth) {
#if CONFIG_ENCODERS
if (avctx->dct_algo == FF_DCT_AUTO ||
avctx->dct_algo == FF_DCT_ALTIVEC) {
c->fdct = ff_fdct_altivec;
}
#endif //CONFIG_ENCODERS
}
}
}

View File

@ -23,8 +23,13 @@
#include <altivec.h>
#endif
#include "libavutil/common.h"
#include "dsputil_altivec.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/ppc/cpu.h"
#include "libavcodec/fdctdsp.h"
#include "fdctdsp.h"
#if HAVE_ALTIVEC
#define vs16(v) ((vector signed short) (v))
#define vs32(v) ((vector signed int) (v))
@ -454,3 +459,21 @@ void ff_fdct_altivec(int16_t *block)
#undef CTS
/* }}} */
}
#endif /* HAVE_ALTIVEC */
av_cold void ff_fdctdsp_init_ppc(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
#if HAVE_ALTIVEC
if (!PPC_ALTIVEC(av_get_cpu_flags()))
return;
if (!high_bit_depth) {
if (avctx->dct_algo == FF_DCT_AUTO ||
avctx->dct_algo == FF_DCT_ALTIVEC) {
c->fdct = ff_fdct_altivec;
}
}
#endif /* HAVE_ALTIVEC */
}

26
libavcodec/ppc/fdctdsp.h Normal file
View File

@ -0,0 +1,26 @@
/*
* 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_PPC_FDCTDSP_H
#define AVCODEC_PPC_FDCTDSP_H
#include <stdint.h>
void ff_fdct_altivec(int16_t *block);
#endif /* AVCODEC_PPC_FDCTDSP_H */

View File

@ -32,6 +32,7 @@
#include "put_bits.h"
#include "bytestream.h"
#include "dsputil.h"
#include "fdctdsp.h"
#define DEFAULT_SLICE_MB_WIDTH 8
@ -145,7 +146,7 @@ static const uint8_t QMAT_CHROMA[4][64] = {
typedef struct {
DSPContext dsp;
FDCTDSPContext fdsp;
uint8_t* fill_y;
uint8_t* fill_u;
uint8_t* fill_v;
@ -274,10 +275,10 @@ static void get(uint8_t *pixels, int stride, int16_t* block)
}
}
static void fdct_get(DSPContext *dsp, uint8_t *pixels, int stride, int16_t* block)
static void fdct_get(FDCTDSPContext *fdsp, uint8_t *pixels, int stride, int16_t* block)
{
get(pixels, stride, block);
dsp->fdct(block);
fdsp->fdct(block);
}
static int encode_slice_plane(AVCodecContext *avctx, int mb_count,
@ -285,18 +286,18 @@ static int encode_slice_plane(AVCodecContext *avctx, int mb_count,
int *qmat, int chroma)
{
ProresContext* ctx = avctx->priv_data;
DSPContext *dsp = &ctx->dsp;
FDCTDSPContext *fdsp = &ctx->fdsp;
DECLARE_ALIGNED(16, int16_t, blocks)[DEFAULT_SLICE_MB_WIDTH << 8], *block;
int i, blocks_per_slice;
PutBitContext pb;
block = blocks;
for (i = 0; i < mb_count; i++) {
fdct_get(dsp, src, src_stride, block + (0 << 6));
fdct_get(dsp, src + 8 * src_stride, src_stride, block + ((2 - chroma) << 6));
fdct_get(fdsp, src, src_stride, block + (0 << 6));
fdct_get(fdsp, src + 8 * src_stride, src_stride, block + ((2 - chroma) << 6));
if (!chroma) {
fdct_get(dsp, src + 16, src_stride, block + (1 << 6));
fdct_get(dsp, src + 16 + 8 * src_stride, src_stride, block + (3 << 6));
fdct_get(fdsp, src + 16, src_stride, block + (1 << 6));
fdct_get(fdsp, src + 16 + 8 * src_stride, src_stride, block + (3 << 6));
}
block += (256 >> chroma);
@ -576,7 +577,7 @@ static av_cold int prores_encode_init(AVCodecContext *avctx)
return -1;
}
ff_dsputil_init(&ctx->dsp, avctx);
ff_fdctdsp_init(&ctx->fdsp, avctx);
avctx->codec_tag = AV_RL32((const uint8_t*)profiles[avctx->profile].name);

View File

@ -26,8 +26,7 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "dct.h"
#include "dsputil.h"
#include "fdctdsp.h"
#include "put_bits.h"
#include "bytestream.h"
#include "internal.h"
@ -195,9 +194,9 @@ typedef struct ProresContext {
const uint8_t *quant_mat;
const uint8_t *scantable;
void (* fdct)(DSPContext *dsp, const uint16_t *src,
int linesize, int16_t *block);
DSPContext dsp;
void (*fdct)(FDCTDSPContext *fdsp, const uint16_t *src,
int linesize, int16_t *block);
FDCTDSPContext fdsp;
int mb_width, mb_height;
int mbs_per_slice;
@ -266,27 +265,27 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src,
mb_width * sizeof(*emu_buf));
}
if (!is_chroma) {
ctx->fdct(&ctx->dsp, esrc, elinesize, blocks);
ctx->fdct(&ctx->fdsp, esrc, elinesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks);
ctx->fdct(&ctx->fdsp, esrc + 8, elinesize, blocks);
blocks += 64;
}
ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks);
ctx->fdct(&ctx->fdsp, esrc + elinesize * 4, elinesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks);
ctx->fdct(&ctx->fdsp, esrc + elinesize * 4 + 8, elinesize, blocks);
blocks += 64;
}
} else {
ctx->fdct(&ctx->dsp, esrc, elinesize, blocks);
ctx->fdct(&ctx->fdsp, esrc, elinesize, blocks);
blocks += 64;
ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks);
ctx->fdct(&ctx->fdsp, esrc + elinesize * 4, elinesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks);
ctx->fdct(&ctx->fdsp, esrc + 8, elinesize, blocks);
blocks += 64;
ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks);
ctx->fdct(&ctx->fdsp, esrc + elinesize * 4 + 8, elinesize, blocks);
blocks += 64;
}
}
@ -1066,7 +1065,7 @@ static av_cold int encode_close(AVCodecContext *avctx)
return 0;
}
static void prores_fdct(DSPContext *dsp, const uint16_t *src,
static void prores_fdct(FDCTDSPContext *fdsp, const uint16_t *src,
int linesize, int16_t *block)
{
int x, y;
@ -1077,7 +1076,7 @@ static void prores_fdct(DSPContext *dsp, const uint16_t *src,
block[y * 8 + x] = tsrc[x];
tsrc += linesize >> 1;
}
dsp->fdct(block);
fdsp->fdct(block);
}
static av_cold int encode_init(AVCodecContext *avctx)
@ -1096,7 +1095,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
ctx->fdct = prores_fdct;
ctx->scantable = interlaced ? ff_prores_interlaced_scan
: ff_prores_progressive_scan;
ff_dsputil_init(&ctx->dsp, avctx);
ff_fdctdsp_init(&ctx->fdsp, avctx);
mps = ctx->mbs_per_slice;
if (mps & (mps - 1)) {

View File

@ -9,6 +9,7 @@ OBJS-$(CONFIG_DCT) += x86/dct_init.o
OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_init.o
OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o \
x86/motion_est.o
OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o
OBJS-$(CONFIG_FFT) += x86/fft_init.o
OBJS-$(CONFIG_FLAC_DECODER) += x86/flacdsp_init.o
OBJS-$(CONFIG_FLAC_ENCODER) += x86/flacdsp_init.o
@ -59,7 +60,7 @@ OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o
OBJS-$(CONFIG_WEBP_DECODER) += x86/vp8dsp_init.o
MMX-OBJS-$(CONFIG_DIRAC_DECODER) += x86/dirac_dwt.o
MMX-OBJS-$(CONFIG_ENCODERS) += x86/fdct.o
MMX-OBJS-$(CONFIG_FDCTDSP) += x86/fdct.o
MMX-OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_mmx.o \
x86/idct_mmx_xvid.o \
x86/idct_sse2_xvid.o \

View File

@ -26,7 +26,6 @@
#include "libavutil/cpu.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/dct.h"
#include "libavcodec/dsputil.h"
#include "libavcodec/mpegvideo.h"
#include "dsputil_x86.h"
@ -353,7 +352,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
const int dct_algo = avctx->dct_algo;
if (EXTERNAL_MMX(cpu_flags)) {
if (!high_bit_depth)
@ -367,10 +365,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
#if HAVE_INLINE_ASM
if (INLINE_MMX(cpu_flags)) {
if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_mmx;
c->vsad[4] = vsad_intra16_mmx;
if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
@ -379,10 +373,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
}
if (INLINE_MMXEXT(cpu_flags)) {
if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_mmxext;
c->vsad[4] = vsad_intra16_mmxext;
if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
@ -391,9 +381,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
}
if (INLINE_SSE2(cpu_flags)) {
if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_sse2;
}
#if HAVE_SSSE3_INLINE

View File

@ -0,0 +1,44 @@
/*
* 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/cpu.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/dct.h"
#include "libavcodec/fdctdsp.h"
av_cold void ff_fdctdsp_init_x86(FDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
const int dct_algo = avctx->dct_algo;
if (!high_bit_depth) {
if ((dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX)) {
if (INLINE_MMX(cpu_flags))
c->fdct = ff_fdct_mmx;
if (INLINE_MMXEXT(cpu_flags))
c->fdct = ff_fdct_mmxext;
if (INLINE_SSE2(cpu_flags))
c->fdct = ff_fdct_sse2;
}
}
}

View File

@ -233,7 +233,7 @@ static void filter(SPPContext *p, uint8_t *dst, uint8_t *src,
const int y1 = y + offset[i + count - 1][1];
const int index = x1 + y1*linesize;
p->dsp.get_pixels(block, p->src + index, linesize);
p->dsp.fdct(block);
p->fdsp.fdct(block);
p->requantize(block2, block, qp, p->idsp.idct_permutation);
p->idsp.idct(block2);
add_block(p->temp + index, linesize, block2);
@ -382,6 +382,7 @@ static av_cold int init(AVFilterContext *ctx)
return AVERROR(ENOMEM);
avpriv_dsputil_init(&spp->dsp, spp->avctx);
ff_idctdsp_init(&spp->idsp, spp->avctx);
ff_fdctdsp_init(&spp->fdsp, spp->avctx);
spp->store_slice = store_slice_c;
switch (spp->mode) {
case MODE_HARD: spp->requantize = hardthresh_c; break;

View File

@ -25,6 +25,7 @@
#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
#include "libavcodec/idctdsp.h"
#include "libavcodec/fdctdsp.h"
#include "avfilter.h"
#define MAX_LEVEL 6 /* quality levels */
@ -42,6 +43,7 @@ typedef struct {
AVCodecContext *avctx;
DSPContext dsp;
IDCTDSPContext idsp;
FDCTDSPContext fdsp;
int8_t *non_b_qp_table;
int non_b_qp_alloc_size;
int use_bframe_qp;