From patchwork Fri Apr 30 03:07:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 27536 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2147003pxb; Thu, 29 Apr 2021 20:17:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNfVn0wpvDDda6aigA28s7Mj92I5+mEPL4/IvUXuRPyzsLRjtddP+TZG/O9SrKnTxLeQU9 X-Received: by 2002:a17:907:1183:: with SMTP id uz3mr1788910ejb.264.1619752633292; Thu, 29 Apr 2021 20:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619752633; cv=none; d=google.com; s=arc-20160816; b=bVB2quarXWAoCPEqB0Or1Pjf+Sc5ZrQwHbSYIjTIXLB34d2ZjFRJYMDaS/fgK73HEt oTdLlqLXv33A50t2bdTuiscQ68CGX9QQmmlV3JbEhTmQ+Tn9rNPWQGFtKbSY79Qqe3jF TgjiCkelSKUsleBqhRxPoqQCm7x3XdvCU+2viGpJjiEe0x/SGIDyvLbK0ksZC8lNBLYo fNiIUJ5usqNxGbZXZ2fJ7q6J8Z6DQ/3eObfot64ZQrDh9feVjqeYxM/VsE3ZJh5H32s7 N8UWbjdYDRlhUGLV2rSqzEq3LmA6JaIrLKmwfsOr0LyDzpLb1B7KAbpbl6tabBdfZt0V 9idQ== 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:ironport-sdr :ironport-sdr:delivered-to; bh=V6cq06/7eVVd1pReW4LfwY9HddFJzcRYSr0dRaEGEcs=; b=H1COeP9Ys5RHEacDYg2EP6sbwcFJKyJm/HeU5FJDL2B031nbSpW63ArPJA3ucFmWtD xLLpFii6XlEvWKsRQcBoY1iGTcF9YCxXsN4w2CxBW+4oEkdVJRw3tQJONIaXMJrg0pxg UKaNmVzpI6cZqPFQqSb9SwmjsRAtoC1E6gqS4mEBlv5qwEg1Q+N/7yAJjpjAmixJh6w9 ftVk4gsbptkSKnFU3/R+7Dpx/yu97IaH+aODuFIWZowrfZReGKcfjFcIG/E8ZnTxrhe+ 8u1fZpKtJkiOsbADQJQ8nrbyE8BJ75Bxe8We70PEJXNJWgfFPyjBQ3kP9Kks1Qw0o7g/ DIMA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a42si622927edf.438.2021.04.29.20.17.12; Thu, 29 Apr 2021 20:17: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; 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=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 342E4689C0A; Fri, 30 Apr 2021 06:17:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ADCA6689C0A for ; Fri, 30 Apr 2021 06:16:59 +0300 (EEST) IronPort-SDR: ztY4vQ3j15p94QgLp64OZ9V5K+14Q0J/K6Xkx7+vqfUAHcOtehoHmUAUDwvXBLiyWxAMcW5HOa BSufSi4dxb+Q== X-IronPort-AV: E=McAfee;i="6200,9189,9969"; a="184659709" X-IronPort-AV: E=Sophos;i="5.82,260,1613462400"; d="scan'208";a="184659709" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2021 20:16:56 -0700 IronPort-SDR: l+mRiV2XGImiB3LG6QseOY81alss5Hr3Ygxm903VxcmqP1xGM+ZvhrquAuB0kUATT6H3Qf/8Q7 RoDgyFjVqOlw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,260,1613462400"; d="scan'208";a="459152496" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.83]) by fmsmga002.fm.intel.com with ESMTP; 29 Apr 2021 20:16:55 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 11:07:08 +0800 Message-Id: <20210430030711.30216-1-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/4] dnn: add DCO_RGB color order to enum DNNColorOrder X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: RUxWxzRj96BB Adding DCO_RGB color order to DNNColorOrder, since tensorflow model needs this kind of color oder as input. Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_tf.c | 1 + libavfilter/dnn/dnn_io_proc.c | 14 +++++++++++--- libavfilter/dnn_interface.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 076dd3d6a9..f70e3d4659 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -143,6 +143,7 @@ static DNNReturnType get_input_tf(void *model, DNNData *input, const char *input tf_output.index = 0; input->dt = TF_OperationOutputType(tf_output); + input->order = DCO_RGB; status = TF_NewStatus(); TF_GraphGetTensorShape(tf_model->graph, tf_output, dims, 4, status); diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c index e104cc5064..5f6ce36b96 100644 --- a/libavfilter/dnn/dnn_io_proc.c +++ b/libavfilter/dnn/dnn_io_proc.c @@ -167,11 +167,19 @@ static DNNReturnType proc_from_frame_to_dnn_frameprocessing(AVFrame *frame, DNND static enum AVPixelFormat get_pixel_format(DNNData *data) { - if (data->dt == DNN_UINT8 && data->order == DCO_BGR) { - return AV_PIX_FMT_BGR24; + if (data->dt == DNN_UINT8) { + switch (data->order) { + case DCO_BGR: + return AV_PIX_FMT_BGR24; + case DCO_RGB: + return AV_PIX_FMT_RGB24; + default: + av_assert0(!"unsupported data pixel format.\n"); + return AV_PIX_FMT_BGR24; + } } - av_assert0(!"not supported yet.\n"); + av_assert0(!"unsupported data type.\n"); return AV_PIX_FMT_BGR24; } diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h index ae5a488341..92c3b0fc6e 100644 --- a/libavfilter/dnn_interface.h +++ b/libavfilter/dnn_interface.h @@ -39,6 +39,7 @@ typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType; typedef enum { DCO_NONE, DCO_BGR, + DCO_RGB, } DNNColorOrder; typedef enum {