1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
#******************************************************************************
#
# $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $
#
#
#
# Borland Delphi SMPEG - SDL MPEG Player Library
# Conversion of the SMPEG - SDL MPEG Player Library
#
# Portions created by Sam Lantinga <slouken@devolution.com> are
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
# 5635-34 Springhouse Dr.
# Pleasanton, CA 94588 (USA)
#
# All Rights Reserved.
#
# The original files are : smpeg.h
#
# The initial developer of this Pascal code was :
# Matthias Thoma <ma.thoma@gmx.de>
#
# Portions created by Matthias Thoma are
# Copyright (C) 2000 - 2001 Matthias Thoma.
#
#
# Contributor(s)
# --------------
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
# Matthias Thoma <ma.thoma@gmx.de>
#
# Obtained through:
# Joint Endeavour of Delphi Innovators ( Project JEDI )
#
# You may retrieve the latest version of this file at the Project
# JEDI home page, located at http://delphi-jedi.org
#
# The contents of this file are used with permission, subject to
# the Mozilla Public License Version 1.1 (the "License"); you may
# not use this file except in compliance with the License. You may
# obtain a copy of the License at
# http://www.mozilla.org/MPL/MPL-1.1.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# Description
# -----------
#
#
#
#
#
#
#
# Requires
# --------
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL-1.2.so.0
# They are available from...
# http://www.libsdl.org .
#
# Programming Notes
# -----------------
#
#
#
#
# Revision History
# ----------------
# May 08 2001 - MT : Initial conversion
#
# October 12 2001 - DA : Various changes as suggested by David Acklam
#
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
# Pascal compilers. Initial support is now included
# for GnuPascal, VirtualPascal, TMT and obviously
# continue support for Delphi Kylix and FreePascal.
#
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
# Fixed all invalid calls to DLL.
# Changed constant names to:
# const
# STATUS_SMPEG_ERROR = -1;
# STATUS_SMPEG_STOPPED = 0;
# STATUS_SMPEG_PLAYING = 1;
# because SMPEG_ERROR is a function (_SMPEG_error
# isn't correct), and cannot be two elements with the
# same name
#
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
# better TMT Pascal support and under instruction
# from Prof. Abimbola Olowofoyeku (The African Chief),
# I have added better Gnu Pascal support
#
# April 30 2003 - DL : under instruction from David Mears AKA
# Jason Siletto, I have added FPC Linux support.
# This was compiled with fpc 1.1, so remember to set
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
#
#
# $Log: smpeg.pas,v $
# Revision 1.7 2004/08/14 22:54:30 savage
# Updated so that Library name defines are correctly defined for MacOS X.
#
# Revision 1.6 2004/05/10 14:10:04 savage
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
#
# Revision 1.5 2004/04/13 09:32:08 savage
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
#
# Revision 1.4 2004/04/02 10:40:55 savage
# Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
#
# Revision 1.3 2004/03/31 22:20:02 savage
# Windows unit not used in this file, so it was removed to keep the code tidy.
#
# Revision 1.2 2004/03/30 20:23:28 savage
# Tidied up use of UNIX compiler directive.
#
# Revision 1.1 2004/02/14 23:35:42 savage
# version 1 of sdl_image, sdl_mixer and smpeg.
#
#
#
#******************************************************************************
import
sdl
when defined(windows):
const SmpegLibName = "smpeg.dll"
elif defined(macosx):
const SmpegLibName = "libsmpeg.dylib"
else:
const SmpegLibName = "libsmpeg.so"
const
SMPEG_FILTER_INFO_MB_ERROR* = 1
SMPEG_FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG
type
SMPEG_FilterInfo*{.final.} = object
yuv_mb_square_error*: PUint16
yuv_pixel_square_error*: PUint16
TSMPEG_FilterInfo* = SMPEG_FilterInfo
PSMPEG_FilterInfo* = ptr SMPEG_FilterInfo # MPEG filter definition
PSMPEG_Filter* = ptr TSMPEG_Filter # Callback functions for the filter
TSMPEG_FilterCallback* = proc (dest, source: PSDL_Overlay, region: PSDL_Rect,
filter_info: PSMPEG_FilterInfo, data: Pointer): Pointer{.
cdecl.}
TSMPEG_FilterDestroy* = proc (Filter: PSMPEG_Filter): Pointer{.cdecl.} # The filter
# definition itself
TSMPEG_Filter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay.
flags*: Uint32
data*: Pointer
callback*: TSMPEG_FilterCallback
destroy*: TSMPEG_FilterDestroy
proc SMPEGfilter_null*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
# The bilinear filter. A basic low-pass filter that will produce a smoother image.
proc SMPEGfilter_bilinear*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
# The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness
proc SMPEGfilter_deblocking*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
#------------------------------------------------------------------------------
# SMPEG.h
#------------------------------------------------------------------------------
const
SMPEG_MAJOR_VERSION* = 0'i8
SMPEG_MINOR_VERSION* = 4'i8
SMPEG_PATCHLEVEL* = 2'i8
type
SMPEG_version*{.final.} = object
major*: UInt8
minor*: UInt8
patch*: UInt8
TSMPEG_version* = SMPEG_version
PSMPEG_version* = ptr TSMPEG_version # This is the actual SMPEG object
TSMPEG*{.final.} = object
PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object
TSMPEG_Info*{.final.} = object
has_audio*: int
has_video*: int
width*: int
height*: int
current_frame*: int
current_fps*: float64
audio_string*: array[0..79, char]
audio_current_frame*: int
current_offset*: UInt32
total_size*: UInt32
current_time*: float64
total_time*: float64
PSMPEG_Info* = ptr TSMPEG_Info # Possible MPEG status codes
const
STATUS_SMPEG_ERROR* = - 1
STATUS_SMPEG_STOPPED* = 0
STATUS_SMPEG_PLAYING* = 1
type
TSMPEGstatus* = int
PSMPEGstatus* = ptr int # Matches the declaration of SDL_UpdateRect()
TSMPEG_DisplayCallback* = proc (dst: PSDL_Surface, x, y: int, w, h: int): Pointer{.
cdecl.} # Create a new SMPEG object from an MPEG file.
# On return, if 'info' is not NULL, it will be filled with information
# about the MPEG object.
# This function returns a new SMPEG object. Use SMPEG_error() to find out
# whether or not there was a problem building the MPEG stream.
# The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
# subsystem. If not, you will have to use the SMPEG_playaudio() function below
# to extract the decoded data.
proc SMPEG_new*(theFile: cstring, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
cdecl, importc, dynlib: SmpegLibName.}
# The same as above for a file descriptor
proc SMPEG_new_descr*(theFile: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
cdecl, importc, dynlib: SmpegLibName.}
# The same as above but for a raw chunk of data. SMPEG makes a copy of the
# data, so the application is free to delete after a successful call to this
# function.
proc SMPEG_new_data*(data: Pointer, size: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
cdecl, importc, dynlib: SmpegLibName.}
# Get current information about an SMPEG object
proc SMPEG_getinfo*(mpeg: PSMPEG, info: PSMPEG_Info){.cdecl,
importc, dynlib: SmpegLibName.}
#procedure SMPEG_getinfo(mpeg: PSMPEG; info: Pointer);
#cdecl; external SmpegLibName;
# Enable or disable audio playback in MPEG stream
proc SMPEG_enableaudio*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.}
# Enable or disable video playback in MPEG stream
proc SMPEG_enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.}
# Delete an SMPEG object
proc SMPEG_delete*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Get the current status of an SMPEG object
proc SMPEG_status*(mpeg: PSMPEG): TSMPEGstatus{.cdecl, importc, dynlib: SmpegLibName.}
# status
# Set the audio volume of an MPEG stream, in the range 0-100
proc SMPEG_setvolume*(mpeg: PSMPEG, volume: int){.cdecl, importc, dynlib: SmpegLibName.}
# Set the destination surface for MPEG video playback
# 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
# 'callback' is a function called when an area of 'dst' needs to be updated.
# If 'callback' is NULL, the default function (SDL_UpdateRect) will be used.
proc SMPEG_setdisplay*(mpeg: PSMPEG, dst: PSDL_Surface, surfLock: PSDL_mutex,
callback: TSMPEG_DisplayCallback){.cdecl,
importc, dynlib: SmpegLibName.}
# Set or clear looping play on an SMPEG object
proc SMPEG_loop*(mpeg: PSMPEG, repeat: int){.cdecl, importc, dynlib: SmpegLibName.}
# Scale pixel display on an SMPEG object
proc SMPEG_scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl,
importc, dynlib: SmpegLibName.}
proc SMPEG_scale*(mpeg: PSMPEG, scale: int){.cdecl, importc, dynlib: SmpegLibName.}
proc SMPEG_Double*(mpeg: PSMPEG, doubleit: bool)
# Move the video display area within the destination surface
proc SMPEG_move*(mpeg: PSMPEG, x, y: int){.cdecl, importc, dynlib: SmpegLibName.}
# Set the region of the video to be shown
proc SMPEG_setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl,
importc, dynlib: SmpegLibName.}
# Play an SMPEG object
proc SMPEG_play*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Pause/Resume playback of an SMPEG object
proc SMPEG_pause*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Stop playback of an SMPEG object
proc SMPEG_stop*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Rewind the play position of an SMPEG object to the beginning of the MPEG
proc SMPEG_rewind*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
# Seek 'bytes' bytes in the MPEG stream
proc SMPEG_seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc, dynlib: SmpegLibName.}
# Skip 'seconds' seconds in the MPEG stream
proc SMPEG_skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc, dynlib: SmpegLibName.}
# Render a particular frame in the MPEG video
# API CHANGE: This function no longer takes a target surface and position.
# Use SMPEG_setdisplay() and SMPEG_move() to set this information.
proc SMPEG_renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl,
importc, dynlib: SmpegLibName.}
# Render the last frame of an MPEG video
proc SMPEG_renderFinal*(mpeg: PSMPEG, dst: PSDL_Surface, x, y: int){.cdecl,
importc, dynlib: SmpegLibName.}
# Set video filter
proc SMPEG_filter*(mpeg: PSMPEG, filter: PSMPEG_Filter): PSMPEG_Filter{.cdecl,
importc, dynlib: SmpegLibName.}
# Return NULL if there is no error in the MPEG stream, or an error message
# if there was a fatal error in the MPEG stream for the SMPEG object.
proc SMPEG_error*(mpeg: PSMPEG): cstring{.cdecl, importc, dynlib: SmpegLibName.}
# Exported callback function for audio playback.
# The function takes a buffer and the amount of data to fill, and returns
# the amount of data in bytes that was actually written. This will be the
# amount requested unless the MPEG audio has finished.
#
proc SMPEG_playAudio*(mpeg: PSMPEG, stream: PUInt8, length: int): int{.cdecl,
importc, dynlib: SmpegLibName.}
# Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer
proc SMPEG_playAudioSDL*(mpeg: Pointer, stream: PUInt8, length: int){.cdecl,
importc, dynlib: SmpegLibName.}
# Get the best SDL audio spec for the audio stream
proc SMPEG_wantedSpec*(mpeg: PSMPEG, wanted: PSDL_AudioSpec): int{.cdecl,
importc, dynlib: SmpegLibName.}
# Inform SMPEG of the actual SDL audio spec used for sound playback
proc SMPEG_actualSpec*(mpeg: PSMPEG, spec: PSDL_AudioSpec){.cdecl,
importc, dynlib: SmpegLibName.}
# This macro can be used to fill a version structure with the compile-time
# version of the SDL library.
proc SMPEG_GETVERSION*(X: var TSMPEG_version)
# implementation
proc SMPEG_double(mpeg: PSMPEG, doubleit: bool) =
if doubleit: SMPEG_scale(mpeg, 2)
else: SMPEG_scale(mpeg, 1)
proc SMPEG_GETVERSION(X: var TSMPEG_version) =
X.major = SMPEG_MAJOR_VERSION
X.minor = SMPEG_MINOR_VERSION
X.patch = SMPEG_PATCHLEVEL
|