Commit 0cf68538 authored by Rostislav Pehlivanov's avatar Rostislav Pehlivanov

aacenc: quit when the audio queue reaches 0 rather than keeping track of empty frames

The libopus encoder does the same thing and its better than
keeping track of when the empty flush frames appear.
Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
parent ef6a7864
...@@ -520,13 +520,13 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -520,13 +520,13 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
int chan_el_counter[4]; int chan_el_counter[4];
FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; FFPsyWindowInfo windows[AAC_MAX_CHANNELS];
if (s->last_frame == 2)
return 0;
/* add current frame to queue */ /* add current frame to queue */
if (frame) { if (frame) {
if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
return ret; return ret;
} else {
if (!s->afq.remaining_samples || (!s->afq.frame_alloc && !s->afq.frame_count))
return 0;
} }
copy_input_samples(s, frame); copy_input_samples(s, frame);
...@@ -841,9 +841,6 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -841,9 +841,6 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
s->lambda_sum += s->lambda; s->lambda_sum += s->lambda;
s->lambda_count++; s->lambda_count++;
if (!frame)
s->last_frame++;
ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts, ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,
&avpkt->duration); &avpkt->duration);
......
...@@ -112,7 +112,6 @@ typedef struct AACEncContext { ...@@ -112,7 +112,6 @@ typedef struct AACEncContext {
struct FFPsyPreprocessContext* psypp; struct FFPsyPreprocessContext* psypp;
AACCoefficientsEncoder *coder; AACCoefficientsEncoder *coder;
int cur_channel; ///< current channel for coder context int cur_channel; ///< current channel for coder context
int last_frame;
int random_state; int random_state;
float lambda; float lambda;
int last_frame_pb_count; ///< number of bits for the previous frame int last_frame_pb_count; ///< number of bits for the previous frame
......
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