diff options
author | Janne Grunau <janne-libav@jannau.net> | 2012-01-01 23:24:24 +0400 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2012-01-02 22:20:23 +0400 |
commit | 881a5e047dc78ec9ab771817497dffec503d77ee (patch) | |
tree | 0857c45d86537a7efe7c54dcbbe6b2d956b32861 /libavcodec/h264.c | |
parent | 264808219d8be93aeda0b6ade8c64898b673f6bc (diff) |
mpegenc: use avctx->slices as number of slices
Adds a new member to MpegEncContext to hold the number of used slice
contexts. Fixes segfaults with '-threads 17 -thread_type slice' and
fate-vsynth{1,2}-mpeg{2,4}thread{,_ilace} with --disable-pthreads.
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 2bde0fec2a..316a57d75e 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1280,7 +1280,6 @@ int ff_h264_frame_start(H264Context *h){ MpegEncContext * const s = &h->s; int i; const int pixel_shift = h->pixel_shift; - int thread_count = (s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1; if(MPV_frame_start(s, s->avctx) < 0) return -1; @@ -1309,7 +1308,7 @@ int ff_h264_frame_start(H264Context *h){ /* can't be in alloc_tables because linesize isn't known there. * FIXME: redo bipred weight to not require extra buffer? */ - for(i = 0; i < thread_count; i++) + for(i = 0; i < s->slice_context_count; i++) if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad) h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*6*s->linesize); @@ -2826,7 +2825,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ return -1; } } else { - for(i = 1; i < s->avctx->thread_count; i++) { + for(i = 1; i < s->slice_context_count; i++) { H264Context *c; c = h->thread_context[i] = av_malloc(sizeof(H264Context)); memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext)); @@ -2839,7 +2838,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ clone_tables(c, h, i); } - for(i = 0; i < s->avctx->thread_count; i++) + for(i = 0; i < s->slice_context_count; i++) if (context_init(h->thread_context[i]) < 0) { av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n"); return -1; @@ -3742,7 +3741,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ int nals_needed=0; ///< number of NALs that need decoding before the next frame thread starts int nal_index; - h->max_contexts = (HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_SLICE)) ? avctx->thread_count : 1; + h->max_contexts = s->slice_context_count; if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){ h->current_slice = 0; if (!s->first_field) |