gf_m2ts_process_data:
 2922|    265|{
 2923|    265|	GF_Err e=GF_OK;
 2924|    265|	u32 pos, pck_size;
 2925|    265|	Bool is_align = 1;
 2926|       |
 2927|    265|	if (ts->buffer_size) {
  ------------------
  |  Branch (2927:6): [True: 0, False: 265]
  ------------------
 2928|       |		//we are sync, copy remaining bytes
 2929|      0|		if ( (ts->buffer[0]==0x47) && (ts->buffer_size<200)) {
  ------------------
  |  Branch (2929:8): [True: 0, False: 0]
  |  Branch (2929:33): [True: 0, False: 0]
  ------------------
 2930|      0|			u32 copy_size;
 2931|      0|			pck_size = ts->prefix_present ? 192 : 188;
  ------------------
  |  Branch (2931:15): [True: 0, False: 0]
  ------------------
 2932|       |
 2933|      0|			if (ts->alloc_size < 200) {
  ------------------
  |  Branch (2933:8): [True: 0, False: 0]
  ------------------
 2934|      0|				ts->alloc_size = 200;
 2935|      0|				ts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);
 2936|      0|			}
 2937|      0|			copy_size = pck_size - ts->buffer_size;
 2938|      0|			if (copy_size > data_size) {
  ------------------
  |  Branch (2938:8): [True: 0, False: 0]
  ------------------
 2939|      0|				memcpy(ts->buffer + ts->buffer_size, data, data_size);
 2940|      0|				ts->buffer_size += data_size;
 2941|      0|				return GF_OK;
 2942|      0|			}
 2943|      0|			memcpy(ts->buffer + ts->buffer_size, data, copy_size);
 2944|      0|			e |= gf_m2ts_process_packet(ts, (unsigned char *)ts->buffer);
 2945|      0|			data += copy_size;
 2946|      0|			data_size = data_size - copy_size;
 2947|      0|			gf_assert((s32)data_size >= 0);
 2948|      0|		}
 2949|       |		//not sync, copy over the complete buffer
 2950|      0|		else {
 2951|      0|			if (ts->alloc_size < ts->buffer_size+data_size) {
  ------------------
  |  Branch (2951:8): [True: 0, False: 0]
  ------------------
 2952|      0|				ts->alloc_size = ts->buffer_size+data_size;
 2953|      0|				ts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);
 2954|      0|			}
 2955|      0|			memcpy(ts->buffer + ts->buffer_size, data, sizeof(char)*data_size);
 2956|      0|			ts->buffer_size += data_size;
 2957|      0|			is_align = 0;
 2958|      0|			data = ts->buffer;
 2959|      0|			data_size = ts->buffer_size;
 2960|      0|		}
 2961|      0|	}
 2962|       |
 2963|       |	/*sync input data*/
 2964|    265|	pos = gf_m2ts_sync(ts, data, data_size, is_align);
 2965|    265|	if (pos==data_size) {
  ------------------
  |  Branch (2965:6): [True: 66, False: 199]
  ------------------
 2966|     66|		if (is_align) {
  ------------------
  |  Branch (2966:7): [True: 66, False: 0]
  ------------------
 2967|     66|			if (ts->alloc_size<data_size) {
  ------------------
  |  Branch (2967:8): [True: 66, False: 0]
  ------------------
 2968|     66|				ts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*data_size);
 2969|     66|				ts->alloc_size = data_size;
 2970|     66|			}
 2971|     66|			memcpy(ts->buffer, data, sizeof(char)*data_size);
 2972|     66|			ts->buffer_size = data_size;
 2973|     66|		}
 2974|     66|		return GF_OK;
 2975|     66|	}
 2976|    199|	pck_size = ts->prefix_present ? 192 : 188;
  ------------------
  |  Branch (2976:13): [True: 16, False: 183]
  ------------------
 2977|    861|	for (;;) {
 2978|       |		/*wait for a complete packet*/
 2979|    861|		if (data_size < pos  + pck_size) {
  ------------------
  |  Branch (2979:7): [True: 199, False: 662]
  ------------------
 2980|    199|			ts->buffer_size = data_size - pos;
 2981|    199|			data += pos;
 2982|    199|			if (!ts->buffer_size) {
  ------------------
  |  Branch (2982:8): [True: 122, False: 77]
  ------------------
 2983|    122|				return e;
 2984|    122|			}
 2985|     77|			gf_assert(ts->buffer_size<pck_size);
 2986|       |
 2987|     77|			if (is_align) {
  ------------------
  |  Branch (2987:8): [True: 77, False: 0]
  ------------------
 2988|     77|				u32 s = ts->buffer_size;
 2989|     77|				if (s<200) s = 200;
  ------------------
  |  Branch (2989:9): [True: 77, False: 0]
  ------------------
 2990|       |
 2991|     77|				if (ts->alloc_size < s) {
  ------------------
  |  Branch (2991:9): [True: 77, False: 0]
  ------------------
 2992|     77|					ts->alloc_size = s;
 2993|     77|					ts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);
 2994|     77|				}
 2995|     77|				memcpy(ts->buffer, data, sizeof(char)*ts->buffer_size);
 2996|     77|			} else {
 2997|      0|				memmove(ts->buffer, data, sizeof(char)*ts->buffer_size);
 2998|      0|			}
 2999|     77|			return e;
 3000|    199|		}
 3001|       |		/*process*/
 3002|    662|		GF_Err pck_e = gf_m2ts_process_packet(ts, (unsigned char *)data + pos);
 3003|    662|		if (pck_e==GF_NOT_SUPPORTED) pck_e = GF_OK;
  ------------------
  |  Branch (3003:7): [True: 102, False: 560]
  ------------------
 3004|    662|		e |= pck_e;
 3005|       |
 3006|    662|		pos += pck_size;
 3007|    662|	}
 3008|      0|	return e;
 3009|    199|}
gf_m2ts_demux_new:
 3254|    265|{
 3255|    265|	GF_M2TS_Demuxer *ts;
 3256|       |
 3257|    265|	GF_SAFEALLOC(ts, GF_M2TS_Demuxer);
  ------------------
  |  |  242|    265|#define GF_SAFEALLOC(__ptr, __struct) {\
  |  |  243|    265|		(__ptr) = (__struct *) gf_malloc(sizeof(__struct));\
  |  |  244|    265|		if (__ptr) {\
  |  |  ------------------
  |  |  |  Branch (244:7): [True: 265, False: 0]
  |  |  ------------------
  |  |  245|    265|			memset((void *) (__ptr), 0, sizeof(__struct));\
  |  |  246|    265|		}\
  |  |  247|    265|	}
  ------------------
 3258|    265|	if (!ts) return NULL;
  ------------------
  |  Branch (3258:6): [True: 0, False: 265]
  ------------------
 3259|    265|	ts->programs = gf_list_new();
 3260|    265|	ts->SDTs = gf_list_new();
 3261|       |
 3262|    265|	ts->pat = gf_m2ts_section_filter_new(gf_m2ts_process_pat, 0);
 3263|    265|	ts->cat = gf_m2ts_section_filter_new(gf_m2ts_process_cat, 0);
 3264|    265|	ts->sdt = gf_m2ts_section_filter_new(gf_m2ts_process_sdt, 1);
 3265|    265|	ts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0);
 3266|    265|	ts->eit = gf_m2ts_section_filter_new(NULL/*gf_m2ts_process_eit*/, 1);
 3267|    265|	ts->tdt_tot = gf_m2ts_section_filter_new(gf_m2ts_process_tdt_tot, 1);
 3268|       |
 3269|       |#ifdef GPAC_ENABLE_MPE
 3270|       |	gf_dvb_mpe_init(ts);
 3271|       |#endif
 3272|       |
 3273|    265|	ts->nb_prog_pmt_received = 0;
 3274|    265|	ts->ChannelAppList = gf_list_new();
 3275|    265|	return ts;
 3276|    265|}
