| 85 | } |
| 86 | |
| 87 | static av_cold int vpx_init(AVCodecContext *avctx, |
| 88 | struct vpx_codec_ctx* decoder) |
| 89 | { |
| 90 | VPxContext *ctx = avctx->priv_data; |
| 91 | struct vpx_codec_dec_cfg deccfg = { |
| 92 | .threads = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), MAX_VPX_THREADS) |
| 93 | }; |
| 94 | |
| 95 | av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str()); |
| 96 | av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config()); |
| 97 | |
| 98 | if (vpx_codec_dec_init(decoder, ctx->iface, &deccfg, 0) != VPX_CODEC_OK) { |
| 99 | const char *error = vpx_codec_error(decoder); |
| 100 | av_log(avctx, AV_LOG_ERROR, "Failed to initialize decoder: %s\n", |
| 101 | error); |
| 102 | return AVERROR(EINVAL); |
| 103 | } |
| 104 | |
| 105 | if (vpx_codec_get_caps(ctx->iface) & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER) { |
| 106 | if (vpx_codec_set_frame_buffer_functions(decoder, get_frame_buffer, release_frame_buffer, avctx->priv_data)) { |
| 107 | vpx_codec_destroy(decoder); |
| 108 | av_log(avctx, AV_LOG_ERROR, "Failed to set frame buffer.\n"); |
| 109 | return AVERROR_EXTERNAL; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | // returns 0 on success, AVERROR_INVALIDDATA otherwise |
| 117 | static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, |
no test coverage detected