This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit baa01b0e748b8e770f070b493c98cdffcf832b7c
Author:     Kacper Michajłow <[email protected]>
AuthorDate: Tue Aug 11 12:30:34 2026 +0200
Commit:     Kacper Michajłow <[email protected]>
CommitDate: Sun Sep 6 00:48:26 2026 +0200

    avcodec: add a raw DSD encoder
    
    AV_SAMPLE_FMT_DSD frames are already the bitstream, so the dsd_msbf
    "encoder" is a plain copy of the samples into packets.
    
    Signed-off-by: Kacper Michajłow <[email protected]>
---
 Changelog                 |  1 +
 doc/general_contents.texi |  2 +-
 libavcodec/Makefile       |  1 +
 libavcodec/allcodecs.c    |  1 +
 libavcodec/dsdenc.c       | 65 +++++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/version.h      |  2 +-
 6 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 5da3610497..c05d1c840a 100644
--- a/Changelog
+++ b/Changelog
@@ -12,6 +12,7 @@ version <next>:
 - AVFoundation input device selection by unique ID and USB serial number
 - NVIDIA optical flow accelerated interpolation filter (vf_fruc_vulkan)
 - H.264 data partitioning support
+- DSD (dsd_msbf) encoder
 
 
 version 9.0:
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index d446391429..ad73894d99 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1359,7 +1359,7 @@ following image formats are supported:
     @tab Used in Origin's Wing Commander IV AVI files.
 @item DPCM Xilam DERF        @tab     @tab  X
 @item DSD (Direct Stream Digital), least significant bit first  @tab  @tab  X
-@item DSD (Direct Stream Digital), most significant bit first   @tab  @tab  X
+@item DSD (Direct Stream Digital), most significant bit first   @tab  X  @tab  
X
 @item DSD (Direct Stream Digital), least significant bit first, planar  @tab  
@tab  X
 @item DSD (Direct Stream Digital), most significant bit first, planar   @tab  
@tab  X
 @item DSP Group TrueSpeech   @tab     @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cdfa4f383..8535f460ab 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -347,6 +347,7 @@ OBJS-$(CONFIG_DPX_DECODER)             += dpx.o
 OBJS-$(CONFIG_DPX_ENCODER)             += dpxenc.o
 OBJS-$(CONFIG_DSD_LSBF_DECODER)        += dsddec.o dsd.o
 OBJS-$(CONFIG_DSD_MSBF_DECODER)        += dsddec.o dsd.o
+OBJS-$(CONFIG_DSD_MSBF_ENCODER)        += dsdenc.o
 OBJS-$(CONFIG_DSD_LSBF_PLANAR_DECODER) += dsddec.o dsd.o
 OBJS-$(CONFIG_DSD_MSBF_PLANAR_DECODER) += dsddec.o dsd.o
 OBJS-$(CONFIG_DSICINAUDIO_DECODER)     += dsicinaudio.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 2d7496a20d..b8e744ad86 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -459,6 +459,7 @@ extern const FFCodec ff_dfpwm_encoder;
 extern const FFCodec ff_dfpwm_decoder;
 extern const FFCodec ff_dolby_e_decoder;
 extern const FFCodec ff_dsd_lsbf_decoder;
+extern const FFCodec ff_dsd_msbf_encoder;
 extern const FFCodec ff_dsd_msbf_decoder;
 extern const FFCodec ff_dsd_lsbf_planar_decoder;
 extern const FFCodec ff_dsd_msbf_planar_decoder;
diff --git a/libavcodec/dsdenc.c b/libavcodec/dsdenc.c
new file mode 100644
index 0000000000..1b5cca6aa2
--- /dev/null
+++ b/libavcodec/dsdenc.c
@@ -0,0 +1,65 @@
+/*
+ * Direct Stream Digital (DSD) encoder
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * DSD (Direct Stream Digital) "encoder": AV_SAMPLE_FMT_DSD is
+ * already the bitstream, so packets are a plain copy of the samples.
+ */
+
+#include <string.h>
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+
+static av_cold int dsd_encode_init(AVCodecContext *avctx)
+{
+    avctx->bits_per_coded_sample = 8;
+    avctx->block_align           = avctx->ch_layout.nb_channels;
+    avctx->bit_rate              = 8LL * avctx->block_align * 
avctx->sample_rate;
+    return 0;
+}
+
+static int dsd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+                            const AVFrame *frame, int *got_packet_ptr)
+{
+    int64_t size = frame->nb_samples * (int64_t)avctx->ch_layout.nb_channels;
+    int ret;
+
+    if ((ret = ff_get_encode_buffer(avctx, avpkt, size, 0)) < 0)
+        return ret;
+
+    memcpy(avpkt->data, frame->data[0], size);
+
+    *got_packet_ptr = 1;
+    return 0;
+}
+
+const FFCodec ff_dsd_msbf_encoder = {
+    .p.name         = "dsd_msbf",
+    CODEC_LONG_NAME("DSD (Direct Stream Digital), most significant bit first"),
+    .p.type         = AVMEDIA_TYPE_AUDIO,
+    .p.id           = AV_CODEC_ID_DSD_MSBF,
+    .p.capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
+    CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_DSD),
+    .init           = dsd_encode_init,
+    FF_CODEC_ENCODE_CB(dsd_encode_frame),
+};
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 6b350a0a6f..9048abdb9a 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 103
+#define LIBAVCODEC_VERSION_MICRO 104
 
 #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]

Reply via email to