History

floatdsp: move butterflies_float from dsputil to avfloatdsp.

This makes wmadec/enc, twinvq and mpegaudiodec (i.e. mp2/mp3) independent of dsputil.

Ronald S. Bultje committed 13 years ago

Commit 5959bfa1 parent 42d324615 files · +51 −47Browse files

Unified · Split

15 files
  1. libavcodec/aacdec.c +3 −3
  2. libavcodec/arm/dsputil_init_neon.c +0 −2
  3. libavcodec/arm/dsputil_neon.S +0 −12
  4. libavcodec/dsputil.c +0 −12
  5. libavcodec/dsputil.h +0 −7
  6. libavcodec/imc.c +5 −2
  7. libavcodec/mpegaudiodec.c +4 −3
  8. libavcodec/twinvq.c +1 −3
  9. libavcodec/wma.c +0 −1
  10. libavcodec/wma.h +0 −1
  11. libavcodec/wmadec.c +1 −1
  12. libavutil/arm/float_dsp_init_neon.c +3 −0
  13. libavutil/arm/float_dsp_neon.S +12 −0
  14. libavutil/float_dsp.c +13 −0
  15. libavutil/float_dsp.h +9 −0
libavcodec/aacdec.c+3−3
@@ -1693,9 +1693,9 @@ static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe) · 1692 unmodified lines
1693 if (cpe->ms_mask[idx] &&1693 if (cpe->ms_mask[idx] &&
1694 cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) {1694 cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) {
1695 for (group = 0; group < ics->group_len[g]; group++) {1695 for (group = 0; group < ics->group_len[g]; group++) {
1696 ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],1696 ac->fdsp.butterflies_float(ch0 + group * 128 + offsets[i],
1697 ch1 + group * 128 + offsets[i],1697 ch1 + group * 128 + offsets[i],
1698 offsets[i+1] - offsets[i]);1698 offsets[i+1] - offsets[i]);
1699 }1699 }
1700 }1700 }
1701 }1701 }
libavcodec/arm/dsputil_init_neon.c+0−2
@@ -142,7 +142,6 @@ void ff_avg_h264_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int); · 141 unmodified lines
142void ff_avg_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);142void ff_avg_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
143void ff_avg_h264_chroma_mc2_neon(uint8_t *, uint8_t *, int, int, int, int);143void ff_avg_h264_chroma_mc2_neon(uint8_t *, uint8_t *, int, int, int, int);
144 144
145void ff_butterflies_float_neon(float *v1, float *v2, int len);
146float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);145float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
147 146
148void ff_vector_clipf_neon(float *dst, const float *src, float min, float max,147void ff_vector_clipf_neon(float *dst, const float *src, float min, float max,
@@ -294,7 +293,6 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) · 145 unmodified lines
294 c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_neon;293 c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_neon;
295 }294 }
296 295
297 c->butterflies_float = ff_butterflies_float_neon;
298 c->scalarproduct_float = ff_scalarproduct_float_neon;296 c->scalarproduct_float = ff_scalarproduct_float_neon;
299 c->vector_clipf = ff_vector_clipf_neon;297 c->vector_clipf = ff_vector_clipf_neon;
300 c->vector_clip_int32 = ff_vector_clip_int32_neon;298 c->vector_clip_int32 = ff_vector_clip_int32_neon;
libavcodec/arm/dsputil_neon.S+0−12
@@ -531,18 +531,6 @@ function ff_add_pixels_clamped_neon, export=1 · 530 unmodified lines
531 bx lr531 bx lr
532endfunc532endfunc
533 533
534function ff_butterflies_float_neon, export=1
5351: vld1.32 {q0},[r0,:128]
536 vld1.32 {q1},[r1,:128]
537 vsub.f32 q2, q0, q1
538 vadd.f32 q1, q0, q1
539 vst1.32 {q2},[r1,:128]!
540 vst1.32 {q1},[r0,:128]!
541 subs r2, r2, #4
542 bgt 1b
543 bx lr
544endfunc
545
546function ff_scalarproduct_float_neon, export=1534function ff_scalarproduct_float_neon, export=1
547 vmov.f32 q2, #0.0535 vmov.f32 q2, #0.0
5481: vld1.32 {q0},[r0,:128]!5361: vld1.32 {q0},[r0,:128]!
libavcodec/dsputil.c+0−12
@@ -2353,17 +2353,6 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) · 2352 unmodified lines
2353WRAPPER8_16_SQ(rd8x8_c, rd16_c)2353WRAPPER8_16_SQ(rd8x8_c, rd16_c)
2354WRAPPER8_16_SQ(bit8x8_c, bit16_c)2354WRAPPER8_16_SQ(bit8x8_c, bit16_c)
2355 2355
2356static void butterflies_float_c(float *restrict v1, float *restrict v2,
2357 int len)
2358{
2359 int i;
2360 for (i = 0; i < len; i++) {
2361 float t = v1[i] - v2[i];
2362 v1[i] += v2[i];
2363 v2[i] = t;
2364 }
2365}
2366
2367float ff_scalarproduct_float_c(const float *v1, const float *v2, int len)2356float ff_scalarproduct_float_c(const float *v1, const float *v2, int len)
2368{2357{
2369 float p = 0.0;2358 float p = 0.0;
@@ -2706,7 +2695,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) · 336 unmodified lines
2706 c->apply_window_int16 = apply_window_int16_c;2695 c->apply_window_int16 = apply_window_int16_c;
2707 c->vector_clip_int32 = vector_clip_int32_c;2696 c->vector_clip_int32 = vector_clip_int32_c;
2708 c->scalarproduct_float = ff_scalarproduct_float_c;2697 c->scalarproduct_float = ff_scalarproduct_float_c;
2709 c->butterflies_float = butterflies_float_c;
2710 2698
2711 c->shrink[0]= av_image_copy_plane;2699 c->shrink[0]= av_image_copy_plane;
2712 c->shrink[1]= ff_shrink22;2700 c->shrink[1]= ff_shrink22;
libavcodec/dsputil.h+0−7
@@ -349,13 +349,6 @@ typedef struct DSPContext { · 348 unmodified lines
349 * @param len length of vectors, multiple of 4349 * @param len length of vectors, multiple of 4
350 */350 */
351 float (*scalarproduct_float)(const float *v1, const float *v2, int len);351 float (*scalarproduct_float)(const float *v1, const float *v2, int len);
352 /**
353 * Calculate the sum and difference of two vectors of floats.
354 * @param v1 first input vector, sum output, 16-byte aligned
355 * @param v2 second input vector, difference output, 16-byte aligned
356 * @param len length of vectors, multiple of 4
357 */
358 void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
359 352
360 /* (I)DCT */353 /* (I)DCT */
361 void (*fdct)(DCTELEM *block/* align 16*/);354 void (*fdct)(DCTELEM *block/* align 16*/);
libavcodec/imc.c+5−2
@@ -36,6 +36,7 @@ · 35 unmodified lines
36#include <stdio.h>36#include <stdio.h>
37 37
38#include "libavutil/channel_layout.h"38#include "libavutil/channel_layout.h"
39#include "libavutil/float_dsp.h"
39#include "avcodec.h"40#include "avcodec.h"
40#include "get_bits.h"41#include "get_bits.h"
41#include "dsputil.h"42#include "dsputil.h"
@@ -95,6 +96,7 @@ typedef struct { · 53 unmodified lines
95 GetBitContext gb;96 GetBitContext gb;
96 97
97 DSPContext dsp;98 DSPContext dsp;
99 AVFloatDSPContext fdsp;
98 FFTContext fft;100 FFTContext fft;
99 DECLARE_ALIGNED(32, FFTComplex, samples)[COEFFS / 2];101 DECLARE_ALIGNED(32, FFTComplex, samples)[COEFFS / 2];
100 float *out_samples;102 float *out_samples;
@@ -244,6 +246,7 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) · 143 unmodified lines
244 return ret;246 return ret;
245 }247 }
246 ff_dsputil_init(&q->dsp, avctx);248 ff_dsputil_init(&q->dsp, avctx);
249 avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
247 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;250 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
248 avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO251 avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO
249 : AV_CH_LAYOUT_STEREO;252 : AV_CH_LAYOUT_STEREO;
@@ -959,8 +962,8 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, · 709 unmodified lines
959 }962 }
960 963
961 if (avctx->channels == 2) {964 if (avctx->channels == 2) {
962 q->dsp.butterflies_float((float *)q->frame.extended_data[0],965 q->fdsp.butterflies_float((float *)q->frame.extended_data[0],
963 (float *)q->frame.extended_data[1], COEFFS);966 (float *)q->frame.extended_data[1], COEFFS);
964 }967 }
965 968
966 *got_frame_ptr = 1;969 *got_frame_ptr = 1;
libavcodec/mpegaudiodec.c+4−3
@@ -25,6 +25,7 @@ · 24 unmodified lines
25 */25 */
26 26
27#include "libavutil/channel_layout.h"27#include "libavutil/channel_layout.h"
28#include "libavutil/float_dsp.h"
28#include "avcodec.h"29#include "avcodec.h"
29#include "get_bits.h"30#include "get_bits.h"
30#include "internal.h"31#include "internal.h"
@@ -82,7 +83,7 @@ typedef struct MPADecodeContext { · 51 unmodified lines
82 int err_recognition;83 int err_recognition;
83 AVCodecContext* avctx;84 AVCodecContext* avctx;
84 MPADSPContext mpadsp;85 MPADSPContext mpadsp;
85 DSPContext dsp;86 AVFloatDSPContext fdsp;
86 AVFrame frame;87 AVFrame frame;
87} MPADecodeContext;88} MPADecodeContext;
88 89
@@ -434,8 +435,8 @@ static av_cold int decode_init(AVCodecContext * avctx) · 345 unmodified lines
434 435
435 s->avctx = avctx;436 s->avctx = avctx;
436 437
438 avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
437 ff_mpadsp_init(&s->mpadsp);439 ff_mpadsp_init(&s->mpadsp);
438 ff_dsputil_init(&s->dsp, avctx);
439 440
440 if (avctx->request_sample_fmt == OUT_FMT &&441 if (avctx->request_sample_fmt == OUT_FMT &&
441 avctx->codec_id != AV_CODEC_ID_MP3ON4)442 avctx->codec_id != AV_CODEC_ID_MP3ON4)
@@ -1157,7 +1158,7 @@ found2: · 715 unmodified lines
1157 /* NOTE: the 1/sqrt(2) normalization factor is included in the1158 /* NOTE: the 1/sqrt(2) normalization factor is included in the
1158 global gain */1159 global gain */
1159#if CONFIG_FLOAT1160#if CONFIG_FLOAT
1160 s-> dsp.butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);1161 s->fdsp.butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);
1161#else1162#else
1162 tab0 = g0->sb_hybrid;1163 tab0 = g0->sb_hybrid;
1163 tab1 = g1->sb_hybrid;1164 tab1 = g1->sb_hybrid;
libavcodec/twinvq.c+1−3
@@ -178,7 +178,6 @@ static const ModeTab mode_44_48 = { · 177 unmodified lines
178typedef struct TwinContext {178typedef struct TwinContext {
179 AVCodecContext *avctx;179 AVCodecContext *avctx;
180 AVFrame frame;180 AVFrame frame;
181 DSPContext dsp;
182 AVFloatDSPContext fdsp;181 AVFloatDSPContext fdsp;
183 FFTContext mdct_ctx[3];182 FFTContext mdct_ctx[3];
184 183
@@ -693,7 +692,7 @@ static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, · 508 unmodified lines
693 if (tctx->avctx->channels == 2) {692 if (tctx->avctx->channels == 2) {
694 memcpy(&out[1][0], &prev_buf[2*mtab->size], size1 * sizeof(out[1][0]));693 memcpy(&out[1][0], &prev_buf[2*mtab->size], size1 * sizeof(out[1][0]));
695 memcpy(&out[1][size1], &tctx->curr_frame[2*mtab->size], size2 * sizeof(out[1][0]));694 memcpy(&out[1][size1], &tctx->curr_frame[2*mtab->size], size2 * sizeof(out[1][0]));
696 tctx->dsp.butterflies_float(out[0], out[1], mtab->size);695 tctx->fdsp.butterflies_float(out[0], out[1], mtab->size);
697 }696 }
698}697}
699 698
@@ -1157,7 +1156,6 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) · 457 unmodified lines
1157 return -1;1156 return -1;
1158 }1157 }
1159 1158
1160 ff_dsputil_init(&tctx->dsp, avctx);
1161 avpriv_float_dsp_init(&tctx->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);1159 avpriv_float_dsp_init(&tctx->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
1162 if ((ret = init_mdct_win(tctx))) {1160 if ((ret = init_mdct_win(tctx))) {
1163 av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");1161 av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
libavcodec/wma.c+0−1
@@ -82,7 +82,6 @@ int ff_wma_init(AVCodecContext *avctx, int flags2) · 81 unmodified lines
82 || avctx->bit_rate <= 0)82 || avctx->bit_rate <= 0)
83 return -1;83 return -1;
84 84
85 ff_dsputil_init(&s->dsp, avctx);
86 ff_fmt_convert_init(&s->fmt_conv, avctx);85 ff_fmt_convert_init(&s->fmt_conv, avctx);
87 avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);86 avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
88 87
libavcodec/wma.h+0−1
@@ -132,7 +132,6 @@ typedef struct WMACodecContext { · 131 unmodified lines
132 float lsp_pow_e_table[256];132 float lsp_pow_e_table[256];
133 float lsp_pow_m_table1[(1 << LSP_POW_BITS)];133 float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
134 float lsp_pow_m_table2[(1 << LSP_POW_BITS)];134 float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
135 DSPContext dsp;
136 FmtConvertContext fmt_conv;135 FmtConvertContext fmt_conv;
137 AVFloatDSPContext fdsp;136 AVFloatDSPContext fdsp;
138 137
libavcodec/wmadec.c+1−1
@@ -719,7 +719,7 @@ static int wma_decode_block(WMACodecContext *s) · 718 unmodified lines
719 s->channel_coded[0] = 1;719 s->channel_coded[0] = 1;
720 }720 }
721 721
722 s->dsp.butterflies_float(s->coefs[0], s->coefs[1], s->block_len);722 s->fdsp.butterflies_float(s->coefs[0], s->coefs[1], s->block_len);
723 }723 }
724 724
725next:725next:
libavutil/arm/float_dsp_init_neon.c+3−0
@@ -41,6 +41,8 @@ void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1, · 40 unmodified lines
41void ff_vector_fmul_reverse_neon(float *dst, const float *src0,41void ff_vector_fmul_reverse_neon(float *dst, const float *src0,
42 const float *src1, int len);42 const float *src1, int len);
43 43
44void ff_butterflies_float_neon(float *v1, float *v2, int len);
45
44void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp)46void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp)
45{47{
46 fdsp->vector_fmul = ff_vector_fmul_neon;48 fdsp->vector_fmul = ff_vector_fmul_neon;
@@ -49,4 +51,5 @@ void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp) · 2 unmodified lines
49 fdsp->vector_fmul_window = ff_vector_fmul_window_neon;51 fdsp->vector_fmul_window = ff_vector_fmul_window_neon;
50 fdsp->vector_fmul_add = ff_vector_fmul_add_neon;52 fdsp->vector_fmul_add = ff_vector_fmul_add_neon;
51 fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_neon;53 fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_neon;
54 fdsp->butterflies_float = ff_butterflies_float_neon;
52}55}
libavutil/arm/float_dsp_neon.S+12−0
@@ -244,3 +244,15 @@ function ff_vector_fmul_reverse_neon, export=1 · 243 unmodified lines
2442: vst1.32 {q8-q9}, [r0,:128]!2442: vst1.32 {q8-q9}, [r0,:128]!
245 bx lr245 bx lr
246endfunc246endfunc
247
248function ff_butterflies_float_neon, export=1
2491: vld1.32 {q0},[r0,:128]
250 vld1.32 {q1},[r1,:128]
251 vsub.f32 q2, q0, q1
252 vadd.f32 q1, q0, q1
253 vst1.32 {q2},[r1,:128]!
254 vst1.32 {q1},[r0,:128]!
255 subs r2, r2, #4
256 bgt 1b
257 bx lr
258endfunc
libavutil/float_dsp.c+13−0
@@ -89,6 +89,18 @@ static void vector_fmul_reverse_c(float *dst, const float *src0, · 88 unmodified lines
89 dst[i] = src0[i] * src1[-i];89 dst[i] = src0[i] * src1[-i];
90}90}
91 91
92static void butterflies_float_c(float *restrict v1, float *restrict v2,
93 int len)
94{
95 int i;
96
97 for (i = 0; i < len; i++) {
98 float t = v1[i] - v2[i];
99 v1[i] += v2[i];
100 v2[i] = t;
101 }
102}
103
92void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)104void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
93{105{
94 fdsp->vector_fmul = vector_fmul_c;106 fdsp->vector_fmul = vector_fmul_c;
@@ -98,6 +110,7 @@ void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) · 3 unmodified lines
98 fdsp->vector_fmul_window = vector_fmul_window_c;110 fdsp->vector_fmul_window = vector_fmul_window_c;
99 fdsp->vector_fmul_add = vector_fmul_add_c;111 fdsp->vector_fmul_add = vector_fmul_add_c;
100 fdsp->vector_fmul_reverse = vector_fmul_reverse_c;112 fdsp->vector_fmul_reverse = vector_fmul_reverse_c;
113 fdsp->butterflies_float = butterflies_float_c;
101 114
102#if ARCH_ARM115#if ARCH_ARM
103 ff_float_dsp_init_arm(fdsp);116 ff_float_dsp_init_arm(fdsp);
libavutil/float_dsp.h+9−0
@@ -137,6 +137,15 @@ typedef struct AVFloatDSPContext { · 136 unmodified lines
137 */137 */
138 void (*vector_fmul_reverse)(float *dst, const float *src0,138 void (*vector_fmul_reverse)(float *dst, const float *src0,
139 const float *src1, int len);139 const float *src1, int len);
140
141 /**
142 * Calculate the sum and difference of two vectors of floats.
143 *
144 * @param v1 first input vector, sum output, 16-byte aligned
145 * @param v2 second input vector, difference output, 16-byte aligned
146 * @param len length of vectors, multiple of 4
147 */
148 void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
140} AVFloatDSPContext;149} AVFloatDSPContext;
141 150
142/**151/**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t