[vlc-commits] [Git][videolan/vlc][master] 2 commits: image: check decoder validity before clearing fmt_in
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Nov 20 14:01:45 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
a23ccf2c by Alaric Senat at 2022-11-20T13:47:12+00:00
image: check decoder validity before clearing fmt_in
The input format must then only be cleared when a decoder is present.
Decoder not being set is a perfectly valid scenario when only generating
an image.
This patch address a crash introduced by 08b24866dc443c30df8f9d5ee4f7e2045bf62956
- - - - -
bfa9a41c by Alaric Senat at 2022-11-20T13:47:12+00:00
transcode: uniformize decoder destruction
This make sure every call to `es_format_Clean` are made on a valid
decoder.
- - - - -
3 changed files:
- modules/stream_out/transcode/transcode.c
- modules/stream_out/transcode/transcode.h
- src/misc/image.c
Changes:
=====================================
modules/stream_out/transcode/transcode.c
=====================================
@@ -673,8 +673,7 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
return id;
error:
- es_format_Clean( &p_owner->fmt_in );
- decoder_Destroy( id->p_decoder );
+ dec_Delete( id->p_decoder );
DeleteSoutStreamID( id );
return NULL;
}
@@ -684,7 +683,6 @@ static void Del( sout_stream_t *p_stream, void *_id )
sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_stream_id_sys_t *id = (sout_stream_id_sys_t *)_id;
- struct decoder_owner *p_owner = id->p_decoder ? dec_get_owner(id->p_decoder) : NULL;
if( id->b_transcode )
{
int i_cat = id->p_decoder ? id->p_decoder->fmt_in->i_cat : UNKNOWN_ES;
@@ -692,8 +690,7 @@ static void Del( sout_stream_t *p_stream, void *_id )
{
case AUDIO_ES:
Send( p_stream, id, NULL );
- es_format_Clean( &p_owner->fmt_in );
- decoder_Destroy( id->p_decoder );
+ dec_Delete( id->p_decoder );
vlc_mutex_lock( &p_sys->lock );
if( id == p_sys->id_master_sync )
p_sys->id_master_sync = NULL;
@@ -705,8 +702,7 @@ static void Del( sout_stream_t *p_stream, void *_id )
* decoder/encoder might not even exist. */
if(!id->b_error)
Send( p_stream, id, NULL );
- es_format_Clean( &p_owner->fmt_in );
- decoder_Destroy( id->p_decoder );
+ dec_Delete( id->p_decoder );
vlc_mutex_lock( &p_sys->lock );
if( id == p_sys->id_video )
p_sys->id_video = NULL;
@@ -714,8 +710,7 @@ static void Del( sout_stream_t *p_stream, void *_id )
transcode_video_clean( id );
break;
case SPU_ES:
- es_format_Clean( &p_owner->fmt_in );
- decoder_Destroy( id->p_decoder );
+ dec_Delete( id->p_decoder );
transcode_spu_clean( p_stream, id );
break;
default:
@@ -724,11 +719,7 @@ static void Del( sout_stream_t *p_stream, void *_id )
transcode_track_pcr_helper_Delete( id->pcr_helper );
}
else
- {
- if (p_owner)
- es_format_Clean( &p_owner->fmt_in );
- decoder_Destroy( id->p_decoder );
- }
+ dec_Delete( id->p_decoder );
if( id->downstream_id ) sout_StreamIdDel( p_stream->p_next, id->downstream_id );
=====================================
modules/stream_out/transcode/transcode.h
=====================================
@@ -166,6 +166,16 @@ static inline struct decoder_owner *dec_get_owner( decoder_t *p_dec )
return container_of( p_dec, struct decoder_owner, dec );
}
+static inline void dec_Delete( decoder_t *p_dec )
+{
+ if( p_dec == NULL )
+ return;
+
+ struct decoder_owner *p_owner = dec_get_owner( p_dec );
+ es_format_Clean( &p_owner->fmt_in );
+ decoder_Destroy( p_dec );
+}
+
static inline void es_format_SetMeta( es_format_t *p_dst, const es_format_t *p_src )
{
p_dst->i_group = p_src->i_group;
=====================================
src/misc/image.c
=====================================
@@ -117,9 +117,12 @@ void image_HandlerDelete( image_handler_t *p_image )
{
if( !p_image ) return;
- struct decoder_owner *p_owner = dec_get_owner( p_image->p_dec );
- es_format_Clean( &p_owner->fmt_in );
- decoder_Destroy( p_image->p_dec );
+ if( p_image->p_dec != NULL )
+ {
+ struct decoder_owner *p_owner = dec_get_owner( p_image->p_dec );
+ es_format_Clean( &p_owner->fmt_in );
+ decoder_Destroy( p_image->p_dec );
+ }
if( p_image->p_enc )
vlc_encoder_Destroy( p_image->p_enc );
if( p_image->p_converter ) DeleteConverter( p_image->p_converter );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/61eff32a9b4bda4c8917f9570ad8850d1305b68d...bfa9a41cac92385ee139aec47592f6541b864c13
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/61eff32a9b4bda4c8917f9570ad8850d1305b68d...bfa9a41cac92385ee139aec47592f6541b864c13
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list