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