Skip to content

Commit

Permalink
avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* defines
Browse files Browse the repository at this point in the history
These defines are also used in other contexts than just AVCodecContext
ones, e.g. in libavformat. Furthermore, given that these defines are
public, the AV-prefix is the right one, so deprecate (and not just move)
the FF-macros.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
  • Loading branch information
mkver committed Sep 6, 2023
1 parent 0c6e5f3 commit 8238bc0
Show file tree
Hide file tree
Showing 93 changed files with 879 additions and 727 deletions.
4 changes: 4 additions & 0 deletions doc/APIchanges
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09

API changes, most recent first:

2023-09-07 - xxxxxxxxxx - lavc 60.26.100 - defs.h
Add AV_PROFILE_* and AV_LEVEL_* replacements in defs.h for the
defines from avcodec.h. The latter are deprecated.

2023-09-06 - xxxxxxxxxx - lavc 60.25.101 - avcodec.h
AVCodecContext.rc_buffer_size may now be set by decoders.

Expand Down
2 changes: 1 addition & 1 deletion fftools/ffprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
print_str("profile", profile);
else {
if (par->profile != FF_PROFILE_UNKNOWN) {
if (par->profile != AV_PROFILE_UNKNOWN) {
char profile_num[12];
snprintf(profile_num, sizeof(profile_num), "%d", par->profile);
print_str("profile", profile_num);
Expand Down
8 changes: 4 additions & 4 deletions libavcodec/aacdec_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -2486,12 +2486,12 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt,
ac->avctx->ch_layout.nb_channels == 1) {
ac->oc[1].m4ac.sbr = 1;
ac->oc[1].m4ac.ps = 1;
ac->avctx->profile = FF_PROFILE_AAC_HE_V2;
ac->avctx->profile = AV_PROFILE_AAC_HE_V2;
output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags,
ac->oc[1].status, 1);
} else {
ac->oc[1].m4ac.sbr = 1;
ac->avctx->profile = FF_PROFILE_AAC_HE;
ac->avctx->profile = AV_PROFILE_AAC_HE;
}
res = AAC_RENAME(ff_decode_sbr_extension)(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) {
Expand Down Expand Up @@ -3080,7 +3080,7 @@ static int aac_decode_er_frame(AVCodecContext *avctx, void *data,
if ((err = frame_configure_elements(avctx)) < 0)
return err;

// The FF_PROFILE_AAC_* defines are all object_type - 1
// The AV_PROFILE_AAC_* defines are all object_type - 1
// This may lead to an undefined profile being signaled
ac->avctx->profile = aot - 1;

Expand Down Expand Up @@ -3163,7 +3163,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame,
if ((err = frame_configure_elements(avctx)) < 0)
goto fail;

// The FF_PROFILE_AAC_* defines are all object_type - 1
// The AV_PROFILE_AAC_* defines are all object_type - 1
// This may lead to an undefined profile being signaled
ac->avctx->profile = ac->oc[1].m4ac.object_type - 1;

Expand Down
14 changes: 7 additions & 7 deletions libavcodec/aacenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,36 +1307,36 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
avctx->bit_rate);

/* Profile and option setting */
avctx->profile = avctx->profile == FF_PROFILE_UNKNOWN ? FF_PROFILE_AAC_LOW :
avctx->profile = avctx->profile == AV_PROFILE_UNKNOWN ? AV_PROFILE_AAC_LOW :
avctx->profile;
for (i = 0; i < FF_ARRAY_ELEMS(aacenc_profiles); i++)
if (avctx->profile == aacenc_profiles[i])
break;
if (avctx->profile == FF_PROFILE_MPEG2_AAC_LOW) {
avctx->profile = FF_PROFILE_AAC_LOW;
if (avctx->profile == AV_PROFILE_MPEG2_AAC_LOW) {
avctx->profile = AV_PROFILE_AAC_LOW;
ERROR_IF(s->options.pred,
"Main prediction unavailable in the \"mpeg2_aac_low\" profile\n");
ERROR_IF(s->options.ltp,
"LTP prediction unavailable in the \"mpeg2_aac_low\" profile\n");
WARN_IF(s->options.pns,
"PNS unavailable in the \"mpeg2_aac_low\" profile, turning off\n");
s->options.pns = 0;
} else if (avctx->profile == FF_PROFILE_AAC_LTP) {
} else if (avctx->profile == AV_PROFILE_AAC_LTP) {
s->options.ltp = 1;
ERROR_IF(s->options.pred,
"Main prediction unavailable in the \"aac_ltp\" profile\n");
} else if (avctx->profile == FF_PROFILE_AAC_MAIN) {
} else if (avctx->profile == AV_PROFILE_AAC_MAIN) {
s->options.pred = 1;
ERROR_IF(s->options.ltp,
"LTP prediction unavailable in the \"aac_main\" profile\n");
} else if (s->options.ltp) {
avctx->profile = FF_PROFILE_AAC_LTP;
avctx->profile = AV_PROFILE_AAC_LTP;
WARN_IF(1,
"Chainging profile to \"aac_ltp\"\n");
ERROR_IF(s->options.pred,
"Main prediction unavailable in the \"aac_ltp\" profile\n");
} else if (s->options.pred) {
avctx->profile = FF_PROFILE_AAC_MAIN;
avctx->profile = AV_PROFILE_AAC_MAIN;
WARN_IF(1,
"Chainging profile to \"aac_main\"\n");
ERROR_IF(s->options.ltp,
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/aacenc_ltp.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void ff_aac_encode_ltp_info(AACEncContext *s, SingleChannelElement *sce,
{
int i;
IndividualChannelStream *ics = &sce->ics;
if (s->profile != FF_PROFILE_AAC_LTP || !ics->predictor_present)
if (s->profile != AV_PROFILE_AAC_LTP || !ics->predictor_present)
return;
if (common_window)
put_bits(&s->pb, 1, 0);
Expand Down Expand Up @@ -119,7 +119,7 @@ void ff_aac_update_ltp(AACEncContext *s, SingleChannelElement *sce)
float *pred_signal = &sce->ltp_state[0];
const float *samples = &s->planar_samples[s->cur_channel][1024];

if (s->profile != FF_PROFILE_AAC_LTP)
if (s->profile != AV_PROFILE_AAC_LTP)
return;

/* Calculate lag */
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/aacenc_pred.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void ff_aac_encode_main_pred(AACEncContext *s, SingleChannelElement *sce)
IndividualChannelStream *ics = &sce->ics;
const int pmax = FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[s->samplerate_index]);

if (s->profile != FF_PROFILE_AAC_MAIN ||
if (s->profile != AV_PROFILE_AAC_MAIN ||
!ics->predictor_present)
return;

Expand Down
2 changes: 1 addition & 1 deletion libavcodec/aacenc_tns.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce)
const int c_bits = is8 ? TNS_Q_BITS_IS8 == 4 : TNS_Q_BITS == 4;
const int sfb_start = av_clip(tns_min_sfb[is8][s->samplerate_index], 0, mmm);
const int sfb_end = av_clip(sce->ics.num_swb, 0, mmm);
const int order = is8 ? 7 : s->profile == FF_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER;
const int order = is8 ? 7 : s->profile == AV_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER;
const int slant = sce->ics.window_sequence[0] == LONG_STOP_SEQUENCE ? 1 :
sce->ics.window_sequence[0] == LONG_START_SEQUENCE ? 0 : 2;
const int sfb_len = sfb_end - sfb_start;
Expand Down
8 changes: 4 additions & 4 deletions libavcodec/aacenctab.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ static const unsigned char aac_maxval_cb[] = {
};

static const int aacenc_profiles[] = {
FF_PROFILE_AAC_MAIN,
FF_PROFILE_AAC_LOW,
FF_PROFILE_AAC_LTP,
FF_PROFILE_MPEG2_AAC_LOW,
AV_PROFILE_AAC_MAIN,
AV_PROFILE_AAC_LOW,
AV_PROFILE_AAC_LTP,
AV_PROFILE_MPEG2_AAC_LOW,
};

#endif /* AVCODEC_AACENCTAB_H */
2 changes: 1 addition & 1 deletion libavcodec/aacsbr_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
*num_bits_left = 0;
} else {
*num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps.common, *num_bits_left);
ac->avctx->profile = FF_PROFILE_AAC_HE_V2;
ac->avctx->profile = AV_PROFILE_AAC_HE_V2;
// ensure the warning is not printed if PS extension is present
ac->warned_he_aac_mono = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/ac3dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
avctx->profile = s->eac3_extension_type_a == 1 ? FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN;
avctx->profile = s->eac3_extension_type_a == 1 ? AV_PROFILE_EAC3_DDP_ATMOS : AV_PROFILE_UNKNOWN;
}

if (!avctx->sample_rate) {
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/amfenc_av1.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_FRAMERATE, framerate);

switch (avctx->profile) {
case FF_PROFILE_AV1_MAIN:
case AV_PROFILE_AV1_MAIN:
profile = AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN;
break;
default:
Expand All @@ -204,7 +204,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_PROFILE, profile);

profile_level = avctx->level;
if (profile_level == FF_LEVEL_UNKNOWN) {
if (profile_level == AV_LEVEL_UNKNOWN) {
profile_level = ctx->level;
}
if (profile_level != 0) {
Expand Down
12 changes: 6 additions & 6 deletions libavcodec/amfenc_h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,19 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_FRAMERATE, framerate);

switch (avctx->profile) {
case FF_PROFILE_H264_BASELINE:
case AV_PROFILE_H264_BASELINE:
profile = AMF_VIDEO_ENCODER_PROFILE_BASELINE;
break;
case FF_PROFILE_H264_MAIN:
case AV_PROFILE_H264_MAIN:
profile = AMF_VIDEO_ENCODER_PROFILE_MAIN;
break;
case FF_PROFILE_H264_HIGH:
case AV_PROFILE_H264_HIGH:
profile = AMF_VIDEO_ENCODER_PROFILE_HIGH;
break;
case FF_PROFILE_H264_CONSTRAINED_BASELINE:
case AV_PROFILE_H264_CONSTRAINED_BASELINE:
profile = AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_BASELINE;
break;
case (FF_PROFILE_H264_HIGH | FF_PROFILE_H264_CONSTRAINED):
case (AV_PROFILE_H264_HIGH | AV_PROFILE_H264_CONSTRAINED):
profile = AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_HIGH;
break;
}
Expand All @@ -246,7 +246,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_PROFILE, profile);

profile_level = avctx->level;
if (profile_level == FF_LEVEL_UNKNOWN) {
if (profile_level == AV_LEVEL_UNKNOWN) {
profile_level = ctx->level;
}
if (profile_level != 0) {
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/amfenc_hevc.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FRAMERATE, framerate);

switch (avctx->profile) {
case FF_PROFILE_HEVC_MAIN:
case AV_PROFILE_HEVC_MAIN:
profile = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN;
break;
default:
Expand All @@ -198,7 +198,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_TIER, ctx->tier);

profile_level = avctx->level;
if (profile_level == FF_LEVEL_UNKNOWN) {
if (profile_level == AV_LEVEL_UNKNOWN) {
profile_level = ctx->level;
}
if (profile_level != 0) {
Expand Down
22 changes: 11 additions & 11 deletions libavcodec/audiotoolboxenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
switch (codec) {
case AV_CODEC_ID_AAC:
switch (profile) {
case FF_PROFILE_AAC_LOW:
case AV_PROFILE_AAC_LOW:
default:
return kAudioFormatMPEG4AAC;
case FF_PROFILE_AAC_HE:
case AV_PROFILE_AAC_HE:
return kAudioFormatMPEG4AAC_HE;
case FF_PROFILE_AAC_HE_V2:
case AV_PROFILE_AAC_HE_V2:
return kAudioFormatMPEG4AAC_HE_V2;
case FF_PROFILE_AAC_LD:
case AV_PROFILE_AAC_LD:
return kAudioFormatMPEG4AAC_LD;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
case FF_PROFILE_AAC_ELD:
case AV_PROFILE_AAC_ELD:
return kAudioFormatMPEG4AAC_ELD;
#endif
}
Expand Down Expand Up @@ -586,12 +586,12 @@ static av_cold int ffat_close_encoder(AVCodecContext *avctx)
}

static const AVProfile aac_profiles[] = {
{ FF_PROFILE_AAC_LOW, "LC" },
{ FF_PROFILE_AAC_HE, "HE-AAC" },
{ FF_PROFILE_AAC_HE_V2, "HE-AACv2" },
{ FF_PROFILE_AAC_LD, "LD" },
{ FF_PROFILE_AAC_ELD, "ELD" },
{ FF_PROFILE_UNKNOWN },
{ AV_PROFILE_AAC_LOW, "LC" },
{ AV_PROFILE_AAC_HE, "HE-AAC" },
{ AV_PROFILE_AAC_HE_V2, "HE-AACv2" },
{ AV_PROFILE_AAC_LD, "LD" },
{ AV_PROFILE_AAC_ELD, "ELD" },
{ AV_PROFILE_UNKNOWN },
};

#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
Expand Down
10 changes: 10 additions & 0 deletions libavcodec/avcodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -1587,8 +1587,12 @@ typedef struct AVCodecContext {
* profile
* - encoding: Set by user.
* - decoding: Set by libavcodec.
* See the AV_PROFILE_* defines in defs.h.
*/
int profile;
#if FF_API_FF_PROFILE_LEVEL
/** @deprecated The following defines are deprecated; use AV_PROFILE_*
* in defs.h instead. */
#define FF_PROFILE_UNKNOWN -99
#define FF_PROFILE_RESERVED -100

Expand Down Expand Up @@ -1719,14 +1723,20 @@ typedef struct AVCodecContext {

#define FF_PROFILE_EVC_BASELINE 0
#define FF_PROFILE_EVC_MAIN 1
#endif

/**
* level
* - encoding: Set by user.
* - decoding: Set by libavcodec.
* See AV_LEVEL_* in defs.h.
*/
int level;
#if FF_API_FF_PROFILE_LEVEL
/** @deprecated The following define is deprecated; use AV_LEVEL_UNKOWN
* in defs.h instead. */
#define FF_LEVEL_UNKNOWN -99
#endif

/**
* Skip loop filtering for selected frames.
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/cbs_av1.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"

#include "avcodec.h"
#include "cbs.h"
#include "cbs_internal.h"
#include "cbs_av1.h"
#include "defs.h"


static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc,
Expand Down
12 changes: 6 additions & 6 deletions libavcodec/cbs_av1_syntax_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ static int FUNC(color_config)(CodedBitstreamContext *ctx, RWContext *rw,

flag(high_bitdepth);

if (seq_profile == FF_PROFILE_AV1_PROFESSIONAL &&
if (seq_profile == AV_PROFILE_AV1_PROFESSIONAL &&
current->high_bitdepth) {
flag(twelve_bit);
priv->bit_depth = current->twelve_bit ? 12 : 10;
} else {
priv->bit_depth = current->high_bitdepth ? 10 : 8;
}

if (seq_profile == FF_PROFILE_AV1_HIGH)
if (seq_profile == AV_PROFILE_AV1_HIGH)
infer(mono_chrome, 0);
else
flag(mono_chrome);
Expand Down Expand Up @@ -126,10 +126,10 @@ static int FUNC(color_config)(CodedBitstreamContext *ctx, RWContext *rw,
} else {
flag(color_range);

if (seq_profile == FF_PROFILE_AV1_MAIN) {
if (seq_profile == AV_PROFILE_AV1_MAIN) {
infer(subsampling_x, 1);
infer(subsampling_y, 1);
} else if (seq_profile == FF_PROFILE_AV1_HIGH) {
} else if (seq_profile == AV_PROFILE_AV1_HIGH) {
infer(subsampling_x, 0);
infer(subsampling_y, 0);
} else {
Expand Down Expand Up @@ -190,8 +190,8 @@ static int FUNC(sequence_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,

HEADER("Sequence Header");

fc(3, seq_profile, FF_PROFILE_AV1_MAIN,
FF_PROFILE_AV1_PROFESSIONAL);
fc(3, seq_profile, AV_PROFILE_AV1_MAIN,
AV_PROFILE_AV1_PROFESSIONAL);
flag(still_picture);
flag(reduced_still_picture_header);

Expand Down
2 changes: 1 addition & 1 deletion libavcodec/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ typedef struct AVCodec {
const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
#endif
const AVClass *priv_class; ///< AVClass for the private context
const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {AV_PROFILE_UNKNOWN}

/**
* Group name of the codec implementation.
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/codec_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef struct AVCodecDescriptor {
const char *const *mime_types;
/**
* If non-NULL, an array of profiles recognized for this codec.
* Terminated with FF_PROFILE_UNKNOWN.
* Terminated with AV_PROFILE_UNKNOWN.
*/
const struct AVProfile *profiles;
} AVCodecDescriptor;
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/codec_par.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ static void codec_parameters_reset(AVCodecParameters *par)
par->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
par->sample_aspect_ratio = (AVRational){ 0, 1 };
par->framerate = (AVRational){ 0, 1 };
par->profile = FF_PROFILE_UNKNOWN;
par->level = FF_LEVEL_UNKNOWN;
par->profile = AV_PROFILE_UNKNOWN;
par->level = AV_LEVEL_UNKNOWN;
}

AVCodecParameters *avcodec_parameters_alloc(void)
Expand Down
Loading

0 comments on commit 8238bc0

Please sign in to comment.