MythTV  master
avi.cpp
Go to the documentation of this file.
1 /*
2  * avi.c: AVI container functions for replex
3  *
4  *
5  * Copyright (C) 2003 Marcus Metzler <mocm@metzlerbros.de>
6  * Metzler Brothers Systementwicklung GbR
7  * Changes to use MythTV logging
8  * Copyright (C) 2011 Gavin Hurlbut <ghurlbut@mythtv.org>
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * General Public License for more details.
20  *
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
26  *
27  */
28 
29 #include <stdlib.h>
30 #include <string.h>
31 
32 #include "mpg_common.h"
33 #include "avi.h"
34 #include "replex.h"
35 #include "pes.h"
36 
37 
38 #define DEBUG 1
39 
40 #ifdef DEBUG
41 #include "mpg_common.h"
42 #endif
43 
44 #include "mythlogging.h"
45 
46 static uint32_t getle32(uint8_t *buf)
47 {
48  return (buf[3]<<24)|(buf[2]<<16)|(buf[1]<<8)|buf[0];
49 }
50 
51 #if 0
52 static uint32_t getbe32(uint8_t *buf)
53 {
54  return (buf[0]<<24)|(buf[1]<<16)|(buf[2]<<8)|buf[3];
55 }
56 
57 static void printhead(uint8_t *buf)
58 {
59  LOG(VB_GENERAL, LOG_INFO, QString("%1%2%3%4 ")
60  .arg(buf[0]).arg(buf[1]).arg(buf[2]).arg(buf[3]));
61 }
62 #endif
63 
64 static uint32_t getsize(int fd)
65 {
66  uint8_t buf[4];
67 
68  int len=read(fd, buf, 4);
69  (void)len;
70  return getle32(buf);
71 }
72 
73 static uint32_t getsize_buf(uint8_t *buf)
74 {
75  return getle32(buf);
76 }
77 
78 
79 int check_riff(avi_context *ac, uint8_t *buf, int len)
80 {
81  uint32_t tag;
82  int c = 0;
83 
84  if (len < 12) return -1;
85  tag = getle32(buf);
86  if (tag != TAG_IT('R','I','F','F')) return -1;
87  c+=4;
88 
89  ac->riff_end = getle32(buf+c);
90  c+=4;
91 
92  tag = getle32(buf+c);
93  if (tag != TAG_IT('A','V','I',' ') &&
94  tag != TAG_IT('A','V','I','X') ) return -1;
95 
96  return c+4;
97 }
98 
99 static
100 int new_idx_frame( avi_context *ac, uint32_t pos, uint32_t len,
101  uint32_t fl, uint32_t id)
102 {
103  uint32_t num = ac->num_idx_frames;
104  if (ac->num_idx_alloc < num+1){
105  avi_index *idx;
106  uint32_t newnum = num + 1024;
107 
108  if (ac->idx){
109  idx = static_cast<avi_index*>(realloc(ac->idx,
110  newnum*sizeof(avi_index)));
111  } else {
112  idx = static_cast<avi_index*>(malloc(newnum*sizeof(avi_index)));
113  }
114  if (!idx) return -1;
115  ac->idx = idx;
116  ac->num_idx_alloc = newnum;
117  }
118  ac->idx[num].off = pos;
119  ac->idx[num].id = id;
120  ac->idx[num].len = len;
121  ac->idx[num].flags = fl;
122  ac->num_idx_frames++;
123 
124 
125 
126  return 0;
127 }
128 
129 static void print_index(avi_context *ac, int num){
130  char *cc;
131  cc = (char *) &ac->idx[num].id;
132  LOG(VB_GENERAL, LOG_DEBUG,
133  QString("%1 chunkid: %2%3%4%5 chunkoff: 0x%6 chunksize: 0x%7 "
134  " chunkflags: 0x%8")
135  .arg(num)
136  .arg(*cc).arg(*(cc+1)).arg(*(cc+2)).arg(*(cc+3))
137  .arg(ac->idx[num].off, 4,16,QChar('0'))
138  .arg(ac->idx[num].len, 4,16,QChar('0'))
139  .arg(ac->idx[num].flags, 4,16,QChar('0')));
140 }
141 
142 int avi_read_index(avi_context *ac, int fd)
143 {
144  uint32_t tag;
145  uint32_t isize;
146  uint32_t c;
147  off_t start;
148  uint8_t buf[16];
149  char *cc;
150 
151  if (!(ac->avih_flags & AVI_HASINDEX)) return -2;
152  LOG(VB_GENERAL, LOG_INFO, "READING INDEX");
153  if ((start = lseek(fd, 0, SEEK_CUR)) < 0) return -3;
154  if (lseek(fd, ac->movi_length+ac->movi_start+4, SEEK_SET) < 0) return -4;
155 
156  read(fd,buf,4);
157  tag = getle32(buf);
158 
159  if (tag != TAG_IT('i','d','x','1')){
160  cc = (char *) &tag;
161  LOG(VB_GENERAL, LOG_INFO, QString(" tag: %1%2%3%4\n ")
162  .arg(*cc).arg(*(cc+1)).arg(*(cc+2)).arg(*(cc+3)));
163 
164  if (lseek(fd, start, SEEK_SET) < 0 ) return -5;
165  return -1;
166  }
167  isize = getsize(fd);
168  c = 0;
169 
170  while ( c < isize ){
171  uint32_t chunkid;
172  uint32_t chunkflags;
173  uint32_t chunkoff;
174  uint32_t chunksize;
175 
176  read(fd,buf,16);
177  chunkid = getle32(buf);
178  chunkflags = getle32(buf+4);
179  chunkoff = getle32(buf+8);
180  chunksize = getle32(buf+12);
181 
182  new_idx_frame(ac, chunkoff, chunksize, chunkflags,chunkid);
183  switch(chunkid){
184  case TAG_IT('0','1','w','b'):
185  ac->achunks++;
186  if (!chunksize) ac->zero_achunks++;
187  break;
188 
189  case TAG_IT('0','0','d','c'):
190  ac->vchunks++;
191  if (!chunksize) ac->zero_vchunks++;
192  break;
193  }
194 
195 #ifdef DEBUG
196 /*
197  print_index(ac,ac->num_idx_frames-1);
198 */
199 #endif
200  c+=16;
201  }
202 #ifdef DEBUG
203  LOG(VB_GENERAL, LOG_DEBUG,
204  QString("Found %1 video (%2 were empty) and %3 "
205  "audio (%4 were empty) chunks")
206  .arg(ac->vchunks).arg(ac->zero_vchunks)
207  .arg(ac->achunks).arg(ac->zero_achunks));
208 #endif
209  lseek(fd, start, SEEK_SET);
210 
211  return 0;
212 }
213 
214 
215 int read_avi_header( avi_context *ac, int fd)
216 {
217  uint8_t buf[256];
218  uint32_t tag;
219  uint32_t size = 0;
220  int c = 0;
221  int skip=0;
222  int n;
223 #ifdef DEBUG
224  char *cc;
225 #endif
226 
227  while ((c=read(fd, buf, 4))==4) {
228  skip=0;
229  tag = getle32(buf);
230 
231 #ifdef DEBUG
232  cc = (char *) &tag;
233  LOG(VB_GENERAL, LOG_DEBUG, QString("tag: %1%2%3%4")
234  .arg(*cc).arg(*(cc+1)).arg(*(cc+2)).arg(*(cc+3)));
235 #endif
236  switch(tag){
237  case TAG_IT('L','I','S','T'):
238  size = getsize(fd);
239  break;
240 
241 
242  case TAG_IT('m','o','v','i'):
243  ac->done=1;
244  ac->movi_start = lseek(fd, 0, SEEK_CUR);
245  ac->movi_length = size-8;
246 #ifdef DEBUG
247  LOG(VB_GENERAL, LOG_DEBUG,
248  QString(" size: %1 header done").arg(size));
249 #endif
250  return 0;
251  break;
252 
253  case TAG_IT('h','d','r','l'):
254  break;
255 
256 
257  case TAG_IT('s','t','r','l'):
258  break;
259 
260  case TAG_IT('J','U','N','K'):
261  case TAG_IT('s','t','r','f'):
262  case TAG_IT('s','t','r','d'):
263  case TAG_IT('s','t','r','n'):
264  size = getsize(fd);
265  skip=1;
266  break;
267  case TAG_IT('a','v','i','h'):
268  size = getsize(fd);
269  c=0;
270  read(fd,buf,size);
271  ac->msec_per_frame = getle32(buf+c);
272  c+=12;
273  ac->avih_flags = getle32(buf+c);
274  c+=4;
275  ac->total_frames = getle32(buf+c);
276  c+=4;
277  ac->init_frames = getle32(buf+c);
278  c+=4;
279  ac->nstreams = getle32(buf+c);
280  c+=8;
281  ac->width = getle32(buf+c);
282  c+=4;
283  ac->height = getle32(buf+c);
284  c+=4;
285 
286 
287 #ifdef DEBUG
288  LOG(VB_GENERAL, LOG_DEBUG,
289  QString(" size: %1").arg(size));
290  LOG(VB_GENERAL, LOG_DEBUG,
291  QString(" microsecs per frame %1")
292  .arg(ac->msec_per_frame));
293  if (ac->avih_flags & AVI_HASINDEX)
294  LOG(VB_GENERAL, LOG_DEBUG, " AVI has index");
295  if (ac->avih_flags & AVI_USEINDEX)
296  LOG(VB_GENERAL, LOG_DEBUG,
297  " AVI must use index");
298  if (ac->avih_flags & AVI_INTERLEAVED)
299  LOG(VB_GENERAL, LOG_DEBUG,
300  " AVI is interleaved");
301  if(ac->total_frames)
302  LOG(VB_GENERAL, LOG_DEBUG,
303  QString(" total frames: %1")
304  .arg(ac->total_frames));
305 
306  LOG(VB_GENERAL, LOG_DEBUG,
307  QString(" number of streams: %1")
308  .arg(ac->nstreams));
309  LOG(VB_GENERAL, LOG_DEBUG, QString(" size: %1x%2")
310  .arg(ac->width).arg(ac->height));
311 #endif
312  break;
313 
314  case TAG_IT('s','t','r','h'):
315  size = getsize(fd);
316 #ifdef DEBUG
317  LOG(VB_GENERAL, LOG_DEBUG,
318  QString(" size: %1").arg(size));
319 #endif
320 
321  c=0;
322  read(fd,buf,size);
323  tag = getle32(buf);
324  c+=16;
325 #ifdef DEBUG
326  cc = (char *) &tag;
327  LOG(VB_GENERAL, LOG_DEBUG, QString(" tag: %1%2%3%4")
328  .arg(*cc).arg(*(cc+1)).arg(*(cc+2)).arg((cc+3)));
329 #endif
330  switch ( tag ){
331  case TAG_IT('v','i','d','s'):
332  ac->vhandler = getle32(buf+4);
333 #ifdef DEBUG
334  if (ac->vhandler){
335  cc = (char *) &ac->vhandler;
336  LOG(VB_GENERAL, LOG_DEBUG,
337  QString(" video handler: %1%2%3%4")
338  .arg(*cc).arg(*(cc+1)).arg(*(cc+2)).arg(*(cc+3)));
339  }
340 #endif
341  ac->vi.initial_frames = getle32(buf+c);
342  c+=4;
343  ac->vi.dw_scale = getle32(buf+c);
344  c+=4;
345  ac->vi.dw_rate = getle32(buf+c);
346  c+=4;
347  ac->vi.dw_start = getle32(buf+c);
348  c+=4;
349  if (ac->vi.dw_scale)
350  ac->vi.fps = (ac->vi.dw_rate*1000)/
351  ac->vi.dw_scale;
352 
353  LOG(VB_GENERAL, LOG_INFO,
354  QString("AVI video info: dw_scale %1 dw_rate %2 "
355  "fps %3 ini_frames %4 dw_start %5")
356  .arg(ac->vi.dw_scale).arg(ac->vi.dw_rate)
357  .arg(ac->vi.fps/1000.0, 0,'f',3,QChar('0'))
358  .arg(ac->vi.initial_frames)
359  .arg(ac->vi.dw_start));
360  break;
361  case TAG_IT('a','u','d','s'):
362  ac->ahandler = getle32(buf+4);
363 #ifdef DEBUG
364  if (ac->ahandler){
365  cc = (char *) &ac->ahandler;
366  LOG(VB_GENERAL, LOG_DEBUG,
367  QString(" audio handler: %1%2%3%4")
368  .arg(*cc).arg(*(cc+1)).arg(*(cc+2)).arg((cc+3)));
369 
370  }
371 #endif
372 
373  if (ac->ntracks == MAX_TRACK) break;
374  n = ac->ntracks;
375  ac->ai[n].initial_frames = getle32(buf+c);
376  c+=4;
377  ac->ai[n].dw_scale = getle32(buf+c);
378  c+=4;
379  ac->ai[n].dw_rate = getle32(buf+c);
380  c+=4;
381  ac->ai[n].dw_start = getle32(buf+c);
382  c+=16;
383  ac->ai[n].dw_ssize = getle32(buf+c);
384  if (ac->ai[n].dw_scale)
385  ac->ai[n].fps =
386  (ac->ai[n].dw_rate*1000)/
387  ac->ai[n].dw_scale;
388 
389  LOG(VB_GENERAL, LOG_INFO,
390  QString("AVI audio%1 info: dw_scale %2 dw_rate "
391  "%3 ini_frames %4 dw_start %5 fps %6 "
392  " sam_size %7").arg(n)
393  .arg(ac->ai[n].dw_scale).arg(ac->ai[n].dw_rate)
394  .arg(ac->ai[n].initial_frames)
395  .arg(ac->ai[n].dw_start)
396  .arg(ac->ai[n].fps/1000.0, 0,'f',3,QChar('0'))
397  .arg(ac->ai[n].dw_ssize));
398 
399  ac->ntracks++;
400  break;
401  }
402  break;
403 
404  case TAG_IT('I','N','F','O'):
405  size -=4;
406  skip =1;
407 #ifdef DEBUG
408  LOG(VB_GENERAL, LOG_DEBUG, QString(" size: %1").arg(size));
409 #endif
410  break;
411 
412  }
413 
414  if (skip){
415  lseek(fd, size, SEEK_CUR);
416  size = 0;
417  }
418 
419  }
420 
421  return -1;
422 }
423 
424 
425 #define MAX_BUF_SIZE 0xffff
427  void (*func)(pes_in_t *p), uint32_t insize)
428 {
429  struct replex *rx= (struct replex *) p->priv;
430  avi_index *idx = ac->idx;
431  uint32_t cidx = ac->current_idx;
432  uint8_t buf[MAX_BUF_SIZE];
433  uint32_t cid;
434  int c=0;
435  off_t pos=0;
436  int per = 0;
437  static int lastper=0;
438 
439  if (cidx > ac->num_idx_frames) return -2;
440 
441  switch(idx[cidx].id){
442  case TAG_IT('0','1','w','b'):
443  p->type = 1;
444  p->rbuf = &rx->arbuffer[0];
445  break;
446 
447  case TAG_IT('0','0','d','c'):
448  p->type = 0xE0;
449  p->rbuf = &rx->vrbuffer;
450  break;
451 
452  default:
453  LOG(VB_GENERAL, LOG_ERR, "strange chunk :");
454  show_buf((uint8_t *) &idx[cidx].id,4);
455  LOG(VB_GENERAL, LOG_ERR, QString("offset: 0x%1 length: 0x%2")
456  .arg(idx[cidx].off, 4,16,QChar('0'))
457  .arg(idx[cidx].len, 4,16,QChar('0')));
458  ac->current_idx++;
459  p->found=0;
460  return 0;
461  break;
462  }
463 
464  memset(buf, 0, MAX_BUF_SIZE);
465  pos=lseek (fd, idx[cidx].off+ac->movi_start-4, SEEK_SET);
466  read(fd,buf,idx[cidx].len);
467  cid = getle32(buf);
468  c+=4;
469  p->plength = getsize_buf(buf+c);
470 // show_buf(buf,16);
471  if (idx[cidx].len > insize) return 0;
472 
473  if (idx[cidx].len > MAX_BUF_SIZE){
474  LOG(VB_GENERAL, LOG_ERR,
475  "Buffer too small in get_avi_from_index");
476  exit(1);
477  }
478  if (!idx[cidx].len){
479  func(p);
480  ac->current_idx++;
481  p->found=0;
482  return 0;
483  }
484  if (cid != idx[cidx].id){
485  char *cc;
486  cc = (char *)&idx[cidx].id;
487  LOG(VB_GENERAL, LOG_ERR,
488  QString("wrong chunk id: %1%2%3%4 != %5%6%7%8")
489  .arg(buf[0]).arg(buf[1]).arg(buf[2]).arg(buf[3])
490  .arg(*cc).arg(*(cc+1)).arg(*(cc+2)).arg(*(cc+3)));
491 
492  print_index(ac,cidx);
493  exit(1);
494  }
495  if (p->plength != idx[cidx].len){
496  LOG(VB_GENERAL, LOG_ERR, QString("wrong chunk size: %1 != %2")
497  .arg(p->plength).arg(idx[cidx].len));
498  exit(1);
499  }
500  c+=4;
501  p->done = 1;
502  p->ini_pos = ring_wpos(p->rbuf);
503 
504  per = (int)(100*(pos-ac->movi_start)/ac->movi_length);
505  if (per % 10 == 0 && per>lastper)
506  LOG(VB_GENERAL, LOG_INFO, QString("read %1%%").arg(per,3));
507  lastper = per;
508 
509  if (ring_write(p->rbuf, buf+c, p->plength)<0){
510  LOG(VB_GENERAL, LOG_ERR,
511  QString("ring buffer overflow %1 0x%2")
512  .arg(p->rbuf->size).arg(p->type, 2,16,QChar('0')));
513  exit(1);
514  }
515 
516  func(p);
517  init_pes_in(p, 0, nullptr, p->withbuf);
518 
519  ac->current_idx++;
520 
521  return 0;
522 }
523 
524 
525 void get_avi(pes_in_t *p, uint8_t *buf, int count, void (*func)(pes_in_t *p))
526 {
527  int l;
528  int c=0;
529  struct replex *rx= (struct replex *) p->priv;
530 
531 
532 // show_buf(buf,16);
533  while (c < count && p->found < 8
534  && !p->done){
535  switch ( p->found ){
536  case 0:
537  if (buf[c] == '0') p->found++;
538  else p->found = 0;
539  c++;
540  break;
541  case 1:
542  if (buf[c] == '0'|| buf[c] == '1'){
543  p->found++;
544  p->which = buf[c] - '0';
545  } else if (buf[c] == '0'){
546  p->found = 1;
547  } else p->found = 0;
548  c++;
549  break;
550  case 2:
551  switch(buf[c]){
552  case 'w':
553  case 'd':
554  p->found++;
555  p->type=buf[c];
556  break;
557  default:
558  p->found = 0;
559  break;
560  }
561  c++;
562  break;
563 
564  case 3:
565  switch(buf[c]){
566  case 'b':
567  if (p->type == 'w'){
568  p->found++;
569  p->type = 1;
570  } else p->found = 0;
571  break;
572  case 'c':
573  if (p->type == 'd'){
574  p->found++;
575  p->type = 0xE0;
576  } else p->found = 0;
577  break;
578  default:
579  p->found = 0;
580  break;
581  }
582  switch(p->type){
583 
584  case 1:
585  p->rbuf = &rx->arbuffer[0];
586  break;
587 
588  case 0xE0:
589  p->rbuf = &rx->vrbuffer;
590  break;
591  }
592  c++;
593  break;
594 
595  case 4:
596  p->plen[0] = buf[c];
597  c++;
598  p->found++;
599  break;
600 
601  case 5:
602  p->plen[1] = buf[c];
603  c++;
604  p->found++;
605  break;
606 
607  case 6:
608  p->plen[2] = buf[c];
609  c++;
610  p->found++;
611  break;
612 
613  case 7:
614  p->plen[3] = buf[c];
615  c++;
616  p->found++;
617  p->plength = getsize_buf(p->plen);
618  if (!p->plength){
619  func(p);
620  p->found=0;
621  break;
622  }
623  p->done = 1;
624  p->ini_pos = ring_wpos(p->rbuf);
625 #if 0
626  if (p->type == 1)
627  {
628  LOG(VB_GENERAL, LOG_ERR, QString("audio 0x%1 0x%2")
629  .arg(p->plength, 0,16)
630  .arg(ALIGN(p->plength), 0,16));
631  LOG(VB_GENERAL, LOG_ERR, QString("video 0x%1 0x%2")
632  .arg(p->plength, 0,16)
633  .arg(ALIGN(p->plength), 0,16));
634  }
635 #endif
636  break;
637 
638  default:
639 
640  break;
641  }
642  }
643  if (p->done || p->found > 8){
644  while (c < count && p->found < p->plength+8){
645  l = count -c;
646  if (l+p->found > p->plength+8)
647  l = p->plength+8-p->found;
648  if (ring_write(p->rbuf, buf+c, l)<0){
649  LOG(VB_GENERAL, LOG_ERR,
650  QString("ring buffer overflow %1")
651  .arg(p->rbuf->size));
652  exit(1);
653  }
654  p->found += l;
655  c += l;
656  }
657  if(p->found == p->plength+8){
658  func(p);
659  }
660  }
661 
662  if (p->plength && p->found == p->plength+8) {
663  int a = 0;//ALIGN(p->plength);
664  init_pes_in(p, 0, nullptr, p->withbuf);
665  if (c+a < count)
666  get_avi(p, buf+c+a, count-c-a, func);
667  }
668 }
getsize
static uint32_t getsize(int fd)
Definition: avi.cpp:64
avi_audio_s::dw_scale
uint32_t dw_scale
Definition: avi.h:49
avi_audio_s::fps
uint32_t fps
Definition: avi.h:51
avi_context::zero_vchunks
uint32_t zero_vchunks
Definition: avi.h:93
getsize_buf
static uint32_t getsize_buf(uint8_t *buf)
Definition: avi.cpp:73
avi_context::ai
avi_audio_info ai[MAX_TRACK]
Definition: avi.h:99
pes.h
discid.disc.read
def read(device=None, features=[])
Definition: disc.py:35
MAX_TRACK
#define MAX_TRACK
Definition: avi.h:69
avi_context::movi_length
int64_t movi_length
Definition: avi.h:73
avi_context::riff_end
int64_t riff_end
Definition: avi.h:71
replex::ac
avi_context ac
Definition: replex.h:60
cc
Definition: cc.h:10
arg
arg(title).arg(filename).arg(doDelete))
avi_context::num_idx_alloc
uint32_t num_idx_alloc
Definition: avi.h:80
read_avi_header
int read_avi_header(avi_context *ac, int fd)
Definition: avi.cpp:215
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
avi_context::width
uint32_t width
Definition: avi.h:86
TAG_IT
#define TAG_IT(a, b, c, d)
Definition: avi.h:34
avi_read_index
int avi_read_index(avi_context *ac, int fd)
Definition: avi.cpp:142
avi_video_s::dw_start
uint32_t dw_start
Definition: avi.h:66
avi_context::vhandler
uint32_t vhandler
Definition: avi.h:89
avi_audio_s::dw_rate
uint32_t dw_rate
Definition: avi.h:49
replex::lastper
int lastper
Definition: replex.h:51
avi_context::ahandler
uint32_t ahandler
Definition: avi.h:90
AVI_HASINDEX
#define AVI_HASINDEX
Definition: avi.h:37
lseek
#define lseek
Definition: mythiowrapper.cpp:236
avi_audio_s::dw_ssize
uint32_t dw_ssize
Definition: avi.h:55
avi_video_s::fps
uint32_t fps
Definition: avi.h:63
if
if(query.exec() &&query.next())
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:464
avi_context::total_frames
uint32_t total_frames
Definition: avi.h:84
mythlogging.h
replex::vrbuffer
ringbuffer vrbuffer
Definition: replex.h:115
hardwareprofile.config.p
p
Definition: config.py:33
avi_context::done
int done
Definition: avi.h:75
new_idx_frame
static int new_idx_frame(avi_context *ac, uint32_t pos, uint32_t len, uint32_t fl, uint32_t id)
Definition: avi.cpp:100
avi_context::current_idx
uint32_t current_idx
Definition: avi.h:96
avi_index_s::len
uint32_t len
Definition: avi.h:43
AVI_USEINDEX
#define AVI_USEINDEX
Definition: avi.h:38
get_avi_from_index
int get_avi_from_index(pes_in_t *p, int fd, avi_context *ac, void(*func)(pes_in_t *p), uint32_t insize)
Definition: avi.cpp:426
mpg_common.h
avi_context::avih_flags
uint32_t avih_flags
Definition: avi.h:83
avi_context::ntracks
int ntracks
Definition: avi.h:79
avi.h
ring_write
int ring_write(ringbuffer *rbuf, uint8_t *data, int count)
Definition: ringbuffer.cpp:90
AVI_INTERLEAVED
#define AVI_INTERLEAVED
Definition: avi.h:39
avi_context::height
uint32_t height
Definition: avi.h:87
avi_context::msec_per_frame
uint32_t msec_per_frame
Definition: avi.h:82
off_t
#define off_t
Definition: mythiowrapper.cpp:238
ring_wpos
static int ring_wpos(ringbuffer *rbuf)
Definition: ringbuffer.h:77
avi_video_s::dw_rate
uint32_t dw_rate
Definition: avi.h:62
avi_context::achunks
uint32_t achunks
Definition: avi.h:92
getle32
static uint32_t getle32(uint8_t *buf)
Definition: avi.cpp:46
avi_index_s::id
uint32_t id
Definition: avi.h:42
MAX_BUF_SIZE
#define MAX_BUF_SIZE
Definition: avi.cpp:425
replex::arbuffer
ringbuffer arbuffer[N_AUDIO]
Definition: replex.h:101
avi_context
Definition: avi.h:70
init_pes_in
void init_pes_in(pes_in_t *p, int t, ringbuffer *rb, int wi)
Definition: pes.cpp:146
avi_context::init_frames
uint32_t init_frames
Definition: avi.h:85
avi_video_s::initial_frames
uint32_t initial_frames
Definition: avi.h:65
get_avi
void get_avi(pes_in_t *p, uint8_t *buf, int count, void(*func)(pes_in_t *p))
Definition: avi.cpp:525
ALIGN
#define ALIGN(a)
Definition: avi.h:35
avi_context::vchunks
uint32_t vchunks
Definition: avi.h:91
avi_index_s::flags
uint32_t flags
Definition: avi.h:43
replex
Definition: replex.h:40
avi_audio_s::dw_start
uint32_t dw_start
Definition: avi.h:54
avi_index_s
Definition: avi.h:41
avi_context::num_idx_frames
uint32_t num_idx_frames
Definition: avi.h:81
print_index
static void print_index(avi_context *ac, int num)
Definition: avi.cpp:129
check_riff
int check_riff(avi_context *ac, uint8_t *buf, int len)
Definition: avi.cpp:79
avi_audio_s::initial_frames
uint32_t initial_frames
Definition: avi.h:53
pes_in_t
Definition: pes.h:70
avi_context::idx
avi_index * idx
Definition: avi.h:101
avi_context::vi
avi_video_info vi
Definition: avi.h:98
avi_context::zero_achunks
uint32_t zero_achunks
Definition: avi.h:94
avi_video_s::dw_scale
uint32_t dw_scale
Definition: avi.h:62
avi_index_s::off
uint32_t off
Definition: avi.h:44
show_buf
void show_buf(uint8_t *buf, int length)
Definition: mpg_common.cpp:37
avi_context::movi_start
int64_t movi_start
Definition: avi.h:72
replex.h
avi_context::nstreams
uint32_t nstreams
Definition: avi.h:88