]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/utils.c
lavf: deprecate AVFormatContext.index_built
[ffmpeg] / libavcodec / utils.c
index eede431e326a557019d24d7cd1a4d96990e45e31..c4bba376bb7a637bbfc0cf1c1e503d9dcef15206 100644 (file)
@@ -551,6 +551,16 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
                avctx->codec->max_lowres);
         goto free_and_end;
     }
+    if (avctx->codec->sample_fmts && avctx->codec->encode) {
+        int i;
+        for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
+            if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
+                break;
+        if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
+            av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
+            goto free_and_end;
+        }
+    }
 
     if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
         ret = avctx->codec->init(avctx);
@@ -1287,7 +1297,9 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count)
 
 void avcodec_thread_free(AVCodecContext *s)
 {
-    return ff_thread_free(s);
+#if HAVE_THREADS
+    ff_thread_free(s);
+#endif
 }
 
 #endif