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

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

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

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

gf_fileio_check:
 1066|    514|{
 1067|    514|	GF_FileIO *fio = (GF_FileIO *)fp;
 1068|    514|	if ((fp==stdin) || (fp==stderr) || (fp==stdout))
  ------------------
  |  Branch (1068:6): [True: 0, False: 514]
  |  Branch (1068:21): [True: 0, False: 514]
  |  Branch (1068:37): [True: 0, False: 514]
  ------------------
 1069|      0|		return GF_FALSE;
 1070|       |
 1071|    514|	if (fio && !fio->_reserved_null && (fio->__this==fio))
  ------------------
  |  Branch (1071:6): [True: 514, False: 0]
  |  Branch (1071:13): [True: 0, False: 514]
  |  Branch (1071:37): [True: 0, False: 0]
  ------------------
 1072|      0|		return GF_TRUE;
 1073|    514|	return GF_FALSE;
 1074|    514|}
gf_fopen_ex:
 1610|    257|{
 1611|    257|	FILE *res = NULL;
 1612|    257|	u32 gfio_type = 0;
 1613|    257|	Bool is_mkdir = GF_FALSE;
 1614|       |
 1615|    257|	if (!file_name || !mode) return NULL;
  ------------------
  |  Branch (1615:6): [True: 0, False: 257]
  |  Branch (1615:20): [True: 0, False: 257]
  ------------------
 1616|    257|	if (!strcmp(mode, "mkdir")) {
  ------------------
  |  Branch (1616:6): [True: 0, False: 257]
  ------------------
 1617|      0|		is_mkdir = GF_TRUE;
 1618|      0|		mode = "w";
 1619|      0|	}
 1620|       |
 1621|    257|	if (!strncmp(file_name, "gmem://", 7)) {
  ------------------
  |  Branch (1621:6): [True: 0, False: 257]
  ------------------
 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|    257|	if (!strncmp(file_name, "gfio://", 7))
  ------------------
  |  Branch (1632:6): [True: 0, False: 257]
  ------------------
 1633|      0|		gfio_type = 1;
 1634|    257|	else if (parent_name && !strncmp(parent_name, "gfio://", 7))
  ------------------
  |  Branch (1634:11): [True: 0, False: 257]
  |  Branch (1634:26): [True: 0, False: 0]
  ------------------
 1635|      0|		gfio_type = 2;
 1636|       |
 1637|    257|	if (gfio_type) {
  ------------------
  |  Branch (1637:6): [True: 0, False: 257]
  ------------------
 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));
  ------------------
  |  | 1087|      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 (1087: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));
  ------------------
  |  | 1087|      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 (1087: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));
  ------------------
  |  | 1087|      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 (1087: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)));
  ------------------
  |  | 1087|      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 (1087: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|    257|	GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Open file %s in mode %s\n", file_name, mode));
  ------------------
  |  | 1087|    257|#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 (1087:52): [True: 0, False: 257]
  |  |  ------------------
  ------------------
 1670|    257|	if (strchr(mode, 'w')) {
  ------------------
  |  Branch (1670:6): [True: 0, False: 257]
  ------------------
 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) ));
  ------------------
  |  | 1087|      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 (1087: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|    257|	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|    257|	if (res) {
  ------------------
  |  Branch (1728:6): [True: 257, False: 0]
  ------------------
 1729|    257|		if (!parent_name || strcmp(parent_name, "__temp_file"))
  ------------------
  |  Branch (1729:7): [True: 257, False: 0]
  |  Branch (1729:23): [True: 0, False: 0]
  ------------------
 1730|    257|			gf_register_file_handle((char*)file_name, res, GF_FALSE);
 1731|       |
 1732|    257|		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));
  ------------------
  |  | 1087|    257|#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 (1087:52): [True: 0, False: 257]
  |  |  ------------------
  ------------------
 1733|    257|	} 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));
  ------------------
  |  | 1087|      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 (1087:52): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1740|      0|#endif
 1741|      0|		}
 1742|      0|	}
 1743|    257|	return res;
 1744|    257|}
gf_fopen:
 1770|    257|{
 1771|       |	return gf_fopen_ex(file_name, NULL, mode, GF_FALSE);
 1772|    257|}
gf_fclose:
 1776|    257|{
 1777|    257|	if (!file)
  ------------------
  |  Branch (1777:6): [True: 0, False: 257]
  ------------------
 1778|      0|		return 0;
 1779|       |
 1780|    257|	if (gf_unregister_file_handle(file))
  ------------------
  |  Branch (1780:6): [True: 0, False: 257]
  ------------------
 1781|      0|		return 0;
 1782|    257|	if (gf_fileio_check(file)) {
  ------------------
  |  Branch (1782:6): [True: 0, False: 257]
  ------------------
 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|    257|	return fclose(file);
 1789|    257|}
gf_fread:
 1835|    257|{
 1836|    257|	size_t result;
 1837|    257|	if (gf_fileio_check(stream)) {
  ------------------
  |  Branch (1837:6): [True: 0, False: 257]
  ------------------
 1838|      0|		return (size_t) gf_fileio_read((GF_FileIO *)stream, ptr, (u32) nbytes);
 1839|      0|	}
 1840|    257|	if (!stream) return 0;
  ------------------
  |  Branch (1840:6): [True: 0, False: 257]
  ------------------
 1841|    257|	result = fread(ptr, 1, nbytes, stream);
 1842|    257|	return result;
 1843|    257|}
os_file.c:gf_register_file_handle:
  545|    257|{
  546|    257|	if (is_temp_file
  ------------------
  |  Branch (546:6): [True: 0, False: 257]
  ------------------
  547|       |#ifdef GPAC_MEMORY_TRACKING
  548|       |		|| gf_mem_track_enabled
  549|       |#endif
  550|    257|	) {
  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|    257|	gpac_file_handles++;
  568|    257|}
os_file.c:gf_unregister_file_handle:
  571|    257|{
  572|    257|	u32 i, count;
  573|    257|	Bool res = GF_FALSE;
  574|    257|	if (gpac_file_handles)
  ------------------
  |  Branch (574:6): [True: 257, False: 0]
  ------------------
  575|    257|		gpac_file_handles--;
  576|       |
  577|    257|	if (!gpac_open_files)
  ------------------
  |  Branch (577:6): [True: 257, False: 0]
  ------------------
  578|    257|		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)));
  ------------------
  |  | 1087|      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 (1087: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|    257|}

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

