#make fprofiled

IN="matrix2.mkv -vf crop=1280:528 -ss 85 -frames 10000"

run() {
    LOG="x264.prof.$1.0"
    echo "x264 $2" > $LOG
    x264 --version >> $LOG
    echo gcc 4.1.2 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 -nocache &
    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 3 --crf 20 -b3 -r1 -m3 -t0 -8"
run m "--threads 3 --crf 20 -b3 -r4 -m6 -t1 -8 -w --b-rdo --mixed-refs --me umh --merange 12"
run s "--threads 3 --crf 20 -b3 -r6 -m7 -t2 -8 -w --b-rdo --mixed-refs --me umh -Aall --bime --direct auto --no-fast-pskip"
run l "--threads 3 -q0 -m5 --scenecut 5"
rm -f fifo.y4m

for i in x264.prof.?.0 ; do head -3 $i > ${i%\.0}.1 ; ~/src/media/scripts/merge_oprof_x264.pl $i >> ${i%\.0}.1 ; done

