[FFmpeg-devel] [PATCH] avcodec: Fix time reporting for DFPWM streams

2022-06-10 Thread Jack Bruienne


This adds the exact bits per sample for DFPWM to 
av_get_exact_bits_per_sample.
Previously, the DTS and PTS were set to 0 because the codec never 
reported them, but adding this allows libavformat to automatically

set DTS and PTS from the byte position of the stream.

Signed-off-by: Jack Bruienne 
---
 libavcodec/utils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index eb7e505a..940f25fe 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -495,6 +495,8 @@ const char *avcodec_profile_name(enum AVCodecID codec_id, int profile)
 int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
 {
 switch (codec_id) {
+case AV_CODEC_ID_DFPWM:
+return 1;
 case AV_CODEC_ID_8SVX_EXP:
 case AV_CODEC_ID_8SVX_FIB:
 case AV_CODEC_ID_ADPCM_ARGO:

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v7 3/3] libavformat: Added DFPWM WAV container support

2022-03-07 Thread Jack Bruienne


This commit adds support for storing DFPWM audio in a WAV container.
It uses the WAVEFORMATEXTENSIBLE structure, following these conventions:
https://gist.github.com/MCJack123/90c24b64c8e626c7f130b57e9800962c
The implementation is very simple: it just adds the GUID to the list of
WAV GUIDs, and modifies the WAV muxer to always use WAVEFORMATEXTENSIBLE
format with that GUID.

This creates a standard container format for DFPWM besides raw data.
It will allow users to transfer DFPWM audio in a standard container
format, with the sample rate and channel count contained in the file
as opposed to being an external parameter as in the raw format.

This format is already supported in my AUKit library, which is the CC
analog to libav (albeit much smaller). Support in other applications is TBD.

Signed-off-by: Jack Bruienne 
---
 libavformat/riff.c| 3 +++
 libavformat/riffenc.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/riff.c b/libavformat/riff.c
index 0c19d3f..f098c1d 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -587,6 +587,8 @@ const AVCodecTag ff_codec_wav_tags[] = {
 { AV_CODEC_ID_AAC, 0xA106 },
 { AV_CODEC_ID_SPEEX,   0xA109 },
 { AV_CODEC_ID_FLAC,0xF1AC },
+/* DFPWM does not have an assigned format tag; it uses a GUID in WAVEFORMATEX instead */
+{ AV_CODEC_ID_DFPWM,   0xFFFE },
 { AV_CODEC_ID_ADPCM_SWF,   ('S' << 8) + 'F' },
 /* HACK/FIXME: Does Vorbis in WAV/AVI have an (in)official ID? */
 { AV_CODEC_ID_VORBIS,  ('V' << 8) + 'o' },
@@ -637,5 +639,6 @@ const AVCodecGuid ff_codec_wav_guids[] = {
 { AV_CODEC_ID_EAC3, { 0xAF, 0x87, 0xFB, 0xA7, 0x02, 0x2D, 0xFB, 0x42, 0xA4, 0xD4, 0x05, 0xCD, 0x93, 0x84, 0x3B, 0xDD } },
 { AV_CODEC_ID_MP2,  { 0x2B, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } },
 { AV_CODEC_ID_ADPCM_AGM,{ 0x82, 0xEC, 0x1F, 0x6A, 0xCA, 0xDB, 0x19, 0x45, 0xBD, 0xE7, 0x56, 0xD3, 0xB3, 0xEF, 0x98, 0x1D } },
+{ AV_CODEC_ID_DFPWM,{ 0x3A, 0xC1, 0xFA, 0x38, 0x81, 0x1D, 0x43, 0x61, 0xA4, 0x0D, 0xCE, 0x53, 0xCA, 0x60, 0x7C, 0xD1 } },
 { AV_CODEC_ID_NONE }
 };
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index ffccfa3..96750e7 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -81,7 +81,7 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
par->channels == 1 && par->channel_layout && par->channel_layout != AV_CH_LAYOUT_MONO ||
par->channels == 2 && par->channel_layout && par->channel_layout != AV_CH_LAYOUT_STEREO ||
par->sample_rate > 48000 ||
-   par->codec_id == AV_CODEC_ID_EAC3 ||
+   par->codec_id == AV_CODEC_ID_EAC3 || par->codec_id == AV_CODEC_ID_DFPWM ||
av_get_bits_per_sample(par->codec_id) > 16;
 
 if (waveformatextensible)
@@ -188,7 +188,7 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
 /* dwChannelMask */
 avio_wl32(pb, write_channel_mask ? par->channel_layout : 0);
 /* GUID + next 3 */
-if (par->codec_id == AV_CODEC_ID_EAC3) {
+if (par->codec_id == AV_CODEC_ID_EAC3 || par->codec_id == AV_CODEC_ID_DFPWM) {
 ff_put_guid(pb, ff_get_codec_guid(par->codec_id, ff_codec_wav_guids));
 } else {
 avio_wl32(pb, par->codec_tag);

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v7 2/3] libavformat: Add DFPWM raw format

2022-03-07 Thread Jack Bruienne


This patch builds on my previous DFPWM codec patch, adding a raw
audio format to be able to read/write the raw files that are most commonly
used (as no other container format supports it yet).

The muxers are mostly copied from the PCM demuxer and the raw muxers, as
DFPWM is typically stored as raw data.

Please see the previous patch for more information on DFPWM.

Changes since v4:
Fixed descriptions of formats.

Changes since v2/v3:
Removed unused MIME parsing code, and added channels option.

Signed-off-by: Jack Bruienne 
---
 Changelog |  2 +-
 MAINTAINERS   |  1 +
 doc/general_contents.texi |  1 +
 libavformat/Makefile  |  2 +
 libavformat/allformats.c  |  2 +
 libavformat/dfpwmdec.c| 82 +++
 libavformat/rawenc.c  | 13 +++
 libavformat/version.h |  4 +-
 8 files changed, 104 insertions(+), 3 deletions(-)
 create mode 100644 libavformat/dfpwmdec.c

diff --git a/Changelog b/Changelog
index f3249fe..ac614f8 100644
--- a/Changelog
+++ b/Changelog
@@ -5,7 +5,7 @@ version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
 - pcm-bluray encoder
-- DFPWM audio encoder/decoder
+- DFPWM audio encoder/decoder and raw muxer/demuxer
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 57b6f33..931cf4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -416,6 +416,7 @@ Muxers/Demuxers:
   dashdec.c Steven Liu
   dashenc.c Karthick Jeyapal
   daud.cReimar Doeffinger
+  dfpwmdec.cJack Bruienne
   dss.c Oleksij Rempel
   dtsdec.c  foo86
   dtshddec.cPaul B Mahol
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 14aeaed..fcd9da1 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -578,6 +578,7 @@ library:
 @item raw aptX  @tab X @tab X
 @item raw aptX HD   @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
+@item raw DFPWM @tab X @tab X
 @item raw Dirac @tab X @tab X
 @item raw DNxHD @tab X @tab X
 @item raw DTS   @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 16d019d..322c8e7 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -166,6 +166,8 @@ OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o
 OBJS-$(CONFIG_DCSTR_DEMUXER) += dcstr.o
 OBJS-$(CONFIG_DERF_DEMUXER)  += derf.o pcm.o
 OBJS-$(CONFIG_DFA_DEMUXER)   += dfa.o
+OBJS-$(CONFIG_DFPWM_DEMUXER) += dfpwmdec.o pcm.o
+OBJS-$(CONFIG_DFPWM_MUXER)   += rawenc.o
 OBJS-$(CONFIG_DHAV_DEMUXER)  += dhav.o
 OBJS-$(CONFIG_DIRAC_DEMUXER) += diracdec.o rawdec.o
 OBJS-$(CONFIG_DIRAC_MUXER)   += rawenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a77..587ad59 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -124,6 +124,8 @@ extern const AVOutputFormat ff_daud_muxer;
 extern const AVInputFormat  ff_dcstr_demuxer;
 extern const AVInputFormat  ff_derf_demuxer;
 extern const AVInputFormat  ff_dfa_demuxer;
+extern const AVInputFormat  ff_dfpwm_demuxer;
+extern const AVOutputFormat ff_dfpwm_muxer;
 extern const AVInputFormat  ff_dhav_demuxer;
 extern const AVInputFormat  ff_dirac_demuxer;
 extern const AVOutputFormat ff_dirac_muxer;
diff --git a/libavformat/dfpwmdec.c b/libavformat/dfpwmdec.c
new file mode 100644
index 000..85d9b61
--- /dev/null
+++ b/libavformat/dfpwmdec.c
@@ -0,0 +1,82 @@
+/*
+ * RAW PCM demuxers
+ * Copyright (c) 2002 Fabrice Bellard
+ * Copyright (c) 2022 Jack Bruienne
+ *
+ * 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
+ */
+
+#include "libavutil/avstring.h"
+#include "avformat.h"
+#include "internal.h"
+#include "pcm.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
+#include "libavutil/avassert.h"
+
+typedef struct DFPWMAudioDemuxerContext {
+AVClass *class;
+int sample_rate;
+int channels;
+} DFPWMA

[FFmpeg-devel] [PATCH v7 1/3] libavcodec: Added DFPWM1a codec

2022-03-07 Thread Jack Bruienne


From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
creates a high-pitched whine, it is often followed by some post-processing
filters to make the stream more listenable.


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.
The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system.

To clarify, the codec does not have a specific sample rate - it is
provided by the container (or user), which is typically 48000, but has
also been known to be 32768. The codec does not specify channel info
either, and it's pretty much always used with one mono channel.
However, since it appears that libavcodec expects both sample rate and
channel count to be handled by either the codec or container, I have
made the decision to allow multiple channels interleaved, which as far
as I know has never been used, but it works fine here nevertheless. The
accompanying raw format has a channels option to set this. (I expect
most users of this will not use multiple channels, but it remains an
option just in case.)

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there, and even fewer decoders. It
will streamline the process for importing and listening to audio,
replacing the need to write code or use tools that require very
specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

Changes since v5:
Moved channel check to init, and added sample size check in decoder.

Changes since v4:
Fixed missing channel check in decoder.

Changes since v3:
Added support for multiple interleaved channels, and cleaned up the
code a bunch.

Changes since v2:
I've found that the reference encoder has a few errors, and sounds
worse than the Java-based implementation that is used most often. I got
in contact with someone who knows DFPWM much better than I do, and I
worked with them to make a few adjustments that should improve the
audio quality. I also made sure that the output matches the Java
codec exactly, so it should have the exact same quality as other codecs.

Signed-off-by: Jack Bruienne 
---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 doc/general_contents.texi |   1 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c|   2 +
 libavcodec/codec_desc.c   |   7 ++
 libavcodec/codec_id.h |   1 +
 libavcodec/dfpwmdec.c | 134 ++
 libavcodec/dfpwmenc.c | 121 ++
 libavcodec/utils.c|   2 +
 10 files changed, 272 insertions(+)
 create mode 100644 libavcodec/dfpwmdec.c
 create mode 100644 libavcodec/dfpwmenc.c

diff --git a/Changelog b/Changelog
index 3af8aa0..f3249fe 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@ version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
 - pcm-bluray encoder
+- DFPWM audio encoder/decoder
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd..57b6f33 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@ Codecs:
   cscd.cReimar Doeffinger
   cuviddec.cTimo Rothenpieler
   dca*

Re: [FFmpeg-devel] [PATCH v6 1/2] libavcodec: Added DFPWM1a codec

2022-03-07 Thread Jack Bruienne

On 3/7/22 06:03, Tomas Härdin wrote:


tor 2022-03-03 klockan 10:44 -0500 skrev Jack Bruienne:

  From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be
used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-
pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM
decoding
creates a high-pitched whine, it is often followed by some post-
processing
filters to make the stream more listenable.

This sounds similar to something I wrote for the Atari 2600 a number of
years ago (https://www.pouet.net/prod.php?which=59283  )

I found an encoder online for DFPWM, and it seems to suffer from the
same "beeping" that my debeeping hack fixes (suppressing 0xAA and 0x55
bytes). Perhaps a similar hack could be useful in dfpwmenc.c


I'm curious how this works. Do you just cut out those bytes from the encoder 
output, or is it modified in some way? Wouldn't removing the data entirely 
eventually cause much of the audio to be lost?


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well
as
the Computronics expansion which preceeded the official support.
These
both implement the slightly adjusted 1a version of the codec, which
is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.
The codec sources are pretty simple: they use the reference codec
with
a basic wrapper to connect it to the FFmpeg AVCodec system.

To clarify, the codec does not have a specific sample rate - it is
provided by the container (or user), which is typically 48000, but
has
also been known to be 32768. The codec does not specify channel info
either, and it's pretty much always used with one mono channel.
However, since it appears that libavcodec expects both sample rate
and
channel count to be handled by either the codec or container, I have
made the decision to allow multiple channels interleaved, which as
far
as I know has never been used, but it works fine here nevertheless.

 From experience it's usually better to be strict when it comes to stuff
like this. The ComputerCraft people should work out a standard for
this, preferably a container. We've had a similar problem in FreeDV
where which codec was being used was implicit most of the time, which
has been resolved with the .c2 format.


I think the best standardized container for DFPWM will be WAV. I'll have to 
figure out the best place to properly standardize this, but one first step may 
be to implement this in CC directly. Unfortunately, ComputerCraft is currently 
without a maintainer - the previous one stepped down in December, and no 
changes are being made outside of critical bugfixes. I do hope to pick up 
development in the future, and I already run a reimplementation of the mod 
outside Minecraft, but as it stands today, getting this to be picked up by 
users will be quite difficult.

However, I do also maintain my own audio processing library AUKit, which now 
includes support for DFPWM in WAV. Since CC only has a basic raw DFPWM player 
built-in (which strictly requires 48kHz mono audio), many users turn to it to 
play more complex formats like WAV with a different sample rate, FLAC, etc. 
This may be a decent start, but it's far from having full support built-in.

I'll see if I can get in contact with the owner of the DFPWM wiki page. This 
will be especially important if this patch gets merged, as people likely won't 
see that you can use FFmpeg on those pages. I am able to submit pull requests 
to the ComputerCraft documentation site, however, so I'm able to get changes 
made there much easier.

In the meantime, I've made a sort-of RFC for the 
format:https://gist.github.com/MCJack123/90c24b64c8e626c7f130b57e9800962c


---
   Changelog |   1 +
   MAINTAINERS   |   1 +
   doc/general_contents.texi |   1 +
   libavcodec/Makefile   |   2 +
   libavcodec/allcodecs.c    |   2 +
   libavcodec/codec_desc.c   |   7 ++
   libavcodec/codec_id.h |   1 +
   libavcodec/dfpwmdec.c | 134
++
   libavcodec/dfpwmenc.c | 121 ++
   libavcodec/utils.c    |   2 +
   libavcodec/version.h  |   4 +-
   11 files changed, 274 insertions(+), 2 deletions(-)
   create mode 100644 libavcodec/dfpwmdec.c
   create mode 100644 libavcodec/dfpwmenc.c

Patch doesn't apply on current master (e645a1d)


I'll update the patch to apply to the current master, but I feel like by the 
time this next gets reviewed master may break again. Should I just keep 
updating the patch to master and resubmitting whenever I notice a new commit 
breaks it?


/Tomas

___
ffmpeg-devel mailing list
ff

[FFmpeg-devel] [PATCH v6 1/2] libavcodec: Added DFPWM1a codec

2022-03-03 Thread Jack Bruienne


From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
creates a high-pitched whine, it is often followed by some post-processing
filters to make the stream more listenable.


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.
The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system.

To clarify, the codec does not have a specific sample rate - it is
provided by the container (or user), which is typically 48000, but has
also been known to be 32768. The codec does not specify channel info
either, and it's pretty much always used with one mono channel.
However, since it appears that libavcodec expects both sample rate and
channel count to be handled by either the codec or container, I have
made the decision to allow multiple channels interleaved, which as far
as I know has never been used, but it works fine here nevertheless. The
accompanying raw format has a channels option to set this. (I expect
most users of this will not use multiple channels, but it remains an
option just in case.)

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there, and even fewer decoders. It
will streamline the process for importing and listening to audio,
replacing the need to write code or use tools that require very
specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

Changes since v5:
Moved channel check to init, and added sample size check in decoder.

Changes since v4:
Fixed missing channel check in decoder.

Changes since v3:
Added support for multiple interleaved channels, and cleaned up the
code a bunch.

Changes since v2:
I've found that the reference encoder has a few errors, and sounds
worse than the Java-based implementation that is used most often. I got
in contact with someone who knows DFPWM much better than I do, and I
worked with them to make a few adjustments that should improve the
audio quality. I also made sure that the output matches the Java
codec exactly, so it should have the exact same quality as other codecs.

Signed-off-by: Jack Bruienne 
---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 doc/general_contents.texi |   1 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c|   2 +
 libavcodec/codec_desc.c   |   7 ++
 libavcodec/codec_id.h |   1 +
 libavcodec/dfpwmdec.c | 134 ++
 libavcodec/dfpwmenc.c | 121 ++
 libavcodec/utils.c|   2 +
 libavcodec/version.h  |   4 +-
 11 files changed, 274 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/dfpwmdec.c
 create mode 100644 libavcodec/dfpwmenc.c

diff --git a/Changelog b/Changelog
index 5ad2cef..5170a6a 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
+- DFPWM audio encoder/decoder
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd..57b6f33 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@ Codecs:
   cscd.cReimar Doeffinger
   cuviddec.c

[FFmpeg-devel] [PATCH v5 2/2] libavformat: Add DFPWM raw format

2022-02-27 Thread Jack Bruienne


This patch builds on my previous DFPWM codec patch, adding a raw
audio format to be able to read/write the raw files that are most commonly
used (as no other container format supports it yet).

The muxers are mostly copied from the PCM demuxer and the raw muxers, as
DFPWM is typically stored as raw data.

Note on the channels argument: The -ac argument can only be used as
an alias if -f dfpwm is passed. If missing, -ac has no effect. The
-channels argument will work regardless of the presence of -f.

Please see the previous patch for more information on DFPWM.

Changes since v4:
Fixed descriptions of formats.

Changes since v2/v3:
Removed unused MIME parsing code, and added channels option.

Signed-off-by: Jack Bruienne 
---
 Changelog |  2 +-
 MAINTAINERS   |  1 +
 doc/general_contents.texi |  1 +
 libavformat/Makefile  |  2 +
 libavformat/allformats.c  |  2 +
 libavformat/dfpwmdec.c| 82 +++
 libavformat/rawenc.c  | 13 +++
 libavformat/version.h |  4 +-
 8 files changed, 104 insertions(+), 3 deletions(-)
 create mode 100644 libavformat/dfpwmdec.c

diff --git a/Changelog b/Changelog
index 5170a6a..ec688da 100644
--- a/Changelog
+++ b/Changelog
@@ -4,7 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
-- DFPWM audio encoder/decoder
+- DFPWM audio encoder/decoder and raw muxer/demuxer
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 57b6f33..931cf4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -416,6 +416,7 @@ Muxers/Demuxers:
   dashdec.c Steven Liu
   dashenc.c Karthick Jeyapal
   daud.cReimar Doeffinger
+  dfpwmdec.cJack Bruienne
   dss.c Oleksij Rempel
   dtsdec.c  foo86
   dtshddec.cPaul B Mahol
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 14aeaed..fcd9da1 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -578,6 +578,7 @@ library:
 @item raw aptX  @tab X @tab X
 @item raw aptX HD   @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
+@item raw DFPWM @tab X @tab X
 @item raw Dirac @tab X @tab X
 @item raw DNxHD @tab X @tab X
 @item raw DTS   @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 6566e40..b89073a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -165,6 +165,8 @@ OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o
 OBJS-$(CONFIG_DCSTR_DEMUXER) += dcstr.o
 OBJS-$(CONFIG_DERF_DEMUXER)  += derf.o pcm.o
 OBJS-$(CONFIG_DFA_DEMUXER)   += dfa.o
+OBJS-$(CONFIG_DFPWM_DEMUXER) += dfpwmdec.o pcm.o
+OBJS-$(CONFIG_DFPWM_MUXER)   += rawenc.o
 OBJS-$(CONFIG_DHAV_DEMUXER)  += dhav.o
 OBJS-$(CONFIG_DIRAC_DEMUXER) += diracdec.o rawdec.o
 OBJS-$(CONFIG_DIRAC_MUXER)   += rawenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a77..587ad59 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -124,6 +124,8 @@ extern const AVOutputFormat ff_daud_muxer;
 extern const AVInputFormat  ff_dcstr_demuxer;
 extern const AVInputFormat  ff_derf_demuxer;
 extern const AVInputFormat  ff_dfa_demuxer;
+extern const AVInputFormat  ff_dfpwm_demuxer;
+extern const AVOutputFormat ff_dfpwm_muxer;
 extern const AVInputFormat  ff_dhav_demuxer;
 extern const AVInputFormat  ff_dirac_demuxer;
 extern const AVOutputFormat ff_dirac_muxer;
diff --git a/libavformat/dfpwmdec.c b/libavformat/dfpwmdec.c
new file mode 100644
index 000..85d9b61
--- /dev/null
+++ b/libavformat/dfpwmdec.c
@@ -0,0 +1,82 @@
+/*
+ * RAW PCM demuxers
+ * Copyright (c) 2002 Fabrice Bellard
+ * Copyright (c) 2022 Jack Bruienne
+ *
+ * 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
+ */
+
+#include "libavutil/avstring.h"
+#include "avformat.h"
+#include "internal.h"
+#include "pcm.h"
+#include "libavutil

[FFmpeg-devel] [PATCH v5 1/2] libavcodec: Added DFPWM1a codec

2022-02-27 Thread Jack Bruienne


From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
creates a high-pitched whine, it is often followed by some post-processing
filters to make the stream more listenable.


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.
The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system.

To clarify, the codec does not have a specific sample rate - it is
provided by the container (or user), which is typically 48000, but has
also been known to be 32768. The codec does not specify channel info
either, and it's pretty much always used with one mono channel.
However, since it appears that libavcodec expects both sample rate and
channel count to be handled by either the codec or container, I have
made the decision to allow multiple channels interleaved, which as far
as I know has never been used, but it works fine here nevertheless. The
accompanying raw format has a channels option to set this. (I expect
most users of this will not use multiple channels, but it remains an
option just in case.)

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there, and even fewer decoders. It
will streamline the process for importing and listening to audio,
replacing the need to write code or use tools that require very
specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

Changes since v4:
Fixed missing channel check in decoder.

Changes since v3:
Added support for multiple interleaved channels, and cleaned up the
code a bunch.

Changes since v2:
I've found that the reference encoder has a few errors, and sounds
worse than the Java-based implementation that is used most often. I got
in contact with someone who knows DFPWM much better than I do, and I
worked with them to make a few adjustments that should improve the
audio quality. I also made sure that the output matches the Java
codec exactly, so it should have the exact same quality as other codecs.

Signed-off-by: Jack Bruienne 
---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 doc/general_contents.texi |   1 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c|   2 +
 libavcodec/codec_desc.c   |   7 ++
 libavcodec/codec_id.h |   1 +
 libavcodec/dfpwmdec.c | 133 ++
 libavcodec/dfpwmenc.c | 121 ++
 libavcodec/utils.c|   2 +
 libavcodec/version.h  |   2 +-
 11 files changed, 272 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/dfpwmdec.c
 create mode 100644 libavcodec/dfpwmenc.c

diff --git a/Changelog b/Changelog
index 5ad2cef..5170a6a 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
+- DFPWM audio encoder/decoder
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd..57b6f33 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@ Codecs:
   cscd.cReimar Doeffinger
   cuviddec.cTimo Rothenpieler
   dca*

[FFmpeg-devel] [PATCH v4 2/2] libavformat: Add DFPWM raw format

2022-02-27 Thread Jack Bruienne


This patch builds on my previous DFPWM codec patch, adding a raw
audio format to be able to read/write the raw files that are most commonly
used (as no other container format supports it yet).

The muxers are mostly copied from the PCM demuxer and the raw muxers, as
DFPWM is typically stored as raw data.

Please see the previous patch for more information on DFPWM.

Changes since v2/v3:
Removed unused MIME parsing code, and added channels option.

Signed-off-by: Jack Bruienne 
---
 Changelog |  2 +-
 MAINTAINERS   |  1 +
 doc/general_contents.texi |  1 +
 libavformat/Makefile  |  2 +
 libavformat/allformats.c  |  2 +
 libavformat/dfpwmdec.c| 82 +++
 libavformat/rawenc.c  | 13 +++
 libavformat/version.h |  4 +-
 8 files changed, 104 insertions(+), 3 deletions(-)
 create mode 100644 libavformat/dfpwmdec.c

diff --git a/Changelog b/Changelog
index 5170a6a..ec688da 100644
--- a/Changelog
+++ b/Changelog
@@ -4,7 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
-- DFPWM audio encoder/decoder
+- DFPWM audio encoder/decoder and raw muxer/demuxer
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 57b6f33..931cf4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -416,6 +416,7 @@ Muxers/Demuxers:
   dashdec.c Steven Liu
   dashenc.c Karthick Jeyapal
   daud.cReimar Doeffinger
+  dfpwmdec.cJack Bruienne
   dss.c Oleksij Rempel
   dtsdec.c  foo86
   dtshddec.cPaul B Mahol
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 14aeaed..fcd9da1 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -578,6 +578,7 @@ library:
 @item raw aptX  @tab X @tab X
 @item raw aptX HD   @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
+@item raw DFPWM @tab X @tab X
 @item raw Dirac @tab X @tab X
 @item raw DNxHD @tab X @tab X
 @item raw DTS   @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 6566e40..b89073a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -165,6 +165,8 @@ OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o
 OBJS-$(CONFIG_DCSTR_DEMUXER) += dcstr.o
 OBJS-$(CONFIG_DERF_DEMUXER)  += derf.o pcm.o
 OBJS-$(CONFIG_DFA_DEMUXER)   += dfa.o
+OBJS-$(CONFIG_DFPWM_DEMUXER) += dfpwmdec.o pcm.o
+OBJS-$(CONFIG_DFPWM_MUXER)   += rawenc.o
 OBJS-$(CONFIG_DHAV_DEMUXER)  += dhav.o
 OBJS-$(CONFIG_DIRAC_DEMUXER) += diracdec.o rawdec.o
 OBJS-$(CONFIG_DIRAC_MUXER)   += rawenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a77..587ad59 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -124,6 +124,8 @@ extern const AVOutputFormat ff_daud_muxer;
 extern const AVInputFormat  ff_dcstr_demuxer;
 extern const AVInputFormat  ff_derf_demuxer;
 extern const AVInputFormat  ff_dfa_demuxer;
+extern const AVInputFormat  ff_dfpwm_demuxer;
+extern const AVOutputFormat ff_dfpwm_muxer;
 extern const AVInputFormat  ff_dhav_demuxer;
 extern const AVInputFormat  ff_dirac_demuxer;
 extern const AVOutputFormat ff_dirac_muxer;
diff --git a/libavformat/dfpwmdec.c b/libavformat/dfpwmdec.c
new file mode 100644
index 000..d5833f8
--- /dev/null
+++ b/libavformat/dfpwmdec.c
@@ -0,0 +1,82 @@
+/*
+ * RAW PCM demuxers
+ * Copyright (c) 2002 Fabrice Bellard
+ * Copyright (c) 2022 Jack Bruienne
+ *
+ * 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
+ */
+
+#include "libavutil/avstring.h"
+#include "avformat.h"
+#include "internal.h"
+#include "pcm.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
+#include "libavutil/avassert.h"
+
+typedef struct DFPWMAudioDemuxerContext {
+AVClass *class;
+int sample_rate;
+int channels;
+} DFPWMAudioDemuxerContext;
+
+static int dfpwm_re

[FFmpeg-devel] [PATCH v4 1/2] libavcodec: Added DFPWM1a codec

2022-02-27 Thread Jack Bruienne


From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
creates a high-pitched whine, it is often followed by some post-processing
filters to make the stream more listenable.


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.
The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system.

To clarify, the codec does not have a specific sample rate - it is
provided by the container (or user), which is typically 48000, but has
also been known to be 32768. The codec does not specify channel info
either, and it's pretty much always used with one mono channel.
However, since it appears that libavcodec expects both sample rate and
channel count to be handled by either the codec or container, I have
made the decision to allow multiple channels interleaved, which as far
as I know has never been used, but it works fine here nevertheless. The
accompanying raw format has a channels option to set this. (I expect
most users of this will not use multiple channels, but it remains an
option just in case.)

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there, and even fewer decoders. It
will streamline the process for importing and listening to audio, 
replacing the need to write code or use tools that require very

specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

Changes since v3:
Added support for multiple interleaved channels, and cleaned up the
code a bunch.

Changes since v2:
I've found that the reference encoder has a few errors, and sounds
worse than the Java-based implementation that is used most often. I got
in contact with someone who knows DFPWM much better than I do, and I
worked with them to make a few adjustments that should improve the
audio quality. I also made sure that the output matches the Java
codec exactly, so it should have the exact same quality as other codecs.

Signed-off-by: Jack Bruienne 
---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 doc/general_contents.texi |   1 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c|   2 +
 libavcodec/codec_desc.c   |   7 +++
 libavcodec/codec_id.h |   1 +
 libavcodec/dfpwmdec.c | 127 ++
 libavcodec/dfpwmenc.c | 121 
 libavcodec/utils.c|   2 +
 libavcodec/version.h  |   2 +-
 11 files changed, 266 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/dfpwmdec.c
 create mode 100644 libavcodec/dfpwmenc.c

diff --git a/Changelog b/Changelog
index 5ad2cef..5170a6a 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
+- DFPWM audio encoder/decoder
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd..57b6f33 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@ Codecs:
   cscd.cReimar Doeffinger
   cuviddec.cTimo Rothenpieler
   dca*  foo86
+  dfpwm*    Ja

[FFmpeg-devel] [PATCH v3 1/2] libavcodec: Added DFPWM1a codec

2022-02-26 Thread Jack Bruienne


From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
creates a high-pitched whine, it is often followed by some post-processing
filters to make the stream more listenable.


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.

The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system.

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there. It will streamline the process
for importing audio, replacing the need to write code or use tools that
require very specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

Changes since the prior v2 patch:
I've found that the reference encoder has a few errors, and sounds
worse than the Java-based implementation that is used most often. I got
in contact with someone who knows DFPWM much better than I do, and I
worked with them to make a few adjustments that should improve the
audio quality. I also made sure that the output matches the Java
codec exactly, so it should have the exact same quality as other codecs.

Signed-off-by: Jack Bruienne 
---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 doc/general_contents.texi |   1 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c|   2 +
 libavcodec/codec_desc.c   |   7 +++
 libavcodec/codec_id.h |   1 +
 libavcodec/dfpwmdec.c | 129 ++
 libavcodec/dfpwmenc.c | 123 
 libavcodec/utils.c|   2 +
 libavcodec/version.h  |   2 +-
 11 files changed, 270 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/dfpwmdec.c
 create mode 100644 libavcodec/dfpwmenc.c

diff --git a/Changelog b/Changelog
index 5ad2cef..5170a6a 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
+- DFPWM audio encoder/decoder
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd..57b6f33 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@ Codecs:
   cscd.cReimar Doeffinger
   cuviddec.cTimo Rothenpieler
   dca*  foo86
+  dfpwm*    Jack Bruienne
   dirac*Rostislav Pehlivanov
   dnxhd*Baptiste Coudurier
   dolby_e*  foo86
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index df1692c..14aeaed 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1194,6 +1194,7 @@ following image formats are supported:
 @item CRI HCA@tab @tab X
 @item Delphine Software International CIN audio  @tab @tab  X
 @tab Codec used in Delphine Software International games.
+@item DFPWM  @tab  X  @tab  X
 @item Digital Speech Standard - Standard Play mode (DSS SP) @tab @tab  X
 @item Discworld II BMV Audio @tab @tab  X
 @item COOK   @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 607

Re: [FFmpeg-devel] [PATCH v2 1/2] libavcodec: Added DFPWM1a codec

2022-02-25 Thread Jack Bruienne
Sorry, I forgot to run make fate on the split patches, and I used the 
wrong capabilities for the decoder. I have attached a modified patch 
that removes AV_CODEC_CAP_VARIABLE_FRAME_SIZE from the decoder 
capabilities. Let me know if you'd like a full v3 patch email instead.


On 2/25/22 18:43, Jack Bruienne wrote:


From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM 
decoding
creates a high-pitched whine, it is often followed by some 
post-processing

filters to make the stream more listenable.


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.

The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system.

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there. It will streamline the process
for importing audio, replacing the need to write code or use tools that
require very specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

Signed-off-by: Jack Bruienne 
---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 doc/general_contents.texi |   1 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c    |   2 +
 libavcodec/codec_desc.c   |   7 +++
 libavcodec/codec_id.h |   1 +
 libavcodec/dfpwmdec.c | 129 ++
 libavcodec/dfpwmenc.c | 123 
 libavcodec/utils.c    |   2 +
 libavcodec/version.h  |   2 +-
 11 files changed, 270 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/dfpwmdec.c
 create mode 100644 libavcodec/dfpwmenc.c
diff --git a/Changelog b/Changelog
index 5ad2cef..5170a6a 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
+- DFPWM audio encoder/decoder
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd..57b6f33 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@ Codecs:
   cscd.cReimar Doeffinger
   cuviddec.cTimo Rothenpieler
   dca*  foo86
+  dfpwm*    Jack Bruienne
   dirac*Rostislav Pehlivanov
   dnxhd*Baptiste Coudurier
   dolby_e*  foo86
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index df1692c..14aeaed 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1194,6 +1194,7 @@ following image formats are supported:
 @item CRI HCA@tab @tab X
 @item Delphine Software International CIN audio  @tab @tab  X
 @tab Codec used in Delphine Software International games.
+@item DFPWM  @tab  X  @tab  X
 @item Digital Speech Standard - Standard Play mode (DSS SP) @tab @tab  X
 @item Discworld II BMV Audio @tab @tab  X
 @item COOK   @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6076b4a..7474220 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -289,6 +289,8 @@ OBJS-$(CONFIG_DERF_DPCM_DECODER)  

[FFmpeg-devel] [PATCH v2 2/2] libavformat: Add DFPWM raw format

2022-02-25 Thread Jack Bruienne


This patch builds on my previous DFPWM codec patch, adding a raw
audio format to be able to read/write the raw files that are most commonly
used (as no other container format supports it yet).

The muxers are mostly copied from the PCM demuxer and the raw muxers, as
DFPWM is typically stored as raw data.

Please see the previous patch for more information on DFPWM.

Signed-off-by: Jack Bruienne 
---
 Changelog |   2 +-
 MAINTAINERS   |   1 +
 doc/general_contents.texi |   1 +
 libavformat/Makefile  |   2 +
 libavformat/allformats.c  |   2 +
 libavformat/dfpwmdec.c| 107 ++
 libavformat/rawenc.c  |  13 +
 libavformat/version.h |   4 +-
 8 files changed, 129 insertions(+), 3 deletions(-)
 create mode 100644 libavformat/dfpwmdec.c

diff --git a/Changelog b/Changelog
index 5170a6a..ec688da 100644
--- a/Changelog
+++ b/Changelog
@@ -4,7 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
-- DFPWM audio encoder/decoder
+- DFPWM audio encoder/decoder and raw muxer/demuxer
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 57b6f33..931cf4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -416,6 +416,7 @@ Muxers/Demuxers:
   dashdec.c Steven Liu
   dashenc.c Karthick Jeyapal
   daud.cReimar Doeffinger
+  dfpwmdec.cJack Bruienne
   dss.c Oleksij Rempel
   dtsdec.c  foo86
   dtshddec.cPaul B Mahol
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 14aeaed..fcd9da1 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -578,6 +578,7 @@ library:
 @item raw aptX  @tab X @tab X
 @item raw aptX HD   @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
+@item raw DFPWM @tab X @tab X
 @item raw Dirac @tab X @tab X
 @item raw DNxHD @tab X @tab X
 @item raw DTS   @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 6566e40..b89073a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -165,6 +165,8 @@ OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o
 OBJS-$(CONFIG_DCSTR_DEMUXER) += dcstr.o
 OBJS-$(CONFIG_DERF_DEMUXER)  += derf.o pcm.o
 OBJS-$(CONFIG_DFA_DEMUXER)   += dfa.o
+OBJS-$(CONFIG_DFPWM_DEMUXER) += dfpwmdec.o pcm.o
+OBJS-$(CONFIG_DFPWM_MUXER)   += rawenc.o
 OBJS-$(CONFIG_DHAV_DEMUXER)  += dhav.o
 OBJS-$(CONFIG_DIRAC_DEMUXER) += diracdec.o rawdec.o
 OBJS-$(CONFIG_DIRAC_MUXER)   += rawenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a77..587ad59 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -124,6 +124,8 @@ extern const AVOutputFormat ff_daud_muxer;
 extern const AVInputFormat  ff_dcstr_demuxer;
 extern const AVInputFormat  ff_derf_demuxer;
 extern const AVInputFormat  ff_dfa_demuxer;
+extern const AVInputFormat  ff_dfpwm_demuxer;
+extern const AVOutputFormat ff_dfpwm_muxer;
 extern const AVInputFormat  ff_dhav_demuxer;
 extern const AVInputFormat  ff_dirac_demuxer;
 extern const AVOutputFormat ff_dirac_muxer;
diff --git a/libavformat/dfpwmdec.c b/libavformat/dfpwmdec.c
new file mode 100644
index 000..ad5bfa5
--- /dev/null
+++ b/libavformat/dfpwmdec.c
@@ -0,0 +1,107 @@
+/*
+ * RAW PCM demuxers
+ * Copyright (c) 2002 Fabrice Bellard
+ * Copyright (c) 2022 Jack Bruienne
+ *
+ * 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
+ */
+
+#include "libavutil/avstring.h"
+#include "avformat.h"
+#include "internal.h"
+#include "pcm.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
+#include "libavutil/avassert.h"
+
+typedef struct DFPWMAudioDemuxerContext {
+AVClass *class;
+int sample_rate;
+} DFPWMAudioDemuxerContext;
+
+static int dfpwm_read_header(AVFormatContext *s)
+{
+DFPWMAudioDemuxerContext *s1 = s->priv_data;
+

[FFmpeg-devel] [PATCH v2 1/2] libavcodec: Added DFPWM1a codec

2022-02-25 Thread Jack Bruienne


From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
creates a high-pitched whine, it is often followed by some post-processing
filters to make the stream more listenable.


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.

The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system.

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there. It will streamline the process
for importing audio, replacing the need to write code or use tools that
require very specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

Signed-off-by: Jack Bruienne 
---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 doc/general_contents.texi |   1 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c|   2 +
 libavcodec/codec_desc.c   |   7 +++
 libavcodec/codec_id.h |   1 +
 libavcodec/dfpwmdec.c | 129 ++
 libavcodec/dfpwmenc.c | 123 
 libavcodec/utils.c|   2 +
 libavcodec/version.h  |   2 +-
 11 files changed, 270 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/dfpwmdec.c
 create mode 100644 libavcodec/dfpwmenc.c

diff --git a/Changelog b/Changelog
index 5ad2cef..5170a6a 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
+- DFPWM audio encoder/decoder
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd..57b6f33 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@ Codecs:
   cscd.cReimar Doeffinger
   cuviddec.cTimo Rothenpieler
   dca*  foo86
+  dfpwm*    Jack Bruienne
   dirac*Rostislav Pehlivanov
   dnxhd*Baptiste Coudurier
   dolby_e*  foo86
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index df1692c..14aeaed 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1194,6 +1194,7 @@ following image formats are supported:
 @item CRI HCA@tab @tab X
 @item Delphine Software International CIN audio  @tab @tab  X
 @tab Codec used in Delphine Software International games.
+@item DFPWM  @tab  X  @tab  X
 @item Digital Speech Standard - Standard Play mode (DSS SP) @tab @tab  X
 @item Discworld II BMV Audio @tab @tab  X
 @item COOK   @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6076b4a..7474220 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -289,6 +289,8 @@ OBJS-$(CONFIG_DERF_DPCM_DECODER)   += dpcm.o
 OBJS-$(CONFIG_DIRAC_DECODER)   += diracdec.o dirac.o diracdsp.o diractab.o \
   dirac_arith.o dirac_dwt.o dirac_vlc.o
 OBJS-$(CONFIG_DFA_DECODER) += dfa.o
+OBJS-$(CONFIG_DFPWM_DECODER)   += dfpwmdec.o
+OBJS-$(CONFIG_DFPWM_ENCODER)

Re: [FFmpeg-devel] [PATCH] libavcodec, libavformat: Added DFPWM1a codec and raw format

2022-02-25 Thread Jack Bruienne
Thanks for looking over the patch. I used git format-patch to make the 
email and then sent it with Thunderbird; it appears that the command on 
the website doesn't put the patch in an attachment. I'll be adding 
--attach for future patches to fix this.


I will be sending split updated patches fixing the issues you mentioned 
promptly.


On 2/25/22 03:15, Paul B Mahol wrote:


On Fri, Feb 25, 2022 at 02:54:35AM -0500, Jack Bruienne wrote:

 From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
creates a high-pitched whine, it is often followed by some post-processing
filters to make the stream more listenable.

It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds both a new codec (with encoding and decoding), as well as
a raw audio format to be able to read/write the raw files that are most
commonly used (as no other container format supports it yet).

The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system. There's a
bit of extra code to convert from unsigned to signed 8-bit audio, as the
codec implementation operates on signed data, which FFmpeg doesn't support.

The muxers are mostly copied from the PCM demuxer and the raw muxers, as
DFPWM is typically stored as raw data.

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there. It will streamline the process
for importing audio, replacing the need to write code or use tools that
require very specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

One thing I noticed is that this sample file fails to decode to raw:
https://samples.ffmpeg.org/ogg/virginradio-three-consecutive-chains.ogg
It reports "Application provided invalid, non monotonically increasing
dts to muxer in stream 0", which appears to be because the initial
timestamp is not 0:00. This affects all raw muxers, including PCM.

Signed-off-by: Jack Bruienne 
---
  Changelog |   1 +
  MAINTAINERS   |   2 +
  doc/general_contents.texi |   2 +
  libavcodec/Makefile   |   2 +
  libavcodec/allcodecs.c|   2 +
  libavcodec/codec_desc.c   |   7 ++
  libavcodec/codec_id.h |   1 +
  libavcodec/dfpwmdec.c | 138 +
  libavcodec/dfpwmenc.c | 140 ++
  libavcodec/utils.c|   2 +
  libavcodec/version.h  |   2 +-
  libavformat/Makefile  |   2 +
  libavformat/allformats.c  |   2 +
  libavformat/dfpwmdec.c| 107 +
  libavformat/rawenc.c  |  13 
  libavformat/version.h |   4 +-
  16 files changed, 424 insertions(+), 3 deletions(-)
  create mode 100644 libavcodec/dfpwmdec.c
  create mode 100644 libavcodec/dfpwmenc.c
  create mode 100644 libavformat/dfpwmdec.c

diff --git a/Changelog b/Changelog
index 5ad2cef..ec688da 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
  version 5.1:
  - dialogue enhance audio filter
  - dropped obsolete XvMC hwaccel
+- DFPWM audio encoder/decoder and raw muxer/demuxer


Keep empty line here above and everywhere else you had removed them.
Is patch corrupted somehow? Just attach file.
And split demuxer and muxer addition from deco

[FFmpeg-devel] [PATCH] libavcodec, libavformat: Added DFPWM1a codec and raw format

2022-02-24 Thread Jack Bruienne

From the wiki page (https://wiki.vexatos.com/dfpwm):

DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
created by Ben “GreaseMonkey” Russell in 2012, originally to be used
as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
creates a high-pitched whine, it is often followed by some post-processing
filters to make the stream more listenable.


It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds both a new codec (with encoding and decoding), as well as
a raw audio format to be able to read/write the raw files that are most
commonly used (as no other container format supports it yet).

The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system. There's a
bit of extra code to convert from unsigned to signed 8-bit audio, as the
codec implementation operates on signed data, which FFmpeg doesn't support.

The muxers are mostly copied from the PCM demuxer and the raw muxers, as
DFPWM is typically stored as raw data.

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there. It will streamline the process
for importing audio, replacing the need to write code or use tools that
require very specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play " for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

One thing I noticed is that this sample file fails to decode to raw:
https://samples.ffmpeg.org/ogg/virginradio-three-consecutive-chains.ogg
It reports "Application provided invalid, non monotonically increasing
dts to muxer in stream 0", which appears to be because the initial
timestamp is not 0:00. This affects all raw muxers, including PCM.

Signed-off-by: Jack Bruienne 
---
 Changelog |   1 +
 MAINTAINERS   |   2 +
 doc/general_contents.texi |   2 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c|   2 +
 libavcodec/codec_desc.c   |   7 ++
 libavcodec/codec_id.h |   1 +
 libavcodec/dfpwmdec.c | 138 +
 libavcodec/dfpwmenc.c | 140 ++
 libavcodec/utils.c|   2 +
 libavcodec/version.h  |   2 +-
 libavformat/Makefile  |   2 +
 libavformat/allformats.c  |   2 +
 libavformat/dfpwmdec.c| 107 +
 libavformat/rawenc.c  |  13 
 libavformat/version.h |   4 +-
 16 files changed, 424 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/dfpwmdec.c
 create mode 100644 libavcodec/dfpwmenc.c
 create mode 100644 libavformat/dfpwmdec.c

diff --git a/Changelog b/Changelog
index 5ad2cef..ec688da 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version 5.1:
 - dialogue enhance audio filter
 - dropped obsolete XvMC hwaccel
+- DFPWM audio encoder/decoder and raw muxer/demuxer
   version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index f33ccbd..931cf4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@ Codecs:
   cscd.cReimar Doeffinger
   cuviddec.cTimo Rothenpieler
   dca*  foo86
+  dfpwm*    Jack Bruienne
   dirac*Rostislav Pehlivanov
   dnxhd*Baptiste Coudurier
   dolby_e*  foo86
@@ -415,6 +416,7 @@ Muxers/Demuxers:
   dashdec.c