diff mbox series

[FFmpeg-devel] avcodec/libaomdec: Set SAR based on RenderWidth and RenderHeight

Message ID 20200821152911.394589-1-derek.buitenhuis@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel] avcodec/libaomdec: Set SAR based on RenderWidth and RenderHeight | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Derek Buitenhuis Aug. 21, 2020, 3:29 p.m. UTC
This is the same thing we do in libdav1d.c

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
---
 libavcodec/libaomdec.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

James Almer Aug. 21, 2020, 4:36 p.m. UTC | #1
On 8/21/2020 12:29 PM, Derek Buitenhuis wrote:
> This is the same thing we do in libdav1d.c
> 
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
> ---
>  libavcodec/libaomdec.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
> index a72ac984e7..1b0f35936e 100644
> --- a/libavcodec/libaomdec.c
> +++ b/libavcodec/libaomdec.c
> @@ -197,6 +197,13 @@ static int aom_decode(AVCodecContext *avctx, void *data, int *got_frame,
>          }
>          if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
>              return ret;
> +        
> +        av_reduce(&picture->sample_aspect_ratio.num,
> +                  &picture->sample_aspect_ratio.den,
> +                  picture->height * img->r_w,
> +                  picture->width * img->r_h,
> +                  INT_MAX);

Should probably also add a ff_set_sar(avctx,
picture->sample_aspect_ratio) call after this. I'll do the same for
libdav1d.

LGTM in any case.

> +
>          if ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) && img->bit_depth == 8)
>              image_copy_16_to_8(picture, img);
>          else
>
Derek Buitenhuis Aug. 21, 2020, 10:59 p.m. UTC | #2
On 21/08/2020 17:36, James Almer wrote:
> Should probably also add a ff_set_sar(avctx,
> picture->sample_aspect_ratio) call after this. I'll do the same for
> libdav1d.
> 
> LGTM in any case.

Done and pushed.

- Derek
diff mbox series

Patch

diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
index a72ac984e7..1b0f35936e 100644
--- a/libavcodec/libaomdec.c
+++ b/libavcodec/libaomdec.c
@@ -197,6 +197,13 @@  static int aom_decode(AVCodecContext *avctx, void *data, int *got_frame,
         }
         if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
             return ret;
+        
+        av_reduce(&picture->sample_aspect_ratio.num,
+                  &picture->sample_aspect_ratio.den,
+                  picture->height * img->r_w,
+                  picture->width * img->r_h,
+                  INT_MAX);
+
         if ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) && img->bit_depth == 8)
             image_copy_16_to_8(picture, img);
         else