1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat: add DFPWM raw format

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 <jackbruienne@gmail.com>
This commit is contained in:
Jack Bruienne 2022-03-07 22:29:57 -05:00 committed by Paul B Mahol
parent 39a33038ce
commit 70fef2371c
8 changed files with 104 additions and 3 deletions

View File

@ -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:

View File

@ -416,6 +416,7 @@ Muxers/Demuxers:
dashdec.c Steven Liu
dashenc.c Karthick Jeyapal
daud.c Reimar Doeffinger
dfpwmdec.c Jack Bruienne
dss.c Oleksij Rempel
dtsdec.c foo86
dtshddec.c Paul B Mahol

View File

@ -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

View File

@ -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

View File

@ -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;

82
libavformat/dfpwmdec.c Normal file
View File

@ -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_read_header(AVFormatContext *s)
{
DFPWMAudioDemuxerContext *s1 = s->priv_data;
AVCodecParameters *par;
AVStream *st;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
par = st->codecpar;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->codec_id = s->iformat->raw_codec_id;
par->sample_rate = s1->sample_rate;
par->channels = s1->channels;
par->bits_per_coded_sample = 1;
par->block_align = 1;
avpriv_set_pts_info(st, 64, 1, par->sample_rate);
return 0;
}
static const AVOption dfpwm_options[] = {
{ "sample_rate", "", offsetof(DFPWMAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
{ "channels", "", offsetof(DFPWMAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
{ NULL },
};
static const AVClass dfpwm_demuxer_class = {
.class_name = "dfpwm demuxer",
.item_name = av_default_item_name,
.option = dfpwm_options,
.version = LIBAVUTIL_VERSION_INT,
};
const AVInputFormat ff_dfpwm_demuxer = {
.name = "dfpwm",
.long_name = NULL_IF_CONFIG_SMALL("raw DFPWM1a"),
.priv_data_size = sizeof(DFPWMAudioDemuxerContext),
.read_header = dfpwm_read_header,
.read_packet = ff_pcm_read_packet,
.read_seek = ff_pcm_read_seek,
.flags = AVFMT_GENERIC_INDEX,
.extensions = "dfpwm",
.raw_codec_id = AV_CODEC_ID_DFPWM,
.priv_class = &dfpwm_demuxer_class,
};

View File

@ -192,6 +192,19 @@ const AVOutputFormat ff_data_muxer = {
};
#endif
#if CONFIG_DFPWM_MUXER
const AVOutputFormat ff_dfpwm_muxer = {
.name = "dfpwm",
.long_name = NULL_IF_CONFIG_SMALL("raw DFPWM1a"),
.extensions = "dfpwm",
.audio_codec = AV_CODEC_ID_DFPWM,
.video_codec = AV_CODEC_ID_NONE,
.init = force_one_stream,
.write_packet = ff_raw_write_packet,
.flags = AVFMT_NOTIMESTAMPS,
};
#endif
#if CONFIG_DIRAC_MUXER
const AVOutputFormat ff_dirac_muxer = {
.name = "dirac",

View File

@ -32,8 +32,8 @@
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 59
#define LIBAVFORMAT_VERSION_MINOR 17
#define LIBAVFORMAT_VERSION_MICRO 103
#define LIBAVFORMAT_VERSION_MINOR 18
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \