---
libavcodec/ac3enc.c | 2 +-
libavcodec/ac3enc.h | 8 ++++----
libavcodec/ac3enc_fixed.c | 2 +-
libavcodec/ac3enc_float.c | 2 +-
libavcodec/ac3enc_template.c | 22 +++++++++++++++++-----
5 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index b8e23e4..05626e6 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1665,7 +1665,7 @@ void ff_ac3_output_frame(AC3EncodeContext *s, unsigned
char *frame)
{
int blk;
- init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
+ init_put_bits(&s->pb, frame, s->frame_size);
s->output_frame_header(s);
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index 6ef1a53..7ea4f95 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -297,9 +297,9 @@ int ff_ac3_float_mdct_init(AC3EncodeContext *s);
int ff_ac3_fixed_allocate_sample_buffers(AC3EncodeContext *s);
int ff_ac3_float_allocate_sample_buffers(AC3EncodeContext *s);
-int ff_ac3_fixed_encode_frame(AVCodecContext *avctx, unsigned char *frame,
- int buf_size, void *data);
-int ff_ac3_float_encode_frame(AVCodecContext *avctx, unsigned char *frame,
- int buf_size, void *data);
+int ff_ac3_fixed_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+ const AVFrame *data);
+int ff_ac3_float_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+ const AVFrame *data);
#endif /* AVCODEC_AC3ENC_H */
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index 202dfb8..241cde8 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -145,7 +145,7 @@ AVCodec ff_ac3_fixed_encoder = {
.id = CODEC_ID_AC3,
.priv_data_size = sizeof(AC3EncodeContext),
.init = ac3_fixed_encode_init,
- .encode = ff_ac3_fixed_encode_frame,
+ .encode2 = ff_ac3_fixed_encode_frame,
.close = ff_ac3_encode_close,
.sample_fmts = (const enum
AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index a4abd89..681a0ef 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -143,7 +143,7 @@ AVCodec ff_ac3_encoder = {
.id = CODEC_ID_AC3,
.priv_data_size = sizeof(AC3EncodeContext),
.init = ff_ac3_encode_init,
- .encode = ff_ac3_float_encode_frame,
+ .encode2 = ff_ac3_float_encode_frame,
.close = ff_ac3_encode_close,
.sample_fmts = (const enum
AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 3396ed1..8770994 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -28,6 +28,8 @@
#include <stdint.h>
+#include "libavutil/mathematics.h"
+#include "internal.h"
/* prototypes for static functions in ac3enc_fixed.c and ac3enc_float.c */
@@ -391,11 +393,11 @@ static void compute_rematrixing_strategy(AC3EncodeContext
*s)
}
-int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame,
- int buf_size, void *data)
+int AC3_NAME(encode_frame)(AVCodecContext *avctx, AVPacket *avpkt,
+ const AVFrame *frame)
{
AC3EncodeContext *s = avctx->priv_data;
- const SampleType *samples = data;
+ const SampleType *samples = (const SampleType *)frame->data[0];
int ret;
if (s->options.allow_per_frame_metadata) {
@@ -442,7 +444,17 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned
char *frame,
ff_ac3_quantize_mantissas(s);
- ff_ac3_output_frame(s, frame);
+ if ((ret = ff_alloc_packet(avpkt, s->frame_size))) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
+ return ret;
+ }
+ ff_ac3_output_frame(s, avpkt->data);
- return s->frame_size;
+ avpkt->duration = av_rescale_q(s->num_blocks * AC3_BLOCK_SIZE,
+ (AVRational){ 1, avctx->sample_rate },
+ avctx->time_base);
+ avpkt->pts = frame->pts;
+ avpkt->size = s->frame_size;
+
+ return 0;
}
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel