Message ID | 20190827142552.430-1-jamrial@gmail.com |
---|---|
State | New |
Headers | show |
On 8/27/2019 11:25 AM, James Almer wrote: > Signed-off-by: James Almer <jamrial@gmail.com> > --- > This is an alternative approach to "avcodec/nuv: Avoid duplicating frames", > similar to the one from "avcodec/qtrle: call ff_reget_buffer() only when the > picture data is going to change", to workaround fuzzer reported timeouts but > without changing the behavior of the decoder. > > libavcodec/nuv.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c > index 75b14bce5b..4b171fde36 100644 > --- a/libavcodec/nuv.c > +++ b/libavcodec/nuv.c > @@ -268,7 +268,15 @@ retry: > init_frame = 1; > } > > - if ((result = ff_reget_buffer(avctx, c->pic)) < 0) > + if (comptype == NUV_COPY_LAST) { > + if (!c->pic->data[0]) > + return AVERROR_INVALIDDATA; > + // ff_reget_buffer() isn't needed when frames don't change, so just update > + // frame props. > + ret = ff_decode_frame_props(avctx, c->pic); > + if (ret < 0) > + return ret; > + } else if ((result = ff_reget_buffer(avctx, c->pic)) < 0) > return result; > if (init_frame) { > memset(c->pic->data[0], 0, avctx->height * c->pic->linesize[0]); Pushed a simpler version now that ff_reget_buffer() has a flags field for this purpose.
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 75b14bce5b..4b171fde36 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -268,7 +268,15 @@ retry: init_frame = 1; } - if ((result = ff_reget_buffer(avctx, c->pic)) < 0) + if (comptype == NUV_COPY_LAST) { + if (!c->pic->data[0]) + return AVERROR_INVALIDDATA; + // ff_reget_buffer() isn't needed when frames don't change, so just update + // frame props. + ret = ff_decode_frame_props(avctx, c->pic); + if (ret < 0) + return ret; + } else if ((result = ff_reget_buffer(avctx, c->pic)) < 0) return result; if (init_frame) { memset(c->pic->data[0], 0, avctx->height * c->pic->linesize[0]);
Signed-off-by: James Almer <jamrial@gmail.com> --- This is an alternative approach to "avcodec/nuv: Avoid duplicating frames", similar to the one from "avcodec/qtrle: call ff_reget_buffer() only when the picture data is going to change", to workaround fuzzer reported timeouts but without changing the behavior of the decoder. libavcodec/nuv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)