On 10/03/16 16:16, Anton Khirnov wrote:
> Quoting Mark Thompson (2016-03-10 16:56:21)
>>>> + ++avfc->nb_surfaces;
>>>> + if (avfc->nb_surfaces == 1) {
>>>> + // Test whether vaDeriveImage() works for this type of surface.
>>>> + VAImageFormat *expected_format;
>>>> + VAImage test_image;
>>>> + int err;
>>>> +
>>>> + ctx->derive_works = 0;
>>>
>>> I think this is unsafe, since this variable is also accessed in
>>> mapping the frame, which can easily happen concurrently with this
>>> function. So it would be better to make this test in frames_init.
>>> Also, this function won't be called at all if the caller supplies his
>>> own frame pool. The mapping function should work even then.
>>
>> So call get_buffer() at the end of frames_init() and try the mapping there?
>> That might be slightly surprising to the user supplying their own pool, but
>> otherwise seems entirely reasonable.
>
> I think just creating a single dummy surface with a random format and
> calling derive on it might be simpler.
The dummy surface needs to have the same attributes as the surface you actually
want to test, though - especially VASurfaceAttribMemoryType, which is going to
be set in many of the obvious use cases for this (e.g. DRM surfaces acquired
from an external source like DRI2 and made into a buffer pool to use here).
Since the attributes aren't supplied, it has to call get_buffer() in the
external case, at which point it might as well call get_buffer() for the
internal case as well.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel