--- libavcodec/internal.h | 15 ++++++++++++++- libavcodec/utils.c | 10 +++++----- 2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 72ca1553f6..07098e1522 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -285,9 +285,22 @@ int ff_thread_can_start_frame(AVCodecContext *avctx); int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); +/** + * Find the first start code in the buffer p. A start code is a sequence of 4 + * bytes, with memory address increasing left to right and in hexadecimal, with + * the value 00 00 01 XX, where XX represents any value. + * + * @param[in] p A pointer to the start of the memory buffer to scan. + * @param[in] end A pointer to the past the end memory address for the buffer + * given by p. p must be <= end. + * + * @param[out] start_code The found start code if it exists, otherwise an invalid start code. + * @return A pointer to the memory address following the found start code, or end + * if no start code was found. + */ const uint8_t *avpriv_find_start_code(const uint8_t *p, const uint8_t *end, - uint32_t *state); + uint32_t *start_code); int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index cf88e0a759..54c9dd056d 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -942,7 +942,7 @@ void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, in const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p, const uint8_t *end, - uint32_t *av_restrict state) + uint32_t *av_restrict start_code) { int i; @@ -950,10 +950,10 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p, if (p >= end) return end; - *state = ~0; + *start_code = ~0; for (i = 0; i < 3; i++) { - uint32_t tmp = *state << 8; - *state = tmp + *(p++); + uint32_t tmp = *start_code << 8; + *start_code = tmp + *(p++); if (tmp == 0x100 || p == end) return p; } @@ -987,7 +987,7 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p, // this will cause the last 4 bytes before end to be read, // i.e. no out of bounds memory access occurs - *state = AV_RB32(p - 4); + *start_code = AV_RB32(p - 4); // read the previous 4 bytes, i.e. bytes {p - 4, p - 3, p - 2, p - 1} return p; -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".