Skip to content

Commit

Permalink
Merge git://iolanguage.com/Io
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Wright committed Jun 8, 2007
2 parents a2ba727 + d773434 commit f4297a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 185 deletions.
17 changes: 11 additions & 6 deletions Makefile
@@ -1,4 +1,6 @@
INSTALL_PREFIX ?= /usr/local
INSTALL_LIBDIR ?= /usr/lib


SYS ?= $(shell uname -s)

Expand Down Expand Up @@ -109,14 +111,17 @@ install:
rm -f $(INSTALL_PREFIX)/bin/io$(BINARY_SUFFIX)
cp _build/binaries/io$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin || true
chmod ugo+rx $(INSTALL_PREFIX)/bin/io$(BINARY_SUFFIX)
rm $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX) || true
cp _build/binaries/io_static$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
chmod ugo+rx $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX) || true
cp _build/dll/* $(INSTALL_PREFIX)/lib || true
cp _build/lib/* $(INSTALL_PREFIX)/lib || true
rm -rf $(INSTALL_PREFIX)/lib/io || true
mkdir -p $(INSTALL_PREFIX)/lib/io || true
cp -fR addons $(INSTALL_PREFIX)/lib/io
chmod -R ugo+rX $(INSTALL_PREFIX)/lib/io
cp _build/dll/* $(INSTALL_LIBDIR) || true
cp _build/lib/* $(INSTALL_LIBDIR) || true
cp _build/dll/* $(INSTALL_PREFIX)/bin || true
rm -rf $(INSTALL_LIBDIR)/io || true
mkdir -p $(INSTALL_LIBDIR)/io || true
cp -fR addons $(INSTALL_LIBDIR)/io
chmod -R ugo+rX $(INSTALL_LIBDIR)/io


linkInstall:
mkdir -p $(INSTALL_PREFIX)/bin || true
Expand Down
172 changes: 9 additions & 163 deletions addons/AVCodec/samples/video.io
@@ -1,169 +1,15 @@
#!/usr/bin/env io

VideoDecoder := AVCodec clone do(
newSlot("internalCoro")
newSlot("externalCoro")
newSlot("frameNumber", 0)
newSlot("sampleRateConverter", nil)
newSlot("audioOn", false)
isDone ::= false

init := method(
self image := Image clone
)

willProcess := getSlot("yield")

_open := getSlot("open")
open := method(
_open
writeln("audioSampleRate = ", audioSampleRate)
writeln("audioChannels = ", audioChannels)
audioOn := (audioSampleRate == 44100 and audioChannels == 2)
writeln("audioOn = ", audioOn)
/*
Flux

if(?audioSampleRate and audioSampleRate != 44100,
writeln("audioSampleRate setup")
self sampleRateConverter := SampleRateConverter clone
sampleRateConverter setOutputToInputRatio(44100 / audioSampleRate)
//sampleRateConverter setOutputToInputRatio(1.5)
writeln("ratio = ", sampleRateConverter outputToInputRatio)
//sampleRateConverter outputBuffer setItemType("float32")
//audioOutputBuffer setItemType("float32")
)
*/
VideoApp := Application clone do(
appDidStart := method(
self videoView := VideoView clone
mainWindow contentView addSubview(videoView)
videoView resizeWithSuperview resizeToFitSuperview
videoView open(System args at(1))
mainWindow reshapeToSize(videoView video videoSize)
)

didProcess := method(
if(isDone, return nil)
setInternalCoro(Coroutine currentCoroutine)

/*
if(audioOn,
if(sampleRateConverter,
//writeln("audioSampleRate converting")
if(audioChannels == 1, audioOutputBuffer duplicateIndexes)
sampleRateConverter inputBuffer appendSeq(audioOutputBuffer)
audioOutputBuffer empty
sampleRateConverter process
AudioDevice asyncWrite(sampleRateConverter outputBuffer)
sampleRateConverter outputBuffer empty
,
//if(audioChannels == 1, audioOutputBuffer duplicateIndexes)
AudioDevice asyncWrite(audioOutputBuffer)
audioOutputBuffer empty
)
)
*/

AudioDevice asyncWrite(audioOutputBuffer)
audioOutputBuffer empty

if(frames size > 0,
if(externalCoro, externalCoro resume)
)
)

readNextFrame := method(
if(isDone, return nil)
while(internalCoro == nil, yield)
setExternalCoro(Coroutine currentCoroutine)
internalCoro resume
frameNumber = frameNumber + 1
frame := frames removeFirst
if(frame, image setDataWidthHeightComponentCount(frame, videoSize x, videoSize y, 3), nil)
)

_startDecoding := getSlot("startDecoding")

startDecoding := method(
setIsDone(false)
_startDecoding
setIsDone(true)
externalCoro resume
)

start := method(
self @@startDecoding
if(internalCoro, internalCoro resume)
)
)

VideoViewer := Object clone do(
appendProto(OpenGL)

init := method(
self videoDecoder := VideoDecoder clone setFileName(System args at(1))
self image := videoDecoder image
)
init

reshape := method(w, h,
self width := w
self height := h
glViewport(0, 0, w, h)
glLoadIdentity
gluOrtho2D(0, w, 0, h)
glutPostRedisplay
)

display := method(
glClearColor(0,0,0, 1)
glClear(GL_COLOR_BUFFER_BIT)
glPushMatrix
draw
glPopMatrix
glutSwapBuffers
)

draw := method(
if(image originalWidth == 0, return)

wr := width / image originalWidth
hr := height / image originalHeight

if (wr < hr) then(
glTranslated(0, (height - image originalHeight * wr)/2, 0)
glScaled(wr, wr, 1)
) else(
glTranslated((width - image originalWidth * hr) / 2, 0, 0)
glScaled(hr, hr, 1)
)

image drawTexture
)

timer := method(n,
if(n == 0,
//writeln("starting")
glutTimerFunc(0, 1)
videoDecoder open
videoDecoder start
videoDecoder readNextFrame
glutReshapeWindow(image originalWidth, image originalHeight)
,
glutTimerFunc(videoDecoder framePeriod * 1000, 1)
videoDecoder readNextFrame
if(videoDecoder isDone, videoDecoder start)
)

//videoDecoder println
glutPostRedisplay
)

run := method(
AudioDevice open
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
glutInitWindowSize(512, 256)
glutInit
glutCreateWindow("")
glutEventTarget(self)
glutDisplayFunc
glutReshapeFunc
glutTimerFunc(0, 0)
glutMainLoop
)
)

VideoViewer run
VideoApp run
16 changes: 0 additions & 16 deletions addons/AVCodec/samples/video2.io

This file was deleted.

0 comments on commit f4297a2

Please sign in to comment.