summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Osipov <simba@lerlan.ru>2011-08-28 14:14:07 +0200
committerMartin Lambers <marlam@marlam.de>2011-08-28 14:14:07 +0200
commit3411dab55e1a0dc2d6867e028877ce23812991a5 (patch)
treec847ba4ac78ad3c9a49a65d6f15d53453a134ef7
parent768d2e5910b70d930959143141d81f51e0337bdb (diff)
downloadbino-3411dab55e1a0dc2d6867e028877ce23812991a5.tar.gz
Fix multithreaded video decoding with FFmpeg.
This fixes the initialization of multithreaded video decoding for FFmpeg >= 0.7. See <http://lists.gnu.org/archive/html/bino-list/2011-08/msg00019.html>.
-rw-r--r--src/media_object.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/media_object.cpp b/src/media_object.cpp
index 8e52f26..428cd3d 100644
--- a/src/media_object.cpp
+++ b/src/media_object.cpp
@@ -779,6 +779,13 @@ void media_object::open(const std::string &url, const device_request &dev_reques
_ffmpeg->format_ctx->streams[i]->discard = AVDISCARD_ALL; // ignore by default; user must activate streams
AVCodecContext *codec_ctx = _ffmpeg->format_ctx->streams[i]->codec;
AVCodec *codec = NULL;
+ if (_ffmpeg->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ {
+ // Activate multithreaded decoding. This must be done before opening the codec; see
+ // http://lists.gnu.org/archive/html/bino-list/2011-08/msg00019.html
+ codec_ctx->thread_count = video_decoding_threads();
+ }
+ // Find and open the codec. CODEC_ID_TEXT is a special case: it has no decoder since it is unencoded raw data.
if (_ffmpeg->format_ctx->streams[i]->codec->codec_id != CODEC_ID_TEXT
&& (!(codec = avcodec_find_decoder(_ffmpeg->format_ctx->streams[i]->codec->codec_id))
|| (e = avcodec_open(codec_ctx, codec)) < 0))
@@ -802,7 +809,6 @@ void media_object::open(const std::string &url, const device_request &dev_reques
_url.c_str(), j + 1));
}
_ffmpeg->video_codecs.push_back(codec);
- _ffmpeg->video_codec_ctxs[j]->thread_count = video_decoding_threads();
// Determine frame template.
_ffmpeg->video_frame_templates.push_back(video_frame());
set_video_frame_template(j);