From 11077f194d507d386729d1a09ecfadf4c8cf634f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Zumer?= Date: Fri, 22 May 2020 14:54:12 -0400 Subject: [PATCH 1/3] Support single-pass bitrate target mode for rav1e --- metrics_gather.sh | 29 +++++++++++++++++++++++++++++ rd_server.py | 1 + work.py | 3 +++ 3 files changed, 33 insertions(+) diff --git a/metrics_gather.sh b/metrics_gather.sh index 8ba9dae..2caa83d 100755 --- a/metrics_gather.sh +++ b/metrics_gather.sh @@ -97,6 +97,10 @@ if [ -z "$CODEC" ]; then export CODEC=daala fi +if [ -z "$ENCODING_MODE" ]; then + export ENCODING_MODE=quantizer +fi + if [ -z "$x" ]; then echo Missing quality setting exit 1 @@ -136,6 +140,18 @@ TIMER='time -v --output='"$TIMEROUT" TIMERDEC='time -v --output='"$TIMERDECOUT" AOMDEC_OPTS='-S' +if [ $ENCODING_MODE = "bitrate" ]; then + FPS_NUM=$(grep -o -a -m 1 -P "(?<=F)([0-9]+)(?=:[0-9]+)" "$FILE") + FPS_DEN=$(grep -o -a -m 1 -P "(?<=F$FPS_NUM:)([0-9]+)" "$FILE") + # compute the number of frames from the size of the input given y4m metadata + FRAMES=$(($(stat -c %s $FILE) / $WIDTH / $HEIGHT)) + + # computes the anchor bitrate in kilobits per second + anchor_bitrate() { + BITRATE=$(($SIZE * 8 / $FRAMES * $FPS_NUM / $FPS_DEN / 1000)) + } +fi + case $CODEC in daala) $(OD_LOG_MODULES='encoder:10' OD_DUMP_IMAGES_SUFFIX="$BASENAME" $TIMER "$ENCODER_EXAMPLE" -k $KFINT -v "$x" $EXTRA_OPTIONS "$FILE" -o "$BASENAME.ogv" > "$BASENAME-stdout.txt" 2> "$BASENAME-enc.out") @@ -231,6 +247,19 @@ rav1e) echo "AV1 decoder not found, desync/corruption detection disabled." fi + if [ $ENCODING_MODE = "bitrate" ]; then + SIZE=$(stat -c %s $BASENAME.ivf) + anchor_bitrate + + # Perform the encode again in single-pass mode using the anchor bitrate. + $($TIMER $RAV1E $FILE --bitrate $BITRATE -o $BASENAME.ivf -r $BASENAME-rec.y4m --threads 1 $EXTRA_OPTIONS > $BASENAME-enc.out) + if hash dav1d 2>/dev/null; then + $($TIMERDEC dav1d -q -i $BASENAME.ivf -o $BASENAME.y4m) || (echo "Corrupt bitstream detected!"; exit 98) + elif hash aomdec 2>dev/null; then + $($TIMERDEC aomdec --codec=av1 $AOMDEC_OPTS -o $BASENAME.y4m $BASENAME.ivf) || (echo "Corrupt bitstream detected!"; exit 98) + fi + fi + if [ -f $BASENAME.y4m ]; then "$Y4M2YUV" "$BASENAME-rec.y4m" -o rec.yuv "$Y4M2YUV" "$BASENAME.y4m" -o enc.yuv diff --git a/rd_server.py b/rd_server.py index 195d277..5e2ff2b 100755 --- a/rd_server.py +++ b/rd_server.py @@ -103,6 +103,7 @@ def run(self): run.rundir = config['runs'] + '/' + run_id run.log = log_file run.set = info['task'] + run.encoding_mode = info['encoding_mode'] run.bindir = run.rundir + '/x86_64/' run.prefix = run.rundir + '/' + run.set try: diff --git a/work.py b/work.py index 831a4e1..b6e9d6e 100644 --- a/work.py +++ b/work.py @@ -38,6 +38,7 @@ def __init__(self, codec): self.info = {} self.codec = codec self.quality = quality_presets[codec] + self.encoding_mode = 'quantizer' self.runid = get_time() self.extra_options = '' self.save_encode = False @@ -179,6 +180,7 @@ def execute(self): command += 'DAALATOOL_ROOT="'+daalatool_dir+'"' command += ' x="'+str(work.quality) + '" ' command += 'CODEC="'+work.codec+'" ' + command += 'ENCODING_MODE="'+work.encoding_mode + '" ' command += 'EXTRA_OPTIONS="'+work.extra_options + '" ' if self.no_delete: command += 'NO_DELETE=1 ' @@ -227,6 +229,7 @@ def create_rdwork(run, video_filenames): work.run = run work.log = run.log work.quality = q + work.encoding_mode = run.encoding_mode work.runid = run.runid work.codec = run.codec work.bindir = run.bindir From 57f50634c7eede090c666b59ff7a780e8f0102a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Zumer?= Date: Mon, 1 Jun 2020 12:23:28 -0400 Subject: [PATCH 2/3] Delete the anchor encode for bitrate testing --- metrics_gather.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/metrics_gather.sh b/metrics_gather.sh index 2caa83d..b0a462b 100755 --- a/metrics_gather.sh +++ b/metrics_gather.sh @@ -250,6 +250,7 @@ rav1e) if [ $ENCODING_MODE = "bitrate" ]; then SIZE=$(stat -c %s $BASENAME.ivf) anchor_bitrate + rm $BASENAME.ivf # Perform the encode again in single-pass mode using the anchor bitrate. $($TIMER $RAV1E $FILE --bitrate $BITRATE -o $BASENAME.ivf -r $BASENAME-rec.y4m --threads 1 $EXTRA_OPTIONS > $BASENAME-enc.out) From ca94ec15766db4f2396ae887c42af9f510053db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Zumer?= Date: Fri, 5 Jun 2020 14:42:11 -0400 Subject: [PATCH 3/3] Add vimeo-corpus test set --- sets.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sets.json b/sets.json index d3e373a..49b1451 100644 --- a/sets.json +++ b/sets.json @@ -3417,5 +3417,25 @@ "sintel_trailer_2k_720p24-003.y4m", "sintel_trailer_2k_720p24-004.y4m" ] + }, + "vimeo-corpus": { + "type": "video", + "sources": [ + "autumn.y4m", + "blower.y4m", + "brothers.y4m", + "coffee.y4m", + "dolphin.y4m", + "ffmpeg.y4m", + "ocean.y4m", + "rabbit.y4m", + "running_man.y4m", + "sky.y4m", + "slideshow.y4m", + "slow_pan.y4m", + "snowboard.y4m", + "surfing.y4m", + "xmas.y4m" + ] } }