gf_m2ts_demux_del:
 3305|    265|{
 3306|    265|	u32 i;
 3307|    265|	if (ts->pat) gf_m2ts_section_filter_del(ts->pat);
  ------------------
  |  Branch (3307:6): [True: 265, False: 0]
  ------------------
 3308|    265|	if (ts->cat) gf_m2ts_section_filter_del(ts->cat);
  ------------------
  |  Branch (3308:6): [True: 265, False: 0]
  ------------------
 3309|    265|	if (ts->sdt) gf_m2ts_section_filter_del(ts->sdt);
  ------------------
  |  Branch (3309:6): [True: 265, False: 0]
  ------------------
 3310|    265|	if (ts->nit) gf_m2ts_section_filter_del(ts->nit);
  ------------------
  |  Branch (3310:6): [True: 265, False: 0]
  ------------------
 3311|    265|	if (ts->eit) gf_m2ts_section_filter_del(ts->eit);
  ------------------
  |  Branch (3311:6): [True: 265, False: 0]
  ------------------
 3312|    265|	if (ts->tdt_tot) gf_m2ts_section_filter_del(ts->tdt_tot);
  ------------------
  |  Branch (3312:6): [True: 265, False: 0]
  ------------------
 3313|       |
 3314|  2.17M|	for (i=0; i<GF_M2TS_MAX_STREAMS; i++) {
  ------------------
  |  |  366|  2.17M|#define GF_M2TS_MAX_STREAMS	8192
  ------------------
  |  Branch (3314:12): [True: 2.17M, False: 265]
  ------------------
 3315|       |		//because of pure PCR streams, an ES might be reassigned on 2 PIDs, one for the ES and one for the PCR
 3316|  2.17M|		if (ts->ess[i] && (ts->ess[i]->pid==i)) {
  ------------------
  |  Branch (3316:7): [True: 0, False: 2.17M]
  |  Branch (3316:21): [True: 0, False: 0]
  ------------------
 3317|      0|			gf_m2ts_es_del(ts->ess[i], ts);
 3318|      0|		}
 3319|  2.17M|	}
 3320|    265|	if (ts->buffer) gf_free(ts->buffer);
  ------------------
  |  Branch (3320:6): [True: 143, False: 122]
  ------------------
 3321|    265|	while (gf_list_count(ts->programs)) {
  ------------------
  |  Branch (3321:9): [True: 0, False: 265]
  ------------------
 3322|      0|		GF_M2TS_Program *p = (GF_M2TS_Program *)gf_list_last(ts->programs);
 3323|      0|		gf_list_rem_last(ts->programs);
 3324|       |
 3325|      0|		while (gf_list_count(p->streams)) {
  ------------------
  |  Branch (3325:10): [True: 0, False: 0]
  ------------------
 3326|      0|			GF_M2TS_ES *es = (GF_M2TS_ES *)gf_list_last(p->streams);
 3327|      0|			gf_list_rem_last(p->streams);
 3328|       |			//force destroy
 3329|      0|			es->flags &= ~GF_M2TS_ES_IS_PCR_REUSE;
 3330|      0|			gf_m2ts_es_del(es, ts);
 3331|      0|		}
 3332|      0|		gf_list_del(p->streams);
 3333|       |		/*reset OD list*/
 3334|      0|		if (p->additional_ods) {
  ------------------
  |  Branch (3334:7): [True: 0, False: 0]
  ------------------
 3335|      0|			gf_odf_desc_list_del(p->additional_ods);
 3336|      0|			gf_list_del(p->additional_ods);
 3337|      0|		}
 3338|      0|		if (p->pmt_iod) gf_odf_desc_del((GF_Descriptor *)p->pmt_iod);
  ------------------
  |  Branch (3338:7): [True: 0, False: 0]
  ------------------
 3339|      0|		if (p->metadata_pointer_descriptor)	gf_m2ts_metadata_pointer_descriptor_del(p->metadata_pointer_descriptor);
  ------------------
  |  Branch (3339:7): [True: 0, False: 0]
  ------------------
 3340|      0|		gf_free(p);
 3341|      0|	}
 3342|    265|	gf_list_del(ts->programs);
 3343|       |
 3344|    265|	if (ts->TDT_time) gf_free(ts->TDT_time);
  ------------------
  |  Branch (3344:6): [True: 0, False: 265]
  ------------------
 3345|    265|	gf_m2ts_reset_sdt(ts);
 3346|    265|	if (ts->tdt_tot)
  ------------------
  |  Branch (3346:6): [True: 265, False: 0]
  ------------------
 3347|    265|		gf_list_del(ts->SDTs);
 3348|       |
 3349|       |#ifdef GPAC_ENABLE_MPE
 3350|       |	gf_dvb_mpe_shutdown(ts);
 3351|       |#endif
 3352|       |
 3353|    265|	if (ts->dsmcc_controler) {
  ------------------
  |  Branch (3353:6): [True: 0, False: 265]
  ------------------
 3354|      0|		if (gf_list_count(ts->dsmcc_controler)) {
  ------------------
  |  Branch (3354:7): [True: 0, False: 0]
  ------------------
 3355|       |#ifdef GPAC_ENABLE_DSMCC
 3356|       |			GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord = (GF_M2TS_DSMCC_OVERLORD*)gf_list_get(ts->dsmcc_controler,0);
 3357|       |			gf_dir_cleanup(dsmcc_overlord->root_dir);
 3358|       |			gf_rmdir(dsmcc_overlord->root_dir);
 3359|       |			gf_m2ts_delete_dsmcc_overlord(dsmcc_overlord);
 3360|       |			if(ts->dsmcc_root_dir) {
 3361|       |				gf_free(ts->dsmcc_root_dir);
 3362|       |			}
 3363|       |#endif
 3364|      0|		}
 3365|      0|		gf_list_del(ts->dsmcc_controler);
 3366|      0|	}
 3367|       |
 3368|    265|	while(gf_list_count(ts->ChannelAppList)) {
  ------------------
  |  Branch (3368:8): [True: 0, False: 265]
  ------------------
 3369|       |#ifdef GPAC_ENABLE_DSMCC
 3370|       |		GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo = (GF_M2TS_CHANNEL_APPLICATION_INFO*)gf_list_get(ts->ChannelAppList,0);
 3371|       |		gf_m2ts_delete_channel_application_info(ChanAppInfo);
 3372|       |		gf_list_rem(ts->ChannelAppList,0);
 3373|       |#endif
 3374|      0|	}
 3375|    265|	gf_list_del(ts->ChannelAppList);
 3376|       |
 3377|    265|	if (ts->dsmcc_root_dir) gf_free(ts->dsmcc_root_dir);
  ------------------
  |  Branch (3377:6): [True: 0, False: 265]
  ------------------
 3378|    265|	gf_free(ts);
 3379|    265|}
gf_m2ts_probe_file:
 3433|    265|{
 3434|    265|	char buf[M2TS_PROBE_SIZE];
 3435|    265|	u32 size;
 3436|       |
 3437|    265|	if (!strncmp(fileName, "gmem://", 7)) {
  ------------------
  |  Branch (3437:6): [True: 0, False: 265]
  ------------------
 3438|      0|		u8 *mem_address;
 3439|      0|		if (gf_blob_get(fileName, &mem_address, &size, NULL) != GF_OK) {
  ------------------
  |  Branch (3439:7): [True: 0, False: 0]
  ------------------
 3440|      0|			return GF_FALSE;
 3441|      0|		}
 3442|      0|		if (size>M2TS_PROBE_SIZE) size = M2TS_PROBE_SIZE;
  ------------------
  |  | 3391|      0|#define M2TS_PROBE_SIZE	188*20
  ------------------
              		if (size>M2TS_PROBE_SIZE) size = M2TS_PROBE_SIZE;
  ------------------
  |  | 3391|      0|#define M2TS_PROBE_SIZE	188*20
  ------------------
  |  Branch (3442:7): [True: 0, False: 0]
  ------------------
 3443|      0|		memcpy(buf, mem_address, size);
 3444|      0|        gf_blob_release(fileName);
 3445|    265|	} else {
 3446|    265|		FILE *t = gf_fopen(fileName, "rb");
 3447|    265|		if (!t) return 0;
  ------------------
  |  Branch (3447:7): [True: 0, False: 265]
  ------------------
 3448|    265|		size = (u32) gf_fread(buf, M2TS_PROBE_SIZE, t);
  ------------------
  |  | 3391|    265|#define M2TS_PROBE_SIZE	188*20
  ------------------
 3449|    265|		gf_fclose(t);
 3450|    265|		if ((s32) size <= 0) return 0;
  ------------------
  |  Branch (3450:7): [True: 0, False: 265]
  ------------------
 3451|    265|	}
 3452|    265|	return gf_m2ts_probe_buffer(buf, size);
 3453|    265|}
mpegts.c:gf_m2ts_process_packet:
 2622|    662|{
 2623|    662|	GF_M2TS_ES *es;
 2624|    662|	GF_M2TS_Header hdr;
 2625|    662|	GF_M2TS_AdaptationField af, *paf;
 2626|    662|	u32 payload_size, af_size;
 2627|    662|	u32 pos = 0;
 2628|       |
 2629|    662|	ts->pck_number++;
 2630|       |
 2631|       |	/* read TS packet header*/
 2632|    662|	hdr.sync = data[0];
 2633|    662|	if (hdr.sync != 0x47) {
  ------------------
  |  Branch (2633:6): [True: 162, False: 500]
  ------------------
 2634|    162|		GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] TS Packet %d does not start with sync marker\n", ts->pck_number));
  ------------------
  |  | 1086|    162|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 162]
  |  |  ------------------
  ------------------
 2635|    162|		if (ts->raw_mode == GF_M2TS_RAW_PROBE)
  ------------------
  |  Branch (2635:7): [True: 162, False: 0]
  ------------------
 2636|    162|			ts->pck_errors++;
 2637|      0|		else
 2638|      0|			ts->pck_number--;
 2639|    162|		return GF_CORRUPTED_DATA;
 2640|    162|	}
 2641|    500|	hdr.error = (data[1] & 0x80) ? 1 : 0;
  ------------------
  |  Branch (2641:14): [True: 48, False: 452]
  ------------------
 2642|    500|	hdr.payload_start = (data[1] & 0x40) ? 1 : 0;
  ------------------
  |  Branch (2642:22): [True: 377, False: 123]
  ------------------
 2643|    500|	hdr.priority = (data[1] & 0x20) ? 1 : 0;
  ------------------
  |  Branch (2643:17): [True: 60, False: 440]
  ------------------
 2644|    500|	hdr.pid = ( (data[1]&0x1f) << 8) | data[2];
 2645|    500|	hdr.scrambling_ctrl = (data[3] >> 6) & 0x3;
 2646|    500|	hdr.adaptation_field = (data[3] >> 4) & 0x3;
 2647|    500|	hdr.continuity_counter = data[3] & 0xf;
 2648|       |
 2649|    500|	if (hdr.error) {
  ------------------
  |  Branch (2649:6): [True: 48, False: 452]
  ------------------
 2650|     48|		GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] TS Packet %d has error (PID could be %d)\n", ts->pck_number, hdr.pid));
  ------------------
  |  | 1086|     48|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 48]
  |  |  ------------------
  ------------------
 2651|     48|		ts->pck_errors++;
 2652|     48|		return GF_CORRUPTED_DATA;
 2653|     48|	}
 2654|       |//#if DEBUG_TS_PACKET
 2655|    452|	GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] TS Packet %d PID %d CC %d Encrypted %d\n", ts->pck_number, hdr.pid, hdr.continuity_counter, hdr.scrambling_ctrl));
  ------------------
  |  | 1086|    452|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 452]
  |  |  ------------------
  ------------------
 2656|       |//#endif
 2657|       |
 2658|    452|	if (hdr.scrambling_ctrl) {
  ------------------
  |  Branch (2658:6): [True: 102, False: 350]
  ------------------
 2659|    102|		if (ts->raw_mode==GF_M2TS_RAW_FORWARD) {
  ------------------
  |  Branch (2659:7): [True: 0, False: 102]
  ------------------
 2660|      0|			GF_M2TS_TSPCK tspck;
 2661|      0|			memset(&tspck, 0, sizeof(GF_M2TS_TSPCK));
 2662|      0|			tspck.data = data - pos;
 2663|      0|			ts->on_event(ts, GF_M2TS_EVT_PCK, &tspck);
 2664|      0|			return GF_OK;
 2665|      0|		}
 2666|       |		//TODO add decyphering API ?
 2667|    102|		GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] TS Packet %d is scrambled - not supported\n", ts->pck_number, hdr.pid));
  ------------------
  |  | 1086|    102|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 102]
  |  |  ------------------
  ------------------
 2668|    102|		return GF_NOT_SUPPORTED;
 2669|    102|	}
 2670|       |
 2671|    350|	paf = NULL;
 2672|    350|	payload_size = 184;
 2673|    350|	pos = 4;
 2674|    350|	switch (hdr.adaptation_field) {
 2675|       |	/*adaptation+data*/
 2676|    150|	case 3:
  ------------------
  |  Branch (2676:2): [True: 150, False: 200]
  ------------------
 2677|    150|		af_size = data[4];
 2678|    150|		if (af_size>183) {
  ------------------
  |  Branch (2678:7): [True: 43, False: 107]
  ------------------
 2679|     43|			GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] TS Packet %d AF field larger than 183  for AF type 3!\n", ts->pck_number));
  ------------------
  |  | 1086|     43|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 43]
  |  |  ------------------
  ------------------
 2680|       |			//error
 2681|     43|			ts->pck_errors++;
 2682|     43|			return GF_CORRUPTED_DATA;
 2683|     43|		}
 2684|    107|		if (ts->raw_mode==GF_M2TS_RAW_PROBE) return GF_OK;
  ------------------
  |  Branch (2684:7): [True: 107, False: 0]
  ------------------
 2685|      0|		paf = &af;
 2686|      0|		memset(paf, 0, sizeof(GF_M2TS_AdaptationField));
 2687|      0|		if (af_size) gf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid);
  ------------------
  |  Branch (2687:7): [True: 0, False: 0]
  ------------------
 2688|      0|		pos += 1+af_size;
 2689|      0|		payload_size = 183 - af_size;
 2690|      0|		break;
 2691|       |	/*adaptation only - still process in case of PCR*/
 2692|    117|	case 2:
  ------------------
  |  Branch (2692:2): [True: 117, False: 233]
  ------------------
 2693|    117|		af_size = data[4];
 2694|    117|		if (af_size != 183) {
  ------------------
  |  Branch (2694:7): [True: 69, False: 48]
  ------------------
 2695|     69|			GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] TS Packet %d AF size is %d when it must be 183 for AF type 2\n", ts->pck_number, af_size));
  ------------------
  |  | 1086|     69|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 69]
  |  |  ------------------
  ------------------
 2696|     69|			ts->pck_errors++;
 2697|     69|			return GF_CORRUPTED_DATA;
 2698|     69|		}
 2699|     48|		if (ts->raw_mode==GF_M2TS_RAW_PROBE) return GF_OK;
  ------------------
  |  Branch (2699:7): [True: 48, False: 0]
  ------------------
 2700|      0|		paf = &af;
 2701|      0|		memset(paf, 0, sizeof(GF_M2TS_AdaptationField));
 2702|      0|		gf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid);
 2703|      0|		payload_size = 0;
 2704|       |		/*no payload and no PCR, return*/
 2705|      0|		if (!paf->PCR_flag)
  ------------------
  |  Branch (2705:7): [True: 0, False: 0]
  ------------------
 2706|      0|			return GF_OK;
 2707|      0|		break;
 2708|       |	/*reserved*/
 2709|     42|	case 0:
  ------------------
  |  Branch (2709:2): [True: 42, False: 308]
  ------------------
 2710|     42|		return GF_OK;
 2711|     41|	default:
  ------------------
  |  Branch (2711:2): [True: 41, False: 309]
  ------------------
 2712|     41|		if (ts->raw_mode==GF_M2TS_RAW_PROBE) return GF_OK;
  ------------------
  |  Branch (2712:7): [True: 41, False: 0]
  ------------------
 2713|      0|		break;
 2714|    350|	}
 2715|      0|	data += pos;
 2716|       |
 2717|       |	/*PAT*/
 2718|      0|	if (hdr.pid == GF_M2TS_PID_PAT) {
  ------------------
  |  Branch (2718:6): [True: 0, False: 0]
  ------------------
 2719|      0|		if (ts->raw_mode==GF_M2TS_RAW_FORWARD) {
  ------------------
  |  Branch (2719:7): [True: 0, False: 0]
  ------------------
 2720|      0|			GF_M2TS_TSPCK tspck;
 2721|      0|			memset(&tspck, 0, sizeof(GF_M2TS_TSPCK));
 2722|      0|			tspck.data = data - pos;
 2723|      0|			ts->on_event(ts, GF_M2TS_EVT_PCK, &tspck);
 2724|      0|			return GF_OK;
 2725|      0|		}
 2726|      0|		gf_m2ts_gather_section(ts, ts->pat, NULL, &hdr, data, payload_size);
 2727|      0|		return GF_OK;
 2728|      0|	}
 2729|       |
 2730|      0|	es = ts->ess[hdr.pid];
 2731|       |	//we work in split mode
 2732|      0|	if (ts->raw_mode) {
  ------------------
  |  Branch (2732:6): [True: 0, False: 0]
  ------------------
 2733|      0|		if (ts->raw_mode==GF_M2TS_RAW_PROBE) return GF_OK;
  ------------------
  |  Branch (2733:7): [True: 0, False: 0]
  ------------------
 2734|       |
 2735|      0|		GF_M2TS_TSPCK tspck;
 2736|       |		//process PMT table
 2737|      0|		if (es && (es->flags & GF_M2TS_ES_IS_PMT)) {
  ------------------
  |  Branch (2737:7): [True: 0, False: 0]
  |  Branch (2737:13): [True: 0, False: 0]
  ------------------
 2738|      0|			GF_M2TS_SECTION_ES *ses = (GF_M2TS_SECTION_ES *)es;
 2739|      0|			if (ses->sec) gf_m2ts_gather_section(ts, ses->sec, ses, &hdr, data, payload_size);
  ------------------
  |  Branch (2739:8): [True: 0, False: 0]
  ------------------
 2740|      0|		}
 2741|       |		//and forward every packet other than PAT
 2742|      0|		memset(&tspck, 0, sizeof(GF_M2TS_TSPCK));
 2743|      0|		tspck.stream = es;
 2744|      0|		tspck.pid = hdr.pid;
 2745|      0|		tspck.data = data - pos;
 2746|      0|		if (paf && paf->PCR_flag) {
  ------------------
  |  Branch (2746:7): [True: 0, False: 0]
  |  Branch (2746:14): [True: 0, False: 0]
  ------------------
 2747|      0|			tspck.pcr_plus_one = paf->PCR_base * 300 + paf->PCR_ext;
 2748|      0|		}
 2749|      0|		ts->on_event(ts, GF_M2TS_EVT_PCK, &tspck);
 2750|      0|		return GF_OK;
 2751|      0|	}
 2752|       |
 2753|      0|	if (hdr.pid == GF_M2TS_PID_CAT) {
  ------------------
  |  Branch (2753:6): [True: 0, False: 0]
  ------------------
 2754|      0|		gf_m2ts_gather_section(ts, ts->cat, NULL, &hdr, data, payload_size);
 2755|      0|		return GF_OK;
 2756|      0|	}
 2757|       |
 2758|      0|	if (paf && paf->PCR_flag) {
  ------------------
  |  Branch (2758:6): [True: 0, False: 0]
  |  Branch (2758:13): [True: 0, False: 0]
  ------------------
 2759|      0|		if (!es) {
  ------------------
  |  Branch (2759:7): [True: 0, False: 0]
  ------------------
 2760|      0|			u32 i, j;
 2761|      0|			for(i=0; i<gf_list_count(ts->programs); i++) {
  ------------------
  |  Branch (2761:13): [True: 0, False: 0]
  ------------------
 2762|      0|				GF_M2TS_PES *first_pes = NULL;
 2763|      0|				GF_M2TS_Program *program = (GF_M2TS_Program *)gf_list_get(ts->programs,i);
 2764|      0|				if(program->pcr_pid != hdr.pid) continue;
  ------------------
  |  Branch (2764:8): [True: 0, False: 0]
  ------------------
 2765|      0|				for (j=0; j<gf_list_count(program->streams); j++) {
  ------------------
  |  Branch (2765:15): [True: 0, False: 0]
  ------------------
 2766|      0|					GF_M2TS_PES *pes = (GF_M2TS_PES *) gf_list_get(program->streams, j);
 2767|      0|					if (pes->flags & GF_M2TS_INHERIT_PCR) {
  ------------------
  |  Branch (2767:10): [True: 0, False: 0]
  ------------------
 2768|      0|						ts->ess[hdr.pid] = (GF_M2TS_ES *) pes;
 2769|      0|						pes->flags |= GF_M2TS_FAKE_PCR | GF_M2TS_ES_IS_PCR_REUSE;
 2770|      0|						break;
 2771|      0|					}
 2772|      0|					if (pes->flags & GF_M2TS_ES_IS_PES) {
  ------------------
  |  Branch (2772:10): [True: 0, False: 0]
  ------------------
 2773|      0|						first_pes = pes;
 2774|      0|					}
 2775|      0|				}
 2776|       |				//non found, use the first media stream as a PCR destination - Q: is it legal to have PCR only streams not declared in PMT ?
 2777|      0|				if (!es && first_pes) {
  ------------------
  |  Branch (2777:9): [True: 0, False: 0]
  |  Branch (2777:16): [True: 0, False: 0]
  ------------------
 2778|      0|					es = (GF_M2TS_ES *) first_pes;
 2779|      0|					first_pes->flags |= GF_M2TS_FAKE_PCR;
 2780|      0|				}
 2781|      0|				break;
 2782|      0|			}
 2783|      0|			if (!es)
  ------------------
  |  Branch (2783:8): [True: 0, False: 0]
  ------------------
 2784|      0|				es = ts->ess[hdr.pid];
 2785|      0|		}
 2786|      0|		if (es) {
  ------------------
  |  Branch (2786:7): [True: 0, False: 0]
  ------------------
 2787|      0|			GF_M2TS_PES_PCK pck;
 2788|      0|			s64 prev_diff_in_us;
 2789|      0|			Bool discontinuity;
 2790|      0|			s32 cc = -1;
 2791|       |
 2792|      0|			if (es->flags & GF_M2TS_FAKE_PCR) {
  ------------------
  |  Branch (2792:8): [True: 0, False: 0]
  ------------------
 2793|      0|				cc = es->program->pcr_cc;
 2794|      0|				es->program->pcr_cc = hdr.continuity_counter;
 2795|      0|			}
 2796|      0|			else if (es->flags & GF_M2TS_ES_IS_PES) cc = ((GF_M2TS_PES*)es)->cc;
  ------------------
  |  Branch (2796:13): [True: 0, False: 0]
  ------------------
 2797|      0|			else if (((GF_M2TS_SECTION_ES*)es)->sec) cc = ((GF_M2TS_SECTION_ES*)es)->sec->cc;
  ------------------
  |  Branch (2797:13): [True: 0, False: 0]
  ------------------
 2798|       |
 2799|      0|			discontinuity = paf->discontinuity_indicator;
 2800|      0|			if ((cc>=0) && es->program->before_last_pcr_value) {
  ------------------
  |  Branch (2800:8): [True: 0, False: 0]
  |  Branch (2800:19): [True: 0, False: 0]
  ------------------
 2801|       |				//no increment of CC if AF only packet
 2802|      0|				if (hdr.adaptation_field == 2) {
  ------------------
  |  Branch (2802:9): [True: 0, False: 0]
  ------------------
 2803|      0|					if (hdr.continuity_counter != cc) {
  ------------------
  |  Branch (2803:10): [True: 0, False: 0]
  ------------------
 2804|      0|						discontinuity = GF_TRUE;
 2805|      0|					}
 2806|      0|				} else if (hdr.continuity_counter != ((cc + 1) & 0xF)) {
  ------------------
  |  Branch (2806:16): [True: 0, False: 0]
  ------------------
 2807|      0|					discontinuity = GF_TRUE;
 2808|      0|				}
 2809|      0|			}
 2810|       |
 2811|      0|			s64 pcr_diff=0;
 2812|      0|			memset(&pck, 0, sizeof(GF_M2TS_PES_PCK));
 2813|      0|			prev_diff_in_us = (s64) (es->program->last_pcr_value - es->program->before_last_pcr_value)/27;
 2814|      0|			es->program->before_last_pcr_value = es->program->last_pcr_value;
 2815|      0|			es->program->before_last_pcr_value_pck_number = es->program->last_pcr_value_pck_number;
 2816|      0|			es->program->last_pcr_value_pck_number = ts->pck_number;
 2817|      0|			es->program->last_pcr_value = paf->PCR_base * 300 + paf->PCR_ext;
 2818|      0|			if (!es->program->last_pcr_value) es->program->last_pcr_value =  1;
  ------------------
  |  Branch (2818:8): [True: 0, False: 0]
  ------------------
 2819|       |
 2820|      0|			if (es->program->before_last_pcr_value) {
  ------------------
  |  Branch (2820:8): [True: 0, False: 0]
  ------------------
 2821|      0|				pcr_diff = es->program->last_pcr_value;
 2822|      0|				pcr_diff -= es->program->before_last_pcr_value;
 2823|       |
 2824|      0|				GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d PCR found "LLU" ("LLU" at 90kHz) - PCR diff is %d us\n", hdr.pid, es->program->last_pcr_value, es->program->last_pcr_value/300, (s32) (pcr_diff)/27 ));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2825|      0|			} else {
 2826|      0|				GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d PCR found "LLU" ("LLU" at 90kHz)\n", hdr.pid, es->program->last_pcr_value, es->program->last_pcr_value/300));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2827|      0|			}
 2828|       |
 2829|      0|			pck.PTS = es->program->last_pcr_value;
 2830|      0|			pck.stream = (GF_M2TS_PES *)es;
 2831|       |
 2832|       |			//try to ignore all discontinuities that are less than 200 ms (seen in some HLS setup ...)
 2833|      0|			Bool adjust_pcr=GF_FALSE;
 2834|      0|			if (discontinuity) {
  ------------------
  |  Branch (2834:8): [True: 0, False: 0]
  ------------------
 2835|      0|				s64 diff_in_us = (s64) (es->program->last_pcr_value - es->program->before_last_pcr_value) / 27;
 2836|      0|				u64 diff = ABS(diff_in_us - prev_diff_in_us);
  ------------------
  |  |  467|      0|#define ABS(a)	( ( (a) > 0 ) ? (a) : - (a) )
  |  |  ------------------
  |  |  |  Branch (467:18): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2837|       |
 2838|      0|				if ((diff_in_us<0) && (diff_in_us >= -200000)) {
  ------------------
  |  Branch (2838:9): [True: 0, False: 0]
  |  Branch (2838:27): [True: 0, False: 0]
  ------------------
 2839|      0|					GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d new PCR, with discontinuity signaled, is less than previously received PCR (diff %d us) but not too large, trying to ignore discontinuity\n", hdr.pid, diff_in_us));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2840|      0|				}
 2841|       |
 2842|       |				//ignore PCR discontinuity indicator if PCR found is larger than previously received PCR and diffence between PCR before and after discontinuity indicator is smaller than 50ms
 2843|      0|				else if ((diff_in_us > 0) && (diff < 200000)) {
  ------------------
  |  Branch (2843:14): [True: 0, False: 0]
  |  Branch (2843:34): [True: 0, False: 0]
  ------------------
 2844|      0|					GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d PCR discontinuity signaled but diff is small (diff %d us - PCR diff %d vs prev PCR diff %d) - ignore it\n", hdr.pid, diff, diff_in_us, prev_diff_in_us));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2845|      0|				} else if (paf->discontinuity_indicator) {
  ------------------
  |  Branch (2845:16): [True: 0, False: 0]
  ------------------
 2846|      0|					GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d PCR discontinuity signaled (diff %d us - PCR diff %d vs prev PCR diff %d)\n", hdr.pid, diff, diff_in_us, prev_diff_in_us));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2847|      0|					pck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;
 2848|      0|				} else {
 2849|      0|					GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d PCR discontinuity not signaled (diff %d us - PCR diff %d vs prev PCR diff %d)\n", hdr.pid, diff, diff_in_us, prev_diff_in_us));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2850|      0|					pck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;
 2851|      0|				}
 2852|      0|				adjust_pcr = GF_TRUE;
 2853|      0|			}
 2854|      0|			else if ((es->flags & GF_M2TS_CHECK_DISC) && ABS(pcr_diff)>270000000 ) {
  ------------------
  |  |  467|      0|#define ABS(a)	( ( (a) > 0 ) ? (a) : - (a) )
  |  |  ------------------
  |  |  |  Branch (467:18): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2854:13): [True: 0, False: 0]
  |  Branch (2854:49): [True: 0, False: 0]
  ------------------
 2855|      0|				s64 diff_in_us = (s64) (pcr_diff) / 27;
 2856|       |				//if less than 200 ms before PCR loop at the last PCR, this is a PCR loop
 2857|      0|				if (GF_M2TS_MAX_PCR - es->program->before_last_pcr_value < 5400000 /*2*2700000*/) {
  ------------------
  |  |  372|      0|#define GF_M2TS_MAX_PCR	2576980377811ULL
  ------------------
  |  Branch (2857:9): [True: 0, False: 0]
  ------------------
 2858|      0|					GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d PCR loop found from "LLU" to "LLU" \n", hdr.pid, es->program->before_last_pcr_value, es->program->last_pcr_value));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2859|       |
 2860|      0|					es->program->pcr_base_offset += GF_M2TS_MAX_PCR;
  ------------------
  |  |  372|      0|#define GF_M2TS_MAX_PCR	2576980377811ULL
  ------------------
 2861|       |					//do not adjust PCR
 2862|      0|				} else if ((diff_in_us<0) && (diff_in_us >= -200000)) {
  ------------------
  |  Branch (2862:16): [True: 0, False: 0]
  |  Branch (2862:34): [True: 0, False: 0]
  ------------------
 2863|      0|					GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d new PCR, without discontinuity signaled, is less than previously received PCR (diff %d us) but not too large, trying to ignore discontinuity\n", hdr.pid, diff_in_us));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2864|      0|					adjust_pcr = GF_TRUE;
 2865|      0|				} else {
 2866|      0|					GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d PCR found "LLU" is less than previously received PCR "LLU" (PCR diff %g sec) but no discontinuity signaled\n", hdr.pid, es->program->last_pcr_value, es->program->before_last_pcr_value, (GF_M2TS_MAX_PCR - es->program->before_last_pcr_value + es->program->last_pcr_value) / 27000000.0));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2867|       |
 2868|      0|					pck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;
 2869|      0|					adjust_pcr = GF_TRUE;
 2870|      0|				}
 2871|      0|			}
 2872|       |
 2873|       |			//adjust pcr_base_offset to absorb the discontinuity
 2874|      0|			if (adjust_pcr) {
  ------------------
  |  Branch (2874:8): [True: 0, False: 0]
  ------------------
 2875|      0|				s64 pcr_base_offset_delta = es->program->before_last_pcr_value + prev_diff_in_us*27;
 2876|      0|				pcr_base_offset_delta -= es->program->last_pcr_value;
 2877|      0|				es->program->pcr_base_offset += pcr_base_offset_delta;
 2878|      0|			}
 2879|       |
 2880|      0|			if (pck.flags & GF_M2TS_PES_PCK_DISCONTINUITY) {
  ------------------
  |  Branch (2880:8): [True: 0, False: 0]
  ------------------
 2881|      0|				gf_m2ts_reset_parsers_for_program_ex(ts, es->program, GF_TRUE);
 2882|      0|			}
 2883|       |
 2884|      0|			if (ts->on_event) {
  ------------------
  |  Branch (2884:8): [True: 0, False: 0]
  ------------------
 2885|      0|				ts->on_event(ts, GF_M2TS_EVT_PES_PCR, &pck);
 2886|      0|			}
 2887|      0|		}
 2888|      0|	}
 2889|       |
 2890|       |	/*check for DVB reserved PIDs*/
 2891|      0|	if (!es) {
  ------------------
  |  Branch (2891:6): [True: 0, False: 0]
  ------------------
 2892|      0|		if (hdr.pid == GF_M2TS_PID_SDT_BAT_ST) {
  ------------------
  |  Branch (2892:7): [True: 0, False: 0]
  ------------------
 2893|      0|			gf_m2ts_gather_section(ts, ts->sdt, NULL, &hdr, data, payload_size);
 2894|      0|			return GF_OK;
 2895|      0|		} else if (hdr.pid == GF_M2TS_PID_NIT_ST) {
  ------------------
  |  Branch (2895:14): [True: 0, False: 0]
  ------------------
 2896|       |			/*ignore them, unused at application level*/
 2897|      0|			gf_m2ts_gather_section(ts, ts->nit, NULL, &hdr, data, payload_size);
 2898|      0|			return GF_OK;
 2899|      0|		} else if (hdr.pid == GF_M2TS_PID_EIT_ST_CIT) {
  ------------------
  |  Branch (2899:14): [True: 0, False: 0]
  ------------------
 2900|       |			/* ignore EIT messages for the moment */
 2901|      0|			gf_m2ts_gather_section(ts, ts->eit, NULL, &hdr, data, payload_size);
 2902|      0|			return GF_OK;
 2903|      0|		} else if (hdr.pid == GF_M2TS_PID_TDT_TOT_ST) {
  ------------------
  |  Branch (2903:14): [True: 0, False: 0]
  ------------------
 2904|      0|			gf_m2ts_gather_section(ts, ts->tdt_tot, NULL, &hdr, data, payload_size);
 2905|      0|		} else {
 2906|       |			/* ignore packet */
 2907|      0|		}
 2908|      0|	} else if (es->flags & GF_M2TS_ES_IS_SECTION) { 	/* The stream uses sections to carry its payload */
  ------------------
  |  Branch (2908:13): [True: 0, False: 0]
  ------------------
 2909|      0|		GF_M2TS_SECTION_ES *ses = (GF_M2TS_SECTION_ES *)es;
 2910|      0|		if (ses->sec) gf_m2ts_gather_section(ts, ses->sec, ses, &hdr, data, payload_size);
  ------------------
  |  Branch (2910:7): [True: 0, False: 0]
  ------------------
 2911|      0|	} else {
 2912|      0|		GF_M2TS_PES *pes = (GF_M2TS_PES *)es;
 2913|       |		/* regular stream using PES packets */
 2914|      0|		if (pes->reframe && payload_size) gf_m2ts_process_pes(ts, pes, &hdr, data, payload_size, paf);
  ------------------
  |  Branch (2914:7): [True: 0, False: 0]
  |  Branch (2914:23): [True: 0, False: 0]
  ------------------
 2915|      0|	}
 2916|       |
 2917|      0|	return GF_OK;
 2918|      0|}
