[FFmpeg-devel] [PATCH 10/20] swscale/output: add VYU444 output support

Michael Niedermayer michael at niedermayer.cc
Thu Oct 17 02:17:05 EEST 2024


On Wed, Oct 09, 2024 at 02:03:28PM -0300, James Almer wrote:
> On 10/8/2024 4:56 PM, Michael Niedermayer wrote:
> > On Mon, Oct 07, 2024 at 09:29:45AM -0300, James Almer wrote:
> > > Signed-off-by: James Almer <jamrial at gmail.com>
> > > ---
> > >   libswscale/output.c                      | 43 ++++++++++++++++++++++++
> > >   libswscale/utils.c                       |  2 +-
> > >   tests/ref/fate/filter-pixdesc-vyu444     |  1 +
> > >   tests/ref/fate/filter-pixfmts-copy       |  1 +
> > >   tests/ref/fate/filter-pixfmts-crop       |  1 +
> > >   tests/ref/fate/filter-pixfmts-field      |  1 +
> > >   tests/ref/fate/filter-pixfmts-fieldorder |  1 +
> > >   tests/ref/fate/filter-pixfmts-hflip      |  1 +
> > >   tests/ref/fate/filter-pixfmts-il         |  1 +
> > >   tests/ref/fate/filter-pixfmts-null       |  1 +
> > >   tests/ref/fate/filter-pixfmts-pad        |  1 +
> > >   tests/ref/fate/filter-pixfmts-scale      |  1 +
> > >   tests/ref/fate/filter-pixfmts-transpose  |  1 +
> > >   tests/ref/fate/filter-pixfmts-vflip      |  1 +
> > >   14 files changed, 56 insertions(+), 1 deletion(-)
> > >   create mode 100644 tests/ref/fate/filter-pixdesc-vyu444
> > > 
> > > diff --git a/libswscale/output.c b/libswscale/output.c
> > > index a11bedde95..6716cfad34 100644
> > > --- a/libswscale/output.c
> > > +++ b/libswscale/output.c
> > > @@ -2931,6 +2931,46 @@ yuv2uyva_X_c(SwsContext *c, const int16_t *lumFilter,
> > >       }
> > >   }
> > > +static void
> > > +yuv2vyu444_X_c(SwsContext *c, const int16_t *lumFilter,
> > > +               const int16_t **lumSrc, int lumFilterSize,
> > > +               const int16_t *chrFilter, const int16_t **chrUSrc,
> > > +               const int16_t **chrVSrc, int chrFilterSize,
> > > +               const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
> > > +{
> > > +    int i;
> > > +
> > > +    for (i = 0; i < dstW; i++) {
> > > +        int j;
> > > +        int Y = 1 << 18, U = 1 << 18;
> > > +        int V = 1 << 18;
> > > +
> > > +        for (j = 0; j < lumFilterSize; j++)
> > > +            Y += lumSrc[j][i] * lumFilter[j];
> > > +
> > > +        for (j = 0; j < chrFilterSize; j++)
> > > +            U += chrUSrc[j][i] * chrFilter[j];
> > > +
> > > +        for (j = 0; j < chrFilterSize; j++)
> > > +            V += chrVSrc[j][i] * chrFilter[j];
> > > +
> > > +        Y >>= 19;
> > > +        U >>= 19;
> > > +        V >>= 19;
> > > +
> > > +        if (Y  & 0x100)
> > > +            Y = av_clip_uint8(Y);
> > > +        if (U  & 0x100)
> > > +            U = av_clip_uint8(U);
> > > +        if (V  & 0x100)
> > > +            V = av_clip_uint8(V);
> > > +
> > > +        dest[3 * i    ] = V;
> > > +        dest[3 * i + 1] = Y;
> > > +        dest[3 * i + 2] = U;
> > > +    }
> > > +}
> > > +
> > >   #define output_pixel(pos, val, bits) \
> > >       AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift);
> > > @@ -3465,6 +3505,9 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
> > >           *yuv2packed2 = yuv2uyvy422_2_c;
> > >           *yuv2packedX = yuv2uyvy422_X_c;
> > >           break;
> > > +    case AV_PIX_FMT_VYU444:
> > > +        *yuv2packedX = yuv2vyu444_X_c;
> > > +        break;
> > 
> > does this work in the unscaled and 2 tap scaling cases ? (which would normally
> > use teh other 2pointers
> 
> I tried
> 
> ./ffmpeg.exe -noauto_conversion_filters -cpuflags 0 -f image2 -c:v pgmyuv -i
> ./tests/vsynth1/%02d.pgm -vf scale=sws_flags=bilinear,format=vyu444 -vcodec
> rawvideo -pix_fmt vyu444 -frames:v 1 -y out.nut
> 

> And it works (The output looks fine with ffplay). Is there some other way to
> test that?

is that command above actually scaling anything ? it looks like input and output
have t he same size

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241017/0fe5c0f6/attachment.sig>


More information about the ffmpeg-devel mailing list