| 77 | static void thread_func( void * ); |
| 78 | |
| 79 | int hb_avcodec_open(AVCodecContext *avctx, const AVCodec *codec, |
| 80 | AVDictionary **av_opts, int thread_count) |
| 81 | { |
| 82 | int ret; |
| 83 | |
| 84 | if ((thread_count == HB_FFMPEG_THREADS_AUTO || thread_count > 0) && |
| 85 | (codec->type == AVMEDIA_TYPE_VIDEO)) |
| 86 | { |
| 87 | #if defined (__aarch64__) && defined(_WIN32) |
| 88 | avctx->thread_count = (thread_count == HB_FFMPEG_THREADS_AUTO) ? |
| 89 | hb_get_cpu_count() + 1 : thread_count; |
| 90 | #else |
| 91 | avctx->thread_count = (thread_count == HB_FFMPEG_THREADS_AUTO) ? |
| 92 | hb_get_cpu_count() / 2 + 1 : thread_count; |
| 93 | #endif |
| 94 | avctx->thread_type = FF_THREAD_FRAME|FF_THREAD_SLICE; |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | avctx->thread_count = 1; |
| 99 | } |
| 100 | |
| 101 | if (codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) |
| 102 | { |
| 103 | // "experimental" encoders will not open without this |
| 104 | avctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; |
| 105 | } |
| 106 | |
| 107 | ret = avcodec_open2(avctx, codec, av_opts); |
| 108 | return ret; |
| 109 | } |
| 110 | |
| 111 | void hb_avcodec_free_context(AVCodecContext **avctx) |
| 112 | { |
no test coverage detected