Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Paul B Mahol <onemda@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v5 1/2] libavcodec: Added DFPWM1a codec
Date: Thu, 3 Mar 2022 13:25:25 +0100
Message-ID: <CAPYw7P7NAi90XsovgF6ypjUktt02eV8PsDtMDZiPTBPkWn+NCQ@mail.gmail.com> (raw)
In-Reply-To: <db9dd520-b6b8-28cb-f0ab-ab881000a526@gmail.com>

On 2/27/22, Jack Bruienne <jackbruienne@gmail.com> 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.
>
> 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 <file.dfpwm>" 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 <jackbruienne@gmail.com>
> ---
>   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
>
>


Please move channel check to init.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

  reply	other threads:[~2022-03-03 12:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-27 21:37 Jack Bruienne
2022-03-03 12:25 ` Paul B Mahol [this message]
2022-03-03 12:28   ` Paul B Mahol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPYw7P7NAi90XsovgF6ypjUktt02eV8PsDtMDZiPTBPkWn+NCQ@mail.gmail.com \
    --to=onemda@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git