mpegts.c:gf_m2ts_sync:
  175|    265|{
  176|    265|	u32 i=0;
  177|       |	/*if first byte is sync assume we're sync*/
  178|    265|	if (simple_check && (data[i]==0x47)) return 0;
  ------------------
  |  Branch (178:6): [True: 265, False: 0]
  |  Branch (178:22): [True: 160, False: 105]
  ------------------
  179|       |
  180|  22.7k|	while (i < size) {
  ------------------
  |  Branch (180:9): [True: 22.7k, False: 0]
  ------------------
  181|  22.7k|		if (i+192 >= size) return size;
  ------------------
  |  Branch (181:7): [True: 66, False: 22.6k]
  ------------------
  182|  22.6k|		if ((data[i]==0x47) && (data[i+188]==0x47))
  ------------------
  |  Branch (182:7): [True: 958, False: 21.7k]
  |  Branch (182:26): [True: 23, False: 935]
  ------------------
  183|     23|			break;
  184|  22.6k|		if ((data[i]==0x47) && (data[i+192]==0x47)) {
  ------------------
  |  Branch (184:7): [True: 935, False: 21.7k]
  |  Branch (184:26): [True: 16, False: 919]
  ------------------
  185|     16|			ts->prefix_present = 1;
  186|     16|			break;
  187|     16|		}
  188|  22.6k|		i++;
  189|  22.6k|	}
  190|     39|	if (i) {
  ------------------
  |  Branch (190:6): [True: 39, False: 0]
  ------------------
  191|     39|		GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] re-sync skipped %d bytes\n", i) );
  ------------------
  |  | 1086|     39|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 39]
  |  |  ------------------
  ------------------
  192|     39|	}
  193|     39|	return i;
  194|    105|}
