[vlc-commits] [Git][videolan/vlc][master] 5 commits: opencv_wrapper: scope psz_inner_name locally
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Jan 17 10:20:48 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
849635ac by Johannes Kauffmann at 2024-01-17T10:02:56+00:00
opencv_wrapper: scope psz_inner_name locally
psz_inner_name was only used in Create(), thus move it out of
filter_sys_t struct. This also moves the free() closer to where the
variable is allocated.
- - - - -
cd3c1f62 by Johannes Kauffmann at 2024-01-17T10:02:56+00:00
libaribcaption: remove unneeded strlen() check
var_InheritString() guarantees that, if the string returned is not NULL,
the string does not contain a NULL terminator as first character.
Checking for strlen() > 0 does the same as checking if the string
contains a NULL terminator as first character, because strlen() doesn't
count the NULL terminator. Thus, remove the unneeded check.
- - - - -
0413a69b by Johannes Kauffmann at 2024-01-17T10:02:56+00:00
libaribcaption: use ARRAY_SIZE
- - - - -
afdfac2e by Johannes Kauffmann at 2024-01-17T10:02:56+00:00
libaribcaption: scope psz_cfg_font_name locally
It's used only once in Open(), so move it out of decoder_sys_t struct.
This also moves the free() closer to where the variable is allocated.
- - - - -
b2406ca9 by Johannes Kauffmann at 2024-01-17T10:02:56+00:00
libaribcaption: scope structure members locally
With the exception of b_cfg_fadeout, these members were only used in
Open(). Thus, move them out of decoder_sys_t struct.
- - - - -
2 changed files:
- modules/codec/arib/libaribcaption.c
- modules/video_filter/opencv_wrapper.c
Changes:
=====================================
modules/codec/arib/libaribcaption.c
=====================================
@@ -48,14 +48,7 @@ typedef struct
/* The following fields of decoder_sys_t are shared between decoder and spu units */
vlc_atomic_rc_t rc;
- int i_cfg_rendering_backend;
- char* psz_cfg_font_name;
- bool b_cfg_replace_drcs;
- bool b_cfg_force_stroke_text;
- bool b_cfg_ignore_background;
- bool b_cfg_ignore_ruby;
bool b_cfg_fadeout;
- float f_cfg_stroke_width;
aribcc_context_t *p_context;
aribcc_decoder_t *p_decoder;
@@ -89,7 +82,6 @@ static void DecSysRelease(decoder_sys_t *p_sys)
aribcc_decoder_free(p_sys->p_decoder);
if (p_sys->p_context)
aribcc_context_free(p_sys->p_context);
- free(p_sys->psz_cfg_font_name);
free(p_sys);
}
@@ -344,14 +336,7 @@ static int Open(vlc_object_t *p_this)
vlc_atomic_rc_init(&p_sys->rc);
- p_sys->i_cfg_rendering_backend = var_InheritInteger(p_this, ARIBCAPTION_CFG_PREFIX "rendering-backend");
- p_sys->psz_cfg_font_name = var_InheritString(p_this, ARIBCAPTION_CFG_PREFIX "font");
- p_sys->b_cfg_replace_drcs = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "replace-drcs");
- p_sys->b_cfg_force_stroke_text = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "force-stroke-text");
- p_sys->b_cfg_ignore_background = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "ignore-background");
- p_sys->b_cfg_ignore_ruby = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "ignore-ruby");
p_sys->b_cfg_fadeout = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "fadeout");
- p_sys->f_cfg_stroke_width = var_InheritFloat(p_this, ARIBCAPTION_CFG_PREFIX "stroke-width");
vlc_mutex_init(&p_sys->dec_lock);
p_sys->p_dec = p_dec;
@@ -400,25 +385,39 @@ static int Open(vlc_object_t *p_this)
return VLC_EGENERIC;
}
+ int i_cfg_rendering_backend =
+ var_InheritInteger(p_this, ARIBCAPTION_CFG_PREFIX "rendering-backend");
b_succ = aribcc_renderer_initialize(p_renderer,
ARIBCC_CAPTIONTYPE_CAPTION,
ARIBCC_FONTPROVIDER_TYPE_AUTO,
- (aribcc_textrenderer_type_t)p_sys->i_cfg_rendering_backend);
+ (aribcc_textrenderer_type_t)i_cfg_rendering_backend);
if (!b_succ) {
msg_Err(p_dec, "libaribcaption renderer initialization failed");
DecSysRelease(p_sys);
return VLC_EGENERIC;
}
+
aribcc_renderer_set_storage_policy(p_renderer, ARIBCC_CAPTION_STORAGE_POLICY_MINIMUM, 0);
- aribcc_renderer_set_replace_drcs(p_renderer, p_sys->b_cfg_replace_drcs);
- aribcc_renderer_set_force_stroke_text(p_renderer, p_sys->b_cfg_force_stroke_text);
- aribcc_renderer_set_force_no_background(p_renderer, p_sys->b_cfg_ignore_background);
- aribcc_renderer_set_force_no_ruby(p_renderer, p_sys->b_cfg_ignore_ruby);
- aribcc_renderer_set_stroke_width(p_renderer, p_sys->f_cfg_stroke_width);
-
- if (p_sys->psz_cfg_font_name && strlen(p_sys->psz_cfg_font_name) > 0) {
- const char* font_families[] = { p_sys->psz_cfg_font_name };
- aribcc_renderer_set_default_font_family(p_renderer, font_families, 1, true);
+
+ bool b_cfg_replace_drcs = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "replace-drcs");
+ bool b_cfg_force_stroke_text = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "force-stroke-text");
+ bool b_cfg_ignore_background = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "ignore-background");
+ bool b_cfg_ignore_ruby = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "ignore-ruby");
+ float f_cfg_stroke_width = var_InheritFloat(p_this, ARIBCAPTION_CFG_PREFIX "stroke-width");
+ aribcc_renderer_set_replace_drcs(p_renderer, b_cfg_replace_drcs);
+ aribcc_renderer_set_force_stroke_text(p_renderer, b_cfg_force_stroke_text);
+ aribcc_renderer_set_force_no_background(p_renderer, b_cfg_ignore_background);
+ aribcc_renderer_set_force_no_ruby(p_renderer, b_cfg_ignore_ruby);
+ aribcc_renderer_set_stroke_width(p_renderer, f_cfg_stroke_width);
+
+ char *psz_cfg_font_name = var_InheritString(p_this, ARIBCAPTION_CFG_PREFIX "font");
+ if (psz_cfg_font_name) {
+ const char* font_families[] = { psz_cfg_font_name };
+ aribcc_renderer_set_default_font_family(p_renderer,
+ font_families,
+ ARRAY_SIZE(font_families),
+ true);
+ free(psz_cfg_font_name);
}
p_dec->p_sys = p_sys;
=====================================
modules/video_filter/opencv_wrapper.c
=====================================
@@ -131,7 +131,6 @@ typedef struct
IplImage *p_cv_image[VOUT_MAX_PLANES];
filter_t *p_opencv;
- char* psz_inner_name;
picture_t hacked_pic;
} filter_sys_t;
@@ -166,18 +165,18 @@ static int Create( filter_t* p_filter )
return VLC_ENOMEM;
}
- p_sys->psz_inner_name = var_InheritString( p_filter, "opencv-filter-name" );
- if( p_sys->psz_inner_name )
+ char *psz_inner_name = var_InheritString( p_filter, "opencv-filter-name" );
+ if( psz_inner_name )
p_sys->p_opencv->p_module =
module_need( p_sys->p_opencv,
"opencv internal filter",
- p_sys->psz_inner_name,
+ psz_inner_name,
true );
if( !p_sys->p_opencv->p_module )
{
- msg_Err( p_filter, "can't open internal opencv filter: %s", p_sys->psz_inner_name );
- free( p_sys->psz_inner_name );
+ msg_Err( p_filter, "can't open internal opencv filter: %s", psz_inner_name );
+ free( psz_inner_name );
vlc_object_delete(p_sys->p_opencv);
free( p_sys );
@@ -239,7 +238,8 @@ static int Create( filter_t* p_filter )
p_sys->f_scale,
p_sys->i_internal_chroma,
p_sys->i_wrapper_output,
- p_sys->psz_inner_name);
+ psz_inner_name);
+ free( psz_inner_name );
#ifndef NDEBUG
msg_Dbg( p_filter, "opencv_wrapper successfully started" );
@@ -265,8 +265,6 @@ static void Destroy( filter_t* p_filter )
filter_sys_t *p_sys = p_filter->p_sys;
ReleaseImages( p_filter );
- free( p_sys->psz_inner_name );
-
// Release the internal OpenCV filter.
filter_Close( p_sys->p_opencv );
module_unneed( p_sys->p_opencv, p_sys->p_opencv->p_module );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8d5dfed586a14f27038570840cf82d0c14cb1af7...b2406ca91c882516324d1185ecf10ceed064b9e6
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8d5dfed586a14f27038570840cf82d0c14cb1af7...b2406ca91c882516324d1185ecf10ceed064b9e6
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