[FFmpeg-devel] [PATCH] avcodec/libjxlenc: support negative linesizes

Tomas Härdin git at haerdin.se
Tue Jan 30 11:34:38 EET 2024


mån 2024-01-29 klockan 19:37 -0500 skrev Leo Izen:
> libjxl doesn't support negative strides, but JPEG XL has an
> orientation
> flag inside the codestream. We can use this to work around the
> library
> limitation, by taking the absolute value of the negative row stride,
> sending the image up-side-down, and telling the library that the
> image
> has a vertical-flip orientation.

Coincidentally we were just talking about negative stride on IRC
yesterday.

>      jxl_fmt.endianness = JXL_NATIVE_ENDIAN;
> -    jxl_fmt.align = frame->linesize[0];
> +    if (frame->linesize[0] >= 0) {
> +        jxl_fmt.align = frame->linesize[0];
> +        data = frame->data[0];
> +    } else {
> +        jxl_fmt.align = -frame->linesize[0];
> +        data = frame->data[0] - jxl_fmt.align * (info.ysize - 1);

Looks correct

/Tomas


More information about the ffmpeg-devel mailing list