| 42 | */ |
| 43 | |
| 44 | static av_cold int decode_init(AVCodecContext *avctx) |
| 45 | { |
| 46 | DSDContext * s; |
| 47 | int i; |
| 48 | uint8_t silence; |
| 49 | |
| 50 | if (!avctx->ch_layout.nb_channels) |
| 51 | return AVERROR_INVALIDDATA; |
| 52 | |
| 53 | ff_init_dsd_data(); |
| 54 | |
| 55 | s = av_malloc_array(avctx->ch_layout.nb_channels, sizeof(*s)); |
| 56 | if (!s) |
| 57 | return AVERROR(ENOMEM); |
| 58 | |
| 59 | silence = avctx->codec_id == AV_CODEC_ID_DSD_LSBF_PLANAR || |
| 60 | avctx->codec_id == AV_CODEC_ID_DSD_LSBF ? DSD_SILENCE_REVERSED : DSD_SILENCE; |
| 61 | for (i = 0; i < avctx->ch_layout.nb_channels; i++) { |
| 62 | s[i].pos = 0; |
| 63 | memset(s[i].buf, silence, sizeof(s[i].buf)); |
| 64 | } |
| 65 | |
| 66 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; |
| 67 | avctx->priv_data = s; |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | typedef struct ThreadData { |
| 72 | AVFrame *frame; |
nothing calls this directly
no test coverage detected