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