PcmFormat.hxx 2.26 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2017 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13
 * http://www.musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14 15 16 17
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 19
 */

Max Kellermann's avatar
Max Kellermann committed
20 21
#ifndef MPD_PCM_FORMAT_HXX
#define MPD_PCM_FORMAT_HXX
22

23
#include "SampleFormat.hxx"
24

25 26
#include <stdint.h>

27
template<typename T> struct ConstBuffer;
28
class PcmBuffer;
29
class PcmDither;
30

31 32 33 34
/**
 * Converts PCM samples to 16 bit.  If the source format is 24 bit,
 * then dithering is applied.
 *
Max Kellermann's avatar
Max Kellermann committed
35 36
 * @param buffer a #PcmBuffer object
 * @param dither a #PcmDither object for 24-to-16 conversion
37 38 39
 * @param src the source PCM buffer
 * @return the destination buffer
 */
40 41
gcc_pure
ConstBuffer<int16_t>
42
pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
43
		  SampleFormat src_format, ConstBuffer<void> src) noexcept;
44

45 46 47
/**
 * Converts PCM samples to 24 bit (32 bit alignment).
 *
Max Kellermann's avatar
Max Kellermann committed
48
 * @param buffer a #PcmBuffer object
49 50 51
 * @param src the source PCM buffer
 * @return the destination buffer
 */
52 53
gcc_pure
ConstBuffer<int32_t>
54
pcm_convert_to_24(PcmBuffer &buffer,
55
		  SampleFormat src_format, ConstBuffer<void> src) noexcept;
56

57 58 59
/**
 * Converts PCM samples to 32 bit.
 *
Max Kellermann's avatar
Max Kellermann committed
60
 * @param buffer a #PcmBuffer object
61 62 63
 * @param src the source PCM buffer
 * @return the destination buffer
 */
64 65
gcc_pure
ConstBuffer<int32_t>
66
pcm_convert_to_32(PcmBuffer &buffer,
67
		  SampleFormat src_format, ConstBuffer<void> src) noexcept;
68

69 70 71
/**
 * Converts PCM samples to 32 bit floating point.
 *
Max Kellermann's avatar
Max Kellermann committed
72
 * @param buffer a #PcmBuffer object
73 74 75
 * @param src the source PCM buffer
 * @return the destination buffer
 */
76 77
gcc_pure
ConstBuffer<float>
78
pcm_convert_to_float(PcmBuffer &buffer,
79
		     SampleFormat src_format, ConstBuffer<void> src) noexcept;
80

81
#endif