#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;
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.
*/
/**
* 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.
*/
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;
size = *obu_size + *start_pos;
- if (size > INT_MAX)
- return AVERROR(ERANGE);
+ if (size > buf_size)
+ return AVERROR_INVALIDDATA;
return size;
}
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