Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavcodec / libaom.c
similarity index 50%
rename from libavfilter/dnn/dnn_backend_native_layer_maximum.h
rename to libavcodec/libaom.c
index 523acbe..0befaaa 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * Copyright (c) 2019 Guo Yejun
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
 
 /**
  * @file
- * DNN inference functions interface for native backend.
+ * AOM common functions
  */
 
+#include "libavutil/pixdesc.h"
+#include "libaom.h"
 
-#ifndef AVFILTER_DNN_DNN_BACKEND_NATIVE_LAYER_MAXIMUM_H
-#define AVFILTER_DNN_DNN_BACKEND_NATIVE_LAYER_MAXIMUM_H
-
-#include "libavformat/avio.h"
-#include "dnn_backend_native.h"
+void ff_aom_image_copy_16_to_8(AVFrame *pic, struct aom_image *img)
+{
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format);
+    int i;
 
-typedef struct DnnLayerMaximumParams{
-    union {
-        uint32_t u32;
-        float y;
-    }val;
-} DnnLayerMaximumParams;
+    for (i = 0; i < desc->nb_components; i++) {
+        int w = img->d_w;
+        int h = img->d_h;
+        int x, y;
 
-int ff_dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num);
-int ff_dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes,
-                                 int32_t output_operand_index, const void *parameters, NativeContext *ctx);
+        if (i) {
+            w = (w + img->x_chroma_shift) >> img->x_chroma_shift;
+            h = (h + img->y_chroma_shift) >> img->y_chroma_shift;
+        }
 
-#endif
+        for (y = 0; y < h; y++) {
+            uint16_t *src = (uint16_t *)(img->planes[i] + y * img->stride[i]);
+            uint8_t *dst = pic->data[i] + y * pic->linesize[i];
+            for (x = 0; x < w; x++)
+                *dst++ = *src++;
+        }
+    }
+}