From 106fd8e5baa59761eedae0d17c8424445ea7d7f3 Mon Sep 17 00:00:00 2001 From: Kieran Kunhya Date: Wed, 19 Sep 2012 12:33:39 +0700 Subject: [PATCH] Don't write a PCR on every video frame --- libmpegts.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libmpegts.c b/libmpegts.c index 9871817..6c4b858 100644 --- a/libmpegts.c +++ b/libmpegts.c @@ -1710,22 +1710,21 @@ int ts_write_frames( ts_writer_t *w, ts_frame_t *frames, int num_frames, uint8_t #endif bs_init( &q, temp, 150 ); - /* It is good practice to write a pcr at the beginning of a video payload, and allows the packet to be - * a random access indicator if applicable */ if( program->pcr_stream == stream && pes_start ) - write_pcr = 1; - else if( check_pcr( w, program ) ) + write_adapt_field = 1; + + if( check_pcr( w, program ) ) { if( program->pcr_stream == stream ) { /* piggyback pcr on this stream */ - write_pcr = 1; + write_adapt_field = write_pcr = 1; } else if( write_pcr_empty( w, program, 0 ) < 0 ) return -1; } - if( write_pcr ) + if( write_adapt_field ) { adapt_field_len = write_adaptation_field( w, &q, program, pes, write_pcr, 1, 0, 0 ); pkt_bytes_left -= adapt_field_len;