[FFmpeg-devel] [PATCH] avcodec/snow: ensure current_picture is writable before modifying its data
James Almer
jamrial at gmail.com
Sat May 30 01:00:12 EEST 2020
On 5/29/2020 5:37 PM, Michael Niedermayer wrote:
> On Fri, May 29, 2020 at 02:20:37PM -0300, James Almer wrote:
>> current_picture was not writable here because a reference existed in
>> at least avctx->coded_frame, and potentially elsewhere if the caller
>> created new ones from it.
>
> Please elaborate when and how the encoder internal buffer becomes
> read only
> i simply took your code and replaced
>
> - ret = av_frame_make_writable(s->current_picture);
> - if (ret < 0)
> - return ret;
> + ret = av_frame_is_writable(s->current_picture);
> + if (ret <= 0)
> + return -1;
>
> and fate is fully happy which tests both the encoder and the filters
> using it
> also if this is for coded_frame then shouldnt it be under FF_API_CODED_FRAME?
> iam clearly missing something here
You need to also move the av_frame_unref(avctx->coded_frame) line back
to where it was before my patch. I moved it before this check to ensure
at least the reference stored there is freed before current_picture is
written to, but there of course could still exist other references
created by the user, and that's what this make_writable() call is for.
And since this specific chunk is not strictly coded_frame related, it
doesn't need to be under that guard.
>
> thx
>
> [...]
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list