rmdec.c
Go to the documentation of this file.
1 /*
2  * "Real" compatible demuxer.
3  * Copyright (c) 2000, 2001 Fabrice Bellard
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 
22 #include "libavutil/avassert.h"
23 #include "libavutil/avstring.h"
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/dict.h"
27 #include "avformat.h"
28 #include "avio_internal.h"
29 #include "internal.h"
30 #include "rmsipr.h"
31 #include "rm.h"
32 
33 #define DEINT_ID_GENR MKTAG('g', 'e', 'n', 'r') ///< interleaving for Cooker/Atrac
34 #define DEINT_ID_INT0 MKTAG('I', 'n', 't', '0') ///< no interleaving needed
35 #define DEINT_ID_INT4 MKTAG('I', 'n', 't', '4') ///< interleaving for 28.8
36 #define DEINT_ID_SIPR MKTAG('s', 'i', 'p', 'r') ///< interleaving for Sipro
37 #define DEINT_ID_VBRF MKTAG('v', 'b', 'r', 'f') ///< VBR case for AAC
38 #define DEINT_ID_VBRS MKTAG('v', 'b', 'r', 's') ///< VBR case for AAC
39 
40 struct RMStream {
41  AVPacket pkt; ///< place to store merged video frame / reordered audio data
42  int videobufsize; ///< current assembled frame size
43  int videobufpos; ///< position for the next slice in the video buffer
44  int curpic_num; ///< picture number of current frame
46  int64_t pktpos; ///< first slice position in file
47  /// Audio descrambling matrix parameters
48  int64_t audiotimestamp; ///< Audio packet timestamp
49  int sub_packet_cnt; // Subpacket counter, used while reading
50  int sub_packet_size, sub_packet_h, coded_framesize; ///< Descrambling parameters from container
51  int audio_framesize; /// Audio frame size from container
52  int sub_packet_lengths[16]; /// Length of each subpacket
53  int32_t deint_id; ///< deinterleaver used in audio stream
54 };
55 
56 typedef struct {
61  int audio_stream_num; ///< Stream number for audio packets
62  int audio_pkt_cnt; ///< Output packet counter
64 
65 static inline void get_strl(AVIOContext *pb, char *buf, int buf_size, int len)
66 {
67  int i;
68  char *q, r;
69 
70  q = buf;
71  for(i=0;i<len;i++) {
72  r = avio_r8(pb);
73  if (i < buf_size - 1)
74  *q++ = r;
75  }
76  if (buf_size > 0) *q = '\0';
77 }
78 
79 static void get_str8(AVIOContext *pb, char *buf, int buf_size)
80 {
81  get_strl(pb, buf, buf_size, avio_r8(pb));
82 }
83 
84 static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned size)
85 {
86  if (size >= 1<<24)
87  return -1;
89  if (!avctx->extradata)
90  return AVERROR(ENOMEM);
91  avctx->extradata_size = avio_read(pb, avctx->extradata, size);
92  memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
93  if (avctx->extradata_size != size)
94  return AVERROR(EIO);
95  return 0;
96 }
97 
98 static void rm_read_metadata(AVFormatContext *s, int wide)
99 {
100  char buf[1024];
101  int i;
102  for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
103  int len = wide ? avio_rb16(s->pb) : avio_r8(s->pb);
104  get_strl(s->pb, buf, sizeof(buf), len);
105  av_dict_set(&s->metadata, ff_rm_metadata[i], buf, 0);
106  }
107 }
108 
110 {
111  RMStream *rms = av_mallocz(sizeof(RMStream));
112  rms->curpic_num = -1;
113  return rms;
114 }
115 
117 {
118  av_free_packet(&rms->pkt);
119 }
120 
122  AVStream *st, RMStream *ast, int read_all)
123 {
124  char buf[256];
125  uint32_t version;
126  int ret;
127 
128  /* ra type header */
129  version = avio_rb16(pb); /* version */
130  if (version == 3) {
131  unsigned bytes_per_minute;
132  int header_size = avio_rb16(pb);
133  int64_t startpos = avio_tell(pb);
134  avio_skip(pb, 8);
135  bytes_per_minute = avio_rb16(pb);
136  avio_skip(pb, 4);
137  rm_read_metadata(s, 0);
138  if ((startpos + header_size) >= avio_tell(pb) + 2) {
139  // fourcc (should always be "lpcJ")
140  avio_r8(pb);
141  get_str8(pb, buf, sizeof(buf));
142  }
143  // Skip extra header crap (this should never happen)
144  if ((startpos + header_size) > avio_tell(pb))
145  avio_skip(pb, header_size + startpos - avio_tell(pb));
146  if (bytes_per_minute)
147  st->codec->bit_rate = 8LL * bytes_per_minute / 60;
148  st->codec->sample_rate = 8000;
149  st->codec->channels = 1;
153  ast->deint_id = DEINT_ID_INT0;
154  } else {
156  int codecdata_length;
157  unsigned bytes_per_minute;
158  /* old version (4) */
159  avio_skip(pb, 2); /* unused */
160  avio_rb32(pb); /* .ra4 */
161  avio_rb32(pb); /* data size */
162  avio_rb16(pb); /* version2 */
163  avio_rb32(pb); /* header size */
164  flavor= avio_rb16(pb); /* add codec info / flavor */
165  ast->coded_framesize = coded_framesize = avio_rb32(pb); /* coded frame size */
166  avio_rb32(pb); /* ??? */
167  bytes_per_minute = avio_rb32(pb);
168  if (version == 4) {
169  if (bytes_per_minute)
170  st->codec->bit_rate = 8LL * bytes_per_minute / 60;
171  }
172  avio_rb32(pb); /* ??? */
173  ast->sub_packet_h = sub_packet_h = avio_rb16(pb); /* 1 */
174  st->codec->block_align= avio_rb16(pb); /* frame size */
175  ast->sub_packet_size = sub_packet_size = avio_rb16(pb); /* sub packet size */
176  avio_rb16(pb); /* ??? */
177  if (version == 5) {
178  avio_rb16(pb); avio_rb16(pb); avio_rb16(pb);
179  }
180  st->codec->sample_rate = avio_rb16(pb);
181  avio_rb32(pb);
182  st->codec->channels = avio_rb16(pb);
183  if (version == 5) {
184  ast->deint_id = avio_rl32(pb);
185  avio_read(pb, buf, 4);
186  buf[4] = 0;
187  } else {
188  get_str8(pb, buf, sizeof(buf)); /* desc */
189  ast->deint_id = AV_RL32(buf);
190  get_str8(pb, buf, sizeof(buf)); /* desc */
191  }
193  st->codec->codec_tag = AV_RL32(buf);
195  st->codec->codec_tag);
196 
197  switch (st->codec->codec_id) {
198  case AV_CODEC_ID_AC3:
200  break;
201  case AV_CODEC_ID_RA_288:
202  st->codec->extradata_size= 0;
203  ast->audio_framesize = st->codec->block_align;
205  break;
206  case AV_CODEC_ID_COOK:
208  case AV_CODEC_ID_ATRAC3:
209  case AV_CODEC_ID_SIPR:
210  if (read_all) {
211  codecdata_length = 0;
212  } else {
213  avio_rb16(pb); avio_r8(pb);
214  if (version == 5)
215  avio_r8(pb);
216  codecdata_length = avio_rb32(pb);
217  if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
218  av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
219  return -1;
220  }
221  }
222 
223  ast->audio_framesize = st->codec->block_align;
224  if (st->codec->codec_id == AV_CODEC_ID_SIPR) {
225  if (flavor > 3) {
226  av_log(s, AV_LOG_ERROR, "bad SIPR file flavor %d\n",
227  flavor);
228  return -1;
229  }
230  st->codec->block_align = ff_sipr_subpk_size[flavor];
231  } else {
232  if(sub_packet_size <= 0){
233  av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
234  return -1;
235  }
236  st->codec->block_align = ast->sub_packet_size;
237  }
238  if ((ret = rm_read_extradata(pb, st->codec, codecdata_length)) < 0)
239  return ret;
240 
241  break;
242  case AV_CODEC_ID_AAC:
243  avio_rb16(pb); avio_r8(pb);
244  if (version == 5)
245  avio_r8(pb);
246  codecdata_length = avio_rb32(pb);
247  if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
248  av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
249  return -1;
250  }
251  if (codecdata_length >= 1) {
252  avio_r8(pb);
253  if ((ret = rm_read_extradata(pb, st->codec, codecdata_length - 1)) < 0)
254  return ret;
255  }
256  break;
257  default:
258  av_strlcpy(st->codec->codec_name, buf, sizeof(st->codec->codec_name));
259  }
260  if (ast->deint_id == DEINT_ID_INT4 ||
261  ast->deint_id == DEINT_ID_GENR ||
262  ast->deint_id == DEINT_ID_SIPR) {
263  if (st->codec->block_align <= 0 ||
264  ast->audio_framesize * sub_packet_h > (unsigned)INT_MAX ||
265  ast->audio_framesize * sub_packet_h < st->codec->block_align)
266  return AVERROR_INVALIDDATA;
267  if (av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h) < 0)
268  return AVERROR(ENOMEM);
269  }
270  switch (ast->deint_id) {
271  case DEINT_ID_INT4:
272  if (ast->coded_framesize > ast->audio_framesize ||
273  sub_packet_h <= 1 ||
274  ast->coded_framesize * sub_packet_h > (2 + (sub_packet_h & 1)) * ast->audio_framesize)
275  return AVERROR_INVALIDDATA;
276  break;
277  case DEINT_ID_GENR:
278  if (ast->sub_packet_size <= 0 ||
279  ast->sub_packet_size > ast->audio_framesize)
280  return AVERROR_INVALIDDATA;
281  break;
282  case DEINT_ID_SIPR:
283  case DEINT_ID_INT0:
284  case DEINT_ID_VBRS:
285  case DEINT_ID_VBRF:
286  break;
287  default:
288  av_log(s, AV_LOG_ERROR, "Unknown interleaver %X\n", ast->deint_id);
289  return AVERROR_INVALIDDATA;
290  }
291 
292  if (read_all) {
293  avio_r8(pb);
294  avio_r8(pb);
295  avio_r8(pb);
296  rm_read_metadata(s, 0);
297  }
298  }
299  return 0;
300 }
301 
302 int
304  AVStream *st, RMStream *rst, int codec_data_size, const uint8_t *mime)
305 {
306  unsigned int v;
307  int size;
308  int64_t codec_pos;
309  int ret;
310 
311  avpriv_set_pts_info(st, 64, 1, 1000);
312  codec_pos = avio_tell(pb);
313  v = avio_rb32(pb);
314  if (v == MKTAG(0xfd, 'a', 'r', '.')) {
315  /* ra type header */
316  if (rm_read_audio_stream_info(s, pb, st, rst, 0))
317  return -1;
318  } else if (v == MKBETAG('L', 'S', 'D', ':')) {
319  avio_seek(pb, -4, SEEK_CUR);
320  if ((ret = rm_read_extradata(pb, st->codec, codec_data_size)) < 0)
321  return ret;
322 
324  st->codec->codec_tag = AV_RL32(st->codec->extradata);
326  st->codec->codec_tag);
327  } else if(mime && !strcmp(mime, "logical-fileinfo")){
328  int stream_count, rule_count, property_count, i;
329  ff_free_stream(s, st);
330  if (avio_rb16(pb) != 0) {
331  av_log(s, AV_LOG_WARNING, "Unsupported version\n");
332  goto skip;
333  }
334  stream_count = avio_rb16(pb);
335  avio_skip(pb, 6*stream_count);
336  rule_count = avio_rb16(pb);
337  avio_skip(pb, 2*rule_count);
338  property_count = avio_rb16(pb);
339  for(i=0; i<property_count; i++){
340  uint8_t name[128], val[128];
341  avio_rb32(pb);
342  if (avio_rb16(pb) != 0) {
343  av_log(s, AV_LOG_WARNING, "Unsupported Name value property version\n");
344  goto skip; //FIXME skip just this one
345  }
346  get_str8(pb, name, sizeof(name));
347  switch(avio_rb32(pb)) {
348  case 2: get_strl(pb, val, sizeof(val), avio_rb16(pb));
349  av_dict_set(&s->metadata, name, val, 0);
350  break;
351  default: avio_skip(pb, avio_rb16(pb));
352  }
353  }
354  } else {
355  int fps;
356  if (avio_rl32(pb) != MKTAG('V', 'I', 'D', 'O')) {
357  fail1:
358  av_log(s, AV_LOG_WARNING, "Unsupported stream type %08x\n", v);
359  goto skip;
360  }
361  st->codec->codec_tag = avio_rl32(pb);
363  st->codec->codec_tag);
364  av_dlog(s, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
365  if (st->codec->codec_id == AV_CODEC_ID_NONE)
366  goto fail1;
367  st->codec->width = avio_rb16(pb);
368  st->codec->height = avio_rb16(pb);
369  avio_skip(pb, 2); // looks like bits per sample
370  avio_skip(pb, 4); // always zero?
373  fps = avio_rb32(pb);
374 
375  if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0)
376  return ret;
377 
379  0x10000, fps, (1 << 30) - 1);
380 #if FF_API_R_FRAME_RATE
381  st->r_frame_rate = st->avg_frame_rate;
382 #endif
383  }
384 
385 skip:
386  /* skip codec info */
387  size = avio_tell(pb) - codec_pos;
388  avio_skip(pb, codec_data_size - size);
389 
390  return 0;
391 }
392 
393 /** this function assumes that the demuxer has already seeked to the start
394  * of the INDX chunk, and will bail out if not. */
396 {
397  AVIOContext *pb = s->pb;
398  unsigned int size, n_pkts, str_id, next_off, n, pos, pts;
399  AVStream *st;
400 
401  do {
402  if (avio_rl32(pb) != MKTAG('I','N','D','X'))
403  return -1;
404  size = avio_rb32(pb);
405  if (size < 20)
406  return -1;
407  avio_skip(pb, 2);
408  n_pkts = avio_rb32(pb);
409  str_id = avio_rb16(pb);
410  next_off = avio_rb32(pb);
411  for (n = 0; n < s->nb_streams; n++)
412  if (s->streams[n]->id == str_id) {
413  st = s->streams[n];
414  break;
415  }
416  if (n == s->nb_streams) {
417  av_log(s, AV_LOG_ERROR,
418  "Invalid stream index %d for index at pos %"PRId64"\n",
419  str_id, avio_tell(pb));
420  goto skip;
421  } else if ((avio_size(pb) - avio_tell(pb)) / 14 < n_pkts) {
422  av_log(s, AV_LOG_ERROR,
423  "Nr. of packets in packet index for stream index %d "
424  "exceeds filesize (%"PRId64" at %"PRId64" = %"PRId64")\n",
425  str_id, avio_size(pb), avio_tell(pb),
426  (avio_size(pb) - avio_tell(pb)) / 14);
427  goto skip;
428  }
429 
430  for (n = 0; n < n_pkts; n++) {
431  avio_skip(pb, 2);
432  pts = avio_rb32(pb);
433  pos = avio_rb32(pb);
434  avio_skip(pb, 4); /* packet no. */
435 
436  av_add_index_entry(st, pos, pts, 0, 0, AVINDEX_KEYFRAME);
437  }
438 
439 skip:
440  if (next_off && avio_tell(pb) < next_off &&
441  avio_seek(pb, next_off, SEEK_SET) < 0) {
442  av_log(s, AV_LOG_ERROR,
443  "Non-linear index detected, not supported\n");
444  return -1;
445  }
446  } while (next_off);
447 
448  return 0;
449 }
450 
452 {
453  RMDemuxContext *rm = s->priv_data;
454  AVStream *st;
455 
456  rm->old_format = 1;
457  st = avformat_new_stream(s, NULL);
458  if (!st)
459  return -1;
461  return rm_read_audio_stream_info(s, s->pb, st, st->priv_data, 1);
462 }
463 
465 {
466  RMDemuxContext *rm = s->priv_data;
467  AVStream *st;
468  AVIOContext *pb = s->pb;
469  unsigned int tag;
470  int tag_size;
471  unsigned int start_time, duration;
472  unsigned int data_off = 0, indx_off = 0;
473  char buf[128], mime[128];
474  int flags = 0;
475 
476  tag = avio_rl32(pb);
477  if (tag == MKTAG('.', 'r', 'a', 0xfd)) {
478  /* very old .ra format */
479  return rm_read_header_old(s);
480  } else if (tag != MKTAG('.', 'R', 'M', 'F')) {
481  return AVERROR(EIO);
482  }
483 
484  tag_size = avio_rb32(pb);
485  avio_skip(pb, tag_size - 8);
486 
487  for(;;) {
488  if (url_feof(pb))
489  return -1;
490  tag = avio_rl32(pb);
491  tag_size = avio_rb32(pb);
492  avio_rb16(pb);
493  av_dlog(s, "tag=%c%c%c%c (%08x) size=%d\n",
494  (tag ) & 0xff,
495  (tag >> 8) & 0xff,
496  (tag >> 16) & 0xff,
497  (tag >> 24) & 0xff,
498  tag,
499  tag_size);
500  if (tag_size < 10 && tag != MKTAG('D', 'A', 'T', 'A'))
501  return -1;
502  switch(tag) {
503  case MKTAG('P', 'R', 'O', 'P'):
504  /* file header */
505  avio_rb32(pb); /* max bit rate */
506  avio_rb32(pb); /* avg bit rate */
507  avio_rb32(pb); /* max packet size */
508  avio_rb32(pb); /* avg packet size */
509  avio_rb32(pb); /* nb packets */
510  duration = avio_rb32(pb); /* duration */
511  s->duration = av_rescale(duration, AV_TIME_BASE, 1000);
512  avio_rb32(pb); /* preroll */
513  indx_off = avio_rb32(pb); /* index offset */
514  data_off = avio_rb32(pb); /* data offset */
515  avio_rb16(pb); /* nb streams */
516  flags = avio_rb16(pb); /* flags */
517  break;
518  case MKTAG('C', 'O', 'N', 'T'):
519  rm_read_metadata(s, 1);
520  break;
521  case MKTAG('M', 'D', 'P', 'R'):
522  st = avformat_new_stream(s, NULL);
523  if (!st)
524  return AVERROR(ENOMEM);
525  st->id = avio_rb16(pb);
526  avio_rb32(pb); /* max bit rate */
527  st->codec->bit_rate = avio_rb32(pb); /* bit rate */
528  avio_rb32(pb); /* max packet size */
529  avio_rb32(pb); /* avg packet size */
530  start_time = avio_rb32(pb); /* start time */
531  avio_rb32(pb); /* preroll */
532  duration = avio_rb32(pb); /* duration */
533  st->start_time = start_time;
534  st->duration = duration;
535  if(duration>0)
537  get_str8(pb, buf, sizeof(buf)); /* desc */
538  get_str8(pb, mime, sizeof(mime)); /* mimetype */
541  if (ff_rm_read_mdpr_codecdata(s, s->pb, st, st->priv_data,
542  avio_rb32(pb), mime) < 0)
543  return -1;
544  break;
545  case MKTAG('D', 'A', 'T', 'A'):
546  goto header_end;
547  default:
548  /* unknown tag: skip it */
549  avio_skip(pb, tag_size - 10);
550  break;
551  }
552  }
553  header_end:
554  rm->nb_packets = avio_rb32(pb); /* number of packets */
555  if (!rm->nb_packets && (flags & 4))
556  rm->nb_packets = 3600 * 25;
557  avio_rb32(pb); /* next data header */
558 
559  if (!data_off)
560  data_off = avio_tell(pb) - 18;
561  if (indx_off && pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) &&
562  avio_seek(pb, indx_off, SEEK_SET) >= 0) {
563  rm_read_index(s);
564  avio_seek(pb, data_off + 18, SEEK_SET);
565  }
566 
567  return 0;
568 }
569 
570 static int get_num(AVIOContext *pb, int *len)
571 {
572  int n, n1;
573 
574  n = avio_rb16(pb);
575  (*len)-=2;
576  n &= 0x7FFF;
577  if (n >= 0x4000) {
578  return n - 0x4000;
579  } else {
580  n1 = avio_rb16(pb);
581  (*len)-=2;
582  return (n << 16) | n1;
583  }
584 }
585 
586 /* multiple of 20 bytes for ra144 (ugly) */
587 #define RAW_PACKET_SIZE 1000
588 
589 static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){
590  RMDemuxContext *rm = s->priv_data;
591  AVIOContext *pb = s->pb;
592  AVStream *st;
593  uint32_t state=0xFFFFFFFF;
594 
595  while(!url_feof(pb)){
596  int len, num, i;
597  *pos= avio_tell(pb) - 3;
598  if(rm->remaining_len > 0){
599  num= rm->current_stream;
600  len= rm->remaining_len;
601  *timestamp = AV_NOPTS_VALUE;
602  *flags= 0;
603  }else{
604  state= (state<<8) + avio_r8(pb);
605 
606  if(state == MKBETAG('I', 'N', 'D', 'X')){
607  int n_pkts, expected_len;
608  len = avio_rb32(pb);
609  avio_skip(pb, 2);
610  n_pkts = avio_rb32(pb);
611  expected_len = 20 + n_pkts * 14;
612  if (len == 20)
613  /* some files don't add index entries to chunk size... */
614  len = expected_len;
615  else if (len != expected_len)
617  "Index size %d (%d pkts) is wrong, should be %d.\n",
618  len, n_pkts, expected_len);
619  len -= 14; // we already read part of the index header
620  if(len<0)
621  continue;
622  goto skip;
623  } else if (state == MKBETAG('D','A','T','A')) {
625  "DATA tag in middle of chunk, file may be broken.\n");
626  }
627 
628  if(state > (unsigned)0xFFFF || state <= 12)
629  continue;
630  len=state - 12;
631  state= 0xFFFFFFFF;
632 
633  num = avio_rb16(pb);
634  *timestamp = avio_rb32(pb);
635  avio_r8(pb); /* reserved */
636  *flags = avio_r8(pb); /* flags */
637  }
638  for(i=0;i<s->nb_streams;i++) {
639  st = s->streams[i];
640  if (num == st->id)
641  break;
642  }
643  if (i == s->nb_streams) {
644 skip:
645  /* skip packet if unknown number */
646  avio_skip(pb, len);
647  rm->remaining_len = 0;
648  continue;
649  }
650  *stream_index= i;
651 
652  return len;
653  }
654  return -1;
655 }
656 
658  RMDemuxContext *rm, RMStream *vst,
659  AVPacket *pkt, int len, int *pseq,
660  int64_t *timestamp)
661 {
662  int hdr;
663  int seq = 0, pic_num = 0, len2 = 0, pos = 0; //init to silcense compiler warning
664  int type;
665  int ret;
666 
667  hdr = avio_r8(pb); len--;
668  type = hdr >> 6;
669 
670  if(type != 3){ // not frame as a part of packet
671  seq = avio_r8(pb); len--;
672  }
673  if(type != 1){ // not whole frame
674  len2 = get_num(pb, &len);
675  pos = get_num(pb, &len);
676  pic_num = avio_r8(pb); len--;
677  }
678  if(len<0)
679  return -1;
680  rm->remaining_len = len;
681  if(type&1){ // frame, not slice
682  if(type == 3){ // frame as a part of packet
683  len= len2;
684  *timestamp = pos;
685  }
686  if(rm->remaining_len < len)
687  return -1;
688  rm->remaining_len -= len;
689  if(av_new_packet(pkt, len + 9) < 0)
690  return AVERROR(EIO);
691  pkt->data[0] = 0;
692  AV_WL32(pkt->data + 1, 1);
693  AV_WL32(pkt->data + 5, 0);
694  if ((ret = avio_read(pb, pkt->data + 9, len)) != len) {
695  av_free_packet(pkt);
696  return ret < 0 ? ret : AVERROR(EIO);
697  }
698  return 0;
699  }
700  //now we have to deal with single slice
701 
702  *pseq = seq;
703  if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){
704  if (len2 > ffio_limit(pb, len2)) {
705  av_log(s, AV_LOG_ERROR, "Impossibly sized packet\n");
706  return AVERROR_INVALIDDATA;
707  }
708  vst->slices = ((hdr & 0x3F) << 1) + 1;
709  vst->videobufsize = len2 + 8*vst->slices + 1;
710  av_free_packet(&vst->pkt); //FIXME this should be output.
711  if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)
712  return AVERROR(ENOMEM);
713  memset(vst->pkt.data, 0, vst->pkt.size);
714  vst->videobufpos = 8*vst->slices + 1;
715  vst->cur_slice = 0;
716  vst->curpic_num = pic_num;
717  vst->pktpos = avio_tell(pb);
718  }
719  if(type == 2)
720  len = FFMIN(len, pos);
721 
722  if(++vst->cur_slice > vst->slices)
723  return 1;
724  AV_WL32(vst->pkt.data - 7 + 8*vst->cur_slice, 1);
725  AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1);
726  if(vst->videobufpos + len > vst->videobufsize)
727  return 1;
728  if (avio_read(pb, vst->pkt.data + vst->videobufpos, len) != len)
729  return AVERROR(EIO);
730  vst->videobufpos += len;
731  rm->remaining_len-= len;
732 
733  if (type == 2 || vst->videobufpos == vst->videobufsize) {
734  vst->pkt.data[0] = vst->cur_slice-1;
735  *pkt= vst->pkt;
736  vst->pkt.data= NULL;
737  vst->pkt.size= 0;
738  vst->pkt.buf = NULL;
739 #if FF_API_DESTRUCT_PACKET
740  vst->pkt.destruct = NULL;
741 #endif
742  if(vst->slices != vst->cur_slice) //FIXME find out how to set slices correct from the begin
743  memmove(pkt->data + 1 + 8*vst->cur_slice, pkt->data + 1 + 8*vst->slices,
744  vst->videobufpos - 1 - 8*vst->slices);
745  pkt->size = vst->videobufpos + 8*(vst->cur_slice - vst->slices);
746  pkt->pts = AV_NOPTS_VALUE;
747  pkt->pos = vst->pktpos;
748  vst->slices = 0;
749  return 0;
750  }
751 
752  return 1;
753 }
754 
755 static inline void
757 {
758  uint8_t *ptr;
759  int j;
760 
761  if (st->codec->codec_id == AV_CODEC_ID_AC3) {
762  ptr = pkt->data;
763  for (j=0;j<pkt->size;j+=2) {
764  FFSWAP(int, ptr[0], ptr[1]);
765  ptr += 2;
766  }
767  }
768 }
769 
770 int
772  AVStream *st, RMStream *ast, int len, AVPacket *pkt,
773  int *seq, int flags, int64_t timestamp)
774 {
775  RMDemuxContext *rm = s->priv_data;
776 
777  if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
778  rm->current_stream= st->id;
779  if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len, seq, &timestamp))
780  return -1; //got partial frame
781  } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
782  if ((ast->deint_id == DEINT_ID_GENR) ||
783  (ast->deint_id == DEINT_ID_INT4) ||
784  (ast->deint_id == DEINT_ID_SIPR)) {
785  int x;
786  int sps = ast->sub_packet_size;
787  int cfs = ast->coded_framesize;
788  int h = ast->sub_packet_h;
789  int y = ast->sub_packet_cnt;
790  int w = ast->audio_framesize;
791 
792  if (flags & 2)
793  y = ast->sub_packet_cnt = 0;
794  if (!y)
795  ast->audiotimestamp = timestamp;
796 
797  switch (ast->deint_id) {
798  case DEINT_ID_INT4:
799  for (x = 0; x < h/2; x++)
800  avio_read(pb, ast->pkt.data+x*2*w+y*cfs, cfs);
801  break;
802  case DEINT_ID_GENR:
803  for (x = 0; x < w/sps; x++)
804  avio_read(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
805  break;
806  case DEINT_ID_SIPR:
807  avio_read(pb, ast->pkt.data + y * w, w);
808  break;
809  }
810 
811  if (++(ast->sub_packet_cnt) < h)
812  return -1;
813  if (ast->deint_id == DEINT_ID_SIPR)
814  ff_rm_reorder_sipr_data(ast->pkt.data, h, w);
815 
816  ast->sub_packet_cnt = 0;
817  rm->audio_stream_num = st->index;
818  rm->audio_pkt_cnt = h * w / st->codec->block_align;
819  } else if ((ast->deint_id == DEINT_ID_VBRF) ||
820  (ast->deint_id == DEINT_ID_VBRS)) {
821  int x;
822  rm->audio_stream_num = st->index;
823  ast->sub_packet_cnt = (avio_rb16(pb) & 0xf0) >> 4;
824  if (ast->sub_packet_cnt) {
825  for (x = 0; x < ast->sub_packet_cnt; x++)
826  ast->sub_packet_lengths[x] = avio_rb16(pb);
827  rm->audio_pkt_cnt = ast->sub_packet_cnt;
828  ast->audiotimestamp = timestamp;
829  } else
830  return -1;
831  } else {
832  av_get_packet(pb, pkt, len);
833  rm_ac3_swap_bytes(st, pkt);
834  }
835  } else
836  av_get_packet(pb, pkt, len);
837 
838  pkt->stream_index = st->index;
839 
840 #if 0
841  if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
842  if(st->codec->codec_id == AV_CODEC_ID_RV20){
843  int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
844  av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq);
845 
846  seq |= (timestamp&~0x3FFF);
847  if(seq - timestamp > 0x2000) seq -= 0x4000;
848  if(seq - timestamp < -0x2000) seq += 0x4000;
849  }
850  }
851 #endif
852 
853  pkt->pts = timestamp;
854  if (flags & 2)
855  pkt->flags |= AV_PKT_FLAG_KEY;
856 
857  return st->codec->codec_type == AVMEDIA_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
858 }
859 
860 int
862  AVStream *st, RMStream *ast, AVPacket *pkt)
863 {
864  RMDemuxContext *rm = s->priv_data;
865 
866  av_assert0 (rm->audio_pkt_cnt > 0);
867 
868  if (ast->deint_id == DEINT_ID_VBRF ||
869  ast->deint_id == DEINT_ID_VBRS)
871  else {
872  if(av_new_packet(pkt, st->codec->block_align) < 0)
873  return AVERROR(ENOMEM);
874  memcpy(pkt->data, ast->pkt.data + st->codec->block_align * //FIXME avoid this
875  (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
876  st->codec->block_align);
877  }
878  rm->audio_pkt_cnt--;
879  if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) {
881  pkt->flags = AV_PKT_FLAG_KEY;
882  } else
883  pkt->flags = 0;
884  pkt->stream_index = st->index;
885 
886  return rm->audio_pkt_cnt;
887 }
888 
890 {
891  RMDemuxContext *rm = s->priv_data;
892  AVStream *st = NULL; // init to silence compiler warning
893  int i, len, res, seq = 1;
894  int64_t timestamp, pos;
895  int flags;
896 
897  for (;;) {
898  if (rm->audio_pkt_cnt) {
899  // If there are queued audio packet return them first
900  st = s->streams[rm->audio_stream_num];
901  res = ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);
902  if(res < 0)
903  return res;
904  flags = 0;
905  } else {
906  if (rm->old_format) {
907  RMStream *ast;
908 
909  st = s->streams[0];
910  ast = st->priv_data;
911  timestamp = AV_NOPTS_VALUE;
912  len = !ast->audio_framesize ? RAW_PACKET_SIZE :
913  ast->coded_framesize * ast->sub_packet_h / 2;
914  flags = (seq++ == 1) ? 2 : 0;
915  pos = avio_tell(s->pb);
916  } else {
917  len=sync(s, &timestamp, &flags, &i, &pos);
918  if (len > 0)
919  st = s->streams[i];
920  }
921 
922  if(len<0 || url_feof(s->pb))
923  return AVERROR(EIO);
924 
925  res = ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt,
926  &seq, flags, timestamp);
927  if((flags&2) && (seq&0x7F) == 1)
928  av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
929  if (res)
930  continue;
931  }
932 
933  if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))
934  || st->discard >= AVDISCARD_ALL){
935  av_free_packet(pkt);
936  } else
937  break;
938  }
939 
940  return 0;
941 }
942 
944 {
945  int i;
946 
947  for (i=0;i<s->nb_streams;i++)
949 
950  return 0;
951 }
952 
953 static int rm_probe(AVProbeData *p)
954 {
955  /* check file header */
956  if ((p->buf[0] == '.' && p->buf[1] == 'R' &&
957  p->buf[2] == 'M' && p->buf[3] == 'F' &&
958  p->buf[4] == 0 && p->buf[5] == 0) ||
959  (p->buf[0] == '.' && p->buf[1] == 'r' &&
960  p->buf[2] == 'a' && p->buf[3] == 0xfd))
961  return AVPROBE_SCORE_MAX;
962  else
963  return 0;
964 }
965 
966 static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
967  int64_t *ppos, int64_t pos_limit)
968 {
969  RMDemuxContext *rm = s->priv_data;
970  int64_t pos, dts;
971  int stream_index2, flags, len, h;
972 
973  pos = *ppos;
974 
975  if(rm->old_format)
976  return AV_NOPTS_VALUE;
977 
978  if (avio_seek(s->pb, pos, SEEK_SET) < 0)
979  return AV_NOPTS_VALUE;
980 
981  rm->remaining_len=0;
982  for(;;){
983  int seq=1;
984  AVStream *st;
985 
986  len=sync(s, &dts, &flags, &stream_index2, &pos);
987  if(len<0)
988  return AV_NOPTS_VALUE;
989 
990  st = s->streams[stream_index2];
991  if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
992  h= avio_r8(s->pb); len--;
993  if(!(h & 0x40)){
994  seq = avio_r8(s->pb); len--;
995  }
996  }
997 
998  if((flags&2) && (seq&0x7F) == 1){
999  av_dlog(s, "%d %d-%d %"PRId64" %d\n",
1000  flags, stream_index2, stream_index, dts, seq);
1001  av_add_index_entry(st, pos, dts, 0, 0, AVINDEX_KEYFRAME);
1002  if(stream_index2 == stream_index)
1003  break;
1004  }
1005 
1006  avio_skip(s->pb, len);
1007  }
1008  *ppos = pos;
1009  return dts;
1010 }
1011 
1012 static int rm_read_seek(AVFormatContext *s, int stream_index,
1013  int64_t pts, int flags)
1014 {
1015  RMDemuxContext *rm = s->priv_data;
1016 
1017  if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)
1018  return -1;
1019  rm->audio_pkt_cnt = 0;
1020  return 0;
1021 }
1022 
1023 
1025  .name = "rm",
1026  .long_name = NULL_IF_CONFIG_SMALL("RealMedia"),
1027  .priv_data_size = sizeof(RMDemuxContext),
1028  .read_probe = rm_probe,
1032  .read_timestamp = rm_read_dts,
1034 };
1035 
1037  .name = "rdt",
1038  .long_name = NULL_IF_CONFIG_SMALL("RDT demuxer"),
1039  .priv_data_size = sizeof(RMDemuxContext),
1041  .flags = AVFMT_NOFILE,
1042 };
const char * name
Definition: avisynth_c.h:675
static int get_num(AVIOContext *pb, int *len)
Definition: rmdec.c:570
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:205
full parsing and interpolation of timestamps for frames not starting on a packet boundary ...
Definition: avformat.h:584
#define RAW_PACKET_SIZE
Definition: rmdec.c:587
int remaining_len
Definition: rmdec.c:60
discard all frames except keyframes
float v
const char * s
Definition: avisynth_c.h:668
Bytestream IO Context.
Definition: avio.h:68
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:261
void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:242
#define DEINT_ID_INT0
no interleaving needed
Definition: rmdec.c:34
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
static void get_strl(AVIOContext *pb, char *buf, int buf_size, int len)
Definition: rmdec.c:65
enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
static int64_t rm_read_dts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
Definition: rmdec.c:966
const unsigned char ff_sipr_subpk_size[4]
Definition: rmsipr.c:25
int64_t pos
byte position in stream, -1 if unknown
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:154
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
int num
numerator
Definition: rational.h:44
int index
stream index in AVFormatContext
Definition: avformat.h:644
Definition: rmdec.c:40
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:199
int cur_slice
Definition: rmdec.c:45
void * priv_data
Definition: avformat.h:663
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:256
#define FF_ARRAY_ELEMS(a)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
int version
Definition: avisynth_c.h:666
static int rm_read_header(AVFormatContext *s)
Definition: rmdec.c:464
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:595
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
output residual component w
#define DEINT_ID_VBRS
VBR case for AAC.
Definition: rmdec.c:38
int videobufpos
position for the next slice in the video buffer
Definition: rmdec.c:43
Format I/O context.
Definition: avformat.h:944
int audio_stream_num
Stream number for audio packets.
Definition: rmdec.c:61
#define AV_WL32(p, darg)
Definition: intreadwrite.h:282
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
#define AVFMT_FLAG_IGNIDX
Ignore index.
Definition: avformat.h:1023
Public dictionary API.
int ffio_limit(AVIOContext *s, int size)
static int64_t start_time
Definition: ffplay.c:293
uint8_t
Opaque data information usually continuous.
Definition: avutil.h:145
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:610
int id
Format-specific stream ID.
Definition: avformat.h:650
enum AVStreamParseType need_parsing
Definition: avformat.h:811
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
Definition: avformat.h:992
uint8_t * data
uint32_t tag
Definition: movenc.c:894
int curpic_num
picture number of current frame
Definition: rmdec.c:44
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
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.
static int rm_read_index(AVFormatContext *s)
this function assumes that the demuxer has already seeked to the start of the INDX chunk...
Definition: rmdec.c:395
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:248
#define DEINT_ID_GENR
interleaving for Cooker/Atrac
Definition: rmdec.c:33
static int64_t duration
Definition: ffplay.c:294
static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, RMDemuxContext *rm, RMStream *vst, AVPacket *pkt, int len, int *pseq, int64_t *timestamp)
Definition: rmdec.c:657
static void get_str8(AVIOContext *pb, char *buf, int buf_size)
Definition: rmdec.c:79
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:478
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Discrete Time axis x
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:73
#define AVINDEX_KEYFRAME
Definition: avformat.h:599
AVDictionary * metadata
Definition: avformat.h:1092
static int rm_read_close(AVFormatContext *s)
Definition: rmdec.c:943
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:579
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * r
Definition: vf_curves.c:94
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
simple assert() macros that are a bit more flexible than ISO C assert().
#define DEINT_ID_VBRF
VBR case for AAC.
Definition: rmdec.c:37
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
int64_t pktpos
first slice position in file
Definition: rmdec.c:46
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:716
RMStream * ff_rm_alloc_rmstream(void)
Definition: rmdec.c:109
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:82
int size
int flags
A combination of AV_PKT_FLAG values.
uint64_t channel_layout
Audio channel layout.
Only parse headers, do not repack.
Definition: avformat.h:583
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:469
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:662
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:36
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:336
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
unsigned int nb_streams
A list of all streams in the file.
Definition: avformat.h:991
AVPacket pkt
place to store merged video frame / reordered audio data
Definition: rmdec.c:41
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:117
int bit_rate
the average bitrate
audio channel layout utility functions
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:118
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:196
#define FFMIN(a, b)
Definition: common.h:58
void ff_free_stream(AVFormatContext *s, AVStream *st)
static int read_probe(AVProbeData *pd)
ret
Definition: avfilter.c:821
int width
picture width / height.
AVInputFormat ff_rm_demuxer
Definition: rmdec.c:1024
int32_t
#define DEINT_ID_INT4
interleaving for 28.8
Definition: rmdec.c:35
static void rm_read_metadata(AVFormatContext *s, int wide)
Definition: rmdec.c:98
#define AV_RL32
static int rm_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
Definition: rmdec.c:1012
int url_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
Definition: aviobuf.c:280
int sub_packet_cnt
Definition: rmdec.c:49
int coded_framesize
Descrambling parameters from container.
Definition: rmdec.c:50
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:517
int audio_framesize
Definition: rmdec.c:51
Stream structure.
Definition: avformat.h:643
static void rm_ac3_swap_bytes(AVStream *st, AVPacket *pkt)
Definition: rmdec.c:756
const AVCodecTag ff_rm_codec_tags[]
Definition: rm.c:31
NULL
Definition: eval.c:55
int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *rst, int codec_data_size, const uint8_t *mime)
Read the MDPR chunk, which contains stream-specific codec initialization parameters.
Definition: rmdec.c:303
enum AVMediaType codec_type
enum AVCodecID codec_id
#define DEINT_ID_SIPR
interleaving for Sipro
Definition: rmdec.c:36
int sample_rate
samples per second
AVIOContext * pb
I/O context.
Definition: avformat.h:977
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> (&#39;D&#39;<<24) + (&#39;C&#39;<<16) + (&#39;B&#39;<<8) + &#39;A&#39;).
static int rm_probe(AVProbeData *p)
Definition: rmdec.c:953
void * buf
Definition: avisynth_c.h:594
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
Definition: libcdio.c:114
int ff_rm_parse_packet(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, int len, AVPacket *pkt, int *seq, int flags, int64_t timestamp)
Parse one rm-stream packet from the input bytestream.
Definition: rmdec.c:771
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:62
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:73
synthesis window for stochastic i
int current_stream
Definition: rmdec.c:59
int old_format
Definition: rmdec.c:58
This structure contains the data a format has to probe a file.
Definition: avformat.h:334
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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.Buffer references ownership and permissions
#define type
int audio_pkt_cnt
Output packet counter.
Definition: rmdec.c:62
int nb_packets
Definition: rmdec.c:57
static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos)
Definition: rmdec.c:589
static uint32_t state
Definition: trasher.c:27
const char *const ff_rm_metadata[4]
Definition: rm.c:24
AVInputFormat ff_rdt_demuxer
Definition: rmdec.c:1036
static int flags
Definition: cpu.c:23
void ff_rm_free_rmstream(RMStream *rms)
Definition: rmdec.c:116
int sub_packet_h
Definition: rmdec.c:50
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:696
#define AVPROBE_SCORE_MAX
maximum score, half of that is used for file-extension-based detection
Definition: avformat.h:340
full parsing and repack
Definition: avformat.h:582
void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize)
Perform 4-bit block reordering for SIPR data.
Definition: rmsipr.c:41
Main libavformat public API header.
int32_t deint_id
Length of each subpacket.
Definition: rmdec.c:53
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:162
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:345
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
Definition: avformat.h:689
int ff_rm_retrieve_cache(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, AVPacket *pkt)
Retrieve one cached packet from the rm-context.
Definition: rmdec.c:861
int den
denominator
Definition: rational.h:45
function y
Definition: D.m:1
static int rm_read_header_old(AVFormatContext *s)
Definition: rmdec.c:451
#define MKBETAG(a, b, c, d)
Definition: common.h:283
int slices
Definition: rmdec.c:45
int len
int channels
number of audio channels
static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: rmdec.c:889
static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, int read_all)
Definition: rmdec.c:121
void * priv_data
Format private data.
Definition: avformat.h:964
static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned size)
Definition: rmdec.c:84
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1009
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:461
int64_t audiotimestamp
Audio descrambling matrix parameters.
Definition: rmdec.c:48
#define FFSWAP(type, a, b)
Definition: common.h:61
int videobufsize
current assembled frame size
Definition: rmdec.c:42
#define AV_CH_LAYOUT_MONO
#define MKTAG(a, b, c, d)
Definition: common.h:282
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:702
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:738
int sub_packet_lengths[16]
Audio frame size from container.
Definition: rmdec.c:52
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:190
int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
Perform a binary search using av_index_search_timestamp() and AVInputFormat.read_timestamp().
int sub_packet_size
Definition: rmdec.c:50