Skip to content

Commit

Permalink
Обновление ffmpeg n7.1-dev-1585-g0b330d8642.
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lt committed Jun 29, 2024
1 parent bd2af51 commit 585a814
Show file tree
Hide file tree
Showing 39 changed files with 1,600 additions and 1,127 deletions.
4 changes: 2 additions & 2 deletions docs/Changelog.Rus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
Обновлен японский перевод (автор tsubasanouta).

Обновлены библиотеки:
ffmpeg git-n7.1-dev-1509-g0c0e7ec81e;
vvdec git-v2.3.0-24-gad8f4bb.
ffmpeg n7.1-dev-1585-g0b330d8642;
vvdec v2.3.0-24-gad8f4bb.


1.7.2 - 2024-06-07
Expand Down
4 changes: 2 additions & 2 deletions docs/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Updated Korean translation (by Hackjjang).
Updated Japanese translation (by tsubasanouta).

Updated libraries:
ffmpeg git-n7.1-dev-1509-g0c0e7ec81e;
vvdec git-v2.3.0-24-gad8f4bb.
ffmpeg n7.1-dev-1585-g0b330d8642;
vvdec v2.3.0-24-gad8f4bb.


1.7.2 - 2024-06-07
Expand Down
7 changes: 2 additions & 5 deletions src/ExtLib/ffmpeg/libavcodec/aac/aacdec_lpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static void parse_qn(GetBitContext *gb, int *qn, int nk_mode, int no_qn)
static int parse_codebook_idx(GetBitContext *gb, uint32_t *kv,
int nk_mode, int no_qn)
{
int idx, n, nk;
int n, nk;

int qn[2];
parse_qn(gb, qn, nk_mode, no_qn);
Expand All @@ -114,7 +114,7 @@ static int parse_codebook_idx(GetBitContext *gb, uint32_t *kv,
}
}

idx = get_bits(gb, 4*n);
skip_bits(gb, 4*n);

if (nk > 0)
for (int i = 0; i < 8; i++)
Expand Down Expand Up @@ -145,7 +145,6 @@ int ff_aac_ldp_parse_channel_stream(AACDecContext *ac, AACUSACConfig *usac,
int k;
const uint8_t *mod;
int first_ldp_flag;
int first_tcx_flag;

ce->ldp.acelp_core_mode = get_bits(gb, 3);
ce->ldp.lpd_mode = get_bits(gb, 5);
Expand All @@ -157,7 +156,6 @@ int ff_aac_ldp_parse_channel_stream(AACDecContext *ac, AACUSACConfig *usac,
mod = ff_aac_lpd_mode_tab[ce->ldp.lpd_mode];

first_ldp_flag = !ce->ldp.core_mode_last;
first_tcx_flag = 1;
if (first_ldp_flag)
ce->ldp.last_lpd_mode = -1; /* last_ldp_mode is a **STATEFUL** value */

Expand All @@ -179,7 +177,6 @@ int ff_aac_ldp_parse_channel_stream(AACDecContext *ac, AACUSACConfig *usac,
// parse_tcx_coding();
ce->ldp.last_lpd_mode = mod[k];
k += (1 << (mod[k] - 1));
first_tcx_flag = 0;
}
}

Expand Down
122 changes: 107 additions & 15 deletions src/ExtLib/ffmpeg/libavcodec/aac/aacdec_usac.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "aacdec_lpd.h"
#include "aacdec_ac.h"

#include "libavcodec/aacsbr.h"

#include "libavcodec/aactab.h"
#include "libavutil/mem.h"
#include "libavcodec/mpeg4audio.h"
Expand Down Expand Up @@ -145,14 +147,19 @@ static int decode_loudness_set(AACDecContext *ac, AACUSACConfig *usac,
return 0;
}

static void decode_usac_sbr_data(AACUsacElemConfig *e, GetBitContext *gb)
static int decode_usac_sbr_data(AACDecContext *ac,
AACUsacElemConfig *e, GetBitContext *gb)
{
uint8_t header_extra1;
uint8_t header_extra2;

e->sbr.harmonic_sbr = get_bits1(gb); /* harmonicSBR */
e->sbr.bs_intertes = get_bits1(gb); /* bs_interTes */
e->sbr.bs_pvc = get_bits1(gb); /* bs_pvc */
if (e->sbr.harmonic_sbr || e->sbr.bs_intertes || e->sbr.bs_pvc) {
avpriv_report_missing_feature(ac->avctx, "AAC USAC eSBR");
return AVERROR_PATCHWELCOME;
}

e->sbr.dflt.start_freq = get_bits(gb, 4); /* dflt_start_freq */
e->sbr.dflt.stop_freq = get_bits(gb, 4); /* dflt_stop_freq */
Expand All @@ -179,6 +186,8 @@ static void decode_usac_sbr_data(AACUsacElemConfig *e, GetBitContext *gb)
e->sbr.dflt.interpol_freq = get_bits1(gb); /* dflt_interpol_freq */
e->sbr.dflt.smoothing_mode = get_bits1(gb); /* dflt_smoothing_mode */
}

return 0;
}

