[vlc-devel] [PATCH 1/7] decoder: pass the chroma to decode to the decoder device

Steve Lhomme robux4 at ycbcr.xyz
Wed Jun 26 17:02:09 CEST 2019


On 2019-06-26 16:48, Thomas Guillem wrote:
> 
> On Wed, Jun 26, 2019, at 16:28, Steve Lhomme wrote:
>> On 2019-06-26 16:06, Thomas Guillem wrote:
>>> Question: The decoder device should not be constant to the window and not depends on the decoder ?
>>
>> Probably, yes. But the decoder/display configuration shouldn't change
>> during the lifetime of the vout thread either.
> 
> To sum up and make sure we understand each other:
> 
> - The vout_thread_t is still constant (the same can be used with different medias)
> - The window module inside the vout_thread_t is also constant: it is enabled when a decoder starts a vout (vout_Request) and disabled when the decoder is destroyed.
> 
> - The decoder device is created after the window is enabled (order coming from a vout_Request() from a video decoder). It is destroyed before the window is disabled.
> - The decoder can now load a hw decoder using the decoder device.
> 
> I see a chicken-egg situation here with your patch. How can you know that the chroma is DXVA2 if you didn't created the hw decoder yet.

In push the decoder will still create the "vout" (thread+window+display) 
as it does now. It will be in 2 parts, first create the vout thread + 
window + decoder device, then the VA can actually be created with the 
decoder device. And then the display module is created using the video 
context that the VA created.

More video context can be pushed and will may use the same decoder 
device. Or it could redo the first part and recreate a vout thread + 
window (which are cached internally) + decoder device.

This is done via a split of decoder_UpdateVideoFormat() in two.

