#!/bin/sh
#Copyright (c) 2018, Intel Corporation All Rights Reserved.

#The source code, information and material ("Material") contained #herein is owned by Intel Corporation 
#or its suppliers or licensors, and title to such Material remains #with Intel Corporation or its 
#suppliers or licensors. The Material contains proprietary #information of Intel or its suppliers 
#and licensors. The Material is protected by worldwide copyright laws #and treaty provisions. No part of 
#the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, 
#distributed or disclosed in any way without Intel's prior express written permission. 
#No license under any patent, copyright or other intellectual property rights in the Material is granted 
#to or conferred upon you, either expressly, by implication, inducement, estoppel or otherwise. Any 
#license under such intellectual property rights must be express and approved by Intel in writing.

#Unless otherwise agreed by Intel in writing, you may not remove or alter this notice or any other 
#notice embedded in Materials by Intel or Intels suppliers or licensors in any way.

TU=7
streams=$1
inpFile=$2
node=$4
outDir=$3/$node
k="_MSS_verify.log"
j="$4$k"
binpath=/mnt/vvvalidation/tools/h264/bin/sample_multi_transcode_$5
statspath=/mnt/vvvalidation/tools/h264/stats/$node
parpath=/mnt/vvvalidation/tools/h264/parfiles/$node
jobpath=/mnt/vvvalidation/tools/h264/jobfiles/$node
MSSlogfile=/mnt/vvvalidation/tools/h264/logs/$j
scriptpath=/mnt/vvvalidation/tools/h264/scripts

###########################################################
##########################

filename=$(basename $inpFile)
extn="${filename##*.}"
fname="${filename%.*}"
inpDir=$(dirname "${inpFile}")

#below out the existing - start frsh each time 
rm -rf $statspath $parpath $jobpath $outDir
mkdir -p $parpath $statspath $outDir $jobpath $scriptpath
i=0
    parfile=parfile\_TU$TU\_HD\_$streams\_$fname
    parfile_7s=parfile\_TU$TU\_SD\_$streams\_$fname

    

    for k in $(seq 1 $streams)
    do
        i=$((i+1))
        inp=$inpDir/$node/$fname\_$i.$extn
        #echo -hw -b 8000  -f 30 -u $TU -async 5 -w 1920 -h 1080 -i::mpeg2 $inp -o::h264 $outDir/$fname\_TU$TU\_hd\_$i.h264 >> $parpath/$parfile
        #echo -hw -b 10000  -f 30 -u $TU -async 5 -i::h264 $inp -o::h264 $outDir/$fname\_TU$TU\_hd\_$i.h264 >> $parpath/$parfile
        #echo  -hw -async 5 -brc 2 -u $TU  -qpi 24 -qpp 26 -qpb 28 -gps 61 -grd 3 -cprofile 100 -clevel 41  -i::h264 $inp -o::h264 $outDir/$fname\_TU$TU\_hd\_$i.h264 >> $parpath/$parfile 
        echo  -async 3 -hw  -u $TU -cqp -qpi 24 -qpp 26 -qpb 28 -gop_size 61 -dist 3 -i::h264 $inp -o::h264 /dev/null >> $parpath/$parfile 
        #echo -hw -b 5000 -f 30 -u 7 -async 5 -w 1280 -h 720 -i::h264 $inp -o::mpeg2 $outDir/$fname\_TU7\_sd\_$i.h264 >> $parpath/$parfile_7s
	#-i::mpeg2 Channel1.m2v -o::h264 Channel1.264 -b 8000 -f 30 -u 7 -w 1920 -h 1080 -hw -join -async 5
#de_drm  -hw -async 5 -brc 2 -qpi 24 -qpp 26 -qpb 28 -gps 61 -grd 3 -cprofile 100 -clevel 41
    done

    #$5 is the Driver binpath comparison between PV3, PV4 and PV5 done in density.py

    jobfile=$jobpath/jobfile\_$streams.sh
    echo "$binpath -p $statspath/$parfile_7.stats -par $parpath/$parfile" >> $jobfile

    chmod a+x $jobfile


