mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2026-01-24 02:20:56 +01:00
Revert "lavfi/vf_hwupload: validate the hw device in init"
This reverts commit 036336296c.
This commit is contained in:
parent
c1995d747c
commit
0f84bdce54
1 changed files with 21 additions and 28 deletions
|
|
@ -39,33 +39,6 @@ typedef struct HWUploadContext {
|
||||||
char *device_type;
|
char *device_type;
|
||||||
} HWUploadContext;
|
} HWUploadContext;
|
||||||
|
|
||||||
static int hwupload_init(AVFilterContext *avctx)
|
|
||||||
{
|
|
||||||
HWUploadContext *ctx = avctx->priv;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (!avctx->hw_device_ctx) {
|
|
||||||
av_log(ctx, AV_LOG_ERROR, "A hardware device reference is required "
|
|
||||||
"to upload frames to.\n");
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->device_type) {
|
|
||||||
err = av_hwdevice_ctx_create_derived(
|
|
||||||
&ctx->hwdevice_ref,
|
|
||||||
av_hwdevice_find_type_by_name(ctx->device_type),
|
|
||||||
avctx->hw_device_ctx, 0);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
} else {
|
|
||||||
ctx->hwdevice_ref = av_buffer_ref(avctx->hw_device_ctx);
|
|
||||||
if (!ctx->hwdevice_ref)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int hwupload_query_formats(AVFilterContext *avctx)
|
static int hwupload_query_formats(AVFilterContext *avctx)
|
||||||
{
|
{
|
||||||
HWUploadContext *ctx = avctx->priv;
|
HWUploadContext *ctx = avctx->priv;
|
||||||
|
|
@ -74,6 +47,27 @@ static int hwupload_query_formats(AVFilterContext *avctx)
|
||||||
AVFilterFormats *input_formats = NULL;
|
AVFilterFormats *input_formats = NULL;
|
||||||
int err, i;
|
int err, i;
|
||||||
|
|
||||||
|
if (ctx->hwdevice_ref) {
|
||||||
|
/* We already have a specified device. */
|
||||||
|
} else if (avctx->hw_device_ctx) {
|
||||||
|
if (ctx->device_type) {
|
||||||
|
err = av_hwdevice_ctx_create_derived(
|
||||||
|
&ctx->hwdevice_ref,
|
||||||
|
av_hwdevice_find_type_by_name(ctx->device_type),
|
||||||
|
avctx->hw_device_ctx, 0);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
} else {
|
||||||
|
ctx->hwdevice_ref = av_buffer_ref(avctx->hw_device_ctx);
|
||||||
|
if (!ctx->hwdevice_ref)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
av_log(ctx, AV_LOG_ERROR, "A hardware device reference is required "
|
||||||
|
"to upload frames to.\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
constraints = av_hwdevice_get_hwframe_constraints(ctx->hwdevice_ref, NULL);
|
constraints = av_hwdevice_get_hwframe_constraints(ctx->hwdevice_ref, NULL);
|
||||||
if (!constraints) {
|
if (!constraints) {
|
||||||
err = AVERROR(EINVAL);
|
err = AVERROR(EINVAL);
|
||||||
|
|
@ -261,7 +255,6 @@ const FFFilter ff_vf_hwupload = {
|
||||||
.p.description = NULL_IF_CONFIG_SMALL("Upload a normal frame to a hardware frame"),
|
.p.description = NULL_IF_CONFIG_SMALL("Upload a normal frame to a hardware frame"),
|
||||||
.p.priv_class = &hwupload_class,
|
.p.priv_class = &hwupload_class,
|
||||||
.p.flags = AVFILTER_FLAG_HWDEVICE,
|
.p.flags = AVFILTER_FLAG_HWDEVICE,
|
||||||
.init = hwupload_init,
|
|
||||||
.uninit = hwupload_uninit,
|
.uninit = hwupload_uninit,
|
||||||
.priv_size = sizeof(HWUploadContext),
|
.priv_size = sizeof(HWUploadContext),
|
||||||
FILTER_INPUTS(hwupload_inputs),
|
FILTER_INPUTS(hwupload_inputs),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue