MythTV  master
element.c
Go to the documentation of this file.
1 /*
2  * element.c: MPEG ELEMENTARY STREAM 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 <stdio.h>
30 #include <string.h>
31 
32 #include "element.h"
33 #include "mpg_common.h"
34 #include "pes.h"
35 
36 #include "mythlogging.h"
37 
38 unsigned int slots [4] = {12, 144, 0, 0};
39 unsigned int bitrates[3][16] =
40 {{0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0},
41  {0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,0},
42  {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0}};
43 
44 uint32_t freq[4] = {441, 480, 320, 0};
45 static uint64_t samples[4] = { 384, 1152, 1152, 1536};
46 const char *frames[3] = {"I-Frame","P-Frame","B-Frame"};
47 
48 unsigned int ac3_bitrates[32] =
49  {32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,576,640,
50  0,0,0,0,0,0,0,0,0,0,0,0,0};
51 static uint8_t ac3half[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
52 uint32_t ac3_freq[4] = {480, 441, 320, 0};
53 
54 #define DEBUG 1
55 
56 uint64_t add_pts_audio(uint64_t pts, audio_frame_t *aframe, uint64_t frames)
57 {
58  int64_t newpts=0;
59 
60  newpts = (pts + (frames *samples [3-aframe->layer] * 27000000ULL)
61  / aframe->frequency);
62  return newpts>0 ? newpts%MAX_PTS2: MAX_PTS2+newpts;
63 }
64 
65 void fix_audio_count(uint64_t *acount, audio_frame_t *aframe, uint64_t origpts, uint64_t pts)
66 {
67  uint64_t di = (samples [3-aframe->layer] * 27000000ULL);
68  int64_t diff = ptsdiff(origpts,pts);
69  int c=(aframe->frequency * diff+di/2)/di;
70  if (c) LOG(VB_GENERAL, LOG_INFO, "fix audio frames %d", c);
71  *acount += c;
72 }
73 
74 
75 uint64_t next_ptsdts_video(uint64_t *pts, sequence_t *s, uint64_t fcount, uint64_t gcount)
76 {
77  int64_t newdts = 0;
78  int64_t newpts = 0;
79  int64_t fnum = s->current_tmpref - gcount + fcount;
80 
81 
82  if ( s->pulldown == NOPULLDOWN ) {
83  newdts = ( (fcount-1) * SEC_PER + *pts);
84  newpts = ((fnum ) * SEC_PER + *pts);
85  } else {
86  uint64_t extra_time = 0;
87 #if 0
88  LOG(VB_GENERAL, LOG_INFO, "pulldown %d %d",
89  (int)fcount-1, fnum-1);
90 #endif
91 
92  if ( s->pulldown == PULLDOWN32)
93  extra_time = SEC_PER;
94  else
95  extra_time = 3*SEC_PER/2;
96 
97  newdts = (fcount - 1) * 5ULL * SEC_PER / 4ULL +
98  ((fcount - 1)%2)*extra_time +
99  *pts;
100 
101  if ((s->pulldown == PULLDOWN23) && (fcount-1))
102  newdts -= SEC_PER/2;
103 
104  newpts = SEC_PER +
105  (fnum -1) * 5ULL * SEC_PER / 4ULL +
106  ((fnum - 1)%2)*extra_time +
107  *pts;
108 
109  }
110 
111 
112  *pts = newpts >= 0 ? newpts%MAX_PTS2: MAX_PTS2+newpts;
113  return newdts >= 0 ? newdts%MAX_PTS2: MAX_PTS2+newdts;
114 }
115 
116 void fix_video_count(sequence_t *s, uint64_t *frame, uint64_t origpts, uint64_t pts,
117  uint64_t origdts, uint64_t dts)
118 {
119  int64_t pdiff = 0;
120  int64_t ddiff = 0;
121  int64_t pframe = 0;
122  int64_t dframe = 0;
123  int psig=0;
124  int dsig=0;
125  int64_t fr=0;
126 
127  pdiff = ptsdiff(origpts,pts);
128  ddiff = ptsdiff(origdts,dts);
129  psig = pdiff > 0;
130  dsig = ddiff > 0;
131  if (!psig) pdiff = -pdiff;
132  if (!dsig) ddiff = -ddiff;
133 
134  if ( s->pulldown == NOPULLDOWN ) {
135  dframe = (ddiff+SEC_PER/2ULL) / SEC_PER;
136  pframe = (pdiff+SEC_PER/2ULL) / SEC_PER;
137  } else {
138  dframe = (4ULL*ddiff/5ULL+SEC_PER/2ULL) / SEC_PER;
139  pframe = (4ULL*pdiff/5ULL+SEC_PER/2ULL) / SEC_PER;
140  }
141 
142  if (!psig) fr = -(int)pframe;
143  else fr = (int)pframe;
144  if (!dsig) fr -= (int)dframe;
145  else fr += (int)dframe;
146  *frame = *frame + fr/2;
147  if (fr/2) LOG(VB_GENERAL, LOG_INFO, "fixed video frame %d", (int)fr/2);
148 }
149 
150 
151 void pts2time(uint64_t pts, uint8_t *buf, int len)
152 {
153  int c = 0;
154 
155  pts = (pts/300)%MAX_PTS;
156  uint8_t h = (uint8_t)(pts/90000)/3600;
157  uint8_t m = (uint8_t)((pts/90000)%3600)/60;
158  uint8_t s = (uint8_t)((pts/90000)%3600)%60;
159 
160  while (c+7 < len){
161  if (buf[c] == 0x00 && buf[c+1] == 0x00 && buf[c+2] == 0x01 &&
162  buf[c+3] == GROUP_START_CODE && (buf[c+5] & 0x08)){
163  buf[c+4] &= ~(0x7F);
164  buf[c+4] |= (h & 0x1F) << 2;
165  buf[c+4] |= (m & 0x30) >> 4;
166 
167  buf[c+5] &= ~(0xF7);
168  buf[c+5] |= (m & 0x0F) << 4;
169  buf[c+5] |= (s & 0x38) >> 3;
170 
171  buf[c+6] &= ~(0xE0);
172  buf[c+6] |= (s & 0x07) << 5;
173 
174 /* 1hhhhhmm|mmmm1sss|sss */
175 #if 0
176  c+=4;
177  LOG(VB_GENERAL, LOG_INFO, "fixed time");
178  LOG(VB_GENERAL, LOG_INFO, "%02d:%02d:%02d",
179  (int)((buf[c]>>2)& 0x1F),
180  (int)(((buf[c]<<4)& 0x30)|((buf[c+1]>>4)& 0x0F)),
181  (int)(((buf[c+1]<<3)& 0x38)|((buf[c+2]>>5)& 0x07)));
182 #endif
183  c = len;
184 
185 
186  } else c++;
187  }
188 
189 }
190 
191 
192 int get_video_info(ringbuffer *rbuf, sequence_t *s, int off, int le)
193 {
194  uint8_t buf[150];
195  int form = -1;
196  int c = 0;
197 
198  s->set = 0;
199  s->ext_set = 0;
200  s->pulldown_set = 0;
201  int re = ring_find_mpg_header(rbuf, SEQUENCE_HDR_CODE, off, le);
202  if (re < 0)
203  return re;
204  uint8_t *headr = buf+4;
205  if (ring_peek(rbuf, buf, 150, off) < 0) return -2;
206 
207  s->h_size = ((headr[1] &0xF0) >> 4) | (headr[0] << 4);
208  s->v_size = ((headr[1] &0x0F) << 8) | (headr[2]);
209 
210  int sw = (int)((headr[3]&0xF0) >> 4) ;
211 
212  if (DEBUG){
213  switch( sw ){
214  case 1:
215  LOG(VB_GENERAL, LOG_INFO, "Video: aspect ratio: 1:1");
216  s->aspect_ratio = 100;
217  break;
218  case 2:
219  LOG(VB_GENERAL, LOG_INFO, "Video: aspect ratio: 4:3");
220  s->aspect_ratio = 133;
221  break;
222  case 3:
223  LOG(VB_GENERAL, LOG_INFO, "Video: aspect ratio: 16:9");
224  s->aspect_ratio = 177;
225  break;
226  case 4:
227  LOG(VB_GENERAL, LOG_INFO,
228  "Video: aspect ratio: 2.21:1");
229  s->aspect_ratio = 221;
230  break;
231 
232  case 5 ... 15:
233  LOG(VB_GENERAL, LOG_INFO,
234  "Video: aspect ratio: reserved");
235  s->aspect_ratio = 0;
236  break;
237 
238  default:
239  s->aspect_ratio = 0;
240  return -3;
241  }
242  }
243 
244  if (DEBUG)
245  LOG(VB_GENERAL, LOG_DEBUG, " size = %dx%d",
246  s->h_size, s->v_size);
247 
248  sw = (int)(headr[3]&0x0F);
249 
250  switch ( sw ) {
251  case 1:
252  s->frame_rate = 23976;
253  form = -1;
254  break;
255  case 2:
256  s->frame_rate = 24000;
257  form = -1;
258  break;
259  case 3:
260  s->frame_rate = 25000;
261  form = VIDEO_PAL;
262  break;
263  case 4:
264  s->frame_rate = 29970;
265  form = VIDEO_NTSC;
266  break;
267  case 5:
268  s->frame_rate = 30000;
269  form = VIDEO_NTSC;
270  break;
271  case 6:
272  s->frame_rate = 50000;
273  form = VIDEO_PAL;
274  break;
275  case 7:
276  s->frame_rate = 60000;
277  form = VIDEO_NTSC;
278  break;
279  }
280  if (DEBUG)
281  LOG(VB_GENERAL, LOG_DEBUG, " frame rate: %2.3f fps",
282  s->frame_rate/1000.0);
283 
284  s->bit_rate = (((headr[4] << 10) & 0x0003FC00UL)
285  | ((headr[5] << 2) & 0x000003FCUL) |
286  (((headr[6] & 0xC0) >> 6) & 0x00000003UL));
287 
288  if (DEBUG)
289  LOG(VB_GENERAL, LOG_DEBUG, " bit rate: %.2f Mbit/s",
290  400*(s->bit_rate)/1000000.0);
291 
292  s->video_format = form;
293 
294 
295 
296  s->vbv_buffer_size = (( headr[7] & 0xF8) >> 3 ) | (( headr[6] & 0x1F )<< 5);
297  s->flags = ( headr[7] & 0x06);
298  if (DEBUG)
299  LOG(VB_GENERAL, LOG_DEBUG, " vbvbuffer %d",
300  16*1024*(s->vbv_buffer_size));
301 
302  c += 8;
303  if ( !(s->flags & INTRAQ_FLAG) )
304  s->flags = ( headr[7] & 0x07);
305  else {
306  s->flags |= headr[c+63] & 0x01;
307  memset(s->intra_quant, 0, 64);
308  for (int i=0;i<64;i++)
309  s->intra_quant[i] |= (headr[c+i] >> 1) |
310  (( headr[c-1+i] & 0x01) << 7);
311 
312  c += 64;
313  }
314  if (s->flags & NONINTRAQ_FLAG){
315  memcpy(s->non_intra_quant, headr+c, 64);
316  c += 64;
317  }
318  s->set=1;
319 
320  return c;
321 }
322 
323 int find_audio_sync(ringbuffer *rbuf, uint8_t *buf, int off, int type, int le)
324 {
325  int found = 0;
326  int l=0;
327 
328  memset(buf,0,7);
329  uint8_t b1 = 0x00;
330  uint8_t b2 = 0x00;
331  uint8_t m2 = 0xFF;
332  switch(type){
333  case AC3:
334  b1 = 0x0B;
335  b2 = 0x77;
336  l = 6;
337  break;
338 
339  case MPEG_AUDIO:
340  b1 = 0xFF;
341  b2 = 0xF8;
342  m2 = 0xF8;
343  l = 4;
344  break;
345 
346  default:
347  return -1;
348  }
349 
350  int c = off;
351  while ( c-off < le){
352  uint8_t b = 0;
353  if (mring_peek(rbuf, &b, 1, c) <0) return -1;
354  switch(found){
355 
356  case 0:
357  if ( b == b1) found = 1;
358  break;
359 
360  case 1:
361  if ( (b&m2) == b2){
362  if (mring_peek(rbuf, buf, l, c-1) < -1)
363  return -2;
364  return c-1-off;
365  } else if ( b != b1) found = 0;
366  }
367  c++;
368  }
369  if (found) return -2;
370  return -1;
371 }
372 
373 int find_audio_s(const uint8_t *rbuf, int off, int type, int le)
374 {
375  int found = 0;
376 
377  uint8_t b1 = 0x00;
378  uint8_t b2 = 0x00;
379  uint8_t m2 = 0xFF;
380  switch(type){
381  case AC3:
382  b1 = 0x0B;
383  b2 = 0x77;
384  break;
385 
386  case MPEG_AUDIO:
387  b1 = 0xFF;
388  b2 = 0xF8;
389  m2 = 0xF8;
390  break;
391 
392  default:
393  return -1;
394  }
395 
396  int c = off;
397  while ( c < le){
398  uint8_t b=rbuf[c];
399  switch(found){
400  case 0:
401  if ( b == b1) found = 1;
402  break;
403 
404  case 1:
405  if ( (b&m2) == b2){
406  return c-1;
407  } else if ( b != b1) found = 0;
408  }
409  c++;
410  }
411  if (found) return -2;
412  return -1;
413 }
414 
415 int check_audio_header(ringbuffer *rbuf, audio_frame_t * af, int off, int le,
416  int type)
417 {
418  uint8_t headr[7];
419  uint8_t frame = 0;
420  int fr = 0;
421  int half = 0;
422  int c=0;
423 
424  if ( (c = find_audio_sync(rbuf, headr, off, type, le))
425  != 0 ) {
426  if (c==-2){
427  LOG(VB_GENERAL, LOG_ERR, "Incomplete audio header");
428  return -2;
429  }
430  LOG(VB_GENERAL, LOG_ERR, "Error in audio header");
431  return -1;
432  }
433  switch (type){
434 
435  case MPEG_AUDIO:
436  if ( af->layer != ((headr[1] & 0x06) >> 1) ){
437  if ( headr[1] == 0xff){
438  return -3;
439  }
440 #ifdef IN_DEBUG
441  LOG(VB_GENERAL, LOG_ERR, "Wrong audio layer");
442 #endif
443  return -1;
444  }
445  if ( af->bit_rate !=
446  (bitrates[(3-af->layer)][(headr[2] >> 4 )]*1000)){
447 #ifdef IN_DEBUG
448  LOG(VB_GENERAL, LOG_ERR, "Wrong audio bit rate");
449 #endif
450  return -1;
451  }
452  break;
453 
454  case AC3:
455  frame = (headr[4]&0x3F);
456  if (af->bit_rate != ac3_bitrates[frame>>1]*1000){
457 #ifdef IN_DEBUG
458  LOG(VB_GENERAL, LOG_ERR, "Wrong audio bit rate");
459 #endif
460  return -1;
461  }
462  half = ac3half[headr[5] >> 3];
463  fr = (headr[4] & 0xc0) >> 6;
464  if (af->frequency != ((ac3_freq[fr] *100) >> half)){
465 #ifdef IN_DEBUG
466  LOG(VB_GENERAL, LOG_ERR, "Wrong audio frequency");
467 #endif
468  return -1;
469  }
470 
471  break;
472 
473  }
474 
475  return 0;
476 }
477 
478 
479 int get_audio_info(ringbuffer *rbuf, audio_frame_t *af, int off, int le)
480 {
481  int c = 0;
482  int fr =0;
483  uint8_t headr[7];
484 
485  af->set=0;
486 
487  if ( (c = find_audio_sync(rbuf, headr, off, MPEG_AUDIO,le)) < 0 )
488  return c;
489 
490  af->layer = (headr[1] & 0x06) >> 1;
491 
492  if (DEBUG)
493  LOG(VB_GENERAL, LOG_DEBUG, "Audiostream: layer: %d",
494  4-af->layer);
495 
496 
497  af->bit_rate = bitrates[(3-af->layer)][(headr[2] >> 4 )]*1000;
498 
499  if (DEBUG){
500  if (af->bit_rate == 0)
501  LOG(VB_GENERAL, LOG_DEBUG, " Bit rate: free");
502  else if (af->bit_rate == 0xf)
503  LOG(VB_GENERAL, LOG_DEBUG, " BRate: reserved");
504  else
505  LOG(VB_GENERAL, LOG_DEBUG, " BRate: %d kb/s",
506  af->bit_rate/1000);
507  }
508 
509  fr = (headr[2] & 0x0c ) >> 2;
510  af->frequency = freq[fr]*100;
511 
512  if (DEBUG){
513  if (af->frequency == 3)
514  LOG(VB_GENERAL, LOG_DEBUG, " Freq: reserved");
515  else
516  LOG(VB_GENERAL, LOG_DEBUG, " Freq: %2.1f kHz",
517  af->frequency/1000.0);
518  }
519  af->off = c;
520  af->set = 1;
521 
522  af->frametime = ((samples [3-af->layer] * 27000000ULL) / af->frequency);
523  af->framesize = af->bit_rate *slots [3-af->layer]/ af->frequency;
524  LOG(VB_GENERAL, LOG_INFO, " frame size: %d", af->framesize);
525  printpts(af->frametime);
526 
527  return c;
528 }
529 
530 int get_ac3_info(ringbuffer *rbuf, audio_frame_t *af, int off, int le)
531 {
532  uint8_t headr[7];
533 
534  af->set=0;
535 
536  int c = find_audio_sync(rbuf, headr, off, AC3, le);
537  if (c < 0)
538  return c;
539 
540  af->off = c;
541 
542  af->layer = 0; // 0 for AC3
543 
544  if (DEBUG)
545  LOG(VB_GENERAL, LOG_DEBUG, "AC3 stream:");
546  uint8_t frame = (headr[4]&0x3F);
547  af->bit_rate = ac3_bitrates[frame>>1]*1000;
548  int half = ac3half[headr[5] >> 3];
549  if (DEBUG)
550  LOG(VB_GENERAL, LOG_DEBUG, " bit rate: %d kb/s",
551  af->bit_rate/1000);
552  int fr = (headr[4] & 0xc0) >> 6;
553  af->frequency = (ac3_freq[fr] *100) >> half;
554 
555  if (DEBUG)
556  LOG(VB_GENERAL, LOG_DEBUG, " freq: %d Hz", af->frequency);
557 
558  switch (headr[4] & 0xc0) {
559  case 0:
560  af->framesize = 4 * af->bit_rate/1000;
561  break;
562 
563  case 0x40:
564  af->framesize = 2 * (320 * af->bit_rate / 147000 + (frame & 1));
565  break;
566 
567  case 0x80:
568  af->framesize = 6 * af->bit_rate/1000;
569  break;
570  }
571 
572  if (DEBUG)
573  LOG(VB_GENERAL, LOG_DEBUG, " frame size %d", af->framesize);
574 
575  af->off = c;
576  af->set = 1;
577 
578  //FIXME calculate frametime
579  af->frametime = 0;
580 
581  return c;
582 }
583 
584 
585 int get_video_ext_info(ringbuffer *rbuf, sequence_t *s, int off, int le)
586 {
587  uint8_t buf[12];
588 
589  int re =ring_find_mpg_header(rbuf, EXTENSION_START_CODE, off, le);
590  if (re < 0) {
591  LOG(VB_GENERAL, LOG_ERR, "Error in find_mpg_header");
592  return re;
593  }
594 
595  if (ring_peek(rbuf, buf, 5, off) < 0) return -2;
596  uint8_t *headr=buf+4;
597 
598  uint8_t ext_id = (headr[0]&0xF0) >> 4;
599 
600  switch (ext_id){
601  case SEQUENCE_EXTENSION:{
602  if (s->ext_set || !s->set) break;
603  if (ring_peek(rbuf, buf, 10, off) < 0) return -2;
604  headr=buf+4;
605 
606  if (DEBUG)
607  LOG(VB_GENERAL, LOG_DEBUG, "Sequence Extension:");
608  s->profile = ((headr[0]&0x0F) << 4) | ((headr[1]&0xF0) >> 4);
609  if (headr[1]&0x08) s->progressive = 1;
610  else s->progressive = 0;
611  s->chroma = (headr[1]&0x06)>>1;
612  if (DEBUG){
613  switch(s->chroma){
614  case 0:
615  LOG(VB_GENERAL, LOG_DEBUG, " chroma reserved ");
616  break;
617  case 1:
618  LOG(VB_GENERAL, LOG_DEBUG, " chroma 4:2:0 ");
619  break;
620  case 2:
621  LOG(VB_GENERAL, LOG_DEBUG, " chroma 4:2:2 ");
622  break;
623  case 3:
624  LOG(VB_GENERAL, LOG_DEBUG, " chroma 4:4:4 ");
625  break;
626  }
627  }
628 
629  uint16_t hsize = ((headr[1]&0x01)<<12) | ((headr[2]&0x80)<<6);
630  uint16_t vsize = ((headr[2]&0x60)<<7);
631  s->h_size |= hsize;
632  s->v_size |= vsize;
633  if (DEBUG)
634  LOG(VB_GENERAL, LOG_DEBUG, " size = %dx%d",
635  s->h_size, s->v_size);
636 
637  uint32_t bitrate = ((headr[2]& 0x1F) << 25) | (( headr[3] & 0xFE ) << 17);
638  s->bit_rate |= bitrate;
639 
640  if (DEBUG)
641  LOG(VB_GENERAL, LOG_DEBUG, " bit rate: %.2f Mbit/s",
642  400.0*(s->bit_rate)/1000000.0);
643 
644 
645  uint32_t vbvb = (headr[4]<<10);
646  s->vbv_buffer_size |= vbvb;
647  if (DEBUG)
648  LOG(VB_GENERAL, LOG_DEBUG, " vbvbuffer %d",
649  16*1024*(s->vbv_buffer_size));
650  uint8_t fr_n = (headr[5] & 0x60) >> 6;
651  uint8_t fr_d = (headr[5] & 0x1F);
652 
653  s->frame_rate = s->frame_rate * (fr_n+1) / (fr_d+1);
654  if (DEBUG)
655  LOG(VB_GENERAL, LOG_DEBUG, " frame rate: %2.3f",
656  s->frame_rate/1000.0);
657  s->ext_set=1;
658  break;
659  }
660 
662  break;
663 
665  int pulldown = 0;
666 
667  if (!s->set || s->pulldown_set) break;
668  if (ring_peek(rbuf, buf, 10, off) < 0) return -2;
669  headr=buf+4;
670 
671  if ( (headr[2]&0x03) != 0x03 ) break; // not frame picture
672  if ( (headr[3]&0x02) ) pulldown = 1; // repeat flag set => pulldown
673 
674  if (pulldown){
675  if (s->current_tmpref)
676  s->pulldown = PULLDOWN23;
677  else
678  s->pulldown = PULLDOWN32;
679  s->pulldown_set = 1;
680  }
681  if (DEBUG){
682  switch (s->pulldown) {
683  case PULLDOWN32:
684  LOG(VB_GENERAL, LOG_DEBUG,
685  "Picture Coding Extension: "
686  "3:2 pulldown detected");
687  break;
688  case PULLDOWN23:
689  LOG(VB_GENERAL, LOG_DEBUG,
690  "Picture Coding Extension: "
691  "2:3 pulldown detected");
692  break;
693 #if 0
694  default:
695  LOG(VB_GENERAL, INFO_DEBUG,
696  " no pulldown detected");
697 #endif
698  }
699  }
700  break;
701  }
704  break;
705  }
706 
707 
708  return ext_id;
709 }
710 
#define EXTENSION_START_CODE
Definition: element.h:43
uint8_t flags
Definition: element.h:95
int get_video_ext_info(ringbuffer *rbuf, sequence_t *s, int off, int le)
Definition: element.c:585
unsigned int slots[4]
Definition: element.c:38
int64_t ptsdiff(uint64_t pts1, uint64_t pts2)
Definition: pes.c:78
int set
Definition: element.h:87
#define SEC_PER
Definition: element.h:79
static uint64_t samples[4]
Definition: element.c:45
uint32_t bit_rate
Definition: element.h:112
uint8_t aspect_ratio
Definition: element.h:91
uint8_t pulldown
Definition: element.h:103
Definition: element.h:83
#define PULLDOWN32
Definition: element.h:74
#define MAX_PTS
Definition: pes.h:52
#define DEBUG
Definition: element.c:54
uint32_t framesize
Definition: element.h:117
uint32_t frametime
Definition: element.h:118
uint8_t pulldown_set
Definition: element.h:102
uint16_t v_size
Definition: element.h:90
uint64_t next_ptsdts_video(uint64_t *pts, sequence_t *s, uint64_t fcount, uint64_t gcount)
Definition: element.c:75
uint32_t ac3_freq[4]
Definition: element.c:52
uint32_t freq[4]
Definition: element.c:44
#define SEQUENCE_EXTENSION
Definition: element.h:47
#define NONINTRAQ_FLAG
Definition: element.h:68
int get_ac3_info(ringbuffer *rbuf, audio_frame_t *af, int off, int le)
Definition: element.c:530
uint64_t add_pts_audio(uint64_t pts, audio_frame_t *aframe, uint64_t frames)
Definition: element.c:56
void printpts(int64_t pts)
Definition: pes.c:42
int find_audio_s(const uint8_t *rbuf, int off, int type, int le)
Definition: element.c:373
int ext_set
Definition: element.h:88
#define QUANT_MATRIX_EXTENSION
Definition: element.h:50
static uint8_t ac3half[12]
Definition: element.c:51
uint8_t chroma
Definition: element.h:101
unsigned int ac3_bitrates[32]
Definition: element.c:48
int check_audio_header(ringbuffer *rbuf, audio_frame_t *af, int off, int le, int type)
Definition: element.c:415
int get_audio_info(ringbuffer *rbuf, audio_frame_t *af, int off, int le)
Definition: element.c:479
uint8_t progressive
Definition: element.h:100
int mring_peek(ringbuffer *rbuf, uint8_t *buf, unsigned int l, uint32_t off)
Definition: mpg_common.c:168
#define INTRAQ_FLAG
Definition: element.h:67
void pts2time(uint64_t pts, uint8_t *buf, int len)
Definition: element.c:151
int ring_find_mpg_header(ringbuffer *rbuf, uint8_t head, int off, int le)
Definition: mpg_common.c:181
uint32_t off
Definition: element.h:119
uint32_t frequency
Definition: element.h:113
#define PICTURE_DISPLAY_EXTENSION
Definition: element.h:51
int ring_peek(ringbuffer *rbuf, uint8_t *data, unsigned int count, uint32_t off)
Definition: ringbuffer.c:121
#define SEQUENCE_HDR_CODE
Definition: element.h:41
uint32_t vbv_buffer_size
Definition: element.h:94
uint32_t frame_rate
Definition: element.h:92
uint8_t profile
Definition: element.h:99
uint8_t current_tmpref
Definition: element.h:105
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
void fix_video_count(sequence_t *s, uint64_t *frame, uint64_t origpts, uint64_t pts, uint64_t origdts, uint64_t dts)
Definition: element.c:116
unsigned short uint16_t
Definition: iso6937tables.h:1
unsigned int bitrates[3][16]
Definition: element.c:39
uint8_t non_intra_quant[64]
Definition: element.h:97
#define NOPULLDOWN
Definition: element.h:73
#define PICTURE_CODING_EXTENSION
Definition: element.h:49
#define PULLDOWN23
Definition: element.h:75
int find_audio_sync(ringbuffer *rbuf, uint8_t *buf, int off, int type, int le)
Definition: element.c:323
#define MAX_PTS2
Definition: pes.h:53
const char * frames[3]
Definition: element.c:46
int get_video_info(ringbuffer *rbuf, sequence_t *s, int off, int le)
Definition: element.c:192
int video_format
Definition: element.h:98
void fix_audio_count(uint64_t *acount, audio_frame_t *aframe, uint64_t origpts, uint64_t pts)
Definition: element.c:65
#define SEQUENCE_DISPLAY_EXTENSION
Definition: element.h:48
uint8_t intra_quant[64]
Definition: element.h:96
uint16_t h_size
Definition: element.h:89
#define GROUP_START_CODE
Definition: element.h:45
uint32_t bit_rate
Definition: element.h:93