FFmepg 多线程解码历程 - 1:validate_thread_parameters

/**
 * Set the threading algorithms used.//设置线程的使用算法
 * Threading requires more than one thread.//需要一个以上的线程
 * Frame threading requires entire frames to be passed to the codec,//帧线程需要整个帧被传递到编码解码器
 * and introduces extra decoding delay, so is incompatible with low_delay.// 并引入了额外的解码延迟,所以是不符合low_delay
 * @param avctx The context.
 */

 //有效的线程参数

static void validate_thread_parameters(AVCodecContext *avctx)
{

    //实现帧线程支持,需要在配置codec的时候设置codec的capabilities,flags,flags2
    int frame_threading_supported = (avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS)
                                && !(avctx->flags & CODEC_FLAG_TRUNCATED)
                                && !(avctx->flags & CODEC_FLAG_LOW_DELAY)
                                && !(avctx->flags2 & CODEC_FLAG2_CHUNKS);
    if (avctx->thread_count == 1) {    //多线程要在双核以上的机器上才行
        avctx->active_thread_type = 0;
    } else if (frame_threading_supported && (avctx->thread_type & FF_THREAD_FRAME)) {//  在codec初始化的时候设置avctx->thread_type |=FF_THREAD_FRAME
        avctx->active_thread_type = FF_THREAD_FRAME;   //线程的类型设置为帧并行
    } else if (avctx->codec->capabilities & CODEC_CAP_SLICE_THREADS &&
               avctx->thread_type & FF_THREAD_SLICE) {  //同样的要实现片级并行则需要在codec初始化的时候设置条件
        avctx->active_thread_type = FF_THREAD_SLICE;
    } else if (!(avctx->codec->capabilities & CODEC_CAP_AUTO_THREADS)) {
        avctx->thread_count       = 1;
        avctx->active_thread_type = 0;
    }

    if (avctx->thread_count > MAX_AUTO_THREADS)
        av_log(avctx, AV_LOG_WARNING,
               "Application has requested %d threads. Using a thread count greater than %d is not recommended.\n",
               avctx->thread_count, MAX_AUTO_THREADS);
}

注释:

如果不知到帧与片 可以查看之前的转载文章  http://blog.csdn.net/jwzhangjie/article/details/8739139 


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值