aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/cbs.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-08-04 07:19:29 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-08-08 11:29:33 +0200
commit715d3286bc678bbce24adb717a3c1f3e83a53269 (patch)
tree0694fe6c9024d9c37c58bcbf897a13dd60f03f2d /libavcodec/cbs.c
parente35b8b848c2a23212b09ff54846cf62acd78ca66 (diff)
downloadffmpeg-715d3286bc678bbce24adb717a3c1f3e83a53269.tar.gz
avcodec/cbs: Use smaller scope for variables, add const
And also avoid an unnecessary indirection for src_buf. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/cbs.c')
-rw-r--r--libavcodec/cbs.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 43329a14a4..c81297ec93 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -925,9 +925,8 @@ static int cbs_clone_internal_refs_unit_content(AVBufferRef **clone_ref,
const CodedBitstreamUnit *unit,
const CodedBitstreamUnitTypeDescriptor *desc)
{
- uint8_t *src, *copy;
- uint8_t **src_ptr, **copy_ptr;
- AVBufferRef **src_buf, **copy_buf;
+ const uint8_t *src;
+ uint8_t *copy;
int err, i;
av_assert0(unit->content);
@@ -938,16 +937,16 @@ static int cbs_clone_internal_refs_unit_content(AVBufferRef **clone_ref,
return AVERROR(ENOMEM);
for (i = 0; i < desc->nb_ref_offsets; i++) {
- src_ptr = (uint8_t**)(src + desc->ref_offsets[i]);
- src_buf = (AVBufferRef**)(src_ptr + 1);
- copy_ptr = (uint8_t**)(copy + desc->ref_offsets[i]);
- copy_buf = (AVBufferRef**)(copy_ptr + 1);
+ const uint8_t *const *src_ptr = (const uint8_t* const*)(src + desc->ref_offsets[i]);
+ const AVBufferRef *src_buf = *(AVBufferRef**)(src_ptr + 1);
+ uint8_t **copy_ptr = (uint8_t**)(copy + desc->ref_offsets[i]);
+ AVBufferRef **copy_buf = (AVBufferRef**)(copy_ptr + 1);
if (!*src_ptr) {
- av_assert0(!*src_buf);
+ av_assert0(!src_buf);
continue;
}
- if (!*src_buf) {
+ if (!src_buf) {
// We can't handle a non-refcounted pointer here - we don't
// have enough information to handle whatever structure lies
// at the other end of it.
@@ -955,7 +954,7 @@ static int cbs_clone_internal_refs_unit_content(AVBufferRef **clone_ref,
goto fail;
}
- *copy_buf = av_buffer_ref(*src_buf);
+ *copy_buf = av_buffer_ref(src_buf);
if (!*copy_buf) {
err = AVERROR(ENOMEM);
goto fail;