FFmpeg
Loading...
Searching...
No Matches
dfpwmdec.c
Go to the documentation of this file.
1/*
2 * RAW PCM demuxers
3 * Copyright (c) 2002 Fabrice Bellard
4 * Copyright (c) 2022 Jack Bruienne
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "libavutil/avstring.h"
24#include "avformat.h"
25#include "demux.h"
26#include "internal.h"
27#include "pcm.h"
28#include "libavutil/log.h"
29#include "libavutil/opt.h"
30#include "libavutil/avassert.h"
31
37
39{
40 DFPWMAudioDemuxerContext *s1 = s->priv_data;
42 AVStream *st;
43 int ret;
44
46 if (!st)
47 return AVERROR(ENOMEM);
48 par = st->codecpar;
49
52 par->sample_rate = s1->sample_rate;
54 if (ret < 0)
55 return ret;
56 par->bits_per_coded_sample = 1;
57 par->block_align = 1;
58
59 avpriv_set_pts_info(st, 64, 1, par->sample_rate);
60 return 0;
61}
62
63static const AVOption dfpwm_options[] = {
64 { "sample_rate", "", offsetof(DFPWMAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
65 { "ch_layout", "", offsetof(DFPWMAudioDemuxerContext, ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "mono"}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
66{ NULL },
67};
69 .class_name = "dfpwm demuxer",
70 .item_name = av_default_item_name,
71 .option = dfpwm_options,
72 .version = LIBAVUTIL_VERSION_INT,
73};
74
76 .p.name = "dfpwm",
77 .p.long_name = NULL_IF_CONFIG_SMALL("raw DFPWM1a"),
78 .p.flags = AVFMT_GENERIC_INDEX,
79 .p.extensions = "dfpwm",
80 .p.priv_class = &dfpwm_demuxer_class,
81 .priv_data_size = sizeof(DFPWMAudioDemuxerContext),
85 .raw_codec_id = AV_CODEC_ID_DFPWM,
86};
const FFInputFormat ff_dfpwm_demuxer
Definition dfpwmdec.c:75
simple assert() macros that are a bit more flexible than ISO C assert().
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition avformat.c:834
Main libavformat public API header.
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition avformat.h:499
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition opt.h:355
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition opt.h:330
@ AV_CODEC_ID_DFPWM
Definition codec_id.h:549
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define AVERROR(e)
Definition error.h:45
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static const AVClass dfpwm_demuxer_class
Definition dfpwmdec.c:68
static int dfpwm_read_header(AVFormatContext *s)
Definition dfpwmdec.c:38
static const AVOption dfpwm_options[]
Definition dfpwmdec.c:63
int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition pcm.c:57
int ff_pcm_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition pcm.c:73
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
AVOptions.
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
Definition log.h:76
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition codec_par.h:113
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
int block_align
The number of bytes per coded audio frame, required by some formats.
Definition codec_par.h:221
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
Format I/O context.
Definition avformat.h:1333
AVOption.
Definition opt.h:428
Stream structure.
Definition avformat.h:766
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:789
AVChannelLayout ch_layout
Definition dfpwmdec.c:35