Browse Source

avcodec/cbs_h265: move the payload_extension_present check into its own function

Will be reused in the following patch.

Signed-off-by: James Almer <jamrial@gmail.com>
tags/n4.3
James Almer 5 years ago
parent
commit
3a41bac4e2
2 changed files with 13 additions and 6 deletions
  1. +10
    -0
      libavcodec/cbs_h2645.c
  2. +3
    -6
      libavcodec/cbs_h265_syntax_template.c

+ 10
- 0
libavcodec/cbs_h2645.c View File

@@ -233,6 +233,16 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc,
return 0; return 0;
} }


// payload_extension_present() - true if we are before the last 1-bit
// in the payload structure, which must be in the last byte.
static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t payload_size,
int cur_pos)
{
int bits_left = payload_size * 8 - cur_pos;
return (bits_left > 0 &&
(bits_left > 7 || show_bits(gbc, bits_left) & MAX_UINT_BITS(bits_left - 1)));
}

#define HEADER(name) do { \ #define HEADER(name) do { \
ff_cbs_trace_header(ctx, name); \ ff_cbs_trace_header(ctx, name); \
} while (0) } while (0)


+ 3
- 6
libavcodec/cbs_h265_syntax_template.c View File

@@ -1572,7 +1572,7 @@ static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw,
int err, i, length; int err, i, length;


#ifdef READ #ifdef READ
int start_pos, end_pos, bits_left;
int start_pos, end_pos;
start_pos = get_bits_count(rw); start_pos = get_bits_count(rw);
#endif #endif


@@ -1651,12 +1651,9 @@ static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw,
} }


#ifdef READ #ifdef READ
// payload_extension_present() - true if we are before the last 1-bit
// in the payload structure, which must be in the last byte.
end_pos = get_bits_count(rw); end_pos = get_bits_count(rw);
bits_left = *payload_size * 8 - (end_pos - start_pos);
if (bits_left > 0 &&
(bits_left > 7 || ff_ctz(show_bits(rw, bits_left)) < bits_left - 1))
if (cbs_h265_payload_extension_present(rw, *payload_size,
end_pos - start_pos))
flag(use_alt_cpb_params_flag); flag(use_alt_cpb_params_flag);
else else
infer(use_alt_cpb_params_flag, 0); infer(use_alt_cpb_params_flag, 0);


Loading…
Cancel
Save