diff options
author | Paul B Mahol <onemda@gmail.com> | 2019-07-24 11:11:35 +0200 |
---|---|---|
committer | Kieran Kunhya <kierank@obe.tv> | 2019-07-25 15:13:09 +0100 |
commit | cc6a1f141762a8967d5fb17b1417900522b7ae9b (patch) | |
tree | d7754515dd22f441effaa6ea17ab174c57379fa7 /libavcodec | |
parent | 923d5c489fd4ffd0b9dbfdc6c14f594bd134ab47 (diff) | |
download | ffmpeg-cc6a1f141762a8967d5fb17b1417900522b7ae9b.tar.gz |
avcodec/adxenc: add EOF header
Fixes #8031.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/adxenc.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index f1ba5911b3..a781151b44 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -141,10 +141,26 @@ static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { ADXContext *c = avctx->priv_data; - const int16_t *samples = (const int16_t *)frame->data[0]; + const int16_t *samples = frame ? (const int16_t *)frame->data[0] : NULL; uint8_t *dst; int ch, out_size, ret; + if (!samples) { + if (c->eof) + return 0; + if ((ret = ff_alloc_packet2(avctx, avpkt, 18, 0)) < 0) + return ret; + c->eof = 1; + dst = avpkt->data; + bytestream_put_be16(&dst, 0x8001); + bytestream_put_be16(&dst, 0x000E); + bytestream_put_be64(&dst, 0x0); + bytestream_put_be32(&dst, 0x0); + bytestream_put_be16(&dst, 0x0); + *got_packet_ptr = 1; + return 0; + } + out_size = BLOCK_SIZE * avctx->channels + !c->header_parsed * HEADER_SIZE; if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0) return ret; @@ -165,6 +181,8 @@ static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, dst += BLOCK_SIZE; } + avpkt->pts = frame->pts; + avpkt->duration = frame->nb_samples; *got_packet_ptr = 1; return 0; } @@ -177,6 +195,7 @@ AVCodec ff_adpcm_adx_encoder = { .priv_data_size = sizeof(ADXContext), .init = adx_encode_init, .encode2 = adx_encode_frame, + .capabilities = AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, }; |