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
16931693 if (cpe->ms_mask[idx] &&
16941694 cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) {
16951695 for (group = 0; group < ics->group_len[g]; group++) {
1696− ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],
1697− ch1 + group * 128 + offsets[i],
1698− offsets[i+1] - offsets[i]);
1696+ ac->fdsp.butterflies_float(ch0 + group * 128 + offsets[i],
1697+ ch1 + group * 128 + offsets[i],
1698+ offsets[i+1] - offsets[i]);
16991699 }
17001700 }
17011701 }
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
142142 void ff_avg_h264_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
143143 void ff_avg_h264_chroma_mc2_neon(uint8_t *, uint8_t *, int, int, int, int);
144144
145−void ff_butterflies_float_neon(float *v1, float *v2, int len);
146145 float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
147146
148147 void 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
294293 c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_neon;
295294 }
296295
297− c->butterflies_float = ff_butterflies_float_neon;
298296 c->scalarproduct_float = ff_scalarproduct_float_neon;
299297 c->vector_clipf = ff_vector_clipf_neon;
300298 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
531531 bx lr
532532 endfunc
533533
534−function ff_butterflies_float_neon, export=1
535−1: 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
544−endfunc
545−
546534 function ff_scalarproduct_float_neon, export=1
547535 vmov.f32 q2, #0.0
548536 1: 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
23532353 WRAPPER8_16_SQ(rd8x8_c, rd16_c)
23542354 WRAPPER8_16_SQ(bit8x8_c, bit16_c)
23552355
2356−static 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−
23672356 float ff_scalarproduct_float_c(const float *v1, const float *v2, int len)
23682357 {
23692358 float p = 0.0;
@@ -2706,7 +2695,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) · 336 unmodified lines
27062695 c->apply_window_int16 = apply_window_int16_c;
27072696 c->vector_clip_int32 = vector_clip_int32_c;
27082697 c->scalarproduct_float = ff_scalarproduct_float_c;
2709− c->butterflies_float = butterflies_float_c;
27102698
27112699 c->shrink[0]= av_image_copy_plane;
27122700 c->shrink[1]= ff_shrink22;
libavcodec/dsputil.h+0−7
@@ -349,13 +349,6 @@ typedef struct DSPContext { · 348 unmodified lines
349349 * @param len length of vectors, multiple of 4
350350 */
351351 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);
359352
360353 /* (I)DCT */
361354 void (*fdct)(DCTELEM *block/* align 16*/);
libavcodec/imc.c+5−2
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #include <stdio.h>
3737
3838 #include "libavutil/channel_layout.h"
39+#include "libavutil/float_dsp.h"
3940 #include "avcodec.h"
4041 #include "get_bits.h"
4142 #include "dsputil.h"
@@ -95,6 +96,7 @@ typedef struct { · 53 unmodified lines
9596 GetBitContext gb;
9697
9798 DSPContext dsp;
99+ AVFloatDSPContext fdsp;
98100 FFTContext fft;
99101 DECLARE_ALIGNED(32, FFTComplex, samples)[COEFFS / 2];
100102 float *out_samples;
@@ -244,6 +246,7 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) · 143 unmodified lines
244246 return ret;
245247 }
246248 ff_dsputil_init(&q->dsp, avctx);
249+ avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
247250 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
248251 avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO
249252 : AV_CH_LAYOUT_STEREO;
@@ -959,8 +962,8 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, · 709 unmodified lines
959962 }
960963
961964 if (avctx->channels == 2) {
962− q->dsp.butterflies_float((float *)q->frame.extended_data[0],
963− (float *)q->frame.extended_data[1], COEFFS);
965+ q->fdsp.butterflies_float((float *)q->frame.extended_data[0],
966+ (float *)q->frame.extended_data[1], COEFFS);
964967 }
965968
966969 *got_frame_ptr = 1;
libavcodec/mpegaudiodec.c+4−3
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 */
2626
2727 #include "libavutil/channel_layout.h"
28+#include "libavutil/float_dsp.h"
2829 #include "avcodec.h"
2930 #include "get_bits.h"
3031 #include "internal.h"
@@ -82,7 +83,7 @@ typedef struct MPADecodeContext { · 51 unmodified lines
8283 int err_recognition;
8384 AVCodecContext* avctx;
8485 MPADSPContext mpadsp;
85− DSPContext dsp;
86+ AVFloatDSPContext fdsp;
8687 AVFrame frame;
8788 } MPADecodeContext;
8889
@@ -434,8 +435,8 @@ static av_cold int decode_init(AVCodecContext * avctx) · 345 unmodified lines
434435
435436 s->avctx = avctx;
436437
438+ avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
437439 ff_mpadsp_init(&s->mpadsp);
438− ff_dsputil_init(&s->dsp, avctx);
439440
440441 if (avctx->request_sample_fmt == OUT_FMT &&
441442 avctx->codec_id != AV_CODEC_ID_MP3ON4)
@@ -1157,7 +1158,7 @@ found2: · 715 unmodified lines
11571158 /* NOTE: the 1/sqrt(2) normalization factor is included in the
11581159 global gain */
11591160 #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);
11611162 #else
11621163 tab0 = g0->sb_hybrid;
11631164 tab1 = g1->sb_hybrid;
libavcodec/twinvq.c+1−3
@@ -178,7 +178,6 @@ static const ModeTab mode_44_48 = { · 177 unmodified lines
178178 typedef struct TwinContext {
179179 AVCodecContext *avctx;
180180 AVFrame frame;
181− DSPContext dsp;
182181 AVFloatDSPContext fdsp;
183182 FFTContext mdct_ctx[3];
184183
@@ -693,7 +692,7 @@ static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, · 508 unmodified lines
693692 if (tctx->avctx->channels == 2) {
694693 memcpy(&out[1][0], &prev_buf[2*mtab->size], size1 * sizeof(out[1][0]));
695694 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);
697696 }
698697 }
699698
@@ -1157,7 +1156,6 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) · 457 unmodified lines
11571156 return -1;
11581157 }
11591158
1160− ff_dsputil_init(&tctx->dsp, avctx);
11611159 avpriv_float_dsp_init(&tctx->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
11621160 if ((ret = init_mdct_win(tctx))) {
11631161 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
8282 || avctx->bit_rate <= 0)
8383 return -1;
8484
85− ff_dsputil_init(&s->dsp, avctx);
8685 ff_fmt_convert_init(&s->fmt_conv, avctx);
8786 avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
8887
libavcodec/wma.h+0−1
@@ -132,7 +132,6 @@ typedef struct WMACodecContext { · 131 unmodified lines
132132 float lsp_pow_e_table[256];
133133 float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
134134 float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
135− DSPContext dsp;
136135 FmtConvertContext fmt_conv;
137136 AVFloatDSPContext fdsp;
138137
libavcodec/wmadec.c+1−1
@@ -719,7 +719,7 @@ static int wma_decode_block(WMACodecContext *s) · 718 unmodified lines
719719 s->channel_coded[0] = 1;
720720 }
721721
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);
723723 }
724724
725725 next:
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
4141 void ff_vector_fmul_reverse_neon(float *dst, const float *src0,
4242 const float *src1, int len);
4343
44+void ff_butterflies_float_neon(float *v1, float *v2, int len);
45+
4446 void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp)
4547 {
4648 fdsp->vector_fmul = ff_vector_fmul_neon;
@@ -49,4 +51,5 @@ void ff_float_dsp_init_neon(AVFloatDSPContext *fdsp) · 2 unmodified lines
4951 fdsp->vector_fmul_window = ff_vector_fmul_window_neon;
5052 fdsp->vector_fmul_add = ff_vector_fmul_add_neon;
5153 fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_neon;
54+ fdsp->butterflies_float = ff_butterflies_float_neon;
5255 }
libavutil/arm/float_dsp_neon.S+12−0
@@ -244,3 +244,15 @@ function ff_vector_fmul_reverse_neon, export=1 · 243 unmodified lines
244244 2: vst1.32 {q8-q9}, [r0,:128]!
245245 bx lr
246246 endfunc
247+
248+function ff_butterflies_float_neon, export=1
249+1: 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
258+endfunc
libavutil/float_dsp.c+13−0
@@ -89,6 +89,18 @@ static void vector_fmul_reverse_c(float *dst, const float *src0, · 88 unmodified lines
8989 dst[i] = src0[i] * src1[-i];
9090 }
9191
92+static 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+
92104 void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
93105 {
94106 fdsp->vector_fmul = vector_fmul_c;
@@ -98,6 +110,7 @@ void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) · 3 unmodified lines
98110 fdsp->vector_fmul_window = vector_fmul_window_c;
99111 fdsp->vector_fmul_add = vector_fmul_add_c;
100112 fdsp->vector_fmul_reverse = vector_fmul_reverse_c;
113+ fdsp->butterflies_float = butterflies_float_c;
101114
102115 #if ARCH_ARM
103116 ff_float_dsp_init_arm(fdsp);
libavutil/float_dsp.h+9−0
@@ -137,6 +137,15 @@ typedef struct AVFloatDSPContext { · 136 unmodified lines
137137 */
138138 void (*vector_fmul_reverse)(float *dst, const float *src0,
139139 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);
140149 } AVFloatDSPContext;
141150
142151 /**

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