| 1 | /* GStreamer |
| 2 | * Copyright (C) 2023 Carlos Rafael Giani <crg7475@mailbox.org> |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public |
| 15 | * License along with this library; if not, write to the |
| 16 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include <gst/gst.h> |
| 23 | #include <gst/audio/audio-prelude.h> |
| 24 | |
| 25 | G_BEGIN_DECLS |
| 26 | |
| 27 | #if G_BYTE_ORDER == G_BIG_ENDIAN |
| 28 | #define _GST_DSD_FORMAT_NE(fmt) GST_DSD_FORMAT_ ## fmt ## BE |
| 29 | #elif G_BYTE_ORDER == G_LITTLE_ENDIAN |
| 30 | #define _GST_DSD_FORMAT_NE(fmt) GST_DSD_FORMAT_ ## fmt ## LE |
| 31 | #endif |
| 32 | |
| 33 | /** |
| 34 | * GstDsdFormat: |
| 35 | * @GST_DSD_FORMAT_UNKNOWN: unknown / invalid DSD format |
| 36 | * @GST_DSD_FORMAT_U8: 8 DSD bits in 1 byte |
| 37 | * @GST_DSD_FORMAT_U16LE: 16 DSD bits in 2 bytes, little endian order |
| 38 | * @GST_DSD_FORMAT_U16BE: 16 DSD bits in 2 bytes, big endian order |
| 39 | * @GST_DSD_FORMAT_U32LE: 32 DSD bits in 4 bytes, little endian order |
| 40 | * @GST_DSD_FORMAT_U32BE: 32 DSD bits in 4 bytes, big endian order |
| 41 | * @GST_NUM_DSD_FORMATS: number of valid DSD formats |
| 42 | * @GST_DSD_FORMAT_U16: 16 DSD bits in 2 bytes, native endianness |
| 43 | * @GST_DSD_FORMAT_U32: 32 DSD bits in 4 bytes, native endianness |
| 44 | * |
| 45 | * Enum value describing how DSD bits are grouped. |
| 46 | * |
| 47 | * Since: 1.24 |
| 48 | */ |
| 49 | typedef enum { |
| 50 | GST_DSD_FORMAT_UNKNOWN = 0, |
| 51 | GST_DSD_FORMAT_U8, |
| 52 | GST_DSD_FORMAT_U16LE, |
| 53 | GST_DSD_FORMAT_U16BE, |
| 54 | GST_DSD_FORMAT_U32LE, |
| 55 | GST_DSD_FORMAT_U32BE, |
| 56 | |
| 57 | GST_NUM_DSD_FORMATS, |
| 58 | |
| 59 | /* native endianness equivalents */ |
| 60 | GST_DSD_FORMAT_U16 = _GST_DSD_FORMAT_NE(U16), |
| 61 | GST_DSD_FORMAT_U32 = _GST_DSD_FORMAT_NE(U32) |
| 62 | } GstDsdFormat; |
| 63 | |
| 64 | /** |
| 65 | * GST_DSD_FORMATS_ALL: |
| 66 | * |
| 67 | * List of all DSD formats, for use in template caps strings. |
| 68 | * |
| 69 | * Big endian formats are preferred, since little-endian ones flip around |
| 70 | * the DSD bytes, and most DSD hardware uses big endian formats. |
| 71 | * |
| 72 | * Since: 1.24 |
| 73 | */ |
| 74 | #define GST_DSD_FORMATS_ALL "{ DSDU32BE, DSDU16BE, DSDU8, DSDU32LE, DSDU16LE }" |
| 75 | |
| 76 | GST_AUDIO_API |
| 77 | GstDsdFormat gst_dsd_format_from_string (const gchar *str); |
| 78 | |
| 79 | GST_AUDIO_API |
| 80 | const gchar * gst_dsd_format_to_string (GstDsdFormat format); |
| 81 | |
| 82 | GST_AUDIO_API |
| 83 | guint gst_dsd_format_get_width (GstDsdFormat format); |
| 84 | |
| 85 | G_END_DECLS |
| 86 | |