---
 libavcodec/mjpegdec.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index b1192c5..1e5dd68 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1212,14 +1212,18 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
 //    len -= 2;
 
     if (id == AV_RL32("JFIF")) {
-        int t_w, t_h, v1, v2;
+        int t_w, t_h, v1, v2, res_units;
         skip_bits(&s->gb, 8); /* the trailing zero-byte */
         v1 = get_bits(&s->gb, 8);
         v2 = get_bits(&s->gb, 8);
-        skip_bits(&s->gb, 8);
 
-        s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 16);
-        s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 16);
+        res_units = get_bits(&s->gb, 8);
+        if (!res_units) {
+            s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 16);
+            s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 16);
+        } else {
+            skip_bits_long(&s->gb, 32);
+        }
 
         if (s->avctx->debug & FF_DEBUG_PICT_INFO)
             av_log(s->avctx, AV_LOG_INFO,
-- 
1.8.1.2

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to