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

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

gf_log_tool_level_on:
  726|  1.43k|{
  727|  1.43k|	if (logs_extras) {
  ------------------
  |  Branch (727:6): [True: 0, False: 1.43k]
  ------------------
  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.43k|	if (log_tool==GF_LOG_TOOL_MAX) return GF_TRUE;
  ------------------
  |  Branch (755:6): [True: 0, False: 1.43k]
  ------------------
  756|  1.43k|	if (log_tool>GF_LOG_TOOL_MAX) return GF_FALSE;
  ------------------
  |  Branch (756:6): [True: 0, False: 1.43k]
  ------------------
  757|  1.43k|	if (global_log_tools[log_tool].level >= log_level) {
  ------------------
  |  Branch (757:6): [True: 0, False: 1.43k]
  ------------------
  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.43k|	return GF_FALSE;
  763|  1.43k|}
gf_log_get_tool_level:
  784|    267|{
  785|    267|	if (log_tool>=GF_LOG_TOOL_MAX) return GF_LOG_ERROR;
  ------------------
  |  Branch (785:6): [True: 0, False: 267]
  ------------------
  786|    267|	return global_log_tools[log_tool].level;
  787|    267|}
gf_log_set_tool_level:
 1056|    534|{
 1057|    534|	if (tool>GF_LOG_TOOL_MAX) return;
  ------------------
  |  Branch (1057:6): [True: 0, False: 534]
  ------------------
 1058|    534|	if (tool==GF_LOG_ALL) {
  ------------------
  |  Branch (1058:6): [True: 0, False: 534]
  ------------------
 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|    534|	} else {
 1064|    534|		global_log_tools[tool].level = level;
 1065|    534|	}
 1066|    534|}

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

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

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

