Re: [FFmpeg-devel] [PATCH] avutil: merge avpriv_float_dsp_init into avpriv_float_dsp_alloc
On 14.10.2015 02:04, James Almer wrote: > On 10/13/2015 8:48 PM, Andreas Cadhalpun wrote: >> Also replace the last two usages of avpriv_float_dsp_init with >> avpriv_float_dsp_alloc. >> >> Signed-off-by: Andreas Cadhalpun>> --- >> libavutil/float_dsp.c | 47 ++- >> libavutil/float_dsp.h | 9 - >> 2 files changed, 26 insertions(+), 30 deletions(-) >> >> diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c >> index 337708e..c1430f0 100644 >> --- a/libavutil/float_dsp.c >> +++ b/libavutil/float_dsp.c >> @@ -116,8 +116,12 @@ float avpriv_scalarproduct_float_c(const float *v1, >> const float *v2, int len) >> return p; >> } >> >> -av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) >> +av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) >> { >> +AVFloatDSPContext *fdsp = av_mallocz(sizeof(AVFloatDSPContext)); >> +if (!fdsp) >> +return NULL; >> + >> fdsp->vector_fmul = vector_fmul_c; >> fdsp->vector_fmac_scalar = vector_fmac_scalar_c; >> fdsp->vector_fmul_scalar = vector_fmul_scalar_c; >> @@ -138,14 +142,7 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext >> *fdsp, int bit_exact) >> ff_float_dsp_init_x86(fdsp); >> if (ARCH_MIPS) >> ff_float_dsp_init_mips(fdsp); >> -} >> - >> -av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) >> -{ >> -AVFloatDSPContext *ret = av_mallocz(sizeof(AVFloatDSPContext)); >> -if (ret) >> -avpriv_float_dsp_init(ret, bit_exact); >> -return ret; >> +return fdsp; >> } >> >> >> @@ -386,7 +383,7 @@ int main(int argc, char **argv) >> { >> int ret = 0, seeded = 0; >> uint32_t seed; >> -AVFloatDSPContext fdsp, cdsp; >> +AVFloatDSPContext *fdsp, *cdsp; >> AVLFG lfg; >> >> LOCAL_ALIGNED(32, float, src0, [LEN]); >> @@ -430,29 +427,37 @@ int main(int argc, char **argv) >> fill_double_array(, dbl_src0, LEN); >> fill_double_array(, dbl_src1, LEN); >> >> -avpriv_float_dsp_init(, 1); >> +fdsp = avpriv_float_dsp_alloc(1); >> av_force_cpu_flags(0); >> -avpriv_float_dsp_init(, 1); >> +cdsp = avpriv_float_dsp_alloc(1); >> + >> +if (!fdsp || !cdsp) { >> +ret = 1; >> +goto end; >> +} > > This could go above the av_log or av_lfg_init lines, to avoid pointlessly > running all the array filling code when the test is going to fail anyway. > > LGTM nonetheless. Changed and pushed. Best regards, Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avutil: merge avpriv_float_dsp_init into avpriv_float_dsp_alloc
On 10/13/2015 8:48 PM, Andreas Cadhalpun wrote: > Also replace the last two usages of avpriv_float_dsp_init with > avpriv_float_dsp_alloc. > > Signed-off-by: Andreas Cadhalpun> --- > libavutil/float_dsp.c | 47 ++- > libavutil/float_dsp.h | 9 - > 2 files changed, 26 insertions(+), 30 deletions(-) > > diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c > index 337708e..c1430f0 100644 > --- a/libavutil/float_dsp.c > +++ b/libavutil/float_dsp.c > @@ -116,8 +116,12 @@ float avpriv_scalarproduct_float_c(const float *v1, > const float *v2, int len) > return p; > } > > -av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) > +av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) > { > +AVFloatDSPContext *fdsp = av_mallocz(sizeof(AVFloatDSPContext)); > +if (!fdsp) > +return NULL; > + > fdsp->vector_fmul = vector_fmul_c; > fdsp->vector_fmac_scalar = vector_fmac_scalar_c; > fdsp->vector_fmul_scalar = vector_fmul_scalar_c; > @@ -138,14 +142,7 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext > *fdsp, int bit_exact) > ff_float_dsp_init_x86(fdsp); > if (ARCH_MIPS) > ff_float_dsp_init_mips(fdsp); > -} > - > -av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) > -{ > -AVFloatDSPContext *ret = av_mallocz(sizeof(AVFloatDSPContext)); > -if (ret) > -avpriv_float_dsp_init(ret, bit_exact); > -return ret; > +return fdsp; > } > > > @@ -386,7 +383,7 @@ int main(int argc, char **argv) > { > int ret = 0, seeded = 0; > uint32_t seed; > -AVFloatDSPContext fdsp, cdsp; > +AVFloatDSPContext *fdsp, *cdsp; > AVLFG lfg; > > LOCAL_ALIGNED(32, float, src0, [LEN]); > @@ -430,29 +427,37 @@ int main(int argc, char **argv) > fill_double_array(, dbl_src0, LEN); > fill_double_array(, dbl_src1, LEN); > > -avpriv_float_dsp_init(, 1); > +fdsp = avpriv_float_dsp_alloc(1); > av_force_cpu_flags(0); > -avpriv_float_dsp_init(, 1); > +cdsp = avpriv_float_dsp_alloc(1); > + > +if (!fdsp || !cdsp) { > +ret = 1; > +goto end; > +} This could go above the av_log or av_lfg_init lines, to avoid pointlessly running all the array filling code when the test is going to fail anyway. LGTM nonetheless. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avutil: merge avpriv_float_dsp_init into avpriv_float_dsp_alloc
Also replace the last two usages of avpriv_float_dsp_init with avpriv_float_dsp_alloc. Signed-off-by: Andreas Cadhalpun--- libavutil/float_dsp.c | 47 ++- libavutil/float_dsp.h | 9 - 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c index 337708e..c1430f0 100644 --- a/libavutil/float_dsp.c +++ b/libavutil/float_dsp.c @@ -116,8 +116,12 @@ float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len) return p; } -av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) +av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) { +AVFloatDSPContext *fdsp = av_mallocz(sizeof(AVFloatDSPContext)); +if (!fdsp) +return NULL; + fdsp->vector_fmul = vector_fmul_c; fdsp->vector_fmac_scalar = vector_fmac_scalar_c; fdsp->vector_fmul_scalar = vector_fmul_scalar_c; @@ -138,14 +142,7 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) ff_float_dsp_init_x86(fdsp); if (ARCH_MIPS) ff_float_dsp_init_mips(fdsp); -} - -av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) -{ -AVFloatDSPContext *ret = av_mallocz(sizeof(AVFloatDSPContext)); -if (ret) -avpriv_float_dsp_init(ret, bit_exact); -return ret; +return fdsp; } @@ -386,7 +383,7 @@ int main(int argc, char **argv) { int ret = 0, seeded = 0; uint32_t seed; -AVFloatDSPContext fdsp, cdsp; +AVFloatDSPContext *fdsp, *cdsp; AVLFG lfg; LOCAL_ALIGNED(32, float, src0, [LEN]); @@ -430,29 +427,37 @@ int main(int argc, char **argv) fill_double_array(, dbl_src0, LEN); fill_double_array(, dbl_src1, LEN); -avpriv_float_dsp_init(, 1); +fdsp = avpriv_float_dsp_alloc(1); av_force_cpu_flags(0); -avpriv_float_dsp_init(, 1); +cdsp = avpriv_float_dsp_alloc(1); + +if (!fdsp || !cdsp) { +ret = 1; +goto end; +} -if (test_vector_fmul(, , src0, src1)) +if (test_vector_fmul(fdsp, cdsp, src0, src1)) ret -= 1 << 0; -if (test_vector_fmac_scalar(, , src2, src0, src1[0])) +if (test_vector_fmac_scalar(fdsp, cdsp, src2, src0, src1[0])) ret -= 1 << 1; -if (test_vector_fmul_scalar(, , src0, src1[0])) +if (test_vector_fmul_scalar(fdsp, cdsp, src0, src1[0])) ret -= 1 << 2; -if (test_vector_fmul_window(, , src0, src1, src2)) +if (test_vector_fmul_window(fdsp, cdsp, src0, src1, src2)) ret -= 1 << 3; -if (test_vector_fmul_add(, , src0, src1, src2)) +if (test_vector_fmul_add(fdsp, cdsp, src0, src1, src2)) ret -= 1 << 4; -if (test_vector_fmul_reverse(, , src0, src1)) +if (test_vector_fmul_reverse(fdsp, cdsp, src0, src1)) ret -= 1 << 5; -if (test_butterflies_float(, , src0, src1)) +if (test_butterflies_float(fdsp, cdsp, src0, src1)) ret -= 1 << 6; -if (test_scalarproduct_float(, , src0, src1)) +if (test_scalarproduct_float(fdsp, cdsp, src0, src1)) ret -= 1 << 7; -if (test_vector_dmul_scalar(, , dbl_src0, dbl_src1[0])) +if (test_vector_dmul_scalar(fdsp, cdsp, dbl_src0, dbl_src1[0])) ret -= 1 << 8; +end: +av_freep(); +av_freep(); return ret; } diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h index ad8e3eb..d1be38f 100644 --- a/libavutil/float_dsp.h +++ b/libavutil/float_dsp.h @@ -170,15 +170,6 @@ typedef struct AVFloatDSPContext { */ float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len); -/** - * Initialize a float DSP context. - * - * @param fdspfloat DSP context - * @param strict setting to non-zero avoids using functions which may not be IEEE-754 compliant - */ -void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int strict); - - void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp); void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp); void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict); -- 2.6.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel