Andreas Rheinhardt (12021-08-12): > Up until now, an AVFilter's lists of input and output AVFilterPads > were terminated by a sentinel and the only way for the user to get > the length of these lists was by using avfilter_pad_count(). This > has two drawbacks: first, sizeof(AVFilterPad) is not negligible > (i.e. 64B on 64bit systems); second, getting the size involves > a function call instead of just reading the data. > > This commit therefore changes this. The sentinels are removed and new > fields nb_inputs and nb_outputs are added to AVFilter that contain the > number of elements of the respective AVFilterPad array. > Given that AVFilter.(in|out)puts are the only arrays of zero-terminated > AVFilterPads an API user has access to (AVFilterContext.(in|out)put_pads > are not zero-terminated and they already have a size field) the argument > to avfilter_pad_count() is always one of these lists, so it just has to > find the filter the list belongs to and read said number. This is slower > than before, but users are expected to switch to AVFilter.nb_(in|out)puts; > and furthermore, avfilter_pad_count() is probably never called in hot > loops anyway. > > This saves about 49KiB from the binary; notice that these sentinels are > not in .bss despite being zeroed; in fact, they are in .data.rel.ro > due to the non-sentinels. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
I think it is a good change. We could shave ~3.5k extra by making the fields uint16_t; lavfi is absolutely not ready to handle filters with thousands of inputs, there are loops everywhere. OTOH, I do not like the fact that it requires more boilerplate code. > @@ -330,6 +329,7 @@ const AVFilter ff_asrc_aevalsrc = { > .priv_size = sizeof(EvalContext), > .inputs = NULL, > .outputs = aevalsrc_outputs, > + .nb_outputs = FF_ARRAY_ELEMS(aevalsrc_outputs), > .priv_class = &aevalsrc_class, > }; A macro would solve that: #define FILTER_INPUTS(array) \ .inputs = (array), .nb_inputs = FF_ARRAY_ELEMS(array) Also, I am rather not for using these fields directly. Keeping them private and leaving avfilter_pad_count() gives us more freedom, including the freedom to change the type from uint16_t to unsigned later without break. Regards, -- Nicolas George
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".