This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 1853c91628442ccca2374c3a690056dbfb379061 Author: Kacper Michajłow <[email protected]> AuthorDate: Tue Aug 11 12:10:29 2026 +0200 Commit: Kacper Michajłow <[email protected]> CommitDate: Sun Sep 6 00:48:25 2026 +0200 avcodec/dstdec: support raw DSD output Output the losslessly decompressed bitstream as AV_SAMPLE_FMT_DSD. The default float output is unchanged. Signed-off-by: Kacper Michajłow <[email protected]> --- libavcodec/dstdec.c | 35 ++++++++++++++++++++++------------- libavcodec/version.h | 2 +- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c index 1db742d193..7551453726 100644 --- a/libavcodec/dstdec.c +++ b/libavcodec/dstdec.c @@ -96,7 +96,8 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR_PATCHWELCOME; } - avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + avctx->sample_fmt = avctx->request_sample_fmt == AV_SAMPLE_FMT_DSD + ? AV_SAMPLE_FMT_DSD : AV_SAMPLE_FMT_FLT; for (i = 0; i < avctx->ch_layout.nb_channels; i++) memset(s->dsdctx[i].buf, 0x69, sizeof(s->dsdctx[i].buf)); @@ -248,6 +249,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, unsigned i, ch, same_map, dst_x_bit; unsigned half_prob[DST_MAX_CHANNELS]; const int channels = avctx->ch_layout.nb_channels; + const int bps = avctx->sample_fmt == AV_SAMPLE_FMT_DSD ? 1 : 4; DSTContext *s = avctx->priv_data; GetBitContext *gb = &s->gb; ArithCoder *ac = &s->ac; @@ -273,12 +275,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, skip_bits1(gb); if (get_bits(gb, 6)) return AVERROR_INVALIDDATA; - // DSD bytes are stored in every 4th byte, as expected by the - // in-place DSD to PCM conversion. Pad short frames with silence. - for (i = 0; i < n; i++) - dsd[i * 4] = avpkt->data[1 + i]; - for (; i < total; i++) - dsd[i * 4] = 0x69; + if (bps == 1) { + memcpy(dsd, avpkt->data + 1, n); + memset(dsd + n, 0x69, total - n); + } else { + // DSD bytes are stored in every 4th byte, as expected by the + // in-place DSD to PCM conversion. Pad short frames with silence. + for (i = 0; i < n; i++) + dsd[i * 4] = avpkt->data[1 + i]; + for (; i < total; i++) + dsd[i * 4] = 0x69; + } goto dsd; } @@ -343,7 +350,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, return ret; memset(s->status, 0xAA, sizeof(s->status)); - memset(dsd, 0, frame->nb_samples * 4 * channels); + memset(dsd, 0, frame->nb_samples * bps * channels); ac_get(ac, gb, prob_dst_x_bit(s->fsets.coeff[0][0]), &dst_x_bit); @@ -371,7 +378,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, ac_get(ac, gb, prob, &residual); v = ((predict >> 15) ^ residual) & 1; - dsd[((i >> 3) * channels + ch) << 2] |= v << (7 - (i & 0x7 )); + dsd[((i >> 3) * channels + ch) * bps] |= v << (7 - (i & 0x7 )); AV_WL64A(status + 8, (AV_RL64A(status + 8) << 1) | ((AV_RL64A(status) >> 63) & 1)); AV_WL64A(status, (AV_RL64A(status) << 1) | v); @@ -379,10 +386,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, } dsd: - for (i = 0; i < channels; i++) { - ff_dsd2pcm_translate(&s->dsdctx[i], frame->nb_samples, 0, - frame->data[0] + i * 4, - channels * 4, pcm + i, channels); + if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { + for (i = 0; i < channels; i++) { + ff_dsd2pcm_translate(&s->dsdctx[i], frame->nb_samples, 0, + frame->data[0] + i * 4, + channels * 4, pcm + i, channels); + } } *got_frame_ptr = 1; diff --git a/libavcodec/version.h b/libavcodec/version.h index c576ee1520..c9b58eb269 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVCODEC_VERSION_MINOR 10 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
