All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Go to the documentation of this file.
1 /*
2  * ACM demuxer
3  * Copyright (c) 2015 Paul B Mahol
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
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  */
22 #include "libavutil/intreadwrite.h"
23 #include "avformat.h"
24 #include "rawdec.h"
25 #include "internal.h"
27 static int acm_probe(AVProbeData *p)
28 {
29  if (AV_RB32(p->buf) != 0x97280301)
30  return 0;
32  return AVPROBE_SCORE_MAX / 3 * 2;
33 }
36 {
37  AVStream *st;
38  int ret;
40  st = avformat_new_stream(s, NULL);
41  if (!st)
42  return AVERROR(ENOMEM);
47  ff_alloc_extradata(st->codec, 14);
48  if (!st->codec->extradata)
49  return AVERROR(ENOMEM);
50  ret = avio_read(s->pb, st->codec->extradata, 14);
51  if (ret < 10)
52  return ret < 0 ? ret : AVERROR_EOF;
54  st->codec->channels = AV_RL16(st->codec->extradata + 8);
55  st->codec->sample_rate = AV_RL16(st->codec->extradata + 10);
56  if (st->codec->channels <= 0 || st->codec->sample_rate <= 0)
58  st->start_time = 0;
59  st->duration = AV_RL32(st->codec->extradata + 4) / st->codec->channels;
61  avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
63  return 0;
64 }
67  .name = "acm",
68  .long_name = NULL_IF_CONFIG_SMALL("Interplay ACM"),
69  .read_probe = acm_probe,
70  .read_header = acm_read_header,
71  .read_packet = ff_raw_read_partial_packet,
73  .extensions = "acm",
74  .raw_codec_id = AV_CODEC_ID_INTERPLAY_ACM,
75 };
#define NULL
Definition: coverity.c:32
Format does not allow to fall back on binary search via read_timestamp.
Definition: avformat.h:491
const char * s
Definition: avisynth_c.h:631
Invalid data found when processing input.
Definition: error.h:59
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4149
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:87
static int acm_read_header(AVFormatContext *s)
Definition: acm.c:35
Format I/O context.
Definition: avformat.h:1314
enum AVStreamParseType need_parsing
Definition: avformat.h:1069
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1647
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:3805
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_RB32
Definition: bytestream.h:87
End of file.
Definition: error.h:55
static int acm_probe(AVProbeData *p)
Definition: acm.c:27
full parsing and repack with timestamp and position generation by parser for raw this assumes that ea...
Definition: avformat.h:811
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:545
#define AVERROR(e)
Definition: error.h:43
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
Definition: rawdec.c:35
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:896
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:462
AVInputFormat ff_acm_demuxer
Definition: acm.c:66
Stream structure.
Definition: avformat.h:877
Format does not need / have any timestamps.
Definition: avformat.h:485
enum AVMediaType codec_type
Definition: avcodec.h:1540
enum AVCodecID codec_id
Definition: avcodec.h:1549
int sample_rate
samples per second
Definition: avcodec.h:2287
AVIOContext * pb
I/O context.
Definition: avformat.h:1356
Format does not allow to fall back on generic search.
Definition: avformat.h:492
int ff_alloc_extradata(AVCodecContext *avctx, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0...
Definition: utils.c:2979
This structure contains the data a format has to probe a file.
Definition: avformat.h:460
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:936
maximum score
Definition: avformat.h:472
Main libavformat public API header.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
Definition: avformat.h:929
Format does not allow seeking by bytes.
Definition: avformat.h:493
int channels
number of audio channels
Definition: avcodec.h:2288
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:661
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:87