avcodec/ac3enc: Use common encode_frame function
This is in preparation for sharing even more stuff common to the fixed and floating-point encoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
fee093a570
commit
6244ecf8ec
@ -1769,12 +1769,16 @@ static void ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
|
||||
output_frame_end(s);
|
||||
}
|
||||
|
||||
int ff_ac3_encode_frame_common_end(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet_ptr)
|
||||
int ff_ac3_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet_ptr)
|
||||
{
|
||||
AC3EncodeContext *const s = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
ret = s->encode_frame(s, frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ac3_apply_rematrixing(s);
|
||||
|
||||
ac3_process_exponents(s);
|
||||
|
@ -49,7 +49,6 @@
|
||||
|
||||
#if AC3ENC_FLOAT
|
||||
#include "libavutil/float_dsp.h"
|
||||
#define AC3_NAME(x) ff_ac3_float_ ## x
|
||||
#define MAC_COEF(d,a,b) ((d)+=(a)*(b))
|
||||
#define COEF_MIN (-16777215.0/16777216.0)
|
||||
#define COEF_MAX ( 16777215.0/16777216.0)
|
||||
@ -59,7 +58,6 @@ typedef float CoefType;
|
||||
typedef float CoefSumType;
|
||||
#else
|
||||
#include "libavutil/fixed_dsp.h"
|
||||
#define AC3_NAME(x) ff_ac3_fixed_ ## x
|
||||
#define MAC_COEF(d,a,b) MAC64(d,a,b)
|
||||
#define COEF_MIN -16777215
|
||||
#define COEF_MAX 16777215
|
||||
@ -256,6 +254,9 @@ typedef struct AC3EncodeContext {
|
||||
uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap)
|
||||
int ref_bap_set; ///< indicates if ref_bap pointers have been set
|
||||
|
||||
/** fixed vs. float function pointers */
|
||||
int (*encode_frame)(struct AC3EncodeContext *s, const AVFrame *frame);
|
||||
|
||||
/* fixed vs. float function pointers */
|
||||
int (*mdct_init)(struct AC3EncodeContext *s);
|
||||
|
||||
@ -282,14 +283,7 @@ void ff_ac3_adjust_frame_size(AC3EncodeContext *s);
|
||||
|
||||
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s);
|
||||
|
||||
int ff_ac3_encode_frame_common_end(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet_ptr);
|
||||
|
||||
/* prototypes for functions in ac3enc_template.c */
|
||||
|
||||
int ff_ac3_fixed_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet_ptr);
|
||||
int ff_ac3_float_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet_ptr);
|
||||
int ff_ac3_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet_ptr);
|
||||
|
||||
#endif /* AVCODEC_AC3ENC_H */
|
||||
|
@ -102,6 +102,7 @@ static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx)
|
||||
{
|
||||
AC3EncodeContext *s = avctx->priv_data;
|
||||
s->fixed_point = 1;
|
||||
s->encode_frame = encode_frame;
|
||||
s->mdct_init = ac3_fixed_mdct_init;
|
||||
s->allocate_sample_buffers = allocate_sample_buffers;
|
||||
return ff_ac3_encode_init(avctx);
|
||||
@ -116,7 +117,7 @@ const FFCodec ff_ac3_fixed_encoder = {
|
||||
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
|
||||
.priv_data_size = sizeof(AC3EncodeContext),
|
||||
.init = ac3_fixed_encode_init,
|
||||
FF_CODEC_ENCODE_CB(ff_ac3_fixed_encode_frame),
|
||||
FF_CODEC_ENCODE_CB(ff_ac3_encode_frame),
|
||||
.close = ff_ac3_encode_close,
|
||||
.p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P,
|
||||
AV_SAMPLE_FMT_NONE },
|
||||
|
@ -104,6 +104,8 @@ static av_cold int ac3_float_mdct_init(AC3EncodeContext *s)
|
||||
av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx)
|
||||
{
|
||||
AC3EncodeContext *s = avctx->priv_data;
|
||||
|
||||
s->encode_frame = encode_frame;
|
||||
s->mdct_init = ac3_float_mdct_init;
|
||||
s->allocate_sample_buffers = allocate_sample_buffers;
|
||||
s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
|
||||
@ -120,7 +122,7 @@ const FFCodec ff_ac3_encoder = {
|
||||
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
|
||||
.priv_data_size = sizeof(AC3EncodeContext),
|
||||
.init = ff_ac3_float_encode_init,
|
||||
FF_CODEC_ENCODE_CB(ff_ac3_float_encode_frame),
|
||||
FF_CODEC_ENCODE_CB(ff_ac3_encode_frame),
|
||||
.close = ff_ac3_encode_close,
|
||||
.p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
|
||||
AV_SAMPLE_FMT_NONE },
|
||||
|
@ -371,10 +371,8 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
|
||||
}
|
||||
|
||||
|
||||
int AC3_NAME(encode_frame)(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet_ptr)
|
||||
static int encode_frame(AC3EncodeContext *s, const AVFrame *frame)
|
||||
{
|
||||
AC3EncodeContext *s = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
if (s->options.allow_per_frame_metadata) {
|
||||
@ -402,5 +400,5 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
scale_coefficients(s);
|
||||
#endif
|
||||
|
||||
return ff_ac3_encode_frame_common_end(avctx, avpkt, frame, got_packet_ptr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ const FFCodec ff_eac3_encoder = {
|
||||
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
|
||||
.priv_data_size = sizeof(AC3EncodeContext),
|
||||
.init = ff_ac3_float_encode_init,
|
||||
FF_CODEC_ENCODE_CB(ff_ac3_float_encode_frame),
|
||||
FF_CODEC_ENCODE_CB(ff_ac3_encode_frame),
|
||||
.close = ff_ac3_encode_close,
|
||||
.p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
|
||||
AV_SAMPLE_FMT_NONE },
|
||||
|
Loading…
x
Reference in New Issue
Block a user