]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ac3enc_template.c
lavfi/hflip: copy palette data in start_frame()
[ffmpeg] / libavcodec / ac3enc_template.c
index 554e0b007bcf2e7c0da1f25c8761b1c3188c7473..20ac301a433ed499c7e2ef3165e2157ba9f09437 100644 (file)
@@ -386,11 +386,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, 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) {
@@ -437,7 +437,13 @@ 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_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;
 }