From patchwork Mon Jun 12 22:40:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 3938 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp77978vsw; Mon, 12 Jun 2017 15:42:35 -0700 (PDT) X-Received: by 10.28.147.202 with SMTP id v193mr656521wmd.37.1497307355090; Mon, 12 Jun 2017 15:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497307355; cv=none; d=google.com; s=arc-20160816; b=QeGrNQ34iQUzynJ6l35vKDqkibDA1v5BjB8+jI5n/D9PezObKvZxXgfi13SrGfIbbn cE8CT2QLrYjrnFr18KoxMg7v6cBmlfXqun4E3coyqZ/VZtJmk4UvA6jMOjOw9cEc+lY2 jnm87JkI8xYvZh47uVUc1mteULRqLLJSGvleuAKtA12Nsq5u9Xmtc6m1FxdJOa6nY6fQ AOg8a4CZF2pmWWLEj807qy0QrO9qYx2dpkOFCTnxZWGth2G7sxAcZcfCvUeZtor7KNhk 9sZ+t9PAIMq9QrDBryHXHGTgyPHO6woljxgHLl9aDvQuHlTgzbAKG+Xe2tzwrPpewuqf W7Yw== 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=EOd5mLAZBz+DQaxeYGt6fexq6meDRcAHlMhk/AGi40k=; b=FVIfQmEXoiyFS6/C3VtTI6db0FFCY1mrixcUqZD4r0LuIshn9r2KYnxywd2k+1am/y crIwhr95Hkh1AXnOZnFkPUsU+89eoMSnMfUKVeaxsLRPe5OGqOi693FWgwO0oE5a3x0C N8XrvnfvjROLKFwmXbv5/3LCxxCdWamTCv2eGEQALNaiU94nZwLI9J0zD6avHnruib5b x/vS9AyUIDd8Ts/uXqUNxTd4GPTzrmhNF64dJrMjfJ2I3lKZ5u5zQZ8Tdr2Mfus7IQaa BQyOxhTfE0qoD4pVgLDKlw6bTP5Q+J0ai2rkQZvpBFzYmLCZI8T+0z56B8ctbfjcVDix +tYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.b=Jk8/don7; 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 201si8328764wms.7.2017.06.12.15.42.34; Mon, 12 Jun 2017 15:42:35 -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=Jk8/don7; 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 95FF568A042; Tue, 13 Jun 2017 01:41:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C013768A036 for ; Tue, 13 Jun 2017 01:41:03 +0300 (EEST) Received: by mail-wr0-f171.google.com with SMTP id q97so116888972wrb.2 for ; Mon, 12 Jun 2017 15:41:05 -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=3y2f9iBQo52LNzYdI9c+qdsxJNIifhMcXk80pYi7gSw=; b=Jk8/don7Vkr3zHFbaTNidDMa5pEH3U6P5Af7YKc+brSj8RrsUvQYs7klfmr7pHZztb u+P1GptYdPMS/IhGunzEZveLAAhxaJhF8XpDMqGB1cpaLA6ymFerFR2dsLv6VqBrpbwM ZyW3tP6qAdw8D6B+tUCqrgy9xeknYtWb27FTOqg7koZ6jMo5cmxgmx4wZGuTC1x7654H fGYvOHkqevB5RoX05/1r7nlspKl6HJJAsbaGiu1TONbqL7Gma3EIetJhMqT+Uq5Pymu5 hYT1REOkEXowFzNfT56584FEiOuKKq4vczvP2IO6EcgCZh4+phnPMv4xsyVyzA331azJ ZVmA== 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=3y2f9iBQo52LNzYdI9c+qdsxJNIifhMcXk80pYi7gSw=; b=P7q/KXIAmQXFgLspb9st7Jdt3FmoF8mWHqlQwi0EDx9gj4Ca55Dd4sNxrd2tShjP8v dZF91XnqKsIclCmh7YT0mcwnVqG5Igl8un2jncyRgmXXdEPJANyjXqkKjvmi1c7h0OZo cwOUn19rDJjMluX13CifAgghxzOsf9ofNPykHEpaNTnJ+EzjMm/Ys9rFeBVfPEhSg+5q q4iZVGbHTJkmPBAhzeBnbnX3LBgb8xSav+YNHJ4kBGZ+dPaeK0NCqF8jUsHO6pSHwYGd 4qC+LF02VMrz8SceN4CUWVBRMSJoZoTEfKxv7oZkyITkOZgztvOMSNcnnCMsng+XdOEx Ew4A== X-Gm-Message-State: AKS2vOwwuNwxj2aWrbb6H9zaPi7ThvKyQmnTdsptMKuVlpnTNWFVuWJK 6R1yKcEvbAAQuWqvctE= X-Received: by 10.28.69.67 with SMTP id s64mr662175wma.100.1497307265304; Mon, 12 Jun 2017 15:41:05 -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.41.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 15:41:04 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Jun 2017 23:40:24 +0100 Message-Id: <20170612224041.6750-8-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 07/24] ffmpeg: Enable generic hwaccel support for VDPAU 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" (cherry picked from commit aa6b2e081c504cb99f5e2e0ceb45295ef24bdac2) --- Makefile | 1 - ffmpeg.h | 1 - ffmpeg_opt.c | 4 +- ffmpeg_vdpau.c | 159 --------------------------------------------------------- 4 files changed, 2 insertions(+), 163 deletions(-) delete mode 100644 ffmpeg_vdpau.c diff --git a/Makefile b/Makefile index 26f9d93d85..ea90ec8b44 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,6 @@ OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o endif OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o -OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o OBJS-ffserver += ffserver_config.o TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch diff --git a/ffmpeg.h b/ffmpeg.h index 231d362f5f..fbb9172d74 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -660,7 +660,6 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int ffmpeg_parse_options(int argc, char **argv); -int vdpau_init(AVCodecContext *s); int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); int videotoolbox_init(AVCodecContext *s); diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 51671e0dd4..1facc82f44 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -67,8 +67,8 @@ const HWAccel hwaccels[] = { #if HAVE_VDPAU_X11 - { "vdpau", vdpau_init, HWACCEL_VDPAU, AV_PIX_FMT_VDPAU, - AV_HWDEVICE_TYPE_NONE }, + { "vdpau", hwaccel_decode_init, HWACCEL_VDPAU, AV_PIX_FMT_VDPAU, + AV_HWDEVICE_TYPE_VDPAU }, #endif #if HAVE_DXVA2_LIB { "dxva2", dxva2_init, HWACCEL_DXVA2, AV_PIX_FMT_DXVA2_VLD, diff --git a/ffmpeg_vdpau.c b/ffmpeg_vdpau.c deleted file mode 100644 index 7d4fbf8a37..0000000000 --- a/ffmpeg_vdpau.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include "ffmpeg.h" - -#include "libavcodec/vdpau.h" - -#include "libavutil/buffer.h" -#include "libavutil/frame.h" -#include "libavutil/hwcontext.h" -#include "libavutil/hwcontext_vdpau.h" -#include "libavutil/pixfmt.h" - -typedef struct VDPAUContext { - AVBufferRef *hw_frames_ctx; - AVFrame *tmp_frame; -} VDPAUContext; - -static void vdpau_uninit(AVCodecContext *s) -{ - InputStream *ist = s->opaque; - VDPAUContext *ctx = ist->hwaccel_ctx; - - ist->hwaccel_uninit = NULL; - ist->hwaccel_get_buffer = NULL; - ist->hwaccel_retrieve_data = NULL; - - av_buffer_unref(&ctx->hw_frames_ctx); - av_frame_free(&ctx->tmp_frame); - - av_freep(&ist->hwaccel_ctx); - av_freep(&s->hwaccel_context); -} - -static int vdpau_get_buffer(AVCodecContext *s, AVFrame *frame, int flags) -{ - InputStream *ist = s->opaque; - VDPAUContext *ctx = ist->hwaccel_ctx; - - return av_hwframe_get_buffer(ctx->hw_frames_ctx, frame, 0); -} - -static int vdpau_retrieve_data(AVCodecContext *s, AVFrame *frame) -{ - InputStream *ist = s->opaque; - VDPAUContext *ctx = ist->hwaccel_ctx; - int ret; - - ret = av_hwframe_transfer_data(ctx->tmp_frame, frame, 0); - if (ret < 0) - return ret; - - ret = av_frame_copy_props(ctx->tmp_frame, frame); - if (ret < 0) { - av_frame_unref(ctx->tmp_frame); - return ret; - } - - av_frame_unref(frame); - av_frame_move_ref(frame, ctx->tmp_frame); - - return 0; -} - -static int vdpau_alloc(AVCodecContext *s) -{ - InputStream *ist = s->opaque; - int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; - VDPAUContext *ctx; - int ret; - - AVBufferRef *device_ref = NULL; - AVHWDeviceContext *device_ctx; - AVVDPAUDeviceContext *device_hwctx; - AVHWFramesContext *frames_ctx; - - ctx = av_mallocz(sizeof(*ctx)); - if (!ctx) - return AVERROR(ENOMEM); - - ist->hwaccel_ctx = ctx; - ist->hwaccel_uninit = vdpau_uninit; - ist->hwaccel_get_buffer = vdpau_get_buffer; - ist->hwaccel_retrieve_data = vdpau_retrieve_data; - - ctx->tmp_frame = av_frame_alloc(); - if (!ctx->tmp_frame) - goto fail; - - ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VDPAU, - ist->hwaccel_device, NULL, 0); - if (ret < 0) - goto fail; - device_ctx = (AVHWDeviceContext*)device_ref->data; - device_hwctx = device_ctx->hwctx; - - ctx->hw_frames_ctx = av_hwframe_ctx_alloc(device_ref); - if (!ctx->hw_frames_ctx) - goto fail; - av_buffer_unref(&device_ref); - - frames_ctx = (AVHWFramesContext*)ctx->hw_frames_ctx->data; - frames_ctx->format = AV_PIX_FMT_VDPAU; - frames_ctx->sw_format = s->sw_pix_fmt; - frames_ctx->width = s->coded_width; - frames_ctx->height = s->coded_height; - - ret = av_hwframe_ctx_init(ctx->hw_frames_ctx); - if (ret < 0) - goto fail; - - if (av_vdpau_bind_context(s, device_hwctx->device, device_hwctx->get_proc_address, 0)) - goto fail; - - av_log(NULL, AV_LOG_VERBOSE, "Using VDPAU to decode input stream #%d:%d.\n", - ist->file_index, ist->st->index); - - return 0; - -fail: - av_log(NULL, loglevel, "VDPAU init failed for stream #%d:%d.\n", - ist->file_index, ist->st->index); - av_buffer_unref(&device_ref); - vdpau_uninit(s); - return AVERROR(EINVAL); -} - -int vdpau_init(AVCodecContext *s) -{ - InputStream *ist = s->opaque; - - if (!ist->hwaccel_ctx) { - int ret = vdpau_alloc(s); - if (ret < 0) - return ret; - } - - ist->hwaccel_get_buffer = vdpau_get_buffer; - ist->hwaccel_retrieve_data = vdpau_retrieve_data; - - return 0; -}