/* * AV1 common parsing code * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
// OBU header fields + max leb128 length #define MAX_OBU_HEADER_SIZE (2 + 8)
typedefstruct AV1OBU { /** Size of payload */ int size; const uint8_t *data;
/** * Size, in bits, of just the data, excluding the trailing_one_bit and * any trailing padding.
*/ int size_bits;
/** Size of entire OBU, including header */ int raw_size; const uint8_t *raw_data;
int type;
int temporal_id; int spatial_id;
} AV1OBU;
/** An input packet split into OBUs */ typedefstruct 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 bitstream data. All * the pointers in the AV1OBU structure will be valid as long * as the input buffer also is.
*/ int ff_av1_extract_obu(AV1OBU *obu, const uint8_t *buf, int length, void *logctx);
/** * Split an input packet into OBUs. * * @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 ff_av1_packet_split(AV1Packet *pkt, const uint8_t *buf, int length, void *logctx);
/** * Free all the allocated memory in the packet.
*/ void ff_av1_packet_uninit(AV1Packet *pkt);
staticinlineint parse_obu_header(const uint8_t *buf, int buf_size,
int64_t *obu_size, int *start_pos, int *type, int *temporal_id, int *spatial_id)
{
GetBitContext gb; int ret, extension_flag, has_size_flag;
int64_t size;
ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_OBU_HEADER_SIZE)); if (ret < 0) return ret;
if (get_bits1(&gb) != 0) // obu_forbidden_bit return AVERROR_INVALIDDATA;
if (get_bits_left(&gb) < 0) return AVERROR_INVALIDDATA;
*start_pos = get_bits_count(&gb) / 8;
size = *obu_size + *start_pos;
if (size > buf_size) return AVERROR_INVALIDDATA;
return size;
}
staticinlineint 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_TILE_LIST ||
type == AV1_OBU_FRAME) { if (size > INT_MAX / 8) return AVERROR(ERANGE); else return size * 8;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.