FFmpeg
Loading...
Searching...
No Matches
dsd.c
Go to the documentation of this file.
1/*
2 * Direct Stream Digital (DSD) decoder
3 * Copyright (c) 2014 Peter Ross
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "config.h"
23
24#include "version_major.h"
26#include "dsd.h"
27
28#if CONFIG_SWRESAMPLE && FF_API_DSD_PCM
30#include "avcodec.h"
31
32av_cold int ff_dsd_to_pcm_init(AVCodecContext *avctx, struct SwrContext **swrp)
33{
34 SwrContext *swr = NULL;
35 int ret;
36
37 swr_free(swrp);
38
39 ret = swr_alloc_set_opts2(&swr, &avctx->ch_layout, avctx->sample_fmt,
40 avctx->sample_rate, &avctx->ch_layout,
41 AV_SAMPLE_FMT_DSD, avctx->sample_rate, 0, avctx);
42 if (ret < 0)
43 return ret;
44
45 ret = swr_init(swr);
46 if (ret < 0) {
47 swr_free(&swr);
48 return ret;
49 }
50
52 "Converting DSD to PCM in the decoder is deprecated and will be "
53 "removed. Set request_sample_fmt to AV_SAMPLE_FMT_DSD to receive "
54 "the raw bitstream, and use libswresample to convert it to PCM "
55 "when needed.\n");
56
57 *swrp = swr;
58 return 0;
59}
60#endif
Libavcodec external API header.
#define NULL
Definition coverity.c:32
int ff_dsd_to_pcm_init(struct AVCodecContext *avctx, struct SwrContext **swrp)
(Re)create a libswresample context converting AV_SAMPLE_FMT_DSD to avctx->sample_fmt at the same samp...
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
@ AV_SAMPLE_FMT_DSD
DSD (Direct Stream Digital) bitstream, interleaved.
Definition samplefmt.h:77
int swr_alloc_set_opts2(struct SwrContext **ps, const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, const AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx)
Allocate SwrContext if needed and set/reset common parameters.
Definition swresample.c:54
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
Definition swresample.c:137
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
Definition swresample.c:156
Libavcodec version macros.
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
main external API structure.
Definition avcodec.h:443
AVChannelLayout ch_layout
Audio channel layout.
Definition avcodec.h:1055
enum AVSampleFormat sample_fmt
audio sample format
Definition avcodec.h:1047
int sample_rate
samples per second
Definition avcodec.h:1040
The libswresample context.
libswresample public header
#define av_log(a,...)