Mercurial > libavformat.hg
comparison mpegtsenc.c @ 5115:640c875b3bfe libavformat
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
author | bcoudurier |
---|---|
date | Tue, 28 Jul 2009 17:51:12 +0000 |
parents | 0be83fd54e7a |
children | 583eb737b1c4 |
comparison
equal
deleted
inserted
replaced
5114:51b1a9987537 | 5115:640c875b3bfe |
---|---|
42 int sid; /* service ID */ | 42 int sid; /* service ID */ |
43 char *name; | 43 char *name; |
44 char *provider_name; | 44 char *provider_name; |
45 int pcr_pid; | 45 int pcr_pid; |
46 int pcr_packet_count; | 46 int pcr_packet_count; |
47 int pcr_packet_freq; | 47 int pcr_packet_period; |
48 } MpegTSService; | 48 } MpegTSService; |
49 | 49 |
50 typedef struct MpegTSWrite { | 50 typedef struct MpegTSWrite { |
51 MpegTSSection pat; /* MPEG2 pat table */ | 51 MpegTSSection pat; /* MPEG2 pat table */ |
52 MpegTSSection sdt; /* MPEG2 sdt table context */ | 52 MpegTSSection sdt; /* MPEG2 sdt table context */ |
53 MpegTSService **services; | 53 MpegTSService **services; |
54 int sdt_packet_count; | 54 int sdt_packet_count; |
55 int sdt_packet_freq; | 55 int sdt_packet_period; |
56 int pat_packet_count; | 56 int pat_packet_count; |
57 int pat_packet_freq; | 57 int pat_packet_period; |
58 int nb_services; | 58 int nb_services; |
59 int onid; | 59 int onid; |
60 int tsid; | 60 int tsid; |
61 uint64_t cur_pcr; | 61 uint64_t cur_pcr; |
62 int mux_rate; | 62 int mux_rate; |
440 service->pcr_pid = ts_st->pid; | 440 service->pcr_pid = ts_st->pid; |
441 } | 441 } |
442 | 442 |
443 if (total_bit_rate <= 8 * 1024) | 443 if (total_bit_rate <= 8 * 1024) |
444 total_bit_rate = 8 * 1024; | 444 total_bit_rate = 8 * 1024; |
445 service->pcr_packet_freq = (total_bit_rate * PCR_RETRANS_TIME) / | 445 service->pcr_packet_period = (total_bit_rate * PCR_RETRANS_TIME) / |
446 (TS_PACKET_SIZE * 8 * 1000); | 446 (TS_PACKET_SIZE * 8 * 1000); |
447 ts->sdt_packet_freq = (total_bit_rate * SDT_RETRANS_TIME) / | 447 ts->sdt_packet_period = (total_bit_rate * SDT_RETRANS_TIME) / |
448 (TS_PACKET_SIZE * 8 * 1000); | 448 (TS_PACKET_SIZE * 8 * 1000); |
449 ts->pat_packet_freq = (total_bit_rate * PAT_RETRANS_TIME) / | 449 ts->pat_packet_period = (total_bit_rate * PAT_RETRANS_TIME) / |
450 (TS_PACKET_SIZE * 8 * 1000); | 450 (TS_PACKET_SIZE * 8 * 1000); |
451 | 451 |
452 ts->mux_rate = 1; // avoid div by 0 | 452 ts->mux_rate = 1; // avoid div by 0 |
453 | 453 |
454 /* write info at the start of the file, so that it will be fast to | 454 /* write info at the start of the file, so that it will be fast to |
468 SDT_RETRANS_TIME * 8 * sdt_size / 1000 + /* SDT size */ | 468 SDT_RETRANS_TIME * 8 * sdt_size / 1000 + /* SDT size */ |
469 PAT_RETRANS_TIME * 8 * pat_pmt_size / 1000 + /* PAT+PMT size */ | 469 PAT_RETRANS_TIME * 8 * pat_pmt_size / 1000 + /* PAT+PMT size */ |
470 PCR_RETRANS_TIME * 8 * 8 / 1000; /* PCR size */ | 470 PCR_RETRANS_TIME * 8 * 8 / 1000; /* PCR size */ |
471 | 471 |
472 av_log(s, AV_LOG_DEBUG, "muxrate %d freq sdt %d pat %d\n", | 472 av_log(s, AV_LOG_DEBUG, "muxrate %d freq sdt %d pat %d\n", |
473 total_bit_rate, ts->sdt_packet_freq, ts->pat_packet_freq); | 473 total_bit_rate, ts->sdt_packet_period, ts->pat_packet_period); |
474 | 474 |
475 if (s->mux_rate) | 475 if (s->mux_rate) |
476 ts->mux_rate = s->mux_rate; | 476 ts->mux_rate = s->mux_rate; |
477 else | 477 else |
478 ts->mux_rate = total_bit_rate; | 478 ts->mux_rate = total_bit_rate; |
496 static void retransmit_si_info(AVFormatContext *s) | 496 static void retransmit_si_info(AVFormatContext *s) |
497 { | 497 { |
498 MpegTSWrite *ts = s->priv_data; | 498 MpegTSWrite *ts = s->priv_data; |
499 int i; | 499 int i; |
500 | 500 |
501 if (++ts->sdt_packet_count == ts->sdt_packet_freq) { | 501 if (++ts->sdt_packet_count == ts->sdt_packet_period) { |
502 ts->sdt_packet_count = 0; | 502 ts->sdt_packet_count = 0; |
503 mpegts_write_sdt(s); | 503 mpegts_write_sdt(s); |
504 } | 504 } |
505 if (++ts->pat_packet_count == ts->pat_packet_freq) { | 505 if (++ts->pat_packet_count == ts->pat_packet_period) { |
506 ts->pat_packet_count = 0; | 506 ts->pat_packet_count = 0; |
507 mpegts_write_pat(s); | 507 mpegts_write_pat(s); |
508 for(i = 0; i < ts->nb_services; i++) { | 508 for(i = 0; i < ts->nb_services; i++) { |
509 mpegts_write_pmt(s, ts->services[i]); | 509 mpegts_write_pmt(s, ts->services[i]); |
510 } | 510 } |
544 | 544 |
545 write_pcr = 0; | 545 write_pcr = 0; |
546 if (ts_st->pid == ts_st->service->pcr_pid) { | 546 if (ts_st->pid == ts_st->service->pcr_pid) { |
547 ts_st->service->pcr_packet_count++; | 547 ts_st->service->pcr_packet_count++; |
548 if (ts_st->service->pcr_packet_count >= | 548 if (ts_st->service->pcr_packet_count >= |
549 ts_st->service->pcr_packet_freq) { | 549 ts_st->service->pcr_packet_period) { |
550 ts_st->service->pcr_packet_count = 0; | 550 ts_st->service->pcr_packet_count = 0; |
551 write_pcr = 1; | 551 write_pcr = 1; |
552 } | 552 } |
553 } | 553 } |
554 | 554 |