[x265] [PATCH] PSNR performance script

Steve Borho steve at borho.org
Fri Jul 19 19:45:45 CEST 2013


On Fri, Jul 19, 2013 at 9:47 PM, <mahesh at multicorewareinc.com> wrote:

> # HG changeset patch
> # User maheshpittala
> # Date 1374288442 25200
> # Node ID 1b6048d7e1d46c9b05f0f37c9d60a0fae8d6130d
> # Parent  8f0e95ff94ee27772301ae6a4aeb047a6fa76a00
> PSNR performance script
>
> diff -r 8f0e95ff94ee -r 1b6048d7e1d4 source/PSNR_Performance.bat
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
> +++ b/source/PSNR_Performance.bat       Fri Jul 19 19:47:22 2013 -0700
> @@ -0,0 +1,50 @@
> +cd %Builddir%\8bit\Release
>

It's parsing commandlines.txt and then ignoring the contents?


> +FOR /F "delims=EOF" %%i IN (%workingdir%\commandlines.txt) do (
>

This looks like it needs to be a subroutine as well.  See also:

http://stackoverflow.com/questions/3713601/subroutines-in-batch-files


> + @echo x265.exe  %video1%.y4m  %%i --no-rdo -f %frames1% -o script.out -r
> script.rec >> "%workingdir%encoder_output_%video1%_no_rdo.txt"
>

x265 now has a --csv [LOGFILE] command line option.  It adds one line to
the CSV per run and each line has the CLI option, the elapsed time, FPS,
bitrate, and global PSNR.  These script should definitely use this feature.


> + x265.exe  %video1%.y4m  %%i --no-rdo -f %frames1% -o script.out -r
> script.rec >> "%workingdir%encoder_output_%video1%_no_rdo.txt" 2>&1
> + @echo %%i --no-rdo  >> "%workingdir%decoder_output_%video1%_no_rdo.txt"
> + %decoder% -b script.out -o script.yuv >>
> "%workingdir%decoder_output_%video1%_no_rdo.txt"
> + @echo %%i --no-rdo  >> "%workingdir%dr_psnr_output_%video1%_no_rdo.txt"
> + %drpsnr% -r %video1%.yuv -c script.yuv -w 1920 -h 1080 -e %frames1% >>
> "%workingdir%dr_psnr_output_%video1%_no_rdo.txt"
>

drpsnr use should be optional, I'm not sure if it should be included at all
in these scripts.  It is not going to give numbers any more accurately than
x265.  It is especially bad that you have to hard code the resolution here.


> +
> + @echo x265.exe  %video1%.y4m  %%i --rdo  -f %frames1% -o script.out -r
> script.rec >> "%workingdir%encoder_output_%video1%_rdo.txt"
> + x265.exe  D:\\BasketballDrive_1920x1080_50.y4m  %%i --rdo    -f
> %frames1% -o script.out -r script.rec >>
> "%workingdir%encoder_output_%video1%_rdo.txt" 2>&1
> + @echo %%i --rdo >> "%workingdir%decoder_output_%video1%_rdo.txt"
> + %decoder% -b script.out -o script.yuv >>
> "%workingdir%decoder_output_%video1%_rdo.txt"
> + @echo %%i --rdo  >> "%workingdir%dr_psnr_output_%video1%_rdo.txt"
> + %drpsnr% -r %video1%.yuv -c script.yuv -w 1920 -h 1080 -e %frames1% >>
> "%workingdir%dr_psnr_output_%video1%_rdo.txt"
> +
> +
> +
> + @echo x265.exe  %video2%.y4m  %%i --no-rdo -f %frames1% -o script.out -r
> script.rec >> "%workingdir%encoder_output_%video2%_no_rdo.txt"
> + x265.exe  D:\\Kimono1_1920x1080_24.y4m  %%i --no-rdo -f %frames1% -o
> script.out -r script.rec >>
> "%workingdir%encoder_output_%video2%_no_rdo.txt" 2>&1
> + @echo %%i --no-rdo  >> "%workingdir%decoder_output_%video2%_no_rdo.txt"
> + %decoder% -b script.out -o script.yuv >>
> "%workingdir%decoder_output_%video2%_no_rdo.txt"
> + @echo %%i --no-rdo  >> "%workingdir%dr_psnr_output_%video2%_no_rdo.txt"
> + %drpsnr% -r %video2%.yuv -c script.yuv -w 1920 -h 1080 -e %frames1% >>
> "%workingdir%dr_psnr_output_%video2%_no_rdo.txt"
> +
> + @echo x265.exe  %video2%.y4m  %%i --rdo  -f %frames1% -o script.out -r
> script.rec >> "%workingdir%encoder_output_%video2%_rdo.txt"
> + x265.exe  D:\\Kimono1_1920x1080_24.y4m  %%i --rdo    -f %frames1% -o
> script.out -r script.rec >> "%workingdir%encoder_output_%video2%_rdo.txt"
> 2>&1
> + @echo %%i --rdo >> "%workingdir%decoder_output_%video2%_rdo.txt"
> + %decoder% -b script.out -o script.yuv >>
> "%workingdir%decoder_output_%video2%_rdo.txt"
> + @echo %%i --rdo  >> "%workingdir%dr_psnr_output_%video2%_rdo.txt"
> + %drpsnr% -r %video2%.yuv -c script.yuv -w 1920 -h 1080 -e %frames1% >>
> "%workingdir%dr_psnr_output_%video2%_rdo.txt"
> +
> +
> +
> + @echo x265.exe  %video3%.y4m  %%i --no-rdo -f %frames1% -o script.out -r
> script.rec >> "%workingdir%encoder_output_%video3%_no_rdo.txt"
> + x265.exe  D:\\FourPeople_1280x720_60.y4m  %%i --no-rdo -f %frames1% -o
> script.out -r script.rec >>
> "%workingdir%encoder_output_%video3%_no_rdo.txt" 2>&1
> + @echo %%i --no-rdo  >> "%workingdir%decoder_output_%video3%_no_rdo.txt"
> + %decoder% -b script.out -o script.yuv >>
> "%workingdir%decoder_output_%video3%_no_rdo.txt"
> + @echo %%i --no-rdo  >> "%workingdir%dr_psnr_output_%video3%_no_rdo.txt"
> + %drpsnr% -r %video3%.yuv -c script.yuv -w 1920 -h 1080 -e %frames1% >>
> "%workingdir%dr_psnr_output_%video3%_no_rdo.txt"
> +
> + @echo x265.exe  %video3%.y4m  %%i --rdo  -f %frames1% -o script.out -r
> script.rec >> "%workingdir%encoder_output_%video3%_rdo.txt"
> + x265.exe  "%workingdir%FourPeople_1280x720_60.y4m"  %%i --rdo    -f
> %frames1% -o script.out -r script.rec >>
> "%workingdir%encoder_output_%video3%_rdo.txt" 2>&1
> + @echo %%i --rdo >> "%workingdir%decoder_output_%video3%_rdo.txt"
> + %decoder% -b script.out -o script.yuv >>
> "%workingdir%decoder_output_%video3%_rdo.txt"
> + @echo %%i --rdo  >> "%workingdir%dr_psnr_output_%video3%_rdo.txt"
> + %drpsnr% -r %video3%.yuv -c script.yuv -w 1920 -h 1080 -e %frames1% >>
> "%workingdir%dr_psnr_output_%video3%_rdo.txt"
> +)
> diff -r 8f0e95ff94ee -r 1b6048d7e1d4 source/Send_Mail.py
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
> +++ b/source/Send_Mail.py       Fri Jul 19 19:47:22 2013 -0700
> @@ -0,0 +1,50 @@
> +#script to send performance result file to xhevc at muticorewareinc.com


