*
* @param s AC-3 encoder private context
*/
-void ff_ac3_apply_rematrixing(AC3EncodeContext *s)
+static void ac3_apply_rematrixing(AC3EncodeContext *s)
{
int nb_coefs;
int blk, bnd, i;
*
* @param s AC-3 encoder private context
*/
-void ff_ac3_group_exponents(AC3EncodeContext *s)
+static void ac3_group_exponents(AC3EncodeContext *s)
{
int blk, ch, i, cpl;
int group_size, nb_groups;
*
* @param s AC-3 encoder private context
*/
-void ff_ac3_process_exponents(AC3EncodeContext *s)
+static void ac3_process_exponents(AC3EncodeContext *s)
{
extract_exponents(s);
* frame size. Output is the SNR offset and a set of bit allocation pointers
* used to quantize the mantissas.
*/
-int ff_ac3_compute_bit_allocation(AC3EncodeContext *s)
+static int ac3_compute_bit_allocation(AC3EncodeContext *s)
{
count_frame_bits(s);
*
* @param s AC-3 encoder private context
*/
-void ff_ac3_quantize_mantissas(AC3EncodeContext *s)
+static void ac3_quantize_mantissas(AC3EncodeContext *s)
{
int blk, ch, ch0=0, got_cpl;
* @param s AC-3 encoder private context
* @param frame output data buffer
*/
-void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
+static void ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
{
int blk;
output_frame_end(s);
}
+int ff_ac3_encode_frame_common_end(AVCodecContext *avctx, AVPacket *avpkt,
+ const AVFrame *frame, int *got_packet_ptr)
+{
+ AC3EncodeContext *const s = avctx->priv_data;
+ int ret;
+
+ ac3_apply_rematrixing(s);
+
+ ac3_process_exponents(s);
+
+ ret = ac3_compute_bit_allocation(s);
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n");
+ return ret;
+ }
+
+ ac3_group_exponents(s);
+
+ ac3_quantize_mantissas(s);
+
+ if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size, 0)) < 0)
+ return ret;
+ ac3_output_frame(s, avpkt->data);
+
+ if (frame->pts != AV_NOPTS_VALUE)
+ avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);
+
+ *got_packet_ptr = 1;
+ return 0;
+}
static void dprint_options(AC3EncodeContext *s)
{
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s);
-void ff_ac3_apply_rematrixing(AC3EncodeContext *s);
-
-void ff_ac3_process_exponents(AC3EncodeContext *s);
-
-int ff_ac3_compute_bit_allocation(AC3EncodeContext *s);
-
-void ff_ac3_group_exponents(AC3EncodeContext *s);
-
-void ff_ac3_quantize_mantissas(AC3EncodeContext *s);
-
-void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame);
-
+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 */
if (AC3ENC_FLOAT)
scale_coefficients(s);
- ff_ac3_apply_rematrixing(s);
-
- ff_ac3_process_exponents(s);
-
- ret = ff_ac3_compute_bit_allocation(s);
- if (ret) {
- av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n");
- return ret;
- }
-
- ff_ac3_group_exponents(s);
-
- ff_ac3_quantize_mantissas(s);
-
- if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size, 0)) < 0)
- return ret;
- ff_ac3_output_frame(s, avpkt->data);
-
- if (frame->pts != AV_NOPTS_VALUE)
- avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);
-
- *got_packet_ptr = 1;
- return 0;
+ return ff_ac3_encode_frame_common_end(avctx, avpkt, frame, got_packet_ptr);
}