ffmpeg | branch: master | James Almer <jamr...@gmail.com> | Fri Mar 14 22:14:19 2025 -0300| [63fa1f52b9c4b37ebf7661a9851acf3ba71db303] | committer: James Almer
swscale/swscale_unscaled: make the fast planar copy path work with more formats dst_depth - src_depth where the result is 6 or 7 in a high bd path means this is only executed for 16 -> 10 and 16 -> 9. This patch makes this path general, supporting arbitrary formats as long as dst_depth > src_depth > 8. Signed-off-by: James Almer <jamr...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63fa1f52b9c4b37ebf7661a9851acf3ba71db303 --- libswscale/swscale_unscaled.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 92d5386567..1df160daaa 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -2267,42 +2267,34 @@ static int planarCopyWrapper(SwsInternal *c, const uint8_t *const src[], srcPtr += srcStride[plane]; } } else if (src_depth <= dst_depth) { + unsigned shift = dst_depth - src_depth; for (i = 0; i < height; i++) { j = 0; if(isBE(c->opts.src_format) == HAVE_BIGENDIAN && isBE(c->opts.dst_format) == HAVE_BIGENDIAN && shiftonly) { - unsigned shift = dst_depth - src_depth; #if HAVE_FAST_64BIT -#define FAST_COPY_UP(shift) \ - for (; j < length - 3; j += 4) { \ - uint64_t v = AV_RN64A(srcPtr2 + j) >> src_shift; \ - AV_WN64A(dstPtr2 + j, v << shift); \ - } + for (; j < length - 3; j += 4) { + uint64_t v = AV_RN64A(srcPtr2 + j) >> src_shift; + AV_WN64A(dstPtr2 + j, (v << shift) << dst_shift); + } #else -#define FAST_COPY_UP(shift) \ - for (; j < length - 1; j += 2) { \ - uint32_t v = AV_RN32A(srcPtr2 + j) >> src_shift; \ - AV_WN32A(dstPtr2 + j, v << shift); \ - } + for (; j < length - 1; j += 2) { + uint32_t v = AV_RN32A(srcPtr2 + j) >> src_shift; + AV_WN32A(dstPtr2 + j, (v << shift) << dst_shift); + } #endif - switch (shift) - { - case 6: FAST_COPY_UP(6); break; - case 7: FAST_COPY_UP(7); break; - } } #define COPY_UP(r,w) \ if(shiftonly){\ for (; j < length; j++){ \ unsigned int v= r(&srcPtr2[j]) >> src_shift;\ - w(&dstPtr2[j], (v << (dst_depth-src_depth)) << dst_shift);\ + w(&dstPtr2[j], (v << shift) << dst_shift);\ }\ }else{\ for (; j < length; j++){ \ unsigned int v= r(&srcPtr2[j]) >> src_shift;\ - w(&dstPtr2[j], ((v<<(dst_depth-src_depth)) | \ - (v>>(2*src_depth-dst_depth))) << dst_shift);\ + w(&dstPtr2[j], ((v << shift) | (v>>(2*src_depth-dst_depth))) << dst_shift);\ }\ } if(isBE(c->opts.src_format)){ _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".