FFmpeg
argo_asf.c
Go to the documentation of this file.
1 /*
2  * Argonaut Games ASF (de)muxer
3  *
4  * Copyright (C) 2020 Zane van Iperen (zane@zanevaniperen.com)
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 "config_components.h"
24 
25 #include "libavutil/avstring.h"
26 #include "avformat.h"
27 #include "demux.h"
28 #include "internal.h"
29 #include "mux.h"
31 #include "libavutil/intreadwrite.h"
32 #include "libavutil/avassert.h"
33 #include "libavutil/opt.h"
34 #include "argo_asf.h"
35 
36 /* Maximum number of blocks to read at once. */
37 #define ASF_NB_BLOCKS 32
38 
39 typedef struct ArgoASFDemuxContext {
42  uint32_t blocks_read;
44 
45 typedef struct ArgoASFMuxContext {
46  const AVClass *class;
49  const char *name;
52 
53 void ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf)
54 {
55  hdr->magic = AV_RL32(buf + 0);
56  hdr->version_major = AV_RL16(buf + 4);
57  hdr->version_minor = AV_RL16(buf + 6);
58  hdr->num_chunks = AV_RL32(buf + 8);
59  hdr->chunk_offset = AV_RL32(buf + 12);
60  memcpy(hdr->name, buf + 16, ASF_NAME_SIZE);
61  hdr->name[ASF_NAME_SIZE] = '\0';
62 }
63 
65 {
66  if (hdr->magic != ASF_TAG || hdr->num_chunks == 0)
67  return AVERROR_INVALIDDATA;
68 
70  return AVERROR_INVALIDDATA;
71 
72  return 0;
73 }
74 
75 void ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *buf)
76 {
77  hdr->num_blocks = AV_RL32(buf + 0);
78  hdr->num_samples = AV_RL32(buf + 4);
79  hdr->unk1 = AV_RL32(buf + 8);
80  hdr->sample_rate = AV_RL16(buf + 12);
81  hdr->unk2 = AV_RL16(buf + 14);
82  hdr->flags = AV_RL32(buf + 16);
83 }
84 
86  const ArgoASFChunkHeader *ckhdr)
87 {
88  if (ckhdr->num_samples != ASF_SAMPLE_COUNT) {
89  av_log(s, AV_LOG_ERROR, "Invalid sample count. Got %u, expected %d\n",
91  return AVERROR_INVALIDDATA;
92  }
93 
94  if ((ckhdr->flags & ASF_CF_ALWAYS1) != ASF_CF_ALWAYS1 || (ckhdr->flags & ASF_CF_ALWAYS0) != 0) {
95  avpriv_request_sample(s, "Nonstandard flags (0x%08X)", ckhdr->flags);
96  return AVERROR_PATCHWELCOME;
97  }
98 
102 
103  if (ckhdr->flags & ASF_CF_STEREO) {
105  } else {
107  }
108 
109  /* v1.1 files (FX Fighter) are all marked as 44100, but are actually 22050. */
110  if (fhdr->version_major == 1 && fhdr->version_minor == 1)
111  st->codecpar->sample_rate = 22050;
112  else
113  st->codecpar->sample_rate = ckhdr->sample_rate;
114 
116 
117  if (!(ckhdr->flags & ASF_CF_BITS_PER_SAMPLE)) {
118  /* The header allows for these, but I've never seen any files with them. */
119  avpriv_request_sample(s, "Non 16-bit samples");
120  return AVERROR_PATCHWELCOME;
121  }
122 
123  /*
124  * (nchannel control bytes) + ((bytes_per_channel) * nchannel)
125  * For mono, this is 17. For stereo, this is 34.
126  */
128  (ckhdr->num_samples / 2) *
130 
132  st->codecpar->sample_rate *
134 
135  avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
136  st->start_time = 0;
137 
138  if (fhdr->num_chunks == 1) {
139  st->duration = ckhdr->num_blocks * ckhdr->num_samples;
140  st->nb_frames = ckhdr->num_blocks;
141  }
142 
143  return 0;
144 }
145 
146 #if CONFIG_ARGO_ASF_DEMUXER
147 /*
148  * Known versions:
149  * 1.1: https://samples.ffmpeg.org/game-formats/brender/part2.zip
150  * FX Fighter
151  * 1.2: Croc! Legend of the Gobbos
152  * 2.1: Croc 2
153  * The Emperor's New Groove
154  * Disney's Aladdin in Nasira's Revenge
155  */
156 static int argo_asf_is_known_version(const ArgoASFFileHeader *hdr)
157 {
158  return (hdr->version_major == 1 && hdr->version_minor == 1) ||
159  (hdr->version_major == 1 && hdr->version_minor == 2) ||
160  (hdr->version_major == 2 && hdr->version_minor == 1);
161 }
162 
163 static int argo_asf_probe(const AVProbeData *p)
164 {
165  ArgoASFFileHeader hdr;
166 
168 
170 
171  if (hdr.magic != ASF_TAG)
172  return 0;
173 
174  if (!argo_asf_is_known_version(&hdr))
175  return AVPROBE_SCORE_EXTENSION / 2;
176 
177  return AVPROBE_SCORE_EXTENSION + 1;
178 }
179 
180 static int argo_asf_read_header(AVFormatContext *s)
181 {
182  int64_t ret;
183  AVIOContext *pb = s->pb;
184  AVStream *st;
185  ArgoASFDemuxContext *asf = s->priv_data;
186  uint8_t buf[ASF_MIN_BUFFER_SIZE];
187 
188  if (!(st = avformat_new_stream(s, NULL)))
189  return AVERROR(ENOMEM);
190 
191  if ((ret = avio_read(pb, buf, ASF_FILE_HEADER_SIZE)) < 0)
192  return ret;
193  else if (ret != ASF_FILE_HEADER_SIZE)
194  return AVERROR(EIO);
195 
197 
198  if ((ret = ff_argo_asf_validate_file_header(s, &asf->fhdr)) < 0)
199  return ret;
200 
201  /* This should only be 1 in ASF files. >1 is fine if in BRP. */
202  if (asf->fhdr.num_chunks != 1)
203  return AVERROR_INVALIDDATA;
204 
205  if ((ret = avio_skip(pb, asf->fhdr.chunk_offset - ASF_FILE_HEADER_SIZE)) < 0)
206  return ret;
207 
208  if ((ret = avio_read(pb, buf, ASF_CHUNK_HEADER_SIZE)) < 0)
209  return ret;
210  else if (ret != ASF_CHUNK_HEADER_SIZE)
211  return AVERROR(EIO);
212 
214 
215  av_dict_set(&s->metadata, "title", asf->fhdr.name, 0);
216 
217  return ff_argo_asf_fill_stream(s, st, &asf->fhdr, &asf->ckhdr);
218 }
219 
220 static int argo_asf_read_packet(AVFormatContext *s, AVPacket *pkt)
221 {
222  ArgoASFDemuxContext *asf = s->priv_data;
223 
224  AVStream *st = s->streams[0];
225  AVIOContext *pb = s->pb;
226  int ret;
227 
228  if (asf->blocks_read >= asf->ckhdr.num_blocks)
229  return AVERROR_EOF;
230 
233  if (ret < 0)
234  return ret;
235 
236  /* Something real screwy is going on. */
237  if (ret % st->codecpar->block_align != 0)
238  return AVERROR_INVALIDDATA;
239 
240 
241  pkt->stream_index = st->index;
242  pkt->duration = asf->ckhdr.num_samples * (ret / st->codecpar->block_align);
243  pkt->pts = asf->blocks_read * asf->ckhdr.num_samples;
244  asf->blocks_read += (ret / st->codecpar->block_align);
245 
247  return 0;
248 }
249 
250 static int argo_asf_seek(AVFormatContext *s, int stream_index,
251  int64_t pts, int flags)
252 {
253  ArgoASFDemuxContext *asf = s->priv_data;
254  AVStream *st = s->streams[stream_index];
255  int64_t offset;
256  uint32_t block = pts / asf->ckhdr.num_samples;
257 
258  if (block >= asf->ckhdr.num_blocks)
259  return -1;
260 
263 
264  if ((offset = avio_seek(s->pb, offset, SEEK_SET)) < 0)
265  return offset;
266 
267  asf->blocks_read = block;
268  return 0;
269 }
270 
271 /*
272  * Not actually sure what ASF stands for.
273  * - Argonaut Sound File?
274  * - Audio Stream File?
275  */
277  .p.name = "argo_asf",
278  .p.long_name = NULL_IF_CONFIG_SMALL("Argonaut Games ASF"),
279  .priv_data_size = sizeof(ArgoASFDemuxContext),
280  .read_probe = argo_asf_probe,
281  .read_header = argo_asf_read_header,
282  .read_packet = argo_asf_read_packet,
283  .read_seek = argo_asf_seek,
284 };
285 #endif
286 
287 #if CONFIG_ARGO_ASF_MUXER
288 static int argo_asf_write_init(AVFormatContext *s)
289 {
290  ArgoASFMuxContext *ctx = s->priv_data;
291  const AVCodecParameters *par = s->streams[0]->codecpar;
292 
293  if (ctx->version_major == 1 && ctx->version_minor == 1 && par->sample_rate != 22050) {
294  av_log(s, AV_LOG_ERROR, "ASF v1.1 files only support a sample rate of 22050\n");
295  return AVERROR(EINVAL);
296  }
297 
298  if (par->ch_layout.nb_channels > 2) {
299  av_log(s, AV_LOG_ERROR, "ASF files only support up to 2 channels\n");
300  return AVERROR(EINVAL);
301  }
302 
303  if (par->block_align != 17 * par->ch_layout.nb_channels)
304  return AVERROR(EINVAL);
305 
306  if (par->sample_rate > UINT16_MAX) {
307  av_log(s, AV_LOG_ERROR, "Sample rate too large\n");
308  return AVERROR(EINVAL);
309  }
310 
311  if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
312  av_log(s, AV_LOG_ERROR, "Stream not seekable, unable to write output file\n");
313  return AVERROR(EINVAL);
314  }
315 
316  return 0;
317 }
318 
319 static void argo_asf_write_file_header(const ArgoASFFileHeader *fhdr, AVIOContext *pb)
320 {
321  avio_wl32( pb, fhdr->magic);
322  avio_wl16( pb, fhdr->version_major);
323  avio_wl16( pb, fhdr->version_minor);
324  avio_wl32( pb, fhdr->num_chunks);
325  avio_wl32( pb, fhdr->chunk_offset);
326  avio_write(pb, fhdr->name, ASF_NAME_SIZE);
327 }
328 
329 static void argo_asf_write_chunk_header(const ArgoASFChunkHeader *ckhdr, AVIOContext *pb)
330 {
331  avio_wl32(pb, ckhdr->num_blocks);
332  avio_wl32(pb, ckhdr->num_samples);
333  avio_wl32(pb, ckhdr->unk1);
334  avio_wl16(pb, ckhdr->sample_rate);
335  avio_wl16(pb, ckhdr->unk2);
336  avio_wl32(pb, ckhdr->flags);
337 }
338 
339 static int argo_asf_write_header(AVFormatContext *s)
340 {
341  const AVCodecParameters *par = s->streams[0]->codecpar;
342  ArgoASFMuxContext *ctx = s->priv_data;
343  ArgoASFChunkHeader chdr;
344  ArgoASFFileHeader fhdr = {
345  .magic = ASF_TAG,
346  .version_major = (uint16_t)ctx->version_major,
347  .version_minor = (uint16_t)ctx->version_minor,
348  .num_chunks = 1,
349  .chunk_offset = ASF_FILE_HEADER_SIZE
350  };
352  const char *name, *end;
353  size_t len;
354 
355  /*
356  * If the user specified a name, use it as is. Otherwise,
357  * try to use metadata (if present), then fall back to the
358  * filename (minus extension).
359  */
360  if (ctx->name) {
361  name = ctx->name;
362  len = strlen(ctx->name);
363  } else if ((t = av_dict_get(s->metadata, "title", NULL, 0))) {
364  name = t->value;
365  len = strlen(t->value);
366  } else if (!(end = strrchr((name = av_basename(s->url)), '.'))) {
367  len = strlen(name);
368  } else {
369  len = end - name;
370  }
371  memcpy(fhdr.name, name, FFMIN(len, ASF_NAME_SIZE));
372 
373  chdr.num_blocks = 0;
375  chdr.unk1 = 0;
376 
377  if (ctx->version_major == 1 && ctx->version_minor == 1)
378  chdr.sample_rate = 44100;
379  else
380  chdr.sample_rate = par->sample_rate;
381 
382  chdr.unk2 = ~0;
384 
385  if (par->ch_layout.nb_channels == 2)
386  chdr.flags |= ASF_CF_STEREO;
387 
388  argo_asf_write_file_header(&fhdr, s->pb);
389  argo_asf_write_chunk_header(&chdr, s->pb);
390  return 0;
391 }
392 
393 static int argo_asf_write_packet(AVFormatContext *s, AVPacket *pkt)
394 {
395  ArgoASFMuxContext *ctx = s->priv_data;
396  AVCodecParameters *par = s->streams[0]->codecpar;
397  int nb_blocks = pkt->size / par->block_align;
398 
399  if (pkt->size % par->block_align != 0)
400  return AVERROR_INVALIDDATA;
401 
402  if (ctx->nb_blocks + nb_blocks > UINT32_MAX)
403  return AVERROR_INVALIDDATA;
404 
405  avio_write(s->pb, pkt->data, pkt->size);
406 
407  ctx->nb_blocks += nb_blocks;
408  return 0;
409 }
410 
411 static int argo_asf_write_trailer(AVFormatContext *s)
412 {
413  ArgoASFMuxContext *ctx = s->priv_data;
414  int64_t ret;
415 
416  if ((ret = avio_seek(s->pb, ASF_FILE_HEADER_SIZE, SEEK_SET)) < 0)
417  return ret;
418 
419  avio_wl32(s->pb, (uint32_t)ctx->nb_blocks);
420  return 0;
421 }
422 
423 static const AVOption argo_asf_options[] = {
424  {
425  .name = "version_major",
426  .help = "override file major version",
427  .offset = offsetof(ArgoASFMuxContext, version_major),
428  .type = AV_OPT_TYPE_INT,
429  .default_val = {.i64 = 2},
430  .min = 0,
431  .max = UINT16_MAX,
433  },
434  {
435  .name = "version_minor",
436  .help = "override file minor version",
437  .offset = offsetof(ArgoASFMuxContext, version_minor),
438  .type = AV_OPT_TYPE_INT,
439  .default_val = {.i64 = 1},
440  .min = 0,
441  .max = UINT16_MAX,
443  },
444  {
445  .name = "name",
446  .help = "embedded file name (max 8 characters)",
447  .offset = offsetof(ArgoASFMuxContext, name),
448  .type = AV_OPT_TYPE_STRING,
449  .default_val = {.str = NULL},
451  },
452  { NULL }
453 };
454 
455 static const AVClass argo_asf_muxer_class = {
456  .class_name = "argo_asf_muxer",
457  .item_name = av_default_item_name,
458  .option = argo_asf_options,
459  .version = LIBAVUTIL_VERSION_INT
460 };
461 
463  .p.name = "argo_asf",
464  .p.long_name = NULL_IF_CONFIG_SMALL("Argonaut Games ASF"),
465  /*
466  * NB: Can't do this as it conflicts with the actual ASF format.
467  * .p.extensions = "asf",
468  */
469  .p.audio_codec = AV_CODEC_ID_ADPCM_ARGO,
470  .p.video_codec = AV_CODEC_ID_NONE,
471  .p.subtitle_codec = AV_CODEC_ID_NONE,
472  .p.priv_class = &argo_asf_muxer_class,
473  .flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH |
475  .init = argo_asf_write_init,
476  .write_header = argo_asf_write_header,
477  .write_packet = argo_asf_write_packet,
478  .write_trailer = argo_asf_write_trailer,
479  .priv_data_size = sizeof(ArgoASFMuxContext)
480 };
481 #endif
ArgoASFChunkHeader::sample_rate
uint16_t sample_rate
Definition: argo_asf.h:51
ArgoASFChunkHeader::num_samples
uint32_t num_samples
Definition: argo_asf.h:49
ArgoASFChunkHeader::flags
uint32_t flags
Definition: argo_asf.h:53
name
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 minimum maximum flags name is the option name
Definition: writing_filters.txt:88
AVOutputFormat::name
const char * name
Definition: avformat.h:510
AVERROR
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
opt.h
ArgoASFChunkHeader::unk2
uint16_t unk2
Definition: argo_asf.h:52
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:393
ArgoASFFileHeader::name
char name[ASF_NAME_SIZE+1]
Definition: argo_asf.h:44
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:47
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
int64_t
long long int64_t
Definition: coverity.c:34
AVPacket::data
uint8_t * data
Definition: packet.h:539
AVOption
AVOption.
Definition: opt.h:429
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:557
ArgoASFDemuxContext::fhdr
ArgoASFFileHeader fhdr
Definition: argo_asf.c:40
FF_OFMT_FLAG_ONLY_DEFAULT_CODECS
#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS
If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat....
Definition: mux.h:59
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:327
ff_argo_asf_fill_stream
int ff_argo_asf_fill_stream(AVFormatContext *s, AVStream *st, const ArgoASFFileHeader *fhdr, const ArgoASFChunkHeader *ckhdr)
Definition: argo_asf.c:85
av_basename
const char * av_basename(const char *path)
Thread safe basename.
Definition: avstring.c:252
FFOutputFormat::p
AVOutputFormat p
The public AVOutputFormat.
Definition: mux.h:65
ASF_CF_ALWAYS1
@ ASF_CF_ALWAYS1
Definition: argo_asf.h:62
ASF_CF_BITS_PER_SAMPLE
@ ASF_CF_BITS_PER_SAMPLE
Definition: argo_asf.h:57
ASF_NB_BLOCKS
#define ASF_NB_BLOCKS
Definition: argo_asf.c:37
avio_wl16
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:437
ASF_FILE_HEADER_SIZE
#define ASF_FILE_HEADER_SIZE
Definition: argo_asf.h:32
avpriv_set_pts_info
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:867
ArgoASFMuxContext::version_minor
int version_minor
Definition: argo_asf.c:48
ArgoASFFileHeader::version_minor
uint16_t version_minor
Definition: argo_asf.h:41
ArgoASFChunkHeader
Definition: argo_asf.h:47
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:151
ff_argo_asf_muxer
const FFOutputFormat ff_argo_asf_muxer
AVPROBE_PADDING_SIZE
#define AVPROBE_PADDING_SIZE
extra allocated bytes at the end of the probe buffer
Definition: avformat.h:465
pts
static int64_t pts
Definition: transcode_aac.c:644
ArgoASFMuxContext::nb_blocks
int64_t nb_blocks
Definition: argo_asf.c:50
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:807
avassert.h
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
AV_PKT_FLAG_CORRUPT
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
Definition: packet.h:595
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_read_callback.c:42
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:62
intreadwrite.h
ArgoASFMuxContext::name
const char * name
Definition: argo_asf.c:49
s
#define s(width, name)
Definition: cbs_vp9.c:198
ArgoASFFileHeader::num_chunks
uint32_t num_chunks
Definition: argo_asf.h:42
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:553
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:453
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
ctx
AVFormatContext * ctx
Definition: movenc.c:49
ArgoASFDemuxContext
Definition: argo_asf.c:39
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:94
ArgoASFDemuxContext::blocks_read
uint32_t blocks_read
Definition: argo_asf.c:42
if
if(ret)
Definition: filter_design.txt:179
AVFormatContext
Format I/O context.
Definition: avformat.h:1300
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:771
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:540
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
ArgoASFDemuxContext::ckhdr
ArgoASFChunkHeader ckhdr
Definition: argo_asf.c:41
AV_CODEC_ID_ADPCM_ARGO
@ AV_CODEC_ID_ADPCM_ARGO
Definition: codec_id.h:415
ff_argo_asf_validate_file_header
int ff_argo_asf_validate_file_header(AVFormatContext *s, const ArgoASFFileHeader *hdr)
Definition: argo_asf.c:64
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:451
argo_asf.h
FFOutputFormat
Definition: mux.h:61
ASF_CF_STEREO
@ ASF_CF_STEREO
Definition: argo_asf.h:58
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:180
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition: opt.h:352
AVPROBE_SCORE_EXTENSION
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition: avformat.h:461
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:184
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:809
ArgoASFFileHeader::version_major
uint16_t version_major
Definition: argo_asf.h:40
ASF_SAMPLE_COUNT
#define ASF_SAMPLE_COUNT
Definition: argo_asf.h:34
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
AVPacket::size
int size
Definition: packet.h:540
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:317
AVOption::name
const char * name
Definition: opt.h:430
FFInputFormat::p
AVInputFormat p
The public AVInputFormat.
Definition: demux.h:46
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:201
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:357
offset
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
Definition: writing_filters.txt:86
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:545
ff_argo_asf_demuxer
const FFInputFormat ff_argo_asf_demuxer
ASF_NAME_SIZE
#define ASF_NAME_SIZE
Definition: argo_asf.h:36
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
ArgoASFFileHeader::chunk_offset
uint32_t chunk_offset
Definition: argo_asf.h:43
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:532
ASF_CF_ALWAYS0
@ ASF_CF_ALWAYS0
Definition: argo_asf.h:63
AVCodecParameters::block_align
int block_align
Audio only.
Definition: codec_par.h:191
FF_OFMT_FLAG_MAX_ONE_OF_EACH
#define FF_OFMT_FLAG_MAX_ONE_OF_EACH
If this flag is set, it indicates that for each codec type whose corresponding default codec (i....
Definition: mux.h:50
ff_argo_asf_parse_chunk_header
void ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *buf)
Definition: argo_asf.c:75
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
demux.h
len
int len
Definition: vorbis_enc_data.h:426
ArgoASFMuxContext
Definition: argo_asf.c:45
av_get_packet
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:91
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:748
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:231
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:80
ArgoASFChunkHeader::num_blocks
uint32_t num_blocks
Definition: argo_asf.h:48
avformat.h
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
ArgoASFFileHeader
Definition: argo_asf.h:38
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:754
ArgoASFChunkHeader::unk1
uint32_t unk1
Definition: argo_asf.h:50
channel_layout.h
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:41
ASF_CHUNK_HEADER_SIZE
#define ASF_CHUNK_HEADER_SIZE
Definition: argo_asf.h:33
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:612
AVPacket::stream_index
int stream_index
Definition: packet.h:541
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:318
ASF_MIN_BUFFER_SIZE
#define ASF_MIN_BUFFER_SIZE
Definition: argo_asf.h:35
read_probe
static int read_probe(const AVProbeData *p)
Definition: cdg.c:30
AVCodecParameters::bits_per_coded_sample
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:110
ff_argo_asf_parse_file_header
void ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf)
Definition: argo_asf.c:53
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:36
AVCodecParameters::format
int format
Definition: codec_par.h:92
ASF_TAG
#define ASF_TAG
Definition: argo_asf.h:31
AV_CHANNEL_LAYOUT_MONO
#define AV_CHANNEL_LAYOUT_MONO
Definition: channel_layout.h:392
AVDictionaryEntry
Definition: dict.h:89
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:516
av_dict_set
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:88
FFInputFormat
Definition: demux.h:42
ArgoASFMuxContext::version_major
int version_major
Definition: argo_asf.c:47
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:97
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AVDictionaryEntry::value
char * value
Definition: dict.h:91
AVStream::start_time
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition: avformat.h:797
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
ArgoASFFileHeader::magic
uint32_t magic
Definition: argo_asf.h:39
mux.h