Commit aa872af5 authored by Justin Ruggles's avatar Justin Ruggles

ac3enc: update to AVCodec.encode2()

Update FATE references due to encoder delay.
parent ad95307f
...@@ -2053,7 +2053,9 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) ...@@ -2053,7 +2053,9 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
s->mdct_end(s); s->mdct_end(s);
#if FF_API_OLD_ENCODE_AUDIO
av_freep(&avctx->coded_frame); av_freep(&avctx->coded_frame);
#endif
return 0; return 0;
} }
...@@ -2437,6 +2439,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) ...@@ -2437,6 +2439,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
return ret; return ret;
avctx->frame_size = AC3_BLOCK_SIZE * s->num_blocks; avctx->frame_size = AC3_BLOCK_SIZE * s->num_blocks;
avctx->delay = AC3_BLOCK_SIZE;
s->bitstream_mode = avctx->audio_service_type; s->bitstream_mode = avctx->audio_service_type;
if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE) if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE)
...@@ -2482,7 +2485,13 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) ...@@ -2482,7 +2485,13 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
if (ret) if (ret)
goto init_fail; goto init_fail;
#if FF_API_OLD_ENCODE_AUDIO
avctx->coded_frame= avcodec_alloc_frame(); avctx->coded_frame= avcodec_alloc_frame();
if (!avctx->coded_frame) {
ret = AVERROR(ENOMEM);
goto init_fail;
}
#endif
ff_dsputil_init(&s->dsp, avctx); ff_dsputil_init(&s->dsp, avctx);
ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT); ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT);
......
...@@ -297,9 +297,9 @@ int ff_ac3_float_mdct_init(AC3EncodeContext *s); ...@@ -297,9 +297,9 @@ int ff_ac3_float_mdct_init(AC3EncodeContext *s);
int ff_ac3_fixed_allocate_sample_buffers(AC3EncodeContext *s); int ff_ac3_fixed_allocate_sample_buffers(AC3EncodeContext *s);
int ff_ac3_float_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 ff_ac3_fixed_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
int buf_size, void *data); const AVFrame *frame, int *got_packet_ptr);
int ff_ac3_float_encode_frame(AVCodecContext *avctx, unsigned char *frame, int ff_ac3_float_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
int buf_size, void *data); const AVFrame *frame, int *got_packet_ptr);
#endif /* AVCODEC_AC3ENC_H */ #endif /* AVCODEC_AC3ENC_H */
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define CONFIG_FFT_FLOAT 0 #define CONFIG_FFT_FLOAT 0
#undef CONFIG_AC3ENC_FLOAT #undef CONFIG_AC3ENC_FLOAT
#include "internal.h"
#include "ac3enc.h" #include "ac3enc.h"
#include "eac3enc.h" #include "eac3enc.h"
...@@ -145,7 +146,7 @@ AVCodec ff_ac3_fixed_encoder = { ...@@ -145,7 +146,7 @@ AVCodec ff_ac3_fixed_encoder = {
.id = CODEC_ID_AC3, .id = CODEC_ID_AC3,
.priv_data_size = sizeof(AC3EncodeContext), .priv_data_size = sizeof(AC3EncodeContext),
.init = ac3_fixed_encode_init, .init = ac3_fixed_encode_init,
.encode = ff_ac3_fixed_encode_frame, .encode2 = ff_ac3_fixed_encode_frame,
.close = ff_ac3_encode_close, .close = ff_ac3_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
*/ */
#define CONFIG_AC3ENC_FLOAT 1 #define CONFIG_AC3ENC_FLOAT 1
#include "internal.h"
#include "ac3enc.h" #include "ac3enc.h"
#include "eac3enc.h" #include "eac3enc.h"
#include "kbdwin.h" #include "kbdwin.h"
...@@ -143,7 +144,7 @@ AVCodec ff_ac3_encoder = { ...@@ -143,7 +144,7 @@ AVCodec ff_ac3_encoder = {
.id = CODEC_ID_AC3, .id = CODEC_ID_AC3,
.priv_data_size = sizeof(AC3EncodeContext), .priv_data_size = sizeof(AC3EncodeContext),
.init = ff_ac3_encode_init, .init = ff_ac3_encode_init,
.encode = ff_ac3_float_encode_frame, .encode2 = ff_ac3_float_encode_frame,
.close = ff_ac3_encode_close, .close = ff_ac3_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
......
...@@ -391,11 +391,11 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s) ...@@ -391,11 +391,11 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
} }
int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, int AC3_NAME(encode_frame)(AVCodecContext *avctx, AVPacket *avpkt,
int buf_size, void *data) const AVFrame *frame, int *got_packet_ptr)
{ {
AC3EncodeContext *s = avctx->priv_data; AC3EncodeContext *s = avctx->priv_data;
const SampleType *samples = data; const SampleType *samples = (const SampleType *)frame->data[0];
int ret; int ret;
if (s->options.allow_per_frame_metadata) { if (s->options.allow_per_frame_metadata) {
...@@ -442,7 +442,15 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, ...@@ -442,7 +442,15 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame,
ff_ac3_quantize_mantissas(s); 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;
} }
...@@ -252,7 +252,7 @@ AVCodec ff_eac3_encoder = { ...@@ -252,7 +252,7 @@ AVCodec ff_eac3_encoder = {
.id = CODEC_ID_EAC3, .id = CODEC_ID_EAC3,
.priv_data_size = sizeof(AC3EncodeContext), .priv_data_size = sizeof(AC3EncodeContext),
.init = ff_ac3_encode_init, .init = ff_ac3_encode_init,
.encode = ff_ac3_float_encode_frame, .encode2 = ff_ac3_float_encode_frame,
.close = ff_ac3_encode_close, .close = ff_ac3_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, .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"), .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52 E-AC-3"),
......
f3ce1f1850655ae43f6184ae436acb70 *./tests/data/lavf/lavf.rm c002d460bc77043ced69fd00f4ae7968 *./tests/data/lavf/lavf.rm
346414 ./tests/data/lavf/lavf.rm 346414 ./tests/data/lavf/lavf.rm
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:-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:-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: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: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 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 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: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 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278
ret: 0 st: 1 flags:1 ts: 1.471000 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 ...@@ -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:-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: 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:-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: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 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 ts: 1.048000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143 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: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 ts: 2.836000
ret: 0 st: 1 flags:1 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278 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 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 ...@@ -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:-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: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: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 ts: 2.413000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 314982 size: 31143 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 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 ...@@ -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 ts: 0.201000
ret: 0 st: 1 flags:1 dts: 0.174000 pts: 0.174000 pos: 78969 size: 278 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:-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:-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: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: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 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 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: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 dts: 0.975000 pts: 0.975000 pos: 346128 size: 278
ret: 0 st: 1 flags:1 ts: 1.566000 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 ...@@ -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:-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: 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:-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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment