Exemplo n.º 1
0
def getFrameCountInfo(inFile):
    '''
    convert the contents of inFile to FrameCountInfo.
    '''
    fcInfo = FrameCountInfo()
    if not os.path.isfile(inFile):
        print "ERROR:Invalid framecount file %s" % inFile
        return fcInfo

    tag = '@FRAMECOUNT'
    cont = getContent(inFile, tag)
    if not cont:
        print "ERROR:tag %s not found" % tag
        return fcInfo

    KEY_TUPLE = ("FILE", "DECIMAL_INCR")
    cont_map = getMap(cont)

    fcInfo.index = range(len(cont_map['FILE']))
    fcInfo.framecount = map(int, cont_map['DECIMAL_INCR'])
    fcInfo.fList = cont_map['FILE']
    return fcInfo
Exemplo n.º 2
0
def getFrameCountInfo(inFile):
    '''
    convert the contents of inFile to FrameCountInfo.
    '''
    fcInfo=FrameCountInfo()
    if not os.path.isfile(inFile):
        print "ERROR:Invalid framecount file %s" % inFile
        return fcInfo

    tag = '@FRAMECOUNT'
    cont = getContent(inFile, tag)
    if not cont:
        print "ERROR:tag %s not found" % tag
        return fcInfo

    KEY_TUPLE=("FILE", "DECIMAL_INCR")
    cont_map = getMap(cont)

    fcInfo.index=range(len(cont_map['FILE']))
    fcInfo.framecount=map(int, cont_map['DECIMAL_INCR'])
    fcInfo.fList=cont_map['FILE']
    return fcInfo
Exemplo n.º 3
0
def getImageLFResult(outFile, imgFile, bStrip, idxOffset):
    '''
    bStrip: whether strip the LF at start/stop of target sequence
    '''
    if not os.path.isfile(imgFile):
        print "No image based LF file available", imgFile
        return None, -1, -1

    ##------------------------------------------------
    tag = '@LONGFRAME'
    cont = getContent(imgFile, tag)
    if not cont:
        print "ERROR:tag %s not found" % tag
        return None, -1, -1

    KEY_TUPLE = ("INDEX", "FILE", "FRAMECOUNT", "LF_PNTCNT_THRESHOLD")
    cont_map = getMap(cont)

    LF_index = map(int, cont_map['INDEX'])
    LF_length = map(int, cont_map['FRAMECOUNT'])
    LF_fList = cont_map['FILE']
    LF_threshold = map(int, cont_map['LF_PNTCNT_THRESHOLD'])

    ##------------------------------------------------
    tag = '@DURATION'
    cont = getContent(imgFile, tag)
    KEY_TUPLE = ("BEGIN_IDX", "BEGIN_FILE", "END_IDX", "END_FILE",
                 "PHASE_START_IDX", "PHASE_START_FILE", "PHASE_STOP_IDX",
                 "PHASE_STOP_FILE", "FRAMES_CNT", "DURATION")
    cont_map = getMap(cont)

    begin_idx = int(cont_map['BEGIN_IDX'][0])
    begin_file = cont_map['BEGIN_FILE'][0]
    end_idx = int(cont_map['END_IDX'][0])
    end_file = cont_map['END_FILE'][0]

    phase_start_index = int(cont_map['PHASE_START_IDX'][0])
    phase_stop_index = int(cont_map['PHASE_STOP_IDX'][0])
    phase_start_file = cont_map['PHASE_START_FILE'][0]
    phase_stop_file = cont_map['PHASE_STOP_FILE'][0]

    if not bStrip:
        ##------------------------------------------------
        tag = '@SWITCH'
        cont = getContent(imgFile, tag)

        KEY_TUPLE = ("INDEX", "FILE", "DIRECTION", "PREV_CNT", "NEXT_CNT")
        cont_map = getMap(cont)

        switch_index = map(int, cont_map['INDEX'])
        switch_file = cont_map['FILE']
        switch_direct = cont_map['DIRECTION']
        switch_pre = map(int, cont_map['PREV_CNT'])
        switch_next = map(int, cont_map['NEXT_CNT'])

        if switch_direct[0] == 'up':
            start_dur = switch_pre[0]
        else:
            start_dur = 0

        if switch_direct[-1] == 'down':
            stop_dur = switch_next[-1]
        else:
            stop_dur = 0

        if start_dur >= vsync_samplingcnt:
            LF_index.insert(0, 0)
            LF_length.insert(0, start_dur)
            LF_fList.insert(0, begin_file)
            LF_threshold.insert(0, vsync_samplingcnt)
        if stop_dur >= vsync_samplingcnt:
            LF_index.append(switch_index[-1])
            LF_length.append(stop_dur)
            LF_fList.append(end_file)
            LF_threshold.append(vsync_samplingcnt)

        phase_start_index = begin_idx
        phase_stop_index = end_idx

    with open(outFile, 'a') as f:
        f.write('\n')
        tag = '@IMAGE'
        f.write('%s\n' % tag)
        f.write('%15s, %15s, %25s, %25s\n' %
                ('INDEX', 'LENGTH', 'FILE', 'LF_PNTCNT_THRESHOLD'))
        for i in range(len(LF_index)):
            f.write('%15s, %15s, %25s, %25s\n' %
                    (LF_index[i] + idxOffset, LF_length[i], LF_fList[i],
                     LF_threshold[i]))
        f.write('@END\n')

    print 'image diff based phase start index: %s, phase stop index: %s' % (
        phase_start_index, phase_stop_index)

    lfInfo = LongFrameInfo()
    lfInfo.LFIndex = [int(i) for i in LF_index]
    lfInfo.length = [int(i) for i in LF_length]
    return lfInfo, phase_start_index, phase_stop_index
