From patchwork Wed Sep 26 03:38:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tristan Matthews X-Patchwork-Id: 10482 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:1286:0:0:0:0:0 with SMTP id 6-v6csp236111jap; Tue, 25 Sep 2018 20:39:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV60gIctXQiIFYVfTFeduk2PKzWOu29oFjOICwvHh9dY5Tjoar8OeR7hZMEEfa0mC8vprWStK X-Received: by 2002:a1c:7301:: with SMTP id d1-v6mr2915633wmb.34.1537933142774; Tue, 25 Sep 2018 20:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537933142; cv=none; d=google.com; s=arc-20160816; b=pz0Z4WaV38xAgrtar2TvL4Vu6KcdY5p3NyZl9ArKzoN04/Fd1vX9JJu8YR1RRZGjbx Cun3KMymAZhyOiL4cH9i39BGyIr476N2yoUy7ano3eTEFia2AeXgvv4Do4mnRwy6AX89 xXTCT9v8hppNCDGsObBYZ9I5ZEWtoNKZL+saReHBVisCcpsgWVA5CMYsY7d1JY7fqIeG Qht1XFH7TIYTZMBnu6b1+UM9eYxUu8GPRWLM6og2QpMKoCiu/vXBWzgyUc3nb6cIVJHb AE26BOWOugPhrweBQKJQZ2pseYAL5oDqVDLdN+O0HL8d7Hu+lBSCidJWxHAtE54azijC DjvQ== 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:message-id:date:to:from:delivered-to; bh=q458NawIP/8NwZix6Y5xzU5MhHcvdbK8XxHn9aF4hbU=; b=YtMXida8Uyvl6oZ4ao5in/wZov9rPWfqb/tR+iQcAyahTVSp3AgYcIaIAdTNuZm6Ke XUYG+MdqVN+x3jMFx8bOnRGS2ztb7Yk7cMybxJVNzq9RLrILz4skfMoxmpA7wNevoCXG Uot33OlbLFaoxMJUi/G50pBpgnfB6tc3KH1smrQR5GVce+frvM8SveaV99mYliZU5nlq sJEhnYFgDbeXjbmdzdYnNm8AAhYjGRThBpLIgldXEoW2Hc2QZ87yBmz2UVUvfjtnEbL3 v5I/dcpUT0oorEEUBXT+srEfX0IOBXlCQZUDrMWAguEcV4KX3egTl+dDgk80VtxdKpa3 A4cw== ARC-Authentication-Results: i=1; mx.google.com; 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 v6-v6si3850456wrn.190.2018.09.25.20.39.01; Tue, 25 Sep 2018 20:39:02 -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; 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 E662D68A46F; Wed, 26 Sep 2018 06:38:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BC5868A0B6 for ; Wed, 26 Sep 2018 06:38:36 +0300 (EEST) Received: by mail-qk1-f194.google.com with SMTP id c13-v6so14668277qkm.4 for ; Tue, 25 Sep 2018 20:38:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pm1fZjhpMmO3hoYf5tzJAgl7myLsJ7oj2zQ5F4R7Z+w=; b=r5VorfjktsZovkA0ZNqr4qecLj5dxCNuYOJPbkaZsQ0LbZQbtKdS+BZmiyXh088nRY 3ooNyAywra6ynHnCQr/gnKh26FIEGibQuGBqtdgnAjAn33RYzHXdc1hkj8hKVgh+VTet IN+dhWEZZ7xc7x/1rC+dJ77EfeNhPUyLy8cR9kdSYQRis18rz7gwixRI6TNl173ILJDp ltRz4qMKfPfmKNEDEUFLs2lWcrdm9x+6J/ke6NkLXtn0nYJSaKAPtiT3ifBh+DDYyPXj st9+EZogNB6COp30BR8tpRXBLFCv+7nX15p0FzNBFWJdPS0ll716d/t53hZkr1UGQJ4h OqCQ== X-Gm-Message-State: ABuFfohLDimJZwP1Z9wyUlOnUOGdyrsvb9GwMdIJRNy73obvAOKDG1ID Aq81hUC5bvs8WwCAqXx9BJsXkwEtiaw= X-Received: by 2002:a37:8d06:: with SMTP id p6-v6mr2974090qkd.4.1537933131577; Tue, 25 Sep 2018 20:38:51 -0700 (PDT) Received: from bellini.lan (192-222-144-238.qc.cable.ebox.net. [192.222.144.238]) by smtp.gmail.com with ESMTPSA id k185-v6sm2206234qkd.27.2018.09.25.20.38.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 20:38:50 -0700 (PDT) From: Tristan Matthews To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Sep 2018 23:38:44 -0400 Message-Id: <20180926033844.15942-1-tmatth@videolan.org> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] libaomdec: add row_mt option 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: Tristan Matthews MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Partially fixes #7456 --- libavcodec/libaomdec.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c index 2530c9f76b..15cda2940a 100644 --- a/libavcodec/libaomdec.c +++ b/libavcodec/libaomdec.c @@ -23,20 +23,63 @@ * AV1 decoder support via libaom */ +#define AOM_DISABLE_CTRL_TYPECHECKS 1 #include #include #include "libavutil/common.h" #include "libavutil/imgutils.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "internal.h" #include "profiles.h" typedef struct AV1DecodeContext { + AVClass *class; struct aom_codec_ctx decoder; + int row_mt; } AV1DecodeContext; +static const char *const ctlidstr[] = { + [AV1D_SET_ROW_MT] = "AV1D_SET_ROW_MT", +}; + + +static av_cold void log_decoder_error(AVCodecContext *avctx, const char *desc) +{ + AV1DecodeContext *ctx = avctx->priv_data; + const char *error = aom_codec_error(&ctx->decoder); + const char *detail = aom_codec_error_detail(&ctx->decoder); + + av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error); + if (detail) + av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail); +} + +static av_cold int codecctl_int(AVCodecContext *avctx, + enum aom_dec_control_id id, int val) +{ + AV1DecodeContext *ctx = avctx->priv_data; + char buf[80]; + int width = -30; + int res; + + snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]); + av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, val); + + res = aom_codec_control(&ctx->decoder, id, val); + if (res != AOM_CODEC_OK) { + snprintf(buf, sizeof(buf), "Failed to set %s codec control", + ctlidstr[id]); + log_decoder_error(avctx, buf); + return AVERROR(EINVAL); + } + + return 0; +} + + static av_cold int aom_init(AVCodecContext *avctx, const struct aom_codec_iface *iface) { @@ -56,6 +99,10 @@ static av_cold int aom_init(AVCodecContext *avctx, return AVERROR(EINVAL); } + // codec control failures are currently treated only as warnings + av_log(avctx, AV_LOG_DEBUG, "aom_codec_control\n"); + codecctl_int(avctx, AV1D_SET_ROW_MT, ctx->row_mt); + return 0; } @@ -220,6 +267,20 @@ static av_cold int av1_init(AVCodecContext *avctx) return aom_init(avctx, &aom_codec_av1_dx_algo); } +#define OFFSET(x) offsetof(AV1DecodeContext, x) +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM +static const AVOption options[] = { + { "row-mt", "Enable row-based multithreading", OFFSET(row_mt), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, VD}, + { NULL }, +}; + +static const AVClass class_aom = { + .class_name = "libaom-av1 decoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_libaom_av1_decoder = { .name = "libaom-av1", .long_name = NULL_IF_CONFIG_SMALL("libaom AV1"), @@ -231,5 +292,6 @@ AVCodec ff_libaom_av1_decoder = { .decode = aom_decode, .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1, .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), + .priv_class = &class_aom, .wrapper_name = "libaom", };