diff --git a/Changelog b/Changelog index fef0d14899..8d988d3b32 100644 --- a/Changelog +++ b/Changelog @@ -9,6 +9,7 @@ version - elbg filter - string validation in ffprobe - support for decoding through VDPAU in ffmpeg (the -hwaccel option) +- complete Voxware MetaSound decoder version 2.1: diff --git a/doc/general.texi b/doc/general.texi index 3aecb1250a..a3221d54fb 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -943,7 +943,6 @@ following image formats are supported: @item Vorbis @tab E @tab X @tab A native but very primitive encoder exists. @item Voxware MetaSound @tab @tab X - @tab imperfect and incomplete support @item WavPack @tab X @tab X @item Westwood Audio (SND1) @tab @tab X @item Windows Media Audio 1 @tab X @tab X diff --git a/libavcodec/metasound.c b/libavcodec/metasound.c index 3bbd791838..677e959d48 100644 --- a/libavcodec/metasound.c +++ b/libavcodec/metasound.c @@ -187,7 +187,7 @@ static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx, sub = mtab->fmode[bits->ftype].sub; - if (bits->ftype != TWINVQ_FT_SHORT) + if (bits->ftype != TWINVQ_FT_SHORT && !tctx->is_6kbps) get_bits(&gb, 2); read_cb_data(tctx, &gb, bits->main_coeffs, bits->ftype); @@ -307,6 +307,12 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx) ibps = avctx->bit_rate / (1000 * avctx->channels); switch ((avctx->channels << 16) + (isampf << 8) + ibps) { + case (1 << 16) + ( 8 << 8) + 6: + tctx->mtab = &ff_metasound_mode0806; + break; + case (2 << 16) + ( 8 << 8) + 6: + tctx->mtab = &ff_metasound_mode0806s; + break; case (1 << 16) + ( 8 << 8) + 8: tctx->mtab = &ff_metasound_mode0808; break; @@ -362,6 +368,7 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx) tctx->decode_ppc = decode_ppc; tctx->frame_size = avctx->bit_rate * tctx->mtab->size / avctx->sample_rate; + tctx->is_6kbps = ibps == 6; return ff_twinvq_decode_init(avctx); } diff --git a/libavcodec/metasound_data.c b/libavcodec/metasound_data.c index 891391b4e0..ed23cdf34d 100644 --- a/libavcodec/metasound_data.c +++ b/libavcodec/metasound_data.c @@ -15198,6 +15198,24 @@ static const uint16_t bark_tab_s44_128[] = { 1, 2, 1, 2, 3, 4, 6, 10, 23, 76 }; +const TwinVQModeTab ff_metasound_mode0806 = { + { + { 8, bark_tab_s8_64, 10, fcb8s, 1, 5, cb0806ss0, cb0806ss1, 27 }, + { 2, bark_tab_m8_256, 20, fcb8m, 2, 5, cb0806sm0, cb0806sm1, 22 }, + { 1, bark_tab_l8_512, 30, fcb8l, 3, 6, cb0806sl0, cb0806sl1, 24 } + }, + 512, 12, lsp8, 1, 5, 3, 3, shape8, 8, 28, 20, 6, 200 +}; + +const TwinVQModeTab ff_metasound_mode0806s = { + { + { 8, bark_tab_s8s_64, 10, fcb8ss, 1, 5, cb0806ss0, cb0806ss1, 27 }, + { 2, bark_tab_m8s_256, 20, fcb8sm, 2, 5, cb0806sm0, cb0806sm1, 22 }, + { 1, bark_tab_l8s_512, 30, fcb8sl, 3, 6, cb0806sl0, cb0806sl1, 24 } + }, + 512, 12, lsp8s, 1, 5, 3, 3, shape8s, 8, 28, 20, 6, 200 +}; + const TwinVQModeTab ff_metasound_mode0808 = { { { 8, bark_tab_s8_64, 10, fcb8s, 1, 5, cb0808s0, cb0808s1, 18 }, diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 31fefa4cf9..08a7a9f4e8 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -704,7 +704,7 @@ static av_cold void init_bitstream_params(TwinVQContext *tctx) TWINVQ_WINDOW_TYPE_BITS + mtab->fmode[i].sub * (bse_bits[i] + n_ch * TWINVQ_SUB_GAIN_BITS); - if (tctx->codec == TWINVQ_CODEC_METASOUND) { + if (tctx->codec == TWINVQ_CODEC_METASOUND && !tctx->is_6kbps) { bsize_no_main_cb[1] += 2; bsize_no_main_cb[2] += 2; } diff --git a/libavcodec/twinvq.h b/libavcodec/twinvq.h index 9ff355470e..c4e9688d46 100644 --- a/libavcodec/twinvq.h +++ b/libavcodec/twinvq.h @@ -141,6 +141,8 @@ typedef struct TwinVQContext { const TwinVQModeTab *mtab; + int is_6kbps; + // history float lsp_hist[2][20]; ///< LSP coefficients of the last frame float bark_hist[3][2][40]; ///< BSE coefficients of last frame diff --git a/libavcodec/twinvqdec.c b/libavcodec/twinvqdec.c index 9fce3c39cf..67ce031391 100644 --- a/libavcodec/twinvqdec.c +++ b/libavcodec/twinvqdec.c @@ -402,6 +402,7 @@ static av_cold int twinvq_decode_init(AVCodecContext *avctx) tctx->decode_ppc = decode_ppc; tctx->frame_size = avctx->bit_rate * tctx->mtab->size / avctx->sample_rate + 8; + tctx->is_6kbps = 0; if (avctx->block_align && avctx->block_align * 8 / tctx->frame_size > 1) { av_log(avctx, AV_LOG_ERROR, "VQF TwinVQ should have only one frame per packet\n");