Remove these first two lines.  #!/usr/bin/python must be the first line.


>
> +
> +#!/usr/bin/python
> +import os, re
> +import sys
> +import smtplib
> +from email.mime.image import MIMEImage
> +from email.mime.multipart import MIMEMultipart
> +from email.mime.text import MIMEText
> +
> +SMTP_SERVER = 'smtp.gmail.com'
> +SMTP_PORT = 587
> +sender = 'user at multicorewareinc.com'

+password = "password"
>

sender = os.getenv('SMTP_USER', "user at email.com")
password = os.getenv("SMTP_PASSWD", "mypassword")


> +recipient = 'xhevc at multicorewareinc.com'
>

Let's not publicize the internal mailing list.  Ooops, too late.


> +subject = 'Performance Results from Regression Test'
> +message = 'PFA'
> +directory=os.getcwd()
> +
> +def main():
> +    msg = MIMEMultipart()
> +    msg['Subject'] = 'Performance Results'
> +    msg['To'] = recipient
> +    msg['From'] = sender
> +
> +    files = os.listdir(directory)
>

import glob
for file in glob.glob("*.csv"):


> +    txtsearch = re.compile(".csv", re.IGNORECASE)
> +    files = filter(txtsearch.search, files)
> +    for filename in files:
> +        path = os.path.join(directory, filename)
> +        if not os.path.isfile(path):
> +            continue
> +        text = MIMEImage(open(path, 'rb').read(), _subtype="csv")
> +        text.add_header('Content-Disposition', 'attachment',
> filename=filename)
> +        msg.attach(text)
> +
> +    part = MIMEText('text', "plain")
> +    part.set_payload(message)
> +    msg.attach(part)
>

