}
for (i = j = 0; i < attr_count; i++) {
+ int k;
+
if (attr_list[i].type != VASurfaceAttribPixelFormat)
continue;
fourcc = attr_list[i].value.value.i;
pix_fmt = vaapi_pix_fmt_from_fourcc(fourcc);
- if (pix_fmt != AV_PIX_FMT_NONE)
+
+ if (pix_fmt == AV_PIX_FMT_NONE)
+ continue;
+
+ for (k = 0; k < j; k++) {
+ if (constraints->valid_sw_formats[k] == pix_fmt)
+ break;
+ }
+
+ if (k == j)
constraints->valid_sw_formats[j++] = pix_fmt;
}
- av_assert0(j == pix_fmt_count);
constraints->valid_sw_formats[j] = AV_PIX_FMT_NONE;
}
} else {
err = AVERROR(ENOMEM);
goto fail;
}
- for (i = 0; i < ctx->nb_formats; i++)
- constraints->valid_sw_formats[i] = ctx->formats[i].pix_fmt;
- constraints->valid_sw_formats[i] = AV_PIX_FMT_NONE;
+ for (i = j = 0; i < ctx->nb_formats; i++) {
+ int k;
+
+ for (k = 0; k < j; k++) {
+ if (constraints->valid_sw_formats[k] == ctx->formats[i].pix_fmt)
+ break;
+ }
+
+ if (k == j)
+ constraints->valid_sw_formats[j++] = ctx->formats[i].pix_fmt;
+ }
+
+ constraints->valid_sw_formats[j] = AV_PIX_FMT_NONE;
}
constraints->valid_hw_formats = av_malloc_array(2, sizeof(pix_fmt));
}
}
-static AVBufferRef *vaapi_pool_alloc(void *opaque, int size)
+static AVBufferRef *vaapi_pool_alloc(void *opaque, buffer_size_t size)
{
AVHWFramesContext *hwfc = opaque;
VAAPIFramesContext *ctx = hwfc->internal->priv;
} else {
render_node = drmGetRenderDeviceNameFromFd(src_hwctx->fd);
if (!render_node) {
- av_log(ctx, AV_LOG_ERROR, "Failed to find a render node "
- "matching the DRM device.\n");
- return AVERROR(ENODEV);
- }
- fd = open(render_node, O_RDWR);
- if (fd < 0) {
- av_log(ctx, AV_LOG_ERROR, "Failed to open render node %s"
- "matching the DRM device.\n", render_node);
+ av_log(ctx, AV_LOG_VERBOSE, "Using non-render node "
+ "because the device does not have an "
+ "associated render node.\n");
+ fd = src_hwctx->fd;
+ } else {
+ fd = open(render_node, O_RDWR);
+ if (fd < 0) {
+ av_log(ctx, AV_LOG_VERBOSE, "Using non-render node "
+ "because the associated render node "
+ "could not be opened.\n");
+ fd = src_hwctx->fd;
+ } else {
+ av_log(ctx, AV_LOG_VERBOSE, "Using render node %s "
+ "in place of non-render DRM device.\n",
+ render_node);
+ }
free(render_node);
- return AVERROR(errno);
}
- av_log(ctx, AV_LOG_VERBOSE, "Using render node %s in place "
- "of non-render DRM device.\n", render_node);
- free(render_node);
}
}
#else