[vlc-devel] [VLC 3.x 1/2] codec: dav1d: limit automatic frame thread count

Marvin Scholz epirat07 at gmail.com
Tue Apr 6 12:49:00 UTC 2021



On 6 Apr 2021, at 14:11, Francois Cartegnie wrote:

> Le 06/04/2021 à 14:01, Marvin Scholz a écrit :
>> Without this limit, on a processor with many cores it would use
>> so many frame threads that it would fail picture pool allocation.
>>
>> Fix #25190
>> ---
>>   modules/codec/dav1d.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/modules/codec/dav1d.c b/modules/codec/dav1d.c
>> index 3e44d524ed..0498492a73 100644
>> --- a/modules/codec/dav1d.c
>> +++ b/modules/codec/dav1d.c
>> @@ -273,6 +273,7 @@ static int Decode(decoder_t *dec, block_t *block)
>>   static int OpenDecoder(vlc_object_t *p_this)
>>   {
>>       decoder_t *dec = (decoder_t *)p_this;
>> +    unsigned i_core_count = vlc_GetCPUCount();
>>        if (dec->fmt_in.i_codec != VLC_CODEC_AV1)
>>           return VLC_EGENERIC;
>> @@ -287,7 +288,7 @@ static int OpenDecoder(vlc_object_t *p_this)
>>           p_sys->s.n_tile_threads = VLC_CLIP(vlc_GetCPUCount(), 1, 
>> 4);
>>       p_sys->s.n_frame_threads = var_InheritInteger(p_this, 
>> "dav1d-thread-frames");
>>       if (p_sys->s.n_frame_threads == 0)
>> -        p_sys->s.n_frame_threads = __MAX(1, vlc_GetCPUCount());
>> +        p_sys->s.n_frame_threads = (i_core_count < 16) ? 
>> i_core_count : 16;
>>       p_sys->s.allocator.cookie = dec;
>>       p_sys->s.allocator.alloc_picture_callback = NewPicture;
>>       p_sys->s.allocator.release_picture_callback = FreePicture;
>>
>
> I don't think the original allocation makes sense.
> We should allocate a share.
>
> You don't want to allocate more cores than frames + tiles threads in 
> any cases, with some higher priority to tiles.
>

This is not an ideal fix, so if you can come up with a better quick fix 
for
#25190 for 3.x feel free to do so.

Right now if you have a CPU with too many cores it will just break AV1
decoding with dav1d completely, so IMO it's worth a quick and dirty
workaround for now until someone cares to come up with a better fix.
(So far no one did, though)

>
> -- 
> Francois Cartegnie
> VideoLAN - VLC Developer
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list