Ejemplo n.º 1
0
 def __init__(self):
     """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
     super(DiracDecoder, self).__init__()
     self.decoder = DiracParser()
     self.inputbuffer = ""
Ejemplo n.º 2
0
 def __init__(self):
     """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
     super(DiracDecoder, self).__init__()
     self.decoder = DiracParser()
     self.inputbuffer = ""
Ejemplo n.º 3
0
class DiracDecoder(component):
    """
    DiracDecoder() -> new Dirac decoder component

    Creates a component that decodes Dirac video.
    """

    Inboxes = {
        "inbox": "Strings containing an encoded dirac video stream",
        "control": "for shutdown signalling",
    }
    Outboxes = {
        "outbox": "YUV decoded video frames",
        "signal": "for shutdown/completion signalling",
    }

    def __init__(self):
        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
        super(DiracDecoder, self).__init__()
        self.decoder = DiracParser()
        self.inputbuffer = ""

    def main(self):
        """Main loop"""
        done = False
        while not done:
            dataShortage = False

            while self.dataReady("inbox"):
                self.inputbuffer += self.recv("inbox")

            while self.dataReady("control"):
                msg = self.recv("control")
                if isinstance(msg, shutdownMicroprocess):
                    self.send(msg, "signal")
                    done = True

            try:
                frame = self.decoder.getFrame()
                frame['pixformat'] = map_chroma_type(frame['chroma_type'])
                self.send(frame, "outbox")

            except "NEEDDATA":
                if self.inputbuffer:
                    self.decoder.sendBytesForDecode(self.inputbuffer)
                    self.inputbuffer = ""
                else:
                    datashortage = True

            except "SEQINFO":
                # sequence info dict in self.decoder.getSeqData()
                pass

            except "END":
                done = True
                self.send(producerFinished(self), "signal")

            except "STREAMERROR":
                print("Stream error")
                raise IOError("STREAMERROR")

            except "INTERNALFAULT":
                print("Internal fault")
                raise RuntimeError("INTERNALFAULT")

            if dataShortage and not done:
                self.pause()

            yield 1
Ejemplo n.º 4
0
class DiracDecoder(component):
    """
    DiracDecoder() -> new Dirac decoder component

    Creates a component that decodes Dirac video.
    """

    Inboxes  = { "inbox"   : "Strings containing an encoded dirac video stream",
                 "control" : "for shutdown signalling",
               }
    Outboxes = { "outbox" : "YUV decoded video frames",
                 "signal" : "for shutdown/completion signalling",
               }
       
    def __init__(self):
        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
        super(DiracDecoder, self).__init__()
        self.decoder = DiracParser()
        self.inputbuffer = ""

    def main(self):
        """Main loop"""
        done = False
        while not done:
            dataShortage = False
        
            while self.dataReady("inbox"):
                self.inputbuffer += self.recv("inbox")

            while self.dataReady("control"):
                msg = self.recv("control")
                if isinstance(msg, shutdownMicroprocess):
                    self.send(msg, "signal")
                    done=True
        
            try:
                frame = self.decoder.getFrame()
                frame['pixformat'] = map_chroma_type(frame['chroma_type'])
                self.send(frame,"outbox")
            
            except "NEEDDATA":
                if self.inputbuffer:
                    self.decoder.sendBytesForDecode(self.inputbuffer)
                    self.inputbuffer = ""
                else:
                    datashortage = True
        
            except "SEQINFO":
                # sequence info dict in self.decoder.getSeqData()
                pass
            
            except "END":
                done = True
                self.send(producerFinished(self), "signal")
        
            except "STREAMERROR":
                print "Stream error"
                raise "STREAMERROR"
        
            except "INTERNALFAULT":
                print "Internal fault"
                raise "INTERNALFAULT"

            if dataShortage and not done:
                self.pause()

            yield 1