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

2022-02-26 Thread James Almer

On 2/26/2022 8:26 PM, 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.

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/libavcod

[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 6076b4a..7474220 100644