WP3: Hybrid Model v1 qp

From VQEG JEG Wiki
Jump to: navigation, search

WP3: Hybrid model implementation

First hybrid model implementation using the quantization parameter

In the hybrid model implementation different programming languages can be combined. For example, python could be used for parsing the XML file generated by the tools extracting the necessary parameters (XML parsing based on C but easier to handle) while C++ could be used for image processing.

The first version of the model considers the quantization parameter in the case it remains constant along the sequence (valid for QP values approx. between 28 and 44) and has been implemented in Python. The model does not consider up to now the transmission distortions. The model is based on the following paper:

  • Analysis of Freely Available Subjective Dataset for HDTV including Coding and Transmission Distortions, Fifth International Workshop on Video Processing and Quality Metrics for Consumer Electronics (VPQM–10), Scottsdale, Arizona, January 13–15, 2010.
    • Authors: Marcus Barkowsky, Margaret Pinson, Romuald Pépion, Patrick Le Callet
    • Abstract: We present the design, preparation, and analysis of a subjective experiment on typical HDTV sequences and scenarios. This experiment follows the guidelines of ITU and VQEG in order to obtain reproducible results. The careful selection of content and distortions extend over a wide and realistic range of typical transmission scenarios. Detailed statistical analysis provides important insight into the relationship between technical parameters of encoding, transmission and decoding and subjectively perceived video quality.

The code is explained in detail below:

import xml.etree.cElementTree as ET The cElementTree module is a C implementation of the ElementTree API, optimized for fast parsing and low memory use. cElementTree is included with Python 2.5 and later, as xml.etree.cElementTree
import time
import sys
if len(sys.argv) < 2: Check that the XML file to parse is specified as argument, exit if the file is not specified
.....print "No file name specified as argument"
.....sys.exit()
else:
.....fileToParse = sys.argv[1]
start = time.time() Start is a variable used to measure the execution time
context = ET.iterparse(fileToParse, events=("start","end")) Get an iterable
context = iter(context) Turn the iterable into an iterator
event, root = context.next() Get the root element
QP module
sumPicturesQP = 0 Sum of the QP values of each picture
numPictures = 0 Number of pictures in the sequence
for event, elem in context:
.....if event == "end" and elem.tag == "Picture": Only one picture is loaded into memory at the same time, which implies that there are no memory limitations regarding the length of the XML file. For each picture:
..........sumMacrosQP = 0 Sum of the QP values of the macroblocks in the picture
..........numPictMacros = 0 Number of macroblocks in the picture
..........qpList = elem.findall("./Slice/MacroBlock/QP_Y") This call returns a list of all the subelements that match the pattern ./Slice/MacroBlock/QP_Y
..........for macroQP in qpList: For each element in the list (QP_Y tag in the picture)
...............sumMacrosQP = sumMacrosQP+int(macroQP.text) Sum the macroblock QP using the text attribute of the element in the list
...............numPictMacros = numPictMacros + 1 Each element in the list corresponds to a different macroblock
..........meanPictQP = float(sumMacrosQP) / float(numPictMacros) Compute the mean QP of the picture
..........sumPicturesQP = sumPicturesQP + meanPictQP Update the sum of the QP values of the macroblocks in the picture
..........numPictures = numPictures + 1 Update the number of pictures
End of QP module
..........root.clear() Free the RAM memory used by the XML parsing of the picture
meanSequenceQP = float(sumPicturesQP) / float(numPictures) Compute the mean QP of the sequence
print "Sequence QP (assuming constant value): "+str(meanSequenceQP)
estimatedMOS = -0.172*meanSequenceQP+9.249 Estimate the MOS according to the considered paper
print "Estimated MOS: "+str(estimatedMOS)
elapsed = (time.time() - start)
print "Time elapsed: "+str(elapsed)+" seconds" Print elapsed time in seconds

Only one picture is loaded into memory at the same time. Consequently there are no memory limitations regarding the length of the XML file. The methods from the ElementTree module (also included in Python 2.5) are used to handle the information of each picture. More information about the available methods can be found in: http://effbot.org/zone/element.htm#the-element-type

In order to execute the program Python (at least version 2.5) must be installed and the XML file to parse must be passed as an argument: python hybrid_v1_qp.py [XML file to parse]