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