diff --git a/revid/revid.go b/revid/revid.go index f04ad86f..0ea02a9b 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -264,33 +264,32 @@ func input(input string, output string) { if clip, err := ringBuffer.Get(); err != nil { inputErrChan <- err return - } else { - for { - upperBound := clipSize+mp2tPacketSize - _, err := io.ReadFull(br, clip[clipSize:upperBound]) - if err != nil { + } + for { + upperBound := clipSize+mp2tPacketSize + _, err := io.ReadFull(br, clip[clipSize:upperBound]) + if err != nil { + inputErrChan <- err + return + } + if *flags&filterFixContinuity != 0 && mp2tFixContinuity(clip[clipsSize:upperBound], packetCount, uint16(*selectedPID)) { + fmt.Printf("Packet #%d.%d fixed\n", clipCount, packetCount) + } + packetCount++ + clipSize += mp2tPacketSize + // send if (1) our buffer is full or (2) 1 second has elapsed and we have % packetsPerFrame + now = time.Now() + if (packetCount == mp2tMaxPackets) || + (now.Sub(prevTime) > clipDuration*time.Second && packetCount%packetsPerFrame == 0) { + clipCount++ + if err := ringBuffer.DoneWriting(clipSize); err != nil { inputErrChan <- err return } - if *flags&filterFixContinuity != 0 && mp2tFixContinuity(clip[clipsSize:upperBound], packetCount, uint16(*selectedPID)) { - fmt.Printf("Packet #%d.%d fixed\n", clipCount, packetCount) - } - packetCount++ - clipSize += mp2tPacketSize - // send if (1) our buffer is full or (2) 1 second has elapsed and we have % packetsPerFrame - now = time.Now() - if (packetCount == mp2tMaxPackets) || - (now.Sub(prevTime) > clipDuration*time.Second && packetCount%packetsPerFrame == 0) { - clipCount++ - if err := ringBuffer.DoneWriting(clipSize); err != nil { - inputErrChan <- err - return - } - clipSize = 0 - packetCount = 0 - prevTime = now - break - } + clipSize = 0 + packetCount = 0 + prevTime = now + break } } }