From: Chitra Dey Sarkar via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: Chitra Dey Sarkar <Chitra.Dey@microsoft.com> Subject: [FFmpeg-devel] libswscale.c : ff_xyz12Torgb48 expensive unaligned 16 byte accesses Date: Mon, 26 May 2025 00:44:13 +0000 Message-ID: <DM4PR21MB461911571585877FFEEE236E9265A@DM4PR21MB4619.namprd21.prod.outlook.com> (raw) In-Reply-To: <DM4PR21MB46198B14FF74B677790A8459929AA@DM4PR21MB4619.namprd21.prod.outlook.com> H We have been profiling FFmpeg at Microsoft and have identified that ff_xyz12ToRgb48 has a high sample count ( profiled every 1ms ) It seems like ff_xyz12ToRgb48 has performance penalty for 1. Unaligned read and write access 2. Access to xyz2rgb_matrix 3. Multiplication I would be interested in optimizing this code , wanted to check if there is an existing optimized version of this function, or any recommended approach to improve it(? I can move the repeated access to xyz2rgb_matrix outside the inner loop and load a full cache line at once to extract the X, Y, and Z values more efficiently-but I wanted to start by getting some initial feedback or thoughts before proceeding further File : FFmpeg/libswscale/swscale.c at a79720e10f30e9fd18bd78242ce96dde06461343 * FFmpeg/FFmpeg<https://github.com/FFmpeg/FFmpeg/blob/a79720e10f30e9fd18bd78242ce96dde06461343/libswscale/swscale.c#L739> void ff_xyz12Torgb48(const SwsInternal *c, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h) { .......... Unaligned read ....................... x = AV_RL16(src16 + xp + 0); y = AV_RL16(src16 + xp + 1); z = AV_RL16(src16 + xp + 2); .......... DRAM Access and multiply ....................... // convert from XYZlinear to sRGBlinear r = c->xyz2rgb_matrix[0][0] * x + c->xyz2rgb_matrix[0][1] * y + c->xyz2rgb_matrix[0][2] * z >> 12; g = c->xyz2rgb_matrix[1][0] * x + c->xyz2rgb_matrix[1][1] * y + c->xyz2rgb_matrix[1][2] * z >> 12; b = c->xyz2rgb_matrix[2][0] * x + c->xyz2rgb_matrix[2][1] * y + c->xyz2rgb_matrix[2][2] * z >> 12; .......... RMW Access ....................... AV_WL16(dst16 + xp + 0, c->rgbgamma[r] << 4); AV_WL16(dst16 + xp + 1, c->rgbgamma[g] << 4); AV_WL16(dst16 + xp + 2, c->rgbgamma[b] << 4); Regards Chitra _______________________________________________ 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 parent reply other threads:[~2025-05-26 0:44 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <DM4PR21MB46198B14FF74B677790A8459929AA@DM4PR21MB4619.namprd21.prod.outlook.com> 2025-05-26 0:44 ` Chitra Dey Sarkar via ffmpeg-devel [this message] 2025-05-26 0:58 ` James Almer
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=DM4PR21MB461911571585877FFEEE236E9265A@DM4PR21MB4619.namprd21.prod.outlook.com \ --to=ffmpeg-devel@ffmpeg.org \ --cc=Chitra.Dey@microsoft.com \ /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