| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (c) 2004 Roman Shaposhnik | 2  * Copyright (c) 2004 Roman Shaposhnik | 
| 3  * Copyright (c) 2008 Alexander Strange (astrange@ithinksw.com) | 3  * Copyright (c) 2008 Alexander Strange (astrange@ithinksw.com) | 
| 4  * | 4  * | 
| 5  * Many thanks to Steven M. Schultz for providing clever ideas and | 5  * Many thanks to Steven M. Schultz for providing clever ideas and | 
| 6  * to Michael Niedermayer <michaelni@gmx.at> for writing initial | 6  * to Michael Niedermayer <michaelni@gmx.at> for writing initial | 
| 7  * implementation. | 7  * implementation. | 
| 8  * | 8  * | 
| 9  * This file is part of FFmpeg. | 9  * This file is part of FFmpeg. | 
| 10  * | 10  * | 
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 771         avctx->active_thread_type = FF_THREAD_SLICE; | 771         avctx->active_thread_type = FF_THREAD_SLICE; | 
| 772 } | 772 } | 
| 773 | 773 | 
| 774 int avcodec_thread_init(AVCodecContext *avctx, int thread_count) | 774 int avcodec_thread_init(AVCodecContext *avctx, int thread_count) | 
| 775 { | 775 { | 
| 776     if (avctx->thread_opaque) { | 776     if (avctx->thread_opaque) { | 
| 777         av_log(avctx, AV_LOG_ERROR, "avcodec_thread_init called after avcodec_op
     en, this does nothing in ffmpeg-mt\n"); | 777         av_log(avctx, AV_LOG_ERROR, "avcodec_thread_init called after avcodec_op
     en, this does nothing in ffmpeg-mt\n"); | 
| 778         return -1; | 778         return -1; | 
| 779     } | 779     } | 
| 780 | 780 | 
| 781     avctx->thread_count = thread_count; | 781     avctx->thread_count = FFMAX(1, thread_count); | 
| 782 | 782 | 
| 783     if (avctx->codec) { | 783     if (avctx->codec) { | 
| 784         validate_thread_parameters(avctx); | 784         validate_thread_parameters(avctx); | 
| 785 | 785 | 
| 786         if (avctx->active_thread_type&FF_THREAD_SLICE) | 786         if (avctx->active_thread_type&FF_THREAD_SLICE) | 
| 787             return thread_init(avctx); | 787             return thread_init(avctx); | 
| 788         else if (avctx->active_thread_type&FF_THREAD_FRAME) | 788         else if (avctx->active_thread_type&FF_THREAD_FRAME) | 
| 789             return frame_thread_init(avctx); | 789             return frame_thread_init(avctx); | 
| 790     } | 790     } | 
| 791 | 791 | 
| 792     return 0; | 792     return 0; | 
| 793 } | 793 } | 
| 794 | 794 | 
| 795 void avcodec_thread_free(AVCodecContext *avctx) | 795 void avcodec_thread_free(AVCodecContext *avctx) | 
| 796 { | 796 { | 
| 797     if (avctx->active_thread_type&FF_THREAD_FRAME) | 797     if (avctx->active_thread_type&FF_THREAD_FRAME) | 
| 798         frame_thread_free(avctx, avctx->thread_count); | 798         frame_thread_free(avctx, avctx->thread_count); | 
| 799     else | 799     else | 
| 800         thread_free(avctx); | 800         thread_free(avctx); | 
| 801 } | 801 } | 
| OLD | NEW | 
|---|