diff options
Diffstat (limited to 'src/internal/kitdecoder.c')
-rw-r--r-- | src/internal/kitdecoder.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/internal/kitdecoder.c b/src/internal/kitdecoder.c index e2d0a25..112be8e 100644 --- a/src/internal/kitdecoder.c +++ b/src/internal/kitdecoder.c @@ -47,11 +47,17 @@ Kit_Decoder* Kit_CreateDecoder(const Kit_Source *src, int stream_index, // Allocate a context for the codec
codec_ctx = avcodec_alloc_context3(codec);
- if(avcodec_copy_context(codec_ctx, format_ctx->streams[stream_index]->codec) != 0) {
- Kit_SetError("Unable to copy audio codec context for stream %d", stream_index);
+ if(codec_ctx == NULL) {
+ Kit_SetError("Unable to allocate codec context for stream %d", stream_index);
goto exit_1;
}
+ // Copy context from stream to target codec context
+ if(avcodec_copy_context(codec_ctx, format_ctx->streams[stream_index]->codec) != 0) {
+ Kit_SetError("Unable to copy codec context for stream %d", stream_index);
+ goto exit_2;
+ }
+
// Set thread count
codec_ctx->thread_count = thread_count;
codec_ctx->thread_type = FF_THREAD_SLICE;
|