[FFmpeg-cvslog] vaapi_encode_h265: Reduce SAR to valid range

Mark Thompson git at videolan.org
Sun Nov 18 23:38:55 EET 2018


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Sun Oct 28 17:13:54 2018 +0000| [80ce23da6533d37d2d6ec27c9132060451af892a] | committer: Mark Thompson

vaapi_encode_h265: Reduce SAR to valid range

Matching previous commit for H.264.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=80ce23da6533d37d2d6ec27c9132060451af892a
---

 libavcodec/vaapi_encode_h265.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 367fa5fde2..8d715f6e93 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -472,18 +472,20 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
             {  80, 33 }, {  18, 11 }, {  15, 11 }, {  64, 33 },
             { 160, 99 }, {   4,  3 }, {   3,  2 }, {   2,  1 },
         };
-        int i;
+        int num, den, i;
+        av_reduce(&num, &den, avctx->sample_aspect_ratio.num,
+                  avctx->sample_aspect_ratio.den, 65535);
         for (i = 0; i < FF_ARRAY_ELEMS(sar_idc); i++) {
-            if (avctx->sample_aspect_ratio.num == sar_idc[i].num &&
-                avctx->sample_aspect_ratio.den == sar_idc[i].den) {
+            if (num == sar_idc[i].num &&
+                den == sar_idc[i].den) {
                 vui->aspect_ratio_idc = i;
                 break;
             }
         }
         if (i >= FF_ARRAY_ELEMS(sar_idc)) {
             vui->aspect_ratio_idc = 255;
-            vui->sar_width  = avctx->sample_aspect_ratio.num;
-            vui->sar_height = avctx->sample_aspect_ratio.den;
+            vui->sar_width  = num;
+            vui->sar_height = den;
         }
         vui->aspect_ratio_info_present_flag = 1;
     }



More information about the ffmpeg-cvslog mailing list