diff options
author | James Almer <jamrial@gmail.com> | 2023-06-20 10:31:24 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2023-06-21 13:31:14 -0300 |
commit | c7183a22dbc34d02016d92bd19b06a2e665861df (patch) | |
tree | 896acbdaf556f9a958c2dfae1f715203ebb9b519 /libavformat/evc.h | |
parent | e5da2ec456d6ef8e6b68da431a190d7edc1b52ff (diff) | |
download | ffmpeg-c7183a22dbc34d02016d92bd19b06a2e665861df.tar.gz |
avformat/evc: move NALU length and type parsing functions to a header
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/evc.h')
-rw-r--r-- | libavformat/evc.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libavformat/evc.h b/libavformat/evc.h index db56275fd8..46b27f7df7 100644 --- a/libavformat/evc.h +++ b/libavformat/evc.h @@ -24,9 +24,39 @@ #include <stdint.h> #include "libavutil/rational.h" +#include "libavcodec/evc.h" #include "avio.h" +static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size) +{ + int unit_type_plus1 = 0; + if (bits_size >= EVC_NALU_HEADER_SIZE) { + unsigned char *p = (unsigned char *)bits; + // forbidden_zero_bit + if ((p[0] & 0x80) != 0) // Cannot get bitstream information. Malformed bitstream. + return -1; + + // nal_unit_type + unit_type_plus1 = (p[0] >> 1) & 0x3F; + } + + return unit_type_plus1 - 1; +} + +static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_size) +{ + uint32_t nalu_len = 0; + + if (bits_size >= EVC_NALU_LENGTH_PREFIX_SIZE) { + unsigned char *p = (unsigned char *)bits; + + for (int i = 0; i < EVC_NALU_LENGTH_PREFIX_SIZE; i++) + nalu_len = (nalu_len << 8) | p[i]; + } + + return nalu_len; +} /** * Writes EVC sample metadata to the provided AVIOContext. |