From patchwork Fri Oct 13 16:59:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wm4 X-Patchwork-Id: 5551 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp903981jah; Fri, 13 Oct 2017 10:00:05 -0700 (PDT) X-Received: by 10.28.135.209 with SMTP id j200mr1890556wmd.40.1507914005208; Fri, 13 Oct 2017 10:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507914005; cv=none; d=google.com; s=arc-20160816; b=M8+FBssVxSyTZ0UJ0V9O8RM18bWlA75+7twbJGmP8itZ4PpRKJpNGv3ZsK0pfPmFxU LJ6LnSkrLh+k08+r1Z29Nabsup7SOPU/2QGvwDueuxnao3EQBTmq3smIub1rbeBkWS3y Y+6UY4MkOqJUn8bB1rmRKgZcStOEH0b2oz2vlEiLTsnvsatxd0WRY7kpyilgOd5hV++D RTe/zDccsqkhOaCWjtwbLDn97PxDc0oll2r3PxzPySt401lwLRVx/5V3esK/LsDDASXq Cxy4yE3ecsamoc6KoDYcZHA1kcdwGiKHtH0qYXVP2frkZ3JJqgMH4XpF6nR0u/5BxIUF nqZg== 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=723oYu+rdtkcdvqRAkGGolAJgdPXRvYiDTgCY3TXRmU=; b=wlJVO+20NEGcqHuHRVlMkA9Pa3UEkW1Muz4v/LkAJkby2bRwtRNH170l0oC+JSYdQd gpKqlsZhratXC/DHL09mugJIYPrwugYOlqLAhzPEnqMjNcCQVCLq4fMqMYJxRACkjNmM xIFiFkpBUHM+X4ZdVygrDSfGNSFk5V9iRApTygPczc+fxGCXR0/5/Lp/vle30fbo6W+E Ns33nfpzzRO+u1nGoTGiMUy5fe3c4NtEukiK1yMZfeQsZ7yS1Huf8WpubjmU+yV4WFqc lf9pXi1e+vvYLqZWhjTOEDmBib5a1mn50I2gGGdy0dkehGOaCwDEo+a82kqoPqSamb7K NAGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@googlemail.com header.s=20161025 header.b=PhhBqiSq; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i7si1052459wre.39.2017.10.13.10.00.04; Fri, 13 Oct 2017 10:00:05 -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=@googlemail.com header.s=20161025 header.b=PhhBqiSq; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B6C5A68A0EB; Fri, 13 Oct 2017 19:59:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1E57268A0FB for ; Fri, 13 Oct 2017 19:59:21 +0300 (EEST) Received: by mail-wm0-f67.google.com with SMTP id k4so23020331wmc.1 for ; Fri, 13 Oct 2017 09:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=r1swgV1dxj4TtU4XZfeqt6D9eHUj5H1u+rQbIL/z4s4=; b=PhhBqiSqea2PEZ+BaNbGVuM1NtXAY9V6I+Gc5ILLrbVQaXlQclDaIwnmkycqlWfYW9 wF7lFARgYUJ27rBdOSZycquqvGR5u1JI8dlRV9j82YQDEXxoMEz7lhn4wovWneU85kiP jyGvQoUjgyhneLQw8JoXVwk4K27lj1xUVJ6z0Ybd+V9DNuIqFHJ4q2SKK/jTpT0f+Pni 4Tb+8GwwHOAVEvcySokpJwEePDk8SpQe7K8+83e0CPUtCyA8BFoBMrYJokNYBnm/JvyK aYAYMHwwYrttxe1noqVmAe6kqyuFBayz/OVvpECmPaC+0Ng7UCOvsU4zHRh96uxbqiux euvw== 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=r1swgV1dxj4TtU4XZfeqt6D9eHUj5H1u+rQbIL/z4s4=; b=thOdtBr4K/ESTat3d+VKu11RXCrgema6avqwvzzJmGrRm02XjQtVPzbswyMghTacV4 9gS3BSmj5sW5iKUHrTFZ6zpmSPusc11eX9p+Q1jq6lDaLSimXwXJKIFBi7DINXwl18K3 tho1oh58iDgIrtIWrdevq+akvnOLKdAEFHM39VeDUSvy9C/rjPgCS6XmgT/T68KQ0nci Yw6YXs6PSZ1Bl+SBHwy9JJPkvaiaBSoE+VFaFJyRg0Uj9ii8rHOuVBC03vOAmtBobbf6 /xzxIAfyOUT0AWs+/7fYbprgbT1jufI2r6zrVfhGbLeK2qk6ImryMQvUGkJ0T62q6iLH msAQ== X-Gm-Message-State: AMCzsaUu+LvTrL1WcyBVFBFDPiARusfEZIMMHq+cJ4H9xkFnm4cX/5EO ubcdHlLIj9EDpvsQ6kcf20hy4Q== X-Google-Smtp-Source: AOwi7QCX/gVQpikg/KtnOEFXMI0ZRzd7BZb6AvGKcPkrLNMt05n4abKuXRlaBaKppDDVQnQEOilrvg== X-Received: by 10.80.196.3 with SMTP id v3mr2926302edf.272.1507913963830; Fri, 13 Oct 2017 09:59:23 -0700 (PDT) Received: from debian.speedport.ip (p2003006CCD5CDB3359F6019A8DC244E7.dip0.t-ipconnect.de. [2003:6c:cd5c:db33:59f6:19a:8dc2:44e7]) by smtp.googlemail.com with ESMTPSA id a1sm1199243edb.37.2017.10.13.09.59.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 09:59:23 -0700 (PDT) From: wm4 To: ffmpeg-devel@ffmpeg.org Date: Fri, 13 Oct 2017 18:59:18 +0200 Message-Id: <20171013165919.7642-5-nfxjfg@googlemail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171013165919.7642-1-nfxjfg@googlemail.com> References: <20171013165919.7642-1-nfxjfg@googlemail.com> Subject: [FFmpeg-devel] [PATCH 4/5] decode: add a mechanism for performing delayed processing on the decoded frames 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" From: Anton Khirnov This will be useful in the CUVID hwaccel. Merges Libav commit badf0951f54c1332e77455dc40398f3512540c1b. --- libavcodec/decode.c | 11 +++++++++++ libavcodec/decode.h | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 9395cfc43b..9878950c82 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -653,6 +653,14 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) fdd = (FrameDecodeData*)frame->opaque_ref->data; + if (fdd->post_process) { + ret = fdd->post_process(avctx, frame); + if (ret < 0) { + av_frame_unref(frame); + return ret; + } + } + user_opaque_ref = fdd->user_opaque_ref; fdd->user_opaque_ref = NULL; av_buffer_unref(&frame->opaque_ref); @@ -1638,6 +1646,9 @@ static void decode_data_free(void *opaque, uint8_t *data) av_buffer_unref(&fdd->user_opaque_ref); + if (fdd->post_process_opaque_free) + fdd->post_process_opaque_free(fdd->post_process_opaque); + av_freep(&fdd); } diff --git a/libavcodec/decode.h b/libavcodec/decode.h index 9326f1d952..dcfc830296 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -22,6 +22,7 @@ #define AVCODEC_DECODE_H #include "libavutil/buffer.h" +#include "libavutil/frame.h" #include "avcodec.h" @@ -34,6 +35,20 @@ typedef struct FrameDecodeData { * The original user-set opaque_ref. */ AVBufferRef *user_opaque_ref; + + /** + * The callback to perform some delayed processing on the frame right + * before it is returned to the caller. + * + * @note This code is called at some unspecified point after the frame is + * returned from the decoder's decode/receive_frame call. Therefore it cannot rely + * on AVCodecContext being in any specific state, so it does not get to + * access AVCodecContext directly at all. All the state it needs must be + * stored in the post_process_opaque object. + */ + int (*post_process)(void *logctx, AVFrame *frame); + void *post_process_opaque; + void (*post_process_opaque_free)(void *opaque); } FrameDecodeData; /**