On 7/24/2019 6:37 AM, Paul B Mahol wrote: > Hi, > > patch attached.
> From dc6473383580af963a120a7de89bdc34c460d000 Mon Sep 17 00:00:00 2001 > From: Paul B Mahol <one...@gmail.com> > Date: Wed, 24 Jul 2019 11:11:35 +0200 > Subject: [PATCH] avcodec/adxenc: add EOF header > > Fixes #8031. > > --- > libavcodec/adxenc.c | 21 ++++++++++++++++++++- > tests/ref/acodec/adpcm-adx | 4 ++-- > tests/ref/acodec/adpcm-adx-trellis | 4 ++-- > 3 files changed, 24 insertions(+), 5 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 }, > }; > diff --git a/tests/ref/acodec/adpcm-adx b/tests/ref/acodec/adpcm-adx > index 8c401001b8..2c8550fb72 100644 > --- a/tests/ref/acodec/adpcm-adx > +++ b/tests/ref/acodec/adpcm-adx > @@ -1,4 +1,4 @@ > -6bf1a8e5ec9cc958a31cb2b1b66bfc75 *tests/data/fate/acodec-adpcm-adx.adx > -297720 tests/data/fate/acodec-adpcm-adx.adx > +c257001314241b469a6512616fd56548 *tests/data/fate/acodec-adpcm-adx.adx > +297738 tests/data/fate/acodec-adpcm-adx.adx > 5b5a436ec9d528d6eb0bebaf667521b0 *tests/data/fate/acodec-adpcm-adx.out.wav > stddev: 2549.93 PSNR: 28.20 MAXDIFF:57514 bytes: 1058400/ 1058432 > diff --git a/tests/ref/acodec/adpcm-adx-trellis > b/tests/ref/acodec/adpcm-adx-trellis > index 039f69f9db..f6f5d768f5 100644 > --- a/tests/ref/acodec/adpcm-adx-trellis > +++ b/tests/ref/acodec/adpcm-adx-trellis > @@ -1,4 +1,4 @@ > -6bf1a8e5ec9cc958a31cb2b1b66bfc75 > *tests/data/fate/acodec-adpcm-adx-trellis.adx > -297720 tests/data/fate/acodec-adpcm-adx-trellis.adx > +c257001314241b469a6512616fd56548 > *tests/data/fate/acodec-adpcm-adx-trellis.adx > +297738 tests/data/fate/acodec-adpcm-adx-trellis.adx > 5b5a436ec9d528d6eb0bebaf667521b0 > *tests/data/fate/acodec-adpcm-adx-trellis.out.wav > stddev: 2549.93 PSNR: 28.20 MAXDIFF:57514 bytes: 1058400/ 1058432 adx is not using avctx->trellis, so the two tests are the same. IMO, unless the trellis code in adpcmenc.c can be shared and used for adx, i'd just remove the test. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".