[FFmpeg-devel] [PATCH v8 13/13] avfilter/graphicsub2text: Add new graphicsub2text filter (OCR)

Soft Works softworkz at hotmail.com
Wed Sep 22 05:35:27 EEST 2021



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Andreas
> Rheinhardt
> Sent: Wednesday, 22 September 2021 04:26
> To: ffmpeg-devel at ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v8 13/13] avfilter/graphicsub2text: Add
> new graphicsub2text filter (OCR)
> 
> Soft Works:
> >
> >
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Andreas
> >> Rheinhardt
> >> Sent: Wednesday, 22 September 2021 04:05
> >> To: ffmpeg-devel at ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCH v8 13/13] avfilter/graphicsub2text: Add
> >> new graphicsub2text filter (OCR)
> >>
> >>> +
> >>> +static void uninit(AVFilterContext *ctx)
> >>> +{
> >>> +    SubOcrContext *s = ctx->priv;
> >>> +
> >>> +    TessBaseAPIEnd(s->tapi);
> >>> +    TessBaseAPIDelete(s->tapi);
> >>
> >> Beware: uninit is also called on init failure, so it might be that
> >> s->tapi is NULL or that TessBaseAPIInit4 did not succeed.
> >
> > vf_ocr does it in the same way, so I assumed it to be safe.
> >
> 
> I wish it were that easy. Our own APIs are (usually) safe in the sense
> that an object that has been memset to zero (as all those contexts are
> initially) can be passed to the free function even when it has never
> been initialized. But this is need not be true for external APIs. And
> unfortunately error paths are often untested.

That's true. Though, I looked at more than a handful of other code 
using tesseract and I've never seen any additional checks in the 
uninit code. But now that you said it - I'll try it out to be sure :-)

Thanks,
softworkz




More information about the ffmpeg-devel mailing list