mpegts.c:gf_m2ts_section_filter_reset:
  234|  1.59k|{
  235|  1.59k|	if (sf->section) {
  ------------------
  |  Branch (235:6): [True: 0, False: 1.59k]
  ------------------
  236|      0|		gf_free(sf->section);
  237|      0|		sf->section = NULL;
  238|      0|	}
  239|  1.59k|	while (sf->table) {
  ------------------
  |  Branch (239:9): [True: 0, False: 1.59k]
  ------------------
  240|      0|		GF_M2TS_Table *t = sf->table;
  241|      0|		sf->table = t->next;
  242|      0|		gf_m2ts_reset_sections(t->sections);
  243|      0|		gf_list_del(t->sections);
  244|      0|		gf_free(t);
  245|      0|	}
  246|  1.59k|	sf->cc = -1;
  247|  1.59k|	sf->length = sf->received = 0;
  248|  1.59k|	sf->demux_restarted = 1;
  249|       |
  250|  1.59k|}
mpegts.c:gf_m2ts_section_filter_new:
  205|  1.59k|{
  206|  1.59k|	GF_M2TS_SectionFilter *sec;
  207|  1.59k|	GF_SAFEALLOC(sec, GF_M2TS_SectionFilter);
  ------------------
  |  |  242|  1.59k|#define GF_SAFEALLOC(__ptr, __struct) {\
  |  |  243|  1.59k|		(__ptr) = (__struct *) gf_malloc(sizeof(__struct));\
  |  |  244|  1.59k|		if (__ptr) {\
  |  |  ------------------
  |  |  |  Branch (244:7): [True: 1.59k, False: 0]
  |  |  ------------------
  |  |  245|  1.59k|			memset((void *) (__ptr), 0, sizeof(__struct));\
  |  |  246|  1.59k|		}\
  |  |  247|  1.59k|	}
  ------------------
  208|  1.59k|	if (!sec) {
  ------------------
  |  Branch (208:6): [True: 0, False: 1.59k]
  ------------------
  209|      0|		GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] gf_m2ts_section_filter_new : OUT OF MEMORY\n"));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  210|      0|		return NULL;
  211|      0|	}
  212|  1.59k|	sec->cc = -1;
  213|  1.59k|	sec->process_section = process_section_callback;
  214|  1.59k|	sec->process_individual = process_individual;
  215|  1.59k|	return sec;
  216|  1.59k|}
