From patchwork Thu Dec 20 20:39:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 11497 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 71E7044CCED for ; Thu, 20 Dec 2018 22:45:23 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9242768ADFA; Thu, 20 Dec 2018 22:45:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9436968AD4D for ; Thu, 20 Dec 2018 22:45:17 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id z5so3110422wrt.11 for ; Thu, 20 Dec 2018 12:45:20 -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:mime-version :content-transfer-encoding; bh=SYBPOJ20roOTr3hUB0eGchZO+reDcJUdH/q83n7rN/Y=; b=ILfQgnGM+Fmpqt3HKQ1HfwR5gMfOKEa0nStrEO46oeZFkNf/616WzTMB1POKVesCRc +U88B0g1HYaCOoJqP6IVL66fQogvgEC4fBxX/Rk1sd6miuSeUruMgaVMdNPJqdma+83G Ay5Apd8N/RcS0huUnL8zOhf3strF3Fua24NdkdxQ1+5KVe6X2proMW7M6Ic6cxG0gRad GLBSo4Fwm5CpKsmdd5zZiDyJUYFOYjd3GF6jEhHCUwLfI9u3d4kmxGqBufeMl833Z+TS 2PDGj7IXjxylrDdr4g/M8p4Y/x/ot4dAG8vtIJbHryz6pmsmKV00nFy69IHuCe1Aqhb3 1Y/Q== 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:mime-version :content-transfer-encoding; bh=SYBPOJ20roOTr3hUB0eGchZO+reDcJUdH/q83n7rN/Y=; b=W5uQSMzPSq3jY0tkbT6YgYh8357ihABAobEbgrbLWFwyE5kGu1EgavMQrsTDuOSWLs FZRHj0HB3imXscU/3/fU7HyVRmawY22Rpx2uvpxaprJJrE414/+/ohKU+5Y0EiquylkK U5LWJZaRrGdtAq14/JmQ6Py7e7+6rE6Pe0eEu88PN1HT8Ysv9SR92wpKPjrEImfDvByc 7xL45atN4OrGxnh9IYat87ZRQzlpMxtSeQSCK7ENfSsJKPXeUOKiqUWMfCKoMKJy+Hg6 a0cTFXKf7fUvv99sdXCtTEveD5KZRu1iji/O/cHYysrnJ+2Q9XTG9yI0Yaw5srPOMfcL j7AQ== X-Gm-Message-State: AA+aEWY/AwZDBPdcCvHgDjpBw+8qxkkWRYCj8MfwlML3EAV8R/Xg8D+j WRPolYVXQCnFeMEEhAecUMjgBKo/4do= X-Google-Smtp-Source: AFSGD/VQGrr1n8U/+1pBJ9e9C0muZgCCFynlWhay6PcN8EpNatZX0DcNuEC+cBYW2R0Mv28FBLmOfw== X-Received: by 2002:adf:b307:: with SMTP id j7mr25609528wrd.46.1545338412141; Thu, 20 Dec 2018 12:40:12 -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 x10sm11956884wrn.29.2018.12.20.12.40.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 12:40:11 -0800 (PST) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Thu, 20 Dec 2018 20:39:55 +0000 Message-Id: <20181220204008.32766-1-sw@jkqxz.net> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/14] vaapi_encode: Allocate picture-private data in generic code 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/vaapi_encode.c | 15 ++++++++++++--- libavcodec/vaapi_encode.h | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index eda8a36299..d8bedbe162 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -570,14 +570,23 @@ static int vaapi_encode_discard(AVCodecContext *avctx, return 0; } -static VAAPIEncodePicture *vaapi_encode_alloc(void) +static VAAPIEncodePicture *vaapi_encode_alloc(AVCodecContext *avctx) { + VAAPIEncodeContext *ctx = avctx->priv_data; VAAPIEncodePicture *pic; pic = av_mallocz(sizeof(*pic)); if (!pic) return NULL; + if (ctx->codec->picture_priv_data_size > 0) { + pic->priv_data = av_mallocz(ctx->codec->picture_priv_data_size); + if (!pic->priv_data) { + av_freep(&pic); + return NULL; + } + } + pic->input_surface = VA_INVALID_ID; pic->recon_surface = VA_INVALID_ID; pic->output_buffer = VA_INVALID_ID; @@ -710,7 +719,7 @@ static int vaapi_encode_get_next(AVCodecContext *avctx, } } - pic = vaapi_encode_alloc(); + pic = vaapi_encode_alloc(avctx); if (!pic) return AVERROR(ENOMEM); @@ -739,7 +748,7 @@ static int vaapi_encode_get_next(AVCodecContext *avctx, for (i = 0; i < ctx->b_per_p && ctx->gop_counter < ctx->gop_size; i++) { - pic = vaapi_encode_alloc(); + pic = vaapi_encode_alloc(avctx); if (!pic) goto fail; diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 965fe65c0b..6204c5171f 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -268,6 +268,10 @@ typedef struct VAAPIEncodeType { // add any necessary global parameters). int (*configure)(AVCodecContext *avctx); + // The size of any private data structure associated with each + // picture (can be zero if not required). + size_t picture_priv_data_size; + // The size of the parameter structures: // sizeof(VAEnc{type}ParameterBuffer{codec}). size_t sequence_params_size;