1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libtheora/lib/state.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,552 @@ 1.4 +/******************************************************************** 1.5 + * * 1.6 + * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * 1.7 + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 1.8 + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 1.9 + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 1.10 + * * 1.11 + * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * 1.12 + * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * 1.13 + * * 1.14 + ******************************************************************** 1.15 + 1.16 + function: 1.17 + last mod: $Id: internal.h 17337 2010-07-19 16:08:54Z tterribe $ 1.18 + 1.19 + ********************************************************************/ 1.20 +#if !defined(_state_H) 1.21 +# define _state_H (1) 1.22 +# include "internal.h" 1.23 +# include "huffman.h" 1.24 +# include "quant.h" 1.25 + 1.26 + 1.27 + 1.28 +/*A single quadrant of the map from a super block to fragment numbers.*/ 1.29 +typedef ptrdiff_t oc_sb_map_quad[4]; 1.30 +/*A map from a super block to fragment numbers.*/ 1.31 +typedef oc_sb_map_quad oc_sb_map[4]; 1.32 +/*A single plane of the map from a macro block to fragment numbers.*/ 1.33 +typedef ptrdiff_t oc_mb_map_plane[4]; 1.34 +/*A map from a macro block to fragment numbers.*/ 1.35 +typedef oc_mb_map_plane oc_mb_map[3]; 1.36 +/*A motion vector.*/ 1.37 +typedef ogg_int16_t oc_mv; 1.38 + 1.39 +typedef struct oc_sb_flags oc_sb_flags; 1.40 +typedef struct oc_border_info oc_border_info; 1.41 +typedef struct oc_fragment oc_fragment; 1.42 +typedef struct oc_fragment_plane oc_fragment_plane; 1.43 +typedef struct oc_base_opt_vtable oc_base_opt_vtable; 1.44 +typedef struct oc_base_opt_data oc_base_opt_data; 1.45 +typedef struct oc_state_dispatch_vtable oc_state_dispatch_vtable; 1.46 +typedef struct oc_theora_state oc_theora_state; 1.47 + 1.48 + 1.49 + 1.50 +/*Shared accelerated functions.*/ 1.51 +# if defined(OC_X86_ASM) 1.52 +# if defined(_MSC_VER) 1.53 +# include "x86_vc/x86int.h" 1.54 +# else 1.55 +# include "x86/x86int.h" 1.56 +# endif 1.57 +# endif 1.58 +# if defined(OC_ARM_ASM) 1.59 +# include "arm/armint.h" 1.60 +# endif 1.61 +# if defined(OC_C64X_ASM) 1.62 +# include "c64x/c64xint.h" 1.63 +# endif 1.64 + 1.65 +# if !defined(oc_state_accel_init) 1.66 +# define oc_state_accel_init oc_state_accel_init_c 1.67 +# endif 1.68 +# if defined(OC_STATE_USE_VTABLE) 1.69 +# if !defined(oc_frag_copy) 1.70 +# define oc_frag_copy(_state,_dst,_src,_ystride) \ 1.71 + ((*(_state)->opt_vtable.frag_copy)(_dst,_src,_ystride)) 1.72 +# endif 1.73 +# if !defined(oc_frag_copy_list) 1.74 +# define oc_frag_copy_list(_state,_dst_frame,_src_frame,_ystride, \ 1.75 + _fragis,_nfragis,_frag_buf_offs) \ 1.76 + ((*(_state)->opt_vtable.frag_copy_list)(_dst_frame,_src_frame,_ystride, \ 1.77 + _fragis,_nfragis,_frag_buf_offs)) 1.78 +# endif 1.79 +# if !defined(oc_frag_recon_intra) 1.80 +# define oc_frag_recon_intra(_state,_dst,_dst_ystride,_residue) \ 1.81 + ((*(_state)->opt_vtable.frag_recon_intra)(_dst,_dst_ystride,_residue)) 1.82 +# endif 1.83 +# if !defined(oc_frag_recon_inter) 1.84 +# define oc_frag_recon_inter(_state,_dst,_src,_ystride,_residue) \ 1.85 + ((*(_state)->opt_vtable.frag_recon_inter)(_dst,_src,_ystride,_residue)) 1.86 +# endif 1.87 +# if !defined(oc_frag_recon_inter2) 1.88 +# define oc_frag_recon_inter2(_state,_dst,_src1,_src2,_ystride,_residue) \ 1.89 + ((*(_state)->opt_vtable.frag_recon_inter2)(_dst, \ 1.90 + _src1,_src2,_ystride,_residue)) 1.91 +# endif 1.92 +# if !defined(oc_idct8x8) 1.93 +# define oc_idct8x8(_state,_y,_x,_last_zzi) \ 1.94 + ((*(_state)->opt_vtable.idct8x8)(_y,_x,_last_zzi)) 1.95 +# endif 1.96 +# if !defined(oc_state_frag_recon) 1.97 +# define oc_state_frag_recon(_state,_fragi, \ 1.98 + _pli,_dct_coeffs,_last_zzi,_dc_quant) \ 1.99 + ((*(_state)->opt_vtable.state_frag_recon)(_state,_fragi, \ 1.100 + _pli,_dct_coeffs,_last_zzi,_dc_quant)) 1.101 +# endif 1.102 +# if !defined(oc_loop_filter_init) 1.103 +# define oc_loop_filter_init(_state,_bv,_flimit) \ 1.104 + ((*(_state)->opt_vtable.loop_filter_init)(_bv,_flimit)) 1.105 +# endif 1.106 +# if !defined(oc_state_loop_filter_frag_rows) 1.107 +# define oc_state_loop_filter_frag_rows(_state, \ 1.108 + _bv,_refi,_pli,_fragy0,_fragy_end) \ 1.109 + ((*(_state)->opt_vtable.state_loop_filter_frag_rows)(_state, \ 1.110 + _bv,_refi,_pli,_fragy0,_fragy_end)) 1.111 +# endif 1.112 +# if !defined(oc_restore_fpu) 1.113 +# define oc_restore_fpu(_state) \ 1.114 + ((*(_state)->opt_vtable.restore_fpu)()) 1.115 +# endif 1.116 +# else 1.117 +# if !defined(oc_frag_copy) 1.118 +# define oc_frag_copy(_state,_dst,_src,_ystride) \ 1.119 + oc_frag_copy_c(_dst,_src,_ystride) 1.120 +# endif 1.121 +# if !defined(oc_frag_copy_list) 1.122 +# define oc_frag_copy_list(_state,_dst_frame,_src_frame,_ystride, \ 1.123 + _fragis,_nfragis,_frag_buf_offs) \ 1.124 + oc_frag_copy_list_c(_dst_frame,_src_frame,_ystride, \ 1.125 + _fragis,_nfragis,_frag_buf_offs) 1.126 +# endif 1.127 +# if !defined(oc_frag_recon_intra) 1.128 +# define oc_frag_recon_intra(_state,_dst,_dst_ystride,_residue) \ 1.129 + oc_frag_recon_intra_c(_dst,_dst_ystride,_residue) 1.130 +# endif 1.131 +# if !defined(oc_frag_recon_inter) 1.132 +# define oc_frag_recon_inter(_state,_dst,_src,_ystride,_residue) \ 1.133 + oc_frag_recon_inter_c(_dst,_src,_ystride,_residue) 1.134 +# endif 1.135 +# if !defined(oc_frag_recon_inter2) 1.136 +# define oc_frag_recon_inter2(_state,_dst,_src1,_src2,_ystride,_residue) \ 1.137 + oc_frag_recon_inter2_c(_dst,_src1,_src2,_ystride,_residue) 1.138 +# endif 1.139 +# if !defined(oc_idct8x8) 1.140 +# define oc_idct8x8(_state,_y,_x,_last_zzi) oc_idct8x8_c(_y,_x,_last_zzi) 1.141 +# endif 1.142 +# if !defined(oc_state_frag_recon) 1.143 +# define oc_state_frag_recon oc_state_frag_recon_c 1.144 +# endif 1.145 +# if !defined(oc_loop_filter_init) 1.146 +# define oc_loop_filter_init(_state,_bv,_flimit) \ 1.147 + oc_loop_filter_init_c(_bv,_flimit) 1.148 +# endif 1.149 +# if !defined(oc_state_loop_filter_frag_rows) 1.150 +# define oc_state_loop_filter_frag_rows oc_state_loop_filter_frag_rows_c 1.151 +# endif 1.152 +# if !defined(oc_restore_fpu) 1.153 +# define oc_restore_fpu(_state) do{}while(0) 1.154 +# endif 1.155 +# endif 1.156 + 1.157 + 1.158 + 1.159 +/*A keyframe.*/ 1.160 +# define OC_INTRA_FRAME (0) 1.161 +/*A predicted frame.*/ 1.162 +# define OC_INTER_FRAME (1) 1.163 +/*A frame of unknown type (frame type decision has not yet been made).*/ 1.164 +# define OC_UNKWN_FRAME (-1) 1.165 + 1.166 +/*The amount of padding to add to the reconstructed frame buffers on all 1.167 + sides. 1.168 + This is used to allow unrestricted motion vectors without special casing. 1.169 + This must be a multiple of 2.*/ 1.170 +# define OC_UMV_PADDING (16) 1.171 + 1.172 +/*Frame classification indices.*/ 1.173 +/*The previous golden frame.*/ 1.174 +# define OC_FRAME_GOLD (0) 1.175 +/*The previous frame.*/ 1.176 +# define OC_FRAME_PREV (1) 1.177 +/*The current frame.*/ 1.178 +# define OC_FRAME_SELF (2) 1.179 +/*Used to mark uncoded fragments (for DC prediction).*/ 1.180 +# define OC_FRAME_NONE (3) 1.181 + 1.182 +/*The input or output buffer.*/ 1.183 +# define OC_FRAME_IO (3) 1.184 +/*Uncompressed prev golden frame.*/ 1.185 +# define OC_FRAME_GOLD_ORIG (4) 1.186 +/*Uncompressed previous frame. */ 1.187 +# define OC_FRAME_PREV_ORIG (5) 1.188 + 1.189 +/*Macroblock modes.*/ 1.190 +/*Macro block is invalid: It is never coded.*/ 1.191 +# define OC_MODE_INVALID (-1) 1.192 +/*Encoded difference from the same macro block in the previous frame.*/ 1.193 +# define OC_MODE_INTER_NOMV (0) 1.194 +/*Encoded with no motion compensated prediction.*/ 1.195 +# define OC_MODE_INTRA (1) 1.196 +/*Encoded difference from the previous frame offset by the given motion 1.197 + vector.*/ 1.198 +# define OC_MODE_INTER_MV (2) 1.199 +/*Encoded difference from the previous frame offset by the last coded motion 1.200 + vector.*/ 1.201 +# define OC_MODE_INTER_MV_LAST (3) 1.202 +/*Encoded difference from the previous frame offset by the second to last 1.203 + coded motion vector.*/ 1.204 +# define OC_MODE_INTER_MV_LAST2 (4) 1.205 +/*Encoded difference from the same macro block in the previous golden 1.206 + frame.*/ 1.207 +# define OC_MODE_GOLDEN_NOMV (5) 1.208 +/*Encoded difference from the previous golden frame offset by the given motion 1.209 + vector.*/ 1.210 +# define OC_MODE_GOLDEN_MV (6) 1.211 +/*Encoded difference from the previous frame offset by the individual motion 1.212 + vectors given for each block.*/ 1.213 +# define OC_MODE_INTER_MV_FOUR (7) 1.214 +/*The number of (coded) modes.*/ 1.215 +# define OC_NMODES (8) 1.216 + 1.217 +/*Determines the reference frame used for a given MB mode.*/ 1.218 +# define OC_FRAME_FOR_MODE(_x) \ 1.219 + OC_UNIBBLE_TABLE32(OC_FRAME_PREV,OC_FRAME_SELF,OC_FRAME_PREV,OC_FRAME_PREV, \ 1.220 + OC_FRAME_PREV,OC_FRAME_GOLD,OC_FRAME_GOLD,OC_FRAME_PREV,(_x)) 1.221 + 1.222 +/*Constants for the packet state machine common between encoder and decoder.*/ 1.223 + 1.224 +/*Next packet to emit/read: Codec info header.*/ 1.225 +# define OC_PACKET_INFO_HDR (-3) 1.226 +/*Next packet to emit/read: Comment header.*/ 1.227 +# define OC_PACKET_COMMENT_HDR (-2) 1.228 +/*Next packet to emit/read: Codec setup header.*/ 1.229 +# define OC_PACKET_SETUP_HDR (-1) 1.230 +/*No more packets to emit/read.*/ 1.231 +# define OC_PACKET_DONE (INT_MAX) 1.232 + 1.233 + 1.234 + 1.235 +#define OC_MV(_x,_y) ((oc_mv)((_x)&0xFF|(_y)<<8)) 1.236 +#define OC_MV_X(_mv) ((signed char)(_mv)) 1.237 +#define OC_MV_Y(_mv) ((_mv)>>8) 1.238 +#define OC_MV_ADD(_mv1,_mv2) \ 1.239 + OC_MV(OC_MV_X(_mv1)+OC_MV_X(_mv2), \ 1.240 + OC_MV_Y(_mv1)+OC_MV_Y(_mv2)) 1.241 +#define OC_MV_SUB(_mv1,_mv2) \ 1.242 + OC_MV(OC_MV_X(_mv1)-OC_MV_X(_mv2), \ 1.243 + OC_MV_Y(_mv1)-OC_MV_Y(_mv2)) 1.244 + 1.245 + 1.246 + 1.247 +/*Super blocks are 32x32 segments of pixels in a single color plane indexed 1.248 + in image order. 1.249 + Internally, super blocks are broken up into four quadrants, each of which 1.250 + contains a 2x2 pattern of blocks, each of which is an 8x8 block of pixels. 1.251 + Quadrants, and the blocks within them, are indexed in a special order called 1.252 + a "Hilbert curve" within the super block. 1.253 + 1.254 + In order to differentiate between the Hilbert-curve indexing strategy and 1.255 + the regular image order indexing strategy, blocks indexed in image order 1.256 + are called "fragments". 1.257 + Fragments are indexed in image order, left to right, then bottom to top, 1.258 + from Y' plane to Cb plane to Cr plane. 1.259 + 1.260 + The co-located fragments in all image planes corresponding to the location 1.261 + of a single quadrant of a luma plane super block form a macro block. 1.262 + Thus there is only a single set of macro blocks for all planes, each of which 1.263 + contains between 6 and 12 fragments, depending on the pixel format. 1.264 + Therefore macro block information is kept in a separate set of arrays from 1.265 + super blocks to avoid unused space in the other planes. 1.266 + The lists are indexed in super block order. 1.267 + That is, the macro block corresponding to the macro block mbi in (luma plane) 1.268 + super block sbi is at index (sbi<<2|mbi). 1.269 + Thus the number of macro blocks in each dimension is always twice the number 1.270 + of super blocks, even when only an odd number fall inside the coded frame. 1.271 + These "extra" macro blocks are just an artifact of our internal data layout, 1.272 + and not part of the coded stream; they are flagged with a negative MB mode.*/ 1.273 + 1.274 + 1.275 + 1.276 +/*Super block information.*/ 1.277 +struct oc_sb_flags{ 1.278 + unsigned char coded_fully:1; 1.279 + unsigned char coded_partially:1; 1.280 + unsigned char quad_valid:4; 1.281 +}; 1.282 + 1.283 + 1.284 + 1.285 +/*Information about a fragment which intersects the border of the displayable 1.286 + region. 1.287 + This marks which pixels belong to the displayable region.*/ 1.288 +struct oc_border_info{ 1.289 + /*A bit mask marking which pixels are in the displayable region. 1.290 + Pixel (x,y) corresponds to bit (y<<3|x).*/ 1.291 + ogg_int64_t mask; 1.292 + /*The number of pixels in the displayable region. 1.293 + This is always positive, and always less than 64.*/ 1.294 + int npixels; 1.295 +}; 1.296 + 1.297 + 1.298 + 1.299 +/*Fragment information.*/ 1.300 +struct oc_fragment{ 1.301 + /*A flag indicating whether or not this fragment is coded.*/ 1.302 + unsigned coded:1; 1.303 + /*A flag indicating that this entire fragment lies outside the displayable 1.304 + region of the frame. 1.305 + Note the contrast with an invalid macro block, which is outside the coded 1.306 + frame, not just the displayable one. 1.307 + There are no fragments outside the coded frame by construction.*/ 1.308 + unsigned invalid:1; 1.309 + /*The index of the quality index used for this fragment's AC coefficients.*/ 1.310 + unsigned qii:4; 1.311 + /*The index of the reference frame this fragment is predicted from.*/ 1.312 + unsigned refi:2; 1.313 + /*The mode of the macroblock this fragment belongs to.*/ 1.314 + unsigned mb_mode:3; 1.315 + /*The index of the associated border information for fragments which lie 1.316 + partially outside the displayable region. 1.317 + For fragments completely inside or outside this region, this is -1. 1.318 + Note that the C standard requires an explicit signed keyword for bitfield 1.319 + types, since some compilers may treat them as unsigned without it.*/ 1.320 + signed int borderi:5; 1.321 + /*The prediction-corrected DC component. 1.322 + Note that the C standard requires an explicit signed keyword for bitfield 1.323 + types, since some compilers may treat them as unsigned without it.*/ 1.324 + signed int dc:16; 1.325 +}; 1.326 + 1.327 + 1.328 + 1.329 +/*A description of each fragment plane.*/ 1.330 +struct oc_fragment_plane{ 1.331 + /*The number of fragments in the horizontal direction.*/ 1.332 + int nhfrags; 1.333 + /*The number of fragments in the vertical direction.*/ 1.334 + int nvfrags; 1.335 + /*The offset of the first fragment in the plane.*/ 1.336 + ptrdiff_t froffset; 1.337 + /*The total number of fragments in the plane.*/ 1.338 + ptrdiff_t nfrags; 1.339 + /*The number of super blocks in the horizontal direction.*/ 1.340 + unsigned nhsbs; 1.341 + /*The number of super blocks in the vertical direction.*/ 1.342 + unsigned nvsbs; 1.343 + /*The offset of the first super block in the plane.*/ 1.344 + unsigned sboffset; 1.345 + /*The total number of super blocks in the plane.*/ 1.346 + unsigned nsbs; 1.347 +}; 1.348 + 1.349 + 1.350 +typedef void (*oc_state_loop_filter_frag_rows_func)( 1.351 + const oc_theora_state *_state,signed char _bv[256],int _refi,int _pli, 1.352 + int _fragy0,int _fragy_end); 1.353 + 1.354 +/*The shared (encoder and decoder) functions that have accelerated variants.*/ 1.355 +struct oc_base_opt_vtable{ 1.356 + void (*frag_copy)(unsigned char *_dst, 1.357 + const unsigned char *_src,int _ystride); 1.358 + void (*frag_copy_list)(unsigned char *_dst_frame, 1.359 + const unsigned char *_src_frame,int _ystride, 1.360 + const ptrdiff_t *_fragis,ptrdiff_t _nfragis,const ptrdiff_t *_frag_buf_offs); 1.361 + void (*frag_recon_intra)(unsigned char *_dst,int _ystride, 1.362 + const ogg_int16_t _residue[64]); 1.363 + void (*frag_recon_inter)(unsigned char *_dst, 1.364 + const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]); 1.365 + void (*frag_recon_inter2)(unsigned char *_dst,const unsigned char *_src1, 1.366 + const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]); 1.367 + void (*idct8x8)(ogg_int16_t _y[64],ogg_int16_t _x[64],int _last_zzi); 1.368 + void (*state_frag_recon)(const oc_theora_state *_state,ptrdiff_t _fragi, 1.369 + int _pli,ogg_int16_t _dct_coeffs[128],int _last_zzi,ogg_uint16_t _dc_quant); 1.370 + void (*loop_filter_init)(signed char _bv[256],int _flimit); 1.371 + oc_state_loop_filter_frag_rows_func state_loop_filter_frag_rows; 1.372 + void (*restore_fpu)(void); 1.373 +}; 1.374 + 1.375 +/*The shared (encoder and decoder) tables that vary according to which variants 1.376 + of the above functions are used.*/ 1.377 +struct oc_base_opt_data{ 1.378 + const unsigned char *dct_fzig_zag; 1.379 +}; 1.380 + 1.381 + 1.382 +/*State information common to both the encoder and decoder.*/ 1.383 +struct oc_theora_state{ 1.384 + /*The stream information.*/ 1.385 + th_info info; 1.386 +# if defined(OC_STATE_USE_VTABLE) 1.387 + /*Table for shared accelerated functions.*/ 1.388 + oc_base_opt_vtable opt_vtable; 1.389 +# endif 1.390 + /*Table for shared data used by accelerated functions.*/ 1.391 + oc_base_opt_data opt_data; 1.392 + /*CPU flags to detect the presence of extended instruction sets.*/ 1.393 + ogg_uint32_t cpu_flags; 1.394 + /*The fragment plane descriptions.*/ 1.395 + oc_fragment_plane fplanes[3]; 1.396 + /*The list of fragments, indexed in image order.*/ 1.397 + oc_fragment *frags; 1.398 + /*The the offset into the reference frame buffer to the upper-left pixel of 1.399 + each fragment.*/ 1.400 + ptrdiff_t *frag_buf_offs; 1.401 + /*The motion vector for each fragment.*/ 1.402 + oc_mv *frag_mvs; 1.403 + /*The total number of fragments in a single frame.*/ 1.404 + ptrdiff_t nfrags; 1.405 + /*The list of super block maps, indexed in image order.*/ 1.406 + oc_sb_map *sb_maps; 1.407 + /*The list of super block flags, indexed in image order.*/ 1.408 + oc_sb_flags *sb_flags; 1.409 + /*The total number of super blocks in a single frame.*/ 1.410 + unsigned nsbs; 1.411 + /*The fragments from each color plane that belong to each macro block. 1.412 + Fragments are stored in image order (left to right then top to bottom). 1.413 + When chroma components are decimated, the extra fragments have an index of 1.414 + -1.*/ 1.415 + oc_mb_map *mb_maps; 1.416 + /*The list of macro block modes. 1.417 + A negative number indicates the macro block lies entirely outside the 1.418 + coded frame.*/ 1.419 + signed char *mb_modes; 1.420 + /*The number of macro blocks in the X direction.*/ 1.421 + unsigned nhmbs; 1.422 + /*The number of macro blocks in the Y direction.*/ 1.423 + unsigned nvmbs; 1.424 + /*The total number of macro blocks.*/ 1.425 + size_t nmbs; 1.426 + /*The list of coded fragments, in coded order. 1.427 + Uncoded fragments are stored in reverse order from the end of the list.*/ 1.428 + ptrdiff_t *coded_fragis; 1.429 + /*The number of coded fragments in each plane.*/ 1.430 + ptrdiff_t ncoded_fragis[3]; 1.431 + /*The total number of coded fragments.*/ 1.432 + ptrdiff_t ntotal_coded_fragis; 1.433 + /*The actual buffers used for the reference frames.*/ 1.434 + th_ycbcr_buffer ref_frame_bufs[6]; 1.435 + /*The index of the buffers being used for each OC_FRAME_* reference frame.*/ 1.436 + int ref_frame_idx[6]; 1.437 + /*The storage for the reference frame buffers. 1.438 + This is just ref_frame_bufs[ref_frame_idx[i]][0].data, but is cached here 1.439 + for faster look-up.*/ 1.440 + unsigned char *ref_frame_data[6]; 1.441 + /*The handle used to allocate the reference frame buffers.*/ 1.442 + unsigned char *ref_frame_handle; 1.443 + /*The strides for each plane in the reference frames.*/ 1.444 + int ref_ystride[3]; 1.445 + /*The number of unique border patterns.*/ 1.446 + int nborders; 1.447 + /*The unique border patterns for all border fragments. 1.448 + The borderi field of fragments which straddle the border indexes this 1.449 + list.*/ 1.450 + oc_border_info borders[16]; 1.451 + /*The frame number of the last keyframe.*/ 1.452 + ogg_int64_t keyframe_num; 1.453 + /*The frame number of the current frame.*/ 1.454 + ogg_int64_t curframe_num; 1.455 + /*The granpos of the current frame.*/ 1.456 + ogg_int64_t granpos; 1.457 + /*The type of the current frame.*/ 1.458 + signed char frame_type; 1.459 + /*The bias to add to the frame count when computing granule positions.*/ 1.460 + unsigned char granpos_bias; 1.461 + /*The number of quality indices used in the current frame.*/ 1.462 + unsigned char nqis; 1.463 + /*The quality indices of the current frame.*/ 1.464 + unsigned char qis[3]; 1.465 + /*The dequantization tables, stored in zig-zag order, and indexed by 1.466 + qi, pli, qti, and zzi.*/ 1.467 + ogg_uint16_t *dequant_tables[64][3][2]; 1.468 + OC_ALIGN16(oc_quant_table dequant_table_data[64][3][2]); 1.469 + /*Loop filter strength parameters.*/ 1.470 + unsigned char loop_filter_limits[64]; 1.471 +}; 1.472 + 1.473 + 1.474 + 1.475 +/*The function type used to fill in the chroma plane motion vectors for a 1.476 + macro block when 4 different motion vectors are specified in the luma 1.477 + plane. 1.478 + _cbmvs: The chroma block-level motion vectors to fill in. 1.479 + _lmbmv: The luma macro-block level motion vector to fill in for use in 1.480 + prediction. 1.481 + _lbmvs: The luma block-level motion vectors.*/ 1.482 +typedef void (*oc_set_chroma_mvs_func)(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]); 1.483 + 1.484 + 1.485 + 1.486 +/*A table of functions used to fill in the Cb,Cr plane motion vectors for a 1.487 + macro block when 4 different motion vectors are specified in the luma 1.488 + plane.*/ 1.489 +extern const oc_set_chroma_mvs_func OC_SET_CHROMA_MVS_TABLE[TH_PF_NFORMATS]; 1.490 + 1.491 + 1.492 + 1.493 +int oc_state_init(oc_theora_state *_state,const th_info *_info,int _nrefs); 1.494 +void oc_state_clear(oc_theora_state *_state); 1.495 +void oc_state_accel_init_c(oc_theora_state *_state); 1.496 +void oc_state_borders_fill_rows(oc_theora_state *_state,int _refi,int _pli, 1.497 + int _y0,int _yend); 1.498 +void oc_state_borders_fill_caps(oc_theora_state *_state,int _refi,int _pli); 1.499 +void oc_state_borders_fill(oc_theora_state *_state,int _refi); 1.500 +void oc_state_fill_buffer_ptrs(oc_theora_state *_state,int _buf_idx, 1.501 + th_ycbcr_buffer _img); 1.502 +int oc_state_mbi_for_pos(oc_theora_state *_state,int _mbx,int _mby); 1.503 +int oc_state_get_mv_offsets(const oc_theora_state *_state,int _offsets[2], 1.504 + int _pli,oc_mv _mv); 1.505 + 1.506 +void oc_loop_filter_init_c(signed char _bv[256],int _flimit); 1.507 +void oc_state_loop_filter(oc_theora_state *_state,int _frame); 1.508 +# if defined(OC_DUMP_IMAGES) 1.509 +int oc_state_dump_frame(const oc_theora_state *_state,int _frame, 1.510 + const char *_suf); 1.511 +# endif 1.512 + 1.513 +/*Default pure-C implementations of shared accelerated functions.*/ 1.514 +void oc_frag_copy_c(unsigned char *_dst, 1.515 + const unsigned char *_src,int _src_ystride); 1.516 +void oc_frag_copy_list_c(unsigned char *_dst_frame, 1.517 + const unsigned char *_src_frame,int _ystride, 1.518 + const ptrdiff_t *_fragis,ptrdiff_t _nfragis,const ptrdiff_t *_frag_buf_offs); 1.519 +void oc_frag_recon_intra_c(unsigned char *_dst,int _dst_ystride, 1.520 + const ogg_int16_t _residue[64]); 1.521 +void oc_frag_recon_inter_c(unsigned char *_dst, 1.522 + const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]); 1.523 +void oc_frag_recon_inter2_c(unsigned char *_dst,const unsigned char *_src1, 1.524 + const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]); 1.525 +void oc_idct8x8_c(ogg_int16_t _y[64],ogg_int16_t _x[64],int _last_zzi); 1.526 +void oc_state_frag_recon_c(const oc_theora_state *_state,ptrdiff_t _fragi, 1.527 + int _pli,ogg_int16_t _dct_coeffs[128],int _last_zzi,ogg_uint16_t _dc_quant); 1.528 +void oc_state_loop_filter_frag_rows_c(const oc_theora_state *_state, 1.529 + signed char _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end); 1.530 +void oc_restore_fpu_c(void); 1.531 + 1.532 +/*We need a way to call a few encoder functions without introducing a link-time 1.533 + dependency into the decoder, while still allowing the old alpha API which 1.534 + does not distinguish between encoder and decoder objects to be used. 1.535 + We do this by placing a function table at the start of the encoder object 1.536 + which can dispatch into the encoder library. 1.537 + We do a similar thing for the decoder in case we ever decide to split off a 1.538 + common base library.*/ 1.539 +typedef void (*oc_state_clear_func)(theora_state *_th); 1.540 +typedef int (*oc_state_control_func)(theora_state *th,int _req, 1.541 + void *_buf,size_t _buf_sz); 1.542 +typedef ogg_int64_t (*oc_state_granule_frame_func)(theora_state *_th, 1.543 + ogg_int64_t _granulepos); 1.544 +typedef double (*oc_state_granule_time_func)(theora_state *_th, 1.545 + ogg_int64_t _granulepos); 1.546 + 1.547 + 1.548 +struct oc_state_dispatch_vtable{ 1.549 + oc_state_clear_func clear; 1.550 + oc_state_control_func control; 1.551 + oc_state_granule_frame_func granule_frame; 1.552 + oc_state_granule_time_func granule_time; 1.553 +}; 1.554 + 1.555 +#endif