summaryrefslogtreecommitdiffstats
path: root/audio/out/internal.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-07-07 17:35:09 +0200
committerwm4 <wm4@nowhere>2017-07-07 17:54:05 +0200
commit90dd2298713d3414bad39b6e8648490cd9f52603 (patch)
treee1da2c0b5d04a2e2fd6bce752131dd3089e603f9 /audio/out/internal.h
parent7c1db05cbb386522017942a173cc9552637a660e (diff)
downloadmpv-90dd2298713d3414bad39b6e8648490cd9f52603.tar.bz2
mpv-90dd2298713d3414bad39b6e8648490cd9f52603.tar.xz
audio/out: add helper code to do 24 bit conversion in AO
I plan to remove the S24 sample formats in mpv. It seems like we should still support this _somehow_ in AOs though. So the idea is to convert the data to more obscure representations (that would not be useful for filtering etc. anyway) within the AO. This commit adds helper to enable this. ao_convert_fmt is meant to provide mechanisms for this, rather than a generic audio format description (as the latter leads only to overly generic misery). The conversion also supports only cases which we think will be needed at all. The main advantage of this approach is that we get S24 out of sight, and that we could support other crazy formats (like S20). The main disadvantage is that usually S32 will be selected (if both S32 and S24 are available), and there's no user control to force S24. That doesn't really matter though, and at worst makes testing harder or will lead to unpleasant arguments with audiophiles (they'd be wrong anyway). ao_convert_fmt.pad_lsb is ignored, although if we ever find a case in which playing S32 with data in the LSBs breaks when playing it as padded 24 bit format. (For example, WAVEFORMATEXTENSIBLE recommends setting the unused bits to 0 if wValidBitsPerSample implies LSB padding.)
Diffstat (limited to 'audio/out/internal.h')
-rw-r--r--audio/out/internal.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/audio/out/internal.h b/audio/out/internal.h
index 0c59ce973e..28deefe128 100644
--- a/audio/out/internal.h
+++ b/audio/out/internal.h
@@ -215,4 +215,19 @@ bool ao_chmap_sel_get_def(struct ao *ao, const struct mp_chmap_sel *s,
void ao_device_list_add(struct ao_device_list *list, struct ao *ao,
struct ao_device_desc *e);
+struct ao_convert_fmt {
+ int src_fmt; // source AF_FORMAT_*
+ int channels; // number of channels
+ int dst_bits; // total target data sample size
+ int pad_msb; // padding in the MSB (i.e. required shifting)
+ int pad_lsb; // padding in LSB (required 0 bits) (ignored)
+};
+
+bool ao_can_convert_inplace(struct ao_convert_fmt *fmt);
+bool ao_need_conversion(struct ao_convert_fmt *fmt);
+void ao_convert_inplace(struct ao_convert_fmt *fmt, void **data, int num_samples);
+
+int ao_read_data_converted(struct ao *ao, struct ao_convert_fmt *fmt,
+ void **data, int samples, int64_t out_time_us);
+
#endif