Commit 4919758a authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

ffmpeg: only free the options if there were any

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent c4f14979
......@@ -158,7 +158,7 @@ int OpenAvio(vlc_object_t *object)
};
AVDictionary *options = NULL;
char *psz_opts = var_InheritString(access, "avio-options");
if (psz_opts && *psz_opts) {
if (psz_opts) {
options = vlc_av_get_options(psz_opts);
free(psz_opts);
}
......@@ -238,7 +238,7 @@ int OutOpenAvio(vlc_object_t *object)
#else
AVDictionary *options = NULL;
char *psz_opts = var_InheritString(access, "sout-avio-options");
if (psz_opts && *psz_opts) {
if (psz_opts) {
options = vlc_av_get_options(psz_opts);
free(psz_opts);
}
......
......@@ -357,9 +357,10 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
AVDictionary *options = NULL;
int ret;
if (psz_opts && *psz_opts)
if (psz_opts) {
options = vlc_av_get_options(psz_opts);
free(psz_opts);
free(psz_opts);
}
vlc_avcodec_lock();
ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, options ? &options : NULL );
......
......@@ -892,9 +892,10 @@ int OpenEncoder( vlc_object_t *p_this )
int ret;
char *psz_opts = var_InheritString(p_enc, ENC_CFG_PREFIX "options");
AVDictionary *options = NULL;
if (psz_opts && *psz_opts)
if (psz_opts) {
options = vlc_av_get_options(psz_opts);
free(psz_opts);
free(psz_opts);
}
vlc_avcodec_lock();
ret = avcodec_open2( p_context, p_codec, options ? &options : NULL );
......
......@@ -89,9 +89,10 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
int ret;
char *psz_opts = var_InheritString(dec, "avcodec-options");
AVDictionary *options = NULL;
if (psz_opts && *psz_opts)
if (psz_opts) {
options = vlc_av_get_options(psz_opts);
free(psz_opts);
free(psz_opts);
}
vlc_avcodec_lock();
ret = avcodec_open2(context, codec, options ? &options : NULL);
......
......@@ -336,13 +336,13 @@ int OpenDemux( vlc_object_t *p_this )
unsigned int nb_streams = p_sys->ic->nb_streams;
for (unsigned i = 1; i < nb_streams; i++)
options[i] = NULL;
if (psz_opts && *psz_opts) {
if (psz_opts) {
options[0] = vlc_av_get_options(psz_opts);
for (unsigned i = 1; i < nb_streams; i++) {
av_dict_copy(&options[i], options[0], 0);
}
free(psz_opts);
}
free(psz_opts);
vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */
error = avformat_find_stream_info( p_sys->ic, options );
/* FIXME: what if nb_streams change after that call? */
......
......@@ -378,9 +378,10 @@ static int Mux( sout_mux_t *p_mux )
char *psz_opts = var_GetNonEmptyString( p_mux, "sout-avformat-options" );
AVDictionary *options = NULL;
if (psz_opts && *psz_opts)
if (psz_opts) {
options = vlc_av_get_options(psz_opts);
free(psz_opts);
free(psz_opts);
}
error = avformat_write_header( p_sys->oc, options ? &options : NULL);
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX))) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment