FFmpeg
Loading...
Searching...
No Matches
dss.c
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
24#include "libavutil/mem.h"
25
26#include "avformat.h"
27#include "demux.h"
28#include "internal.h"
29#include "avio_internal.h"
30
31#define DSS_HEAD_OFFSET_AUTHOR 0xc
32#define DSS_AUTHOR_SIZE 16
33
34#define DSS_HEAD_OFFSET_START_TIME 0x26
35#define DSS_HEAD_OFFSET_END_TIME 0x32
36#define DSS_TIME_SIZE 12
37
38#define DSS_HEAD_OFFSET_ACODEC 0x2a4
39#define DSS_ACODEC_DSS_SP 0x0 /* SP mode */
40#define DSS_ACODEC_DSS_SP_VR 0x1 /* SP mode, variable rate */
41#define DSS_ACODEC_G723_1 0x2 /* LP mode */
42
43#define DSS_HEAD_OFFSET_COMMENT 0x31e
44#define DSS_COMMENT_SIZE 64
45
46#define DSS_BLOCK_SIZE 512
47#define DSS_AUDIO_BLOCK_HEADER_SIZE 6
48#define DSS_BLOCK_KEEP_BEFORE 2
49#define DSS_FRAME_SIZE 42
50#define DSS_SP_SHORT_FRAME_SIZE 9
51
52static const uint8_t frame_size[4] = { 24, 20, 4, 1 };
53
54typedef struct DSSDemuxContext {
55 unsigned int audio_codec;
56 int swap;
57 int64_t block_pos; /* offset of the current audio block header */
58 int frames_left; /* frames still to come from that block */
60 AVPacket *seek_pkt; /* frame a seek stopped at, returned next */
61 int seek_end; /* then what ended the read past it, if anything */
62 int64_t frames_read; /* index of the next frame */
63
66
67/* Frames that start in an audio block: byte 2 when it is not 0, otherwise
68 * byte 5 unless that is 0xff. A recorder writes the second form where it
69 * pauses or stops, and those frames are audio like any other. */
70static int dss_block_frames(const uint8_t *header)
71{
72 if (header[2] || header[5] == 0xff)
73 return header[2];
74 return header[5];
75}
76
77static int dss_probe(const AVProbeData *p)
78{
79 if ( AV_RL32(p->buf) != MKTAG(0x2, 'd', 's', 's')
80 && AV_RL32(p->buf) != MKTAG(0x3, 'd', 's', 's'))
81 return 0;
82
83 return AVPROBE_SCORE_MAX;
84}
85
87 const char *key)
88{
89 AVIOContext *pb = s->pb;
90 char datetime[64], string[DSS_TIME_SIZE + 1] = { 0 };
91 int y, month, d, h, minute, sec;
92 int ret;
93
94 avio_seek(pb, offset, SEEK_SET);
95
96 ret = avio_read(s->pb, string, DSS_TIME_SIZE);
97 if (ret < DSS_TIME_SIZE)
98 return ret < 0 ? ret : AVERROR_EOF;
99
100 if (sscanf(string, "%2d%2d%2d%2d%2d%2d", &y, &month, &d, &h, &minute, &sec) != 6)
101 return AVERROR_INVALIDDATA;
102 /* We deal with a two-digit year here, so set the default date to 2000
103 * and hope it will never be used in the next century. */
104 snprintf(datetime, sizeof(datetime), "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
105 y + 2000, month, d, h, minute, sec);
106 return av_dict_set(&s->metadata, key, datetime, 0);
107}
108
110 unsigned int size, const char *key)
111{
112 AVIOContext *pb = s->pb;
113 char *value;
114 int ret;
115
116 avio_seek(pb, offset, SEEK_SET);
117
118 value = av_mallocz(size + 1);
119 if (!value)
120 return AVERROR(ENOMEM);
121
122 ret = avio_read(s->pb, value, size);
123 if (ret < size) {
124 av_free(value);
125 return ret < 0 ? ret : AVERROR_EOF;
126 }
127
128 return av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
129}
130
132
133/* Go back to the first audio block, where reading starts after the header. */
135{
136 DSSDemuxContext *ctx = s->priv_data;
137 int64_t ret = avio_seek(s->pb, ctx->dss_header_size, SEEK_SET);
138
139 if (ret < 0)
140 return (int)ret;
141
142 ctx->swap = 0;
143 ctx->frames_left = 0;
144 ctx->frames_read = 0;
145 ctx->dss_sp_swap_byte = -1;
146 /* dss_next_block steps forward first, so start one block short. */
147 ctx->block_pos = ctx->dss_header_size - DSS_BLOCK_SIZE;
148 return 0;
149}
150
151/* Frames in the file, or 0 if the input cannot seek. Each block header states
152 * how many frames start in the block, but the reader takes them from where the
153 * first one starts, on into the next blocks when the block states more than it
154 * holds, and stops where the file ends or a frame does not parse. So the
155 * frames are counted by reading them all. */
157{
158 AVIOContext *pb = s->pb;
159 int64_t frames = 0;
160 int ret;
161 AVPacket *pkt;
162
163 if (!(pb->seekable & AVIO_SEEKABLE_NORMAL))
164 return 0;
165 if ((ret = dss_rewind(s)) < 0)
166 return ret;
167
169 if (!pkt)
170 return AVERROR(ENOMEM);
171
172 while ((ret = dss_read_packet(s, pkt)) >= 0 || ret == FFERROR_REDO) {
173 if (ret >= 0)
174 frames++;
176 }
178
179 if (pb->error < 0 && pb->error != AVERROR_EOF)
180 return pb->error;
182 return ret;
183 return frames;
184}
185
187{
188 DSSDemuxContext *ctx = s->priv_data;
189 AVIOContext *pb = s->pb;
190 AVStream *st;
192 int ret, version;
193
195 if (!st)
196 return AVERROR(ENOMEM);
197
198 version = avio_r8(pb);
199 ctx->dss_header_size = version * DSS_BLOCK_SIZE;
200
202 DSS_AUTHOR_SIZE, "author");
203 if (ret)
204 return ret;
205
207 if (ret)
208 return ret;
209
211 DSS_COMMENT_SIZE, "comment");
212 if (ret)
213 return ret;
214
215 avio_seek(pb, DSS_HEAD_OFFSET_ACODEC, SEEK_SET);
216 ctx->audio_codec = avio_r8(pb);
217
218 if (ctx->audio_codec == DSS_ACODEC_DSS_SP ||
219 ctx->audio_codec == DSS_ACODEC_DSS_SP_VR) {
221 /* The decoder reads the format to tell variable rate SP apart. */
222 if ((ret = ff_alloc_extradata(st->codecpar, 1)) < 0)
223 return ret;
224 st->codecpar->extradata[0] = ctx->audio_codec;
225 /* See libavcodec/dss_sp.c: the decoder runs at 12000 Hz and
226 * decimates 11:12, so the output rate is 11000 Hz, not 11025. This
227 * also sets the packet time base just below. */
228 st->codecpar->sample_rate = 11000;
229 } else if (ctx->audio_codec == DSS_ACODEC_G723_1) {
231 st->codecpar->sample_rate = 8000;
232 } else {
233 avpriv_request_sample(s, "Support for codec %x in DSS",
234 ctx->audio_codec);
236 }
237
240
242
244 if (frames < 0)
245 return (int)frames;
246 if (frames > 0) {
247 st->nb_frames = frames;
248 st->duration = frames * (ctx->audio_codec == DSS_ACODEC_G723_1 ? 240 : 264);
249 }
250
251 return dss_rewind(s);
252}
253
254/* A seek callback can report an operational error without setting pb->error.
255 * Some callbacks also reject positions at or past EOF. Preserve that case
256 * when the input size establishes that there is no data at the target. */
258{
259 int64_t ret = avio_seek(pb, pos, SEEK_SET);
261
262 if (ret >= 0)
263 return 0;
264 if (pb->error < 0)
265 return pb->error;
266 if (ret == AVERROR_EOF)
267 return ret;
268 size = avio_size(pb);
269 if (size >= 0 && pos >= size)
270 return AVERROR_EOF;
271 return ret;
272}
273
275{
276 DSSDemuxContext *ctx = s->priv_data;
277 AVIOContext *pb = s->pb;
278 int64_t keep = FFMAX(pos - DSS_BLOCK_KEEP_BEFORE, ctx->dss_header_size);
279 int ret;
280
281 if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) {
282 if ((ret = dss_seek_to(pb, keep)) < 0)
283 return ret;
284 ret = ffio_ensure_seekback(pb, pos - keep + 2 * DSS_BLOCK_SIZE);
285 if (ret < 0)
286 return ret;
287 }
288 return dss_seek_to(pb, pos);
289}
290
291/* Read `size` bytes of frame payload, stepping over any block header met on
292 * the way. Block payloads are contiguous as far as the frames are concerned,
293 * and a frame is short enough to straddle at most one boundary. */
294static int dss_read_payload(AVFormatContext *s, uint8_t *buf, int size)
295{
296 DSSDemuxContext *ctx = s->priv_data;
297 AVIOContext *pb = s->pb;
298 int ret;
299
300 while (size > 0) {
301 int64_t off = (avio_tell(pb) - ctx->dss_header_size) % DSS_BLOCK_SIZE;
302 int chunk;
303
304 if (off < DSS_AUDIO_BLOCK_HEADER_SIZE) {
305 ret = dss_seek_to(pb, avio_tell(pb) +
307 if (ret < 0)
308 return ret;
309 continue;
310 }
311 chunk = FFMIN(size, (int)(DSS_BLOCK_SIZE - off));
312 ret = ffio_read_size(pb, buf, chunk);
313 if (ret < 0) {
314 /* ffio_read_size reports a short read as invalid data, including
315 * when AVIO returned some bytes before an I/O error. */
316 if (pb->error < 0)
317 return pb->error;
319 }
320 buf += chunk;
321 size -= chunk;
322 }
323 return 0;
324}
325
326/* Move to the next audio block and take its framing from its header.
327 *
328 * Each block states the length of the frame fragment carried over from the
329 * previous block, the byte-swap parity of its first whole frame, and how many
330 * frames it holds. Deriving the framing by running on from the previous frame
331 * instead gives the same answer for as long as nothing disturbs the recording,
332 * which is why most files decode; but a paused or edited recording restates
333 * them, and a running walk then reads every remaining frame a byte out of
334 * phase. Believing the block keeps the walk in step, and costs nothing when
335 * the two agree. */
337{
338 DSSDemuxContext *ctx = s->priv_data;
339 AVIOContext *pb = s->pb;
341 int64_t block_pos = ctx->block_pos;
342 int cont, ret;
343
344 for (;;) {
345 ctx->block_pos += DSS_BLOCK_SIZE;
346 if ((ret = dss_seek_block(s, ctx->block_pos)) < 0)
347 goto fail;
349 if (ret < 0 && ret != AVERROR_EOF)
350 goto fail;
352 ret = pb->error < 0 ? pb->error : AVERROR_EOF;
353 goto fail;
354 }
355
356 ctx->swap = !!(header[0] & 0x80);
357 cont = 2 * header[1] + 2 * ctx->swap - DSS_AUDIO_BLOCK_HEADER_SIZE;
358 if (cont < 0 || cont > DSS_BLOCK_SIZE - DSS_AUDIO_BLOCK_HEADER_SIZE)
359 cont = 0;
360
361 ctx->frames_left = dss_block_frames(header);
362 if (!ctx->frames_left)
363 continue;
364
365 /* A swapped frame takes one byte from the frame before it, two bytes
366 * before its own start, in this block or at the end of the previous
367 * one. Read it from there rather than carry it over: after a seek, at
368 * the start of a cut file, or where a block restarts the framing, the
369 * frame before has not been read. */
370 if (ctx->swap) {
371 int64_t at = ctx->block_pos + cont - 2;
372
373 if (cont >= 2)
375 if (at >= ctx->dss_header_size + DSS_AUDIO_BLOCK_HEADER_SIZE) {
376 if ((ret = dss_seek_to(pb, at)) < 0)
377 goto fail;
378 ctx->dss_sp_swap_byte = avio_r8(pb);
379 if (pb->error < 0) {
380 ret = pb->error;
381 goto fail;
382 }
383 }
384 }
385
386 ret = dss_seek_to(pb, ctx->block_pos + DSS_AUDIO_BLOCK_HEADER_SIZE + cont);
387 if (ret < 0)
388 goto fail;
389 return 0;
390 }
391
392fail:
393 ctx->block_pos = block_pos;
394 ctx->frames_left = 0;
395 return ret;
396}
397
398/* Offset of the next frame. A frame can start where a block does, after the
399 * block header that dss_read_payload() steps over. */
401{
402 DSSDemuxContext *ctx = s->priv_data;
403 int64_t pos = avio_tell(s->pb);
404 int64_t off = (pos - ctx->dss_header_size) % DSS_BLOCK_SIZE;
405
408 return pos;
409}
410
411/* size is the frame length in bytes, 41 or 9; both are odd, so the parity
412 * flips after every frame. */
413static void dss_sp_byte_swap(DSSDemuxContext *ctx, uint8_t *data, int size)
414{
415 int i;
416
417 if (ctx->swap) {
418 for (i = 0; i < size - 1; i += 2)
419 data[i] = data[i + 4];
420
421 data[1] = ctx->dss_sp_swap_byte;
422 } else {
423 ctx->dss_sp_swap_byte = data[size - 1];
424 }
425
426 /* Zero the padding, and make sure the byte past the frame is 0. */
427 memset(data + size + 1, 0, DSS_FRAME_SIZE - size);
428 data[size - 1] = 0;
429 ctx->swap ^= 1;
430}
431
433{
434 DSSDemuxContext *ctx = s->priv_data;
435 int size = DSS_FRAME_SIZE - 1;
436 int ret, done = 0;
437 int64_t pos;
438
439 if (ctx->frames_left <= 0) {
441 if (ret < 0)
442 return ret;
443 }
445
447 if (ret < 0)
448 return ret;
449
450 pkt->duration = 264;
451 pkt->pts = ctx->frames_read++ * 264;
452 pkt->pos = pos;
453 pkt->stream_index = 0;
454
455 /* In variable rate SP the top bit of the frame's first byte, in 16-bit
456 * word order, is clear for a short frame. A swapped frame starts with the
457 * byte carried over from the previous frame; otherwise it is the second
458 * byte read. */
459 if (ctx->audio_codec == DSS_ACODEC_DSS_SP_VR) {
460 if (ctx->swap) {
461 if (ctx->dss_sp_swap_byte >= 0 && !(ctx->dss_sp_swap_byte & 0x80))
463 } else {
464 ret = dss_read_payload(s, pkt->data, 2);
465 if (ret < 0)
466 return ret;
467 done = 2;
468 if (!(pkt->data[1] & 0x80))
470 }
471 }
472
473 /* A swapped frame reads one byte less than its size, starting at offset
474 * 3, which writes one byte into pkt's padding for a long frame; an
475 * unswapped one reads one byte more. */
476 if (ctx->swap)
477 ret = dss_read_payload(s, pkt->data + 3, size - 1);
478 else
479 ret = dss_read_payload(s, pkt->data + done, size + 1 - done);
480 if (ret < 0)
481 return ret;
482
483 ctx->frames_left--;
484
485 dss_sp_byte_swap(ctx, pkt->data, size);
486
487 if (ctx->dss_sp_swap_byte < 0) {
488 return FFERROR_REDO;
489 }
490
491 return 0;
492}
493
495{
496 DSSDemuxContext *ctx = s->priv_data;
497 uint8_t byte;
498 int size, ret;
499 int64_t pos;
500
501 if (ctx->frames_left <= 0) {
503 if (ret < 0)
504 return ret;
505 }
507
508 ret = dss_read_payload(s, &byte, 1);
509 if (ret < 0)
510 return ret;
511 if (byte == 0xff)
512 return AVERROR_INVALIDDATA;
513
514 size = frame_size[byte & 3];
515
517 if (ret < 0)
518 return ret;
519 pkt->pos = pos;
520
521 pkt->data[0] = byte;
522 pkt->duration = 240;
523 pkt->pts = ctx->frames_read++ * 240;
524
525 pkt->stream_index = 0;
526
527 ret = dss_read_payload(s, pkt->data + 1, size - 1);
528 if (ret < 0)
529 return ret;
530
531 ctx->frames_left--;
532
533 return 0;
534}
535
537{
538 DSSDemuxContext *ctx = s->priv_data;
539
540 if (ctx->audio_codec != DSS_ACODEC_G723_1)
541 return dss_sp_read_packet(s, pkt);
542 else
543 return dss_723_1_read_packet(s, pkt);
544}
545
546/* Return the frame a seek stopped at, and if the read ended after it, what
547 * ended it; then go on reading. */
549{
550 DSSDemuxContext *ctx = s->priv_data;
551
552 if (ctx->seek_pkt && ctx->seek_pkt->size) {
553 av_packet_move_ref(pkt, ctx->seek_pkt);
554 return 0;
555 }
556 if (ctx->seek_end) {
557 int ret = ctx->seek_end;
558
559 ctx->seek_end = 0;
560 return ret;
561 }
562 return dss_read_packet(s, pkt);
563}
564
565/* Read from the first frame up to the one that holds the timestamp, and keep
566 * that one to be returned next, or past the end the last one. Only reading
567 * tells where the frames are, as for the duration: a block that states more
568 * frames than it holds sends the reader on into the next blocks, and a frame
569 * that does not parse ends the stream. So the frame found, its timestamp and
570 * the frames after it are those of a read from the start. Like opening the
571 * file, this reads the input up to the target. */
572static int dss_read_seek(AVFormatContext *s, int stream_index,
573 int64_t timestamp, int flags)
574{
575 DSSDemuxContext *ctx = s->priv_data;
576 AVPacket *pkt;
577 int ret;
578
579 if (!ctx->seek_pkt && !(ctx->seek_pkt = av_packet_alloc()))
580 return AVERROR(ENOMEM);
581 av_packet_unref(ctx->seek_pkt);
582 ctx->seek_end = 0;
583 if ((ret = dss_rewind(s)) < 0)
584 return ret;
585
587 if (!pkt)
588 return AVERROR(ENOMEM);
589
590 while ((ret = dss_read_packet(s, pkt)) >= 0 || ret == FFERROR_REDO) {
591 if (ret < 0) {
593 continue;
594 }
595 av_packet_unref(ctx->seek_pkt);
596 av_packet_move_ref(ctx->seek_pkt, pkt);
597 if (ctx->seek_pkt->pts + ctx->seek_pkt->duration > timestamp)
598 break;
599 }
601
602 if (ret < 0) {
603 if (s->pb->error < 0 && s->pb->error != AVERROR_EOF)
604 ret = s->pb->error;
605 else if ((ret == AVERROR_EOF || ret == AVERROR_INVALIDDATA) &&
606 ctx->seek_pkt->size) {
607 ctx->seek_end = ret;
608 ret = 0;
609 }
610 if (ret < 0)
611 av_packet_unref(ctx->seek_pkt);
612 }
613 return ret;
614}
615
617{
618 DSSDemuxContext *ctx = s->priv_data;
619
620 av_packet_free(&ctx->seek_pkt);
621 return 0;
622}
623
625 .p.name = "dss",
626 .p.long_name = NULL_IF_CONFIG_SMALL("Digital Speech Standard (DSS)"),
627 .p.extensions = "dss",
628 .p.flags = AVFMT_NO_BYTE_SEEK,
629 .priv_data_size = sizeof(DSSDemuxContext),
635};
const FFInputFormat ff_dss_demuxer
Definition dss.c:624
static int frames
static AVFormatContext * ctx
static void chunk(Buf *b, const char type[4], const uint8_t *data, int n)
Definition apnggen.c:106
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:865
Main libavformat public API header.
#define AVPROBE_SCORE_MAX
maximum score
Definition avformat.h:485
#define AVFMT_NO_BYTE_SEEK
Format does not allow seeking by bytes.
Definition avformat.h:508
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition aviobuf.c:236
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition avio.h:41
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition aviobuf.c:326
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:507
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:620
int avio_r8(AVIOContext *s)
Definition aviobuf.c:611
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
Definition aviobuf.c:994
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:674
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
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
Definition bytestream.h:99
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
Public libavutil channel layout APIs header.
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
#define FFERROR_REDO
Returned by demuxers to indicate that data was consumed but discarded (ignored streams or junk data).
Definition demux.h:234
static AVPacket * pkt
#define DSS_BLOCK_KEEP_BEFORE
Definition dss.c:48
static void dss_sp_byte_swap(DSSDemuxContext *ctx, uint8_t *data, int size)
Definition dss.c:413
#define DSS_ACODEC_G723_1
Definition dss.c:41
static int dss_next_block(AVFormatContext *s)
Definition dss.c:336
#define DSS_AUTHOR_SIZE
Definition dss.c:32
static int64_t dss_frame_pos(AVFormatContext *s)
Definition dss.c:400
static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition dss.c:432
static int dss_read_metadata_string(AVFormatContext *s, unsigned int offset, unsigned int size, const char *key)
Definition dss.c:109
#define DSS_HEAD_OFFSET_ACODEC
Definition dss.c:38
static int dss_seek_to(AVIOContext *pb, int64_t pos)
Definition dss.c:257
static int dss_read_payload(AVFormatContext *s, uint8_t *buf, int size)
Definition dss.c:294
static int dss_block_frames(const uint8_t *header)
Definition dss.c:70
static int dss_probe(const AVProbeData *p)
Definition dss.c:77
static int dss_rewind(AVFormatContext *s)
Definition dss.c:134
#define DSS_HEAD_OFFSET_END_TIME
Definition dss.c:35
static int dss_read_header(AVFormatContext *s)
Definition dss.c:186
#define DSS_HEAD_OFFSET_COMMENT
Definition dss.c:43
static int dss_read_close(AVFormatContext *s)
Definition dss.c:616
static int dss_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition dss.c:536
static int dss_read_next_packet(AVFormatContext *s, AVPacket *pkt)
Definition dss.c:548
#define DSS_HEAD_OFFSET_AUTHOR
Definition dss.c:31
#define DSS_FRAME_SIZE
Definition dss.c:49
static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition dss.c:494
#define DSS_AUDIO_BLOCK_HEADER_SIZE
Definition dss.c:47
#define DSS_COMMENT_SIZE
Definition dss.c:44
#define DSS_ACODEC_DSS_SP
Definition dss.c:39
#define DSS_TIME_SIZE
Definition dss.c:36
static int dss_seek_block(AVFormatContext *s, int64_t pos)
Definition dss.c:274
static int dss_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition dss.c:572
static int64_t dss_count_frames(AVFormatContext *s)
Definition dss.c:156
#define DSS_SP_SHORT_FRAME_SIZE
Definition dss.c:50
static int dss_read_metadata_date(AVFormatContext *s, unsigned int offset, const char *key)
Definition dss.c:86
#define DSS_BLOCK_SIZE
Definition dss.c:46
#define DSS_ACODEC_DSS_SP_VR
Definition dss_sp.c:39
double value
Definition eval.c:102
const char * key
int ret
Definition ffplay.c:391
SDL_atomic_t done
Definition ffplay.c:392
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:580
static const uint8_t frame_size[4]
Definition g723_1.h:222
#define fail
Definition test.h:479
@ AV_CODEC_ID_G723_1
Definition codec_id.h:511
@ AV_CODEC_ID_DSS_SP
Definition codec_id.h:525
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:435
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition packet.c:492
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition packet.c:98
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AV_CHANNEL_LAYOUT_MONO
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
Definition dict.h:79
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:87
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
#define AV_RL32(p)
unsigned offset
Definition libaomenc.c:812
int ff_alloc_extradata(AVCodecParameters *par, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0.
Definition utils.c:237
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
version
Definition libkvazaar.c:313
#define FFMIN(a, b)
Definition macros.h:49
#define MKTAG(a, b, c, d)
Definition macros.h:55
#define FFMAX(a, b)
Definition macros.h:47
Memory handling functions.
const char data[16]
Definition mxf.c:155
static const uint8_t header[24]
Definition sdr2.c:68
unsigned int pos
Definition spdifenc.c:431
An AVChannelLayout holds information about the channel layout of audio data.
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
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:71
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:1401
Bytestream IO Context.
Definition avio.h:160
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition avio.h:261
int error
contains the error code or 0 if no error happened
Definition avio.h:239
This structure stores compressed data.
Definition packet.h:587
This structure contains the data a format has to probe a file.
Definition avformat.h:473
Stream structure.
Definition avformat.h:768
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:791
int64_t nb_frames
number of frames in this stream if known or 0
Definition avformat.h:829
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition avformat.h:827
int seek_end
Definition dss.c:61
int frames_left
Definition dss.c:58
int64_t frames_read
Definition dss.c:62
int dss_header_size
Definition dss.c:64
int dss_sp_swap_byte
Definition dss.c:59
AVPacket * seek_pkt
Definition dss.c:60
int64_t block_pos
Definition dss.c:57
unsigned int audio_codec
Definition dss.c:55
#define av_free(p)
#define av_mallocz(s)
#define avpriv_request_sample(...)
int size