This needs some rudimentary exception handling


> +    session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
> +    session.ehlo()
> +    session.starttls()
> +    session.ehlo
> +    session.login(sender, password)
> +
> +    session.sendmail(sender, recipient, msg.as_string())
> +    session.quit()
> +if __name__ == '__main__':
> +    main()
> diff -r 8f0e95ff94ee -r 1b6048d7e1d4 source/commandlines.txt
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
> +++ b/source/commandlines.txt   Fri Jul 19 19:47:22 2013 -0700
> @@ -0,0 +1,16 @@
> +--wpp --tu-intra-depth 1 --tu-inter-depth 2 --no-tskip --max-merge 1
> --threads 4 --hash 1
> +--rect --max-merge 1 --wpp  --no-rdoq --hash 1
> +--wpp --tu-intra-depth 1 --tu-inter-depth 2 --no-tskip --max-merge 1
> --threads 4 --no-rdoq --hash 1
> +--hash 1
> +--rect --max-merge 1 --hash 1
> +--rect --max-merge 1 --wpp --hash 1
> +--rect --max-merge 1 --cpuid 1 --hash 1
> +--rect --max-merge 1 --cpuid 1 --wpp --hash 1
> +--no-rect --no-amp --hash 1
> +--no-rect --no-amp --max-merge 1 --hash 1
> +--no-rect --no-amp --max-merge 1  --wpp --hash 1
> +--max-merge 1 --wpp --no-rdoq --hash 1
> +--rect --amp --hash 1
> +--sao --hash 1
> +--keyint 1 --hash 1
> +--keyint 32 --hash 1
>

I think this file is superceded by the --csv command line switch, please
drop it from the patch for now


