ID 683416
Date 2/12/2021
Public

## A.3.3. c_av_st_video_file_io

The declaration for the c_av_st_video_file_io class:
class c_av_st_video_file_io#(parameter BITS_PER_CHANNEL = 8,
CHANNELS_PER_PIXEL = 3);
Table 95.  Method Calls for c_av_st_video_file_io Class
Method Call Description
function void set_send_control_packets(t_packet_controls); If this method is used to set the send_control_packet control to off, then one control packet is sent at the beginning of video data, but no further control packets are sent.
function t_packet_control get_send_control_packets();
function void set_send_user_packets(t_packet_control s); If the send_user_packets control is off, no user packets at all are sent. Otherwise, user packets are sent before and after any control packets.
function t_packet_control get_send_user_packets();
function void set_send_early_eop_packets(t_packet_control s); If the send_eop_packets control is off, all packets are of the correct length (or longer). Otherwise, early EOP are sent of a length determined by the constraints on early_eop_packet_length.
function t_packet_control get_send_early_eop_packets();
function void set_early_eop_probability(int s); If the send_early_eop_packets control is set to random, the early_eop_probability control determines what proportion of video packets are terminated early.
function int get_early_eop_probability();
function void set_send_late_eop_packets(t_packet_controls); If the send_late_eop_packets control is off, all packets are of the correct length (or longer). Otherwise, late EOP are sent of a length determined by the constraints on late_eop_packet_length.
function t_packet_control get_send_late_eop_packets();
function void set_late_eop_probability (int s); If the send_late_eop_packets control is set to random, the late_eop_probability control determines what proportion of video packets are terminated late.
function int get_late_eop_probability ();
function void set_user_packet_probability (int s); If the send_user_packets is set to random, the user_packet_probability control determines the probability that a user packet being sent before a control packet. It also determines the probability that a user packet will be sent after a control packet.
function int get_user_packet_probability ();
function void set_control_packet_probability(int s); If the send_control_packets control is set to random, the control_packet_probability control determines the probability of a control packet being sent before a video packet.
function int get_control_packet_probability();
function void set_send_garbage_after_control_packets (t_packet_control s); When the send_control_packet() method puts a control packet into the m_video_item_out mailbox, the append_garbage member of the control packet object is set to the value of send_garbage_after_control_packets.
function t_packet_control get_send_garbage_after_control_packets();
function void set_object_name(string s); You can use object_name to name a given object instance of a class to ensure any reporting that the class generates is labeled with the originating object’s name.
function string get_object_name();
function string get_filename(); This returns the filename associated with the object, by the open_file call.
function void set_image_height(bit[15:0]height);
function bit[15:0]get_image_height();
function void set_image_width(bit[15:0] width);
function bit[15:] get_image_width();
function void set_video_data_type(string s);
Sets the fourcc[3] code associated with the raw video data. The following are the supported four character code (FOURCC) codes:
• RGB32
• IYU2
• YUY2
• Y410
• A2R10GB10
• Y210
function string get_video_data_type(); Returns the FOURCC code (for example, RGB32) being used for the raw video data.
function int get_video_packets_handled();
function new(mailbox #(c_av_st_video_item)m_vid_out); Constructor. The mailbox is used to pass all packets in and out of the file I/O object.
function void open_file(string fname, t_rwrw); Files are opened using this method. For example:

t_rw is an enumerated type with values read or write.

NB. The read fails if there is no associated .spc file, for example, vip_car_o.spc).

function void close_file(); For example, video_file_reader.close_file();
task send_control_packet(); The control packet sent is derived from the image height, width, and interlace fields as provided by open_file().
task send_user_packet(); The user packet sent is always comprised of random data and had a maximum length hard-coded to 33 data items.
task_generate_spc_file(); When writing a file, this call creates the necessary associated .spc file.
task read_video_packet(); The main file reading method call. Binary data is read from the file and packed into pixel objects according to the settings of ycbr_pixel_order and endianism. Pixel objects are packed into a video data object, with some pixels optionally added or discarded if late/early EOP is being applied. When one complete field of video has been read (as determined by the height and width controls), the video_data object is put in the mailbox.
task wait_for_and_write_video_packet_to_file(); When called, this method waits for an object to be put in the mailbox (usually from a sink BFM). When a control or a user packet object arrives, this call is reported and ignored. When a video packet arrives, the video data is written to the open file in little endianism format.
Table 96.  Members of c_av_st_video_file_io Class
Member Description

local int video_packets_handled = 0;

video_packets_handled is added whenever a packet is read or written to or from the file.
local int control_packets_handled = 0; control_packets_handled is added whenever a control packet is put in the object’s mailbox.
local int user_packets_handled = 0; user_packets_handled is added whenever a user packet is put in the object's mailbox.
local reg[15:0] image_height;
local reg[15:0] image_width;
local reg[3:0] image_interlaced;
string image_fourcc;
local string object_name = "file_io";
local string filename;
local string spc_filename;
local int fourcc_channels_per_pixel; Set when the associate .spc file is read.
local int fourcc_bits_per_channel; Set when the associate .spc file is read.
local int fourcc_pixels_per_word; Set when the associate .spc file is read.
local int fourcc_channel_lsb; Set when the associate .spc file is read.
int early_eop_probability = 20;
Int late_eop_probability = 20;
int user_packet_probability = 20;
int control_packet_probability = 20;
mailbox #(c_av_st_video_item) m_video_item_out = new(0); The mailbox is used to pass all packets in/out of the file i/o object.
rand t_packet_control send_control_packets = on;
rand t_packet_control send_user_packets = off;
rand t_packet_control send_early_eop_packets = off;
rand t_packet_control send_late_eop_packets = off; If both send_late_eop_packets and send_early_eop_packets are set to random, a late EOP will only be generated if an early EOP has not been generated.
rand t_packet_control send_garbage_after_control_packets = off;
rand int early_eop_packet_length = 20; constraint early_eop_length { early_eop_packet_length dist {1:= 10, [2:image_height*image_width-1]:/90}; early_eop_packet_length inside {[1:image_height*image_width]}; }
rand int late_eop_packet_length = 20; constraint late_eop_length { late_eop_packet_length inside {[1:100]}; }