Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avfilter: Refactor vf_psnr sse_line
@ 2023-04-14 17:32 Suraj Shirvankar
  0 siblings, 0 replies; 2+ messages in thread
From: Suraj Shirvankar @ 2023-04-14 17:32 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Suraj Shirvankar

Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
---
 libavfilter/vf_psnr.c | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 15cde7e8c8..a0c673831d 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -59,7 +59,7 @@ typedef struct PSNRContext {
 } PSNRContext;
 
 #define OFFSET(x) offsetof(PSNRContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption psnr_options[] = {
     {"stats_file", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
@@ -81,31 +81,26 @@ static inline double get_psnr(double mse, uint64_t nb_frames, int max)
     return 10.0 * log10(pow_2(max) / (mse / nb_frames));
 }
 
-static uint64_t sse_line_8bit(const uint8_t *main_line,  const uint8_t *ref_line, int outw)
-{
-    int j;
-    unsigned m2 = 0;
-
-    for (j = 0; j < outw; j++)
-        m2 += pow_2(main_line[j] - ref_line[j]);
+#define SSE_LINE(name, type)                                            \
+    static uint64_t sse_line_##name(const uint8_t *_main_line,          \
+                                    const uint8_t *_ref_line, int outw) \
+    {                                                                   \
+        int j;                                                          \
+        uint64_t m2 = 0;                                                \
+        const type *main_line = (const type *)_main_line;               \
+        const type *ref_line = (const type *)_ref_line;                 \
+                                                                        \
+        for (j = 0; j < outw; j++)                                      \
+            m2 += pow_2(main_line[j] - ref_line[j]);                    \
+                                                                        \
+        return m2;                                                      \
+    }
 
-    return m2;
-}
+SSE_LINE(8bit, uint8_t)
+SSE_LINE(16bit, uint16_t)
 
-static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_line, int outw)
+typedef struct ThreadData
 {
-    int j;
-    uint64_t m2 = 0;
-    const uint16_t *main_line = (const uint16_t *) _main_line;
-    const uint16_t *ref_line = (const uint16_t *) _ref_line;
-
-    for (j = 0; j < outw; j++)
-        m2 += pow_2(main_line[j] - ref_line[j]);
-
-    return m2;
-}
-
-typedef struct ThreadData {
     const uint8_t *main_data[4];
     const uint8_t *ref_data[4];
     int main_linesize[4];
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [FFmpeg-devel] [PATCH] avfilter: Refactor vf_psnr sse_line
@ 2023-04-14 16:30 Suraj Shirvankar
  0 siblings, 0 replies; 2+ messages in thread
From: Suraj Shirvankar @ 2023-04-14 16:30 UTC (permalink / raw)
  To: ffmpeg-devel

Small refactor to psnr

Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
---
  libavfilter/vf_psnr.c | 41 ++++++++++++++++++-----------------------
  1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 15cde7e8c8..a0c673831d 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -59,7 +59,7 @@ typedef struct PSNRContext {
  } PSNRContext;
   #define OFFSET(x) offsetof(PSNRContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
   static const AVOption psnr_options[] = {
      {"stats_file", "Set file where to store per-frame difference 
information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 
0, 0, FLAGS },
@@ -81,31 +81,26 @@ static inline double get_psnr(double mse, uint64_t 
nb_frames, int max)
      return 10.0 * log10(pow_2(max) / (mse / nb_frames));
  }
  -static uint64_t sse_line_8bit(const uint8_t *main_line,  const 
uint8_t *ref_line, int outw)
-{
-    int j;
-    unsigned m2 = 0;
-
-    for (j = 0; j < outw; j++)
-        m2 += pow_2(main_line[j] - ref_line[j]);
+#define SSE_LINE(name, type)                                            \
+    static uint64_t sse_line_##name(const uint8_t *_main_line,          \
+                                    const uint8_t *_ref_line, int outw) \
+    {                                                                   \
+        int j;                                                          \
+        uint64_t m2 = 0;                                                \
+        const type *main_line = (const type *)_main_line;               \
+        const type *ref_line = (const type *)_ref_line;                 \
+                                                                        \
+        for (j = 0; j < outw; j++)                                      \
+            m2 += pow_2(main_line[j] - ref_line[j]);                    \
+                                                                        \
+        return m2;                                                      \
+    }
  -    return m2;
-}
+SSE_LINE(8bit, uint8_t)
+SSE_LINE(16bit, uint16_t)
  -static uint64_t sse_line_16bit(const uint8_t *_main_line, const 
uint8_t *_ref_line, int outw)
+typedef struct ThreadData
  {
-    int j;
-    uint64_t m2 = 0;
-    const uint16_t *main_line = (const uint16_t *) _main_line;
-    const uint16_t *ref_line = (const uint16_t *) _ref_line;
-
-    for (j = 0; j < outw; j++)
-        m2 += pow_2(main_line[j] - ref_line[j]);
-
-    return m2;
-}
-
-typedef struct ThreadData {
      const uint8_t *main_data[4];
      const uint8_t *ref_data[4];
      int main_linesize[4];
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-14 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 17:32 [FFmpeg-devel] [PATCH] avfilter: Refactor vf_psnr sse_line Suraj Shirvankar
  -- strict thread matches above, loose matches on Subject: below --
2023-04-14 16:30 Suraj Shirvankar

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git