mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/mpeg4audio: add avpriv_mpeg4audio_get_config2()
Identical to avpriv_mpeg4audio_get_config() except taking a size argument in bytes, and featuring a new logging context paremeter. Schedule avpriv_mpeg4audio_get_config() for removal as soon as major is bumped as well. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
bb697f30ab
commit
f96a8b015f
|
@ -975,7 +975,7 @@ static int decode_audio_specific_config_gb(AACContext *ac,
|
||||||
int i, ret;
|
int i, ret;
|
||||||
GetBitContext gbc = *gb;
|
GetBitContext gbc = *gb;
|
||||||
|
|
||||||
if ((i = ff_mpeg4audio_get_config_gb(m4ac, &gbc, sync_extension)) < 0)
|
if ((i = ff_mpeg4audio_get_config_gb(m4ac, &gbc, sync_extension, avctx)) < 0)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (m4ac->sampling_index > 12) {
|
if (m4ac->sampling_index > 12) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ static inline int get_sample_rate(GetBitContext *gb, int *index)
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
|
int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
|
||||||
int sync_extension)
|
int sync_extension, void *logctx)
|
||||||
{
|
{
|
||||||
int specific_config_bitindex, ret;
|
int specific_config_bitindex, ret;
|
||||||
int start_bit_index = get_bits_count(gb);
|
int start_bit_index = get_bits_count(gb);
|
||||||
|
@ -152,6 +152,7 @@ int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
|
||||||
return specific_config_bitindex - start_bit_index;
|
return specific_config_bitindex - start_bit_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR < 59
|
||||||
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
|
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
|
||||||
int bit_size, int sync_extension)
|
int bit_size, int sync_extension)
|
||||||
{
|
{
|
||||||
|
@ -165,5 +166,22 @@ int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return ff_mpeg4audio_get_config_gb(c, &gb, sync_extension);
|
return ff_mpeg4audio_get_config_gb(c, &gb, sync_extension, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf,
|
||||||
|
int size, int sync_extension, void *logctx)
|
||||||
|
{
|
||||||
|
GetBitContext gb;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (size <= 0)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
ret = init_get_bits8(&gb, buf, size);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return ff_mpeg4audio_get_config_gb(c, &gb, sync_extension, logctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,11 +53,13 @@ extern const uint8_t ff_mpeg4audio_channels[8];
|
||||||
* @param[in] c MPEG4AudioConfig structure to fill.
|
* @param[in] c MPEG4AudioConfig structure to fill.
|
||||||
* @param[in] gb Extradata from container.
|
* @param[in] gb Extradata from container.
|
||||||
* @param[in] sync_extension look for a sync extension after config if true.
|
* @param[in] sync_extension look for a sync extension after config if true.
|
||||||
|
* @param[in] logctx opaque struct starting with an AVClass element, used for logging.
|
||||||
* @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata.
|
* @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata.
|
||||||
*/
|
*/
|
||||||
int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
|
int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
|
||||||
int sync_extension);
|
int sync_extension, void *logctx);
|
||||||
|
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR < 59
|
||||||
/**
|
/**
|
||||||
* Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
|
* Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
|
||||||
* @param[in] c MPEG4AudioConfig structure to fill.
|
* @param[in] c MPEG4AudioConfig structure to fill.
|
||||||
|
@ -68,6 +70,19 @@ int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
|
||||||
*/
|
*/
|
||||||
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
|
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
|
||||||
int bit_size, int sync_extension);
|
int bit_size, int sync_extension);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
|
||||||
|
* @param[in] c MPEG4AudioConfig structure to fill.
|
||||||
|
* @param[in] buf Extradata from container.
|
||||||
|
* @param[in] size Extradata size in bytes.
|
||||||
|
* @param[in] sync_extension look for a sync extension after config if true.
|
||||||
|
* @param[in] logctx opaque struct starting with an AVClass element, used for logging.
|
||||||
|
* @return negative AVERROR code on error, AudioSpecificConfig bit index in extradata on success.
|
||||||
|
*/
|
||||||
|
int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf,
|
||||||
|
int size, int sync_extension, void *logctx);
|
||||||
|
|
||||||
enum AudioObjectType {
|
enum AudioObjectType {
|
||||||
AOT_NULL,
|
AOT_NULL,
|
||||||
|
|
Loading…
Reference in New Issue