avcodec/codec2utils: remove avpriv prefix from inline functions

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2020-10-26 10:58:51 -03:00
parent fec1b4738f
commit 3916af4d95
4 changed files with 35 additions and 35 deletions

View File

@ -37,7 +37,7 @@ int avpriv_codec2_mode_bit_rate(void *logctx, int mode)
int avpriv_codec2_mode_frame_size(void *logctx, int mode)
{
int frame_size_table[AVPRIV_CODEC2_MODE_MAX+1] = {
int frame_size_table[CODEC2_MODE_MAX+1] = {
160, // 3200
160, // 2400
320, // 1600
@ -49,7 +49,7 @@ int avpriv_codec2_mode_frame_size(void *logctx, int mode)
320, // 700C
};
if (mode < 0 || mode > AVPRIV_CODEC2_MODE_MAX) {
if (mode < 0 || mode > CODEC2_MODE_MAX) {
av_log(logctx, AV_LOG_ERROR, "unknown codec2 mode %i, can't find frame_size\n", mode);
return 0;
} else {
@ -59,7 +59,7 @@ int avpriv_codec2_mode_frame_size(void *logctx, int mode)
int avpriv_codec2_mode_block_align(void *logctx, int mode)
{
int block_align_table[AVPRIV_CODEC2_MODE_MAX+1] = {
int block_align_table[CODEC2_MODE_MAX+1] = {
8, // 3200
6, // 2400
8, // 1600
@ -71,7 +71,7 @@ int avpriv_codec2_mode_block_align(void *logctx, int mode)
4, // 700C
};
if (mode < 0 || mode > AVPRIV_CODEC2_MODE_MAX) {
if (mode < 0 || mode > CODEC2_MODE_MAX) {
av_log(logctx, AV_LOG_ERROR, "unknown codec2 mode %i, can't find block_align\n", mode);
return 0;
} else {

View File

@ -27,14 +27,14 @@
//Highest mode we're willing to use.
//Don't want to let users accidentally produce files that can't be decoded in the future.
//CODEC2_MODE_WB (9) is experimental/unstable as of 2017-11-23.
#define AVPRIV_CODEC2_MODE_MAX 8 //CODEC2_MODE_700C
#define CODEC2_MODE_MAX 8 //CODEC2_MODE_700C
//Used by both codec2raw demuxer and libcodec2 encoder.
//The integers match the values in codec2.h, so "3200" -> CODEC2_MODE_3000 = 0 and so on.
//It is possible that we're linked to a version of libcodec2 that lacks some of these modes.
//For example Debian stretch ships with libcodec2.so.0.4 which lacks CODEC2_MODE_700C.
#define AVPRIV_CODEC2_AVOPTIONS(desc, classname, min_val, default_val, option_flags) \
{ "mode", desc, offsetof(classname, mode), AV_OPT_TYPE_INT, {.i64 = default_val}, min_val, AVPRIV_CODEC2_MODE_MAX, .flags=option_flags, .unit="codec2_mode"},\
#define CODEC2_AVOPTIONS(desc, classname, min_val, default_val, option_flags) \
{ "mode", desc, offsetof(classname, mode), AV_OPT_TYPE_INT, {.i64 = default_val}, min_val, CODEC2_MODE_MAX, .flags=option_flags, .unit="codec2_mode"},\
{ "3200", "3200", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, .flags=option_flags, .unit="codec2_mode"},\
{ "2400", "2400", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, .flags=option_flags, .unit="codec2_mode"},\
{ "1600", "1600", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, .flags=option_flags, .unit="codec2_mode"},\
@ -59,10 +59,10 @@ int avpriv_codec2_mode_frame_size(void *logctx, int mode);
//Mimics (codec2_bits_per_frame()+7)/8
int avpriv_codec2_mode_block_align(void *logctx, int mode);
#define AVPRIV_CODEC2_EXTRADATA_SIZE 4
#define CODEC2_EXTRADATA_SIZE 4
//Used in codec2raw demuxer and libcodec2 encoder
static inline void avpriv_codec2_make_extradata(uint8_t *ptr, int mode) {
static inline void codec2_make_extradata(uint8_t *ptr, int mode) {
//version 0.8 as of 2017-12-23 (r3386)
ptr[0] = 0; //major
ptr[1] = 8; //minor
@ -71,11 +71,11 @@ static inline void avpriv_codec2_make_extradata(uint8_t *ptr, int mode) {
}
//Returns version as a 16-bit value. 0.8 -> 0x0008
static inline uint16_t avpriv_codec2_version_from_extradata(uint8_t *ptr) {
static inline uint16_t codec2_version_from_extradata(uint8_t *ptr) {
return (ptr[0] << 8) + ptr[1];
}
static inline uint8_t avpriv_codec2_mode_from_extradata(uint8_t *ptr) {
static inline uint8_t codec2_mode_from_extradata(uint8_t *ptr) {
return ptr[2];
}

View File

@ -34,7 +34,7 @@ typedef struct {
static const AVOption options[] = {
//not AV_OPT_FLAG_DECODING_PARAM since mode should come from the demuxer
//1300 (aka FreeDV 1600) is the most common mode on-the-air, default to it here as well
AVPRIV_CODEC2_AVOPTIONS("codec2 mode", LibCodec2Context, 0, 4 /*CODEC2_MODE_1300*/, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_ENCODING_PARAM),
CODEC2_AVOPTIONS("codec2 mode", LibCodec2Context, 0, 4 /*CODEC2_MODE_1300*/, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_ENCODING_PARAM),
{ NULL },
};
@ -55,7 +55,7 @@ static av_cold int libcodec2_init_common(AVCodecContext *avctx, int mode)
{
LibCodec2Context *c2 = avctx->priv_data;
//Grab mode name from options, unless it's some weird number.
const char *modename = mode >= 0 && mode <= AVPRIV_CODEC2_MODE_MAX ? options[mode+1].name : "?";
const char *modename = mode >= 0 && mode <= CODEC2_MODE_MAX ? options[mode+1].name : "?";
c2->codec = codec2_create(mode);
if (!c2->codec) {
@ -93,13 +93,13 @@ static av_cold int libcodec2_init_decoder(AVCodecContext *avctx)
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avctx->channel_layout = AV_CH_LAYOUT_MONO;
if (avctx->extradata_size != AVPRIV_CODEC2_EXTRADATA_SIZE) {
if (avctx->extradata_size != CODEC2_EXTRADATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "must have exactly %i bytes of extradata (got %i)\n",
AVPRIV_CODEC2_EXTRADATA_SIZE, avctx->extradata_size);
CODEC2_EXTRADATA_SIZE, avctx->extradata_size);
return AVERROR_INVALIDDATA;
}
return libcodec2_init_common(avctx, avpriv_codec2_mode_from_extradata(avctx->extradata));
return libcodec2_init_common(avctx, codec2_mode_from_extradata(avctx->extradata));
}
static av_cold int libcodec2_init_encoder(AVCodecContext *avctx)
@ -114,13 +114,13 @@ static av_cold int libcodec2_init_encoder(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
avctx->extradata = av_mallocz(AVPRIV_CODEC2_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata = av_mallocz(CODEC2_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata) {
return AVERROR(ENOMEM);
}
avctx->extradata_size = AVPRIV_CODEC2_EXTRADATA_SIZE;
avpriv_codec2_make_extradata(avctx->extradata, c2->mode);
avctx->extradata_size = CODEC2_EXTRADATA_SIZE;
codec2_make_extradata(avctx->extradata, c2->mode);
return libcodec2_init_common(avctx, c2->mode);
}

View File

@ -29,8 +29,8 @@
#include "rawenc.h"
#include "pcm.h"
#define AVPRIV_CODEC2_HEADER_SIZE 7
#define AVPRIV_CODEC2_MAGIC 0xC0DEC2
#define CODEC2_HEADER_SIZE 7
#define CODEC2_MAGIC 0xC0DEC2
//the lowest version we should ever run across is 0.8
//we may run across later versions as the format evolves
@ -46,7 +46,7 @@ typedef struct {
static int codec2_probe(const AVProbeData *p)
{
//must start wih C0 DE C2
if (AV_RB24(p->buf) != AVPRIV_CODEC2_MAGIC) {
if (AV_RB24(p->buf) != CODEC2_MAGIC) {
return 0;
}
@ -63,7 +63,7 @@ static int codec2_probe(const AVProbeData *p)
static int codec2_read_header_common(AVFormatContext *s, AVStream *st)
{
int mode = avpriv_codec2_mode_from_extradata(st->codecpar->extradata);
int mode = codec2_mode_from_extradata(st->codecpar->extradata);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_CODEC2;
@ -95,28 +95,28 @@ static int codec2_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
}
if (avio_rb24(s->pb) != AVPRIV_CODEC2_MAGIC) {
if (avio_rb24(s->pb) != CODEC2_MAGIC) {
av_log(s, AV_LOG_ERROR, "not a .c2 file\n");
return AVERROR_INVALIDDATA;
}
ret = ff_alloc_extradata(st->codecpar, AVPRIV_CODEC2_EXTRADATA_SIZE);
ret = ff_alloc_extradata(st->codecpar, CODEC2_EXTRADATA_SIZE);
if (ret) {
return ret;
}
ret = ffio_read_size(s->pb, st->codecpar->extradata, AVPRIV_CODEC2_EXTRADATA_SIZE);
ret = ffio_read_size(s->pb, st->codecpar->extradata, CODEC2_EXTRADATA_SIZE);
if (ret < 0) {
return ret;
}
version = avpriv_codec2_version_from_extradata(st->codecpar->extradata);
version = codec2_version_from_extradata(st->codecpar->extradata);
if ((version >> 8) != EXPECTED_CODEC2_MAJOR_VERSION) {
avpriv_report_missing_feature(s, "Major version %i", version >> 8);
return AVERROR_PATCHWELCOME;
}
s->internal->data_offset = AVPRIV_CODEC2_HEADER_SIZE;
s->internal->data_offset = CODEC2_HEADER_SIZE;
return codec2_read_header_common(s, st);
}
@ -160,14 +160,14 @@ static int codec2_write_header(AVFormatContext *s)
st = s->streams[0];
if (st->codecpar->extradata_size != AVPRIV_CODEC2_EXTRADATA_SIZE) {
if (st->codecpar->extradata_size != CODEC2_EXTRADATA_SIZE) {
av_log(s, AV_LOG_ERROR, ".c2 files require exactly %i bytes of extradata (got %i)\n",
AVPRIV_CODEC2_EXTRADATA_SIZE, st->codecpar->extradata_size);
CODEC2_EXTRADATA_SIZE, st->codecpar->extradata_size);
return AVERROR(EINVAL);
}
avio_wb24(s->pb, AVPRIV_CODEC2_MAGIC);
avio_write(s->pb, st->codecpar->extradata, AVPRIV_CODEC2_EXTRADATA_SIZE);
avio_wb24(s->pb, CODEC2_MAGIC);
avio_write(s->pb, st->codecpar->extradata, CODEC2_EXTRADATA_SIZE);
return 0;
}
@ -189,13 +189,13 @@ static int codec2raw_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
}
ret = ff_alloc_extradata(st->codecpar, AVPRIV_CODEC2_EXTRADATA_SIZE);
ret = ff_alloc_extradata(st->codecpar, CODEC2_EXTRADATA_SIZE);
if (ret) {
return ret;
}
s->internal->data_offset = 0;
avpriv_codec2_make_extradata(st->codecpar->extradata, c2->mode);
codec2_make_extradata(st->codecpar->extradata, c2->mode);
return codec2_read_header_common(s, st);
}
@ -211,7 +211,7 @@ static const AVOption codec2_options[] = {
};
static const AVOption codec2raw_options[] = {
AVPRIV_CODEC2_AVOPTIONS("codec2 mode [mandatory]", Codec2Context, -1, -1, AV_OPT_FLAG_DECODING_PARAM),
CODEC2_AVOPTIONS("codec2 mode [mandatory]", Codec2Context, -1, -1, AV_OPT_FLAG_DECODING_PARAM),
FRAMES_PER_PACKET,
{ NULL },
};