>>
>>> This patch could be more readable if you move the vlc_decoder_device_Create() call to its definite place (Just after the window creation).
>>
>> Yes it's going to move later.
> 
> I think it should be done before, cf ^^
> 
>>
>>> On Wed, Jun 26, 2019, at 15:50, Steve Lhomme wrote:
>>>> On Windows the default decoder device to use would be the D3D11 one, but if the
>>>> source chroma to decode (in push or not) is a DXVA2 chroma we should be using
>>>> a D3D9 decoder device. The D3D11 decoder device needs to have that information
>>>> so it can refuse to be created by default.
>>>> ---
>>>>    include/vlc_codec.h                           | 6 ++++--
>>>>    modules/hw/vaapi/decoder_device.c             | 3 ++-
>>>>    modules/video_output/opengl/converter_vdpau.c | 3 ++-
>>>>    src/input/decoder_helpers.c                   | 7 ++++---
>>>>    src/video_output/display.c                    | 2 +-
>>>>    5 files changed, 13 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/include/vlc_codec.h b/include/vlc_codec.h
>>>> index 86f092c029..a421c6d710 100644
>>>> --- a/include/vlc_codec.h
>>>> +++ b/include/vlc_codec.h
>>>> @@ -528,9 +528,11 @@ typedef struct vlc_decoder_device
>>>>     *
>>>>     * @param device the "decoder device" structure to initialize
>>>>     * @param window pointer to a window to help device initialization
>>>> (can be NULL)
>>>> + * @param chroma hint on the chroma what will be decoded
>>>>     **/
>>>>    typedef int (*vlc_decoder_device_Open)(vlc_decoder_device *device,
>>>> -                                        vout_window_t *window);
>>>> +                                        vout_window_t *window,
>>>> +                                        vlc_fourcc_t chroma);
>>>>    /** "decoder device" module close entry point */
>>>>    typedef void (*vlc_decoder_device_Close)(vlc_decoder_device *device);
>>>>    
>>>> @@ -541,7 +543,7 @@ typedef void
>>>> (*vlc_decoder_device_Close)(vlc_decoder_device *device);
>>>>     * module as a transition.
>>>>     */
>>>>    VLC_USED vlc_decoder_device *
>>>> -vlc_decoder_device_Create(vout_window_t *window);
>>>> +vlc_decoder_device_Create(vout_window_t *window, const video_format_t
>>>> *);
>>>>    
>>>>    /**
>>>>     * Hold a decoder device
>>>> diff --git a/modules/hw/vaapi/decoder_device.c
>>>> b/modules/hw/vaapi/decoder_device.c
>>>> index 5efe9e635b..00d654d245 100644
>>>> --- a/modules/hw/vaapi/decoder_device.c
>>>> +++ b/modules/hw/vaapi/decoder_device.c
>>>> @@ -217,8 +217,9 @@ Close(vlc_decoder_device *device)
>>>>    }
>>>>    
>>>>    static int
>>>> -Open(vlc_decoder_device *device, vout_window_t *window)
>>>> +Open(vlc_decoder_device *device, vout_window_t *window, vlc_fourcc_t
>>>> chroma)
>>>>    {
>>>> +    VLC_UNUSED(chroma);
>>>>        VADisplay vadpy = NULL;
>>>>        struct vaapi_instance *vainst = NULL;
>>>>    #if defined (HAVE_VA_X11)
>>>> diff --git a/modules/video_output/opengl/converter_vdpau.c
>>>> b/modules/video_output/opengl/converter_vdpau.c
>>>> index d40d5d181f..3363a38ca1 100644
>>>> --- a/modules/video_output/opengl/converter_vdpau.c
>>>> +++ b/modules/video_output/opengl/converter_vdpau.c
>>>> @@ -185,8 +185,9 @@ DecoderContextClose(vlc_decoder_device *device)
>>>>    }
>>>>    
>>>>    static int
>>>> -DecoderContextOpen(vlc_decoder_device *device, vout_window_t *window)
>>>> +DecoderContextOpen(vlc_decoder_device *device, vout_window_t *window,
>>>> vlc_fourcc_t chroma)
>>>>    {
>>>> +    VLC_UNUSED(chroma);
>>>>        if (!window || !vlc_xlib_init(VLC_OBJECT(window)))
>>>>            return VLC_EGENERIC;
>>>>    
>>>> diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
>>>> index 7384e2bda0..35a291921d 100644
>>>> --- a/src/input/decoder_helpers.c
>>>> +++ b/src/input/decoder_helpers.c
>>>> @@ -105,7 +105,8 @@ static int decoder_device_Open(void *func, bool
>>>> forced, va_list ap)
>>>>        vlc_decoder_device_Open open = func;
>>>>        vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *);
>>>>        vout_window_t *window = va_arg(ap, vout_window_t *);
>>>> -    int ret = open(device, window);
>>>> +    vlc_fourcc_t chroma = va_arg(ap, vlc_fourcc_t);
>>>> +    int ret = open(device, window, chroma);
>>>>        if (ret != VLC_SUCCESS)
>>>>        {
>>>>            device->sys = NULL;
>>>> @@ -128,7 +129,7 @@ static void decoder_device_Close(void *func,
>>>> va_list ap)
>>>>    }
>>>>    
>>>>    vlc_decoder_device *
>>>> -vlc_decoder_device_Create(vout_window_t *window)
>>>> +vlc_decoder_device_Create(vout_window_t *window, const video_format_t *fmt)
>>>>    {
>>>>        struct vlc_decoder_device_priv *priv =
>>>>                vlc_object_create(window, sizeof (*priv));
>>>> @@ -137,7 +138,7 @@ vlc_decoder_device_Create(vout_window_t *window)
>>>>        char *name = var_InheritString(window, "dec-dev");
>>>>        priv->module = vlc_module_load(&priv->device, "decoder device", name,
>>>>                                        true, decoder_device_Open, &priv->device,
>>>> -                                    window);
>>>> +                                    window, fmt->i_chroma);
>>>>        free(name);
>>>>        if (!priv->module)
>>>>        {
>>>> diff --git a/src/video_output/display.c b/src/video_output/display.c
>>>> index 2173bb084e..b0c5ee8ad1 100644
>>>> --- a/src/video_output/display.c
>>>> +++ b/src/video_output/display.c
>>>> @@ -777,7 +777,7 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
>>>>        vd->sys = NULL;
>>>>        vd->owner = *owner;
>>>>    
>>>> -    osys->video_context.device =
>>>> vlc_decoder_device_Create(osys->cfg.window);
>>>> +    osys->video_context.device =
>>>> vlc_decoder_device_Create(osys->cfg.window, source);
>>>>        vlc_video_context *video_context = osys->video_context.device ?
>>>>            &osys->video_context : NULL;
>>>>    
>>>> -- 
>>>> 2.17.1
>>>>
>>>> _______________________________________________
>>>> vlc-devel mailing list
>>>> To unsubscribe or modify your subscription options:
>>>> https://mailman.videolan.org/listinfo/vlc-devel
>>> _______________________________________________
>>> vlc-devel mailing list
>>> To unsubscribe or modify your subscription options:
>>> https://mailman.videolan.org/listinfo/vlc-devel
>>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> 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