[FFmpeg-devel] [PATCH 5/7] avfilter/formats: Factor checking for mergeability out of ff_merge_*

Nicolas George george at nsup.org
Wed Aug 19 20:23:17 EEST 2020


Andreas Rheinhardt (12020-08-15):
> The callers of the ff_merge_*() functions fall into two categories with
> quite different needs:
> 
> One caller is can_merge_formats() which only wants to test for mergeability
> without it merging anything. In order to do so, it duplicates the lists
> it intends to test and resets their owners so that they are not modified
> by ff_merge_*(). It also means that it needs to receive the merged list
> (and not only an int containing whether the lists are mergeable) to
> properly free it.
> 
> The other callers want the lists to be actually merged. But given the
> fact that ff_merge_*() automatically updates the owners of the lists,
> they only want the information whether the merge succeeded or not; they
> don't want a link to the new list.
> 
> Therefore this commit splits these functions in two: ff_merge_*() for
> the latter callers and ff_can_merge_*() for the former.
> ff_merge_*() doesn't need to return a pointer to the combined list at all
> and hence these functions have been modified to return an int, which
> allows to distinguish between incompability and memory allocation failures.
> 
> ff_can_merge_*() meanwhile doesn't modify its arguments at all obviating
> the need for copies. This in turn implies that there is no reason to
> return a pointer to the new list, as nothing needs to be freed. These
> functions therefore return an int as well. This allowed to completely
> remove can_merge_formats() in avfiltergraph.c.
> 
> Notice that no ff_can_merge_channel_layouts() has been created, because
> there is currently no caller for this. It could be added if needed.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

LGTM, well done.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200819/05bbe6f6/attachment.sig>


More information about the ffmpeg-devel mailing list