]> git.sesse.net Git - vlc/blobdiff - modules/codec/avcodec/avcodec.c
avcodec: adjust MT contention scope
[vlc] / modules / codec / avcodec / avcodec.c
index b126d7acb68f352d38e087704dd154f5b37da4ee..04ade540e98b99b708bdd180c17cecabe0acc8cf 100644 (file)
@@ -144,6 +144,7 @@ vlc_module_begin ()
     add_obsolete_integer( "ffmpeg-threads" ) /* removed since 2.1.0 */
     add_integer( "avcodec-threads", 0, THREADS_TEXT, THREADS_LONGTEXT, true );
 #endif
+    add_string( "avcodec-options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true )
 
 
 #ifdef ENABLE_SOUT
@@ -239,6 +240,8 @@ vlc_module_begin ()
     /* Audio AAC encoder profile */
     add_string( ENC_CFG_PREFIX "aac-profile", "low",
                 ENC_PROFILE_TEXT, ENC_PROFILE_LONGTEXT, true )
+
+    add_string( ENC_CFG_PREFIX "options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true )
 #endif /* ENABLE_SOUT */
 
 #ifdef MERGE_FFMPEG
@@ -355,9 +358,6 @@ static void CloseDecoder( vlc_object_t *p_this )
     case VIDEO_ES:
          EndVideoDec ( p_dec );
         break;
-    case SPU_ES:
-         EndSubtitleDec( p_dec );
-        break;
     }
 
     if( p_sys->p_context )
@@ -419,9 +419,22 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
                                                       p_sys->p_context->sample_rate;
     }
     int ret;
+    char *psz_opts = var_InheritString( p_dec, "avcodec-options" );
+    AVDictionary *options = NULL;
+    if (psz_opts && *psz_opts)
+        options = vlc_av_get_options(psz_opts);
+    free(psz_opts);
+
     vlc_avcodec_lock();
-    ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, NULL /* options */ );
+    ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, options ? &options : NULL );
     vlc_avcodec_unlock();
+
+    AVDictionaryEntry *t = NULL;
+    while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX))) {
+        msg_Err( p_dec, "Unknown option \"%s\"", t->key );
+    }
+    av_dict_free(&options);
+
     if( ret < 0 )
         return VLC_EGENERIC;
     msg_Dbg( p_dec, "avcodec codec (%s) started", p_sys->psz_namecodec );