Commit 610864dc authored by Tyler Jones's avatar Tyler Jones Committed by Rostislav Pehlivanov

avcodec/vorbisenc: Include fdsp

Signed-off-by: 's avatarTyler Jones <tdjones879@gmail.com>
parent 189ff421
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
#include <float.h> #include <float.h>
#include "libavutil/float_dsp.h"
#include "avcodec.h" #include "avcodec.h"
#include "internal.h" #include "internal.h"
...@@ -126,6 +127,8 @@ typedef struct vorbis_enc_context { ...@@ -126,6 +127,8 @@ typedef struct vorbis_enc_context {
vorbis_enc_mode *modes; vorbis_enc_mode *modes;
int64_t next_pts; int64_t next_pts;
AVFloatDSPContext *fdsp;
} vorbis_enc_context; } vorbis_enc_context;
#define MAX_CHANNELS 2 #define MAX_CHANNELS 2
...@@ -236,6 +239,26 @@ static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc) ...@@ -236,6 +239,26 @@ static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
return 0; 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, static int create_vorbis_context(vorbis_enc_context *venc,
AVCodecContext *avctx) AVCodecContext *avctx)
{ {
...@@ -426,12 +449,7 @@ static int create_vorbis_context(vorbis_enc_context *venc, ...@@ -426,12 +449,7 @@ static int create_vorbis_context(vorbis_enc_context *venc,
if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs) if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
venc->win[0] = ff_vorbis_vwin[venc->log2_blocksize[0] - 6]; if ((ret = dsp_init(avctx, venc)) < 0)
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 ret;
return 0; return 0;
...@@ -1155,6 +1173,7 @@ static av_cold int vorbis_encode_close(AVCodecContext *avctx) ...@@ -1155,6 +1173,7 @@ static av_cold int vorbis_encode_close(AVCodecContext *avctx)
av_freep(&venc->samples); av_freep(&venc->samples);
av_freep(&venc->floor); av_freep(&venc->floor);
av_freep(&venc->coeffs); av_freep(&venc->coeffs);
av_freep(&venc->fdsp);
ff_mdct_end(&venc->mdct[0]); ff_mdct_end(&venc->mdct[0]);
ff_mdct_end(&venc->mdct[1]); ff_mdct_end(&venc->mdct[1]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment