Unified · Split
| @@ -23,16 +23,17 @@ · 22 unmodified lines | |||
| 23 | #define AVFORMAT_EVC_H | 23 | #define AVFORMAT_EVC_H |
| 24 | 24 | ||
| 25 | #include <stdint.h> | 25 | #include <stdint.h> |
| 26 | |||
| 27 | #include "libavutil/intreadwrite.h" | ||
| 26 | #include "libavutil/rational.h" | 28 | #include "libavutil/rational.h" |
| 27 | #include "libavcodec/evc.h" | 29 | #include "libavcodec/evc.h" |
| 28 | #include "avio.h" | 30 | #include "avio.h" |
| 29 | 31 | ||
| 30 | static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size) | 32 | static inline int evc_get_nalu_type(const uint8_t *p, int bits_size) |
| 31 | { | 33 | { |
| 32 | int unit_type_plus1 = 0; | 34 | int unit_type_plus1 = 0; |
| 33 | 35 | ||
| 34 | if (bits_size >= EVC_NALU_HEADER_SIZE) { | 36 | if (bits_size >= EVC_NALU_HEADER_SIZE) { |
| 35 | unsigned char *p = (unsigned char *)bits; | ||
| 36 | // forbidden_zero_bit | 37 | // forbidden_zero_bit |
| 37 | if ((p[0] & 0x80) != 0) // Cannot get bitstream information. Malformed bitstream. | 38 | if ((p[0] & 0x80) != 0) // Cannot get bitstream information. Malformed bitstream. |
| 38 | return -1; | 39 | return -1; |
| @@ -46,16 +47,10 @@ static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size) · 7 unmodified lines | |||
| 46 | 47 | ||
| 47 | static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_size) | 48 | static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_size) |
| 48 | { | 49 | { |
| 49 | uint32_t nalu_len = 0; | 50 | if (bits_size >= EVC_NALU_LENGTH_PREFIX_SIZE) |
| 50 | 51 | return AV_RB32(bits); | |
| 51 | if (bits_size >= EVC_NALU_LENGTH_PREFIX_SIZE) { | ||
| 52 | unsigned char *p = (unsigned char *)bits; | ||
| 53 | |||
| 54 | for (int i = 0; i < EVC_NALU_LENGTH_PREFIX_SIZE; i++) | ||
| 55 | nalu_len = (nalu_len << 8) | p[i]; | ||
| 56 | } | ||
| 57 | 52 | ||
| 58 | return nalu_len; | 53 | return 0; |
| 59 | } | 54 | } |
| 60 | 55 | ||
| 61 | /** | 56 | /** |