[vlc-devel] [PATCH 01/18] libvlc: pass the HDR10 metadata to the OpenGL makeCurrent callback

Steve Lhomme robux4 at ycbcr.xyz
Wed Feb 5 13:16:58 CET 2020


On 2020-02-04 19:50, Rémi Denis-Courmont wrote:
> Le tiistaina 4. helmikuuta 2020, 17.25.56 EET Steve Lhomme a écrit :
>> Just like with D3D11, it should theoretically be possible to send the HDR10
>> metadata of the frame we're about to display over HDMI.
>>
>> We should get this information as early as possible to prepare the tone
>> mapping we will use for rendering.
>> ---
>>   doc/libvlc/QtGL/qtvlcwidget.cpp   |  2 +-
>>   doc/libvlc/sdl_opengl_player.cpp  |  2 +-
>>   include/vlc/libvlc_media_player.h | 33 ++++++++++++++++---------------
>>   modules/video_output/vgl.c        |  4 ++--
>>   4 files changed, 21 insertions(+), 20 deletions(-)
>>
>> diff --git a/doc/libvlc/QtGL/qtvlcwidget.cpp
>> b/doc/libvlc/QtGL/qtvlcwidget.cpp index a9abeccc167..7c1eee7a43b 100644
>> --- a/doc/libvlc/QtGL/qtvlcwidget.cpp
>> +++ b/doc/libvlc/QtGL/qtvlcwidget.cpp
>> @@ -93,7 +93,7 @@ public:
>>       }
>>
>>       // This callback is called to set the OpenGL context
>> -    static bool make_current(void* data, bool current)
>> +    static bool make_current(void* data, bool current, const
>> libvlc_video_frame_hdr10_metadata_t *hdr10) {
>>           VLCVideo* that = static_cast<VLCVideo*>(data);
>>           if (current)
>> diff --git a/doc/libvlc/sdl_opengl_player.cpp
>> b/doc/libvlc/sdl_opengl_player.cpp index d34b99b2682..903f0fefb3c 100644
>> --- a/doc/libvlc/sdl_opengl_player.cpp
>> +++ b/doc/libvlc/sdl_opengl_player.cpp
>> @@ -182,7 +182,7 @@ public:
>>       }
>>
>>       // This callback is called to set the OpenGL context
>> -    static bool make_current(void* data, bool current)
>> +    static bool make_current(void* data, bool current, const
>> libvlc_video_frame_hdr10_metadata_t *hdr10) {
>>           VLCVideo* that = static_cast<VLCVideo*>(data);
>>           if (current)
>> diff --git a/include/vlc/libvlc_media_player.h
>> b/include/vlc/libvlc_media_player.h index 7c72c9774b2..02ca8b5fd54 100644
>> --- a/include/vlc/libvlc_media_player.h
>> +++ b/include/vlc/libvlc_media_player.h
>> @@ -540,15 +540,29 @@ typedef void (*libvlc_video_update_output_cb)(void*
>> opaque, unsigned width, unsi */
>>   typedef void (*libvlc_video_swap_cb)(void* opaque);
>>
>> +typedef struct
>> +{
>> +    /* similar to SMPTE ST 2086 mastering display color volume */
>> +    uint16_t RedPrimary[2];
>> +    uint16_t GreenPrimary[2];
>> +    uint16_t BluePrimary[2];
>> +    uint16_t WhitePoint[2];
>> +    unsigned int MaxMasteringLuminance;
>> +    unsigned int MinMasteringLuminance;
>> +    uint16_t MaxContentLightLevel;
>> +    uint16_t MaxFrameAverageLightLevel;
>> +} libvlc_video_frame_hdr10_metadata_t;
>> +
>>   /**
>>    * Callback prototype to set up the OpenGL context for rendering
>>    *
>>    * \param opaque private pointer passed to the @a
>> libvlc_video_set_output_callbacks() [IN] * \param enter true to set the
>> context as current, false to unset it [IN] + * \param hdr10
>> libvlc_video_frame_hdr10_metadata_t* or NULL [IN] * \return true on success
>>    * \version LibVLC 4.0.0 or later
>>    */
>> -typedef bool (*libvlc_video_makeCurrent_cb)(void* opaque, bool enter);
>> +typedef bool (*libvlc_video_makeCurrent_cb)(void* opaque, bool enter, const
>> libvlc_video_frame_hdr10_metadata_t *hdr10);
> 
> That seems way too specific to current generation / too inextensible, to fit in
> the generic make_current callback...

I can add an extra callback to be called when the rendering is about to 
start. It will only be called by the D3D11 output for now. And those who 
don't want to receive the data can also not set the callback.

As for extensibility, I suppose passing the structure with an ID of the 
type+version of the structure could help. Either passing all structures 
in a table of {type, structure*} or passing then one by one. I prefer 
the latter.

>>
>>   /**
>>    * Callback prototype to load opengl functions
>> @@ -712,24 +726,11 @@ typedef bool( *libvlc_video_direct3d_update_output_cb
>> )( void *opaque, const libvlc_video_direct3d_cfg_t *cfg,
>> libvlc_video_output_cfg_t *output );
>>
>> -typedef struct
>> -{
>> -    /* similar to SMPTE ST 2086 mastering display color volume */
>> -    uint16_t RedPrimary[2];
>> -    uint16_t GreenPrimary[2];
>> -    uint16_t BluePrimary[2];
>> -    uint16_t WhitePoint[2];
>> -    unsigned int MaxMasteringLuminance;
>> -    unsigned int MinMasteringLuminance;
>> -    uint16_t MaxContentLightLevel;
>> -    uint16_t MaxFrameAverageLightLevel;
>> -} libvlc_video_direct3d_hdr10_metadata_t;
>> -
>>   /** Tell the host the rendering is about to start/has finished.
>>    *
>>    * \param opaque private pointer set on the opaque parameter of @a
>> libvlc_video_direct3d_device_setup_cb() [IN] * \param enter true if the
>> rendering is about to start, false if it's finished - * \param hdr10
>> libvlc_video_direct3d_hdr10_metadata_t* or NULL [IN] + * \param hdr10
>> libvlc_video_frame_hdr10_metadata_t* or NULL [IN] * \return true on success
>>    * \version LibVLC 4.0.0 or later
>>    *
>> @@ -748,7 +749,7 @@ typedef struct
>>    * - RSSetViewports()
>>    * - DrawIndexed()
>>    */
>> -typedef bool( *libvlc_video_direct3d_start_end_rendering_cb )( void
>> *opaque, bool enter, const libvlc_video_direct3d_hdr10_metadata_t *hdr10 );
>> +typedef bool( *libvlc_video_direct3d_start_end_rendering_cb )( void
>> *opaque, bool enter, const libvlc_video_frame_hdr10_metadata_t *hdr10 );
>>
>>   /** Tell the host the rendering for the given plane is about to start
>>    *
>> diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
>> index d880f1a5ff5..9f550e53c13 100644
>> --- a/modules/video_output/vgl.c
>> +++ b/modules/video_output/vgl.c
>> @@ -58,14 +58,14 @@ static void *OurGetProcAddress(vlc_gl_t *gl, const char
>> *name) static int MakeCurrent(vlc_gl_t *gl)
>>   {
>>       vout_display_sys_t *sys = gl->sys;
>> -    bool success = sys->makeCurrentCb(sys->opaque, true);
>> +    bool success = sys->makeCurrentCb(sys->opaque, true, NULL);
>>       return success ? VLC_SUCCESS : VLC_EGENERIC;
>>   }
>>
>>   static void ReleaseCurrent(vlc_gl_t *gl)
>>   {
>>       vout_display_sys_t *sys = gl->sys;
>> -    sys->makeCurrentCb(sys->opaque, false);
>> +    sys->makeCurrentCb(sys->opaque, false, NULL);
>>   }
>>
>>   static void VglSwapBuffers(vlc_gl_t *gl)
> 
> 
> -- 
> Реми Дёни-Курмон
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> 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