System OpenGL code
'Define pic_w 176 // image width' define pic_h 144 // Image Height 'define frame 300 // total number of frames 'define h_clk 5 // half-cycle typedef byte unsigned ubyte_t; // read a frame image, num indicates the first frame, read pixels are stored in the array frame import "DPI-C" function int read_yuv (inout ubyte_t frame [], input int num); program rdic rd_yuv int I _frame = 0; // indicates the number of frames to read, ubyte_t frame ['pic _ H] ['pic _ w] From frame 1; // an array containing pixels initial begin bit CLK; // read reference frame A1: assert (read_yuv (frame, I _frame) = 1) else $ error ("read frame failed! "); Fork forever # 'H _ CLK =! CLK; forever @ (posedge CLK) Begin // process #100 + + I _frame; // process A2: assert (read_yuv (frame, I _frame) = 1) else $ error ("read frame failed! "); End join_none endendprogram
C language code. Only brightness and color are read.
# Include <math. h> # include <stdio. h> # include <stdlib. h> # include <malloc. h> # include <string. h> # include <svdpi. h> # define pic_p "f :\\ sequence \ YUV \ foreman_qcif.yuv" // image path int read_yuv (const svopenarrayhandle pix_array, const int I _frame) {int width, height; uint8_t * ADDR; file * FP; width = svsize (pix_array, 2); // obtain the image width, height = svsize (pix_array, 1 ); // obtain the Image Height ADDR = (uint8_t *) svgetarrayptr (pix_array); // open the file fp = Fopen (pic_p, "rb"); If (! FP) return 0; // locate the start of a frame. If (fseek (FP, (uint64_t) (I _frame) * width * height * 3/2, seek_set) return 0; // read the Y component to the memory if (fread (ADDR, 1, width * height, FP) <= 0) return 0; fclose (FP); return 1 ;}