media/libtheora/lib/decint.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libtheora/lib/decint.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,186 @@
     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: decint.h 17457 2010-09-24 02:05:49Z tterribe $
    1.18 +
    1.19 + ********************************************************************/
    1.20 +
    1.21 +#include <limits.h>
    1.22 +#if !defined(_decint_H)
    1.23 +# define _decint_H (1)
    1.24 +# include "theora/theoradec.h"
    1.25 +# include "state.h"
    1.26 +# include "bitpack.h"
    1.27 +# include "huffdec.h"
    1.28 +# include "dequant.h"
    1.29 +
    1.30 +typedef struct th_setup_info         oc_setup_info;
    1.31 +typedef struct oc_dec_opt_vtable     oc_dec_opt_vtable;
    1.32 +typedef struct oc_dec_pipeline_state oc_dec_pipeline_state;
    1.33 +typedef struct th_dec_ctx            oc_dec_ctx;
    1.34 +
    1.35 +
    1.36 +
    1.37 +/*Decoder-specific accelerated functions.*/
    1.38 +# if defined(OC_C64X_ASM)
    1.39 +#  include "c64x/c64xdec.h"
    1.40 +# endif
    1.41 +
    1.42 +# if !defined(oc_dec_accel_init)
    1.43 +#  define oc_dec_accel_init oc_dec_accel_init_c
    1.44 +# endif
    1.45 +# if defined(OC_DEC_USE_VTABLE)
    1.46 +#  if !defined(oc_dec_dc_unpredict_mcu_plane)
    1.47 +#   define oc_dec_dc_unpredict_mcu_plane(_dec,_pipe,_pli) \
    1.48 + ((*(_dec)->opt_vtable.dc_unpredict_mcu_plane)(_dec,_pipe,_pli))
    1.49 +#  endif
    1.50 +# else
    1.51 +#  if !defined(oc_dec_dc_unpredict_mcu_plane)
    1.52 +#   define oc_dec_dc_unpredict_mcu_plane oc_dec_dc_unpredict_mcu_plane_c
    1.53 +#  endif
    1.54 +# endif
    1.55 +
    1.56 +
    1.57 +
    1.58 +/*Constants for the packet-in state machine specific to the decoder.*/
    1.59 +
    1.60 +/*Next packet to read: Data packet.*/
    1.61 +#define OC_PACKET_DATA (0)
    1.62 +
    1.63 +
    1.64 +
    1.65 +struct th_setup_info{
    1.66 +  /*The Huffman codes.*/
    1.67 +  ogg_int16_t   *huff_tables[TH_NHUFFMAN_TABLES];
    1.68 +  /*The quantization parameters.*/
    1.69 +  th_quant_info  qinfo;
    1.70 +};
    1.71 +
    1.72 +
    1.73 +
    1.74 +/*Decoder specific functions with accelerated variants.*/
    1.75 +struct oc_dec_opt_vtable{
    1.76 +  void (*dc_unpredict_mcu_plane)(oc_dec_ctx *_dec,
    1.77 +   oc_dec_pipeline_state *_pipe,int _pli);
    1.78 +};
    1.79 +
    1.80 +
    1.81 +
    1.82 +struct oc_dec_pipeline_state{
    1.83 +  /*Decoded DCT coefficients.
    1.84 +    These are placed here instead of on the stack so that they can persist
    1.85 +     between blocks, which makes clearing them back to zero much faster when
    1.86 +     only a few non-zero coefficients were decoded.
    1.87 +    It requires at least 65 elements because the zig-zag index array uses the
    1.88 +     65th element as a dumping ground for out-of-range indices to protect us
    1.89 +     from buffer overflow.
    1.90 +    We make it fully twice as large so that the second half can serve as the
    1.91 +     reconstruction buffer, which saves passing another parameter to all the
    1.92 +     acceleration functios.
    1.93 +    It also solves problems with 16-byte alignment for NEON on ARM.
    1.94 +    gcc (as of 4.2.1) only seems to be able to give stack variables 8-byte
    1.95 +     alignment, and silently produces incorrect results if you ask for 16.
    1.96 +    Finally, keeping it off the stack means there's less likely to be a data
    1.97 +     hazard beween the NEON co-processor and the regular ARM core, which avoids
    1.98 +     unnecessary stalls.*/
    1.99 +  OC_ALIGN16(ogg_int16_t dct_coeffs[128]);
   1.100 +  OC_ALIGN16(signed char bounding_values[256]);
   1.101 +  ptrdiff_t           ti[3][64];
   1.102 +  ptrdiff_t           ebi[3][64];
   1.103 +  ptrdiff_t           eob_runs[3][64];
   1.104 +  const ptrdiff_t    *coded_fragis[3];
   1.105 +  const ptrdiff_t    *uncoded_fragis[3];
   1.106 +  ptrdiff_t           ncoded_fragis[3];
   1.107 +  ptrdiff_t           nuncoded_fragis[3];
   1.108 +  const ogg_uint16_t *dequant[3][3][2];
   1.109 +  int                 fragy0[3];
   1.110 +  int                 fragy_end[3];
   1.111 +  int                 pred_last[3][4];
   1.112 +  int                 mcu_nvfrags;
   1.113 +  int                 loop_filter;
   1.114 +  int                 pp_level;
   1.115 +};
   1.116 +
   1.117 +
   1.118 +struct th_dec_ctx{
   1.119 +  /*Shared encoder/decoder state.*/
   1.120 +  oc_theora_state        state;
   1.121 +  /*Whether or not packets are ready to be emitted.
   1.122 +    This takes on negative values while there are remaining header packets to
   1.123 +     be emitted, reaches 0 when the codec is ready for input, and goes to 1
   1.124 +     when a frame has been processed and a data packet is ready.*/
   1.125 +  int                    packet_state;
   1.126 +  /*Buffer in which to assemble packets.*/
   1.127 +  oc_pack_buf            opb;
   1.128 +  /*Huffman decode trees.*/
   1.129 +  ogg_int16_t           *huff_tables[TH_NHUFFMAN_TABLES];
   1.130 +  /*The index of the first token in each plane for each coefficient.*/
   1.131 +  ptrdiff_t              ti0[3][64];
   1.132 +  /*The number of outstanding EOB runs at the start of each coefficient in each
   1.133 +     plane.*/
   1.134 +  ptrdiff_t              eob_runs[3][64];
   1.135 +  /*The DCT token lists.*/
   1.136 +  unsigned char         *dct_tokens;
   1.137 +  /*The extra bits associated with DCT tokens.*/
   1.138 +  unsigned char         *extra_bits;
   1.139 +  /*The number of dct tokens unpacked so far.*/
   1.140 +  int                    dct_tokens_count;
   1.141 +  /*The out-of-loop post-processing level.*/
   1.142 +  int                    pp_level;
   1.143 +  /*The DC scale used for out-of-loop deblocking.*/
   1.144 +  int                    pp_dc_scale[64];
   1.145 +  /*The sharpen modifier used for out-of-loop deringing.*/
   1.146 +  int                    pp_sharp_mod[64];
   1.147 +  /*The DC quantization index of each block.*/
   1.148 +  unsigned char         *dc_qis;
   1.149 +  /*The variance of each block.*/
   1.150 +  int                   *variances;
   1.151 +  /*The storage for the post-processed frame buffer.*/
   1.152 +  unsigned char         *pp_frame_data;
   1.153 +  /*Whether or not the post-processsed frame buffer has space for chroma.*/
   1.154 +  int                    pp_frame_state;
   1.155 +  /*The buffer used for the post-processed frame.
   1.156 +    Note that this is _not_ guaranteed to have the same strides and offsets as
   1.157 +     the reference frame buffers.*/
   1.158 +  th_ycbcr_buffer        pp_frame_buf;
   1.159 +  /*The striped decode callback function.*/
   1.160 +  th_stripe_callback     stripe_cb;
   1.161 +  oc_dec_pipeline_state  pipe;
   1.162 +# if defined(OC_DEC_USE_VTABLE)
   1.163 +  /*Table for decoder acceleration functions.*/
   1.164 +  oc_dec_opt_vtable      opt_vtable;
   1.165 +# endif
   1.166 +# if defined(HAVE_CAIRO)
   1.167 +  /*Output metrics for debugging.*/
   1.168 +  int                    telemetry;
   1.169 +  int                    telemetry_mbmode;
   1.170 +  int                    telemetry_mv;
   1.171 +  int                    telemetry_qi;
   1.172 +  int                    telemetry_bits;
   1.173 +  int                    telemetry_frame_bytes;
   1.174 +  int                    telemetry_coding_bytes;
   1.175 +  int                    telemetry_mode_bytes;
   1.176 +  int                    telemetry_mv_bytes;
   1.177 +  int                    telemetry_qi_bytes;
   1.178 +  int                    telemetry_dc_bytes;
   1.179 +  unsigned char         *telemetry_frame_data;
   1.180 +# endif
   1.181 +};
   1.182 +
   1.183 +/*Default pure-C implementations of decoder-specific accelerated functions.*/
   1.184 +void oc_dec_accel_init_c(oc_dec_ctx *_dec);
   1.185 +
   1.186 +void oc_dec_dc_unpredict_mcu_plane_c(oc_dec_ctx *_dec,
   1.187 + oc_dec_pipeline_state *_pipe,int _pli);
   1.188 +
   1.189 +#endif

mercurial