Ignore:
Timestamp:
Jun 27, 2008 4:18:13 PM (16 years ago)
Author:
nanang
Message:

Ticket #543:

  • Fixed bug of calculating clock interval which should include channel count
  • Added L16 codecs including stereo
  • Added WAV files for stereo tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py

    r2063 r2075  
    5050        user_data.output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 
    5151 
    52         # Find appropriate clock rate for the input file 
     52        # Get WAV input length, in seconds 
     53        fin = wave.open(user_data.input_filename, "r") 
     54        if fin == None: 
     55                raise TestError("Failed opening input WAV file") 
     56        inwavlen = fin.getnframes() * 1.0 / fin.getframerate() 
     57        inwavlen += 0.2 
     58        fin.close() 
     59        print "WAV input len = " + str(inwavlen) + "s" 
     60 
     61        # Get clock rate of the output 
    5362        mo_clock_rate = re.compile("\.(\d+)\.wav").search(user_data.output_filename) 
    5463        if (mo_clock_rate==None): 
    5564                raise TestError("Cannot compare input & output, incorrect output filename format") 
    5665        clock_rate = mo_clock_rate.group(1) 
    57         user_data.input_filename = re.sub("\.\d+\.wav", "."+clock_rate+".wav", user_data.input_filename) 
     66         
     67        # Get channel count of the output 
     68        channel_count = 1 
     69        if re.search("--stereo", ua2.inst_param.arg) != None: 
     70                channel_count = 2 
     71         
     72        # Get matched input file from output file 
     73        # (PESQ evaluates only files whose same clock rate & channel count) 
     74        if channel_count == 2: 
     75            if re.search("\.\d+\.\d+\.wav", user_data.input_filename) != None: 
     76                    user_data.input_filename = re.sub("\.\d+\.\d+\.wav",  
     77                                                      "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 
     78            else: 
     79                    user_data.input_filename = re.sub("\.\d+\.wav",  
     80                                                      "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 
    5881 
    5982        if (clock_rate != "8") & (clock_rate != "16"): 
     
    6285        # Get conference clock rate of UA2 for PESQ sample rate option 
    6386        user_data.pesq_sample_rate_opt = "+" + clock_rate + "000" 
    64  
    65         # Get WAV input length, in seconds 
    66         fin = wave.open(user_data.input_filename, "r") 
    67         if fin == None: 
    68                 raise TestError("Failed opening input WAV file") 
    69         inwavlen = fin.getnframes() // fin.getframerate() 
    70         if (fin.getnframes() % fin.getframerate()) > 0: 
    71                 inwavlen = inwavlen + 1 
    72         fin.close() 
    7387 
    7488        # UA1 making call 
     
    110124 
    111125        # Parse ouput 
    112         mo_pesq_out = re.compile("Prediction[^=]+=\s+([\d\.]+)\s*").search(pesq_out[0]) 
     126        mo_pesq_out = re.compile("Prediction[^=]+=\s+([\-\d\.]+)\s*").search(pesq_out[0]) 
    113127        if (mo_pesq_out == None): 
    114128                raise TestError("Failed to fetch PESQ result") 
Note: See TracChangeset for help on using the changeset viewer.