comparison libmpdemux/demux_ts.c @ 14992:d1d36694aa3d

consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL)
author nicodvb
date Wed, 23 Mar 2005 07:43:31 +0000
parents 293d3dee2eae
children 218d63292982
comparison
equal deleted inserted replaced
14991:07f1e7669772 14992:d1d36694aa3d
1045 uint64_t dts, cts; 1045 uint64_t dts, cts;
1046 1046
1047 if(sl->random_accesspoint) 1047 if(sl->random_accesspoint)
1048 rap_flag = getbits(buf, n++, 1); 1048 rap_flag = getbits(buf, n++, 1);
1049 1049
1050 if((rap_flag || sl->random_accesspoint_only) || (!sl->random_accesspoint && !sl->random_accesspoint_only)) 1050 if(rap_flag || sl->random_accesspoint_only)
1051 pes_es->is_synced = 1; 1051 pes_es->is_synced = 1;
1052 1052
1053 n += sl->au_seqnum_len; 1053 n += sl->au_seqnum_len;
1054 if(packet_len * 8 <= n+8) 1054 if(packet_len * 8 <= n+8)
1055 return -1; 1055 return -1;
2362 char *p, tmp[TS_FEC_PACKET_SIZE]; 2362 char *p, tmp[TS_FEC_PACKET_SIZE];
2363 demux_stream_t *ds = NULL; 2363 demux_stream_t *ds = NULL;
2364 demux_packet_t **dp = NULL; 2364 demux_packet_t **dp = NULL;
2365 int *dp_offset = 0, *buffer_size = 0; 2365 int *dp_offset = 0, *buffer_size = 0;
2366 int32_t progid, pid_type, bad, ts_error; 2366 int32_t progid, pid_type, bad, ts_error;
2367 int junk = 0; 2367 int junk = 0, rap_flag = 0;
2368 pmt_t *pmt; 2368 pmt_t *pmt;
2369 2369
2370 2370
2371 while(! done) 2371 while(! done)
2372 { 2372 {
2373 bad = ts_error = 0; 2373 bad = ts_error = 0;
2374 ds = (demux_stream_t*) NULL; 2374 ds = (demux_stream_t*) NULL;
2375 dp = (demux_packet_t **) NULL; 2375 dp = (demux_packet_t **) NULL;
2376 dp_offset = buffer_size = NULL; 2376 dp_offset = buffer_size = NULL;
2377 rap_flag = 0;
2377 2378
2378 junk = priv->ts.packet_size - TS_PACKET_SIZE; 2379 junk = priv->ts.packet_size - TS_PACKET_SIZE;
2379 buf_size = priv->ts.packet_size - junk; 2380 buf_size = priv->ts.packet_size - junk;
2380 2381
2381 if(stream_eof(stream)) 2382 if(stream_eof(stream))
2428 cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc)); 2429 cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
2429 tss->last_cc = cc; 2430 tss->last_cc = cc;
2430 2431
2431 bad = ts_error; // || (! cc_ok); 2432 bad = ts_error; // || (! cc_ok);
2432 2433
2433 if(! bad) 2434 afc = (packet[3] >> 4) & 3;
2434 { 2435 if(afc > 1)
2435 // skip adaptation field, but only if cc_ok is not corrupt, 2436 {
2436 //otherwise we may throw away good data 2437 int c;
2437 afc = (packet[3] >> 4) & 3; 2438 c = stream_read_char(stream);
2438 if(! (afc % 2)) //no payload in this TS packet 2439 buf_size--;
2439 { 2440 rap_flag = stream_read_char(stream) & 0x40;
2440 stream_skip(stream, buf_size-1+junk); 2441 buf_size--;
2441 continue; 2442
2442 } 2443 c = min(c-1, buf_size);
2443 2444 stream_skip(stream, c);
2444 if(afc == 3) 2445 buf_size -= c;
2445 { 2446 if(buf_size == 0)
2446 int c; 2447 continue;
2447 c = stream_read_char(stream); 2448 }
2448 buf_size--; 2449
2449 2450 if(! (afc % 2)) //no payload in this TS packet
2450 c = min(c, buf_size); 2451 {
2451 stream_skip(stream, c); 2452 stream_skip(stream, buf_size-1+junk);
2452 buf_size -= c; 2453 continue;
2453 if(buf_size == 0) 2454 }
2454 continue; 2455
2455 2456 if(bad)
2456 afc = c + 1;
2457 }
2458 }
2459 else
2460 { 2457 {
2461 // logically this packet should be dropped, but if I do it 2458 // logically this packet should be dropped, but if I do it
2462 // certain streams play corrupted. Maybe the decoders know 2459 // certain streams play corrupted. Maybe the decoders know
2463 // how to deal with it, but at least I consider the packet 2460 // how to deal with it, but at least I consider the packet
2464 // as "not initial" 2461 // as "not initial"
2650 stream_read(stream, p, buf_size); 2647 stream_read(stream, p, buf_size);
2651 stream_skip(stream, junk); 2648 stream_skip(stream, junk);
2652 2649
2653 len = pes_parse2(p, buf_size, es, pid_type, pmt, pid); 2650 len = pes_parse2(p, buf_size, es, pid_type, pmt, pid);
2654 es->pid = tss->pid; 2651 es->pid = tss->pid;
2655 tss->is_synced = es->is_synced; 2652 tss->is_synced = es->is_synced | rap_flag;
2656 2653
2657 if(es->type==SL_PES_STREAM && !tss->is_synced) 2654 if(es->type==SL_PES_STREAM && !tss->is_synced)
2658 { 2655 {
2659 if(probe) 2656 if(probe)
2660 return 0; 2657 return 0;