Originally committed as revision 14734 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -482,6 +482,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len |
| 482 | 482 |
int comp_page = 0, anc_page = 0; /* initialize to kill warnings */ |
| 483 | 483 |
char language[4] = {0}; /* initialize to kill warnings */
|
| 484 | 484 |
int has_hdmv_descr = 0; |
| 485 |
+ int has_dirac_descr = 0; |
|
| 485 | 486 |
|
| 486 | 487 |
#ifdef DEBUG_SI |
| 487 | 488 |
av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len); |
| ... | ... |
@@ -589,6 +590,18 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len |
| 589 | 589 |
language[2] = get8(&p, desc_end); |
| 590 | 590 |
language[3] = 0; |
| 591 | 591 |
break; |
| 592 |
+ case REGISTRATION_DESCRIPTOR: /*MPEG-2 Registration descriptor */ |
|
| 593 |
+ {
|
|
| 594 |
+ uint8_t bytes[4]; |
|
| 595 |
+ bytes[0] = get8(&p, desc_end); |
|
| 596 |
+ bytes[1] = get8(&p, desc_end); |
|
| 597 |
+ bytes[2] = get8(&p, desc_end); |
|
| 598 |
+ bytes[3] = get8(&p, desc_end); |
|
| 599 |
+ if(bytes[0] == 'd' && bytes[1] == 'r' && |
|
| 600 |
+ bytes[2] == 'a' && bytes[3] == 'c') |
|
| 601 |
+ has_dirac_descr = 1; |
|
| 602 |
+ break; |
|
| 603 |
+ } |
|
| 592 | 604 |
default: |
| 593 | 605 |
break; |
| 594 | 606 |
} |
| ... | ... |
@@ -610,12 +623,14 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len |
| 610 | 610 |
case STREAM_TYPE_VIDEO_MPEG4: |
| 611 | 611 |
case STREAM_TYPE_VIDEO_H264: |
| 612 | 612 |
case STREAM_TYPE_VIDEO_VC1: |
| 613 |
+ case STREAM_TYPE_VIDEO_DIRAC: |
|
| 613 | 614 |
case STREAM_TYPE_AUDIO_AAC: |
| 614 | 615 |
case STREAM_TYPE_AUDIO_AC3: |
| 615 | 616 |
case STREAM_TYPE_AUDIO_DTS: |
| 616 | 617 |
case STREAM_TYPE_AUDIO_HDMV_DTS: |
| 617 | 618 |
case STREAM_TYPE_SUBTITLE_DVB: |
| 618 |
- if(stream_type == STREAM_TYPE_AUDIO_HDMV_DTS && !has_hdmv_descr) |
|
| 619 |
+ if((stream_type == STREAM_TYPE_AUDIO_HDMV_DTS && !has_hdmv_descr) |
|
| 620 |
+ || (stream_type == STREAM_TYPE_VIDEO_DIRAC && !has_dirac_descr)) |
|
| 619 | 621 |
break; |
| 620 | 622 |
if(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES){
|
| 621 | 623 |
pes= ts->pids[pid]->u.pes_filter.opaque; |
| ... | ... |
@@ -944,6 +959,10 @@ static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code) |
| 944 | 944 |
codec_type = CODEC_TYPE_VIDEO; |
| 945 | 945 |
codec_id = CODEC_ID_VC1; |
| 946 | 946 |
break; |
| 947 |
+ case STREAM_TYPE_VIDEO_DIRAC: |
|
| 948 |
+ codec_type = CODEC_TYPE_VIDEO; |
|
| 949 |
+ codec_id = CODEC_ID_DIRAC; |
|
| 950 |
+ break; |
|
| 947 | 951 |
case STREAM_TYPE_AUDIO_AAC: |
| 948 | 952 |
codec_type = CODEC_TYPE_AUDIO; |
| 949 | 953 |
codec_id = CODEC_ID_AAC; |
| ... | ... |
@@ -220,6 +220,9 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) |
| 220 | 220 |
case CODEC_ID_H264: |
| 221 | 221 |
stream_type = STREAM_TYPE_VIDEO_H264; |
| 222 | 222 |
break; |
| 223 |
+ case CODEC_ID_DIRAC: |
|
| 224 |
+ stream_type = STREAM_TYPE_VIDEO_DIRAC; |
|
| 225 |
+ break; |
|
| 223 | 226 |
case CODEC_ID_MP2: |
| 224 | 227 |
case CODEC_ID_MP3: |
| 225 | 228 |
stream_type = STREAM_TYPE_AUDIO_MPEG1; |
| ... | ... |
@@ -267,6 +270,16 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) |
| 267 | 267 |
put16(&q, 1); /* ancillary page id */ |
| 268 | 268 |
} |
| 269 | 269 |
break; |
| 270 |
+ case CODEC_TYPE_VIDEO: |
|
| 271 |
+ if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
|
|
| 272 |
+ *q++ = 0x05; /*MPEG-2 registration descriptor*/ |
|
| 273 |
+ *q++ = 4; |
|
| 274 |
+ *q++ = 'd'; |
|
| 275 |
+ *q++ = 'r'; |
|
| 276 |
+ *q++ = 'a'; |
|
| 277 |
+ *q++ = 'c'; |
|
| 278 |
+ } |
|
| 279 |
+ break; |
|
| 270 | 280 |
} |
| 271 | 281 |
|
| 272 | 282 |
val = 0xf000 | (q - desc_length_ptr - 2); |
| ... | ... |
@@ -527,13 +540,17 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, |
| 527 | 527 |
*q++ = 0; |
| 528 | 528 |
} |
| 529 | 529 |
if (is_start) {
|
| 530 |
+ int pes_extension = 0; |
|
| 530 | 531 |
/* write PES header */ |
| 531 | 532 |
*q++ = 0x00; |
| 532 | 533 |
*q++ = 0x00; |
| 533 | 534 |
*q++ = 0x01; |
| 534 | 535 |
private_code = 0; |
| 535 | 536 |
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
|
| 536 |
- *q++ = 0xe0; |
|
| 537 |
+ if (st->codec->codec_id == CODEC_ID_DIRAC) {
|
|
| 538 |
+ *q++ = 0xfd; |
|
| 539 |
+ } else |
|
| 540 |
+ *q++ = 0xe0; |
|
| 537 | 541 |
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO && |
| 538 | 542 |
(st->codec->codec_id == CODEC_ID_MP2 || |
| 539 | 543 |
st->codec->codec_id == CODEC_ID_MP3)) {
|
| ... | ... |
@@ -554,6 +571,19 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, |
| 554 | 554 |
header_len += 5; |
| 555 | 555 |
flags |= 0x40; |
| 556 | 556 |
} |
| 557 |
+ if (st->codec->codec_type == CODEC_TYPE_VIDEO && |
|
| 558 |
+ st->codec->codec_id == CODEC_ID_DIRAC) {
|
|
| 559 |
+ /* set PES_extension_flag */ |
|
| 560 |
+ pes_extension = 1; |
|
| 561 |
+ flags |= 0x01; |
|
| 562 |
+ |
|
| 563 |
+ /* |
|
| 564 |
+ * One byte for PES2 extension flag + |
|
| 565 |
+ * one byte for extension length + |
|
| 566 |
+ * one byte for extension id |
|
| 567 |
+ */ |
|
| 568 |
+ header_len += 3; |
|
| 569 |
+ } |
|
| 557 | 570 |
len = payload_size + header_len + 3; |
| 558 | 571 |
if (private_code != 0) |
| 559 | 572 |
len++; |
| ... | ... |
@@ -574,6 +604,16 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, |
| 574 | 574 |
write_pts(q, 1, dts); |
| 575 | 575 |
q += 5; |
| 576 | 576 |
} |
| 577 |
+ if (pes_extension && st->codec->codec_id == CODEC_ID_DIRAC) {
|
|
| 578 |
+ flags = 0x01; /* set PES_extension_flag_2 */ |
|
| 579 |
+ *q++ = flags; |
|
| 580 |
+ *q++ = 0x80 | 0x01; /* marker bit + extension length */ |
|
| 581 |
+ /* |
|
| 582 |
+ * Set the stream id extension flag bit to 0 and |
|
| 583 |
+ * write the extended stream id |
|
| 584 |
+ */ |
|
| 585 |
+ *q++ = 0x00 | 0x60; |
|
| 586 |
+ } |
|
| 577 | 587 |
if (private_code != 0) |
| 578 | 588 |
*q++ = private_code; |
| 579 | 589 |
is_start = 0; |