diff options
author | Justin Ruggles | 2012-01-29 19:01:10 -0500 |
---|---|---|
committer | Justin Ruggles | 2012-03-20 18:46:56 -0400 |
commit | aa872af5e3993c63293bbf1e33183117112b8b7a (patch) | |
tree | 78e1df718ac816d7fc9f9a4953df4212667fa47a /libavcodec | |
parent | ad95307f9251aa8c0e8773727589d3c1986655fc (diff) |
ac3enc: update to AVCodec.encode2()
Update FATE references due to encoder delay.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ac3enc.c | 9 | ||||
-rw-r--r-- | libavcodec/ac3enc.h | 8 | ||||
-rw-r--r-- | libavcodec/ac3enc_fixed.c | 3 | ||||
-rw-r--r-- | libavcodec/ac3enc_float.c | 3 | ||||
-rw-r--r-- | libavcodec/ac3enc_template.c | 18 | ||||
-rw-r--r-- | libavcodec/eac3enc.c | 2 |
6 files changed, 31 insertions, 12 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"), |