Message ID | 1351593588-19503-6-git-send-email-martin@martin.st |
---|---|
State | New |
Headers | show |
On Tue, 30 Oct 2012, Martin Storsjö wrote: > --- > libavcodec/cngdec.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c > index caaa9c1..da74e2e 100644 > --- a/libavcodec/cngdec.c > +++ b/libavcodec/cngdec.c > @@ -112,6 +112,10 @@ static int cng_decode_frame(AVCodecContext *avctx, void *data, > float e = 1.0; > float scaling; > > + /* The delay flag is set to allow the caller to call decode with an empty > + * AVPacket, to generate more noise with the current parameters. The caller > + * shouldn't try to flush it at the end by calling with an empty AVPacket, > + * since it will generate an infinite amount of comfort noise frames. */ > if (avpkt->size) { > int dbov = -avpkt->data[0]; > p->target_energy = 1081109975 * pow(10, dbov / 10.0) * 0.75; > -- > 1.7.9.4 An alternative would be to have the caller pass an out of spec packet to it (e.g. a single byte set to 0x80, which isn't allowed currently), to generate another packet of comfort noise. Or have the caller cache the last packet and require passing that to generate more noise with the current parameters. // Martin
On 10/30/2012 11:39 AM, Martin Storsjö wrote: > --- > libavcodec/cngdec.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c > index caaa9c1..da74e2e 100644 > --- a/libavcodec/cngdec.c > +++ b/libavcodec/cngdec.c > @@ -112,6 +112,10 @@ static int cng_decode_frame(AVCodecContext *avctx, void *data, > float e = 1.0; > float scaling; > > + /* The delay flag is set to allow the caller to call decode with an empty > + * AVPacket, to generate more noise with the current parameters. The caller > + * shouldn't try to flush it at the end by calling with an empty AVPacket, > + * since it will generate an infinite amount of comfort noise frames. */ > if (avpkt->size) { > int dbov = -avpkt->data[0]; > p->target_energy = 1081109975 * pow(10, dbov / 10.0) * 0.75; > Should be put in a better place (e.g. in the documentation). lu
diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c index caaa9c1..da74e2e 100644 --- a/libavcodec/cngdec.c +++ b/libavcodec/cngdec.c @@ -112,6 +112,10 @@ static int cng_decode_frame(AVCodecContext *avctx, void *data, float e = 1.0; float scaling; + /* The delay flag is set to allow the caller to call decode with an empty + * AVPacket, to generate more noise with the current parameters. The caller + * shouldn't try to flush it at the end by calling with an empty AVPacket, + * since it will generate an infinite amount of comfort noise frames. */ if (avpkt->size) { int dbov = -avpkt->data[0]; p->target_energy = 1081109975 * pow(10, dbov / 10.0) * 0.75;