From patchwork Wed Aug 22 16:47:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 10056 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp1069231jap; Wed, 22 Aug 2018 09:54:13 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdah/brORKGQWgUdJ9a73KBC4/c96D/VdkFeyfiJPsHgHhd0zXTSJYyXIRAMZ4gajH63KmlD X-Received: by 2002:a1c:ec1b:: with SMTP id k27-v6mr2751314wmh.157.1534956853348; Wed, 22 Aug 2018 09:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534956853; cv=none; d=google.com; s=arc-20160816; b=bekdI1X/MQ5ts3+QK+EmvbxMYudpT33QZFY9vck6Qjv7Eu2bGqY0cU6h1kqKm7Ne4i TPxfeG4QkscLaBhEhV0W/jYN+e2tzneTtkiS09KmIe2oHOxvNY/STErOAR/lLq/fQh58 30RGdZOqqEFu/3PygROoqr8Bf84CaRwRJgnfrRYsUa8DaCo5i4/bDbKprA5MXV0tjtuj p21WYxwroyl2UubS7mdKc+516B+5/3o8X6o2mombVdCb2qwYPThIIY9Fqmp98c2cRWic /EX2Yd9/NjEvS82fCht3KABgHMmT+kWxSP+HicUeNkLEZo9RubRA2F0A9d9ArY28RlJP 4EZQ== 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:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=TH+nsjJQnVtVrB5jCSlRowAZ4BEMhdlUOHsnV/8SJ+E=; b=QDgM8qosOii7lLxv8By+5wEmuvl6nWuKkNlHBQU5na7LbttA1ffUFZ51FXM72GFvSe jfpcz8K7FiGtu43oLuM1ErKYIcJDoaM1NIsBrDqy73vGJ3qkGPFW5p1vGQleH+asa4Cx aUcL10bHakWL5uMtpScMv25r87KNLoJcXx60cGMF+UVvDg+p4mx0UfkdU2M0gcQasrz2 bI8HZIjRJba8ek/n7rKDSDHoarAO0tSLQWBf3Sp8x1VmhS0OlUuP7pYhu7MuH54FXMwL boLn6xexvBwoaF0xrjxAUjz0azpnrh6XaSgHLvga7kV+KUsD4ybvkoKPDz9JwlpOmNcV qXUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Nr0Vlvfa; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z14-v6si1517157wru.344.2018.08.22.09.54.12; Wed, 22 Aug 2018 09:54:13 -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=@gmail.com header.s=20161025 header.b=Nr0Vlvfa; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0148B689AF9; Wed, 22 Aug 2018 19:54:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 249AD680983 for ; Wed, 22 Aug 2018 19:54:04 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id t25-v6so2882786wmi.3 for ; Wed, 22 Aug 2018 09:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=ve6PNhzw9FAvVaGwdXFE1pu0ddJlLkcoYYFhRgKI1qg=; b=Nr0Vlvfa7tkq+lSls9ukWD72Z6Fnaznr/cY9QQWz4ywhXY2GtkPzbrhpbL5fNQOgWV iU2yW48MwFK95woCVRix4Q5tuv63BMZwdBwjwh+2J6GlzUl0RQ8xNxXCMI99p719mpHr 2ymvrrddLtkjSFSC00EtUMcruUFVGU0PCoG0D0tjOPOanVcM1t9nV4xE0mkz85ErUVe2 KZBkx770C2WGaiZGNzMKfQ4uBWM9lqv91mWunDJGR9JlFUdnwZSeeaNeHPUNilOJvDr3 uUZ7GDrGyDsnO6jWLY6pc8+/mk7yB3ftqkRP0KOIr+eWluDQqmI5R7U1we3pP1yASfWZ YjcQ== 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; bh=ve6PNhzw9FAvVaGwdXFE1pu0ddJlLkcoYYFhRgKI1qg=; b=Skqik4jPqYLxXpGvBB+t4z78Xlncl8FrqCiIzmciRYNDxv35t1xA4xSUYZoh5yyOcZ Vf9t+BQLWfP0fL7h5xYpsmk8sIuPnygW4FJWqiT71Yu0TyYIzlMWzN3iSq4Kz0lkbN+R gRJRskr4jag49W+pNdvagIPu7xfYMFykD+VTUJmKu394Uxbc0LsHamqM1VQFN7Y1U6Uq 5GVkNEXpi8OqehVqLQbWCpWiuy+U2n/GvyF6Ll1GfmzLeglXmU5b1WCysGju827DM1Uh 1cZCTMfM6xc4Wq96fxps34IUFAOz40Am9lvnql8jEManv0vGLi/qhY1wyABtIZMAJfNl QGDw== X-Gm-Message-State: APzg51DX/jJMej5poIlwjdb2eBavybmpBan+C5ySHslL1wh8RqzBiJoA eUHN2fzVi53tQUgsBmA0FZ5PMFib X-Received: by 2002:a1c:230f:: with SMTP id j15-v6mr2863610wmj.124.1534956477626; Wed, 22 Aug 2018 09:47:57 -0700 (PDT) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id o33-v6sm3353275wrf.11.2018.08.22.09.47.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 09:47:57 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Aug 2018 18:47:48 +0200 Message-Id: <20180822164748.26895-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avcodec/proresdec2: add frame threading support 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" Signed-off-by: Paul B Mahol --- libavcodec/proresdec2.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index b4ea6b5e03..d818e5d8da 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -36,6 +36,7 @@ #include "simple_idct.h" #include "proresdec.h" #include "proresdata.h" +#include "thread.h" static void permute(uint8_t *dst, const uint8_t *src, const uint8_t permutation[64]) { @@ -644,6 +645,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { ProresContext *ctx = avctx->priv_data; + ThreadFrame tframe = { .f = data }; AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; @@ -669,7 +671,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, buf += frame_hdr_size; buf_size -= frame_hdr_size; - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0) return ret; decode_picture: @@ -697,6 +699,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return avpkt->size; } +#if HAVE_THREADS +static int decode_init_thread_copy(AVCodecContext *avctx) +{ + ProresContext *ctx = avctx->priv_data; + + ctx->slices = NULL; + + return 0; +} +#endif + static av_cold int decode_close(AVCodecContext *avctx) { ProresContext *ctx = avctx->priv_data; @@ -713,7 +726,8 @@ AVCodec ff_prores_decoder = { .id = AV_CODEC_ID_PRORES, .priv_data_size = sizeof(ProresContext), .init = decode_init, + .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .close = decode_close, .decode = decode_frame, - .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, };