lib/igt_audio: use double instead of int16_t
PATCH 1/1 lib/igt_audio: use double instead of int16_t
In order to be able to generate S32_LE signals, we need a higher precision than S16_LE. Change the signal generation code to use double instead of int16_t and introduce a new helper to fill a buffer with S16_LE samples. We already use arrays of doubles elsewhere (see audio_signal_detect). Similar format-specific helpers will be added for S32_LE in the future.
---
This patch is necessary for supporting more audio formats, and will be useful for amplitude checks (no need to convert back-and-forth between normalized double values and int16_t).
lib/igt_audio.c | 41 ++++++++++++++++++++++++++++------------- lib/igt_audio.h | 4 +++- tests/kms_chamelium.c | 2 +- 3 files changed, 32 insertions(+), 15 deletions(-)
lib/igt_audio.c +28 -13
@@ -51,7 +51,7 @@ struct audio_signal_freq {int freq;int channel; -int16_t *period; +double *period;size_t period_len;int offset; };
@@ -142,7 +142,7 @@ int audio_signal_add_frequency(struct audio_signal *signal, int frequency,*/ void audio_signal_synthesize (struct audio_signal *signal) { -int16_t *period; +double *period;double value;size_t period_len;int freq;
@@ -152,13 +152,13 @@ void audio_signal_synthesize(struct audio_signal *signal) freq = signal->freqs[i].freq; period_len = signal->sampling_rate / freq; - period =calloc (1 , period_len *sizeof (int16_t )); + period =calloc (period_len,sizeof (double ));for (j =0 ; j < period_len; j++) { value =2.0 *M_PI * freq / signal->sampling_rate * j; - value =sin (value) *INT16_MAX / signal->freqs_count; + value =sin (value) / signal->freqs_count; - period[j] = (int16_t ) value; + period[j] = value; } signal->freqs[i].period = period;
@@ -202,19 +202,19 @@ void audio_signal_reset(struct audio_signal *signal)* @samples: The number of samples to fill * * Fill the requested number of samples to the target buffer with the audio -* signal data (in interleaved S16_LE format), at the requested sampling rate +* signal data (in interleaved double format), at the requested sampling rate * and number of channels. */ -void audio_signal_fill (struct audio_signal *signal,int16_t *buffer, -size_t buffer_len) +void audio_signal_fill (struct audio_signal *signal,double *buffer, +size_t samples) { -int16_t *destination, *source; +double *destination, *source;struct audio_signal_freq *freq;int total;int count;int i, j, k; -memset (buffer,0 ,sizeof (int16_t ) * signal->channels * buffer_len); +memset (buffer,0 ,sizeof (double ) * signal->channels * samples);for (i =0 ; i < signal->freqs_count; i++) { freq = &signal->freqs[i];
@@ -222,13 +222,13 @@ void audio_signal_fill(struct audio_signal *signal, int16_t *buffer,igt_assert (freq->period); -while (total < buffer_len) { +while (total < samples) { source = freq->period + freq->offset; destination = buffer + total * signal->channels; count = freq->period_len - freq->offset; -if (count > buffer_len - total) - count = buffer_len - total; +if (count > samples - total) + count = samples - total; freq->offset += count; freq->offset %= freq->period_len;
@@ -247,6 +247,21 @@ void audio_signal_fill(struct audio_signal *signal, int16_t *buffer, } } +void audio_signal_fill_s16_le (struct audio_signal *signal,int16_t *buffer, +size_t samples) +{ +double *tmp; +size_t i; + + tmp =malloc (sizeof (double ) * signal->channels * samples); +audio_signal_fill (signal, tmp, samples); + +for (i =0 ; i < signal->channels * samples; ++i) + buffer[i] =INT16_MAX * tmp[i]; + +free (tmp); +} +/** * Checks that frequencies specified in signal, and only those, are included * in the input data.
lib/igt_audio.h +3 -1
@@ -40,8 +40,10 @@ int audio_signal_add_frequency(struct audio_signal *signal, int frequency, int channel);void audio_signal_synthesize (struct audio_signal *signal);void audio_signal_reset (struct audio_signal *signal); -void audio_signal_fill (struct audio_signal *signal,int16_t *buffer, +void audio_signal_fill (struct audio_signal *signal,double *buffer,size_t buffer_len); +void audio_signal_fill_s16_le (struct audio_signal *signal,int16_t *buffer, +size_t buffer_len);bool audio_signal_detect (struct audio_signal *signal,int sampling_rate,int channel,double *data,size_t data_len); size_t audio_extract_channel_s32_le(double *dst, size_t dst_cap,
tests/kms_chamelium.c +1 -1
@@ -790,7 +790,7 @@ audio_output_callback(void *data, short *buffer, int frames) {struct audio_state *state = data; -audio_signal_fill (state->signal, buffer, frames); +audio_signal_fill_s16_le (state->signal, buffer, frames);return state->run ?0 :-1 ; }
--
2.21.0
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for lib/igt_audio: use double instead of int16_t
== Series Details ==
== Series Details ==
Series: lib/igt_audio: use double instead of int16_t
URL : https://patchwork.freedesktop.org/series/60616/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6078 -> IGTPW_2977
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/60616/revisions/1/mbox/
Known issues
------------
Here are the changes found in IGTPW_2977 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_ctx_exec@basic:
- fi-icl-u2: [PASS][1] -> [INCOMPLETE][2] ([fdo#107713])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/fi-icl-u2/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/fi-icl-u2/igt@[email protected]
#### Possible fixes ####
* igt@i915_selftest@live_contexts:
- fi-bdw-gvtdvm: [DMESG-FAIL][3] ([fdo#110235]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
* igt@i915_selftest@live_hangcheck:
- fi-skl-iommu: [INCOMPLETE][5] ([fdo#108602] / [fdo#108744]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108602
[fdo#108744]: https://bugs.freedesktop.org/show_bug.cgi?id=108744
[fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
[fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235
Participating hosts (54 -> 41)
------------------------------
Missing (13): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-skl-6770hq fi-byt-squawks fi-bsw-cyan fi-apl-guc fi-ctg-p8600 fi-byt-clapper fi-gdg-551 fi-pnv-d510 fi-icl-dsi fi-bdw-samus
Build changes
-------------
* IGT: IGT_4984 -> IGTPW_2977
CI_DRM_6078: c8c778558fd52abd3303d8ea324df788062adc97 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2977: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/
IGT_4984: 66c887d2f7a92a4a97acd9611d5342afc5d4f815 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 7 lines · Simon Ser
In order to be able to generate
S32_LEsignals, we need a higher precision thanS16_LE. Change the signal generation code to use double instead ofint16_tand introduce a new helper to fill a buffer withS16_LEsamples. We already use arrays of doubles elsewhere (seeaudio_signal_detect). Similar format-specific helpers will be added forS32_LEin the future.Signed-off-by Simon Ser <[email protected]>
Missing shards due to a Jenkin's hiccup. I'll requeued them.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.IGT: success for lib/igt_audio: use double instead of int16_t
In reply to Simon Ser== Series Details ==
== Series Details ==
Series: lib/igt_audio: use double instead of int16_t
URL : https://patchwork.freedesktop.org/series/60616/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6078_full -> IGTPW_2977_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/60616/revisions/1/mbox/
Known issues
------------
Here are the changes found in IGTPW_2977_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_eio@in-flight-suspend:
- shard-apl: [PASS][1] -> [DMESG-WARN][2] ([fdo#108566]) +1 similar issue
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-apl7/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-apl3/igt@[email protected]
- shard-glk: [PASS][3] -> ([FAIL][4], [PASS][5]) ([fdo#110667])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-glk2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-glk8/igt@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-glk7/igt@[email protected]
* igt@gem_tiled_swapping@non-threaded:
- shard-glk: [PASS][6] -> ([DMESG-WARN][7], [DMESG-WARN][8]) ([fdo#108686])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-glk4/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-glk9/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-glk7/igt@[email protected]
* igt@kms_flip@flip-vs-expired-vblank:
- shard-glk: [PASS][9] -> ([FAIL][10], [PASS][11]) ([fdo#102887])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-glk7/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-glk9/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-glk6/igt@[email protected]
* igt@kms_vblank@pipe-b-ts-continuation-suspend:
- shard-kbl: [PASS][12] -> ([PASS][13], [DMESG-WARN][14]) ([fdo#108566])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-kbl6/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-kbl6/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-kbl7/igt@[email protected]
* igt@perf_pmu@rc6:
- shard-kbl: [PASS][15] -> [SKIP][16] ([fdo#109271])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-kbl1/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-kbl4/igt@[email protected]
#### Possible fixes ####
* igt@i915_suspend@fence-restore-untiled:
- shard-apl: [DMESG-WARN][17] ([fdo#108566]) -> [PASS][18] +3 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-apl1/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-apl6/igt@[email protected]
* igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
- shard-hsw: [FAIL][19] ([fdo#105767]) -> ([PASS][20], [PASS][21])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-hsw1/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-hsw2/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-hsw7/igt@[email protected]
* igt@kms_cursor_legacy@cursor-vs-flip-atomic:
- shard-hsw: [INCOMPLETE][22] ([fdo#103540]) -> ([PASS][23], [PASS][24])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-hsw8/igt@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-hsw5/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-hsw8/igt@[email protected]
* igt@kms_vblank@pipe-b-ts-continuation-dpms-suspend:
- shard-snb: [DMESG-WARN][25] ([fdo#110684]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-snb5/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-snb1/igt@[email protected]
* igt@tools_test@tools_test:
- shard-glk: [SKIP][27] ([fdo#109271]) -> ([PASS][28], [PASS][29])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-glk4/igt@tools_test@tools_test.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-glk7/igt@tools_test@tools_test.html
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-glk8/igt@tools_test@tools_test.html
#### Warnings ####
* igt@kms_setmode@basic:
- shard-kbl: [FAIL][30] ([fdo#99912]) -> ([PASS][31], [FAIL][32]) ([fdo#99912])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6078/shard-kbl7/igt@[email protected]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-kbl2/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/shard-kbl7/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102887]: https://bugs.freedesktop.org/show_bug.cgi?id=102887
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#108686]: https://bugs.freedesktop.org/show_bug.cgi?id=108686
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#110667]: https://bugs.freedesktop.org/show_bug.cgi?id=110667
[fdo#110684]: https://bugs.freedesktop.org/show_bug.cgi?id=110684
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
Participating hosts (10 -> 6)
------------------------------
Missing (4): pig-skl-6260u shard-skl pig-hsw-4770r pig-glk-j5005
Build changes
-------------
* IGT: IGT_4984 -> IGTPW_2977
* Piglit: piglit_4509 -> None
CI_DRM_6078: c8c778558fd52abd3303d8ea324df788062adc97 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2977: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/
IGT_4984: 66c887d2f7a92a4a97acd9611d5342afc5d4f815 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2977/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev