diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-03-25 10:27:31 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-03-30 12:36:32 +0200 |
commit | 67f6e7ed6ddac43139984b6956f45bb5c1861546 (patch) | |
tree | a931d71df1442c32203715d2e6fa82a3fab6a4af /libavcodec/ffv1enc_template.c | |
parent | 11ff9cb5e976e87ec345e6f4856f62b86d6cb0b3 (diff) | |
download | ffmpeg-67f6e7ed6ddac43139984b6956f45bb5c1861546.tar.gz |
avcodec: Remove cumbersome way of checking for amount of bytes left
Several encoders used code like the following to check for the amount of
bytes left in a PutBitContext:
pb->buf_end - pb->buf - (put_bits_count(pb) >> 3)
Besides the fact that using the pointers directly might pose
a maintainence burden in the future this also leads to suboptimal code:
The above code reads all three pointers (buf, buf_ptr and buf_end), but
touching buf is unnecessary and switching to put_bytes_left()
automatically fixes this.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/ffv1enc_template.c')
-rw-r--r-- | libavcodec/ffv1enc_template.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c index bc0add5ed7..8a4a387923 100644 --- a/libavcodec/ffv1enc_template.c +++ b/libavcodec/ffv1enc_template.c @@ -37,7 +37,7 @@ static av_always_inline int RENAME(encode_line)(FFV1Context *s, int w, return AVERROR_INVALIDDATA; } } else { - if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) < w * 4) { + if (put_bytes_left(&s->pb, 0) < w * 4) { av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return AVERROR_INVALIDDATA; } |