]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/av1_parse.h
hwcontext_vulkan: dlopen libvulkan
[ffmpeg] / libavcodec / av1_parse.h
index 0de619dbeca2ed65052cd462e4b6d881d6d5cfed..ae0ebb5a1850ade198c404e4c1d1faac99dedd3a 100644 (file)
@@ -27,6 +27,9 @@
 #include "avcodec.h"
 #include "get_bits.h"
 
+// OBU header fields + max leb128 length
+#define MAX_OBU_HEADER_SIZE (2 + 8)
+
 typedef struct AV1OBU {
     /** Size of payload */
     int size;
@@ -56,12 +59,13 @@ typedef struct AV1Packet {
     AV1OBU *obus;
     int nb_obus;
     int obus_allocated;
+    unsigned obus_allocated_size;
 } AV1Packet;
 
 /**
  * Extract an OBU from a raw bitstream.
  *
- * @note This function does not copy or store any bistream data. All
+ * @note This function does not copy or store any bitstream data. All
  *       the pointers in the AV1OBU structure will be valid as long
  *       as the input buffer also is.
  */
@@ -71,7 +75,7 @@ int ff_av1_extract_obu(AV1OBU *obu, const uint8_t *buf, int length,
 /**
  * Split an input packet into OBUs.
  *
- * @note This function does not copy or store any bistream data. All
+ * @note This function does not copy or store any bitstream data. All
  *       the pointers in the AV1Packet structure will be valid as
  *       long as the input buffer also is.
  */
@@ -104,7 +108,7 @@ static inline int parse_obu_header(const uint8_t *buf, int buf_size,
     int ret, extension_flag, has_size_flag;
     int64_t size;
 
-    ret = init_get_bits8(&gb, buf, FFMIN(buf_size, 2 + 8)); // OBU header fields + max leb128 length
+    ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_OBU_HEADER_SIZE));
     if (ret < 0)
         return ret;
 
@@ -134,8 +138,8 @@ static inline int parse_obu_header(const uint8_t *buf, int buf_size,
 
     size = *obu_size + *start_pos;
 
-    if (size > INT_MAX)
-        return AVERROR(ERANGE);
+    if (size > buf_size)
+        return AVERROR_INVALIDDATA;
 
     return size;
 }
@@ -145,7 +149,9 @@ static inline int get_obu_bit_length(const uint8_t *buf, int size, int type)
     int v;
 
     /* There are no trailing bits on these */
-    if (type == AV1_OBU_TILE_GROUP || type == AV1_OBU_FRAME) {
+    if (type == AV1_OBU_TILE_GROUP ||
+        type == AV1_OBU_TILE_LIST ||
+        type == AV1_OBU_FRAME) {
         if (size > INT_MAX / 8)
             return AVERROR(ERANGE);
         else