From patchwork Sat Nov 18 18:47:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 6176 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp2086391jah; Sat, 18 Nov 2017 10:54:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMabKC9Wk5aPTIBO4jXU/vol8Yd1pjDz9YaoPx9MYzqw7vKiCgumT5sVD0MzXF6bxyIrqaqq X-Received: by 10.28.131.2 with SMTP id f2mr6239425wmd.137.1511031283199; Sat, 18 Nov 2017 10:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511031283; cv=none; d=google.com; s=arc-20160816; b=uyYBTdH3NWeb64fre+UDY7APovagT9eyikEBaQHz5RPmH0opFe8B+jLdPr+T6ao4Ag IdjmtAZEffblGOLEYkbes01zL+pRpp9WkQlhAodg0ZDO8I/KwqO8klepHsY9zDJ63cm/ 9t/a+lwQ+0lVifIZyUD9/ZyVDYWNsmpasiCQaBpM78EQ2+cEDN3UHF+3KjZbCmrVZnMf aMdQyjBAQiuzFCcJ7GAyGWWkdPGcc4QQqEwLBHnrd6fN3hafrQMK6A3f9cvU2dPElbYZ cMGHaQ2NoOkmRdcVyCFYyG4reCZfzgz2Szaxhigg0SyzIg/5RnV/NgwEV575j2DwIPIU jbUQ== 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=7pMhjZqOjulWkGY4LRkxcik3q2Q/0QHgiEdOtifYejI=; b=0PgOCfoos5glK1jfEVe8aWvrHuH70LEimH/MeWQRoan1nDEAHmFmCTobmLjVade9mI 1CBHcVIUugqx1GdqREWlbTLBy/kJIc1rviSCvVX4lO2NBARYsrLvIBCFiHfGTUFcfpIu n5xhq/xuhI+6pxFoQGhV4sUvaPTKYYvHRCKRCmPs3oX8LjkMV8cL72qysKXSPa4dsjWF /Vv+5x2nYYQJex9JoW1oYbMpEWBJYuzwKqKAu4ujmodg0IDjRhf/3WjBZThpJK21Tp5b Oin8gvBMEtYSSmyiQj2tM7Xk+WsAjl47sF/Fiu+fpR1PuJ/CnJIWTM9p6FnjvDX8X79/ brwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.s=20150623 header.b=ATO42p29; 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 l184si5209006wma.161.2017.11.18.10.54.42; Sat, 18 Nov 2017 10:54:43 -0800 (PST) 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.s=20150623 header.b=ATO42p29; 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 8A5D268A0CB; Sat, 18 Nov 2017 20:54:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9738968A0CB for ; Sat, 18 Nov 2017 20:54:18 +0200 (EET) Received: by mail-wr0-f194.google.com with SMTP id u98so4716297wrb.13 for ; Sat, 18 Nov 2017 10:54:35 -0800 (PST) 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=WPufq/NbQjK82edgHQoWBG9P/4Ep+zgmCHCxCe1CJ1Q=; b=ATO42p29uO6dZCAdoHKaHQFQPy4/T5iOlg+x47z8tfWkFm9w4dk31rlcfv3n8aJsaD x0T+h2HSGzM0WPnGR/LNWNsfuFICr8+hkeqfoJn07tiY9sJ4yUOlTe+4C2BezP5N9u41 5r3CNl2GZpyOBBuiVutIBLO70neQs4uX2/xqb1QAFbDoKdNR5Ut8FxRhA6oDVHKCL7+/ Fd8iev8zRIYFClgENucnMcoCWE7/9YWLF4oyzEfOA23HzNlOVaz+PaeT29oaQDXyPxwh 7ifNIBZgQsUqjHgNr+x4ipEgMtzR75iiMXNNR4Iju2hqPjeWtr8c2p95q6F0FuXQyRRs /tow== 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=WPufq/NbQjK82edgHQoWBG9P/4Ep+zgmCHCxCe1CJ1Q=; b=XJinkiJfmFNJ8Yel2rHN1ZzA6rkXd1521Xz/M3bpDcbHbl/ITCi5i3nqz/Y7oNFJC3 eR3UvAlg2N5y9XqvQJHJsx82/ArXrTsW3cFo/ZeZQg5CAIIumvDmxdSf+URszd9AZzE+ +QG0vMuEFzMdUu19YgAUvkH0yjwDM+amH+yhoui2x7eyGq33hHBak6NsBWZB5EBFuSzP dLLr9EvzPboZGfe+aR7qUi+JhPnu5gfxnfjRxG/SSXiWb3/PyRrbik1b+kiQHMIY6nq/ R30zMMz0SvmKXHeIg8kjDsJoSPmZ061hDUxGYm/l7AQRirbVf1WbC6lfqWwsEMJsmo0T 6CXw== X-Gm-Message-State: AJaThX6paDTbCgtCoeuPiBFWcGsLxBLggNtv31qnyXW/1Y7ycHxThgMY edsyhwL22dOuv94Ek28O1ZJu6ony X-Received: by 10.223.195.198 with SMTP id d6mr7301249wrg.100.1511030847111; Sat, 18 Nov 2017 10:47:27 -0800 (PST) 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 143sm13477360wmj.35.2017.11.18.10.47.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2017 10:47:26 -0800 (PST) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Nov 2017 18:47:10 +0000 Message-Id: <20171118184713.11490-10-sw@jkqxz.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171118184713.11490-1-sw@jkqxz.net> References: <20171118184713.11490-1-sw@jkqxz.net> Subject: [FFmpeg-devel] [PATCH 10/13] vaapi: Make the decode profile matching more explicit 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" Also fixes a bug where it could attempt to decode with an unsupported codec if allow-profile-mismatch was set. --- libavcodec/vaapi_decode.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index d467bed874..d36ef906a2 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -287,8 +287,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, VAStatus vas; int err, i, j; const AVCodecDescriptor *codec_desc; - VAProfile profile, va_profile, *profile_list = NULL; - int profile_count, exact_match, alt_profile; + VAProfile *profile_list = NULL, matched_va_profile; + int profile_count, exact_match, matched_ff_profile; const AVPixFmtDescriptor *sw_desc, *desc; AVHWDeviceContext *device = (AVHWDeviceContext*)device_ref->data; @@ -317,7 +317,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, goto fail; } - profile = VAProfileNone; + matched_va_profile = VAProfileNone; exact_match = 0; for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) { @@ -326,23 +326,22 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, continue; if (avctx->profile == vaapi_profile_map[i].codec_profile) profile_match = 1; - profile = vaapi_profile_map[i].va_profile; for (j = 0; j < profile_count; j++) { - if (profile == profile_list[j]) { + if (vaapi_profile_map[i].va_profile == profile_list[j]) { exact_match = profile_match; break; } } if (j < profile_count) { + matched_va_profile = vaapi_profile_map[i].va_profile; + matched_ff_profile = vaapi_profile_map[i].codec_profile; if (exact_match) break; - alt_profile = vaapi_profile_map[i].codec_profile; - va_profile = vaapi_profile_map[i].va_profile; } } av_freep(&profile_list); - if (profile == VAProfileNone) { + if (matched_va_profile == VAProfileNone) { av_log(avctx, AV_LOG_ERROR, "No support for codec %s " "profile %d.\n", codec_desc->name, avctx->profile); err = AVERROR(ENOSYS); @@ -356,8 +355,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, codec_desc->name, avctx->profile); av_log(avctx, AV_LOG_WARNING, "Using possibly-" "incompatible profile %d instead.\n", - alt_profile); - profile = va_profile; + matched_ff_profile); } else { av_log(avctx, AV_LOG_VERBOSE, "Codec %s profile %d not " "supported for hardware decode.\n", @@ -367,7 +365,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, } } - vas = vaCreateConfig(hwctx->display, profile, + vas = vaCreateConfig(hwctx->display, matched_va_profile, VAEntrypointVLD, NULL, 0, va_config); if (vas != VA_STATUS_SUCCESS) {