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 #include "libavutil/avstring.h"
23 #include "avformat.h"
24 #include "internal.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/avassert.h"
28 #include "libavutil/opt.h"
29 #include "argo_asf.h"
30 
31 /* Maximum number of blocks to read at once. */
32 #define ASF_NB_BLOCKS 32
33 
34 typedef struct ArgoASFDemuxContext {
37  uint32_t blocks_read;
39 
40 typedef struct ArgoASFMuxContext {
41  const AVClass *class;
44  const char *name;
45  int64_t nb_blocks;
47 
48 void ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf)
49 {
50  hdr->magic = AV_RL32(buf + 0);
51  hdr->version_major = AV_RL16(buf + 4);
52  hdr->version_minor = AV_RL16(buf + 6);
53  hdr->num_chunks = AV_RL32(buf + 8);
54  hdr->chunk_offset = AV_RL32(buf + 12);
55  for (int i = 0; i < FF_ARRAY_ELEMS(hdr->name); i++)
56  hdr->name[i] = AV_RL8(buf + 16 + i);
57 }
58 
60 {
61  if (hdr->magic != ASF_TAG || hdr->num_chunks == 0)
62  return AVERROR_INVALIDDATA;
63 
65  return AVERROR_INVALIDDATA;
66 
67  return 0;
68 }
69 
70 void ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *buf)
71 {
72  hdr->num_blocks = AV_RL32(buf + 0);
73  hdr->num_samples = AV_RL32(buf + 4);
74  hdr->unk1 = AV_RL32(buf + 8);
75  hdr->sample_rate = AV_RL16(buf + 12);
76  hdr->unk2 = AV_RL16(buf + 14);
77  hdr->flags = AV_RL32(buf + 16);
78 }
79 
81  const ArgoASFChunkHeader *ckhdr)
82 {
83  if (ckhdr->num_samples != ASF_SAMPLE_COUNT) {
84  av_log(s, AV_LOG_ERROR, "Invalid sample count. Got %u, expected %d\n",
86  return AVERROR_INVALIDDATA;
87  }
88 
89  if ((ckhdr->flags & ASF_CF_ALWAYS1) != ASF_CF_ALWAYS1 || (ckhdr->flags & ASF_CF_ALWAYS0) != 0) {
90  avpriv_request_sample(s, "Nonstandard flags (0x%08X)", ckhdr->flags);
91  return AVERROR_PATCHWELCOME;
92  }
93 
97 
98  if (ckhdr->flags & ASF_CF_STEREO) {
100  st->codecpar->channels = 2;
101  } else {
103  st->codecpar->channels = 1;
104  }
105 
106  /* v1.1 files (FX Fighter) are all marked as 44100, but are actually 22050. */
107  if (fhdr->version_major == 1 && fhdr->version_minor == 1)
108  st->codecpar->sample_rate = 22050;
109  else
110  st->codecpar->sample_rate = ckhdr->sample_rate;
111 
113 
114  if (!(ckhdr->flags & ASF_CF_BITS_PER_SAMPLE)) {
115  /* The header allows for these, but I've never seen any files with them. */
116  avpriv_request_sample(s, "Non 16-bit samples");
117  return AVERROR_PATCHWELCOME;
118  }
119 
120  /*
121  * (nchannel control bytes) + ((bytes_per_channel) * nchannel)
122  * For mono, this is 17. For stereo, this is 34.
123  */
124  st->codecpar->block_align = st->codecpar->channels +
125  (ckhdr->num_samples / 2) *
126  st->codecpar->channels;
127 
128  st->codecpar->bit_rate = st->codecpar->channels *
129  st->codecpar->sample_rate *
131 
132  avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
133  st->start_time = 0;
134 
135  if (fhdr->num_chunks == 1) {
136  st->duration = ckhdr->num_blocks * ckhdr->num_samples;
137  st->nb_frames = ckhdr->num_blocks;
138  }
139 
140  return 0;
141 }
142 
143 #if CONFIG_ARGO_ASF_DEMUXER
144 /*
145  * Known versions:
146  * 1.1: https://samples.ffmpeg.org/game-formats/brender/part2.zip
147  * FX Fighter
148  * 1.2: Croc! Legend of the Gobbos
149  * 2.1: Croc 2
150  * The Emperor's New Groove
151  * Disney's Aladdin in Nasira's Revenge
152  */
153 static int argo_asf_is_known_version(const ArgoASFFileHeader *hdr)
154 {
155  return (hdr->version_major == 1 && hdr->version_minor == 1) ||
156  (hdr->version_major == 1 && hdr->version_minor == 2) ||
157  (hdr->version_major == 2 && hdr->version_minor == 1);
158 }
159 
160 static int argo_asf_probe(const AVProbeData *p)
161 {
162  ArgoASFFileHeader hdr;
163 
165 
167 
168  if (hdr.magic != ASF_TAG)
169  return 0;
170 
171  if (!argo_asf_is_known_version(&hdr))
172  return AVPROBE_SCORE_EXTENSION / 2;
173 
174  return AVPROBE_SCORE_EXTENSION + 1;
175 }
176 
177 static int argo_asf_read_header(AVFormatContext *s)
178 {
179  int64_t ret;
180  AVIOContext *pb = s->pb;
181  AVStream *st;
182  ArgoASFDemuxContext *asf = s->priv_data;
183  uint8_t buf[ASF_MIN_BUFFER_SIZE];
184 
185  if (!(st = avformat_new_stream(s, NULL)))
186  return AVERROR(ENOMEM);
187 
188  if ((ret = avio_read(pb, buf, ASF_FILE_HEADER_SIZE)) < 0)
189  return ret;
190  else if (ret != ASF_FILE_HEADER_SIZE)
191  return AVERROR(EIO);
192 
194 
195  if ((ret = ff_argo_asf_validate_file_header(s, &asf->fhdr)) < 0)
196  return ret;
197 
198  /* This should only be 1 in ASF files. >1 is fine if in BRP. */
199  if (asf->fhdr.num_chunks != 1)
200  return AVERROR_INVALIDDATA;
201 
202  if ((ret = avio_skip(pb, asf->fhdr.chunk_offset - ASF_FILE_HEADER_SIZE)) < 0)
203  return ret;
204 
205  if ((ret = avio_read(pb, buf, ASF_CHUNK_HEADER_SIZE)) < 0)
206  return ret;
207  else if (ret != ASF_CHUNK_HEADER_SIZE)
208  return AVERROR(EIO);
209 
211 
212  return ff_argo_asf_fill_stream(s, st, &asf->fhdr, &asf->ckhdr);
213 }
214 
215 static int argo_asf_read_packet(AVFormatContext *s, AVPacket *pkt)
216 {
217  ArgoASFDemuxContext *asf = s->priv_data;
218 
219  AVStream *st = s->streams[0];
220  AVIOContext *pb = s->pb;
221  int ret;
222 
223  if (asf->blocks_read >= asf->ckhdr.num_blocks)
224  return AVERROR_EOF;
225 
228  if (ret < 0)
229  return ret;
230 
231  /* Something real screwy is going on. */
232  if (ret % st->codecpar->block_align != 0)
233  return AVERROR_INVALIDDATA;
234 
235 
236  pkt->stream_index = st->index;
237  pkt->duration = asf->ckhdr.num_samples * (ret / st->codecpar->block_align);
238  pkt->pts = asf->blocks_read * asf->ckhdr.num_samples;
239  asf->blocks_read += (ret / st->codecpar->block_align);
240 
242  return 0;
243 }
244 
245 static int argo_asf_seek(AVFormatContext *s, int stream_index,
246  int64_t pts, int flags)
247 {
248  ArgoASFDemuxContext *asf = s->priv_data;
249  AVStream *st = s->streams[stream_index];
250  int64_t offset;
251  uint32_t block = pts / asf->ckhdr.num_samples;
252 
253  if (block >= asf->ckhdr.num_blocks)
254  return -1;
255 
257  (block * st->codecpar->block_align);
258 
259  if ((offset = avio_seek(s->pb, offset, SEEK_SET)) < 0)
260  return offset;
261 
262  asf->blocks_read = block;
263  return 0;
264 }
265 
266 /*
267  * Not actually sure what ASF stands for.
268  * - Argonaut Sound File?
269  * - Audio Stream File?
270  */
272  .name = "argo_asf",
273  .long_name = NULL_IF_CONFIG_SMALL("Argonaut Games ASF"),
274  .priv_data_size = sizeof(ArgoASFDemuxContext),
275  .read_probe = argo_asf_probe,
276  .read_header = argo_asf_read_header,
277  .read_packet = argo_asf_read_packet,
278  .read_seek = argo_asf_seek,
279 };
280 #endif
281 
282 #if CONFIG_ARGO_ASF_MUXER
283 static int argo_asf_write_init(AVFormatContext *s)
284 {
285  ArgoASFMuxContext *ctx = s->priv_data;
286  const AVCodecParameters *par;
287 
288  if (s->nb_streams != 1) {
289  av_log(s, AV_LOG_ERROR, "ASF files have exactly one stream\n");
290  return AVERROR(EINVAL);
291  }
292 
293  par = s->streams[0]->codecpar;
294 
295  if (par->codec_id != AV_CODEC_ID_ADPCM_ARGO) {
296  av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
297  avcodec_get_name(par->codec_id));
298  return AVERROR(EINVAL);
299  }
300 
301  if (ctx->version_major == 1 && ctx->version_minor == 1 && par->sample_rate != 22050) {
302  av_log(s, AV_LOG_ERROR, "ASF v1.1 files only support a sample rate of 22050\n");
303  return AVERROR(EINVAL);
304  }
305 
306  if (par->channels > 2) {
307  av_log(s, AV_LOG_ERROR, "ASF files only support up to 2 channels\n");
308  return AVERROR(EINVAL);
309  }
310 
311  if (par->block_align != 17 * par->channels)
312  return AVERROR(EINVAL);
313 
314  if (par->sample_rate > UINT16_MAX) {
315  av_log(s, AV_LOG_ERROR, "Sample rate too large\n");
316  return AVERROR(EINVAL);
317  }
318 
319  if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
320  av_log(s, AV_LOG_ERROR, "Stream not seekable, unable to write output file\n");
321  return AVERROR(EINVAL);
322  }
323 
324  return 0;
325 }
326 
327 static void argo_asf_write_file_header(const ArgoASFFileHeader *fhdr, AVIOContext *pb)
328 {
329  avio_wl32( pb, fhdr->magic);
330  avio_wl16( pb, fhdr->version_major);
331  avio_wl16( pb, fhdr->version_minor);
332  avio_wl32( pb, fhdr->num_chunks);
333  avio_wl32( pb, fhdr->chunk_offset);
334  avio_write(pb, fhdr->name, sizeof(fhdr->name));
335 }
336 
337 static void argo_asf_write_chunk_header(const ArgoASFChunkHeader *ckhdr, AVIOContext *pb)
338 {
339  avio_wl32(pb, ckhdr->num_blocks);
340  avio_wl32(pb, ckhdr->num_samples);
341  avio_wl32(pb, ckhdr->unk1);
342  avio_wl16(pb, ckhdr->sample_rate);
343  avio_wl16(pb, ckhdr->unk2);
344  avio_wl32(pb, ckhdr->flags);
345 }
346 
347 static int argo_asf_write_header(AVFormatContext *s)
348 {
349  const AVCodecParameters *par = s->streams[0]->codecpar;
350  ArgoASFMuxContext *ctx = s->priv_data;
351  ArgoASFChunkHeader chdr;
352  ArgoASFFileHeader fhdr = {
353  .magic = ASF_TAG,
354  .version_major = (uint16_t)ctx->version_major,
355  .version_minor = (uint16_t)ctx->version_minor,
356  .num_chunks = 1,
357  .chunk_offset = ASF_FILE_HEADER_SIZE
358  };
359 
360  /*
361  * If the user specified a name, use it as is. Otherwise take the
362  * basename and lop off the extension (if any).
363  */
364  if (ctx->name) {
365  strncpy(fhdr.name, ctx->name, sizeof(fhdr.name));
366  } else {
367  const char *start = av_basename(s->url);
368  const char *end = strrchr(start, '.');
369  size_t len;
370 
371  if (end)
372  len = end - start;
373  else
374  len = strlen(start);
375 
376  memcpy(fhdr.name, start, FFMIN(len, sizeof(fhdr.name)));
377  }
378 
379  chdr.num_blocks = 0;
381  chdr.unk1 = 0;
382 
383  if (ctx->version_major == 1 && ctx->version_minor == 1)
384  chdr.sample_rate = 44100;
385  else
386  chdr.sample_rate = par->sample_rate;
387 
388  chdr.unk2 = ~0;
390 
391  if (par->channels == 2)
392  chdr.flags |= ASF_CF_STEREO;
393 
394  argo_asf_write_file_header(&fhdr, s->pb);
395  argo_asf_write_chunk_header(&chdr, s->pb);
396  return 0;
397 }
398 
399 static int argo_asf_write_packet(AVFormatContext *s, AVPacket *pkt)
400 {
401  ArgoASFMuxContext *ctx = s->priv_data;
402  AVCodecParameters *par = s->streams[0]->codecpar;
403  int nb_blocks = pkt->size / par->block_align;
404 
405  if (pkt->size % par->block_align != 0)
406  return AVERROR_INVALIDDATA;
407 
408  if (ctx->nb_blocks + nb_blocks > UINT32_MAX)
409  return AVERROR_INVALIDDATA;
410 
411  avio_write(s->pb, pkt->data, pkt->size);
412 
413  ctx->nb_blocks += nb_blocks;
414  return 0;
415 }
416 
417 static int argo_asf_write_trailer(AVFormatContext *s)
418 {
419  ArgoASFMuxContext *ctx = s->priv_data;
420  int64_t ret;
421 
422  if ((ret = avio_seek(s->pb, ASF_FILE_HEADER_SIZE, SEEK_SET) < 0))
423  return ret;
424 
425  avio_wl32(s->pb, (uint32_t)ctx->nb_blocks);
426  return 0;
427 }
428 
429 static const AVOption argo_asf_options[] = {
430  {
431  .name = "version_major",
432  .help = "override file major version",
433  .offset = offsetof(ArgoASFMuxContext, version_major),
434  .type = AV_OPT_TYPE_INT,
435  .default_val = {.i64 = 2},
436  .min = 0,
437  .max = UINT16_MAX,
439  },
440  {
441  .name = "version_minor",
442  .help = "override file minor version",
443  .offset = offsetof(ArgoASFMuxContext, version_minor),
444  .type = AV_OPT_TYPE_INT,
445  .default_val = {.i64 = 1},
446  .min = 0,
447  .max = UINT16_MAX,
449  },
450  {
451  .name = "name",
452  .help = "embedded file name (max 8 characters)",
453  .offset = offsetof(ArgoASFMuxContext, name),
454  .type = AV_OPT_TYPE_STRING,
455  .default_val = {.str = NULL},
457  },
458  { NULL }
459 };
460 
461 static const AVClass argo_asf_muxer_class = {
462  .class_name = "argo_asf_muxer",
463  .item_name = av_default_item_name,
464  .option = argo_asf_options,
465  .version = LIBAVUTIL_VERSION_INT
466 };
467 
469  .name = "argo_asf",
470  .long_name = NULL_IF_CONFIG_SMALL("Argonaut Games ASF"),
471  /*
472  * NB: Can't do this as it conflicts with the actual ASF format.
473  * .extensions = "asf",
474  */
475  .audio_codec = AV_CODEC_ID_ADPCM_ARGO,
476  .video_codec = AV_CODEC_ID_NONE,
477  .init = argo_asf_write_init,
478  .write_header = argo_asf_write_header,
479  .write_packet = argo_asf_write_packet,
480  .write_trailer = argo_asf_write_trailer,
481  .priv_class = &argo_asf_muxer_class,
482  .priv_data_size = sizeof(ArgoASFMuxContext)
483 };
484 #endif
ArgoASFChunkHeader::sample_rate
uint16_t sample_rate
Definition: argo_asf.h:50
ff_argo_asf_demuxer
const AVInputFormat ff_argo_asf_demuxer
ArgoASFChunkHeader::num_samples
uint32_t num_samples
Definition: argo_asf.h:48
ArgoASFChunkHeader::flags
uint32_t flags
Definition: argo_asf.h:52
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:496
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
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:724
ArgoASFChunkHeader::unk2
uint16_t unk2
Definition: argo_asf.h:51
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_MONO
Definition: channel_layout.h:90
AVPacket::data
uint8_t * data
Definition: packet.h:373
AVOption
AVOption.
Definition: opt.h:247
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:391
ArgoASFDemuxContext::fhdr
ArgoASFFileHeader fhdr
Definition: argo_asf.c:35
AV_RL8
#define AV_RL8(x)
Definition: intreadwrite.h:398
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:80
av_basename
const char * av_basename(const char *path)
Thread safe basename.
Definition: avstring.c:260
ASF_NB_BLOCKS
#define ASF_NB_BLOCKS
Definition: argo_asf.c:32
avio_wl16
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:451
ASF_FILE_HEADER_SIZE
#define ASF_FILE_HEADER_SIZE
Definition: argo_asf.h:32
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
ArgoASFMuxContext::version_minor
int version_minor
Definition: argo_asf.c:43
ArgoASFFileHeader::version_minor
uint16_t version_minor
Definition: argo_asf.h:40
ArgoASFChunkHeader
Definition: argo_asf.h:46
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:149
AVPROBE_PADDING_SIZE
#define AVPROBE_PADDING_SIZE
extra allocated bytes at the end of the probe buffer
Definition: avformat.h:460
pts
static int64_t pts
Definition: transcode_aac.c:653
ArgoASFMuxContext::nb_blocks
int64_t nb_blocks
Definition: argo_asf.c:45
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:888
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:91
avassert.h
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVInputFormat
Definition: avformat.h:626
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
AV_PKT_FLAG_CORRUPT
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
Definition: packet.h:426
intreadwrite.h
ArgoASFMuxContext::name
const char * name
Definition: argo_asf.c:44
s
#define s(width, name)
Definition: cbs_vp9.c:257
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:277
ArgoASFFileHeader::num_chunks
uint32_t num_chunks
Definition: argo_asf.h:41
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:631
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:448
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:37
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ArgoASFDemuxContext
Definition: argo_asf.c:34
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:37
AVFormatContext
Format I/O context.
Definition: avformat.h:1097
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:992
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
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:36
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
AV_CODEC_ID_ADPCM_ARGO
@ AV_CODEC_ID_ADPCM_ARGO
Definition: codec_id.h:394
ff_argo_asf_validate_file_header
int ff_argo_asf_validate_file_header(AVFormatContext *s, const ArgoASFFileHeader *hdr)
Definition: argo_asf.c:59
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:446
argo_asf.h
AVPROBE_SCORE_EXTENSION
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition: avformat.h:456
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:890
ArgoASFFileHeader::version_major
uint16_t version_major
Definition: argo_asf.h:39
ASF_SAMPLE_COUNT
#define ASF_SAMPLE_COUNT
Definition: argo_asf.h:34
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
AVPacket::size
int size
Definition: packet.h:374
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:117
AVOption::name
const char * name
Definition: opt.h:248
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:218
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:371
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:379
ff_argo_asf_muxer
const AVOutputFormat ff_argo_asf_muxer
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:67
avcodec_get_name
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:448
ArgoASFFileHeader::chunk_offset
uint32_t chunk_offset
Definition: argo_asf.h:42
i
int i
Definition: input.c:406
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:48
AVOutputFormat
Definition: avformat.h:495
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:366
AVCodecParameters::block_align
int block_align
Audio only.
Definition: codec_par.h:177
ff_argo_asf_parse_chunk_header
void ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *buf)
Definition: argo_asf.c:70
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
len
int len
Definition: vorbis_enc_data.h:426
ArgoASFMuxContext
Definition: argo_asf.c:40
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:196
ret
ret
Definition: filter_design.txt:187
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVStream
Stream structure.
Definition: avformat.h:845
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
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:71
ArgoASFChunkHeader::num_blocks
uint32_t num_blocks
Definition: argo_asf.h:47
avformat.h
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
ArgoASFFileHeader
Definition: argo_asf.h:37
ASF_CF_ALWAYS0
@ ASF_CF_ALWAYS0
Definition: argo_asf.h:62
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:846
ArgoASFChunkHeader::unk1
uint32_t unk1
Definition: argo_asf.h:49
channel_layout.h
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
ASF_CHUNK_HEADER_SIZE
#define ASF_CHUNK_HEADER_SIZE
Definition: argo_asf.h:33
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:625
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: utils.c:1146
AVPacket::stream_index
int stream_index
Definition: packet.h:375
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:333
ASF_MIN_BUFFER_SIZE
#define ASF_MIN_BUFFER_SIZE
Definition: argo_asf.h:35
AVCodecParameters::bits_per_coded_sample
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:102
ff_argo_asf_parse_file_header
void ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf)
Definition: argo_asf.c:48
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
ArgoASFFileHeader::name
int8_t name[8]
Definition: argo_asf.h:43
AVCodecParameters::format
int format
Definition: codec_par.h:84
ASF_TAG
#define ASF_TAG
Definition: argo_asf.h:31
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
AVPacket
This structure stores compressed data.
Definition: packet.h:350
ArgoASFMuxContext::version_major
int version_major
Definition: argo_asf.c:42
AVCodecParameters::channel_layout
uint64_t channel_layout
Audio only.
Definition: codec_par.h:162
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:89
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:28
ASF_CF_STEREO
@ ASF_CF_STEREO
Definition: argo_asf.h:57
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
ASF_CF_BITS_PER_SAMPLE
@ ASF_CF_BITS_PER_SAMPLE
Definition: argo_asf.h:56
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:878
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
ASF_CF_ALWAYS1
@ ASF_CF_ALWAYS1
Definition: argo_asf.h:61
ArgoASFFileHeader::magic
uint32_t magic
Definition: argo_asf.h:38