From patchwork Mon Jun 12 22:40:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 3933 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp77619vsw; Mon, 12 Jun 2017 15:41:20 -0700 (PDT) X-Received: by 10.223.146.129 with SMTP id 1mr757340wrn.164.1497307279986; Mon, 12 Jun 2017 15:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497307279; cv=none; d=google.com; s=arc-20160816; b=fjnuvNKVmNXCaR1YnaTPWH+7ybQGsf5uOqkn/01nmwtcNU88MbCXeRy9F/vTo0NBsD 2QqLkXbMwtrBC2PohThFF4skkI0eBlgZzdRY024FyFpcmYq/i+SWNr8YT8jPconEMboV u2ewi65PJPS1O6+ZBQK70N9zuHU5fo3fF8zFiOs3YS5izwy/t+mDwRLF0foDaWdhEnik /vViXojtbUB3i9jHpoxxk4cs84KmF9eoMu/Jlz7zqHgrp2QaLAUb0frrSZmPI5qjvgwj 3O9ZIt3m8S8VUdq5YlDp3yveJFQjsymu3nncOooAd5YfP4BDW6d6Yztc4UKzounMpiYK wdYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=7phD0SHrtDSdwst7HRdvpF+7cCgg/E0HIDX9I5fsCwk=; b=WgJP/4QRzwAXYjrhXbCOtd/SxgEEaoWVPgERUahkJnwwPG8WyLrqfwKimr4XGKFK50 YWukQedKvxWT8AQQvkWwplntkV6SXMUe9/kmiYIIMKtP1X+4UZqpIeU1+w9Sb5K0nR5O pykxuUbABTkRB9XyTXbSF6394HJN4tOra69m+LY7KyvKknUgsIDd6XWrr3IOR0Vk60Em 5IdnVCcfOdRMdm2vfS31zGTLnVoPc+1HOal1hhe8eqOX1FYLH8edf1TL/mehbBRXDtaL JHBbVSNWIlpqKfdgoadV8MFpBNls8lUzF0D/AGEByjlQd9iP4LIRElq6HkesbgsR3CMe 107Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.b=GQg4EHuf; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y73si8907722wmd.145.2017.06.12.15.41.19; Mon, 12 Jun 2017 15:41:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.b=GQg4EHuf; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1FD1668832B; Tue, 13 Jun 2017 01:41:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f169.google.com (mail-wr0-f169.google.com [209.85.128.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3EF8968071F for ; Tue, 13 Jun 2017 01:40:58 +0300 (EEST) Received: by mail-wr0-f169.google.com with SMTP id g76so113424967wrd.1 for ; Mon, 12 Jun 2017 15:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=7cd+jHLh4XX/egkmKRF3CrzIx2ojZiBkRXn+d+cVlu8=; b=GQg4EHufFst2lOcEZmjK9VUrV071c0VdqwyotdxlnpTAD8az45OxtGDn5iU/0YVDIR /7Hr9LAEoFvYsi81F+tElnOgLOHoyk+vdLF/euP6Lf61O2W2Q5F0j3aOGllpcAYvDnoL sCPzXvC7jTmAL0mCkUGBil1AGaw0c3oekaeCZQP6ysNKTuDOQSXVUurWAMyCvmG5r7Aj MUvs2Q+XfE/T0nFLOUpiOFFvBBTQOvxLWzcXYzT2doQ1C+IiGCDIYNcAXJZXEbeyYkH3 yBSls3k+RvniHVMD+kGUJJjU+HD70Z+K+cOHn+Lzt7ThcyZ29fBTUXAguhelK3vKr2s/ ifxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=7cd+jHLh4XX/egkmKRF3CrzIx2ojZiBkRXn+d+cVlu8=; b=Kjtwkfvre3XaQlinJvcDODSS4By8Bw+hqaxVpSGy2JvX32B+njjxRM9GXFpPGWq3LH nOkmgrPlyhCQ3JHUSCXjR+UMgLxh/KTjQhuI/Ctd3DWf/b+dgXTlKvP6pq5dzyIxgMG1 9f3KyDRDWYsOy/NnlkqqMbYQrs9PCltYjR0E+6eOEr1ytAVYmKh9LGC6usx1hLKZk5T4 uuBzLLG1gXkGKLjpALvv8mTA/IZ1cydQnZ7pn4EsUeilIgtr86mG4SPFSQYGgDwdlLkk eWJKOhh3Jo8zSyR/Uf/3/FItygE21rC4fBIVJ3+Z9N79harI0bqbfapqeujF9YG5iogx S7Eg== X-Gm-Message-State: AKS2vOwI6twiG7XJTdudvIaXYhXzAdFYlpkTcjkLiJ2JsqJBgD8axGoG AccofIGkOiDgN/7P41k= X-Received: by 10.28.6.213 with SMTP id 204mr9227586wmg.15.1497307259684; Mon, 12 Jun 2017 15:40:59 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id m191sm13098233wmg.30.2017.06.12.15.40.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 15:40:58 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Jun 2017 23:40:18 +0100 Message-Id: <20170612224041.6750-2-sw@jkqxz.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612224041.6750-1-sw@jkqxz.net> References: <20170612224041.6750-1-sw@jkqxz.net> Subject: [FFmpeg-devel] [PATCH 01/24] hwcontext_vaapi: Try to support the VDPAU wrapper X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The driver is somewhat bitrotten (not updated for years) but is still usable for decoding with this change. To support it, this adds a new driver quirk to indicate no support at all for surface attributes. Based on a patch by wm4 . (cherry picked from commit e791b915c774408fbc0ec9e7270b021899e08ccc) --- libavutil/hwcontext_vaapi.c | 79 ++++++++++++++++++++++++++------------------- libavutil/hwcontext_vaapi.h | 7 ++++ 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 3b50e95615..3970726d30 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -155,7 +155,8 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, unsigned int fourcc; int err, i, j, attr_count, pix_fmt_count; - if (config) { + if (config && + !(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES)) { attr_count = 0; vas = vaQuerySurfaceAttributes(hwctx->display, config->config_id, 0, &attr_count); @@ -273,6 +274,11 @@ static const struct { "ubit", AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE, }, + { + "VDPAU wrapper", + "Splitted-Desktop Systems VDPAU backend for VA-API", + AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES, + }, }; static int vaapi_device_init(AVHWDeviceContext *hwdev) @@ -451,43 +457,48 @@ static int vaapi_frames_init(AVHWFramesContext *hwfc) } if (!hwfc->pool) { - int need_memory_type = !(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE); - int need_pixel_format = 1; - for (i = 0; i < avfc->nb_attributes; i++) { - if (ctx->attributes[i].type == VASurfaceAttribMemoryType) - need_memory_type = 0; - if (ctx->attributes[i].type == VASurfaceAttribPixelFormat) - need_pixel_format = 0; - } - ctx->nb_attributes = - avfc->nb_attributes + need_memory_type + need_pixel_format; + if (!(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES)) { + int need_memory_type = !(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE); + int need_pixel_format = 1; + for (i = 0; i < avfc->nb_attributes; i++) { + if (ctx->attributes[i].type == VASurfaceAttribMemoryType) + need_memory_type = 0; + if (ctx->attributes[i].type == VASurfaceAttribPixelFormat) + need_pixel_format = 0; + } + ctx->nb_attributes = + avfc->nb_attributes + need_memory_type + need_pixel_format; - ctx->attributes = av_malloc(ctx->nb_attributes * + ctx->attributes = av_malloc(ctx->nb_attributes * sizeof(*ctx->attributes)); - if (!ctx->attributes) { - err = AVERROR(ENOMEM); - goto fail; - } + if (!ctx->attributes) { + err = AVERROR(ENOMEM); + goto fail; + } - for (i = 0; i < avfc->nb_attributes; i++) - ctx->attributes[i] = avfc->attributes[i]; - if (need_memory_type) { - ctx->attributes[i++] = (VASurfaceAttrib) { - .type = VASurfaceAttribMemoryType, - .flags = VA_SURFACE_ATTRIB_SETTABLE, - .value.type = VAGenericValueTypeInteger, - .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA, - }; - } - if (need_pixel_format) { - ctx->attributes[i++] = (VASurfaceAttrib) { - .type = VASurfaceAttribPixelFormat, - .flags = VA_SURFACE_ATTRIB_SETTABLE, - .value.type = VAGenericValueTypeInteger, - .value.value.i = fourcc, - }; + for (i = 0; i < avfc->nb_attributes; i++) + ctx->attributes[i] = avfc->attributes[i]; + if (need_memory_type) { + ctx->attributes[i++] = (VASurfaceAttrib) { + .type = VASurfaceAttribMemoryType, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA, + }; + } + if (need_pixel_format) { + ctx->attributes[i++] = (VASurfaceAttrib) { + .type = VASurfaceAttribPixelFormat, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, + .value.value.i = fourcc, + }; + } + av_assert0(i == ctx->nb_attributes); + } else { + ctx->attributes = NULL; + ctx->nb_attributes = 0; } - av_assert0(i == ctx->nb_attributes); ctx->rt_format = rt_format; diff --git a/libavutil/hwcontext_vaapi.h b/libavutil/hwcontext_vaapi.h index da1d4fe6c2..0b2e071cb3 100644 --- a/libavutil/hwcontext_vaapi.h +++ b/libavutil/hwcontext_vaapi.h @@ -51,6 +51,13 @@ enum { * so the surface allocation code will not try to use it. */ AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE = (1 << 2), + + /** + * The driver does not support surface attributes at all. + * The surface allocation code will never pass them to surface allocation, + * and the results of the vaQuerySurfaceAttributes() call will be faked. + */ + AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES = (1 << 3), }; /**