| Line | Branch | Exec | Source |
|---|---|---|---|
| 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" | ||
| 25 | #include "libavutil/attributes.h" | ||
| 26 | #include "dsd.h" | ||
| 27 | |||
| 28 | #if CONFIG_SWRESAMPLE && FF_API_DSD_PCM | ||
| 29 | #include "libswresample/swresample.h" | ||
| 30 | #include "avcodec.h" | ||
| 31 | |||
| 32 | 3 | av_cold int ff_dsd_to_pcm_init(AVCodecContext *avctx, struct SwrContext **swrp) | |
| 33 | { | ||
| 34 | 3 | SwrContext *swr = NULL; | |
| 35 | int ret; | ||
| 36 | |||
| 37 | 3 | swr_free(swrp); | |
| 38 | |||
| 39 | 3 | ret = swr_alloc_set_opts2(&swr, &avctx->ch_layout, avctx->sample_fmt, | |
| 40 | 3 | avctx->sample_rate, &avctx->ch_layout, | |
| 41 | AV_SAMPLE_FMT_DSD, avctx->sample_rate, 0, avctx); | ||
| 42 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) |
| 43 | ✗ | return ret; | |
| 44 | |||
| 45 | 3 | ret = swr_init(swr); | |
| 46 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) { |
| 47 | ✗ | swr_free(&swr); | |
| 48 | ✗ | return ret; | |
| 49 | } | ||
| 50 | |||
| 51 | 3 | av_log(avctx, AV_LOG_WARNING, | |
| 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 | 3 | *swrp = swr; | |
| 58 | 3 | return 0; | |
| 59 | } | ||
| 60 | #endif | ||
| 61 |