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