lavf/mpegtsenc: Add parentheses to clarify operator precedence in CC update

While "cc + 1 & 0xf" is technically correct because addition has
higher precedence than bitwise AND in C, the intent of "(cc + 1) & 0xf"
is not immediately obvious without recalling the precedence table.

Add explicit parentheses to make the intended evaluation order clear
and improve readability.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
Jun Zhao
2026-03-29 16:19:12 +08:00
committed by Jun Zhao
parent 3f39783337
commit 4c0dff0878

View File

@@ -170,7 +170,7 @@ static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)
b |= 0x40; b |= 0x40;
*q++ = b; *q++ = b;
*q++ = s->pid; *q++ = s->pid;
s->cc = s->cc + 1 & 0xf; s->cc = (s->cc + 1) & 0xf;
*q++ = 0x10 | s->cc; *q++ = 0x10 | s->cc;
if (s->discontinuity) { if (s->discontinuity) {
q[-1] |= 0x20; q[-1] |= 0x20;
@@ -1583,7 +1583,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
val |= 0x40; val |= 0x40;
*q++ = val; *q++ = val;
*q++ = ts_st->pid; *q++ = ts_st->pid;
ts_st->cc = ts_st->cc + 1 & 0xf; ts_st->cc = (ts_st->cc + 1) & 0xf;
*q++ = 0x10 | ts_st->cc; // payload indicator + CC *q++ = 0x10 | ts_st->cc; // payload indicator + CC
if (ts_st->discontinuity) { if (ts_st->discontinuity) {
set_af_flag(buf, 0x80); set_af_flag(buf, 0x80);