]> gitweb.factorcode.org Git - factor.git/blob - extra/ogg/theora/theora.factor
Switch to https urls
[factor.git] / extra / ogg / theora / theora.factor
1 ! Copyright (C) 2007 Chris Double.
2 ! See https://factorcode.org/license.txt for BSD license.
3 !
4 USING:
5     alien
6     alien.c-types
7     alien.libraries
8     alien.syntax
9     classes.struct
10     combinators
11     ogg
12     system
13 ;
14 IN: ogg.theora
15
16 <<
17 "theoradec" {
18     { [ os windows? ]  [ "theoradec.dll" ] }
19     { [ os macosx? ] [ "libtheoradec.0.dylib" ] }
20     { [ os unix? ]   [ "libtheoradec.so" ] }
21 } cond cdecl add-library
22
23 "theoraenc" {
24     { [ os windows? ]  [ "theoraenc.dll" ] }
25     { [ os macosx? ] [ "libtheoraenc.0.dylib" ] }
26     { [ os unix? ]   [ "libtheoraenc.so" ] }
27 } cond cdecl add-library
28 >>
29
30 CONSTANT: TH-EFAULT      -1
31 CONSTANT: TH-EINVAL     -10
32 CONSTANT: TH-EBADHEADER -20
33 CONSTANT: TH-ENOTFORMAT -21
34 CONSTANT: TH-EVERSION   -22
35 CONSTANT: TH-EIMPL      -23
36 CONSTANT: TH-EBADPACKET -24
37 CONSTANT: TH-DUPFRAME     1
38
39 TYPEDEF: int th-colorspace
40 CONSTANT: TH-CS-UNSPECIFIED   0
41 CONSTANT: TH-CS-ITU-REC-470M  1
42 CONSTANT: TH-CS-ITU-REC-470BG 2
43 CONSTANT: TH-CS-NSPACES       3
44
45 TYPEDEF: int th-pixelformat
46 CONSTANT: TH-PF-RSVD     0
47 CONSTANT: TH-PF-422      1
48 CONSTANT: TH-PF-444      2
49 CONSTANT: TH-PF-NFORMATS 3
50
51 STRUCT: th-img-plane
52     { width int }
53     { height int }
54     { stride int }
55     { data uchar* }
56 ;
57
58 TYPEDEF: th-img-plane[3] th-ycbcr-buffer
59
60 STRUCT: th-info
61     { version-major uchar }
62     { version-minor uchar }
63     { version-subminor uchar }
64     { frame-width uint }
65     { frame-height uint }
66     { pic-width uint }
67     { pic-height uint }
68     { pic-x uint }
69     { pic-y uint }
70     { fps-numerator uint }
71     { fps-denominator uint }
72     { aspect-numerator uint }
73     { aspect-denominator uint }
74     { colorspace th-colorspace }
75     { pixel-fmt th-pixelformat }
76     { target-bitrate int }
77     { quality int }
78     { keyframe-granule-shift int }
79 ;
80
81 STRUCT: th-comment
82     { user-comments c-string* }
83     { comment-lengths int* }
84     { comments int }
85     { vendor c-string }
86 ;
87
88 TYPEDEF: uchar[64] th-quant-base
89
90 STRUCT: th-quant-ranges
91     { nranges int }
92     { sizes int* }
93     { base-matrices th-quant-base* }
94 ;
95
96 STRUCT: th-quant-info
97     { dc-scale { short 64 } }
98     { ac-scale { short 64 } }
99     { loop-filter-limits { uchar 64 } }
100     { qi-ranges { th-quant-ranges 2 3 } }
101 ;
102
103 CONSTANT: TH-NHUFFMANE-TABLES 80
104 CONSTANT: TH-NDCT-TOKENS 32
105
106 STRUCT: th-huff-code
107     { pattern int }
108     { nbits int }
109 ;
110
111 LIBRARY: theoradec
112 FUNCTION: c-string th_version_string ( )
113 FUNCTION: uint th_version_number ( )
114 FUNCTION: longlong th_granule_frame ( void* encdec, longlong granpos )
115 FUNCTION: int th_packet_isheader ( ogg-packet* op )
116 FUNCTION: int th_packet_iskeyframe ( ogg-packet* op )
117 FUNCTION: void th_info_init ( th-info* info )
118 FUNCTION: void th_info_clear ( th-info* info )
119 FUNCTION: void th_comment_init ( th-comment* tc )
120 FUNCTION: void th_comment_add ( th-comment* tc, c-string comment )
121 FUNCTION: void th_comment_add_tag ( th-comment* tc, c-string tag, c-string value )
122 FUNCTION: c-string th_comment_query ( th-comment* tc, c-string tag, int count )
123 FUNCTION: int   th_comment_query_count ( th-comment* tc, c-string tag )
124 FUNCTION: void  th_comment_clear ( th-comment* tc )
125
126 CONSTANT: TH-ENCCTL-SET-HUFFMAN-CODES 0
127 CONSTANT: TH-ENCCTL-SET-QUANT-PARAMS 2
128 CONSTANT: TH-ENCCTL-SET-KEYFRAME-FREQUENCY-FORCE 4
129 CONSTANT: TH-ENCCTL-SET-VP3-COMPATIBLE 10
130 CONSTANT: TH-ENCCTL-GET-SPLEVEL-MAX 12
131 CONSTANT: TH-ENCCTL-SET-SPLEVEL 14
132 CONSTANT: TH-ENCCTL-SET-DUP-COUNT 18
133 CONSTANT: TH-ENCCTL-SET-RATE-FLAGS 20
134 CONSTANT: TH-ENCCTL-SET-RATE-BUFFER 22
135 CONSTANT: TH-ENCCTL-2PASS-OUT 24
136 CONSTANT: TH-ENCCTL-2PASS-IN 26
137 CONSTANT: TH-ENCCTL-SET-QUALITY 28
138 CONSTANT: TH-ENCCTL-SET-BITRATE 30
139
140 CONSTANT: TH-RATECTL-DROP-FRAMES 1
141 CONSTANT: TH-RATECTL-CAP-OVERFLOW 2
142 CONSTANT: TH-RATECTL-CAP-UNDERFOW 4
143
144 TYPEDEF: void* th-enc-ctx
145
146 LIBRARY: theoraenc
147 FUNCTION: th-enc-ctx* th_encode_alloc ( th-info* info )
148 FUNCTION: int th_encode_ctl ( th-enc-ctx* enc, int req, void* buf, int buf_sz )
149 FUNCTION: int th_encode_flushheader ( th-enc-ctx* enc, th-comment* comments, ogg-packet* op )
150 FUNCTION: int th_encode_ycbcr_in ( th-enc-ctx* enc, th-ycbcr-buffer ycbcr )
151 FUNCTION: int th_encode_packetout ( th-enc-ctx* enc, int last, ogg-packet* op )
152 FUNCTION: void th_encode_free ( th-enc-ctx* enc )
153
154 CONSTANT: TH-DECCTL-GET-PPLEVEL-MAX 1
155 CONSTANT: TH-DECCTL-SET-PPLEVEL 3
156 CONSTANT: TH-DECCTL-SET-GRANPOS 5
157 CONSTANT: TH-DECCTL-SET-STRIPE-CB 7
158 CONSTANT: TH-DECCTL-SET-TELEMETRY-MBMODE 9
159 CONSTANT: TH-DECCTL-SET-TELEMETRY-MV 11
160 CONSTANT: TH-DECCTL-SET-TELEMETRY-QI 13
161 CONSTANT: TH-DECCTL-SET-TELEMETRY-BITS 15
162
163 TYPEDEF: void* th-stripe-decoded-func
164
165 STRUCT: th-stripe-callback
166     { ctx void* }
167     { stripe-decoded th-stripe-decoded-func }
168 ;
169
170 TYPEDEF: void* th-dec-ctx
171 TYPEDEF: void* th-setup-info
172
173 LIBRARY: theoradec
174 FUNCTION: int th_decode_headerin ( th-info* info, th-comment* tc, th-setup-info** setup, ogg-packet* op )
175 FUNCTION: th-dec-ctx* th_decode_alloc ( th-info* info, th-setup-info* setup )
176 FUNCTION: void th_setup_free ( th-setup-info* setup )
177 FUNCTION: int th_decode_ctl ( th-dec-ctx* dec, int req, void* buf, int buf_sz )
178 FUNCTION: int th_decode_packetin ( th-dec-ctx* dec, ogg-packet* op, longlong granpos )
179 FUNCTION: int th_decode_ycbcr_out ( th-dec-ctx* dec, th-ycbcr-buffer ycbcr )
180 FUNCTION: void th_decode_free ( th-dec-ctx* dec )