[FFmpeg-devel] swscale/unscaled : add grayf32 bswap and rename packed_16bpc_bswap
Michael Niedermayer
michael at niedermayer.cc
Sun Oct 21 19:13:40 EEST 2018
On Sat, Oct 20, 2018 at 10:26:43PM +0200, Martin Vignali wrote:
> Hello,
>
> 001 : add unscaled grayf32 bswap func
> similar to packed_16bpc_bswap processing
>
> 002 : rename packed_16bpc_bswap func to bswap_16bpc
> this func is used for planar and packed bswap16
>
> Martin
[...]
> swscale_unscaled.c | 34 +++++++++++++++++++++++++++++++++-
> utils.c | 4 +---
> 2 files changed, 34 insertions(+), 4 deletions(-)
> 455f5d4fc8f8bd50ac8ff9ed254842ef9b53b63a 0001-swscale-swscale_unscaled-add-grayf32-le-to-be.patch
> From b8fee3940071e48861499b053a1b82cd6ed5a07e Mon Sep 17 00:00:00 2001
> From: Martin Vignali <martin.vignali at gmail.com>
> Date: Sat, 20 Oct 2018 21:58:58 +0200
> Subject: [PATCH 1/2] swscale/swscale_unscaled : add grayf32 le to be
>
> ---
> libswscale/swscale_unscaled.c | 34 +++++++++++++++++++++++++++++++++-
> libswscale/utils.c | 4 +---
> 2 files changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
> index 4b3cd71e90..18b2608205 100644
> --- a/libswscale/swscale_unscaled.c
> +++ b/libswscale/swscale_unscaled.c
> @@ -450,6 +450,33 @@ static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[],
> return srcSliceH;
> }
>
> +static int bswap_32bpc(SwsContext *c, const uint8_t *src[],
> + int srcStride[], int srcSliceY, int srcSliceH,
> + uint8_t *dst[], int dstStride[])
> +{
> + int i, j, p;
> +
> + for (p = 0; p < 4; p++) {
> + int srcstr = srcStride[p] / 4;
> + int dststr = dstStride[p] / 4;
> + uint32_t *dstPtr = (uint32_t *) dst[p];
> + const uint32_t *srcPtr = (const uint32_t *) src[p];
> + int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
> + if(!dstPtr || !srcPtr)
> + continue;
> + dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
> + for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
> + for (j = 0; j < min_stride; j++) {
> + dstPtr[j] = av_bswap32(srcPtr[j]);
stride can be arbitrary larger than the area of memory
of a line of an image, in fact it can theoretically be smaller too for the
source. You need to use the width not the stride
> + }
> + srcPtr += srcstr;
> + dstPtr += dststr;
> + }
> + }
> +
> + return srcSliceH;
> +}
> +
> static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
> int srcSliceY, int srcSliceH, uint8_t *dst[],
> int dstStride[])
> @@ -2017,6 +2044,10 @@ void ff_get_unscaled_swscale(SwsContext *c)
> IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P16))
> c->swscale = packed_16bpc_bswap;
>
> + /* bswap 32 */
> + if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAYF32))
> + c->swscale = bswap_32bpc;
> +
> if (usePal(srcFormat) && isByteRGB(dstFormat))
> c->swscale = palToRgbWrapper;
>
> @@ -2063,7 +2094,8 @@ void ff_get_unscaled_swscale(SwsContext *c)
> if ( srcFormat == dstFormat ||
> (srcFormat == AV_PIX_FMT_YUVA420P && dstFormat == AV_PIX_FMT_YUV420P) ||
> (srcFormat == AV_PIX_FMT_YUV420P && dstFormat == AV_PIX_FMT_YUVA420P) ||
> - (isFloat(srcFormat) == isFloat(dstFormat)) && ((isPlanarYUV(srcFormat) && isPlanarGray(dstFormat)) ||
> + !isFloat(srcFormat) && !isFloat(dstFormat) &&
> + ((isPlanarYUV(srcFormat) && isPlanarGray(dstFormat)) ||
> (isPlanarYUV(dstFormat) && isPlanarGray(srcFormat)) ||
> (isPlanarGray(dstFormat) && isPlanarGray(srcFormat)) ||
> (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
> diff --git a/libswscale/utils.c b/libswscale/utils.c
> index cb40164a95..cbba67c4db 100644
> --- a/libswscale/utils.c
> +++ b/libswscale/utils.c
> @@ -1809,9 +1809,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
>
> /* unscaled special cases */
> if (unscaled && !usesHFilter && !usesVFilter &&
> - (c->srcRange == c->dstRange || isAnyRGB(dstFormat) ||
> - srcFormat == AV_PIX_FMT_GRAYF32 && dstFormat == AV_PIX_FMT_GRAY8 ||
> - srcFormat == AV_PIX_FMT_GRAY8 && dstFormat == AV_PIX_FMT_GRAYF32)) {
> + (c->srcRange == c->dstRange || isAnyRGB(dstFormat))) {
> ff_get_unscaled_swscale(c);
>
> if (c->swscale) {
What is the intend of the 2 hunks above ?
These seem to remove cases, while the commit message says a case is added
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20181021/66e12629/attachment.sig>
More information about the ffmpeg-devel
mailing list