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 and contributors http://www.xiph.org/ *
10 : * *
11 : ********************************************************************
12 :
13 : function:
14 : last mod: $Id: internal.h 17337 2010-07-19 16:08:54Z tterribe $
15 :
16 : ********************************************************************/
17 : #if !defined(_state_H)
18 : # define _state_H (1)
19 : # include "internal.h"
20 : # include "huffman.h"
21 : # include "quant.h"
22 :
23 :
24 :
25 : /*A single quadrant of the map from a super block to fragment numbers.*/
26 : typedef ptrdiff_t oc_sb_map_quad[4];
27 : /*A map from a super block to fragment numbers.*/
28 : typedef oc_sb_map_quad oc_sb_map[4];
29 : /*A single plane of the map from a macro block to fragment numbers.*/
30 : typedef ptrdiff_t oc_mb_map_plane[4];
31 : /*A map from a macro block to fragment numbers.*/
32 : typedef oc_mb_map_plane oc_mb_map[3];
33 : /*A motion vector.*/
34 : typedef ogg_int16_t oc_mv;
35 :
36 : typedef struct oc_sb_flags oc_sb_flags;
37 : typedef struct oc_border_info oc_border_info;
38 : typedef struct oc_fragment oc_fragment;
39 : typedef struct oc_fragment_plane oc_fragment_plane;
40 : typedef struct oc_base_opt_vtable oc_base_opt_vtable;
41 : typedef struct oc_base_opt_data oc_base_opt_data;
42 : typedef struct oc_state_dispatch_vtable oc_state_dispatch_vtable;
43 : typedef struct oc_theora_state oc_theora_state;
44 :
45 :
46 :
47 : /*Shared accelerated functions.*/
48 : # if defined(OC_X86_ASM)
49 : # if defined(_MSC_VER)
50 : # include "x86_vc/x86int.h"
51 : # else
52 : # include "x86/x86int.h"
53 : # endif
54 : # endif
55 : # if defined(OC_ARM_ASM)
56 : # include "arm/armint.h"
57 : # endif
58 : # if defined(OC_C64X_ASM)
59 : # include "c64x/c64xint.h"
60 : # endif
61 :
62 : # if !defined(oc_state_accel_init)
63 : # define oc_state_accel_init oc_state_accel_init_c
64 : # endif
65 : # if defined(OC_STATE_USE_VTABLE)
66 : # if !defined(oc_frag_copy)
67 : # define oc_frag_copy(_state,_dst,_src,_ystride) \
68 : ((*(_state)->opt_vtable.frag_copy)(_dst,_src,_ystride))
69 : # endif
70 : # if !defined(oc_frag_copy_list)
71 : # define oc_frag_copy_list(_state,_dst_frame,_src_frame,_ystride, \
72 : _fragis,_nfragis,_frag_buf_offs) \
73 : ((*(_state)->opt_vtable.frag_copy_list)(_dst_frame,_src_frame,_ystride, \
74 : _fragis,_nfragis,_frag_buf_offs))
75 : # endif
76 : # if !defined(oc_frag_recon_intra)
77 : # define oc_frag_recon_intra(_state,_dst,_dst_ystride,_residue) \
78 : ((*(_state)->opt_vtable.frag_recon_intra)(_dst,_dst_ystride,_residue))
79 : # endif
80 : # if !defined(oc_frag_recon_inter)
81 : # define oc_frag_recon_inter(_state,_dst,_src,_ystride,_residue) \
82 : ((*(_state)->opt_vtable.frag_recon_inter)(_dst,_src,_ystride,_residue))
83 : # endif
84 : # if !defined(oc_frag_recon_inter2)
85 : # define oc_frag_recon_inter2(_state,_dst,_src1,_src2,_ystride,_residue) \
86 : ((*(_state)->opt_vtable.frag_recon_inter2)(_dst, \
87 : _src1,_src2,_ystride,_residue))
88 : # endif
89 : # if !defined(oc_idct8x8)
90 : # define oc_idct8x8(_state,_y,_x,_last_zzi) \
91 : ((*(_state)->opt_vtable.idct8x8)(_y,_x,_last_zzi))
92 : # endif
93 : # if !defined(oc_state_frag_recon)
94 : # define oc_state_frag_recon(_state,_fragi, \
95 : _pli,_dct_coeffs,_last_zzi,_dc_quant) \
96 : ((*(_state)->opt_vtable.state_frag_recon)(_state,_fragi, \
97 : _pli,_dct_coeffs,_last_zzi,_dc_quant))
98 : # endif
99 : # if !defined(oc_loop_filter_init)
100 : # define oc_loop_filter_init(_state,_bv,_flimit) \
101 : ((*(_state)->opt_vtable.loop_filter_init)(_bv,_flimit))
102 : # endif
103 : # if !defined(oc_state_loop_filter_frag_rows)
104 : # define oc_state_loop_filter_frag_rows(_state, \
105 : _bv,_refi,_pli,_fragy0,_fragy_end) \
106 : ((*(_state)->opt_vtable.state_loop_filter_frag_rows)(_state, \
107 : _bv,_refi,_pli,_fragy0,_fragy_end))
108 : # endif
109 : # if !defined(oc_restore_fpu)
110 : # define oc_restore_fpu(_state) \
111 : ((*(_state)->opt_vtable.restore_fpu)())
112 : # endif
113 : # else
114 : # if !defined(oc_frag_copy)
115 : # define oc_frag_copy(_state,_dst,_src,_ystride) \
116 : oc_frag_copy_c(_dst,_src,_ystride)
117 : # endif
118 : # if !defined(oc_frag_copy_list)
119 : # define oc_frag_copy_list(_state,_dst_frame,_src_frame,_ystride, \
120 : _fragis,_nfragis,_frag_buf_offs) \
121 : oc_frag_copy_list_c(_dst_frame,_src_frame,_ystride, \
122 : _fragis,_nfragis,_frag_buf_offs)
123 : # endif
124 : # if !defined(oc_frag_recon_intra)
125 : # define oc_frag_recon_intra(_state,_dst,_dst_ystride,_residue) \
126 : oc_frag_recon_intra_c(_dst,_dst_ystride,_residue)
127 : # endif
128 : # if !defined(oc_frag_recon_inter)
129 : # define oc_frag_recon_inter(_state,_dst,_src,_ystride,_residue) \
130 : oc_frag_recon_inter_c(_dst,_src,_ystride,_residue)
131 : # endif
132 : # if !defined(oc_frag_recon_inter2)
133 : # define oc_frag_recon_inter2(_state,_dst,_src1,_src2,_ystride,_residue) \
134 : oc_frag_recon_inter2_c(_dst,_src1,_src2,_ystride,_residue)
135 : # endif
136 : # if !defined(oc_idct8x8)
137 : # define oc_idct8x8(_state,_y,_x,_last_zzi) oc_idct8x8_c(_y,_x,_last_zzi)
138 : # endif
139 : # if !defined(oc_state_frag_recon)
140 : # define oc_state_frag_recon oc_state_frag_recon_c
141 : # endif
142 : # if !defined(oc_loop_filter_init)
143 : # define oc_loop_filter_init(_state,_bv,_flimit) \
144 : oc_loop_filter_init_c(_bv,_flimit)
145 : # endif
146 : # if !defined(oc_state_loop_filter_frag_rows)
147 : # define oc_state_loop_filter_frag_rows oc_state_loop_filter_frag_rows_c
148 : # endif
149 : # if !defined(oc_restore_fpu)
150 : # define oc_restore_fpu(_state) do{}while(0)
151 : # endif
152 : # endif
153 :
154 :
155 :
156 : /*A keyframe.*/
157 : # define OC_INTRA_FRAME (0)
158 : /*A predicted frame.*/
159 : # define OC_INTER_FRAME (1)
160 : /*A frame of unknown type (frame type decision has not yet been made).*/
161 : # define OC_UNKWN_FRAME (-1)
162 :
163 : /*The amount of padding to add to the reconstructed frame buffers on all
164 : sides.
165 : This is used to allow unrestricted motion vectors without special casing.
166 : This must be a multiple of 2.*/
167 : # define OC_UMV_PADDING (16)
168 :
169 : /*Frame classification indices.*/
170 : /*The previous golden frame.*/
171 : # define OC_FRAME_GOLD (0)
172 : /*The previous frame.*/
173 : # define OC_FRAME_PREV (1)
174 : /*The current frame.*/
175 : # define OC_FRAME_SELF (2)
176 : /*Used to mark uncoded fragments (for DC prediction).*/
177 : # define OC_FRAME_NONE (3)
178 :
179 : /*The input or output buffer.*/
180 : # define OC_FRAME_IO (3)
181 : /*Uncompressed prev golden frame.*/
182 : # define OC_FRAME_GOLD_ORIG (4)
183 : /*Uncompressed previous frame. */
184 : # define OC_FRAME_PREV_ORIG (5)
185 :
186 : /*Macroblock modes.*/
187 : /*Macro block is invalid: It is never coded.*/
188 : # define OC_MODE_INVALID (-1)
189 : /*Encoded difference from the same macro block in the previous frame.*/
190 : # define OC_MODE_INTER_NOMV (0)
191 : /*Encoded with no motion compensated prediction.*/
192 : # define OC_MODE_INTRA (1)
193 : /*Encoded difference from the previous frame offset by the given motion
194 : vector.*/
195 : # define OC_MODE_INTER_MV (2)
196 : /*Encoded difference from the previous frame offset by the last coded motion
197 : vector.*/
198 : # define OC_MODE_INTER_MV_LAST (3)
199 : /*Encoded difference from the previous frame offset by the second to last
200 : coded motion vector.*/
201 : # define OC_MODE_INTER_MV_LAST2 (4)
202 : /*Encoded difference from the same macro block in the previous golden
203 : frame.*/
204 : # define OC_MODE_GOLDEN_NOMV (5)
205 : /*Encoded difference from the previous golden frame offset by the given motion
206 : vector.*/
207 : # define OC_MODE_GOLDEN_MV (6)
208 : /*Encoded difference from the previous frame offset by the individual motion
209 : vectors given for each block.*/
210 : # define OC_MODE_INTER_MV_FOUR (7)
211 : /*The number of (coded) modes.*/
212 : # define OC_NMODES (8)
213 :
214 : /*Determines the reference frame used for a given MB mode.*/
215 : # define OC_FRAME_FOR_MODE(_x) \
216 : OC_UNIBBLE_TABLE32(OC_FRAME_PREV,OC_FRAME_SELF,OC_FRAME_PREV,OC_FRAME_PREV, \
217 : OC_FRAME_PREV,OC_FRAME_GOLD,OC_FRAME_GOLD,OC_FRAME_PREV,(_x))
218 :
219 : /*Constants for the packet state machine common between encoder and decoder.*/
220 :
221 : /*Next packet to emit/read: Codec info header.*/
222 : # define OC_PACKET_INFO_HDR (-3)
223 : /*Next packet to emit/read: Comment header.*/
224 : # define OC_PACKET_COMMENT_HDR (-2)
225 : /*Next packet to emit/read: Codec setup header.*/
226 : # define OC_PACKET_SETUP_HDR (-1)
227 : /*No more packets to emit/read.*/
228 : # define OC_PACKET_DONE (INT_MAX)
229 :
230 :
231 :
232 : #define OC_MV(_x,_y) ((oc_mv)((_x)&0xFF|(_y)<<8))
233 : #define OC_MV_X(_mv) ((signed char)(_mv))
234 : #define OC_MV_Y(_mv) ((_mv)>>8)
235 : #define OC_MV_ADD(_mv1,_mv2) \
236 : OC_MV(OC_MV_X(_mv1)+OC_MV_X(_mv2), \
237 : OC_MV_Y(_mv1)+OC_MV_Y(_mv2))
238 : #define OC_MV_SUB(_mv1,_mv2) \
239 : OC_MV(OC_MV_X(_mv1)-OC_MV_X(_mv2), \
240 : OC_MV_Y(_mv1)-OC_MV_Y(_mv2))
241 :
242 :
243 :
244 : /*Super blocks are 32x32 segments of pixels in a single color plane indexed
245 : in image order.
246 : Internally, super blocks are broken up into four quadrants, each of which
247 : contains a 2x2 pattern of blocks, each of which is an 8x8 block of pixels.
248 : Quadrants, and the blocks within them, are indexed in a special order called
249 : a "Hilbert curve" within the super block.
250 :
251 : In order to differentiate between the Hilbert-curve indexing strategy and
252 : the regular image order indexing strategy, blocks indexed in image order
253 : are called "fragments".
254 : Fragments are indexed in image order, left to right, then bottom to top,
255 : from Y' plane to Cb plane to Cr plane.
256 :
257 : The co-located fragments in all image planes corresponding to the location
258 : of a single quadrant of a luma plane super block form a macro block.
259 : Thus there is only a single set of macro blocks for all planes, each of which
260 : contains between 6 and 12 fragments, depending on the pixel format.
261 : Therefore macro block information is kept in a separate set of arrays from
262 : super blocks to avoid unused space in the other planes.
263 : The lists are indexed in super block order.
264 : That is, the macro block corresponding to the macro block mbi in (luma plane)
265 : super block sbi is at index (sbi<<2|mbi).
266 : Thus the number of macro blocks in each dimension is always twice the number
267 : of super blocks, even when only an odd number fall inside the coded frame.
268 : These "extra" macro blocks are just an artifact of our internal data layout,
269 : and not part of the coded stream; they are flagged with a negative MB mode.*/
270 :
271 :
272 :
273 : /*Super block information.*/
274 : struct oc_sb_flags{
275 : unsigned char coded_fully:1;
276 : unsigned char coded_partially:1;
277 : unsigned char quad_valid:4;
278 : };
279 :
280 :
281 :
282 : /*Information about a fragment which intersects the border of the displayable
283 : region.
284 : This marks which pixels belong to the displayable region.*/
285 : struct oc_border_info{
286 : /*A bit mask marking which pixels are in the displayable region.
287 : Pixel (x,y) corresponds to bit (y<<3|x).*/
288 : ogg_int64_t mask;
289 : /*The number of pixels in the displayable region.
290 : This is always positive, and always less than 64.*/
291 : int npixels;
292 : };
293 :
294 :
295 :
296 : /*Fragment information.*/
297 : struct oc_fragment{
298 : /*A flag indicating whether or not this fragment is coded.*/
299 : unsigned coded:1;
300 : /*A flag indicating that this entire fragment lies outside the displayable
301 : region of the frame.
302 : Note the contrast with an invalid macro block, which is outside the coded
303 : frame, not just the displayable one.
304 : There are no fragments outside the coded frame by construction.*/
305 : unsigned invalid:1;
306 : /*The index of the quality index used for this fragment's AC coefficients.*/
307 : unsigned qii:4;
308 : /*The index of the reference frame this fragment is predicted from.*/
309 : unsigned refi:2;
310 : /*The mode of the macroblock this fragment belongs to.*/
311 : unsigned mb_mode:3;
312 : /*The index of the associated border information for fragments which lie
313 : partially outside the displayable region.
314 : For fragments completely inside or outside this region, this is -1.
315 : Note that the C standard requires an explicit signed keyword for bitfield
316 : types, since some compilers may treat them as unsigned without it.*/
317 : signed int borderi:5;
318 : /*The prediction-corrected DC component.
319 : Note that the C standard requires an explicit signed keyword for bitfield
320 : types, since some compilers may treat them as unsigned without it.*/
321 : signed int dc:16;
322 : };
323 :
324 :
325 :
326 : /*A description of each fragment plane.*/
327 : struct oc_fragment_plane{
328 : /*The number of fragments in the horizontal direction.*/
329 : int nhfrags;
330 : /*The number of fragments in the vertical direction.*/
331 : int nvfrags;
332 : /*The offset of the first fragment in the plane.*/
333 : ptrdiff_t froffset;
334 : /*The total number of fragments in the plane.*/
335 : ptrdiff_t nfrags;
336 : /*The number of super blocks in the horizontal direction.*/
337 : unsigned nhsbs;
338 : /*The number of super blocks in the vertical direction.*/
339 : unsigned nvsbs;
340 : /*The offset of the first super block in the plane.*/
341 : unsigned sboffset;
342 : /*The total number of super blocks in the plane.*/
343 : unsigned nsbs;
344 : };
345 :
346 :
347 : typedef void (*oc_state_loop_filter_frag_rows_func)(
348 : const oc_theora_state *_state,signed char _bv[256],int _refi,int _pli,
349 : int _fragy0,int _fragy_end);
350 :
351 : /*The shared (encoder and decoder) functions that have accelerated variants.*/
352 : struct oc_base_opt_vtable{
353 : void (*frag_copy)(unsigned char *_dst,
354 : const unsigned char *_src,int _ystride);
355 : void (*frag_copy_list)(unsigned char *_dst_frame,
356 : const unsigned char *_src_frame,int _ystride,
357 : const ptrdiff_t *_fragis,ptrdiff_t _nfragis,const ptrdiff_t *_frag_buf_offs);
358 : void (*frag_recon_intra)(unsigned char *_dst,int _ystride,
359 : const ogg_int16_t _residue[64]);
360 : void (*frag_recon_inter)(unsigned char *_dst,
361 : const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]);
362 : void (*frag_recon_inter2)(unsigned char *_dst,const unsigned char *_src1,
363 : const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]);
364 : void (*idct8x8)(ogg_int16_t _y[64],ogg_int16_t _x[64],int _last_zzi);
365 : void (*state_frag_recon)(const oc_theora_state *_state,ptrdiff_t _fragi,
366 : int _pli,ogg_int16_t _dct_coeffs[128],int _last_zzi,ogg_uint16_t _dc_quant);
367 : void (*loop_filter_init)(signed char _bv[256],int _flimit);
368 : oc_state_loop_filter_frag_rows_func state_loop_filter_frag_rows;
369 : void (*restore_fpu)(void);
370 : };
371 :
372 : /*The shared (encoder and decoder) tables that vary according to which variants
373 : of the above functions are used.*/
374 : struct oc_base_opt_data{
375 : const unsigned char *dct_fzig_zag;
376 : };
377 :
378 :
379 : /*State information common to both the encoder and decoder.*/
380 : struct oc_theora_state{
381 : /*The stream information.*/
382 : th_info info;
383 : # if defined(OC_STATE_USE_VTABLE)
384 : /*Table for shared accelerated functions.*/
385 : oc_base_opt_vtable opt_vtable;
386 : # endif
387 : /*Table for shared data used by accelerated functions.*/
388 : oc_base_opt_data opt_data;
389 : /*CPU flags to detect the presence of extended instruction sets.*/
390 : ogg_uint32_t cpu_flags;
391 : /*The fragment plane descriptions.*/
392 : oc_fragment_plane fplanes[3];
393 : /*The list of fragments, indexed in image order.*/
394 : oc_fragment *frags;
395 : /*The the offset into the reference frame buffer to the upper-left pixel of
396 : each fragment.*/
397 : ptrdiff_t *frag_buf_offs;
398 : /*The motion vector for each fragment.*/
399 : oc_mv *frag_mvs;
400 : /*The total number of fragments in a single frame.*/
401 : ptrdiff_t nfrags;
402 : /*The list of super block maps, indexed in image order.*/
403 : oc_sb_map *sb_maps;
404 : /*The list of super block flags, indexed in image order.*/
405 : oc_sb_flags *sb_flags;
406 : /*The total number of super blocks in a single frame.*/
407 : unsigned nsbs;
408 : /*The fragments from each color plane that belong to each macro block.
409 : Fragments are stored in image order (left to right then top to bottom).
410 : When chroma components are decimated, the extra fragments have an index of
411 : -1.*/
412 : oc_mb_map *mb_maps;
413 : /*The list of macro block modes.
414 : A negative number indicates the macro block lies entirely outside the
415 : coded frame.*/
416 : signed char *mb_modes;
417 : /*The number of macro blocks in the X direction.*/
418 : unsigned nhmbs;
419 : /*The number of macro blocks in the Y direction.*/
420 : unsigned nvmbs;
421 : /*The total number of macro blocks.*/
422 : size_t nmbs;
423 : /*The list of coded fragments, in coded order.
424 : Uncoded fragments are stored in reverse order from the end of the list.*/
425 : ptrdiff_t *coded_fragis;
426 : /*The number of coded fragments in each plane.*/
427 : ptrdiff_t ncoded_fragis[3];
428 : /*The total number of coded fragments.*/
429 : ptrdiff_t ntotal_coded_fragis;
430 : /*The actual buffers used for the reference frames.*/
431 : th_ycbcr_buffer ref_frame_bufs[6];
432 : /*The index of the buffers being used for each OC_FRAME_* reference frame.*/
433 : int ref_frame_idx[6];
434 : /*The storage for the reference frame buffers.
435 : This is just ref_frame_bufs[ref_frame_idx[i]][0].data, but is cached here
436 : for faster look-up.*/
437 : unsigned char *ref_frame_data[6];
438 : /*The handle used to allocate the reference frame buffers.*/
439 : unsigned char *ref_frame_handle;
440 : /*The strides for each plane in the reference frames.*/
441 : int ref_ystride[3];
442 : /*The number of unique border patterns.*/
443 : int nborders;
444 : /*The unique border patterns for all border fragments.
445 : The borderi field of fragments which straddle the border indexes this
446 : list.*/
447 : oc_border_info borders[16];
448 : /*The frame number of the last keyframe.*/
449 : ogg_int64_t keyframe_num;
450 : /*The frame number of the current frame.*/
451 : ogg_int64_t curframe_num;
452 : /*The granpos of the current frame.*/
453 : ogg_int64_t granpos;
454 : /*The type of the current frame.*/
455 : signed char frame_type;
456 : /*The bias to add to the frame count when computing granule positions.*/
457 : unsigned char granpos_bias;
458 : /*The number of quality indices used in the current frame.*/
459 : unsigned char nqis;
460 : /*The quality indices of the current frame.*/
461 : unsigned char qis[3];
462 : /*The dequantization tables, stored in zig-zag order, and indexed by
463 : qi, pli, qti, and zzi.*/
464 : ogg_uint16_t *dequant_tables[64][3][2];
465 0 : OC_ALIGN16(oc_quant_table dequant_table_data[64][3][2]);
466 : /*Loop filter strength parameters.*/
467 : unsigned char loop_filter_limits[64];
468 : };
469 :
470 :
471 :
472 : /*The function type used to fill in the chroma plane motion vectors for a
473 : macro block when 4 different motion vectors are specified in the luma
474 : plane.
475 : _cbmvs: The chroma block-level motion vectors to fill in.
476 : _lmbmv: The luma macro-block level motion vector to fill in for use in
477 : prediction.
478 : _lbmvs: The luma block-level motion vectors.*/
479 : typedef void (*oc_set_chroma_mvs_func)(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]);
480 :
481 :
482 :
483 : /*A table of functions used to fill in the Cb,Cr plane motion vectors for a
484 : macro block when 4 different motion vectors are specified in the luma
485 : plane.*/
486 : extern const oc_set_chroma_mvs_func OC_SET_CHROMA_MVS_TABLE[TH_PF_NFORMATS];
487 :
488 :
489 :
490 : int oc_state_init(oc_theora_state *_state,const th_info *_info,int _nrefs);
491 : void oc_state_clear(oc_theora_state *_state);
492 : void oc_state_accel_init_c(oc_theora_state *_state);
493 : void oc_state_borders_fill_rows(oc_theora_state *_state,int _refi,int _pli,
494 : int _y0,int _yend);
495 : void oc_state_borders_fill_caps(oc_theora_state *_state,int _refi,int _pli);
496 : void oc_state_borders_fill(oc_theora_state *_state,int _refi);
497 : void oc_state_fill_buffer_ptrs(oc_theora_state *_state,int _buf_idx,
498 : th_ycbcr_buffer _img);
499 : int oc_state_mbi_for_pos(oc_theora_state *_state,int _mbx,int _mby);
500 : int oc_state_get_mv_offsets(const oc_theora_state *_state,int _offsets[2],
501 : int _pli,oc_mv _mv);
502 :
503 : void oc_loop_filter_init_c(signed char _bv[256],int _flimit);
504 : void oc_state_loop_filter(oc_theora_state *_state,int _frame);
505 : # if defined(OC_DUMP_IMAGES)
506 : int oc_state_dump_frame(const oc_theora_state *_state,int _frame,
507 : const char *_suf);
508 : # endif
509 :
510 : /*Default pure-C implementations of shared accelerated functions.*/
511 : void oc_frag_copy_c(unsigned char *_dst,
512 : const unsigned char *_src,int _src_ystride);
513 : void oc_frag_copy_list_c(unsigned char *_dst_frame,
514 : const unsigned char *_src_frame,int _ystride,
515 : const ptrdiff_t *_fragis,ptrdiff_t _nfragis,const ptrdiff_t *_frag_buf_offs);
516 : void oc_frag_recon_intra_c(unsigned char *_dst,int _dst_ystride,
517 : const ogg_int16_t _residue[64]);
518 : void oc_frag_recon_inter_c(unsigned char *_dst,
519 : const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]);
520 : void oc_frag_recon_inter2_c(unsigned char *_dst,const unsigned char *_src1,
521 : const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]);
522 : void oc_idct8x8_c(ogg_int16_t _y[64],ogg_int16_t _x[64],int _last_zzi);
523 : void oc_state_frag_recon_c(const oc_theora_state *_state,ptrdiff_t _fragi,
524 : int _pli,ogg_int16_t _dct_coeffs[128],int _last_zzi,ogg_uint16_t _dc_quant);
525 : void oc_state_loop_filter_frag_rows_c(const oc_theora_state *_state,
526 : signed char _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end);
527 : void oc_restore_fpu_c(void);
528 :
529 : /*We need a way to call a few encoder functions without introducing a link-time
530 : dependency into the decoder, while still allowing the old alpha API which
531 : does not distinguish between encoder and decoder objects to be used.
532 : We do this by placing a function table at the start of the encoder object
533 : which can dispatch into the encoder library.
534 : We do a similar thing for the decoder in case we ever decide to split off a
535 : common base library.*/
536 : typedef void (*oc_state_clear_func)(theora_state *_th);
537 : typedef int (*oc_state_control_func)(theora_state *th,int _req,
538 : void *_buf,size_t _buf_sz);
539 : typedef ogg_int64_t (*oc_state_granule_frame_func)(theora_state *_th,
540 : ogg_int64_t _granulepos);
541 : typedef double (*oc_state_granule_time_func)(theora_state *_th,
542 : ogg_int64_t _granulepos);
543 :
544 :
545 : struct oc_state_dispatch_vtable{
546 : oc_state_clear_func clear;
547 : oc_state_control_func control;
548 : oc_state_granule_frame_func granule_frame;
549 : oc_state_granule_time_func granule_time;
550 : };
551 :
552 : #endif
|