threads: allow thread count of zero
This moves setting the thread count to a minimum of 1 to frame_thread_init(), allowing a value of zero to propagate through to the codec if frame threading is not used. This makes auto-threads work in libx264. Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
		
							parent
							
								
									fb98507126
								
							
						
					
					
						commit
						ff1efc524c
					
				@ -683,6 +683,11 @@ static int frame_thread_init(AVCodecContext *avctx)
 | 
			
		||||
    FrameThreadContext *fctx;
 | 
			
		||||
    int i, err = 0;
 | 
			
		||||
 | 
			
		||||
    if (thread_count <= 1) {
 | 
			
		||||
        avctx->active_thread_type = 0;
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    avctx->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));
 | 
			
		||||
 | 
			
		||||
    fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
 | 
			
		||||
@ -882,8 +887,6 @@ int ff_thread_init(AVCodecContext *avctx, int thread_count)
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    avctx->thread_count = FFMAX(1, thread_count);
 | 
			
		||||
 | 
			
		||||
    if (avctx->codec) {
 | 
			
		||||
        validate_thread_parameters(avctx);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user