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$
15 
16  ********************************************************************/
17 
18 #include <limits.h>
19 #if !defined(_decint_H)
20 # define _decint_H (1)
21 # include "theora/theoradec.h"
22 # include "internal.h"
23 # include "bitpack.h"
24 
25 typedef struct th_setup_info oc_setup_info;
26 typedef struct th_dec_ctx    oc_dec_ctx;
27 
28 # include "huffdec.h"
29 # include "dequant.h"
30 
31 /*Constants for the packet-in state machine specific to the decoder.*/
32 
33 /*Next packet to read: Data packet.*/
34 #define OC_PACKET_DATA (0)
35 
36 
37 
38 struct th_setup_info{
39   /*The Huffman codes.*/
40   oc_huff_node      *huff_tables[TH_NHUFFMAN_TABLES];
41   /*The quantization parameters.*/
42   th_quant_info  qinfo;
43 };
44 
45 
46 
47 struct th_dec_ctx{
48   /*Shared encoder/decoder state.*/
49   oc_theora_state      state;
50   /*Whether or not packets are ready to be emitted.
51     This takes on negative values while there are remaining header packets to
52      be emitted, reaches 0 when the codec is ready for input, and goes to 1
53      when a frame has been processed and a data packet is ready.*/
54   int                  packet_state;
55   /*Buffer in which to assemble packets.*/
56   oc_pack_buf          opb;
57   /*Huffman decode trees.*/
58   oc_huff_node        *huff_tables[TH_NHUFFMAN_TABLES];
59   /*The index of the first token in each plane for each coefficient.*/
60   ptrdiff_t            ti0[3][64];
61   /*The number of outstanding EOB runs at the start of each coefficient in each
62      plane.*/
63   ptrdiff_t            eob_runs[3][64];
64   /*The DCT token lists.*/
65   unsigned char       *dct_tokens;
66   /*The extra bits associated with DCT tokens.*/
67   unsigned char       *extra_bits;
68   /*The number of dct tokens unpacked so far.*/
69   int                  dct_tokens_count;
70   /*The out-of-loop post-processing level.*/
71   int                  pp_level;
72   /*The DC scale used for out-of-loop deblocking.*/
73   int                  pp_dc_scale[64];
74   /*The sharpen modifier used for out-of-loop deringing.*/
75   int                  pp_sharp_mod[64];
76   /*The DC quantization index of each block.*/
77   unsigned char       *dc_qis;
78   /*The variance of each block.*/
79   int                 *variances;
80   /*The storage for the post-processed frame buffer.*/
81   unsigned char       *pp_frame_data;
82   /*Whether or not the post-processsed frame buffer has space for chroma.*/
83   int                  pp_frame_state;
84   /*The buffer used for the post-processed frame.
85     Note that this is _not_ guaranteed to have the same strides and offsets as
86      the reference frame buffers.*/
87   th_ycbcr_buffer      pp_frame_buf;
88   /*The striped decode callback function.*/
89   th_stripe_callback   stripe_cb;
90 # if defined(HAVE_CAIRO)
91   /*Output metrics for debugging.*/
92   int                  telemetry;
93   int                  telemetry_mbmode;
94   int                  telemetry_mv;
95   int                  telemetry_qi;
96   int                  telemetry_bits;
97   int                  telemetry_frame_bytes;
98   int                  telemetry_coding_bytes;
99   int                  telemetry_mode_bytes;
100   int                  telemetry_mv_bytes;
101   int                  telemetry_qi_bytes;
102   int                  telemetry_dc_bytes;
103   unsigned char       *telemetry_frame_data;
104 # endif
105 };
106 
107 #endif
108