mpegts.c:gf_m2ts_section_filter_del:
  252|  1.59k|{
  253|  1.59k|	gf_m2ts_section_filter_reset(sf);
  254|  1.59k|	gf_free(sf);
  255|  1.59k|}
mpegts.c:gf_m2ts_reset_sdt:
  313|    265|{
  314|    265|	while (gf_list_count(ts->SDTs)) {
  ------------------
  |  Branch (314:9): [True: 0, False: 265]
  ------------------
  315|      0|		GF_M2TS_SDT *sdt = (GF_M2TS_SDT *)gf_list_last(ts->SDTs);
  316|      0|		gf_list_rem_last(ts->SDTs);
  317|      0|		if (sdt->provider) gf_free(sdt->provider);
  ------------------
  |  Branch (317:7): [True: 0, False: 0]
  ------------------
  318|      0|		if (sdt->service) gf_free(sdt->service);
  ------------------
  |  Branch (318:7): [True: 0, False: 0]
  ------------------
  319|      0|		gf_free(sdt);
  320|      0|	}
  321|    265|}
mpegts.c:gf_m2ts_probe_buffer:
 3393|    265|{
 3394|    265|	GF_Err e;
 3395|    265|	GF_M2TS_Demuxer *ts;
 3396|    265|	u32 lt;
 3397|       |
 3398|    265|	lt = gf_log_get_tool_level(GF_LOG_CONTAINER);
 3399|    265|	gf_log_set_tool_level(GF_LOG_CONTAINER, GF_LOG_QUIET);
 3400|       |
 3401|    265|	ts = gf_m2ts_demux_new();
 3402|    265|	ts->raw_mode = GF_M2TS_RAW_PROBE;
 3403|    265|	e = gf_m2ts_process_data(ts, buf, size);
 3404|       |
 3405|    265|	if (!ts->pck_number) {
  ------------------
  |  Branch (3405:6): [True: 91, False: 174]
  ------------------
 3406|     91|		e = GF_BAD_PARAM;
 3407|    174|	} else {
 3408|    174|		u32 nb_pck;
 3409|       |		//max number of packets
 3410|    174|		if (ts->prefix_present)
  ------------------
  |  Branch (3410:7): [True: 16, False: 158]
  ------------------
 3411|     16|			nb_pck = size/192;
 3412|    158|		else
 3413|    158|			nb_pck = size/188;
 3414|       |		//incomplete last packet
 3415|    174|		if (ts->buffer_size) nb_pck--;
  ------------------
  |  Branch (3415:7): [True: 52, False: 122]
  ------------------
 3416|       |		//probe success if after align we have nb_pck - 2 and at least 2 packets
 3417|    174|		if ((nb_pck<2) || (ts->pck_number + 2 < nb_pck))
  ------------------
  |  Branch (3417:7): [True: 75, False: 99]
  |  Branch (3417:21): [True: 8, False: 91]
  ------------------
 3418|     83|			e = GF_BAD_PARAM;
 3419|       |		//accept if we have not too few errors (triggered on error bit and corrupted AF fields)
 3420|     91|		else if ((nb_pck>3) && ts->pck_errors*3<ts->pck_number)
  ------------------
  |  Branch (3420:12): [True: 51, False: 40]
  |  Branch (3420:26): [True: 21, False: 30]
  ------------------
 3421|     21|			e = GF_OK;
 3422|    174|	}
 3423|    265|	gf_m2ts_demux_del(ts);
 3424|       |
 3425|    265|	gf_log_set_tool_level(GF_LOG_CONTAINER, lt);
 3426|       |
 3427|    265|	if (e) return GF_FALSE;
  ------------------
  |  Branch (3427:6): [True: 225, False: 40]
  ------------------
 3428|     40|	return GF_TRUE;
 3429|       |
 3430|    265|}

gf_malloc:
  149|  2.65k|{
  150|  2.65k|	return MALLOC(size);
  ------------------
  |  |  121|  2.65k|#define MALLOC	malloc
  ------------------
  151|  2.65k|}
gf_realloc:
  159|    143|{
  160|    143|	return REALLOC(ptr, size);
  ------------------
  |  |  123|    143|#define REALLOC	realloc
  ------------------
  161|    143|}
gf_free:
  164|  3.58k|{
  165|  3.58k|	FREE(ptr);
  ------------------
  |  |  124|  3.58k|#define FREE	free
  ------------------
  166|  3.58k|}

gf_log_tool_level_on:
  727|  1.44k|{
  728|  1.44k|	if (logs_extras) {
  ------------------
  |  Branch (728:6): [True: 0, False: 1.44k]
  ------------------
  729|      0|		gf_mx_p(logs_mx);
  730|      0|		u32 count = logs_extras ? gf_list_count(logs_extras) : 0; //avoid race condition
  ------------------
  |  Branch (730:15): [True: 0, False: 0]
  ------------------
  731|      0|		for (u32 i=0;i<count;i++) {
  ------------------
  |  Branch (731:16): [True: 0, False: 0]
  ------------------
  732|      0|			GF_LogExtra *lf = gf_list_get(logs_extras, i);
  733|      0|			u32 j;
  734|      0|			for (j=0; j<lf->nb_tools; j++) {
  ------------------
  |  Branch (734:14): [True: 0, False: 0]
  ------------------
  735|      0|				if (lf->tools[j]==GF_LOG_ALL) {}
  ------------------
  |  Branch (735:9): [True: 0, False: 0]
  ------------------
  736|      0|				else if (lf->tools[j]==GF_LOG_TOOL_UNDEFINED) {
  ------------------
  |  Branch (736:14): [True: 0, False: 0]
  ------------------
  737|      0|					lf->tools[j] = log_tool;
  738|      0|				}
  739|      0|				else if (log_tool!=lf->tools[j])
  ------------------
  |  Branch (739:14): [True: 0, False: 0]
  ------------------
  740|      0|					continue;
  741|       |
  742|      0|				if (lf->levels[j] >= log_level) {
  ------------------
  |  Branch (742:9): [True: 0, False: 0]
  ------------------
  743|      0|					gf_mx_v(logs_mx);
  744|      0|					if (lf->strict && (log_level==GF_LOG_ERROR) && (log_tool != GF_LOG_MEMORY))
  ------------------
  |  Branch (744:10): [True: 0, False: 0]
  |  Branch (744:24): [True: 0, False: 0]
  |  Branch (744:53): [True: 0, False: 0]
  ------------------
  745|      0|						gf_log_set_strict_error(GF_TRUE);
  746|      0|					return GF_TRUE;
  747|      0|				}
  748|      0|				if (lf->levels[j] == GF_LOG_QUIET) {
  ------------------
  |  Branch (748:9): [True: 0, False: 0]
  ------------------
  749|      0|					gf_mx_v(logs_mx);
  750|      0|					return GF_FALSE;
  751|      0|				}
  752|      0|			}
  753|      0|		}
  754|      0|		gf_mx_v(logs_mx);
  755|      0|	}
  756|  1.44k|	if (log_tool==GF_LOG_TOOL_MAX) return GF_TRUE;
  ------------------
  |  Branch (756:6): [True: 0, False: 1.44k]
  ------------------
  757|  1.44k|	if (log_tool>GF_LOG_TOOL_MAX) return GF_FALSE;
  ------------------
  |  Branch (757:6): [True: 0, False: 1.44k]
  ------------------
  758|  1.44k|	if (global_log_tools[log_tool].level >= log_level) {
  ------------------
  |  Branch (758:6): [True: 0, False: 1.44k]
  ------------------
  759|      0|		if (global_log_tools[log_tool].strict && (log_level==GF_LOG_ERROR) && (log_tool != GF_LOG_MEMORY))
  ------------------
  |  Branch (759:7): [True: 0, False: 0]
  |  Branch (759:44): [True: 0, False: 0]
  |  Branch (759:73): [True: 0, False: 0]
  ------------------
  760|      0|			gf_log_set_strict_error(GF_TRUE);
  761|      0|		return GF_TRUE;
  762|      0|	}
  763|  1.44k|	return GF_FALSE;
  764|  1.44k|}
gf_log_get_tool_level:
  785|    265|{
  786|    265|	if (log_tool>=GF_LOG_TOOL_MAX) return GF_LOG_ERROR;
  ------------------
  |  Branch (786:6): [True: 0, False: 265]
  ------------------
  787|    265|	return global_log_tools[log_tool].level;
  788|    265|}
gf_log_set_tool_level:
 1057|    530|{
 1058|    530|	if (tool>GF_LOG_TOOL_MAX) return;
  ------------------
  |  Branch (1058:6): [True: 0, False: 530]
  ------------------
 1059|    530|	if (tool==GF_LOG_ALL) {
  ------------------
  |  Branch (1059:6): [True: 0, False: 530]
  ------------------
 1060|      0|		u32 i;
 1061|      0|		for (i=0; i<GF_LOG_TOOL_MAX; i++) {
  ------------------
  |  Branch (1061:13): [True: 0, False: 0]
  ------------------
 1062|      0|			global_log_tools[i].level = level;
 1063|      0|		}
 1064|    530|	} else {
 1065|    530|		global_log_tools[tool].level = level;
 1066|    530|	}
 1067|    530|}

