aacenc: add support for changing options based on a profile

This commit adds the ability for a profile to set the default
options, as well as for the user to override such options
by simply stating them in the command line while still keeping
the same profile, as long as those options are still permitted by
the profile.

Example: setting the profile to aac_low (the default) will turn
PNS and IS on. They can be disabled by -aac_pns 0 and -aac_is 0,
respectively. Turning on -aac_pred 1 will cause the profile to be
elevated to aac_main, as long as no options forbidding aac_main
have been entered (like AAC-LTP, which will be pushed soon).

A useful feature is that by setting the profile to mpeg2_aac_low,
all MPEG4 features will be disabled and if the user tries to enable
them then the program will exit with an error. This profile is
signalled with the same bitstream as aac_low (MPEG4) but some devices
and decoders will fail if any MPEG4 features have been enabled.
This commit is contained in:
Rostislav Pehlivanov 2015-10-12 16:50:10 +01:00
parent cf28490e56
commit 0f4334df45
5 changed files with 138 additions and 52 deletions

View file

@ -201,5 +201,43 @@ static inline int lcg_random(unsigned previous_val)
av_log(avctx, AV_LOG_WARNING, __VA_ARGS__); \
}
#define AAC_OPT_SET(e_opt, p_opt, bypass, name) \
ERROR_IF ((e_opt)->name == 1 && (p_opt)->name == OPT_BANNED, \
"Profile %i does not allow %s\n", avctx->profile, #name); \
ERROR_IF ((e_opt)->name == 0 && (p_opt)->name == OPT_REQUIRED, \
"Option %s is a requirement for this profile (%i)\n", \
#name, avctx->profile); \
if ((e_opt)->name == 1 && (p_opt)->name == OPT_NEEDS_MAIN && \
avctx->profile == FF_PROFILE_AAC_LOW) { \
WARN_IF(1, "Profile %i does not allow for %s, setting profile to " \
"\"aac_main\"(%i)\n", avctx->profile, #name, \
FF_PROFILE_AAC_MAIN); \
avctx->profile = FF_PROFILE_AAC_MAIN; \
p_opt = &aacenc_profiles[FF_PROFILE_AAC_MAIN].opts; \
} \
if ((e_opt)->name == 1 && (p_opt)->name == OPT_NEEDS_LTP && \
avctx->profile == FF_PROFILE_AAC_LOW) { \
WARN_IF(1, "Profile %i does not allow for %s, setting profile to " \
"\"aac_ltp\"(%i)\n", avctx->profile, #name, \
FF_PROFILE_AAC_LTP); \
avctx->profile = FF_PROFILE_AAC_LTP; \
p_opt = &aacenc_profiles[FF_PROFILE_AAC_LTP].opts; \
} \
if ((e_opt)->name == OPT_AUTO) { \
if ((p_opt)->name == OPT_BANNED) { \
(e_opt)->name = 0; \
} else if ((p_opt)->name == OPT_NEEDS_LTP) { \
(e_opt)->name = 0; \
} else if ((p_opt)->name == OPT_NEEDS_MAIN) { \
(e_opt)->name = 0; \
} else if ((p_opt)->name == OPT_REQUIRED) { \
(e_opt)->name = 1; \
} else if (bypass) { \
(e_opt)->name = (e_opt)->name; \
} else { \
(e_opt)->name = (p_opt)->name; \
} \
} \
av_log(avctx, AV_LOG_VERBOSE, "Option %s set to %i\n", #name, (e_opt)->name);
#endif /* AVCODEC_AACENC_UTILS_H */