mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-29 22:00:58 +02:00
avcodec/ac3enc: Share more code between fixed/float encoders
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
1042ee36cd
commit
2fcc50d1f5
@ -315,7 +315,7 @@ static void validate_mix_level(void *log_ctx, const char *opt_name,
|
||||
*
|
||||
* @param s AC-3 encoder private context
|
||||
*/
|
||||
int ff_ac3_validate_metadata(AC3EncodeContext *s)
|
||||
static int ac3_validate_metadata(AC3EncodeContext *s)
|
||||
{
|
||||
AVCodecContext *avctx = s->avctx;
|
||||
AC3EncOptions *opt = &s->options;
|
||||
@ -488,7 +488,7 @@ int ff_ac3_validate_metadata(AC3EncodeContext *s)
|
||||
*
|
||||
* @param s AC-3 encoder private context
|
||||
*/
|
||||
void ff_ac3_adjust_frame_size(AC3EncodeContext *s)
|
||||
static void ac3_adjust_frame_size(AC3EncodeContext *s)
|
||||
{
|
||||
while (s->bits_written >= s->bit_rate && s->samples_written >= s->sample_rate) {
|
||||
s->bits_written -= s->bit_rate;
|
||||
@ -1984,9 +1984,16 @@ int ff_ac3_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
AC3EncodeContext *const s = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
ret = s->encode_frame(s, frame);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (s->options.allow_per_frame_metadata) {
|
||||
ret = ac3_validate_metadata(s);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (s->bit_alloc.sr_code == 1 || s->eac3)
|
||||
ac3_adjust_frame_size(s);
|
||||
|
||||
s->encode_frame(s, frame);
|
||||
|
||||
ac3_apply_rematrixing(s);
|
||||
|
||||
@ -2328,7 +2335,7 @@ static av_cold int validate_options(AC3EncodeContext *s)
|
||||
if (s->cutoff > (s->sample_rate >> 1))
|
||||
s->cutoff = s->sample_rate >> 1;
|
||||
|
||||
ret = ff_ac3_validate_metadata(s);
|
||||
ret = ac3_validate_metadata(s);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -255,7 +255,7 @@ typedef struct AC3EncodeContext {
|
||||
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);
|
||||
void (*encode_frame)(struct AC3EncodeContext *s, const AVFrame *frame);
|
||||
|
||||
/* fixed vs. float function pointers */
|
||||
int (*mdct_init)(struct AC3EncodeContext *s);
|
||||
@ -277,9 +277,6 @@ int ff_ac3_float_encode_init(AVCodecContext *avctx);
|
||||
|
||||
int ff_ac3_encode_close(AVCodecContext *avctx);
|
||||
|
||||
int ff_ac3_validate_metadata(AC3EncodeContext *s);
|
||||
|
||||
void ff_ac3_adjust_frame_size(AC3EncodeContext *s);
|
||||
|
||||
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s);
|
||||
|
||||
|
@ -371,19 +371,8 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
|
||||
}
|
||||
|
||||
|
||||
static int encode_frame(AC3EncodeContext *s, const AVFrame *frame)
|
||||
static void encode_frame(AC3EncodeContext *s, const AVFrame *frame)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (s->options.allow_per_frame_metadata) {
|
||||
ret = ff_ac3_validate_metadata(s);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (s->bit_alloc.sr_code == 1 || (AC3ENC_FLOAT && s->eac3))
|
||||
ff_ac3_adjust_frame_size(s);
|
||||
|
||||
copy_input_samples(s, (SampleType **)frame->extended_data);
|
||||
|
||||
apply_mdct(s);
|
||||
@ -399,6 +388,4 @@ static int encode_frame(AC3EncodeContext *s, const AVFrame *frame)
|
||||
#if AC3ENC_FLOAT
|
||||
scale_coefficients(s);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user