gf_list_new:
  609|    795|{
  610|    795|	GF_List *nlist;
  611|       |
  612|    795|	nlist = (GF_List *) gf_malloc(sizeof(GF_List));
  613|    795|	if (! nlist) return NULL;
  ------------------
  |  Branch (613:6): [True: 0, False: 795]
  ------------------
  614|       |
  615|    795|	nlist->slots = NULL;
  616|    795|	nlist->entryCount = 0;
  617|    795|	nlist->allocSize = 0;
  618|    795|	return nlist;
  619|    795|}
gf_list_del:
  634|    795|{
  635|    795|	if (!ptr) return;
  ------------------
  |  Branch (635:6): [True: 0, False: 795]
  ------------------
  636|    795|	gf_free(ptr->slots);
  637|    795|	gf_free(ptr);
  638|    795|}
gf_list_count:
  662|    795|{
  663|    795|	if (!ptr) return 0;
  ------------------
  |  Branch (663:6): [True: 0, False: 795]
  ------------------
  664|    795|	return ptr->entryCount;
  665|    795|}

gf_fileio_check:
 1066|    530|{
 1067|    530|	GF_FileIO *fio = (GF_FileIO *)fp;
 1068|    530|	if ((fp==stdin) || (fp==stderr) || (fp==stdout))
  ------------------
  |  Branch (1068:6): [True: 0, False: 530]
  |  Branch (1068:21): [True: 0, False: 530]
  |  Branch (1068:37): [True: 0, False: 530]
  ------------------
 1069|      0|		return GF_FALSE;
 1070|       |
 1071|    530|	if (fio && !fio->_reserved_null && (fio->__this==fio))
  ------------------
  |  Branch (1071:6): [True: 530, False: 0]
  |  Branch (1071:13): [True: 0, False: 530]
  |  Branch (1071:37): [True: 0, False: 0]
  ------------------
 1072|      0|		return GF_TRUE;
 1073|    530|	return GF_FALSE;
 1074|    530|}
gf_fopen_ex:
 1610|    265|{
 1611|    265|	FILE *res = NULL;
 1612|    265|	u32 gfio_type = 0;
 1613|    265|	Bool is_mkdir = GF_FALSE;
 1614|       |
 1615|    265|	if (!file_name || !mode) return NULL;
  ------------------
  |  Branch (1615:6): [True: 0, False: 265]
  |  Branch (1615:20): [True: 0, False: 265]
  ------------------
 1616|    265|	if (!strcmp(mode, "mkdir")) {
  ------------------
  |  Branch (1616:6): [True: 0, False: 265]
  ------------------
 1617|      0|		is_mkdir = GF_TRUE;
 1618|      0|		mode = "w";
 1619|      0|	}
 1620|       |
 1621|    265|	if (!strncmp(file_name, "gmem://", 7)) {
  ------------------
  |  Branch (1621:6): [True: 0, False: 265]
  ------------------
 1622|      0|		GF_FileIO *new_gfio;
 1623|      0|		if (strstr(mode, "w"))
  ------------------
  |  Branch (1623:7): [True: 0, False: 0]
  ------------------
 1624|      0|			return NULL;
 1625|      0|		new_gfio = gf_fileio_from_blob(file_name);
 1626|      0|		if (new_gfio)
  ------------------
  |  Branch (1626:7): [True: 0, False: 0]
  ------------------
 1627|      0|			gf_register_file_handle((char*)file_name, (FILE *) new_gfio, GF_FALSE);
 1628|      0|		return (FILE *) new_gfio;
 1629|       |
 1630|      0|	}
 1631|       |
 1632|    265|	if (!strncmp(file_name, "gfio://", 7))
  ------------------
  |  Branch (1632:6): [True: 0, False: 265]
  ------------------
 1633|      0|		gfio_type = 1;
 1634|    265|	else if (parent_name && !strncmp(parent_name, "gfio://", 7))
  ------------------
  |  Branch (1634:11): [True: 0, False: 265]
  |  Branch (1634:26): [True: 0, False: 0]
  ------------------
 1635|      0|		gfio_type = 2;
 1636|       |
 1637|    265|	if (gfio_type) {
  ------------------
  |  Branch (1637:6): [True: 0, False: 265]
  ------------------
 1638|      0|		GF_FileIO *gfio_ref;
 1639|      0|		GF_FileIO *new_gfio;
 1640|      0|		GF_Err e;
 1641|      0|		GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Open GFIO %s in mode %s\n", file_name, mode));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1642|       |
 1643|      0|		if (gfio_type==1)
  ------------------
  |  Branch (1643:7): [True: 0, False: 0]
  ------------------
 1644|      0|			gfio_ref = gf_fileio_from_url(file_name);
 1645|      0|		else
 1646|      0|			gfio_ref = gf_fileio_from_url(parent_name);
 1647|       |
 1648|      0|		if (!gfio_ref) return NULL;
  ------------------
  |  Branch (1648:7): [True: 0, False: 0]
  ------------------
 1649|      0|		if (strchr(mode, 'r') && !gf_fileio_read_mode(gfio_ref)) {
  ------------------
  |  Branch (1649:7): [True: 0, False: 0]
  |  Branch (1649:28): [True: 0, False: 0]
  ------------------
 1650|      0|			GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("FileIO %s is not read-enabled and open mode %s was requested\n", file_name, mode));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1651|      0|			return NULL;
 1652|      0|		}
 1653|      0|		if (strpbrk(mode, "wa") && !gf_fileio_write_mode(gfio_ref)) {
  ------------------
  |  Branch (1653:7): [True: 0, False: 0]
  |  Branch (1653:30): [True: 0, False: 0]
  ------------------
 1654|      0|			GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("FileIO %s is not write-enabled and open mode %s was requested\n", file_name, mode));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1655|      0|			return NULL;
 1656|      0|		}
 1657|      0|		new_gfio = gf_fileio_open_url(gfio_ref, file_name, mode, &e);
 1658|      0|		if (e) {
  ------------------
  |  Branch (1658:7): [True: 0, False: 0]
  ------------------
 1659|      0|			if (!no_warn) {
  ------------------
  |  Branch (1659:8): [True: 0, False: 0]
  ------------------
 1660|      0|				GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("FileIO %s open in mode %s failed: %s\n", file_name, mode, gf_error_to_string(e)));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1661|      0|			}
 1662|      0|			return NULL;
 1663|      0|		}
 1664|      0|		if (new_gfio)
  ------------------
  |  Branch (1664:7): [True: 0, False: 0]
  ------------------
 1665|      0|			gf_register_file_handle((char*)file_name, (FILE *) new_gfio, GF_FALSE);
 1666|      0|		return (FILE *) new_gfio;
 1667|      0|	}
 1668|       |
 1669|    265|	GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Open file %s in mode %s\n", file_name, mode));
  ------------------
  |  | 1086|    265|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 265]
  |  |  ------------------
  ------------------
 1670|    265|	if (strchr(mode, 'w')) {
  ------------------
  |  Branch (1670:6): [True: 0, False: 265]
  ------------------
 1671|      0|		char *fname = gf_strdup(file_name);
 1672|      0|		char *sep = strchr(fname, '/');
 1673|      0|		if (!sep) sep = strchr(fname, '\\');
  ------------------
  |  Branch (1673:7): [True: 0, False: 0]
  ------------------
 1674|      0|		if (file_name[0] == '/') sep = strchr(fname+1, '/');
  ------------------
  |  Branch (1674:7): [True: 0, False: 0]
  ------------------
 1675|      0|		else if (file_name[2] == '\\') sep = strchr(fname+3, '\\');
  ------------------
  |  Branch (1675:12): [True: 0, False: 0]
  ------------------
 1676|       |
 1677|      0|		while (sep) {
  ------------------
  |  Branch (1677:10): [True: 0, False: 0]
  ------------------
 1678|      0|			char *n_sep;
 1679|      0|			char c = sep[0];
 1680|      0|			sep[0] = 0;
 1681|      0|			if (!gf_dir_exists(fname)) {
  ------------------
  |  Branch (1681:8): [True: 0, False: 0]
  ------------------
 1682|      0|				GF_Err e = gf_mkdir(fname);
 1683|      0|				if (e != GF_OK) {
  ------------------
  |  Branch (1683:9): [True: 0, False: 0]
  ------------------
 1684|      0|					GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Failed to create directory \"%s\": %s\n", file_name, gf_error_to_string(e) ));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1685|      0|					sep[0] = c;
 1686|      0|					gf_free(fname);
 1687|      0|					return NULL;
 1688|      0|				}
 1689|      0|			}
 1690|      0|			sep[0] = c;
 1691|      0|			n_sep = strchr(sep+1, '/');
 1692|      0|			if (!n_sep) n_sep = strchr(sep+1, '\\');
  ------------------
  |  Branch (1692:8): [True: 0, False: 0]
  ------------------
 1693|      0|			sep = n_sep;
 1694|      0|		}
 1695|      0|		gf_free(fname);
 1696|      0|		if (is_mkdir) return NULL;
  ------------------
  |  Branch (1696:7): [True: 0, False: 0]
  ------------------
 1697|      0|	}
 1698|       |
 1699|       |#ifdef GPAC_CONFIG_EMSCRIPTEN
 1700|       |	if (mainloop_th_id && strchr(mode, 'r') && (gf_th_id() != mainloop_th_id)) {
 1701|       |		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Opening file in read mode outside of main loop will likely deadlock - please report to GPAC devs\n"));
 1702|       |	}
 1703|       |#endif
 1704|       |
 1705|       |#if defined(WIN32)
 1706|       |	wchar_t *wname;
 1707|       |	wchar_t *wmode;
 1708|       |
 1709|       |	wname = gf_utf8_to_wcs(file_name);
 1710|       |	wmode = gf_utf8_to_wcs(mode);
 1711|       |	if (!wname || !wmode)
 1712|       |	{
 1713|       |		if (wname) gf_free(wname);
 1714|       |		if (wmode) gf_free(wmode);
 1715|       |		return NULL;
 1716|       |	}
 1717|       |	res = _wfsopen(wname, wmode, _SH_DENYNO);
 1718|       |	gf_free(wname);
 1719|       |	gf_free(wmode);
 1720|       |#elif defined(GPAC_CONFIG_LINUX) && !defined(GPAC_CONFIG_ANDROID)
 1721|    265|	res = fopen64(file_name, mode);
 1722|       |#elif (defined(GPAC_CONFIG_FREEBSD) || defined(GPAC_CONFIG_DARWIN))
 1723|       |	res = fopen(file_name, mode);
 1724|       |#else
 1725|       |	res = fopen(file_name, mode);
 1726|       |#endif
 1727|       |
 1728|    265|	if (res) {
  ------------------
  |  Branch (1728:6): [True: 265, False: 0]
  ------------------
 1729|    265|		if (!parent_name || strcmp(parent_name, "__temp_file"))
  ------------------
  |  Branch (1729:7): [True: 265, False: 0]
  |  Branch (1729:23): [True: 0, False: 0]
  ------------------
 1730|    265|			gf_register_file_handle((char*)file_name, res, GF_FALSE);
 1731|       |
 1732|    265|		GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] file \"%s\" opened in mode \"%s\" - %d file handles\n", file_name, mode, gpac_file_handles));
  ------------------
  |  | 1086|    265|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 265]
  |  |  ------------------
  ------------------
 1733|    265|	} else if (!no_warn) {
  ------------------
  |  Branch (1733:13): [True: 0, False: 0]
  ------------------
 1734|      0|		if (strpbrk(mode, "wa")) {
  ------------------
  |  Branch (1734:7): [True: 0, False: 0]
  ------------------
 1735|       |#if defined(WIN32)
 1736|       |			u32 err = GetLastError();
 1737|       |			GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] system failure for file opening of \"%s\" in mode \"%s\": 0x%08x (%u opened)\n", file_name, mode, err, gpac_file_handles));
 1738|       |#else
 1739|      0|			GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] system failure for file opening of \"%s\" in mode \"%s\": %d (%u opened)\n", file_name, mode, errno, gpac_file_handles));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1740|      0|#endif
 1741|      0|		}
 1742|      0|	}
 1743|    265|	return res;
 1744|    265|}
