[vlc-devel] [PATCH 23/31] decoder: create a vlc_video_context in the decoder
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jul 5 16:20:02 CEST 2019
Create one by default if the decoder didn't create one by itself.
---
include/vlc_codec.h | 3 +++
src/input/decoder.c | 4 +---
src/input/decoder_helpers.c | 13 +++++++++++++
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 0f7bbf9684..9765e06585 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -111,6 +111,9 @@ struct decoder_t
/* Output format of decoder/packetizer */
es_format_t fmt_out;
+ /* Video context used by picture coming out of the decoder */
+ struct vlc_video_context *vctx_out;
+
/* Tell the decoder if it is allowed to drop frames */
bool b_frame_drop_allowed;
diff --git a/src/input/decoder.c b/src/input/decoder.c
index ee7e63fb47..a17888ed16 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -617,9 +617,7 @@ static int vout_update_format( decoder_t *p_dec )
.dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
.mouse_event = MouseEvent, .mouse_opaque = p_dec,
};
- vlc_video_context *vctx = vlc_video_context_Create( p_dec->init_device, NULL, NULL );
- int res = input_resource_GetDisplay( p_owner->p_resource, vctx, &cfg);
- vlc_video_context_Release(vctx);
+ int res = input_resource_GetDisplay( p_owner->p_resource, p_dec->vctx_out, &cfg);
vlc_mutex_lock( &p_owner->lock );
p_owner->fmt.video.i_chroma = p_dec->fmt_out.i_codec;
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index c37e9f50df..afc9f85a48 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -51,6 +51,12 @@ void decoder_Init( decoder_t *p_dec, const es_format_t *restrict p_fmt )
void decoder_Clean( decoder_t *p_dec )
{
+ if ( p_dec->vctx_out )
+ {
+ vlc_video_context_Release( p_dec->vctx_out );
+ p_dec->vctx_out = NULL;
+ }
+
if ( p_dec->p_module != NULL )
{
module_unneed(p_dec, p_dec->p_module);
@@ -95,6 +101,13 @@ int decoder_UpdateVideoOutput( decoder_t *dec )
dec->cbs->video.format_update == NULL) )
return -1;
+ if (dec->vctx_out == NULL)
+ {
+ // Create a default video context as the decoder didn't create one
+ dec->vctx_out = vlc_video_context_Create( dec->init_device, NULL, NULL);
+ if (unlikely(dec->vctx_out == NULL))
+ return -1;
+ }
return dec->cbs->video.format_update( dec );
}
--
2.17.1
More information about the vlc-devel
mailing list