Ejemplo n.º 1
0
    bool openVideo(AVCodec* pCodec, AVCodecContext* pCodecCtx, AVFrame*& pFrame, const std::string& filename)
    {
        AVDictionary* param = nullptr;

        if(pCodecCtx->codec_id == AV_CODEC_ID_H264)
        {
            // H.264 defaults to lossless currently. This should be changed in the future.
            av_dict_set(&param, "qp", "0", 0);
            /*
            Change options to trade off compression efficiency against encoding speed. If you specify a preset, the changes it makes will be applied before all other parameters are applied.
            You should generally set this option to the slowest you can bear.
            Values available: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo.
            */
            av_dict_set(&param, "preset", "veryslow", 0);
        }

        // Open the codec
        if(avcodec_open2(pCodecCtx, pCodec, &param) < 0)
        {
            return error(filename, "Can't open video codec.");
        }
        av_dict_free(&param);

        // create a frame
        pFrame = allocateFrame(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, filename);
        if(pFrame == nullptr)
        {
            return false;
        }
        return true;
    }
Ejemplo n.º 2
0
MEM_LOC allocateFrameForProcess(process_t* req_process) {

	ASSERT(paging_enabled, "cannot allocate for process without paging");
	MEM_LOC frame = allocateFrame();

	if (req_process) {
		usedListAdd(req_process, frame);
	}

	return frame;
}
Ejemplo n.º 3
0
void generateFrames(TestData* testdata, int num){
  int i;
  for(i=0; i<num; i++){
		allocateFrame(&testdata->frames[i],&testdata->fi);
  }
  // first frame noise
  fillArrayWithNoise(testdata->frames[0].data[0],
										 testdata->fi.width*testdata->fi.height, 10);
  fillArrayWithNoise(testdata->frames[0].data[1],
										 testdata->fi.width/2*testdata->fi.height/2, 5);
	fillArrayWithNoise(testdata->frames[0].data[2],
										 testdata->fi.width/2*testdata->fi.height/2, 5);

  // add rectangles
  int k;
  for(k=0; k<NUM_RECTANGLES; k++){
    paintRectangle(testdata->frames[0].data[0],&testdata->fi,
									 randUpTo(testdata->fi.width), randUpTo(testdata->fi.height),
									 randUpTo((testdata->fi.width>>4)+4),
									 randUpTo((testdata->fi.height>>4)+4),randPixel());

  }

  TransformData td;
  test_bool(initTransformData(&td, &testdata->fi, &testdata->fi, "generate") == VS_OK);
  td.interpolType=Zero;
  test_bool(configureTransformData(&td)== VS_OK);


  fprintf(stderr, "testframe transforms\n");

  for(i=1; i<num; i++){
    Transform t = getTestFrameTransform(i);
    fprintf(stderr, "%i, %6.4lf %6.4lf %8.5lf %6.4lf %i\n",
						i, t.x, t.y, t.alpha, t.zoom, t.extra);

    test_bool(transformPrepare(&td,&testdata->frames[i-1],&testdata->frames[i])== VS_OK);
    test_bool(transformYUV_float(&td, t)== VS_OK);
    test_bool(transformFinish(&td)== VS_OK);
  }
  cleanupTransformData(&td);
}
Ejemplo n.º 4
0
main(int argc, char *argv[])
{
	char	*tracename;
	int	page_number,frame_no, done ;
	int	do_line;
	int	no_events, disk_writes, disk_reads;
	int     debugmode;
 	enum	repl  replace;
	int	allocated=0, modified=0;
	int	victim_page;
        unsigned address;
    	char 	rw;
	int 	i;
	page	victim;
	FILE	*trace;


        if (argc < 5) {
             printf( "Usage: ./memsim inputfile numberframes replacementmode debugmode \n");
             exit ( -1);
	}
	else {
        tracename = argv[1];	
	trace = fopen( tracename, "r");
        if (trace == NULL ) {
            printf( "Cannot open trace file %s \n", tracename);
            exit ( -1);
         }
	numFrames = atoi(argv[2]);
	if (numFrames < 1) {
            printf( "Frame number must be at least 1\n");
            exit ( -1);
         }

        if (strcmp(argv[3], "lru\0") == 0)
            replace = lru;
	    else if (strcmp(argv[3], "rand\0") == 0)
	     replace = random;
	          else if (strcmp(argv[3], "esc\0") == 0)
                       replace = enhanced2ndchance;		 
        else 
	  {
             printf( "Replacement algorithm must be rand/lru/esc  \n");
             exit ( -1);
	  }

        if (strcmp(argv[4], "quiet\0") == 0)
            debugmode = 0;
	else if (strcmp(argv[4], "debug\0") == 0)
            debugmode = 1;
        else 
	  {
             printf( "Replacement algorithm must be quiet/debug  \n");
             exit ( -1);
	  }
	}
	
	done = createMMU (numFrames);
	if ( done == -1 ) {
		 printf( "Cannot create MMU" ) ;
		 exit(-1);
        }
	no_events = 0 ;
	disk_writes = 0 ;
	disk_reads = 0 ;

        do_line = fscanf(trace,"%x %c",&address,&rw);
	while (do_line == 2) {
		page_number =  address >> pageoffset;
		frame_no = checkInMemory( page_number) ;    /* ask for physical address */

		if ( frame_no == -1 )
		{
		  disk_reads++ ;			/* Page fault, need to load it into memory */
		  if (debugmode) 
		      printf( "Page fault %8d \n", page_number) ;
		  if (allocated < numFrames)  			/* allocate it to an empty frame */
		   {
                     allocateFrame(page_number);
		     allocated++;
                   }
                   else{
		      victim = selectVictim(page_number, replace) ;   /* find frameNo of the victim  */

		   if (victim.modified)           /* need to know victim page and modified  */
	 	      {
                      disk_writes++;			    
                      if (debugmode) printf( "Disk write %8d \n", victim.pageNo) ;
		      }
		   else 
                      if (debugmode) printf( "Discard    %8d \n", victim.pageNo) ;

		   }
		}
		if ( rw == 'R')
		     /* need to update reference status for lru or esc */
			if (debugmode) printf( "reading    %8d \n", page_number) ;
		else if ( rw == 'W')
                     /* need to set this page as modified */	
			if (debugmode) printf( "writting   %8d \n", page_number) ;
		 else {
		      printf( "Badly formatted file. Error on line %d\n", no_events+1); 
		      exit (-1);
		}
	        no_events++;
                do_line = fscanf(trace,"%x %c",&address,&rw);
	}

	printf( "total memory frames:  %d\n", numFrames);
	printf( "events in trace:      %d\n", no_events);
	printf( "total disk reads:     %d\n", disk_reads);
	printf( "total disk writes:    %d\n", disk_writes);
	printf( "page fault rate:      %.2f\n",  (float) disk_reads/no_events);
}