X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Favformat%2Fconsumer_avformat.c;h=60d62ff9f24f6d630af89735a0ebcbf1942f0653;hb=52ba2d01d33ce1b489f06444560524e5fae250b6;hp=5a1ab27201c5faf0709a8cdee2eae8f2e7f9f9ca;hpb=8b541300771625c174ade1b1113c19f863633ef6;p=melted diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c index 5a1ab27..60d62ff 100644 --- a/src/modules/avformat/consumer_avformat.c +++ b/src/modules/avformat/consumer_avformat.c @@ -326,6 +326,10 @@ static AVStream *add_audio_stream( mlt_consumer this, AVFormatContext *oc, int c if ( st != NULL ) { AVCodecContext *c = st->codec; + int thread_count = mlt_properties_get_int( properties, "threads" ); + if ( thread_count == 0 && getenv( "MLT_AVFORMAT_THREADS" ) ) + thread_count = atoi( getenv( "MLT_AVFORMAT_THREADS" ) ); + c->codec_id = codec_id; c->codec_type = CODEC_TYPE_AUDIO; @@ -347,6 +351,11 @@ static AVStream *add_audio_stream( mlt_consumer this, AVFormatContext *oc, int c tag = arg[ 0 ] + ( arg[ 1 ] << 8 ) + ( arg[ 2 ] << 16 ) + ( arg[ 3 ] << 24 ); c->codec_tag = tag; } + if ( thread_count > 1 ) + { + avcodec_thread_init( c, thread_count ); + c->thread_count = thread_count; + } } else { @@ -427,6 +436,10 @@ static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int c char *pix_fmt = mlt_properties_get( properties, "pix_fmt" ); double ar = mlt_properties_get_double( properties, "display_ratio" ); AVCodecContext *c = st->codec; + int thread_count = mlt_properties_get_int( properties, "threads" ); + if ( thread_count == 0 && getenv( "MLT_AVFORMAT_THREADS" ) ) + thread_count = atoi( getenv( "MLT_AVFORMAT_THREADS" ) ); + c->codec_id = codec_id; c->codec_type = CODEC_TYPE_VIDEO; @@ -526,7 +539,12 @@ static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int c if ( mlt_properties_get_int( properties, "ilme" ) ) c->flags |= CODEC_FLAG_INTERLACED_ME; } - } + if ( thread_count > 1 ) + { + avcodec_thread_init( c, thread_count ); + c->thread_count = thread_count; + } + } else { fprintf( stderr, "Could not allocate a stream for video\n" );