History

swscale/utils: disable full_chr_h_input optimization for odd width

The basic problem here is that the rgb*ToUV_half_* functions hard-code a bilinear downsample from src[i] + src[i+1], with no bounds check on the i+1 access. Due to the signature of the function, we cannot easily plumb the "true" width into the function body to perform a bounds check. Similarly, we cannot easily pre-pad the input because it is typically reading from the (const) input frame, which would require a full memcpy to pad. Either of these solutions are more trouble than the feature is worth, so just disable it on odd input sizes.

Niklas Haas committed 1 year ago

Commit 2f95bc31 parent 79452d31 file · +1 −1Browse files

Unified · Split

libswscale/utils.c+1−1
@@ -1535,7 +1535,7 @@ av_cold int ff_sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter, · 1534 unmodified lines
15351535
15361536 /* drop every other pixel for chroma calculation unless user
15371537 * wants full chroma */
1538− if (isAnyRGB(srcFormat) && !(flags & SWS_FULL_CHR_H_INP) &&
1538+ if (isAnyRGB(srcFormat) && !(srcW & 1) && !(flags & SWS_FULL_CHR_H_INP) &&
15391539 srcFormat != AV_PIX_FMT_RGB8 && srcFormat != AV_PIX_FMT_BGR8 &&
15401540 srcFormat != AV_PIX_FMT_RGB4 && srcFormat != AV_PIX_FMT_BGR4 &&
15411541 srcFormat != AV_PIX_FMT_RGB4_BYTE && srcFormat != AV_PIX_FMT_BGR4_BYTE &&

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t