Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate IMA-ADPCM #91492

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion editor/import/resource_importer_wav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
AudioStreamWAV::Format dst_format;

if (compression == 1) {
#ifndef DISABLE_DEPRECATED
WARN_DEPRECATED_MSG("IMA ADPCM compression is deprecated. Consider using Quite OK Audio instead.");
dst_format = AudioStreamWAV::FORMAT_IMA_ADPCM;
if (format_channels == 1) {
_compress_ima_adpcm(data, pcm_data);
Expand Down Expand Up @@ -493,7 +495,9 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
w[i * 2 + 1] = rr[i];
}
}

#else
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "This engine build was compiled without deprecated features. IMA ADPCM is not available.");
#endif // DISABLE_DEPRECATED
} else {
dst_format = is16 ? AudioStreamWAV::FORMAT_16_BITS : AudioStreamWAV::FORMAT_8_BITS;
bool enforce16 = is16 || compression == 2;
Expand Down
2 changes: 2 additions & 0 deletions editor/import/resource_importer_wav.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ResourceImporterWAV : public ResourceImporter {
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;

#ifndef DISABLE_DEPRECATED
static void _compress_ima_adpcm(const Vector<float> &p_data, Vector<uint8_t> &dst_data) {
static const int16_t _ima_adpcm_step_table[89] = {
7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
Expand Down Expand Up @@ -139,6 +140,7 @@ class ResourceImporterWAV : public ResourceImporter {
}
}
}
#endif // DISABLE_DEPRECATED

virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;

Expand Down
19 changes: 17 additions & 2 deletions scene/resources/audio_stream_wav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "core/io/marshalls.h"

void AudioStreamPlaybackWAV::start(double p_from_pos) {
#ifndef DISABLE_DEPRECATED
if (base->format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
//no seeking in IMA_ADPCM
for (int i = 0; i < 2; i++) {
Expand All @@ -48,8 +49,11 @@ void AudioStreamPlaybackWAV::start(double p_from_pos) {

offset = 0;
} else {
#endif
seek(p_from_pos);
#ifndef DISABLE_DEPRECATED
}
#endif

sign = 1;
active = true;
Expand All @@ -72,9 +76,11 @@ double AudioStreamPlaybackWAV::get_playback_position() const {
}

void AudioStreamPlaybackWAV::seek(double p_time) {
#ifndef DISABLE_DEPRECATED
if (base->format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
return; //no seeking in ima-adpcm
}
#endif

double max = base->get_length();
if (p_time < 0) {
Expand All @@ -98,6 +104,7 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst,
pos <<= 1;
}

#ifndef DISABLE_DEPRECATED
if (is_ima_adpcm) {
int64_t sample_pos = pos + p_ima_adpcm[0].window_ofs;

Expand Down Expand Up @@ -175,6 +182,7 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst,
}

} else {
#endif // DISABLE_DEPRECATED
if (is_qoa) {
if (pos != p_qoa->cache_pos) { // Prevents triple decoding on lower mix rates.
for (int i = 0; i < 2; i++) {
Expand Down Expand Up @@ -252,7 +260,9 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst,
if (is_stereo) {
final_r = final_r + ((next_r - final_r) * frac >> MIX_FRAC_BITS);
}
#ifndef DISABLE_DEPRECATED
}
#endif

if (!is_stereo) {
final_r = final; //copy to right channel if stereo
Expand Down Expand Up @@ -328,13 +338,15 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_
const void *data = dataptr + AudioStreamWAV::DATA_PAD;
AudioFrame *dst_buff = p_buffer;

#ifndef DISABLE_DEPRECATED
if (format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
if (loop_format != AudioStreamWAV::LOOP_DISABLED) {
ima_adpcm[0].loop_pos = loop_begin_fp >> MIX_FRAC_BITS;
ima_adpcm[1].loop_pos = loop_begin_fp >> MIX_FRAC_BITS;
loop_format = AudioStreamWAV::LOOP_FORWARD;
}
}
#endif

while (todo > 0) {
int64_t limit = 0;
Expand Down Expand Up @@ -375,7 +387,7 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_
sign *= -1;
} else {
/* go to loop-begin */

#ifndef DISABLE_DEPRECATED
if (format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
for (int i = 0; i < 2; i++) {
ima_adpcm[i].step_index = ima_adpcm[i].loop_step_index;
Expand All @@ -384,8 +396,11 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_
}
offset = loop_begin_fp;
} else {
#endif
offset = loop_begin_fp + (offset - loop_end_fp);
#ifndef DISABLE_DEPRECATED
}
#endif
}
} else {
/* no loop, check for end of sample */
Expand Down Expand Up @@ -413,7 +428,7 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_

todo -= target;

switch (base->format) {
switch (format) {
case AudioStreamWAV::FORMAT_8_BITS: {
if (is_stereo) {
do_resample<int8_t, true, false, false>((int8_t *)data, dst_buff, offset, increment, target, ima_adpcm, &qoa);
Expand Down
9 changes: 7 additions & 2 deletions servers/audio/effects/audio_effect_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ Ref<AudioStreamWAV> AudioEffectRecord::get_recording() const {
int16_t v = CLAMP(current_instance->recording_data[i] * 32768, -32768, 32767);
encode_uint16(v, &w[i * 2]);
}
} else if (dst_format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
}
#ifndef DISABLE_DEPRECATED
else if (dst_format == AudioStreamWAV::FORMAT_IMA_ADPCM) {

//byte interleave
Vector<float> left;
Vector<float> right;
Expand Down Expand Up @@ -259,7 +262,9 @@ Ref<AudioStreamWAV> AudioEffectRecord::get_recording() const {
w[i * 2 + 0] = rl[i];
w[i * 2 + 1] = rr[i];
}
} else {
}
#endif
else {
ERR_PRINT("Format not implemented.");
}

Expand Down
Loading