# HG changeset patch # User nicodvb # Date 1111563811 0 # Node ID d1d36694aa3d8937414a12b130817b146d3e1a38 # Parent 07f1e7669772c069aaabcf62dbae91e295b195a6 consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL) diff -r 07f1e7669772 -r d1d36694aa3d libmpdemux/demux_ts.c --- a/libmpdemux/demux_ts.c Tue Mar 22 23:27:18 2005 +0000 +++ b/libmpdemux/demux_ts.c Wed Mar 23 07:43:31 2005 +0000 @@ -1047,7 +1047,7 @@ if(sl->random_accesspoint) rap_flag = getbits(buf, n++, 1); - if((rap_flag || sl->random_accesspoint_only) || (!sl->random_accesspoint && !sl->random_accesspoint_only)) + if(rap_flag || sl->random_accesspoint_only) pes_es->is_synced = 1; n += sl->au_seqnum_len; @@ -2364,7 +2364,7 @@ demux_packet_t **dp = NULL; int *dp_offset = 0, *buffer_size = 0; int32_t progid, pid_type, bad, ts_error; - int junk = 0; + int junk = 0, rap_flag = 0; pmt_t *pmt; @@ -2374,6 +2374,7 @@ ds = (demux_stream_t*) NULL; dp = (demux_packet_t **) NULL; dp_offset = buffer_size = NULL; + rap_flag = 0; junk = priv->ts.packet_size - TS_PACKET_SIZE; buf_size = priv->ts.packet_size - junk; @@ -2430,33 +2431,29 @@ bad = ts_error; // || (! cc_ok); - if(! bad) + afc = (packet[3] >> 4) & 3; + if(afc > 1) { - // skip adaptation field, but only if cc_ok is not corrupt, - //otherwise we may throw away good data - afc = (packet[3] >> 4) & 3; - if(! (afc % 2)) //no payload in this TS packet - { - stream_skip(stream, buf_size-1+junk); - continue; - } - - if(afc == 3) - { - int c; - c = stream_read_char(stream); - buf_size--; - - c = min(c, buf_size); - stream_skip(stream, c); - buf_size -= c; - if(buf_size == 0) - continue; - - afc = c + 1; - } + int c; + c = stream_read_char(stream); + buf_size--; + rap_flag = stream_read_char(stream) & 0x40; + buf_size--; + + c = min(c-1, buf_size); + stream_skip(stream, c); + buf_size -= c; + if(buf_size == 0) + continue; } - else + + if(! (afc % 2)) //no payload in this TS packet + { + stream_skip(stream, buf_size-1+junk); + continue; + } + + if(bad) { // logically this packet should be dropped, but if I do it // certain streams play corrupted. Maybe the decoders know @@ -2652,7 +2649,7 @@ len = pes_parse2(p, buf_size, es, pid_type, pmt, pid); es->pid = tss->pid; - tss->is_synced = es->is_synced; + tss->is_synced = es->is_synced | rap_flag; if(es->type==SL_PES_STREAM && !tss->is_synced) {