[FFmpeg-cvslog] dnn: add DCO_RGB color order to enum DNNColorOrder

Ting Fu git at videolan.org
Tue May 11 05:55:10 EEST 2021


ffmpeg | branch: master | Ting Fu <ting.fu at intel.com> | Thu May  6 16:46:07 2021 +0800| [f02928eb5a75b2ee20dd94c30304f44a7d6f8de1] | committer: Guo, Yejun

dnn: add DCO_RGB color order to enum DNNColorOrder

Adding DCO_RGB color order to DNNColorOrder, since tensorflow model
needs this kind of color oder as input.

Signed-off-by: Ting Fu <ting.fu at intel.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f02928eb5a75b2ee20dd94c30304f44a7d6f8de1
---

 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 03fe310b03..45da29ae70 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 5f60d68078..1e2bef3f9a 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -168,11 +168,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 799244ee14..5e9ffeb077 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 {



More information about the ffmpeg-cvslog mailing list