aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-01-29 19:01:10 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2012-03-20 18:46:56 -0400
commitaa872af5e3993c63293bbf1e33183117112b8b7a (patch)
tree78e1df718ac816d7fc9f9a4953df4212667fa47a
parentad95307f9251aa8c0e8773727589d3c1986655fc (diff)
downloadffmpeg-aa872af5e3993c63293bbf1e33183117112b8b7a.tar.gz
ac3enc: update to AVCodec.encode2()
Update FATE references due to encoder delay.
-rw-r--r--libavcodec/ac3enc.c9
-rw-r--r--libavcodec/ac3enc.h8
-rw-r--r--libavcodec/ac3enc_fixed.c3
-rw-r--r--libavcodec/ac3enc_float.c3
-rw-r--r--libavcodec/ac3enc_template.c18
-rw-r--r--libavcodec/eac3enc.c2
-rw-r--r--tests/ref/lavf/rm2
-rw-r--r--tests/ref/seek/lavf_rm18
8 files changed, 41 insertions, 22 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 967c1bd8d3..c903b724d5 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2053,7 +2053,9 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
s->mdct_end(s);
+#if FF_API_OLD_ENCODE_AUDIO
av_freep(&avctx->coded_frame);
+#endif
return 0;
}
@@ -2437,6 +2439,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
return ret;
avctx->frame_size = AC3_BLOCK_SIZE * s->num_blocks;
+ avctx->delay = AC3_BLOCK_SIZE;
s->bitstream_mode = avctx->audio_service_type;
if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE)
@@ -2482,7 +2485,13 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
if (ret)
goto init_fail;
+#if FF_API_OLD_ENCODE_AUDIO
avctx->coded_frame= avcodec_alloc_frame();
+ if (!avctx->coded_frame) {
+ ret = AVERROR(ENOMEM);
+ goto init_fail;
+ }
+#endif
ff_dsputil_init(&s->dsp, avctx);
ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT);
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index 6ef1a5373a..e8415a2d69 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 *frame, int *got_packet_ptr);
+int ff_ac3_float_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+ const AVFrame *frame, int *got_packet_ptr);
#endif /* AVCODEC_AC3ENC_H */
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index 98838f300b..140d4873ed 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -28,6 +28,7 @@
#define CONFIG_FFT_FLOAT 0
#undef CONFIG_AC3ENC_FLOAT
+#include "internal.h"
#include "ac3enc.h"
#include "eac3enc.h"
@@ -145,7 +146,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 64b360f131..f64019778b 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -27,6 +27,7 @@
*/
#define CONFIG_AC3ENC_FLOAT 1
+#include "internal.h"
#include "ac3enc.h"
#include "eac3enc.h"
#include "kbdwin.h"
@@ -143,7 +144,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 bc06c2f46f..9427cfe971 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -391,11 +391,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) {
@@ -442,7 +442,15 @@ 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;
+ if (frame->pts != AV_NOPTS_VALUE)
+ avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);
+
+ *got_packet_ptr = 1;
+ return 0;
}
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index 459fb90ce6..eb35211c73 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -252,7 +252,7 @@ AVCodec ff_eac3_encoder = {
.id = CODEC_ID_EAC3,
.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/52 E-AC-3"),
diff --git a/tests/ref/lavf/rm b/tests/ref/lavf/rm
index 27054969c6..188d15d932 100644
--- a/tests/ref/lavf/rm
+++ b/tests/ref/lavf/rm
@@ -1,2 +1,2 @@
-f3ce1f1850655ae43f6184ae436acb70 *./tests/data/lavf/lavf.rm
+c002d460bc77043ced69fd00f4ae7968 *./tests/data/lavf/lavf.rm
346414 ./tests/data/lavf/lavf.rm
diff --git a/tests/ref/seek/lavf_rm b/tests/ref/seek/lavf_rm
index 394928086b..adce9e0895 100644
--- a/tests/ref/seek/lavf_rm
+++ b/tests/ref/seek/lavf_rm
@@ -1,12 +1,12 @@
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 398 size: 31082
+ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 387 size: 278
ret: 0 st:-1 flags:0 ts:-1.000000
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 398 size: 31082
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 688 size: 31082
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143
ret: 0 st: 0 flags:0 ts: 0.788000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143
ret: 0 st: 0 flags:1 ts:-0.317000
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 398 size: 31082
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 688 size: 31082
ret: 0 st: 1 flags:0 ts: 2.577000
ret: 0 st: 1 flags:1 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278
ret: 0 st: 1 flags:1 ts: 1.471000
@@ -14,13 +14,13 @@ ret: 0 st: 1 flags:1 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278
ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 158515 size: 31134
ret: 0 st:-1 flags:1 ts:-0.740831
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 398 size: 31082
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 688 size: 31082
ret: 0 st: 0 flags:0 ts: 2.153000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143
ret: 0 st: 0 flags:1 ts: 1.048000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143
ret: 0 st: 1 flags:0 ts:-0.058000
-ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 31483 size: 278
+ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 387 size: 278
ret: 0 st: 1 flags:1 ts: 2.836000
ret: 0 st: 1 flags:1 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278
ret: 0 st:-1 flags:0 ts: 1.730004
@@ -28,7 +28,7 @@ ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 158515 size: 31134
ret: 0 st: 0 flags:0 ts:-0.482000
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 398 size: 31082
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 688 size: 31082
ret: 0 st: 0 flags:1 ts: 2.413000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143
ret: 0 st: 1 flags:0 ts: 1.307000
@@ -36,13 +36,13 @@ ret: 0 st: 1 flags:1 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278
ret: 0 st: 1 flags:1 ts: 0.201000
ret: 0 st: 1 flags:1 dts: 0.174000 pts: 0.174000 pos: 78969 size: 278
ret: 0 st:-1 flags:0 ts:-0.904994
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 398 size: 31082
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 688 size: 31082
ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143
ret: 0 st: 0 flags:0 ts: 0.883000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143
ret: 0 st: 0 flags:1 ts:-0.222000
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 398 size: 31082
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 688 size: 31082
ret: 0 st: 1 flags:0 ts: 2.672000
ret: 0 st: 1 flags:1 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278
ret: 0 st: 1 flags:1 ts: 1.566000
@@ -50,4 +50,4 @@ ret: 0 st: 1 flags:1 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 158515 size: 31134
ret: 0 st:-1 flags:1 ts:-0.645825
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 398 size: 31082
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 688 size: 31082