gf_fopen:
 1770|    265|{
 1771|       |	return gf_fopen_ex(file_name, NULL, mode, GF_FALSE);
 1772|    265|}
gf_fclose:
 1776|    265|{
 1777|    265|	if (!file)
  ------------------
  |  Branch (1777:6): [True: 0, False: 265]
  ------------------
 1778|      0|		return 0;
 1779|       |
 1780|    265|	if (gf_unregister_file_handle(file))
  ------------------
  |  Branch (1780:6): [True: 0, False: 265]
  ------------------
 1781|      0|		return 0;
 1782|    265|	if (gf_fileio_check(file)) {
  ------------------
  |  Branch (1782:6): [True: 0, False: 265]
  ------------------
 1783|      0|		GF_Err e;
 1784|      0|		gf_fileio_open_url((GF_FileIO *) file, NULL, "close", &e);
 1785|      0|		if (e) return -1;
  ------------------
  |  Branch (1785:7): [True: 0, False: 0]
  ------------------
 1786|      0|		return 0;
 1787|      0|	}
 1788|    265|	return fclose(file);
 1789|    265|}
gf_fread:
 1835|    265|{
 1836|    265|	size_t result;
 1837|    265|	if (gf_fileio_check(stream)) {
  ------------------
  |  Branch (1837:6): [True: 0, False: 265]
  ------------------
 1838|      0|		return (size_t) gf_fileio_read((GF_FileIO *)stream, ptr, (u32) nbytes);
 1839|      0|	}
 1840|    265|	if (!stream) return 0;
  ------------------
  |  Branch (1840:6): [True: 0, False: 265]
  ------------------
 1841|    265|	result = fread(ptr, 1, nbytes, stream);
 1842|    265|	return result;
 1843|    265|}
os_file.c:gf_register_file_handle:
  545|    265|{
  546|    265|	if (is_temp_file
  ------------------
  |  Branch (546:6): [True: 0, False: 265]
  ------------------
  547|       |#ifdef GPAC_MEMORY_TRACKING
  548|       |		|| gf_mem_track_enabled
  549|       |#endif
  550|    265|	) {
  551|      0|		GF_FileHandle *h;
  552|      0|		gf_mx_p(logs_mx);
  553|      0|		if (!gpac_open_files) gpac_open_files = gf_list_new();
  ------------------
  |  Branch (553:7): [True: 0, False: 0]
  ------------------
  554|      0|		GF_SAFEALLOC(h, GF_FileHandle);
  ------------------
  |  |  242|      0|#define GF_SAFEALLOC(__ptr, __struct) {\
  |  |  243|      0|		(__ptr) = (__struct *) gf_malloc(sizeof(__struct));\
  |  |  244|      0|		if (__ptr) {\
  |  |  ------------------
  |  |  |  Branch (244:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  245|      0|			memset((void *) (__ptr), 0, sizeof(__struct));\
  |  |  246|      0|		}\
  |  |  247|      0|	}
  ------------------
  555|      0|		if (h) {
  ------------------
  |  Branch (555:7): [True: 0, False: 0]
  ------------------
  556|      0|			h->ptr = ptr;
  557|      0|			if (is_temp_file) {
  ------------------
  |  Branch (557:8): [True: 0, False: 0]
  ------------------
  558|      0|				h->is_temp = GF_TRUE;
  559|      0|				h->url = filename;
  560|      0|			} else {
  561|      0|				h->url = gf_strdup(filename);
  562|      0|			}
  563|      0|			gf_list_add(gpac_open_files, h);
  564|      0|		}
  565|      0|		gf_mx_v(logs_mx);
  566|      0|	}
  567|    265|	gpac_file_handles++;
  568|    265|}
os_file.c:gf_unregister_file_handle:
  571|    265|{
  572|    265|	u32 i, count;
  573|    265|	Bool res = GF_FALSE;
  574|    265|	if (gpac_file_handles)
  ------------------
  |  Branch (574:6): [True: 265, False: 0]
  ------------------
  575|    265|		gpac_file_handles--;
  576|       |
  577|    265|	if (!gpac_open_files)
  ------------------
  |  Branch (577:6): [True: 265, False: 0]
  ------------------
  578|    265|		return GF_FALSE;
  579|       |
  580|      0|	gf_mx_p(logs_mx);
  581|      0|	count = gf_list_count(gpac_open_files);
  582|      0|	for (i=0; i<count; i++) {
  ------------------
  |  Branch (582:12): [True: 0, False: 0]
  ------------------
  583|      0|		GF_FileHandle *h = gf_list_get(gpac_open_files, i);
  584|      0|		if (h->ptr != ptr) continue;
  ------------------
  |  Branch (584:7): [True: 0, False: 0]
  ------------------
  585|       |
  586|      0|		if (h->is_temp) {
  ------------------
  |  Branch (586:7): [True: 0, False: 0]
  ------------------
  587|      0|			GF_Err e;
  588|      0|			fclose(h->ptr);
  589|      0|			e = gf_file_delete(h->url);
  590|      0|			if (e) {
  ------------------
  |  Branch (590:8): [True: 0, False: 0]
  ------------------
  591|      0|				GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("[Core] Failed to delete temp file %s: %s\n", h->url, gf_error_to_string(e)));
  ------------------
  |  | 1086|      0|#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
  |  |  ------------------
  |  |  |  Branch (1086:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  592|      0|			}
  593|      0|			res = GF_TRUE;
  594|      0|		}
  595|      0|		gf_free(h->url);
  596|      0|		gf_free(h);
  597|      0|		gf_list_rem(gpac_open_files, i);
  598|      0|		if (!gf_list_count(gpac_open_files)) {
  ------------------
  |  Branch (598:7): [True: 0, False: 0]
  ------------------
  599|      0|			gf_list_del(gpac_open_files);
  600|       |			gpac_open_files = NULL;
  601|      0|		}
  602|      0|		break;
  603|      0|	}
  604|      0|	gf_mx_v(logs_mx);
  605|      0|	return res;
  606|    265|}

LLVMFuzzerTestOneInput:
   12|    265|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   13|    265|  char filename[256];
   14|    265|  sprintf(filename, "/tmp/libfuzzer.%d", getpid());
   15|       |
   16|    265|  FILE *fp = fopen(filename, "wb");
   17|    265|  if (!fp)
  ------------------
  |  Branch (17:7): [True: 0, False: 265]
  ------------------
   18|      0|    return 0;
   19|    265|  fwrite(data, size, 1, fp);
   20|    265|  fclose(fp);
   21|       |
   22|    265|  gf_m2ts_probe_file(filename);
   23|       |
   24|    265|  unlink(filename);
   25|    265|  return 0;
   26|    265|}