Exemplo n.º 4
0
def getImageLFResult(outFile, imgFile, bStrip, idxOffset):
    '''
    bStrip: whether strip the LF at start/stop of target sequence
    '''
    if not os.path.isfile(imgFile):
        print "No image based LF file available", imgFile
        return None, -1, -1

    ##------------------------------------------------
    tag = '@LONGFRAME'
    cont = getContent(imgFile, tag)
    if not cont:
        print "ERROR:tag %s not found" % tag
        return None, -1, -1

    KEY_TUPLE=("INDEX", "FILE", "FRAMECOUNT", "LF_PNTCNT_THRESHOLD")
    cont_map = getMap(cont)

    LF_index     = map(int, cont_map['INDEX'])
    LF_length    = map(int, cont_map['FRAMECOUNT'])
    LF_fList     = cont_map['FILE']
    LF_threshold = map(int, cont_map['LF_PNTCNT_THRESHOLD'])


    ##------------------------------------------------
    tag = '@DURATION'
    cont = getContent(imgFile, tag)
    KEY_TUPLE = ("BEGIN_IDX", "BEGIN_FILE", "END_IDX", "END_FILE", "PHASE_START_IDX", "PHASE_START_FILE", "PHASE_STOP_IDX", "PHASE_STOP_FILE", "FRAMES_CNT", "DURATION")
    cont_map = getMap(cont)

    begin_idx        = int(cont_map['BEGIN_IDX'][0])
    begin_file       = cont_map['BEGIN_FILE'][0]
    end_idx          = int(cont_map['END_IDX'][0])
    end_file         = cont_map['END_FILE'][0]

    phase_start_index= int(cont_map['PHASE_START_IDX'][0])
    phase_stop_index = int(cont_map['PHASE_STOP_IDX'][0])
    phase_start_file = cont_map['PHASE_START_FILE'][0]
    phase_stop_file  = cont_map['PHASE_STOP_FILE'][0]

    if not bStrip:
        ##------------------------------------------------
        tag = '@SWITCH'
        cont = getContent(imgFile, tag)

        KEY_TUPLE = ("INDEX", "FILE", "DIRECTION", "PREV_CNT", "NEXT_CNT")
        cont_map = getMap(cont)

        switch_index    = map(int, cont_map['INDEX'])
        switch_file     = cont_map['FILE']
        switch_direct   = cont_map['DIRECTION']
        switch_pre      = map(int, cont_map['PREV_CNT'])
        switch_next     = map(int, cont_map['NEXT_CNT'])

        if switch_direct[0] == 'up':
            start_dur = switch_pre[0]
        else:
            start_dur = 0;

        if switch_direct[-1] == 'down':
            stop_dur = switch_next[-1]
        else:
            stop_dur = 0

        if start_dur >= vsync_samplingcnt:
            LF_index.insert(0,0)
            LF_length.insert(0,start_dur)
            LF_fList.insert(0,begin_file)
            LF_threshold.insert(0,vsync_samplingcnt)
        if stop_dur >= vsync_samplingcnt:
            LF_index.append(switch_index[-1])
            LF_length.append(stop_dur)
            LF_fList.append(end_file)
            LF_threshold.append(vsync_samplingcnt)

        phase_start_index = begin_idx
        phase_stop_index  = end_idx

    with open(outFile, 'a') as f:
        f.write('\n')
        tag='@IMAGE'
        f.write('%s\n' % tag)
        f.write('%15s, %15s, %25s, %25s\n' % ('INDEX', 'LENGTH', 'FILE', 'LF_PNTCNT_THRESHOLD'))
        for i in range(len(LF_index)):
            f.write('%15s, %15s, %25s, %25s\n' % (LF_index[i]+idxOffset, LF_length[i], LF_fList[i], LF_threshold[i]))
        f.write('@END\n')

    print 'image diff based phase start index: %s, phase stop index: %s' % (phase_start_index, phase_stop_index)

    lfInfo = LongFrameInfo()
    lfInfo.LFIndex = [int(i) for i in LF_index]
    lfInfo.length = [int(i) for i in LF_length]
    return lfInfo, phase_start_index, phase_stop_index