> diff -r 8f0e95ff94ee -r 1b6048d7e1d4 source/performance_XL.py
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
> +++ b/source/performance_XL.py  Fri Jul 19 19:47:22 2013 -0700
> @@ -0,0 +1,158 @@
> +#Script for Reading encoded and PSNR results from log files
> +
> +#!/usr/bin/python
> +import os
> +import re
> +searchquery1 = 'encoded'
> +searchquery2 = '    Global'
> +inputs_var=0
> +cmd_var=0
> +inc=0
> +
> +os.remove("Performance_Results.csv")
> +enc_nordo =
> ['encoder_output_BasketballDrive_1920x1080_50_no_rdo.txt','encoder_output_FourPeople_1280x720_60_no_rdo.txt','encoder_output_Kimono1_1920x1080_24_no_rdo.txt']
> +psnr_nordo
> =['dr_psnr_output_BasketballDrive_1920x1080_50_no_rdo.txt','dr_psnr_output_FourPeople_1280x720_60_no_rdo.txt','dr_psnr_output_Kimono1_1920x1080_24_no_rdo.txt']
> +enc_rdo =
> ['encoder_output_BasketballDrive_1920x1080_50_rdo.txt','encoder_output_FourPeople_1280x720_60_rdo.txt','encoder_output_Kimono1_1920x1080_24_rdo.txt']
> +psnr_rdo =
> ['dr_psnr_output_BasketballDrive_1920x1080_50_rdo.txt','dr_psnr_output_FourPeople_1280x720_60_rdo.txt','dr_psnr_output_Kimono1_1920x1080_24_rdo.txt']
> +
> +cmdlines = [' --wpp --tu-intra-depth 1 --tu-inter-depth 2 --no-tskip
> --max-merge 1 --threads 4 ',' --rect --max-merge 1 --wpp  --no-rdoq','--wpp
> --tu-intra-depth 1 --tu-inter-depth 2 --no-tskip --max-merge 1 --threads 4
> --no-rdoq',' default ',' --rect --max-merge 1 ',' --rect --max-merge 1
> --wpp ',' --rect --max-merge 1 --cpuid 1 ', ' --rect --max-merge 1 --cpuid
> 1 --wpp ',' --no-rect --no-amp ','--no-rect --no-amp --max-merge 1 ','
> --no-rect --no-amp --max-merge 1 --wpp','--max-merge 1 --wpp --no-rdoq ','
> --rect --amp' ,' --sao ',' --keyint 1 ',' --keyint 32 ']
>

cmdlines = open('commandlines.txt', 'r').read().splitlines()


> +inputs = [' 1.BasketballDrive_1920x1080_50.y4m', '
> 2.FourPeople_1280x720_60.y4m', ' 3.Kimono1_1920x1080_24.y4m']
>

These should be read from config.txt, I guess


> +
> +log = open('Performance_Results.csv','w')
> +print (",,,,,,,,,, NO_RDO,,,,,,,,,, RDO  ", file = log)
> +
> +print ("    COMMAND LINE,,,,,,,     ,    TOTAL TIME(seconds),
>  SPEED(fps),    BITRATE(kb/s),    FRAMES,    PSNR(Y)_Global,    PSNR(U),
>  PSNR(V), avg,      ,    TOTAL TIME(seconds),    SPEED(fps),
>  BITRATE(kb/s),    FRAMES,    PSNR(Y)_Global,    PSNR(U),    PSNR(V), avg",
> file = log)
> +print (" ", file = log)
> +
> +for enc in enc_nordo:
> +       print ("%s" %(inputs[inputs_var]), file = log)
> +       print (" ", file = log)
> +       psnr=psnr_nordo[inputs_var]
> +
> +       out1 = open('output1.txt', 'a')
> +       print ("encoder output for nordo...", file = out1)
> +       out1.close()
> +       out2 = open('output2.txt', 'a')
> +       print ("dr_psnr output for nordo...", file = out2)
> +       out3 = open('output3.txt', 'a')
> +       print ("encoder output for rdo...", file = out3)
> +       out3.close()
> +       out4 = open('output4.txt', 'a')
> +       print ("dr_psnr output for rdo...", file = out4)
> +       out4.close()
> +
> +       #encoder output for nordo
> +       f1 = open(enc, 'r')
> +       out1 = open('output1.txt', 'a')
> +       line1 = f1.readlines()
> +       for i, line in enumerate(line1):
> +         if line.startswith(searchquery1):
> +             for char in line:
> +              line = re.sub('[(]','',line)
> +              line = re.sub('[s]','',line)
> +             out1.write(line)
> +       f1.close ()
> +       out1.close()
> +
> +       #dr_psnr output for nordo
> +       f2 = open(psnr, 'r')
> +       out2 = open('output2.txt', 'a')
> +       line2 = f2.readlines()
> +       for i, line in enumerate(line2):
> +         if line.startswith(searchquery2):
> +             out2.write(line)
> +       f2.close ()
> +       out2.close()
> +
> +       #encoder output for rdo
> +       f3 = open(enc_rdo[inc], 'r')
> +       out3 = open('output3.txt', 'a')
> +       line3 = f3.readlines()
> +       for i, line in enumerate(line3):
> +         if line.startswith(searchquery1):
> +             for char in line:
> +              line = re.sub('[(]','',line)
> +              line = re.sub('[s]','',line)
> +             out3.write(line)
> +       f3.close ()
> +       out3.close()
> +
> +       #dr_psnr output for rdo
> +       f4 = open(psnr_rdo[inc], 'r')
> +       out4 = open('output4.txt', 'a')
> +       line4 = f4.readlines()
> +       for i, line in enumerate(line4):
> +         if line.startswith(searchquery2):
> +             out4.write(line)
> +       f4.close ()
> +       out4.close()
> +
> +       out1 = open('output1.txt')
> +       out2 = open('output2.txt')
> +       out3 = open('output3.txt')
> +       out4 = open('output4.txt')
> +
> +       log = open('Performance_Results.csv','a')
> +       eof1 = out1.readline()
> +       eof2 = out2.readline()
> +       eof3 = out3.readline()
> +       eof4 = out4.readline()
> +
> +       #for a in eof1:
> +       num_lines = sum(1 for line in open('output1.txt'))
> +
> +       for index in range(num_lines-1):
> +           #for b in eof2:
> +                  eof1 = out1.readline()
> +                  eof2 = out2.readline()
> +                  eof3 = out3.readline()
> +                  eof4 = out4.readline()
> +
> +                  col1 = eof1.split()
> +                  print (col1)
> +                  col2 = eof2.split()
> +                  print (col2)
> +                  col3 = eof3.split()
> +                  print (col3)
> +                  col4 = eof4.split()
> +                  print (col4)
> +
> +                  time = col1[4]
> +                  time1 = col3[4]
> +
> +                  speed = col1[5]
> +                  speed1 = col3[5]
> +
> +                  bitrate = float(col1[7])
> +                  bitrate1 = float(col3[7])
> +
> +                  frames = int(col1[1])
> +                  frames1 = int(col3[1])
> +
> +                  psnr_y  = float(col2[1])
> +                  psnr_u  = float(col2[2])
> +                  psnr_v  = float(col2[3])
> +                  avg_psnr = (float)((psnr_y+psnr_u+psnr_v)/3)
> +
> +                  psnr_y1  = float(col4[1])
> +                  psnr_u1  = float(col4[2])
> +                  psnr_v1  = float(col4[3])
> +                  avg_psnr1 = (float)((psnr_y1+psnr_u1+psnr_v1)/3)
> +
> +                  print
> ("%s,,,,,,,,%s,%s,%f,%d,%f,%f,%f,%f,,%s,%s,%f,%d,%f,%f,%f,%f"
> %(cmdlines[cmd_var],time,speed,bitrate,frames,psnr_y,psnr_u,psnr_v,avg_psnr,time1,speed1,bitrate1,frames1,psnr_y1,psnr_u1,psnr_v1,avg_psnr1),
> file = log)
> +                  cmd_var=cmd_var+1
> +
> +
> +       out1.close()
> +       out2.close()
> +       out3.close()
> +       out4.close()
> +       os.remove("output1.txt")
> +       os.remove("output2.txt")
> +       os.remove("output3.txt")
> +       os.remove("output4.txt")
> +       inputs_var=inputs_var+1
> +       cmd_var=0
> +       inc=inc+1
> +       print (" ", file = log)
> +log.close()
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> http://mailman.videolan.org/listinfo/x265-devel
>
>


-- 
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/private/x265-devel/attachments/20130719/9a91e7e4/attachment-0001.html>


More information about the x265-devel mailing list