summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
Diffstat (limited to 'video')
-rw-r--r--video/decode/vaapi.c48
1 files changed, 6 insertions, 42 deletions
diff --git a/video/decode/vaapi.c b/video/decode/vaapi.c
index f78a01d86e..bcc03aeaa4 100644
--- a/video/decode/vaapi.c
+++ b/video/decode/vaapi.c
@@ -50,10 +50,8 @@
*/
#define ADDTIONAL_SURFACES 5
-// Magic number taken from original MPlayer vaapi patch.
-#define MAX_DECODER_SURFACES 21
-
-#define MAX_SURFACES (MAX_DECODER_SURFACES + ADDTIONAL_SURFACES)
+// Some upper bound.
+#define MAX_SURFACES 25
struct priv {
struct mp_log *log;
@@ -127,35 +125,6 @@ static int find_entrypoint(int format, VAEntrypoint *ep, int num_ep)
return -1;
}
-static int is_direct_mapping(VADisplay display)
-{
- VADisplayAttribute attr = {0};
- VAStatus status;
-
-#if VA_CHECK_VERSION(0,34,0)
- attr.type = VADisplayAttribRenderMode;
- attr.flags = VA_DISPLAY_ATTRIB_GETTABLE;
-
- status = vaGetDisplayAttributes(display, &attr, 1);
- if (status == VA_STATUS_SUCCESS)
- return !(attr.value & (VA_RENDER_MODE_LOCAL_OVERLAY|
- VA_RENDER_MODE_EXTERNAL_OVERLAY));
-#else
- /* If the driver doesn't make a copy of the VA surface for
- display, then we have to retain it until it's no longer the
- visible surface. In other words, if the driver is using
- DirectSurface mode, we don't want to decode the new surface
- into the previous one that was used for display. */
- attr.type = VADisplayAttribDirectSurface;
- attr.flags = VA_DISPLAY_ATTRIB_GETTABLE;
-
- status = vaGetDisplayAttributes(display, &attr, 1);
- if (status == VA_STATUS_SUCCESS)
- return !attr.value;
-#endif
- return 0;
-}
-
// We must allocate only surfaces that were passed to the decoder on creation.
// We achieve this by reserving surfaces in the pool as needed.
// Releasing surfaces is necessary after filling the surface id list so
@@ -164,10 +133,12 @@ static bool preallocate_surfaces(struct lavc_ctx *ctx, int num, int w, int h,
VASurfaceID out_surfaces[MAX_SURFACES])
{
struct priv *p = ctx->hwdec_priv;
- assert(num <= MAX_SURFACES);
struct mp_image *reserve[MAX_SURFACES] = {0};
bool res = true;
+ if (num > MAX_SURFACES)
+ return false;
+
for (int n = 0; n < num; n++) {
reserve[n] = mp_image_pool_get(p->pool, IMGFMT_VAAPI, w, h);
out_surfaces[n] = va_surface_id(reserve[n]);
@@ -248,14 +219,7 @@ static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
MP_VERBOSE(p, "Using profile '%s'.\n", str_va_profile(va_profile));
- int num_surfaces = hwdec_get_max_refs(ctx);
- if (!is_direct_mapping(p->display)) {
- MP_VERBOSE(p, "No direct mapping.\n");
- // Note: not sure why it has to be *=2 rather than +=1.
- num_surfaces *= 2;
- }
- num_surfaces = MPMIN(num_surfaces, MAX_DECODER_SURFACES) + ADDTIONAL_SURFACES;
-
+ int num_surfaces = hwdec_get_max_refs(ctx) + ADDTIONAL_SURFACES;
if (num_surfaces > MAX_SURFACES) {
MP_ERR(p, "Internal error: too many surfaces.\n");
goto error;