From: Suraj Shirvankar <surajshirvankar@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] vf_psnr: Refactor vf_psnr sse_line
Date: Fri, 14 Apr 2023 17:58:59 +0200
Message-ID: <260ab8b9-ddbe-c933-9a08-3420c4a02189@gmail.com> (raw)
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".
reply other threads:[~2023-04-14 15:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=260ab8b9-ddbe-c933-9a08-3420c4a02189@gmail.com \
--to=surajshirvankar@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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