summaryrefslogtreecommitdiff
path: root/libavcodec/apedec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-05-30 00:59:15 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-05-30 00:59:15 +0200
commit40f3a87c10d5773eb66e09f4ed3d8197b1840863 (patch)
treebee50efb5beaff032de1fc4dcd797e3000b30c4c /libavcodec/apedec.c
parent5c6e94c42bcdc026071855a6b1749406b2456c8b (diff)
parent054013a0fc6f2b52c60cee3e051be8cc7f82cef3 (diff)
downloadffmpeg-40f3a87c10d5773eb66e09f4ed3d8197b1840863.tar.gz
Merge commit '054013a0fc6f2b52c60cee3e051be8cc7f82cef3'
* commit '054013a0fc6f2b52c60cee3e051be8cc7f82cef3': dsputil: Move APE-specific bits into apedsp Conflicts: libavcodec/arm/int_neon.S libavcodec/x86/dsputil.asm Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/apedec.c')
-rw-r--r--libavcodec/apedec.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 1fd41cdd9d..a41ac265e7 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -25,6 +25,7 @@
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
+#include "apedsp.h"
#include "avcodec.h"
#include "dsputil.h"
#include "bytestream.h"
@@ -136,6 +137,7 @@ typedef struct APEContext {
AVClass *class; ///< class for AVOptions
AVCodecContext *avctx;
DSPContext dsp;
+ APEDSPContext adsp;
int channels;
int samples; ///< samples left to decode in current frame
int bps;
@@ -195,8 +197,6 @@ static void predictor_decode_stereo_3930(APEContext *ctx, int count);
static void predictor_decode_mono_3950(APEContext *ctx, int count);
static void predictor_decode_stereo_3950(APEContext *ctx, int count);
-// TODO: dsputilize
-
static av_cold int ape_decode_close(AVCodecContext *avctx)
{
APEContext *s = avctx->priv_data;
@@ -212,6 +212,19 @@ static av_cold int ape_decode_close(AVCodecContext *avctx)
return 0;
}
+static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2,
+ const int16_t *v3,
+ int order, int mul)
+{
+ int res = 0;
+
+ while (order--) {
+ res += *v1 * *v2++;
+ *v1++ += mul * *v3++;
+ }
+ return res;
+}
+
static av_cold int ape_decode_init(AVCodecContext *avctx)
{
APEContext *s = avctx->priv_data;
@@ -293,6 +306,15 @@ static av_cold int ape_decode_init(AVCodecContext *avctx)
s->predictor_decode_stereo = predictor_decode_stereo_3950;
}
+ s->adsp.scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
+
+ if (ARCH_ARM)
+ ff_apedsp_init_arm(&s->adsp);
+ if (ARCH_PPC)
+ ff_apedsp_init_ppc(&s->adsp);
+ if (ARCH_X86)
+ ff_apedsp_init_x86(&s->adsp);
+
ff_dsputil_init(&s->dsp, avctx);
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
@@ -1275,9 +1297,10 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
while (count--) {
/* round fixedpoint scalar product */
- res = ctx->dsp.scalarproduct_and_madd_int16(f->coeffs, f->delay - order,
- f->adaptcoeffs - order,
- order, APESIGN(*data));
+ res = ctx->adsp.scalarproduct_and_madd_int16(f->coeffs,
+ f->delay - order,
+ f->adaptcoeffs - order,
+ order, APESIGN(*data));
res = (res + (1 << (fracbits - 1))) >> fracbits;
res += *data;
*data++ = res;