diff mbox series

[FFmpeg-devel] yuv4mpegenc: add bitdepth multiplier after rounding width.

Message ID 20230417150010.64865-1-rsbultje@gmail.com
State Accepted
Commit 989ff02472acb0566416bca13a161793bc59f52e
Headers show
Series [FFmpeg-devel] yuv4mpegenc: add bitdepth multiplier after rounding width. | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Ronald S. Bultje April 17, 2023, 3 p.m. UTC
Fixes output of HBD odd-width chroma.
---
 libavformat/yuv4mpegenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ronald S. Bultje April 19, 2023, 1:51 p.m. UTC | #1
Hi,

On Mon, Apr 17, 2023 at 11:00 AM Ronald S. Bultje <rsbultje@gmail.com>
wrote:

> Fixes output of HBD odd-width chroma.
> ---
>  libavformat/yuv4mpegenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
> index fc6b08e0cd..2fa5ee2714 100644
> --- a/libavformat/yuv4mpegenc.c
> +++ b/libavformat/yuv4mpegenc.c
> @@ -195,13 +195,14 @@ static int yuv4_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>
>      /* The following code presumes all planes to be non-interleaved. */
>      for (int k = 0; k < desc->nb_components; k++) {
> -        int plane_height = height, plane_width = width *
> desc->comp[k].step;
> +        int plane_height = height, plane_width = width;
>          const uint8_t *ptr = frame->data[k];
>
>          if (desc->nb_components >= 3 && (k == 1 || k == 2)) { /* chroma?
> */
>              plane_width  = AV_CEIL_RSHIFT(plane_width,
> desc->log2_chroma_w);
>              plane_height = AV_CEIL_RSHIFT(plane_height,
> desc->log2_chroma_h);
>          }
> +        plane_width *= desc->comp[k].step;
>
>          for (int i = 0; i < plane_height; i++) {
>              avio_write(pb, ptr, plane_width);
> --
> 2.38.1
>

Applied.

Ronald
diff mbox series

Patch

diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
index fc6b08e0cd..2fa5ee2714 100644
--- a/libavformat/yuv4mpegenc.c
+++ b/libavformat/yuv4mpegenc.c
@@ -195,13 +195,14 @@  static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
 
     /* The following code presumes all planes to be non-interleaved. */
     for (int k = 0; k < desc->nb_components; k++) {
-        int plane_height = height, plane_width = width * desc->comp[k].step;
+        int plane_height = height, plane_width = width;
         const uint8_t *ptr = frame->data[k];
 
         if (desc->nb_components >= 3 && (k == 1 || k == 2)) { /* chroma? */
             plane_width  = AV_CEIL_RSHIFT(plane_width,  desc->log2_chroma_w);
             plane_height = AV_CEIL_RSHIFT(plane_height, desc->log2_chroma_h);
         }
+        plane_width *= desc->comp[k].step;
 
         for (int i = 0; i < plane_height; i++) {
             avio_write(pb, ptr, plane_width);