]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ituh263dec.c
qsv: Load the hw hevc plugin by default on Linux
[ffmpeg] / libavcodec / ituh263dec.c
index b1da22f6559bd2b64151ad544d2461714540dd87..ca0dd2c0d957aff43fc65fa7d7736e3656f9b83d 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * ITU H263 bitstream decoder
+ * ITU H.263 bitstream decoder
  * Copyright (c) 2000,2001 Fabrice Bellard
- * H263+ support.
+ * H.263+ support.
  * Copyright (c) 2001 Juan J. Sierralta P
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  *
 
 /**
  * @file
- * h263 decoder.
+ * H.263 decoder.
  */
 
 #include <limits.h>
 
 #include "libavutil/attributes.h"
+#include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
 #include "avcodec.h"
@@ -39,7 +40,7 @@
 #include "internal.h"
 #include "mathops.h"
 #include "mpegutils.h"
-#include "unary.h"
+#include "unary_legacy.h"
 #include "flv.h"
 #include "rv10.h"
 #include "mpeg4video.h"
@@ -297,7 +298,7 @@ int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code)
     if (!s->h263_long_vectors) {
         val = sign_extend(val, 5 + f_code);
     } else {
-        /* horrible h263 long vector mode */
+        /* horrible H.263 long vector mode */
         if (pred < -31 && val < -63)
             val += 64;
         if (pred > 32 && val > 63)
@@ -865,10 +866,10 @@ end:
     return SLICE_OK;
 }
 
-/* most is hardcoded. should extend to handle all h263 streams */
+/* Most is hardcoded; should extend to handle all H.263 streams. */
 int ff_h263_decode_picture_header(MpegEncContext *s)
 {
-    int format, width, height, i;
+    int format, width, height, i, ret;
     uint32_t startcode;
 
     align_get_bits(&s->gb);
@@ -899,8 +900,8 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
         return -1;
     }
     if (get_bits1(&s->gb) != 0) {
-        av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
-        return -1;      /* h263 id */
+        av_log(s->avctx, AV_LOG_ERROR, "Bad H.263 id\n");
+        return -1;      /* H.263 id */
     }
     skip_bits1(&s->gb);         /* split screen off */
     skip_bits1(&s->gb);         /* camera  off */
@@ -919,15 +920,13 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
         /* H.263v1 */
         width = ff_h263_format[format][0];
         height = ff_h263_format[format][1];
-        if (!width)
-            return -1;
 
         s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);
 
         s->h263_long_vectors = get_bits1(&s->gb);
 
         if (get_bits1(&s->gb) != 0) {
-            av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
+            av_log(s->avctx, AV_LOG_ERROR, "H.263 SAC not supported\n");
             return -1; /* SAC: off */
         }
         s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
@@ -1018,7 +1017,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
                 height = get_bits(&s->gb, 9) * 4;
                 ff_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
                 if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
-                    /* aspected dimensions */
+                    /* expected dimensions */
                     s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
                     s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
                 }else{
@@ -1073,6 +1072,9 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
         s->qscale = get_bits(&s->gb, 5);
     }
 
+    if ((ret = av_image_check_size(s->width, s->height, 0, s)) < 0)
+        return ret;
+
     s->mb_width = (s->width  + 15) / 16;
     s->mb_height = (s->height  + 15) / 16;
     s->mb_num = s->mb_width * s->mb_height;