avcodec/opus: Use prefix for defines

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-10-07 19:36:09 +02:00
parent a4dc60a258
commit e846617b82
3 changed files with 11 additions and 11 deletions

View File

@ -25,9 +25,9 @@
#include <stdint.h>
#define MAX_FRAME_SIZE 1275
#define MAX_FRAMES 48
#define MAX_PACKET_DUR 5760
#define OPUS_MAX_FRAME_SIZE 1275
#define OPUS_MAX_FRAMES 48
#define OPUS_MAX_PACKET_DUR 5760
#define OPUS_TS_HEADER 0x7FE0 // 0x3ff (11 bits)
#define OPUS_TS_MASK 0xFFE0 // top 11 bits

View File

@ -128,7 +128,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
}
frame_bytes = end - ptr;
if (frame_bytes > MAX_FRAME_SIZE)
if (frame_bytes > OPUS_MAX_FRAME_SIZE)
goto fail;
pkt->frame_offset[0] = ptr - buf;
pkt->frame_size[0] = frame_bytes;
@ -147,7 +147,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
}
frame_bytes = end - ptr;
if (frame_bytes & 1 || frame_bytes >> 1 > MAX_FRAME_SIZE)
if (frame_bytes & 1 || frame_bytes >> 1 > OPUS_MAX_FRAME_SIZE)
goto fail;
pkt->frame_offset[0] = ptr - buf;
pkt->frame_size[0] = frame_bytes >> 1;
@ -177,7 +177,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
/* calculate 2nd frame size */
frame_bytes = end - ptr - pkt->frame_size[0];
if (frame_bytes < 0 || frame_bytes > MAX_FRAME_SIZE)
if (frame_bytes < 0 || frame_bytes > OPUS_MAX_FRAME_SIZE)
goto fail;
pkt->frame_offset[1] = pkt->frame_offset[0] + pkt->frame_size[0];
pkt->frame_size[1] = frame_bytes;
@ -189,7 +189,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
padding = (i >> 6) & 0x01;
pkt->vbr = (i >> 7) & 0x01;
if (pkt->frame_count == 0 || pkt->frame_count > MAX_FRAMES)
if (pkt->frame_count == 0 || pkt->frame_count > OPUS_MAX_FRAMES)
goto fail;
/* read padding size */
@ -239,7 +239,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
} else {
frame_bytes = end - ptr - padding;
if (frame_bytes % pkt->frame_count ||
frame_bytes / pkt->frame_count > MAX_FRAME_SIZE)
frame_bytes / pkt->frame_count > OPUS_MAX_FRAME_SIZE)
goto fail;
frame_bytes /= pkt->frame_count;
}
@ -258,7 +258,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
/* total packet duration cannot be larger than 120ms */
pkt->frame_duration = opus_frame_duration[pkt->config];
if (pkt->frame_duration * pkt->frame_count > MAX_PACKET_DUR)
if (pkt->frame_duration * pkt->frame_count > OPUS_MAX_PACKET_DUR)
goto fail;
/* set mode and bandwidth */

View File

@ -37,8 +37,8 @@ typedef struct OpusPacket {
int config; /**< configuration: tells the audio mode,
** bandwidth, and frame duration */
int frame_count; /**< frame count */
int frame_offset[MAX_FRAMES]; /**< frame offsets */
int frame_size[MAX_FRAMES]; /**< frame sizes */
int frame_offset[OPUS_MAX_FRAMES]; /**< frame offsets */
int frame_size[OPUS_MAX_FRAMES]; /**< frame sizes */
int frame_duration; /**< frame duration, in samples @ 48kHz */
enum OpusMode mode; /**< mode */
enum OpusBandwidth bandwidth; /**< bandwidth */