Skip to content

Instantly share code, notes, and snippets.

@tguillem
Created December 7, 2017 12:09
Show Gist options
  • Save tguillem/72b7225b075f16c341e4515956c8b105 to your computer and use it in GitHub Desktop.
Save tguillem/72b7225b075f16c341e4515956c8b105 to your computer and use it in GitHub Desktop.
if (config->methods &
AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX &&
avctx->hw_frames_ctx) {
const AVHWFramesContext *frames_ctx =
(AVHWFramesContext*)avctx->hw_frames_ctx->data;
if (frames_ctx->format != user_choice) {
av_log(avctx, AV_LOG_ERROR, "Invalid setup for format %s: "
"does not match the format of the provided frames "
"context.\n", desc->name);
goto try_again;
}
} else if (config->methods &
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX &&
avctx->hw_device_ctx) {
const AVHWDeviceContext *device_ctx =
(AVHWDeviceContext*)avctx->hw_device_ctx->data;
if (device_ctx->type != config->device_type) {
av_log(avctx, AV_LOG_ERROR, "Invalid setup for format %s: "
"does not match the type of the provided device "
"context.\n", desc->name);
goto try_again;
}
} else if (config->methods &
AV_CODEC_HW_CONFIG_METHOD_INTERNAL) {
// Internal-only setup, no additional configuration.
} else if (config->methods &
AV_CODEC_HW_CONFIG_METHOD_AD_HOC) {
// Some ad-hoc configuration we can't see and can't check.
} else {
av_log(avctx, AV_LOG_ERROR, "Invalid setup for format %s: "
"missing configuration.\n", desc->name);
goto try_again;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment