From: Suraj Shirvankar <surajshirvankar@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avfilter: Refactor vf_psnr sse_line Date: Fri, 14 Apr 2023 18:30:04 +0200 Message-ID: <817ffb0b-b08f-ee24-9085-0e7ea483a7f2@gmail.com> (raw) 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".
next reply other threads:[~2023-04-14 16:30 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-04-14 16:30 Suraj Shirvankar [this message] 2023-04-14 17:32 Suraj Shirvankar
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=817ffb0b-b08f-ee24-9085-0e7ea483a7f2@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