Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/libtheora/theora/codec.h
9904 views
1
/********************************************************************
2
* *
3
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
4
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7
* *
8
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
9
* by the Xiph.Org Foundation https://www.xiph.org/ *
10
* *
11
********************************************************************
12
13
function:
14
15
********************************************************************/
16
17
/**\mainpage
18
*
19
* \section intro Introduction
20
*
21
* This is the documentation for the <tt>libtheora</tt> C API.
22
*
23
* The \c libtheora package is the current reference
24
* implementation for <a href="https://www.theora.org/">Theora</a>, a free,
25
* patent-unencumbered video codec.
26
* Theora is derived from On2's VP3 codec with additional features and
27
* integration with Ogg multimedia formats by
28
* <a href="https://www.xiph.org/">the Xiph.Org Foundation</a>.
29
* Complete documentation of the format itself is available in
30
* <a href="https://www.theora.org/doc/Theora.pdf">the Theora
31
* specification</a>.
32
*
33
* \section Organization
34
*
35
* The functions documented here are divided between two
36
* separate libraries:
37
* - \c libtheoraenc contains the encoder interface,
38
* described in \ref encfuncs.
39
* - \c libtheoradec contains the decoder interface,
40
* described in \ref decfuncs, \n
41
* and additional \ref basefuncs.
42
*
43
* New code should link to \c libtheoradec. If using encoder
44
* features, it must also link to \c libtheoraenc.
45
*
46
* During initial development, prior to the 1.0 release,
47
* \c libtheora exported a different \ref oldfuncs which
48
* combined both encode and decode functions.
49
* In general, legacy API symbols can be identified
50
* by their \c theora_ or \c OC_ namespace prefixes.
51
* The current API uses \c th_ or \c TH_ instead.
52
*
53
* While deprecated, \c libtheoraenc and \c libtheoradec
54
* together export the legacy api as well at the one documented above.
55
* Likewise, the legacy \c libtheora included with this package
56
* exports the new 1.x API. Older code and build scripts can therefore
57
* but updated independently to the current scheme.
58
*/
59
60
/**\file
61
* The shared <tt>libtheoradec</tt> and <tt>libtheoraenc</tt> C API.
62
* You don't need to include this directly.*/
63
64
#if !defined(OGG_THEORA_CODEC_HEADER)
65
# define OGG_THEORA_CODEC_HEADER (1)
66
# include <ogg/ogg.h>
67
68
#if defined(__cplusplus)
69
extern "C" {
70
#endif
71
72
73
74
/**\name Return codes*/
75
/*@{*/
76
/**An invalid pointer was provided.*/
77
#define TH_EFAULT (-1)
78
/**An invalid argument was provided.*/
79
#define TH_EINVAL (-10)
80
/**The contents of the header were incomplete, invalid, or unexpected.*/
81
#define TH_EBADHEADER (-20)
82
/**The header does not belong to a Theora stream.*/
83
#define TH_ENOTFORMAT (-21)
84
/**The bitstream version is too high.*/
85
#define TH_EVERSION (-22)
86
/**The specified function is not implemented.*/
87
#define TH_EIMPL (-23)
88
/**There were errors in the video data packet.*/
89
#define TH_EBADPACKET (-24)
90
/**The decoded packet represented a dropped frame.
91
The player can continue to display the current frame, as the contents of the
92
decoded frame buffer have not changed.*/
93
#define TH_DUPFRAME (1)
94
/*@}*/
95
96
/**The currently defined color space tags.
97
* See <a href="https://www.theora.org/doc/Theora.pdf">the Theora
98
* specification</a>, Chapter 4, for exact details on the meaning
99
* of each of these color spaces.*/
100
typedef enum{
101
/**The color space was not specified at the encoder.
102
It may be conveyed by an external means.*/
103
TH_CS_UNSPECIFIED,
104
/**A color space designed for NTSC content.*/
105
TH_CS_ITU_REC_470M,
106
/**A color space designed for PAL/SECAM content.*/
107
TH_CS_ITU_REC_470BG,
108
/**The total number of currently defined color spaces.*/
109
TH_CS_NSPACES
110
}th_colorspace;
111
112
/**The currently defined pixel format tags.
113
* See <a href="https://www.theora.org/doc/Theora.pdf">the Theora
114
* specification</a>, Section 4.4, for details on the precise sample
115
* locations.*/
116
typedef enum{
117
/**Chroma decimation by 2 in both the X and Y directions (4:2:0).
118
The Cb and Cr chroma planes are half the width and half the
119
height of the luma plane.*/
120
TH_PF_420,
121
/**Currently reserved.*/
122
TH_PF_RSVD,
123
/**Chroma decimation by 2 in the X direction (4:2:2).
124
The Cb and Cr chroma planes are half the width of the luma plane, but full
125
height.*/
126
TH_PF_422,
127
/**No chroma decimation (4:4:4).
128
The Cb and Cr chroma planes are full width and full height.*/
129
TH_PF_444,
130
/**The total number of currently defined pixel formats.*/
131
TH_PF_NFORMATS
132
}th_pixel_fmt;
133
134
135
136
/**A buffer for a single color plane in an uncompressed image.
137
* This contains the image data in a left-to-right, top-down format.
138
* Each row of pixels is stored contiguously in memory, but successive
139
* rows need not be.
140
* Use \a stride to compute the offset of the next row.
141
* The encoder accepts both positive \a stride values (top-down in memory)
142
* and negative (bottom-up in memory).
143
* The decoder currently always generates images with positive strides.*/
144
typedef struct{
145
/**The width of this plane.*/
146
int width;
147
/**The height of this plane.*/
148
int height;
149
/**The offset in bytes between successive rows.*/
150
int stride;
151
/**A pointer to the beginning of the first row.*/
152
unsigned char *data;
153
}th_img_plane;
154
155
/**A complete image buffer for an uncompressed frame.
156
* The chroma planes may be decimated by a factor of two in either
157
* direction, as indicated by th_info#pixel_fmt.
158
* The width and height of the Y' plane must be multiples of 16.
159
* They may need to be cropped for display, using the rectangle
160
* specified by th_info#pic_x, th_info#pic_y, th_info#pic_width,
161
* and th_info#pic_height.
162
* All samples are 8 bits.
163
* \note The term YUV often used to describe a colorspace is ambiguous.
164
* The exact parameters of the RGB to YUV conversion process aside, in
165
* many contexts the U and V channels actually have opposite meanings.
166
* To avoid this confusion, we are explicit: the name of the color
167
* channels are Y'CbCr, and they appear in that order, always.
168
* The prime symbol denotes that the Y channel is non-linear.
169
* Cb and Cr stand for "Chroma blue" and "Chroma red", respectively.*/
170
typedef th_img_plane th_ycbcr_buffer[3];
171
172
/**Theora bitstream information.
173
* This contains the basic playback parameters for a stream, and corresponds to
174
* the initial 'info' header packet.
175
* To initialize an encoder, the application fills in this structure and
176
* passes it to th_encode_alloc().
177
* A default encoding mode is chosen based on the values of the #quality and
178
* #target_bitrate fields.
179
* On decode, it is filled in by th_decode_headerin(), and then passed to
180
* th_decode_alloc().
181
*
182
* Encoded Theora frames must be a multiple of 16 in size;
183
* this is what the #frame_width and #frame_height members represent.
184
* To handle arbitrary picture sizes, a crop rectangle is specified in the
185
* #pic_x, #pic_y, #pic_width and #pic_height members.
186
*
187
* All frame buffers contain pointers to the full, padded frame.
188
* However, the current encoder <em>will not</em> reference pixels outside of
189
* the cropped picture region, and the application does not need to fill them
190
* in.
191
* The decoder <em>will</em> allocate storage for a full frame, but the
192
* application <em>should not</em> rely on the padding containing sensible
193
* data.
194
*
195
* It is also generally recommended that the offsets and sizes should still be
196
* multiples of 2 to avoid chroma sampling shifts when chroma is sub-sampled.
197
* See <a href="https://www.theora.org/doc/Theora.pdf">the Theora
198
* specification</a>, Section 4.4, for more details.
199
*
200
* Frame rate, in frames per second, is stored as a rational fraction, as is
201
* the pixel aspect ratio.
202
* Note that this refers to the aspect ratio of the individual pixels, not of
203
* the overall frame itself.
204
* The frame aspect ratio can be computed from pixel aspect ratio using the
205
* image dimensions.*/
206
typedef struct{
207
/**\name Theora version
208
* Bitstream version information.*/
209
/*@{*/
210
unsigned char version_major;
211
unsigned char version_minor;
212
unsigned char version_subminor;
213
/*@}*/
214
/**The encoded frame width.
215
* This must be a multiple of 16, and less than 1048576.*/
216
ogg_uint32_t frame_width;
217
/**The encoded frame height.
218
* This must be a multiple of 16, and less than 1048576.*/
219
ogg_uint32_t frame_height;
220
/**The displayed picture width.
221
* This must be no larger than width.*/
222
ogg_uint32_t pic_width;
223
/**The displayed picture height.
224
* This must be no larger than height.*/
225
ogg_uint32_t pic_height;
226
/**The X offset of the displayed picture.
227
* This must be no larger than #frame_width-#pic_width or 255, whichever is
228
* smaller.*/
229
ogg_uint32_t pic_x;
230
/**The Y offset of the displayed picture.
231
* This must be no larger than #frame_height-#pic_height, and
232
* #frame_height-#pic_height-#pic_y must be no larger than 255.
233
* This slightly funny restriction is due to the fact that the offset is
234
* specified from the top of the image for consistency with the standard
235
* graphics left-handed coordinate system used throughout this API, while
236
* it is stored in the encoded stream as an offset from the bottom.*/
237
ogg_uint32_t pic_y;
238
/**\name Frame rate
239
* The frame rate, as a fraction.
240
* If either is 0, the frame rate is undefined.*/
241
/*@{*/
242
ogg_uint32_t fps_numerator;
243
ogg_uint32_t fps_denominator;
244
/*@}*/
245
/**\name Aspect ratio
246
* The aspect ratio of the pixels.
247
* If either value is zero, the aspect ratio is undefined.
248
* If not specified by any external means, 1:1 should be assumed.
249
* The aspect ratio of the full picture can be computed as
250
* \code
251
* aspect_numerator*pic_width/(aspect_denominator*pic_height).
252
* \endcode */
253
/*@{*/
254
ogg_uint32_t aspect_numerator;
255
ogg_uint32_t aspect_denominator;
256
/*@}*/
257
/**The color space.*/
258
th_colorspace colorspace;
259
/**The pixel format.*/
260
th_pixel_fmt pixel_fmt;
261
/**The target bit-rate in bits per second.
262
If initializing an encoder with this struct, set this field to a non-zero
263
value to activate CBR encoding by default.*/
264
int target_bitrate;
265
/**The target quality level.
266
Valid values range from 0 to 63, inclusive, with higher values giving
267
higher quality.
268
If initializing an encoder with this struct, and #target_bitrate is set
269
to zero, VBR encoding at this quality will be activated by default.*/
270
/*Currently this is set so that a qi of 0 corresponds to distortions of 24
271
times the JND, and each increase by 16 halves that value.
272
This gives us fine discrimination at low qualities, yet effective rate
273
control at high qualities.
274
The qi value 63 is special, however.
275
For this, the highest quality, we use one half of a JND for our threshold.
276
Due to the lower bounds placed on allowable quantizers in Theora, we will
277
not actually be able to achieve quality this good, but this should
278
provide as close to visually lossless quality as Theora is capable of.
279
We could lift the quantizer restrictions without breaking VP3.1
280
compatibility, but this would result in quantized coefficients that are
281
too large for the current bitstream to be able to store.
282
We'd have to redesign the token syntax to store these large coefficients,
283
which would make transcoding complex.*/
284
int quality;
285
/**The amount to shift to extract the last keyframe number from the granule
286
* position.
287
* This can be at most 31.
288
* th_info_init() will set this to a default value (currently <tt>6</tt>,
289
* which is good for streaming applications), but you can set it to 0 to
290
* make every frame a keyframe.
291
* The maximum distance between key frames is
292
* <tt>1<<#keyframe_granule_shift</tt>.
293
* The keyframe frequency can be more finely controlled with
294
* #TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE, which can also be adjusted
295
* during encoding (for example, to force the next frame to be a keyframe),
296
* but it cannot be set larger than the amount permitted by this field after
297
* the headers have been output.*/
298
int keyframe_granule_shift;
299
}th_info;
300
301
/**The comment information.
302
*
303
* This structure holds the in-stream metadata corresponding to
304
* the 'comment' header packet.
305
* The comment header is meant to be used much like someone jotting a quick
306
* note on the label of a video.
307
* It should be a short, to the point text note that can be more than a couple
308
* words, but not more than a short paragraph.
309
*
310
* The metadata is stored as a series of (tag, value) pairs, in
311
* length-encoded string vectors.
312
* The first occurrence of the '=' character delimits the tag and value.
313
* A particular tag may occur more than once, and order is significant.
314
* The character set encoding for the strings is always UTF-8, but the tag
315
* names are limited to ASCII, and treated as case-insensitive.
316
* See <a href="https://www.theora.org/doc/Theora.pdf">the Theora
317
* specification</a>, Section 6.3.3 for details.
318
*
319
* In filling in this structure, th_decode_headerin() will null-terminate
320
* the user_comment strings for safety.
321
* However, the bitstream format itself treats them as 8-bit clean vectors,
322
* possibly containing null characters, so the length array should be
323
* treated as their authoritative length.
324
*/
325
typedef struct th_comment{
326
/**The array of comment string vectors.*/
327
char **user_comments;
328
/**An array of the corresponding length of each vector, in bytes.*/
329
int *comment_lengths;
330
/**The total number of comment strings.*/
331
int comments;
332
/**The null-terminated vendor string.
333
This identifies the software used to encode the stream.*/
334
char *vendor;
335
}th_comment;
336
337
338
339
/**A single base matrix.*/
340
typedef unsigned char th_quant_base[64];
341
342
/**A set of \a qi ranges.*/
343
typedef struct{
344
/**The number of ranges in the set.*/
345
int nranges;
346
/**The size of each of the #nranges ranges.
347
These must sum to 63.*/
348
const int *sizes;
349
/**#nranges <tt>+1</tt> base matrices.
350
Matrices \a i and <tt>i+1</tt> form the endpoints of range \a i.*/
351
const th_quant_base *base_matrices;
352
}th_quant_ranges;
353
354
/**A complete set of quantization parameters.
355
The quantizer for each coefficient is calculated as:
356
\code
357
Q=MAX(MIN(qmin[qti][ci!=0],scale[ci!=0][qi]*base[qti][pli][qi][ci]/100),
358
1024).
359
\endcode
360
361
\a qti is the quantization type index: 0 for intra, 1 for inter.
362
<tt>ci!=0</tt> is 0 for the DC coefficient and 1 for AC coefficients.
363
\a qi is the quality index, ranging between 0 (low quality) and 63 (high
364
quality).
365
\a pli is the color plane index: 0 for Y', 1 for Cb, 2 for Cr.
366
\a ci is the DCT coefficient index.
367
Coefficient indices correspond to the normal 2D DCT block
368
ordering--row-major with low frequencies first--\em not zig-zag order.
369
370
Minimum quantizers are constant, and are given by:
371
\code
372
qmin[2][2]={{4,2},{8,4}}.
373
\endcode
374
375
Parameters that can be stored in the bitstream are as follows:
376
- The two scale matrices ac_scale and dc_scale.
377
\code
378
scale[2][64]={dc_scale,ac_scale}.
379
\endcode
380
- The base matrices for each \a qi, \a qti and \a pli (up to 384 in all).
381
In order to avoid storing a full 384 base matrices, only a sparse set of
382
matrices are stored, and the rest are linearly interpolated.
383
This is done as follows.
384
For each \a qti and \a pli, a series of \a n \a qi ranges is defined.
385
The size of each \a qi range can vary arbitrarily, but they must sum to
386
63.
387
Then, <tt>n+1</tt> matrices are specified, one for each endpoint of the
388
ranges.
389
For interpolation purposes, each range's endpoints are the first \a qi
390
value it contains and one past the last \a qi value it contains.
391
Fractional values are rounded to the nearest integer, with ties rounded
392
away from zero.
393
394
Base matrices are stored by reference, so if the same matrices are used
395
multiple times, they will only appear once in the bitstream.
396
The bitstream is also capable of omitting an entire set of ranges and
397
its associated matrices if they are the same as either the previous
398
set (indexed in row-major order) or if the inter set is the same as the
399
intra set.
400
401
- Loop filter limit values.
402
The same limits are used for the loop filter in all color planes, despite
403
potentially differing levels of quantization in each.
404
405
For the current encoder, <tt>scale[ci!=0][qi]</tt> must be no greater
406
than <tt>scale[ci!=0][qi-1]</tt> and <tt>base[qti][pli][qi][ci]</tt> must
407
be no greater than <tt>base[qti][pli][qi-1][ci]</tt>.
408
These two conditions ensure that the actual quantizer for a given \a qti,
409
\a pli, and \a ci does not increase as \a qi increases.
410
This is not required by the decoder.*/
411
typedef struct{
412
/**The DC scaling factors.*/
413
ogg_uint16_t dc_scale[64];
414
/**The AC scaling factors.*/
415
ogg_uint16_t ac_scale[64];
416
/**The loop filter limit values.*/
417
unsigned char loop_filter_limits[64];
418
/**The \a qi ranges for each \a ci and \a pli.*/
419
th_quant_ranges qi_ranges[2][3];
420
}th_quant_info;
421
422
423
424
/**The number of Huffman tables used by Theora.*/
425
#define TH_NHUFFMAN_TABLES (80)
426
/**The number of DCT token values in each table.*/
427
#define TH_NDCT_TOKENS (32)
428
429
/**A Huffman code for a Theora DCT token.
430
* Each set of Huffman codes in a given table must form a complete, prefix-free
431
* code.
432
* There is no requirement that all the tokens in a table have a valid code,
433
* but the current encoder is not optimized to take advantage of this.
434
* If each of the five grouops of 16 tables does not contain at least one table
435
* with a code for every token, then the encoder may fail to encode certain
436
* frames.
437
* The complete table in the first group of 16 does not have to be in the same
438
* place as the complete table in the other groups, but the complete tables in
439
* the remaining four groups must all be in the same place.*/
440
typedef struct{
441
/**The bit pattern for the code, with the LSbit of the pattern aligned in
442
* the LSbit of the word.*/
443
ogg_uint32_t pattern;
444
/**The number of bits in the code.
445
* This must be between 0 and 32, inclusive.*/
446
int nbits;
447
}th_huff_code;
448
449
450
451
/**\defgroup basefuncs Functions Shared by Encode and Decode*/
452
/*@{*/
453
/**\name Basic shared functions
454
* These functions return information about the library itself,
455
* or provide high-level information about codec state
456
* and packet type.
457
*
458
* You must link to \c libtheoradec if you use any of the
459
* functions in this section.*/
460
/*@{*/
461
/**Retrieves a human-readable string to identify the library vendor and
462
* version.
463
* \return the version string.*/
464
extern const char *th_version_string(void);
465
/**Retrieves the library version number.
466
* This is the highest bitstream version that the encoder library will produce,
467
* or that the decoder library can decode.
468
* This number is composed of a 16-bit major version, 8-bit minor version
469
* and 8 bit sub-version, composed as follows:
470
* \code
471
* (VERSION_MAJOR<<16)+(VERSION_MINOR<<8)+(VERSION_SUBMINOR)
472
* \endcode
473
* \return the version number.*/
474
extern ogg_uint32_t th_version_number(void);
475
/**Converts a granule position to an absolute frame index, starting at
476
* <tt>0</tt>.
477
* The granule position is interpreted in the context of a given
478
* #th_enc_ctx or #th_dec_ctx handle (either will suffice).
479
* \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx
480
* handle.
481
* \param _granpos The granule position to convert.
482
* \returns The absolute frame index corresponding to \a _granpos.
483
* \retval -1 The given granule position was invalid (i.e. negative).*/
484
extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos);
485
/**Converts a granule position to an absolute time in seconds.
486
* The granule position is interpreted in the context of a given
487
* #th_enc_ctx or #th_dec_ctx handle (either will suffice).
488
* \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx
489
* handle.
490
* \param _granpos The granule position to convert.
491
* \return The absolute time in seconds corresponding to \a _granpos.
492
* This is the "end time" for the frame, or the latest time it should
493
* be displayed.
494
* It is not the presentation time.
495
* \retval -1 The given granule position was invalid (i.e. negative).*/
496
extern double th_granule_time(void *_encdec,ogg_int64_t _granpos);
497
/**Determines whether a Theora packet is a header or not.
498
* This function does no verification beyond checking the packet type bit, so
499
* it should not be used for bitstream identification; use
500
* th_decode_headerin() for that.
501
* As per the Theora specification, an empty (0-byte) packet is treated as a
502
* data packet (a delta frame with no coded blocks).
503
* \param _op An <tt>ogg_packet</tt> containing encoded Theora data.
504
* \retval 1 The packet is a header packet
505
* \retval 0 The packet is a video data packet.*/
506
extern int th_packet_isheader(ogg_packet *_op);
507
/**Determines whether a theora packet is a key frame or not.
508
* This function does no verification beyond checking the packet type and
509
* key frame bits, so it should not be used for bitstream identification; use
510
* th_decode_headerin() for that.
511
* As per the Theora specification, an empty (0-byte) packet is treated as a
512
* delta frame (with no coded blocks).
513
* \param _op An <tt>ogg_packet</tt> containing encoded Theora data.
514
* \retval 1 The packet contains a key frame.
515
* \retval 0 The packet contains a delta frame.
516
* \retval -1 The packet is not a video data packet.*/
517
extern int th_packet_iskeyframe(ogg_packet *_op);
518
/*@}*/
519
520
521
/**\name Functions for manipulating header data
522
* These functions manipulate the #th_info and #th_comment structures
523
* which describe video parameters and key-value metadata, respectively.
524
*
525
* You must link to \c libtheoradec if you use any of the
526
* functions in this section.*/
527
/*@{*/
528
/**Initializes a th_info structure.
529
* This should be called on a freshly allocated #th_info structure before
530
* attempting to use it.
531
* \param _info The #th_info struct to initialize.*/
532
extern void th_info_init(th_info *_info);
533
/**Clears a #th_info structure.
534
* This should be called on a #th_info structure after it is no longer
535
* needed.
536
* \param _info The #th_info struct to clear.*/
537
extern void th_info_clear(th_info *_info);
538
539
/**Initialize a #th_comment structure.
540
* This should be called on a freshly allocated #th_comment structure
541
* before attempting to use it.
542
* \param _tc The #th_comment struct to initialize.*/
543
extern void th_comment_init(th_comment *_tc);
544
/**Add a comment to an initialized #th_comment structure.
545
* \note Neither th_comment_add() nor th_comment_add_tag() support
546
* comments containing null values, although the bitstream format does
547
* support them.
548
* To add such comments you will need to manipulate the #th_comment
549
* structure directly.
550
* \param _tc The #th_comment struct to add the comment to.
551
* \param _comment Must be a null-terminated UTF-8 string containing the
552
* comment in "TAG=the value" form.*/
553
extern void th_comment_add(th_comment *_tc,const char *_comment);
554
/**Add a comment to an initialized #th_comment structure.
555
* \note Neither th_comment_add() nor th_comment_add_tag() support
556
* comments containing null values, although the bitstream format does
557
* support them.
558
* To add such comments you will need to manipulate the #th_comment
559
* structure directly.
560
* \param _tc The #th_comment struct to add the comment to.
561
* \param _tag A null-terminated string containing the tag associated with
562
* the comment.
563
* \param _val The corresponding value as a null-terminated string.*/
564
extern void th_comment_add_tag(th_comment *_tc,const char *_tag,
565
const char *_val);
566
/**Look up a comment value by its tag.
567
* \param _tc An initialized #th_comment structure.
568
* \param _tag The tag to look up.
569
* \param _count The instance of the tag.
570
* The same tag can appear multiple times, each with a distinct
571
* value, so an index is required to retrieve them all.
572
* The order in which these values appear is significant and
573
* should be preserved.
574
* Use th_comment_query_count() to get the legal range for
575
* the \a _count parameter.
576
* \return A pointer to the queried tag's value.
577
* This points directly to data in the #th_comment structure.
578
* It should not be modified or freed by the application, and
579
* modifications to the structure may invalidate the pointer.
580
* \retval NULL If no matching tag is found.*/
581
extern char *th_comment_query(th_comment *_tc,const char *_tag,int _count);
582
/**Look up the number of instances of a tag.
583
* Call this first when querying for a specific tag and then iterate over the
584
* number of instances with separate calls to th_comment_query() to
585
* retrieve all the values for that tag in order.
586
* \param _tc An initialized #th_comment structure.
587
* \param _tag The tag to look up.
588
* \return The number of instances of this particular tag.*/
589
extern int th_comment_query_count(th_comment *_tc,const char *_tag);
590
/**Clears a #th_comment structure.
591
* This should be called on a #th_comment structure after it is no longer
592
* needed.
593
* It will free all memory used by the structure members.
594
* \param _tc The #th_comment struct to clear.*/
595
extern void th_comment_clear(th_comment *_tc);
596
/*@}*/
597
/*@}*/
598
599
600
601
#if defined(__cplusplus)
602
}
603
#endif
604
605
#endif /* OGG_THEORA_CODEC_HEADER */
606
607