2008-07-29 23:38:23 -07:00
|
|
|
/********************************************************************
|
|
|
|
* *
|
|
|
|
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
|
|
|
|
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
|
|
|
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
|
|
|
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
|
|
|
* *
|
2009-09-27 15:14:21 -07:00
|
|
|
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
|
2009-01-21 16:00:49 -08:00
|
|
|
* by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
|
2008-07-29 23:38:23 -07:00
|
|
|
* *
|
|
|
|
********************************************************************
|
|
|
|
|
|
|
|
function:
|
2009-09-27 15:14:21 -07:00
|
|
|
last mod: $Id: decint.h 16503 2009-08-22 18:14:02Z giles $
|
2008-07-29 23:38:23 -07:00
|
|
|
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#if !defined(_decint_H)
|
|
|
|
# define _decint_H (1)
|
|
|
|
# include "theora/theoradec.h"
|
2009-09-27 15:14:21 -07:00
|
|
|
# include "internal.h"
|
2009-01-21 16:00:49 -08:00
|
|
|
# include "bitpack.h"
|
2008-07-29 23:38:23 -07:00
|
|
|
|
|
|
|
typedef struct th_setup_info oc_setup_info;
|
|
|
|
typedef struct th_dec_ctx oc_dec_ctx;
|
|
|
|
|
|
|
|
# include "huffdec.h"
|
|
|
|
# include "dequant.h"
|
|
|
|
|
|
|
|
/*Constants for the packet-in state machine specific to the decoder.*/
|
|
|
|
|
|
|
|
/*Next packet to read: Data packet.*/
|
|
|
|
#define OC_PACKET_DATA (0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct th_setup_info{
|
|
|
|
/*The Huffman codes.*/
|
|
|
|
oc_huff_node *huff_tables[TH_NHUFFMAN_TABLES];
|
|
|
|
/*The quantization parameters.*/
|
|
|
|
th_quant_info qinfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct th_dec_ctx{
|
|
|
|
/*Shared encoder/decoder state.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
oc_theora_state state;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*Whether or not packets are ready to be emitted.
|
|
|
|
This takes on negative values while there are remaining header packets to
|
|
|
|
be emitted, reaches 0 when the codec is ready for input, and goes to 1
|
|
|
|
when a frame has been processed and a data packet is ready.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
int packet_state;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*Buffer in which to assemble packets.*/
|
2009-09-27 15:14:21 -07:00
|
|
|
oc_pack_buf opb;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*Huffman decode trees.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
oc_huff_node *huff_tables[TH_NHUFFMAN_TABLES];
|
2009-09-27 15:14:21 -07:00
|
|
|
/*The index of the first token in each plane for each coefficient.*/
|
|
|
|
ptrdiff_t ti0[3][64];
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The number of outstanding EOB runs at the start of each coefficient in each
|
|
|
|
plane.*/
|
2009-09-27 15:14:21 -07:00
|
|
|
ptrdiff_t eob_runs[3][64];
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The DCT token lists.*/
|
2009-09-27 15:14:21 -07:00
|
|
|
unsigned char *dct_tokens;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The extra bits associated with DCT tokens.*/
|
2009-09-27 15:14:21 -07:00
|
|
|
unsigned char *extra_bits;
|
|
|
|
/*The number of dct tokens unpacked so far.*/
|
|
|
|
int dct_tokens_count;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The out-of-loop post-processing level.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
int pp_level;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The DC scale used for out-of-loop deblocking.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
int pp_dc_scale[64];
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The sharpen modifier used for out-of-loop deringing.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
int pp_sharp_mod[64];
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The DC quantization index of each block.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
unsigned char *dc_qis;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The variance of each block.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
int *variances;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*The storage for the post-processed frame buffer.*/
|
2009-01-21 16:00:49 -08:00
|
|
|
unsigned char *pp_frame_data;
|
2008-07-29 23:38:23 -07:00
|
|
|
/*Whether or not the post-processsed frame buffer has space for chroma.*/
|
2009-09-27 15:14:21 -07:00
|
|
|
int pp_frame_state;
|
|
|
|
/*The buffer used for the post-processed frame.
|
|
|
|
Note that this is _not_ guaranteed to have the same strides and offsets as
|
|
|
|
the reference frame buffers.*/
|
2008-07-29 23:38:23 -07:00
|
|
|
th_ycbcr_buffer pp_frame_buf;
|
|
|
|
/*The striped decode callback function.*/
|
|
|
|
th_stripe_callback stripe_cb;
|
2009-09-27 15:14:21 -07:00
|
|
|
# if defined(HAVE_CAIRO)
|
|
|
|
/*Output metrics for debugging.*/
|
|
|
|
int telemetry;
|
|
|
|
int telemetry_mbmode;
|
|
|
|
int telemetry_mv;
|
|
|
|
int telemetry_qi;
|
|
|
|
int telemetry_bits;
|
|
|
|
int telemetry_frame_bytes;
|
|
|
|
int telemetry_coding_bytes;
|
|
|
|
int telemetry_mode_bytes;
|
|
|
|
int telemetry_mv_bytes;
|
|
|
|
int telemetry_qi_bytes;
|
|
|
|
int telemetry_dc_bytes;
|
|
|
|
unsigned char *telemetry_frame_data;
|
|
|
|
# endif
|
2008-07-29 23:38:23 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|