Revision f1024bf4 chunker_player/player_stats.c

View differences:

chunker_player/player_stats.c
357 357
			{
358 358
				// bitrate (Kbits/sec) loss_percentage loss_burstiness est_mean_psnr
359 359
				fprintf(tracefile, "%d %.3f %.3f %.3f\n", (int)((Channels[SelectedChannel].Bitrate) * (qoe_reference_coeff/qoe_adjust_factor) / 1000), (float)(((double)losses)/((double)counter) * 100), (float)mean_burstiness, (float)(*quality));
360
				fclose(tracefile);
360 361
			}
361
			fclose(tracefile);
362 362
		}
363 363
		
364 364
		history->QoEIndex = (end_index+1)%QUEUE_HISTORY_SIZE;
......
457 457
#endif
458 458
	FILE* tracefile = NULL;
459 459
	tracefile = fopen(tracefilename, "a");
460
		
461
	if(history->LogIndex != history->Index)
460
	if(tracefile)
462 461
	{
463
		int index;
464
		int end_index;
465
		int start_index;
462
	    if(history->LogIndex != history->Index)
463
	    {
464
		    int index;
465
		    int end_index;
466
		    int start_index;
466 467

  
467
		start_index = history->LogIndex;
468
		end_index = history->Index-1;
469
		if(end_index < 0)
470
			end_index = QUEUE_HISTORY_SIZE-1;
471
		else if(history->Index < start_index)
472
			end_index += QUEUE_HISTORY_SIZE;
468
		    start_index = history->LogIndex;
469
		    end_index = history->Index-1;
470
		    if(end_index < 0)
471
			    end_index = QUEUE_HISTORY_SIZE-1;
472
		    else if(history->Index < start_index)
473
			    end_index += QUEUE_HISTORY_SIZE;
473 474
		
474
		for(index=start_index; (index<=end_index); index++)
475
		{
476
			int id = history->History[index%QUEUE_HISTORY_SIZE].ID;
477
			int status = history->History[index%QUEUE_HISTORY_SIZE].Status;
478
			int lossrate = -1, skiprate = -1, perc_lossrate = -1, perc_skiprate = -1, lastiframe_dist = -1;
479
			int bitrate = -1;
480
			char type = '?';
481
			switch(history->History[index%QUEUE_HISTORY_SIZE].Type)
482
			{
483
				case 1:
484
					type = 'I';
485
					break;
486
				case 2:
487
					type = 'P';
488
					break;
489
				case 3:
490
					type = 'B';
491
					break;
492
				case 5:
493
					type = 'A';
494
					break;
495
			}
496
			if(history->History[index%QUEUE_HISTORY_SIZE].Type != 5)
497
			{
498
				if((FirstLoggedVFrameNumber < 0))
499
					FirstLoggedVFrameNumber = id;
500
				LastLoggedVFrameNumber = id;
501
				VideoFramesLogged[status]++;
502
			}
503
			if(status != LOST_FRAME)
504
			{
505
				lossrate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.Lossrate;
506
				skiprate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.Skiprate;
507
				perc_lossrate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.PercLossrate;
508
				perc_skiprate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.PercSkiprate;
509
				if(type != 'A')
510
				{
511
					lastiframe_dist = history->History[index%QUEUE_HISTORY_SIZE].Statistics.LastIFrameDistance;
512
				}
513
				bitrate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.Bitrate;
514
			}
515
			fprintf(tracefile, "%d %d %c %d %d %d %d %d %d\n",
516
				id, status, type, lossrate, skiprate, perc_lossrate, perc_skiprate, lastiframe_dist, bitrate);
517
			counter++;
518
		}
519
		history->LogIndex = (end_index+1)%QUEUE_HISTORY_SIZE;
475
		    for(index=start_index; (index<=end_index); index++)
476
		    {
477
			    int id = history->History[index%QUEUE_HISTORY_SIZE].ID;
478
			    int status = history->History[index%QUEUE_HISTORY_SIZE].Status;
479
			    int lossrate = -1, skiprate = -1, perc_lossrate = -1, perc_skiprate = -1, lastiframe_dist = -1;
480
			    int bitrate = -1;
481
			    char type = '?';
482
			    switch(history->History[index%QUEUE_HISTORY_SIZE].Type)
483
			    {
484
				    case 1:
485
					    type = 'I';
486
					    break;
487
				    case 2:
488
					    type = 'P';
489
					    break;
490
				    case 3:
491
					    type = 'B';
492
					    break;
493
				    case 5:
494
					    type = 'A';
495
					    break;
496
			    }
497
			    if(history->History[index%QUEUE_HISTORY_SIZE].Type != 5)
498
			    {
499
				    if((FirstLoggedVFrameNumber < 0))
500
					    FirstLoggedVFrameNumber = id;
501
				    LastLoggedVFrameNumber = id;
502
				    VideoFramesLogged[status]++;
503
			    }
504
			    if(status != LOST_FRAME)
505
			    {
506
				    lossrate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.Lossrate;
507
				    skiprate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.Skiprate;
508
				    perc_lossrate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.PercLossrate;
509
				    perc_skiprate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.PercSkiprate;
510
				    if(type != 'A')
511
				    {
512
					    lastiframe_dist = history->History[index%QUEUE_HISTORY_SIZE].Statistics.LastIFrameDistance;
513
				    }
514
				    bitrate = history->History[index%QUEUE_HISTORY_SIZE].Statistics.Bitrate;
515
			    }
516
			    fprintf(tracefile, "%d %d %c %d %d %d %d %d %d\n",
517
				    id, status, type, lossrate, skiprate, perc_lossrate, perc_skiprate, lastiframe_dist, bitrate);
518
			    counter++;
519
		    }
520
		    history->LogIndex = (end_index+1)%QUEUE_HISTORY_SIZE;
521
	    }
522
	    fclose(tracefile);
520 523
	}
521
	fclose(tracefile);
522 524
		
523 525
	SDL_UnlockMutex(history->Mutex);
524 526
	return counter;

Also available in: Unified diff