vaapi: remove direct mapping non-sense

This must have been some non-sense in the original vaapi mplayer patch.
While I still have no good idea what this "direct mapping" business is
about, it appears to be pretty much pointless. Nothing can hold
additional "real" surface references (due to how the API and mpv/lavc
refcounting work), so removing the additional surfaces won't break
anything. It still could be that this was for achieving additional
buffering (not reusing surfaces as soon), but we buffer some additional
data anyway. Plus, the original intention of the vaapi mplayer code was
probably increasing surface count just by 1 or 2, not actually doubling
it, and/or it was a "trick" to get to the maximum count of 21 when h264
is in use.

gstreamer-vaapi uses "ref_frames + SCRATCH_SURFACES_COUNT" here, with
SCRATCH_SURFACES_COUNT defined to 4. It doesn't appear to check the
overlay attributes at all in the decoder.

In any case, remove this non-sense.
This commit is contained in:
wm4 2015-05-29 16:28:55 +02:00
parent 327b091909
commit d3894290ec
1 changed files with 6 additions and 42 deletions

View File

@ -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;