}
-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, int *got_packet_ptr)
{
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) {
ff_ac3_quantize_mantissas(s);
- ff_ac3_output_frame(s, frame);
+ if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size)))
+ 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->delay);
- return s->frame_size;
+ *got_packet_ptr = 1;
+ return 0;
}