static void decode_usac_element_core(AACUsacElemConfig *e,
Expand All @@ -190,13 +199,17 @@ static void decode_usac_element_core(AACUsacElemConfig *e,
e->sbr.ratio = sbr_ratio;
}

static void decode_usac_element_pair(AACUsacElemConfig *e, GetBitContext *gb)
static int decode_usac_element_pair(AACDecContext *ac,
AACUsacElemConfig *e, GetBitContext *gb)
{
e->stereo_config_index = 0;
if (e->sbr.ratio) {
decode_usac_sbr_data(e, gb);
int ret = decode_usac_sbr_data(ac, e, gb);
if (ret < 0)
return ret;
e->stereo_config_index = get_bits(gb, 2);
}

if (e->stereo_config_index) {
e->mps.freq_res = get_bits(gb, 3); /* bsFreqRes */
e->mps.fixed_gain = get_bits(gb, 3); /* bsFixedGainDMX */
Expand All @@ -216,6 +229,8 @@ static void decode_usac_element_pair(AACUsacElemConfig *e, GetBitContext *gb)
if (e->mps.temp_shape_config == 2)
e->mps.env_quant_mode = get_bits1(gb); /* bsEnvQuantMode */
}

return 0;
}

static int decode_usac_extension(AACDecContext *ac, AACUsacElemConfig *e,
Expand Down Expand Up @@ -294,6 +309,9 @@ int ff_aac_usac_reset_state(AACDecContext *ac, OutputConfiguration *oc)
AACUsacStereo *us = &che->us;
memset(us, 0, sizeof(*us));

if (e->sbr.ratio)
ff_aac_sbr_config_usac(ac, che, e);

for (int j = 0; j < ch; j++) {
SingleChannelElement *sce = &che->ch[ch];
AACUsacElemData *ue = &sce->ue;
Expand All @@ -320,6 +338,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
uint8_t freq_idx;
uint8_t channel_config_idx;
int nb_channels = 0;
int ratio_mult, ratio_dec;
int samplerate;
int sbr_ratio;
MPEG4AudioConfig *m4ac = &oc->m4ac;
Expand All @@ -329,6 +348,9 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
int map_pos_set = 0;
uint8_t layout_map[MAX_ELEM_ID*4][3] = { 0 };

if (!ac)
return AVERROR_PATCHWELCOME;

memset(usac, 0, sizeof(*usac));

freq_idx = get_bits(gb, 5); /* usacSamplingFrequencyIndex */
Expand All @@ -340,8 +362,6 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
return AVERROR(EINVAL);
}

m4ac->sample_rate = avctx->sample_rate = samplerate;

usac->core_sbr_frame_len_idx = get_bits(gb, 3); /* coreSbrFrameLengthIndex */
m4ac->frame_length_short = usac->core_sbr_frame_len_idx == 0 ||
usac->core_sbr_frame_len_idx == 2;
Expand All @@ -354,7 +374,26 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
usac->core_sbr_frame_len_idx == 4 ? 1 :
0;

if (sbr_ratio == 2) {
ratio_mult = 8;
ratio_dec = 3;
} else if (sbr_ratio == 3) {
ratio_mult = 2;
ratio_dec = 1;
} else if (sbr_ratio == 4) {
ratio_mult = 4;
ratio_dec = 1;
} else {
ratio_mult = 1;
ratio_dec = 1;
}

avctx->sample_rate = samplerate;
m4ac->ext_sample_rate = samplerate;
m4ac->sample_rate = (samplerate * ratio_dec) / ratio_mult;

m4ac->sampling_index = ff_aac_sample_rate_idx(m4ac->sample_rate);
m4ac->sbr = sbr_ratio > 0;

channel_config_idx = get_bits(gb, 5); /* channelConfigurationIndex */
if (!channel_config_idx) {
Expand Down Expand Up @@ -426,8 +465,11 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
case ID_USAC_SCE: /* SCE */
/* UsacCoreConfig */
decode_usac_element_core(e, gb, sbr_ratio);
if (e->sbr.ratio > 0)
decode_usac_sbr_data(e, gb);
if (e->sbr.ratio > 0) {
ret = decode_usac_sbr_data(ac, e, gb);
if (ret < 0)
return ret;
}
layout_map[map_count][0] = TYPE_SCE;
layout_map[map_count][1] = elem_id[0]++;
if (!map_pos_set)
Expand All @@ -437,7 +479,9 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
case ID_USAC_CPE: /* UsacChannelPairElementConf */
/* UsacCoreConfig */
decode_usac_element_core(e, gb, sbr_ratio);
decode_usac_element_pair(e, gb);
ret = decode_usac_element_pair(ac, e, gb);
if (ret < 0)
return ret;
layout_map[map_count][0] = TYPE_CPE;
layout_map[map_count][1] = elem_id[1]++;
if (!map_pos_set)
Expand Down Expand Up @@ -1307,13 +1351,14 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac,
int ret;
int arith_reset_flag;
AACUsacStereo *us = &che->us;
int core_nb_channels = nb_channels;

/* Local symbols */
uint8_t global_gain;

us->common_window = 0;

for (int ch = 0; ch < nb_channels; ch++) {
for (int ch = 0; ch < core_nb_channels; ch++) {
SingleChannelElement *sce = &che->ch[ch];
AACUsacElemData *ue = &sce->ue;

Expand All @@ -1323,13 +1368,16 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac,
ue->core_mode = get_bits1(gb);
}

if (nb_channels == 2) {
if (nb_channels > 1 && ec->stereo_config_index == 1)
core_nb_channels = 1;

if (core_nb_channels == 2) {
ret = decode_usac_stereo_info(ac, usac, ec, che, gb, indep_flag);
if (ret)
return ret;
}

for (int ch = 0; ch < nb_channels; ch++) {
for (int ch = 0; ch < core_nb_channels; ch++) {
SingleChannelElement *sce = &che->ch[ch];
IndividualChannelStream *ics = &sce->ics;
AACUsacElemData *ue = &sce->ue;
Expand All @@ -1341,7 +1389,7 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac,
continue;
}

if ((nb_channels == 1) ||
if ((core_nb_channels == 1) ||
(che->ch[0].ue.core_mode != che->ch[1].ue.core_mode))
ue->tns_data_present = get_bits1(gb);

Expand Down Expand Up @@ -1424,7 +1472,29 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac,
}
}

spectrum_decode(ac, usac, che, nb_channels);
if (ec->sbr.ratio) {
int sbr_ch = nb_channels;
if (nb_channels == 2 &&
!(ec->stereo_config_index == 0 || ec->stereo_config_index == 3))
sbr_ch = 1;

ret = ff_aac_sbr_decode_usac_data(ac, che, ec, gb, sbr_ch, indep_flag);
if (ret < 0)
return ret;

if (ec->stereo_config_index) {
avpriv_report_missing_feature(ac->avctx, "AAC USAC Mps212");
return AVERROR_PATCHWELCOME;
}
}

spectrum_decode(ac, usac, che, core_nb_channels);

if (ac->oc[1].m4ac.sbr > 0) {
ac->proc.sbr_apply(ac, che, nb_channels == 2 ? TYPE_CPE : TYPE_SCE,
che->ch[0].output,
che->ch[1].output);
}

return 0;
}
Expand Down Expand Up @@ -1591,9 +1661,29 @@ int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac,
int indep_flag, samples = 0;
int audio_found = 0;
int elem_id[3 /* SCE, CPE, LFE */] = { 0, 0, 0 };

AVFrame *frame = ac->frame;

int ratio_mult, ratio_dec;
AACUSACConfig *usac = &ac->oc[1].usac;
int sbr_ratio = usac->core_sbr_frame_len_idx == 2 ? 2 :
usac->core_sbr_frame_len_idx == 3 ? 3 :
usac->core_sbr_frame_len_idx == 4 ? 1 :
0;

if (sbr_ratio == 2) {
ratio_mult = 8;
ratio_dec = 3;
} else if (sbr_ratio == 3) {
ratio_mult = 2;
ratio_dec = 1;
} else if (sbr_ratio == 4) {
ratio_mult = 4;
ratio_dec = 1;
} else {
ratio_mult = 1;
ratio_dec = 1;
}

ff_aac_output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags,
ac->oc[1].status, 0);

Expand Down Expand Up @@ -1660,8 +1750,10 @@ int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac,
if (audio_found)
samples = ac->oc[1].m4ac.frame_length_short ? 768 : 1024;

samples = (samples * ratio_mult) / ratio_dec;

if (ac->oc[1].status && audio_found) {
avctx->sample_rate = ac->oc[1].m4ac.sample_rate;
avctx->sample_rate = ac->oc[1].m4ac.ext_sample_rate;
avctx->frame_size = samples;
ac->oc[1].status = OC_LOCKED;
}
Expand Down
11 changes: 11 additions & 0 deletions src/ExtLib/ffmpeg/libavcodec/aacsbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ int ff_aac_sbr_decode_extension(AACDecContext *ac, ChannelElement *che,
int ff_aac_sbr_decode_extension_fixed(AACDecContext *ac, ChannelElement *che,
GetBitContext *gb, int crc, int cnt, int id_aac);

/** Due to channel allocation not being known upon SBR parameter transmission,
* supply the parameters separately.
* Functionally identical to ff_aac_sbr_decode_extension() */
int ff_aac_sbr_config_usac(AACDecContext *ac, ChannelElement *che,
AACUsacElemConfig *ue);

/** Decode frame SBR data, USAC. */
int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che,
AACUsacElemConfig *ue, GetBitContext *gb,
int sbr_ch, int indep_flag);

/** Apply one SBR element to one AAC element. */
void ff_aac_sbr_apply(AACDecContext *ac, ChannelElement *che,
int id_aac, void /* float */ *L, void /* float */ *R);
Expand Down
Loading

0 comments on commit 585a814

Please sign in to comment.