FFmpeg: libavformat/dss.c Source File
Go to the documentation of this file. 1 /*
2 * Digital Speech Standard (DSS) demuxer
3 * Copyright (c) 2014 Oleksij Rempel <linux@rempel-privat.de>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
25
29
30 #define DSS_HEAD_OFFSET_AUTHOR 0xc
31 #define DSS_AUTHOR_SIZE 16
32
33 #define DSS_HEAD_OFFSET_START_TIME 0x26
34 #define DSS_HEAD_OFFSET_END_TIME 0x32
35 #define DSS_TIME_SIZE 12
36
37 #define DSS_HEAD_OFFSET_ACODEC 0x2a4
38 #define DSS_ACODEC_DSS_SP 0x0 /* SP mode */
39 #define DSS_ACODEC_G723_1 0x2 /* LP mode */
40
41 #define DSS_HEAD_OFFSET_COMMENT 0x31e
42 #define DSS_COMMENT_SIZE 64
43
44 #define DSS_BLOCK_SIZE 512
45 #define DSS_AUDIO_BLOCK_HEADER_SIZE 6
46 #define DSS_FRAME_SIZE 42
47
49
55
59
61 {
64 return 0;
65
67 }
68
71 {
74 int y, month, d,
h, minute, sec;
76
78
82
83 if (sscanf(
string,
"%2d%2d%2d%2d%2d%2d", &y, &month, &d, &
h, &minute, &sec) != 6)
85 /* We deal with a two-digit year here, so set the default date to 2000
86 * and hope it will never be used in the next century. */
87 snprintf(datetime,
sizeof(datetime),
"%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
88 y + 2000, month, d,
h, minute, sec);
90 }
91
93 unsigned int size,
const char *
key)
94 {
98
100
104
109 }
110
112 }
113
115 {
120
122 if (!st)
124
127
132
136
141
144
149 * 512 / (506 * 264);
153 } else {
157 }
158
161
164
165 /* Jump over header */
166
167 if (
avio_seek(pb,
ctx->dss_header_size, SEEK_SET) !=
ctx->dss_header_size)
169
172
173 return 0;
174 }
175
177 {
180
183 }
184
186 {
188
192
193 /* Zero the padding. */
195 data[1] =
ctx->dss_sp_swap_byte;
196 } else {
198 }
199
200 /* make sure byte 40 is always 0 */
203 }
204
206 {
208 int read_size,
ret,
offset = 0, buff_offset = 0;
210
211 if (
ctx->counter == 0)
213
216 buff_offset = 3;
217 } else
219
223
227
228 if (
ctx->counter < read_size) {
231 if (ret < ctx->counter)
232 goto error_eof;
233
236 }
237 ctx->counter -= read_size;
238
239 /* This will write one byte into pkt's padding if buff_offset == 3 */
243 goto error_eof;
244
246
247 if (
ctx->dss_sp_swap_byte < 0) {
249 }
250
251 return 0;
252
253 error_eof:
255 }
256
258 {
263
264 if (
ctx->counter == 0)
266
267 /* We make one byte-step here. Don't forget to add offset. */
269 if (byte == 0xff)
271
273
276
281
286
288
292 if (ret < ctx->counter)
294
299 }
301
305
306 return 0;
307 }
308
310 {
312
315 else
317 }
318
321 {
326
328 seekto = timestamp / 264 * 41 / 506 * 512;
329 else
331
332 if (seekto < 0)
333 seekto = 0;
334
335 seekto +=
ctx->dss_header_size;
336
340
349 } else {
352 }
353 ctx->dss_sp_swap_byte = -1;
354 return 0;
355 }
356
357
361 .p.extensions = "dss",
367 };
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
#define DSS_HEAD_OFFSET_COMMENT
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static void dss_skip_audio_header(AVFormatContext *s, AVPacket *pkt)
static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
#define DSS_HEAD_OFFSET_ACODEC
static void dss_sp_byte_swap(DSSDemuxContext *ctx, uint8_t *data)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
#define DSS_ACODEC_DSS_SP
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static int dss_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define DSS_HEAD_OFFSET_AUTHOR
static int dss_read_metadata_date(AVFormatContext *s, unsigned int offset, const char *key)
static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static const uint8_t frame_size[4]
This structure contains the data a format has to probe a file.
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
const struct AVCodec * audio_codec
Forced audio codec.
#define DSS_ACODEC_G723_1
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
An AVChannelLayout holds information about the channel layout of audio data.
static const uint8_t header[24]
int avio_r8(AVIOContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
#define DSS_HEAD_OFFSET_END_TIME
static int read_header(FFV1Context *f, RangeCoder *c)
#define i(width, name, range_min, range_max)
static int dss_read_metadata_string(AVFormatContext *s, unsigned int offset, unsigned int size, const char *key)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
static int dss_read_packet(AVFormatContext *s, AVPacket *pkt)
#define DSS_AUDIO_BLOCK_HEADER_SIZE
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
const FFInputFormat ff_dss_demuxer
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int read_probe(const AVProbeData *p)
#define avpriv_request_sample(...)
#define AV_CHANNEL_LAYOUT_MONO
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int64_t pos
byte position in stream, -1 if unknown
static int dss_read_header(AVFormatContext *s)
static int dss_probe(const AVProbeData *p)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Generated on Wed Nov 19 2025 19:23:11 for FFmpeg by
doxygen
1.8.17