From patchwork Sat Dec 2 23:14:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 6515 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp2802868jah; Sat, 2 Dec 2017 15:20:44 -0800 (PST) X-Google-Smtp-Source: AGs4zMYxjD8MHI/NZ2eOYNJCWhEnlSmuu1LIEFX/wQbpONJf86g9bq/6sZByHBXSIZc9iwjbCeSp X-Received: by 10.28.61.135 with SMTP id k129mr3911695wma.81.1512256844876; Sat, 02 Dec 2017 15:20:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512256844; cv=none; d=google.com; s=arc-20160816; b=bOiEzx6iePGz48R6mVR6V8ZhK18YWJhWG0BJz3gs3btOEFlbGCxPOHtYq0YL6G5lVD 8alzlkNeg/NY0AvtOsO71eud3JVhbonQWX3B46VpSBCFseQIKNYdd7m/UQkNgqt+Pbf6 oZOTRGCVd7l8QoSlDHt6Uyp8S46QCB6ggsQFQqUc5SEu8QZNvsDGXfBCHxDzj5Ey1yjF XyM6YmdOsHToVeYsg1feWglSoLRbU7eK5WfKgSdJ9yIuhk9/TexDHn+wdSDho4I3yotu Cc8xrEmEQRFmurmTzdwp50sZgqrfTXqxt1e69B6VCWl28S21IcH04BhczKANV+aAyO0z 7aRQ== 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:cc: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=X5wKF1hslRnokNtHWl5WCs1ABndRGkHuX9qBXimOUYw=; b=bRo3zac9tqmuWL6mdz3Au95SpWFALgdBVSnWxVzoKgZRiKx+kQrvO9dMDAkrJEPoIS fvYu5w2GZSObNlO07ZBrGNG+xlnRpObNUxydG9pm0rncuIBiIxGz2vnvW1W/MquGLhTq fRAAo3Ah2BmePRgT0UcaBUmu8CibCO5TMKUiXRCECJ/QhHwDDPXaM/VyrgIeEb4rIHaP V53RXh7Gmex/wI+1Un53/gv5eOBQK0GUSsd8AUYmLbZfUZWR7FbNAN9d7co8zX52UB+F fadyzYPuMqaGWSZ7ik5YRMTVm8h38W8d+MDLWycevuZm07CdARL1+BzVMRtuPVPJTBqT HWdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=Pzx98exJ; 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 103si7357727wrc.215.2017.12.02.15.20.43; Sat, 02 Dec 2017 15:20:44 -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=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=Pzx98exJ; 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 108E368A213; Sun, 3 Dec 2017 01:20:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f181.google.com (mail-io0-f181.google.com [209.85.223.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4234E68A065 for ; Sun, 3 Dec 2017 01:20:32 +0200 (EET) Received: by mail-io0-f181.google.com with SMTP id g1so14929227ioc.8 for ; Sat, 02 Dec 2017 15:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=gAb36F8288lomGrK6nJQnk55CayfqhBDDhIG1EsEwok=; b=Pzx98exJ+anX1ulXkX5AmNTwGNpuwfEwHZJlz45vb25Oo5Hfp1LomxabtEpxS4T+Mn l3OvO1kCvPy/KrPb1aHnQUzlYsjS6HUVs+3i4rewyMkPKBnOrY9QW6K/eVSN0FSuWifE NsUBPljjZCSEGwewLK4Y9Uid0FHW+2UeSudiD5EmEzYWUg+VgOR+WXrT7Ib/1s0DrosN pyYgvGc465UKIJulbhNfTmVIu2MOZEVB7gShuyk+onCZr+fJA3p2rhG2Ts0WnbYK1oYF QE0flj6aJPnw24tmqyIYVp+WD+1r1FlmYKEVhp9VZl71nMzNu0l5CmUPMFXX24gIDdRw LnuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=gAb36F8288lomGrK6nJQnk55CayfqhBDDhIG1EsEwok=; b=KXu+WWurGSRlwtG/XXDWHlLrMoFWuh8VTELnrv9/Oz8J6aZJ8vWbzIYTA1GCOm59W3 s/p6Oesa2Jpvjku/+C4TocQzJDYRnBtDg2oEIFDcHUdnHWdBjArlHrY3O6cEskr0hjfH ZLmZob5F9KrowgoLB65GV4tkFzwZWDIHSLzlQV4Rm9xgAmciUqQDBpKG1DBAE8sI6O7U Tc5zvczXTN7mmvonMMjduziHE6/63s8xgmZSNfMkgZVVrR37ayI2PrMskOx8TFRUTs8B wa552jXFAWiezWilLtCyXmntRxwgy/jvrkSyW0Nlx/aL16Do1gjK7IaqubSpRce/FVHm 7dyw== X-Gm-Message-State: AJaThX55qo+A7MjF+Nhml4UFjLYw6pr+9RUlkkM1VrOuszTNshV78dxO VeEvmfWiLv+t2xduBtL/ieNfS4Ov X-Received: by 10.107.83.24 with SMTP id h24mr18854873iob.239.1512256461077; Sat, 02 Dec 2017 15:14:21 -0800 (PST) Received: from localhost.localdomain (24-196-247-173.dhcp.reno.nv.charter.com. [24.196.247.173]) by smtp.gmail.com with ESMTPSA id w71sm4330504iof.49.2017.12.02.15.14.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 02 Dec 2017 15:14:20 -0800 (PST) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Sat, 2 Dec 2017 15:14:09 -0800 Message-Id: <20171202231409.32371-2-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.13.6 (Apple Git-96) In-Reply-To: <20171202231409.32371-1-ffmpeg@tmm1.net> References: <20171202231409.32371-1-ffmpeg@tmm1.net> Subject: [FFmpeg-devel] [PATCH 2/2] libavcodec/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if set 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 Cc: matthieu.bouron@stupeflix.com, sw@jkqxz.net, Aman Gupta MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta --- libavcodec/mediacodecdec_common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index cb2f6ae5e5..e524ffe0e4 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -24,6 +24,7 @@ #include #include "libavutil/common.h" +#include "libavutil/hwcontext_mediacodec.h" #include "libavutil/mem.h" #include "libavutil/log.h" #include "libavutil/pixfmt.h" @@ -475,8 +476,12 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, pix_fmt = ff_get_format(avctx, pix_fmts); if (pix_fmt == AV_PIX_FMT_MEDIACODEC) { AVMediaCodecContext *user_ctx = avctx->hwaccel_context; + AVMediaCodecDeviceContext *device_ctx = avctx->hw_device_ctx; - if (user_ctx && user_ctx->surface) { + if (device_ctx && device_ctx->surface) { + s->surface = ff_mediacodec_surface_ref(device_ctx->surface, avctx); + av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface); + } else if (user_ctx && user_ctx->surface) { s->surface = ff_mediacodec_surface_ref(user_ctx->surface, avctx); av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface); }