vlc | branch: master | Steve Lhomme <[email protected]> | Fri Sep 20 16:46:14 2019 +0200| [8e31e10cd3bff39e78fa948dbf4b13cc88acdead] | committer: Steve Lhomme
video context: allow storing typed extra data in the video context Each video context can store extra objects, like the IDirect3DDevice9* for D3D9, which is not found in the decoder device. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8e31e10cd3bff39e78fa948dbf4b13cc88acdead --- include/vlc_picture.h | 18 +++++++++++++++++- src/input/decoder_helpers.c | 16 +++++++++++++--- src/libvlccore.sym | 1 + src/video_output/display.c | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/vlc_picture.h b/include/vlc_picture.h index 9238e09895..9ca42b9b6e 100644 --- a/include/vlc_picture.h +++ b/include/vlc_picture.h @@ -87,12 +87,28 @@ struct vlc_video_context_operations void (*destroy)(void *priv); }; +/** Decoder device type */ +enum vlc_video_context_type +{ + VLC_VIDEO_CONTEXT_NONE, + VLC_VIDEO_CONTEXT_VAAPI, + VLC_VIDEO_CONTEXT_VDPAU, + VLC_VIDEO_CONTEXT_DXVA2, + VLC_VIDEO_CONTEXT_D3D11VA, + VLC_VIDEO_CONTEXT_AWINDOW, + VLC_VIDEO_CONTEXT_NVDEC, + VLC_VIDEO_CONTEXT_CVPX, + VLC_VIDEO_CONTEXT_MMAL, +}; + VLC_API vlc_video_context * vlc_video_context_Create(vlc_decoder_device *, + enum vlc_video_context_type private_type, size_t private_size, const struct vlc_video_context_operations *); VLC_API void vlc_video_context_Release(vlc_video_context *); -VLC_API void *vlc_video_context_GetPrivate(vlc_video_context *); +VLC_API enum vlc_video_context_type vlc_video_context_GetType(const vlc_video_context *); +VLC_API void *vlc_video_context_GetPrivate(vlc_video_context *, enum vlc_video_context_type); VLC_API vlc_video_context *vlc_video_context_Hold(vlc_video_context *); /** diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c index 612e9d0a8a..ed13fc9878 100644 --- a/src/input/decoder_helpers.c +++ b/src/input/decoder_helpers.c @@ -188,11 +188,13 @@ struct vlc_video_context vlc_atomic_rc_t rc; vlc_decoder_device *device; const struct vlc_video_context_operations *ops; + enum vlc_video_context_type private_type; size_t private_size; uint8_t private[]; }; vlc_video_context * vlc_video_context_Create(vlc_decoder_device *device, + enum vlc_video_context_type private_type, size_t private_size, const struct vlc_video_context_operations *ops) { @@ -200,6 +202,7 @@ vlc_video_context * vlc_video_context_Create(vlc_decoder_device *device, if (unlikely(vctx == NULL)) return NULL; vlc_atomic_rc_init( &vctx->rc ); + vctx->private_type = private_type; vctx->private_size = private_size; vctx->device = device; if (vctx->device) @@ -208,9 +211,16 @@ vlc_video_context * vlc_video_context_Create(vlc_decoder_device *device, return vctx; } -void *vlc_video_context_GetPrivate(vlc_video_context *vctx) +void *vlc_video_context_GetPrivate(vlc_video_context *vctx, enum vlc_video_context_type type) { - return &vctx->private; + if (vctx && vctx->private_type == type) + return &vctx->private; + return NULL; +} + +enum vlc_video_context_type vlc_video_context_GetType(const vlc_video_context *vctx) +{ + return vctx->private_type; } vlc_video_context *vlc_video_context_Hold(vlc_video_context *vctx) @@ -226,7 +236,7 @@ void vlc_video_context_Release(vlc_video_context *vctx) if (vctx->device) vlc_decoder_device_Release( vctx->device ); if ( vctx->ops && vctx->ops->destroy ) - vctx->ops->destroy( vlc_video_context_GetPrivate(vctx) ); + vctx->ops->destroy( vlc_video_context_GetPrivate(vctx, vctx->private_type) ); free(vctx); } } diff --git a/src/libvlccore.sym b/src/libvlccore.sym index 8ff8a2fb89..d1a048be98 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -947,6 +947,7 @@ vlc_media_tree_Preparse vlc_viewpoint_to_4x4 vlc_video_context_Create vlc_video_context_Release +vlc_video_context_GetType vlc_video_context_GetPrivate vlc_video_context_Hold vlc_video_context_HoldDevice diff --git a/src/video_output/display.c b/src/video_output/display.c index 56245be3b0..f9fb3d0e7c 100644 --- a/src/video_output/display.c +++ b/src/video_output/display.c @@ -770,7 +770,7 @@ vout_display_t *vout_display_New(vlc_object_t *parent, if (owner) vd->owner = *owner; - vlc_video_context *fake_vctx = vlc_video_context_Create(dec_device, 0, NULL); + vlc_video_context *fake_vctx = vlc_video_context_Create(dec_device, VLC_VIDEO_CONTEXT_NONE, 0, NULL); if (vlc_module_load(vd, "vout display", module, module && *module != '\0', vout_display_start, vd, &osys->cfg, &vd->fmt, _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
