summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-08-29 04:26:36 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-08-29 04:26:36 +0200
commit097a909ea126b165809b43227e74d99c14f783cc (patch)
tree6403f53819927c83cac3770247bdcc1a16be2bca /libavcodec
parent028b6d2b5cf6a6dc593921c4ceab60a747eccf71 (diff)
frame_thread_encoder: pass private options
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/frame_thread_encoder.c10
-rw-r--r--libavcodec/frame_thread_encoder.h2
-rw-r--r--libavcodec/utils.c2
3 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
index 40213cde2f..c584e0b36a 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -113,7 +113,7 @@ end:
return NULL;
}
-int ff_frame_thread_encoder_init(AVCodecContext *avctx){
+int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){
int i=0;
ThreadContext *c;
@@ -151,6 +151,7 @@ int ff_frame_thread_encoder_init(AVCodecContext *avctx){
pthread_cond_init(&c->finished_task_cond, NULL);
for(i=0; i<avctx->thread_count ; i++){
+ AVDictionary *tmp = NULL;
AVCodecContext *thread_avctx = avcodec_alloc_context3(avctx->codec);
if(!thread_avctx)
goto fail;
@@ -165,10 +166,13 @@ int ff_frame_thread_encoder_init(AVCodecContext *avctx){
thread_avctx->thread_count = 1;
thread_avctx->active_thread_type &= ~FF_THREAD_FRAME;
- //FIXME pass private options to encoder
- if(avcodec_open2(thread_avctx, avctx->codec, NULL) < 0) {
+ av_dict_copy(&tmp, options, 0);
+ av_dict_set(&tmp, "threads", "1", 0);
+ if(avcodec_open2(thread_avctx, avctx->codec, &tmp) < 0) {
+ av_dict_free(&tmp);
goto fail;
}
+ av_dict_free(&tmp);
av_assert0(!thread_avctx->internal->frame_thread_encoder);
thread_avctx->internal->frame_thread_encoder = c;
if(pthread_create(&c->worker[i], NULL, worker, thread_avctx)) {
diff --git a/libavcodec/frame_thread_encoder.h b/libavcodec/frame_thread_encoder.h
index 398c7f5fac..1da0ce1808 100644
--- a/libavcodec/frame_thread_encoder.h
+++ b/libavcodec/frame_thread_encoder.h
@@ -20,7 +20,7 @@
#include "avcodec.h"
-int ff_frame_thread_encoder_init(AVCodecContext *avctx);
+int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options);
void ff_frame_thread_encoder_free(AVCodecContext *avctx);
int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 150d90703a..b93be5f8fe 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -874,7 +874,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
entangled_thread_counter--; //we will instanciate a few encoders thus kick the counter to prevent false detection of a problem
- ret = ff_frame_thread_encoder_init(avctx);
+ ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL);
entangled_thread_counter++;
if (ret < 0)
goto free_and_end;