mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	l3_video: listing sorted bps rates
This commit is contained in:
		| @@ -34,8 +34,8 @@ our $cx_name         = ""; | |||||||
| our $tx_side         = "B"; | our $tx_side         = "B"; | ||||||
| our $min_tx          = undef; | our $min_tx          = undef; | ||||||
| our $max_tx          = -1; | our $max_tx          = -1; | ||||||
| our $est_buf_size    = -1; | our $buf_size        = -1; | ||||||
| our $log_cli         = 0; | our $log_cli         = "unset"; # do not set to 0, it turns into logfile "./0" | ||||||
| our $stream_res      = undef; | our $stream_res      = undef; | ||||||
| our @frame_rates     = ( 10, 12, 15, 24, 25, 29.97, 30, 50, 59.94, 60); | our @frame_rates     = ( 10, 12, 15, 24, 25, 29.97, 30, 50, 59.94, 60); | ||||||
| our $frame_rates_desc = join(", ", @::frame_rates); | our $frame_rates_desc = join(", ", @::frame_rates); | ||||||
| @@ -51,6 +51,26 @@ our @audio_rates      = 128000; # 128k | |||||||
| # https://blog.forret.com/2006/09/27/hd-720p-1080i-and-1080p/ | # https://blog.forret.com/2006/09/27/hd-720p-1080i-and-1080p/ | ||||||
| # Framerate is highly subjective in digital formats, because there are | # Framerate is highly subjective in digital formats, because there are | ||||||
| # variable frame rates dictated by min- and max-frame rate. | # variable frame rates dictated by min- and max-frame rate. | ||||||
|  | our %stream_keys = ( | ||||||
|  |   'w'           => 0, | ||||||
|  |   'width'       => 0, | ||||||
|  |   'x'           => 0, | ||||||
|  |   'h'           => 1, | ||||||
|  |   'height'      => 1, | ||||||
|  |   'y'           => 1, | ||||||
|  |   'i'           => 2, | ||||||
|  |   'interlaced'  => 2, | ||||||
|  |   'audio'       => 3, | ||||||
|  |   'audio_bps'   => 3, | ||||||
|  |   'video'       => 4, | ||||||
|  |   'video_bps'   => 4, | ||||||
|  |   'stream'      => 5, | ||||||
|  |   'stream_bps'  => 5, | ||||||
|  |   'fps'         => 6, | ||||||
|  |   'frames'      => 6, | ||||||
|  |   'framerate'   => 6, | ||||||
|  |   ); | ||||||
|  |  | ||||||
| our %avail_stream_res = ( | our %avail_stream_res = ( | ||||||
|   # nicname             w,    h,  interlaced,   audio,    vid bps,   tt bps   framerate |   # nicname             w,    h,  interlaced,   audio,    vid bps,   tt bps   framerate | ||||||
|   "sqvga-4:3"     => [  160,  120,    0,        16000,    32000,      48000,    30], |   "sqvga-4:3"     => [  160,  120,    0,        16000,    32000,      48000,    30], | ||||||
| @@ -71,7 +91,7 @@ our %avail_stream_res = ( | |||||||
|   "d1-1200k-4:3"  => [  640,  480,    0,        32000,  1168000,    1200000,    30], |   "d1-1200k-4:3"  => [  640,  480,    0,        32000,  1168000,    1200000,    30], | ||||||
|   "d1-1200k-16:9" => [  852,  480,    0,        32000,  1168000,    1200000,    30], |   "d1-1200k-16:9" => [  852,  480,    0,        32000,  1168000,    1200000,    30], | ||||||
|   "hd-1800k-16:9" => [ 1280,  720,    0,        64000,  1736000,    1800000,    59.94], |   "hd-1800k-16:9" => [ 1280,  720,    0,        64000,  1736000,    1800000,    59.94], | ||||||
|   "hd-2400k-16:9" => [ 1280,  720,    0,        64000,  2272000,    2400000,    59.94], |   "hd-2400k-16:9" => [ 1280,  720,    0,        64000,  2272000,    2336000,    59.94], | ||||||
|  |  | ||||||
|  |  | ||||||
|   "108p4:3"       => [  144,  108,    0,        16000,    32000,      48000,    30], |   "108p4:3"       => [  144,  108,    0,        16000,    32000,      48000,    30], | ||||||
| @@ -121,22 +141,23 @@ our %avail_stream_res = ( | |||||||
|   "yt-hdr-2160p60" => [ 3840, 2160,    0,       512000, 75500000,   1800000,    60], |   "yt-hdr-2160p60" => [ 3840, 2160,    0,       512000, 75500000,   1800000,    60], | ||||||
|  |  | ||||||
|  |  | ||||||
|   "raw720p30"      => [ 1280,  720,    0,        64000,  1736000,  221184000,    30], |   "raw720p30"      => [ 1280,  720,    0,        64000,  221120000,  221184000,    30], | ||||||
|   "raw720p60"      => [ 1280,  720,    0,        64000,  1736000,  442368000,    60], |   "raw720p60"      => [ 1280,  720,    0,        64000,  442304000,  442368000,    60], | ||||||
|  |  | ||||||
|   # frame size 6.2MB |   # frame size 6.2MB | ||||||
|   # 1080i60 1920x1080 186MBps |   # 1080i60 1920x1080 186MBps | ||||||
|   "raw1080i"       => [ 1920,  540,    1,       128000,  1736000, 1486512000,    59.94], |   "raw1080i"       => [ 1920,  540,    1,       128000,  1486384000, 1486512000,    59.94], | ||||||
|   "raw1080i30"     => [ 1920,  540,    1,       128000,  1736000, 1488000000,    30], |   "raw1080i30"     => [ 1920,  540,    1,       128000,  1487872000, 1488000000,    30], | ||||||
|   "raw1080i60"     => [ 1920,  540,    1,       128000,  1736000, 1488000000,    60], |   "raw1080i60"     => [ 1920,  540,    1,       128000,  1487872000, 1488000000,    60], | ||||||
|  |  | ||||||
|   # 1080p60 1920x1080 373MBps, 6.2Mbps frame size |   # 1080p60 1920x1080 373MBps, 6.2Mbps frame size | ||||||
|   "raw1080p"       => [ 1920, 1080,    0,       128000,  1736000, 2976000000,    60], |   "raw1080p"       => [ 1920, 1080,    0,       128000,  2975872000, 2976000000,    60], | ||||||
|  |  | ||||||
| ); | ); | ||||||
|  |  | ||||||
| our $avail_stream_desc = join(", ", keys(%avail_stream_res)); | our $avail_stream_desc = join(", ", keys(%avail_stream_res)); | ||||||
| our $resolution = "720p"; | our $resolution = "720p"; | ||||||
|  | my $list_streams = 0; | ||||||
|  |  | ||||||
| our $usage = "$0  # modulates a Layer 3 CX to emulate a video server | our $usage = "$0  # modulates a Layer 3 CX to emulate a video server | ||||||
|   --mgr        {hostname | IP} |   --mgr        {hostname | IP} | ||||||
| @@ -147,12 +168,16 @@ our $usage = "$0  # modulates a Layer 3 CX to emulate a video server | |||||||
|     # default $tx_side |     # default $tx_side | ||||||
|   --min_tx     {speed in bps} |   --min_tx     {speed in bps} | ||||||
|   --max_tx     {speed in bps|SAME} |   --max_tx     {speed in bps|SAME} | ||||||
|   --est_buf_size {kilobytes}  # fill a buffer at max_tx for this long |   --buf_size   {kilobytes}  # fill a buffer at max_tx for this long | ||||||
|   --frame_rate {$frame_rates_desc} |  | ||||||
|     # default $frame_rate |     # default $frame_rate | ||||||
|   --stream_res {$avail_stream_desc} |   --stream_res {$avail_stream_desc} | ||||||
|  |   --list_streams # show stream bps table and exit | ||||||
|     # default $resolution |     # default $resolution | ||||||
|  |   --log_cli {0|1} | ||||||
| "; | "; | ||||||
|  | #  --frame_rate {$frame_rates_desc} # not really applicable | ||||||
|  | # the stream resolution (kbps) is really a better burn rate | ||||||
|  |  | ||||||
| my $show_help = 0; | my $show_help = 0; | ||||||
|  |  | ||||||
| @@ -163,12 +188,17 @@ if (@ARGV < 2) { | |||||||
| GetOptions | GetOptions | ||||||
| ( | ( | ||||||
|    'help|h'             => \$show_help, |    'help|h'             => \$show_help, | ||||||
|    'cx_name|e=s'        => \$::cx_name, |  | ||||||
|    'set_tx|side|s=s'    => \$::tx_side, |  | ||||||
|    'mgr|m=s'            => \$::lfmgr_host, |    'mgr|m=s'            => \$::lfmgr_host, | ||||||
|    'mgr_port|p=i'       => \$::lfmgr_port, |    'mgr_port|p=i'       => \$::lfmgr_port, | ||||||
|  |    'log_cli=s{0,1}'     => \$log_cli, | ||||||
|    'tx_style|style=s'   => \$::tx_style, |    'tx_style|style=s'   => \$::tx_style, | ||||||
|    'est_buf_size|buf=i' => \$::est_buf_size, |    'cx_name|e=s'        => \$::cx_name, | ||||||
|  |    'set_tx|side|s=s'    => \$::tx_side, | ||||||
|  |    'min_tx=i'           => \$::min_tx, | ||||||
|  |    'max_tx=i'           => \$::max_tx, | ||||||
|  |    'buf_size|buf=i'     => \$::buf_size, | ||||||
|  |    'stream_res=s'       => \$::stream_res, | ||||||
|  |    'list_streams'       => \$list_streams, | ||||||
| ) || die($::usage); | ) || die($::usage); | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -177,6 +207,36 @@ if ($show_help) { | |||||||
|    exit 0; |    exit 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | if ($list_streams) { | ||||||
|  |   print "Predefined Video Streams\n"; | ||||||
|  |   print "=" x 72; | ||||||
|  |   print "\n"; | ||||||
|  |   my %sortedkeys = (); | ||||||
|  |   foreach my $oldkey (keys(%::avail_stream_res)) { | ||||||
|  |     my $ra_row  = $::avail_stream_res{$oldkey}; | ||||||
|  |     my $x       = 10000 + int(@$ra_row[$stream_keys{x}]); | ||||||
|  |     my $y       = 10000 + int(@$ra_row[$stream_keys{y}]); | ||||||
|  |     my $newkey = "${x}_${y}_${oldkey}"; | ||||||
|  |     $sortedkeys{$newkey} = $oldkey; | ||||||
|  |   } | ||||||
|  |   foreach my $sorted_key (sort(keys(%sortedkeys))) { | ||||||
|  |     my $key = $sortedkeys{$sorted_key}; | ||||||
|  |     my $ra_row1 = $::avail_stream_res{$key}; | ||||||
|  |     my $x       = @$ra_row1[$stream_keys{x}]; | ||||||
|  |     my $y       = @$ra_row1[$stream_keys{y}]; | ||||||
|  |     my $bps     = int(@$ra_row1[$stream_keys{stream_bps}]); | ||||||
|  |     my $bps_sum = int(@$ra_row1[$stream_keys{video_bps}]) + int(@$ra_row1[$stream_keys{audio_bps}]); | ||||||
|  |     #my $warning = ""; | ||||||
|  |     printf("[ %15s ]  %5s x %5s using %13s", $key, $x, $y, $bps); | ||||||
|  |     if ($bps != $bps_sum) { | ||||||
|  |       print " Invalid BPS $bps, correct to $bps_sum"; | ||||||
|  |     } | ||||||
|  |     print "\n"; | ||||||
|  |  | ||||||
|  |   } | ||||||
|  |   exit 0; | ||||||
|  | } | ||||||
|  |  | ||||||
| if ($::quiet eq "0") { | if ($::quiet eq "0") { | ||||||
|   $::quiet = "no"; |   $::quiet = "no"; | ||||||
| } | } | ||||||
| @@ -189,9 +249,11 @@ if (defined $log_cli) { | |||||||
|     # here is how we reset the variable if it was used as a flag |     # here is how we reset the variable if it was used as a flag | ||||||
|     if ($log_cli eq "") { |     if ($log_cli eq "") { | ||||||
|       $ENV{'LOG_CLI'} = 1; |       $ENV{'LOG_CLI'} = 1; | ||||||
|  |       #print "LOG_CLI now 1\n"; | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
|       $ENV{'LOG_CLI'} = $log_cli; |       $ENV{'LOG_CLI'} = $log_cli; | ||||||
|  |       #print "LOG_CLI now $log_cli\n"; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @@ -229,4 +291,8 @@ else { | |||||||
| $::utils->log_cli("# $0 ".`date "+%Y-%m-%d %H:%M:%S"`); | $::utils->log_cli("# $0 ".`date "+%Y-%m-%d %H:%M:%S"`); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | die ("Please provide cx_name") | ||||||
|  |   unless((defined $::cx_name) && ("" ne $::cx_name)); | ||||||
| # print out choices for now | # print out choices for now | ||||||
|  | print $::utils->doAsyncCmd($::utils->fmt_cmd("show_cx", "all", $::cx_name)); | ||||||
|  | # | ||||||
		Reference in New Issue
	
	Block a user
	 Jed Reynolds
					Jed Reynolds