#make fprofiled

IN="the_matrix.mkv -ss 100 -frames 10000"

run() {
    LOG="x264.prof.$1.0"
    echo "x264 $2" > $LOG
    x264 --version >> $LOG
    echo gcc `gcc --version | grep -oP '\d\.\d\.\d' | head -1` fprofiled >> $LOG
    rm -f fifo.y4m
    mkfifo fifo.y4m
    sudo opcontrol --init
    sudo opcontrol --start
    sudo opcontrol --reset
    mplayer $IN -vo yuv4mpeg:file=fifo.y4m -nosound -benchmark &
    x264 fifo.y4m $2 --no-ssim --no-psnr --thread-input -o /dev/null >> $LOG 2>&1
    sudo opcontrol --stop
    sudo opcontrol --dump
    opreport -l $HOME/src/media/x264/x264 >> $LOG
}

run f "--threads 2 --crf 20 -b3 -r1 -m3 -t0 -8"
run m "--threads 2 --crf 20 -b3 -r4 -m6 -t1 -8 -w --b-rdo --mixed-refs --me umh --merange 12"
run s "--threads 2 --crf 20 -b3 -r6 -m7 -t2 -8 -w --b-rdo --mixed-refs --me umh -Aall --bime --direct auto --no-fast-pskip"
run l "-q0 -m5 -Aall --scenecut 5"
rm -f fifo.y4m

for i in x264.prof.?.0 ; do merge_oprof_x264.pl $i > ${i/\.0/}.1 ; done

