[FFmpeg-devel] [PATCH 1/2] avcodec/vorbisenc: Include fdsp
Tyler Jones
tdjones879 at gmail.com
Tue May 30 18:14:17 EEST 2017
Signed-off-by: Tyler Jones <tdjones879 at gmail.com>
---
libavcodec/vorbisenc.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index 2974ca2..7c3cd51 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -25,6 +25,7 @@
*/
#include <float.h>
+#include "libavutil/float_dsp.h"
#include "avcodec.h"
#include "internal.h"
@@ -126,6 +127,8 @@ typedef struct vorbis_enc_context {
vorbis_enc_mode *modes;
int64_t next_pts;
+
+ AVFloatDSPContext *fdsp;
} vorbis_enc_context;
#define MAX_CHANNELS 2
@@ -236,6 +239,26 @@ static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
return 0;
}
+static av_cold int dsp_init(AVCodecContext *avctx, vorbis_enc_context *venc)
+{
+ int ret = 0;
+
+ venc->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+ if (!venc->fdsp)
+ return AVERROR(ENOMEM);
+
+ // init windows
+ venc->win[0] = ff_vorbis_vwin[venc->log2_blocksize[0] - 6];
+ venc->win[1] = ff_vorbis_vwin[venc->log2_blocksize[1] - 6];
+
+ if ((ret = ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0, 1.0)) < 0)
+ return ret;
+ if ((ret = ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0, 1.0)) < 0)
+ return ret;
+
+ return 0;
+}
+
static int create_vorbis_context(vorbis_enc_context *venc,
AVCodecContext *avctx)
{
@@ -426,12 +449,7 @@ static int create_vorbis_context(vorbis_enc_context *venc,
if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs)
return AVERROR(ENOMEM);
- venc->win[0] = ff_vorbis_vwin[venc->log2_blocksize[0] - 6];
- venc->win[1] = ff_vorbis_vwin[venc->log2_blocksize[1] - 6];
-
- if ((ret = ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0, 1.0)) < 0)
- return ret;
- if ((ret = ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0, 1.0)) < 0)
+ if ((ret = dsp_init(avctx, venc)) < 0)
return ret;
return 0;
@@ -1155,6 +1173,7 @@ static av_cold int vorbis_encode_close(AVCodecContext *avctx)
av_freep(&venc->samples);
av_freep(&venc->floor);
av_freep(&venc->coeffs);
+ av_freep(&venc->fdsp);
ff_mdct_end(&venc->mdct[0]);
ff_mdct_end(&venc->mdct[1]);
--
2.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170530/edcc3fae/attachment.sig>
More information about the ffmpeg-devel
mailing list