aboutsummaryrefslogtreecommitdiff
path: root/Src/h264dec/ldecod/inc
diff options
context:
space:
mode:
Diffstat (limited to 'Src/h264dec/ldecod/inc')
-rw-r--r--Src/h264dec/ldecod/inc/biaridecod.h157
-rw-r--r--Src/h264dec/ldecod/inc/block.h133
-rw-r--r--Src/h264dec/ldecod/inc/cabac.h64
-rw-r--r--Src/h264dec/ldecod/inc/context_ini.h23
-rw-r--r--Src/h264dec/ldecod/inc/contributors.h223
-rw-r--r--Src/h264dec/ldecod/inc/defines.h273
-rw-r--r--Src/h264dec/ldecod/inc/elements.h112
-rw-r--r--Src/h264dec/ldecod/inc/erc_api.h159
-rw-r--r--Src/h264dec/ldecod/inc/erc_do.h44
-rw-r--r--Src/h264dec/ldecod/inc/erc_globals.h52
-rw-r--r--Src/h264dec/ldecod/inc/errorconcealment.h20
-rw-r--r--Src/h264dec/ldecod/inc/fmo.h30
-rw-r--r--Src/h264dec/ldecod/inc/global.h1230
-rw-r--r--Src/h264dec/ldecod/inc/header.h22
-rw-r--r--Src/h264dec/ldecod/inc/image.h33
-rw-r--r--Src/h264dec/ldecod/inc/intra16x16_pred.h25
-rw-r--r--Src/h264dec/ldecod/inc/intra4x4_pred.h25
-rw-r--r--Src/h264dec/ldecod/inc/intra8x8_pred.h25
-rw-r--r--Src/h264dec/ldecod/inc/leaky_bucket.h26
-rw-r--r--Src/h264dec/ldecod/inc/loopfilter.h23
-rw-r--r--Src/h264dec/ldecod/inc/macroblock.h177
-rw-r--r--Src/h264dec/ldecod/inc/mb_prediction.h33
-rw-r--r--Src/h264dec/ldecod/inc/mbuffer.h235
-rw-r--r--Src/h264dec/ldecod/inc/mc_prediction.h61
-rw-r--r--Src/h264dec/ldecod/inc/meminput.h26
-rw-r--r--Src/h264dec/ldecod/inc/nalu.h28
-rw-r--r--Src/h264dec/ldecod/inc/optim.h46
-rw-r--r--Src/h264dec/ldecod/inc/output.h27
-rw-r--r--Src/h264dec/ldecod/inc/parset.h56
-rw-r--r--Src/h264dec/ldecod/inc/parsetcommon.h202
-rw-r--r--Src/h264dec/ldecod/inc/quant.h169
-rw-r--r--Src/h264dec/ldecod/inc/sei.h100
-rw-r--r--Src/h264dec/ldecod/inc/transform8x8.h24
-rw-r--r--Src/h264dec/ldecod/inc/vlc.h122
34 files changed, 4005 insertions, 0 deletions
diff --git a/Src/h264dec/ldecod/inc/biaridecod.h b/Src/h264dec/ldecod/inc/biaridecod.h
new file mode 100644
index 00000000..9364632b
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/biaridecod.h
@@ -0,0 +1,157 @@
+
+/*!
+ ***************************************************************************
+ * \file
+ * biaridecod.h
+ *
+ * \brief
+ * Headerfile for binary arithmetic decoder routines
+ *
+ * \author
+ * Detlev Marpe,
+ * Gabi Blättermann
+ * Copyright (C) 2000 HEINRICH HERTZ INSTITUTE All Rights Reserved.
+ *
+ * \date
+ * 21. Oct 2000
+ **************************************************************************
+ */
+
+#ifndef _BIARIDECOD_H_
+#define _BIARIDECOD_H_
+
+
+/************************************************************************
+ * D e f i n i t i o n s
+ ***********************************************************************
+ */
+
+/* Range table for LPS */
+/*
+static const byte rLPS_table_64x4[64][4]=
+{
+ { 128, 176, 208, 240},
+ { 128, 167, 197, 227},
+ { 128, 158, 187, 216},
+ { 123, 150, 178, 205},
+ { 116, 142, 169, 195},
+ { 111, 135, 160, 185},
+ { 105, 128, 152, 175},
+ { 100, 122, 144, 166},
+ { 95, 116, 137, 158},
+ { 90, 110, 130, 150},
+ { 85, 104, 123, 142},
+ { 81, 99, 117, 135},
+ { 77, 94, 111, 128},
+ { 73, 89, 105, 122},
+ { 69, 85, 100, 116},
+ { 66, 80, 95, 110},
+ { 62, 76, 90, 104},
+ { 59, 72, 86, 99},
+ { 56, 69, 81, 94},
+ { 53, 65, 77, 89},
+ { 51, 62, 73, 85},
+ { 48, 59, 69, 80},
+ { 46, 56, 66, 76},
+ { 43, 53, 63, 72},
+ { 41, 50, 59, 69},
+ { 39, 48, 56, 65},
+ { 37, 45, 54, 62},
+ { 35, 43, 51, 59},
+ { 33, 41, 48, 56},
+ { 32, 39, 46, 53},
+ { 30, 37, 43, 50},
+ { 29, 35, 41, 48},
+ { 27, 33, 39, 45},
+ { 26, 31, 37, 43},
+ { 24, 30, 35, 41},
+ { 23, 28, 33, 39},
+ { 22, 27, 32, 37},
+ { 21, 26, 30, 35},
+ { 20, 24, 29, 33},
+ { 19, 23, 27, 31},
+ { 18, 22, 26, 30},
+ { 17, 21, 25, 28},
+ { 16, 20, 23, 27},
+ { 15, 19, 22, 25},
+ { 14, 18, 21, 24},
+ { 14, 17, 20, 23},
+ { 13, 16, 19, 22},
+ { 12, 15, 18, 21},
+ { 12, 14, 17, 20},
+ { 11, 14, 16, 19},
+ { 11, 13, 15, 18},
+ { 10, 12, 15, 17},
+ { 10, 12, 14, 16},
+ { 9, 11, 13, 15},
+ { 9, 11, 12, 14},
+ { 8, 10, 12, 14},
+ { 8, 9, 11, 13},
+ { 7, 9, 11, 12},
+ { 7, 9, 10, 12},
+ { 7, 8, 10, 11},
+ { 6, 8, 9, 11},
+ { 6, 7, 9, 10},
+ { 6, 7, 8, 9},
+ { 2, 2, 2, 2}
+};*/
+static const byte rLPS_table_64x4[4][64]={
+{128, 128, 128, 123, 116, 111, 105, 100, 95, 90, 85, 81, 77, 73, 69, 66,
+ 62, 59, 56, 53, 51, 48, 46, 43, 41, 39, 37, 35, 33, 32, 30, 29,
+ 27, 26, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 14, 13, 12,
+ 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 7, 6, 6, 6, 2,
+ },
+{176, 167, 158, 150, 142, 135, 128, 122, 116, 110, 104, 99, 94, 89, 85, 80,
+ 76, 72, 69, 65, 62, 59, 56, 53, 50, 48, 45, 43, 41, 39, 37, 35,
+ 33, 31, 30, 28, 27, 26, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
+ 14, 14, 13, 12, 12, 11, 11, 10, 9, 9, 9, 8, 8, 7, 7, 2,
+ },
+{208, 197, 187, 178, 169, 160, 152, 144, 137, 130, 123, 117, 111, 105, 100, 95,
+ 90, 86, 81, 77, 73, 69, 66, 63, 59, 56, 54, 51, 48, 46, 43, 41,
+ 39, 37, 35, 33, 32, 30, 29, 27, 26, 25, 23, 22, 21, 20, 19, 18,
+ 17, 16, 15, 15, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 2,
+ },
+{240, 227, 216, 205, 195, 185, 175, 166, 158, 150, 142, 135, 128, 122, 116, 110,
+ 104, 99, 94, 89, 85, 80, 76, 72, 69, 65, 62, 59, 56, 53, 50, 48,
+ 45, 43, 41, 39, 37, 35, 33, 31, 30, 28, 27, 25, 24, 23, 22, 21,
+ 20, 19, 18, 17, 16, 15, 14, 14, 13, 12, 12, 11, 11, 10, 9, 2,
+}};
+
+// make uint16 to match biari_decode_symbol
+static const byte AC_next_state_MPS_64[64] =
+{
+ 1,2,3,4,5,6,7,8,9,10,
+ 11,12,13,14,15,16,17,18,19,20,
+ 21,22,23,24,25,26,27,28,29,30,
+ 31,32,33,34,35,36,37,38,39,40,
+ 41,42,43,44,45,46,47,48,49,50,
+ 51,52,53,54,55,56,57,58,59,60,
+ 61,62,62,63
+};
+
+// make uint16 to match biari_decode_symbol
+static const byte AC_next_state_LPS_64[64] =
+{
+ 0, 0, 1, 2, 2, 4, 4, 5, 6, 7,
+ 8, 9, 9,11,11,12,13,13,15,15,
+ 16,16,18,18,19,19,21,21,22,22,
+ 23,24,24,25,26,26,27,27,28,29,
+ 29,30,30,30,31,32,32,33,33,33,
+ 34,34,35,35,35,36,36,36,37,37,
+ 37,38,38,63
+};
+
+static const byte renorm_table_32[32]={6,5,4,4,3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+static const byte renorm_table_256[256]={6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
+
+extern void arideco_start_decoding(DecodingEnvironmentPtr eep, unsigned char *code_buffer, int firstbyte, int *code_len);
+//extern int arideco_bits_read(const DecodingEnvironmentPtr dep);
+extern void arideco_done_decoding(DecodingEnvironmentPtr dep);
+extern void biari_init_context (int qp, BiContextTypePtr ctx, const char* ini);
+extern unsigned int biari_decode_symbol(DecodingEnvironmentPtr dep, BiContextTypePtr bi_ct );
+extern unsigned int biari_decode_symbol_eq_prob(DecodingEnvironmentPtr dep);
+extern unsigned int biari_decode_final(DecodingEnvironmentPtr dep);
+extern unsigned int getbyte(DecodingEnvironmentPtr dep);
+extern unsigned int getword(DecodingEnvironmentPtr dep);
+#endif // BIARIDECOD_H_
+
diff --git a/Src/h264dec/ldecod/inc/block.h b/Src/h264dec/ldecod/inc/block.h
new file mode 100644
index 00000000..d819b13c
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/block.h
@@ -0,0 +1,133 @@
+
+/*!
+ ************************************************************************
+ * \file block.h
+ *
+ * \brief
+ * definitions for block decoding functions
+ *
+ * \author
+ * Inge Lille-Langoy <inge.lille-langoy@telenor.com> \n
+ * Telenor Satellite Services \n
+ * P.O.Box 6914 St.Olavs plass \n
+ * N-0130 Oslo, Norway
+ *
+ ************************************************************************
+ */
+
+#ifndef _BLOCK_H_
+#define _BLOCK_H_
+
+#include "global.h"
+#include "transform8x8.h"
+
+static const byte QP_SCALE_CR[52]=
+{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,
+ 12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
+ 28,29,29,30,31,32,32,33,34,34,35,35,36,36,37,37,
+ 37,38,38,38,39,39,39,39
+
+};
+
+//! look up tables for FRExt_chroma support
+static const unsigned char subblk_offset_x[3][8][4] =
+{
+ {
+ {0, 4, 0, 4},
+ {0, 4, 0, 4},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ },
+ {
+ {0, 4, 0, 4},
+ {0, 4, 0, 4},
+ {0, 4, 0, 4},
+ {0, 4, 0, 4},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ },
+ {
+ {0, 4, 0, 4},
+ {8,12, 8,12},
+ {0, 4, 0, 4},
+ {8,12, 8,12},
+ {0, 4, 0, 4},
+ {8,12, 8,12},
+ {0, 4, 0, 4},
+ {8,12, 8,12}
+ }
+};
+
+
+static const unsigned char subblk_offset_y[3][8][4] =
+{
+ {
+ {0, 0, 4, 4},
+ {0, 0, 4, 4},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0}
+ },
+ {
+ {0, 0, 4, 4},
+ {8, 8,12,12},
+ {0, 0, 4, 4},
+ {8, 8,12,12},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0}
+ },
+ {
+ {0, 0, 4, 4},
+ {0, 0, 4, 4},
+ {8, 8,12,12},
+ {8, 8,12,12},
+ {0, 0, 4, 4},
+ {0, 0, 4, 4},
+ {8, 8,12,12},
+ {8, 8,12,12}
+ }
+};
+
+static const byte decode_block_scan[16] = {0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15};
+static const int cof4_pos_to_subblock[4][4] = { { 0, 1, 4, 5}, {2,3,6,7}, {8,9,12,13}, {10,11,14,15} };
+
+extern void iMBtrans4x4(Macroblock *currMB, ColorPlane pl, int smb);
+extern void iMBtrans8x8(Macroblock *currMB, ColorPlane pl);
+
+extern void itrans_sp_cr(Macroblock *currMB, int uv);
+
+extern void intrapred_chroma (Macroblock *currMB, int uv);
+
+extern void Inv_Residual_trans_4x4(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
+extern void Inv_Residual_trans_8x8(Macroblock *currMB, ColorPlane pl, int ioff,int joff);
+
+extern void itrans4x4_c(const h264_short_block_t tblock, const h264_imgpel_macroblock_t mb_pred, h264_imgpel_macroblock_t mb_rec, int pos_x, int pos_y);
+extern void itrans4x4_mmx(const h264_short_block_t tblock, const h264_imgpel_macroblock_t mb_pred, h264_imgpel_macroblock_t mb_rec, int pos_x, int pos_y);
+extern int intrapred (Macroblock *currMB, ColorPlane pl, int ioff,int joff,int i4,int j4);
+extern void itrans_2 (Macroblock *currMB, ColorPlane pl);
+extern void iTransform (Macroblock *currMB, ColorPlane pl, int smb);
+
+extern void copy_image_data (imgpel **imgBuf1, imgpel **imgBuf2, int dest_x, int src_x, int width, int height);
+extern void copy_image_data_16x16 (imgpel **imgBuf1, imgpel **imgBuf2, int dest_x, int src_x);
+
+extern void copy_image_data_16x16_stride_c(struct video_image *destination, int dest_x, int dest_y, const h264_imgpel_macroblock_t source);
+extern void copy_image_data_16x16_stride_sse(struct video_image *destination, int dest_x, int dest_y, const h264_imgpel_macroblock_t source);
+extern void copy_image_data_8x8_stride (struct video_image *destination, int dest_x, int dest_y, const h264_imgpel_macroblock_t source);
+extern void copy_image_data_8x8_stride2 (struct video_image *destination, int dest_x, int dest_y, const h264_imgpel_macroblock_t source, int src_x, int src_y);
+extern void copy_image_data_4x4_stride (struct video_image *destination, int dest_x, int dest_y, const h264_imgpel_macroblock_t source, int src_x, int src_y);
+extern void copy_image_data_stride (struct video_image *destination, int dest_x, int dest_y, const h264_imgpel_macroblock_t source, int width, int height);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/cabac.h b/Src/h264dec/ldecod/inc/cabac.h
new file mode 100644
index 00000000..5458d2be
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/cabac.h
@@ -0,0 +1,64 @@
+
+/*!
+ ***************************************************************************
+ * \file
+ * cabac.h
+ *
+ * \brief
+ * Header file for entropy coding routines
+ *
+ * \author
+ * Detlev Marpe \n
+ * Copyright (C) 2000 HEINRICH HERTZ INSTITUTE All Rights Reserved.
+ *
+ * \date
+ * 21. Oct 2000 (Changes by Tobias Oelbaum 28.08.2001)
+ ***************************************************************************
+ */
+
+#ifndef _CABAC_H_
+#define _CABAC_H_
+
+#include "global.h"
+
+typedef struct Run_Level
+{
+ int level;
+ int run;
+} RunLevel;
+extern MotionInfoContexts* create_contexts_MotionInfo(void);
+extern TextureInfoContexts* create_contexts_TextureInfo(void);
+extern void delete_contexts_MotionInfo(MotionInfoContexts *enco_ctx);
+extern void delete_contexts_TextureInfo(TextureInfoContexts *enco_ctx);
+
+extern void cabac_new_slice(Slice *currSlice);
+
+extern int readMB_typeInfo_CABAC(Macroblock *currMB, DecodingEnvironmentPtr dep_dp);
+extern int readB8_typeInfo_CABAC(Slice *currSlice, DecodingEnvironmentPtr dep_dp);
+extern int readIntraPredMode_CABAC(Slice *currSlice, DecodingEnvironmentPtr dep_dp);
+extern char readRefFrame_CABAC(Macroblock *currMB, DecodingEnvironmentPtr dep_dp, int list, int x, int y);
+extern char readRefFrame_CABAC0(Macroblock *currMB, DecodingEnvironmentPtr dep_dp, int list, int y);
+extern int readMVD_CABAC(Macroblock *currMB, DecodingEnvironmentPtr dep_dp, int k, int list, int x, int y);
+extern int readCBP_CABAC (Macroblock *currMB, DecodingEnvironmentPtr dep_dp);
+
+// readRunLevel_CABAC returns level and sets *run
+extern RunLevel readRunLevel_CABAC(Macroblock *currMB, DecodingEnvironmentPtr dep_dp, int context);
+extern short readDquant_CABAC(Slice *currSlice, DecodingEnvironmentPtr dep_dp);
+extern char readCIPredMode_CABAC (Macroblock *currMB, DecodingEnvironmentPtr dep_dp);
+extern int readMB_skip_flagInfo_CABAC (Macroblock *currMB, DecodingEnvironmentPtr dep_dp);
+extern Boolean readFieldModeInfo_CABAC (Macroblock *currMB, DecodingEnvironmentPtr dep_dp);
+extern Boolean readMB_transform_size_flag_CABAC(Macroblock *currMB, DecodingEnvironmentPtr dep_dp);
+
+extern void readIPCM_CABAC(Slice *currSlice, struct datapartition *dP);
+
+extern int cabac_startcode_follows(Slice *currSlice, int eos_bit);
+
+
+extern int check_next_mb_and_get_field_mode_CABAC(Slice *currSlice, DataPartition *act_dp);
+
+extern void CheckAvailabilityOfNeighborsCABAC(Macroblock *currMB);
+
+extern void set_read_and_store_CBP(Macroblock **currMB, int chroma_format_idc);
+
+#endif // _CABAC_H_
+
diff --git a/Src/h264dec/ldecod/inc/context_ini.h b/Src/h264dec/ldecod/inc/context_ini.h
new file mode 100644
index 00000000..73977be6
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/context_ini.h
@@ -0,0 +1,23 @@
+
+/*!
+ *************************************************************************************
+ * \file context_ini.h
+ *
+ * \brief
+ * CABAC context initializations
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Detlev Marpe <marpe@hhi.de>
+ * - Heiko Schwarz <hschwarz@hhi.de>
+ **************************************************************************************
+ */
+
+
+#ifndef _CONTEXT_INI_
+#define _CONTEXT_INI_
+
+extern void init_contexts (Slice *currslice);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/contributors.h b/Src/h264dec/ldecod/inc/contributors.h
new file mode 100644
index 00000000..3e462d0b
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/contributors.h
@@ -0,0 +1,223 @@
+
+/*! \file
+ * contributors.h
+ * \brief
+ * List of contributors and copyright information.
+ *
+ * \par Copyright statements
+ \verbatim
+ H.264 JM coder/decoder
+
+ Copyright (C) 2000 by
+ Telenor Satellite Services, Norway
+ Ericsson Radio Systems, Sweden
+ TELES AG, Germany
+ Nokia Inc., USA
+ Nokia Corporation, Finland
+ Siemens AG, Germany
+ Fraunhofer-Institute for Telecommunications Heinrich-Hertz-Institut (HHI), Germany
+ University of Hannover, Institut of Communication Theory and Signal Processing, Germany
+ TICSP, Tampere University of Technology, Finland
+ Munich University of Technology, Institute for Communications Engineering, Germany
+ Videolocus, Canada
+ Motorola Inc., USA
+ Microsoft Corp., USA
+ Apple Computer, Inc.
+ RealNetworks, Inc., USA
+ Thomson, Inc., USA
+ Sejong Univ., Digital Media System Lab., Korea
+ \endverbatim
+ \par Full Contact Information
+ \verbatim
+
+ Lowell Winger <lwinger@videolocus.com><lwinger@uwaterloo.ca>
+ Guy Côté <gcote@videolocus.com>
+ Michael Gallant <mgallant@videolocus.com>
+ VideoLocus Inc.
+ 97 Randall Dr.
+ Waterloo, ON, Canada N2V1C5
+
+ Inge Lille-Langøy <inge.lille-langoy@telenor.com>
+ Telenor Satellite Services
+ P.O.Box 6914 St.Olavs plass
+ N-0130 Oslo, Norway
+
+ Rickard Sjoberg <rickard.sjoberg@era.ericsson.se>
+ Ericsson Radio Systems
+ KI/ERA/T/VV
+ 164 80 Stockholm, Sweden
+
+ Stephan Wenger <stewe@cs.tu-berlin.de>
+ TU Berlin / TELES AG
+ Sekr. FR 6-3
+ Franklinstr. 28-29
+ D-10587 Berlin, Germany
+
+ Jani Lainema <jani.lainema@nokia.com>
+ Nokia Inc. / Nokia Research Center
+ 6000 Connection Drive
+ Irving, TX 75039, USA
+
+ Sebastian Purreiter <sebastian.purreiter@mch.siemens.de>
+ Siemens AG
+ ICM MD MP RD MCH 83
+ P.O.Box 80 17 07
+ D-81617 Munich, Germany
+
+ Thomas Wedi <wedi@tnt.uni-hannover.de>
+ University of Hannover
+ Institut of Communication Theory and Signal Processing
+ Appelstr. 9a
+ 30167 Hannover, Germany
+
+ Guido Heising
+ Fraunhofer-Institute for Telecommunications
+ Heinrich-Hertz-Institut (HHI)
+ Einsteinufer 37
+ 10587 Berlin
+ Germany
+
+ Gabi Blaettermann
+ Fraunhofer-Institute for Telecommunications
+ Heinrich-Hertz-Institut (HHI)
+ Einsteinufer 37
+ 10587 Berlin
+ Germany
+
+ Detlev Marpe <marpe@hhi.de>
+ Fraunhofer-Institute for Telecommunications
+ Heinrich-Hertz-Institut (HHI)
+ Einsteinufer 37
+ 10587 Berlin
+ Germany
+
+ Ragip Kurceren <ragip.kurceren@nokia.com>
+ Nokia Inc. / Nokia Research Center
+ 6000 Connection Drive
+ Irving, TX 75039, USA
+
+ Viktor Varsa <viktor.varsa@nokia.com>
+ Nokia Inc. / Nokia Research Center
+ 6000 Connection Drive
+ Irving, TX 75039, USA
+
+ Ye-Kui Wang <wyk@ieee.org>
+ Tampere University of Technology
+ Tampere International Center for Signal Processing
+ 33720 Tampere, Finland
+
+ Ari Hourunranta <ari.hourunranta@nokia.com>
+ Nokia Corporation / Nokia Mobile Phones
+ P.O. Box 88
+ 33721 Tampere, Finland
+
+ Yann Le Maguet <yann.lemaguet@philips.com>
+ Philips Research France
+
+ Dong Tian <tian@cs.tut.fi>
+ Tampere University of Technology
+ Tampere International Center for Signal Processing
+ 33720 Tampere, Finland
+
+ Miska M. Hannuksela <miska.hannuksela@nokia.com>
+ Nokia Corporation / Nokia Mobile Phones
+ P.O. Box 88
+ 33721 Tampere, Finland
+
+ Karsten Suehring <suehring@hhi.de>
+ Fraunhofer-Institute for Telecommunications
+ Heinrich-Hertz-Institut (HHI)
+ Einsteinufer 37
+ 10587 Berlin
+ Germany
+
+ Heiko Schwarz <hschwarz@hhi.de>
+ Fraunhofer-Institute for Telecommunications
+ Heinrich-Hertz-Institut (HHI)
+ Einsteinufer 37
+ 10587 Berlin
+ Germany
+
+ Tobias Oelbaum <drehvial@gmx.net>
+ Institute for Communications Engineering
+ Munich University of Technology
+ Germany
+
+ Limin Wang <liwang@gi.com>
+ Krit Panusopone <kpanusopone@gi.com>
+ Rajeev Gandhi <rgandhi@gi.com>
+ Yue Yu <yyu@gi.com>
+ Motorola Inc.
+ 6450 Sequence Drive
+ San Diego, CA 92121 USA
+
+ Feng Wu <fengwu@microsoft.com>
+ Xiaoyan Sun <sunxiaoyan@msrchina.research.microsoft.com>
+ Microsoft Research Asia
+ 3/F, Beijing Sigma Center
+ No.49, Zhichun Road, Hai Dian District,
+ Beijing China 100080
+
+ Yoshihiro Kikuchi <yoshihiro.kikuchi@toshiba.co.jp>
+ Takeshi Chujoh <takeshi.chujoh@toshiba.co.jp>
+ Toshiba Corporation
+ Research and Development Center
+ Kawasaki 212-8582, Japan
+
+ Shinya Kadono <kadono@drl.mei.co.jp>
+ Matsushita Electric Industrial Co., Ltd.
+ 1006 Kadoma, Kadoma
+ Osaka 663-8113, Japan
+
+ Dzung Hoang <dthoang@yahoo.com>
+ 10533 Roy Butler Dr.
+ Austin, TX 78717
+
+ Eric Viscito <eric@ev-consulting.com>
+ eV Consulting
+ 52 Tracy Ln
+ Shelburne, VT 05482 USA
+
+ Barry Haskell
+ Apple Computer, Inc. <bhaskell@apple.com>
+ 2 Infinite Loop
+ Cupertino, California 95014
+
+ Greg Conklin
+ RealNetworks, Inc. <gregc@real.com>
+ 2601 Elliott Ave
+ Seattle, WA 98101
+
+ Jill Boyce <jill.boyce@thomson.net>
+ Cristina Gomila <cristina.gomila@thomson.net>
+ Thomson
+ 2 Independence Way
+ Princeton, NJ 08540
+
+ Alexis Michael Tourapis <alexismt@ieee.org><atour@dolby.com>
+ Athanasios Leontaris <aleon@dolby.com>
+ Dolby Laboratories Inc.
+ 3601 West Alameda Ave.
+ Burbank, CA 91505
+
+ Saurav K Bandyopadhyay <saurav@ieee.org>
+ Purvin Pandit <Purvin.Pandit@thomson.net>
+ Zhenyu Wu <Zhenyu.Wu@thomson.net>
+ Thomson Inc.
+ 2 Independence Way
+ Princeton, NJ 08540
+
+ Shun-ichi Sekiguchi <Sekiguchi.Shunichi@eb.MitsubishiElectric.co.jp>
+ Information Technology R&D Center,
+ Mitsubishi Electric Corporation
+ 5-1-1, Ofuna, Kamakura, Japan
+
+ Yung-Lyul Lee <yllee@sejong.ac.kr>
+ Ki-Hun Han <khhan@dms.sejong.ac.kr>
+ Department of Computer Engineering,
+ Sejong University
+ 98 Kunja-Dong, Kwangjin-Gu, Seoul 143-747, Korea
+
+ \endverbatim
+*/
+
diff --git a/Src/h264dec/ldecod/inc/defines.h b/Src/h264dec/ldecod/inc/defines.h
new file mode 100644
index 00000000..edc50563
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/defines.h
@@ -0,0 +1,273 @@
+
+/*!
+ **************************************************************************
+ * \file defines.h
+ *
+ * \brief
+ * Header file containing some useful global definitions
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Detlev Marpe
+ * - Karsten Sühring <suehring@hhi.de>
+ * - Alexis Michael Tourapis <alexismt@ieee.org>
+ *
+ *
+ * \date
+ * 21. March 2001
+ **************************************************************************
+ */
+
+
+#ifndef H264_DEFINES_H_
+#define H264_DEFINES_H_
+#pragma once
+
+#if defined _DEBUG
+# define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
+#else
+# define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
+#endif
+
+#define JM "16.1 (FRExt)"
+#define VERSION "16.1"
+#define EXT_VERSION "(FRExt)"
+
+#define DUMP_DPB 0 //!< Dump DPB info for debug purposes
+#define PAIR_FIELDS_IN_OUTPUT 0 //!< Pair field pictures for output purposes
+#define IMGTYPE 0 //!< Define imgpel size type. 0 implies byte (cannot handle >8 bit depths) and 1 implies unsigned short
+#define ENABLE_FIELD_CTX 1 //!< Enables Field mode related context types for CABAC
+#define ENABLE_HIGH444_CTX 1 //!< Enables High 444 profile context types for CABAC.
+#define ZEROSNR 0 //!< PSNR computation method
+#define ENABLE_OUTPUT_TONEMAPPING 1 //!< enable tone map the output if tone mapping SEI present
+
+
+#include "typedefs.h"
+
+
+#define H264_MEMORY_ALIGNMENT 32
+
+//#define MAX_NUM_SLICES 150
+#define MAX_NUM_SLICES 50
+#define MAX_REFERENCE_PICTURES 32 //!< H.264 allows 32 fields
+#define MAX_CODED_FRAME_SIZE 8000000 //!< bytes for one frame
+
+//AVC Profile IDC definitions
+#define BASELINE 66 //!< YUV 4:2:0/8 "Baseline"
+#define MAIN 77 //!< YUV 4:2:0/8 "Main"
+#define EXTENDED 88 //!< YUV 4:2:0/8 "Extended"
+#define FREXT_HP 100 //!< YUV 4:2:0/8 "High"
+#define FREXT_Hi10P 110 //!< YUV 4:2:0/10 "High 10"
+#define FREXT_Hi422 122 //!< YUV 4:2:2/10 "High 4:2:2"
+#define FREXT_Hi444 244 //!< YUV 4:4:4/14 "High 4:4:4"
+#define FREXT_CAVLC444 44 //!< YUV 4:4:4/14 "CAVLC 4:4:4"
+
+
+#define FILE_NAME_SIZE 255
+#define INPUT_TEXT_SIZE 1024
+
+#if (ENABLE_HIGH444_CTX == 1)
+# define NUM_BLOCK_TYPES 22
+#else
+# define NUM_BLOCK_TYPES 10
+#endif
+
+
+//#define _LEAKYBUCKET_
+
+#define BLOCK_SHIFT 2
+#define BLOCK_SIZE 4
+#define BLOCK_SIZE_8x8 8
+#define SMB_BLOCK_SIZE 8
+#define BLOCK_PIXELS 16
+#define MB_BLOCK_SIZE 16
+#define MB_PIXELS 256 // MB_BLOCK_SIZE * MB_BLOCK_SIZE
+#define MB_PIXELS_SHIFT 8 // log2(MB_BLOCK_SIZE * MB_BLOCK_SIZE)
+#define MB_BLOCK_SHIFT 4
+#define BLOCK_MULTIPLE 4 // (MB_BLOCK_SIZE/BLOCK_SIZE)
+#define MB_BLOCK_PARTITIONS 16 // (BLOCK_MULTIPLE * BLOCK_MULTIPLE)
+#define BLOCK_CONTEXT 64 // (4 * MB_BLOCK_PARTITIONS)
+
+// These variables relate to the subpel accuracy supported by the software (1/4)
+#define BLOCK_SIZE_SP 16 // BLOCK_SIZE << 2
+#define BLOCK_SIZE_8x8_SP 32 // BLOCK_SIZE8x8 << 2
+
+// Available MB modes
+enum {
+ PSKIP = 0,
+ BSKIP_DIRECT = 0,
+ P16x16 = 1,
+ P16x8 = 2,
+ P8x16 = 3,
+ SMB8x8 = 4,
+ SMB8x4 = 5,
+ SMB4x8 = 6,
+ SMB4x4 = 7,
+ P8x8 = 8,
+ I4MB = 9,
+ I16MB = 10,
+ IBLOCK = 11,
+ SI4MB = 12,
+ I8MB = 13,
+ IPCM = 14,
+ MAXMODE = 15
+} ;//MBModeTypes;
+
+// number of intra prediction modes
+#define NO_INTRA_PMODE 9
+
+// Direct Mode types
+enum {
+ DIR_TEMPORAL = 0, //!< Temporal Direct Mode
+ DIR_SPATIAL = 1 //!< Spatial Direct Mode
+} ;//DirectModes;
+
+// CAVLC block types
+enum {
+ LUMA = 0,
+ LUMA_INTRA16x16DC = 1,
+ LUMA_INTRA16x16AC = 2,
+ CB = 3,
+ CB_INTRA16x16DC = 4,
+ CB_INTRA16x16AC = 5,
+ CR = 8,
+ CR_INTRA16x16DC = 9,
+ CR_INTRA16x16AC = 10
+} ;//CAVLCBlockTypes;
+
+// CABAC block types
+enum {
+ LUMA_16DC = 0,
+ LUMA_16AC = 1,
+ LUMA_8x8 = 2,
+ LUMA_8x4 = 3,
+ LUMA_4x8 = 4,
+ LUMA_4x4 = 5,
+ CHROMA_DC = 6,
+ CHROMA_AC = 7,
+ CHROMA_DC_2x4 = 8,
+ CHROMA_DC_4x4 = 9,
+ CB_16DC = 10,
+ CB_16AC = 11,
+ CB_8x8 = 12,
+ CB_8x4 = 13,
+ CB_4x8 = 14,
+ CB_4x4 = 15,
+ CR_16DC = 16,
+ CR_16AC = 17,
+ CR_8x8 = 18,
+ CR_8x4 = 19,
+ CR_4x8 = 20,
+ CR_4x4 = 21
+} ;//CABACBlockTypes;
+
+// Macro defines
+#define Q_BITS 15
+#define DQ_BITS 6
+#define Q_BITS_8 16
+#define DQ_BITS_8 6
+
+//#define IS_INTRA(MB) ((MB)->mb_type==I4MB || (MB)->mb_type==I16MB ||(MB)->mb_type==IPCM || (MB)->mb_type==I8MB || (MB)->mb_type==SI4MB)
+#define IS_INTRA(MB) (!!((1 << (MB)->mb_type) & ((1<<I4MB) | (1<<I16MB) | (1<<IPCM) | (1<<I8MB) | (1<<SI4MB))))
+#define IS_I16MB(MB) ((MB)->mb_type==I16MB || (MB)->mb_type==IPCM)
+
+#define IS_INTER(MB) (!IS_INTRA(MB))
+//#define IS_INTER(MB) ((MB)->mb_type!=SI4MB && (MB)->mb_type!=I4MB && (MB)->mb_type!=I16MB && (MB)->mb_type!=I8MB && (MB)->mb_type!=IPCM)
+#define IS_INTERMV(MB) ((MB)->mb_type!=I4MB && (MB)->mb_type!=I16MB && (MB)->mb_type!=I8MB && (MB)->mb_type!=0 && (MB)->mb_type!=IPCM)
+#define IS_DIRECT(MB) ((MB)->mb_type==0 && (currSlice->slice_type == B_SLICE ))
+#define IS_SKIP(MB) ((MB)->mb_type==0 && (currSlice->slice_type == P_SLICE || currSlice->slice_type == SP_SLICE))
+
+#define TOTRUN_NUM 15
+#define RUNBEFORE_NUM 7
+#define RUNBEFORE_NUM_M1 6
+
+// Quantization parameter range
+#define MIN_QP 0
+#define MAX_QP 51
+// 4x4 intra prediction modes
+enum {
+ VERT_PRED = 0,
+ HOR_PRED = 1,
+ DC_PRED = 2,
+ DIAG_DOWN_LEFT_PRED = 3,
+ DIAG_DOWN_RIGHT_PRED = 4,
+ VERT_RIGHT_PRED = 5,
+ HOR_DOWN_PRED = 6,
+ VERT_LEFT_PRED = 7,
+ HOR_UP_PRED = 8
+} ;//I4x4PredModes;
+
+// 16x16 intra prediction modes
+enum {
+ VERT_PRED_16 = 0,
+ HOR_PRED_16 = 1,
+ DC_PRED_16 = 2,
+ PLANE_16 = 3
+} ;//I16x16PredModes;
+
+// 8x8 chroma intra prediction modes
+enum {
+ DC_PRED_8 = 0,
+ HOR_PRED_8 = 1,
+ VERT_PRED_8 = 2,
+ PLANE_8 = 3
+} ;//I8x8PredModes;
+
+enum {
+ EOS = 1, //!< End Of Sequence
+ SOP = 2, //!< Start Of Picture
+ SOS = 3 //!< Start Of Slice
+};
+
+// MV Prediction types
+enum {
+ MVPRED_MEDIAN = 0,
+ MVPRED_L = 1,
+ MVPRED_U = 2,
+ MVPRED_UR = 3
+} ;//MVPredTypes;
+
+enum {
+ DECODING_OK = 0,
+ SEARCH_SYNC = 1,
+ PICTURE_DECODED = 2
+};
+
+#define LAMBDA_ACCURACY_BITS 16
+#define INVALIDINDEX (-135792468)
+
+#define RC_MAX_TEMPORAL_LEVELS 5
+
+//Start code and Emulation Prevention need this to be defined in identical manner at encoder and decoder
+#define ZEROBYTES_SHORTSTARTCODE 2 //indicates the number of zero bytes in the short start-code prefix
+
+#define MAX_PLANE 3
+#define IS_INDEPENDENT(IMG) ((IMG)->separate_colour_plane_flag)
+#define IS_FREXT_PROFILE(profile_idc) ( profile_idc>=FREXT_HP || profile_idc == FREXT_CAVLC444 )
+#define HI_INTRA_ONLY_PROFILE (((p_Vid->active_sps->profile_idc>=FREXT_Hi10P)&&(p_Vid->active_sps->constrained_set3_flag))||(p_Vid->active_sps->profile_idc==FREXT_CAVLC444))
+
+enum
+{
+ VUI_AR_UNDEFINED = 0,
+ VUI_AR_SQUARE = 1, // 1:1
+ VUI_AR_12_11 = 2, // 12:11
+ VUI_AR_10_11 = 3, // 10:11
+ VUI_AR_16_11 = 4, // 16:11
+ VUI_AR_40_33 = 5, // 40:33
+ VUI_AR_24_11 = 6, // 24:11
+ VUI_AR_20_11 = 7, // 20:11
+ VUI_AR_32_11 = 8, // 32:11
+ VUI_AR_80_33 = 9, // 80:33
+ VUI_AR_18_11 = 10, // 18:11
+ VUI_AR_15_11 = 11, // 15:11
+ VUI_AR_64_33 = 12, // 64:33
+VUI_AR_160_99 = 13, // 160:99
+VUI_AR_4_3 = 14, // 4:3
+VUI_AR_3_2 = 15, // 3:2
+VUI_AR_2_1 = 16, // 2:1
+
+
+ VUI_EXTENDED_SAR = 255,
+};
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/elements.h b/Src/h264dec/ldecod/inc/elements.h
new file mode 100644
index 00000000..f115bff6
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/elements.h
@@ -0,0 +1,112 @@
+
+/*!
+ *************************************************************************************
+ * \file elements.h
+ *
+ * \brief
+ * Header file for elements in H.264 streams
+ *
+ * \date
+ * 6.10.2000
+ *
+ * \version
+ * 1.0
+ *
+ * \author
+ * Sebastian Purreiter <sebastian.purreiter@mch.siemens.de> \n
+ * Siemens AG, Information and Communication Mobile \n
+ * P.O.Box 80 17 07 \n
+ * D-81617 Munich, Germany \n
+ *************************************************************************************
+ */
+
+#ifndef _ELEMENTS_H_
+#define _ELEMENTS_H_
+
+/*!
+ * definition of H.264 syntax elements
+ * order of elements follow dependencies for picture reconstruction
+ */
+/*!
+ * \brief Assignment of old TYPE partition elements to new
+ * elements
+ *
+ * old element | new elements
+ * ----------------+-------------------------------------------------------------------
+ * TYPE_HEADER | SE_HEADER, SE_PTYPE
+ * TYPE_MBHEADER | SE_MBTYPE, SE_REFFRAME, SE_INTRAPREDMODE
+ * TYPE_MVD | SE_MVD
+ * TYPE_CBP | SE_CBP_INTRA, SE_CBP_INTER
+ * SE_DELTA_QUANT_INTER
+ * SE_DELTA_QUANT_INTRA
+ * TYPE_COEFF_Y | SE_LUM_DC_INTRA, SE_LUM_AC_INTRA, SE_LUM_DC_INTER, SE_LUM_AC_INTER
+ * TYPE_2x2DC | SE_CHR_DC_INTRA, SE_CHR_DC_INTER
+ * TYPE_COEFF_C | SE_CHR_AC_INTRA, SE_CHR_AC_INTER
+ * TYPE_EOS | SE_EOS
+*/
+
+#define SE_HEADER 0
+#define SE_PTYPE 1
+#define SE_MBTYPE 2
+#define SE_REFFRAME 3
+#define SE_INTRAPREDMODE 4
+#define SE_MVD 5
+#define SE_CBP_INTRA 6
+#define SE_LUM_DC_INTRA 7
+#define SE_CHR_DC_INTRA 8
+#define SE_LUM_AC_INTRA 9
+#define SE_CHR_AC_INTRA 10
+#define SE_CBP_INTER 11
+#define SE_LUM_DC_INTER 12
+#define SE_CHR_DC_INTER 13
+#define SE_LUM_AC_INTER 14
+#define SE_CHR_AC_INTER 15
+#define SE_DELTA_QUANT_INTER 16
+#define SE_DELTA_QUANT_INTRA 17
+#define SE_BFRAME 18
+#define SE_EOS 19
+#define SE_MAX_ELEMENTS 20
+
+
+#define NO_EC 0 //!< no error concealment necessary
+#define EC_REQ 1 //!< error concealment required
+#define EC_SYNC 2 //!< search and sync on next header element
+
+#define MAXPARTITIONMODES 2 //!< maximum possible partition modes as defined in assignSE2partition[][]
+
+/*!
+ * \brief lookup-table to assign different elements to partition
+ *
+ * \note here we defined up to 6 different partitions similar to
+ * document Q15-k-18 described in the PROGFRAMEMODE.
+ * The Sliceheader contains the PSYNC information. \par
+ *
+ * Elements inside a partition are not ordered. They are
+ * ordered by occurence in the stream.
+ * Assumption: Only partitionlosses are considered. \par
+ *
+ * The texture elements luminance and chrominance are
+ * not ordered in the progressive form
+ * This may be changed in image.c \par
+ *
+ * We also defined the proposed internet partition mode
+ * of Stephan Wenger here. To select the desired mode
+ * uncomment one of the two following lines. \par
+ *
+ * -IMPORTANT:
+ * Picture- or Sliceheaders must be assigned to partition 0. \par
+ * Furthermore partitions must follow syntax dependencies as
+ * outlined in document Q15-J-23.
+ */
+
+
+static const byte assignSE2partition[][SE_MAX_ELEMENTS] =
+{
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // element number (do not uncomment)
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, //!< all elements in one partition no data partitioning
+ { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0 } //!< three partitions per slice
+};
+
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/erc_api.h b/Src/h264dec/ldecod/inc/erc_api.h
new file mode 100644
index 00000000..428c4ed3
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/erc_api.h
@@ -0,0 +1,159 @@
+
+/*!
+ ************************************************************************
+ * \file erc_api.h
+ *
+ * \brief
+ * External (still inside video decoder) interface for error concealment module
+ *
+ * \author
+ * - Ari Hourunranta <ari.hourunranta@nokia.com>
+ * - Ye-Kui Wang <wyk@ieee.org>
+ * - Jill Boyce <jill.boyce@thomson.net>
+ * - Saurav K Bandyopadhyay <saurav@ieee.org>
+ * - Zhenyu Wu <Zhenyu.Wu@thomson.net
+ * - Purvin Pandit <Purvin.Pandit@thomson.net>
+ *
+ * ************************************************************************
+ */
+
+
+#ifndef _ERC_API_H_
+#define _ERC_API_H_
+
+#include "erc_globals.h"
+
+/*
+* Defines
+*/
+
+/* If the average motion vector of the correctly received macroblocks is less than the
+threshold, concealByCopy is used, otherwise concealByTrial is used. */
+#define MVPERMB_THR 8
+
+/* used to determine the size of the allocated memory for a temporal Region (MB) */
+#define DEF_REGION_SIZE 384 /* 8*8*6 */
+
+#define ERC_BLOCK_OK 3
+#define ERC_BLOCK_CONCEALED 2
+#define ERC_BLOCK_CORRUPTED 1
+#define ERC_BLOCK_EMPTY 0
+
+
+/*
+* Functions to convert MBNum representation to blockNum
+*/
+
+#define xPosYBlock(currYBlockNum,picSizeX) \
+((currYBlockNum)%((picSizeX)>>3))
+
+#define yPosYBlock(currYBlockNum,picSizeX) \
+((currYBlockNum)/((picSizeX)>>3))
+
+#define xPosMB(currMBNum,picSizeX) \
+((currMBNum)%((picSizeX)>>4))
+
+#define yPosMB(currMBNum,picSizeX) \
+((currMBNum)/((picSizeX)>>4))
+
+#define MBxy2YBlock(currXPos,currYPos,comp,picSizeX) \
+((((currYPos)<<1)+((comp)>>1))*((picSizeX)>>3)+((currXPos)<<1)+((comp)&1))
+
+#define MBNum2YBlock(currMBNum,comp,picSizeX) \
+MBxy2YBlock(xPosMB((currMBNum),(picSizeX)),yPosMB((currMBNum),(picSizeX)),(comp),(picSizeX))
+
+
+/*
+* typedefs
+*/
+
+/* segment data structure */
+typedef struct ercSegment_s
+{
+ int startMBPos;
+ int endMBPos;
+ int fCorrupted;
+} ercSegment_t;
+
+/* Error detector & concealment instance data structure */
+typedef struct ercVariables_s
+{
+ /* Number of macroblocks (size or size/4 of the arrays) */
+ int nOfMBs;
+ /* Number of segments (slices) in frame */
+ int nOfSegments;
+
+ /* Array for conditions of Y blocks */
+ int *yCondition;
+ /* Array for conditions of U blocks */
+ int *uCondition;
+ /* Array for conditions of V blocks */
+ int *vCondition;
+
+ /* Array for Slice level information */
+ ercSegment_t *segments;
+ int currSegment;
+
+ /* Conditions of the MBs of the previous frame */
+ int *prevFrameYCondition;
+
+ /* Flag telling if the current segment was found to be corrupted */
+ int currSegmentCorrupted;
+ /* Counter for corrupted segments per picture */
+ int nOfCorruptedSegments;
+
+ /* State variables for error detector and concealer */
+ int concealment;
+
+} ercVariables_t;
+
+/*
+* External function interface
+*/
+
+void ercInit(VideoParameters *p_Vid, int pic_sizex, int pic_sizey, int flag);
+ercVariables_t *ercOpen( void );
+void ercReset( ercVariables_t *errorVar, int nOfMBs, int numOfSegments, int picSizeX );
+void ercClose( VideoParameters *p_Vid, ercVariables_t *errorVar );
+void ercSetErrorConcealment( ercVariables_t *errorVar, int value );
+
+void ercStartSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar );
+void ercStopSegment( int currMBNum, int segment, unsigned int bitPos, ercVariables_t *errorVar );
+void ercMarkCurrSegmentLost(int picSizeX, ercVariables_t *errorVar );
+void ercMarkCurrSegmentOK(int picSizeX, ercVariables_t *errorVar );
+void ercMarkCurrMBConcealed( int currMBNum, int comp, int picSizeX, ercVariables_t *errorVar );
+
+int ercConcealIntraFrame( VideoParameters *p_Vid, frame *recfr, int picSizeX, int picSizeY, ercVariables_t *errorVar );
+int ercConcealInterFrame( frame *recfr, objectBuffer_t *object_list,
+ int picSizeX, int picSizeY, ercVariables_t *errorVar, int chroma_format_idc );
+
+
+/* Thomson APIs for concealing entire frame loss */
+
+#include "mbuffer.h"
+#include "output.h"
+
+struct concealment_node {
+ StorablePicture* picture;
+ int missingpocs;
+ struct concealment_node *next;
+};
+
+extern struct concealment_node * init_node(StorablePicture* , int );
+extern void print_node( struct concealment_node * );
+extern void print_list( struct concealment_node * );
+extern void init_lists_for_non_reference_loss(VideoParameters *p_Vid, int , PictureStructure );
+
+extern void conceal_non_ref_pics(VideoParameters *p_Vid, int diff);
+extern void conceal_lost_frames(VideoParameters *p_Vid);
+
+extern void sliding_window_poc_management(DecodedPictureBuffer *p_Dpb, StorablePicture *p);
+
+extern void write_lost_non_ref_pic(VideoParameters *p_Vid, int poc);
+extern void write_lost_ref_after_idr(VideoParameters *p_Vid, int pos);
+
+extern int comp(const void *, const void *);
+
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/erc_do.h b/Src/h264dec/ldecod/inc/erc_do.h
new file mode 100644
index 00000000..9879222f
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/erc_do.h
@@ -0,0 +1,44 @@
+
+/*!
+ ************************************************************************
+ * \file erc_do.h
+ *
+ * \brief
+ * Header for the I & P frame error concealment common functions
+ *
+ * \author
+ * - Viktor Varsa <viktor.varsa@nokia.com>
+ * - Ye-Kui Wang <wyk@ieee.org>
+ *
+ ************************************************************************
+ */
+
+#ifndef _ERC_DO_H_
+#define _ERC_DO_H_
+
+
+#include "erc_api.h"
+
+void ercPixConcealIMB (VideoParameters *p_Vid, imgpel *currFrame, int row, int column, int predBlocks[], int frameWidth, int mbWidthInBlocks);
+
+int ercCollect8PredBlocks( int predBlocks[], int currRow, int currColumn, int *condition,
+ int maxRow, int maxColumn, int step, byte fNoCornerNeigh );
+int ercCollectColumnBlocks( int predBlocks[], int currRow, int currColumn, int *condition, int maxRow, int maxColumn, int step );
+
+#define isSplitted(object_list,currMBNum) \
+ ((object_list+((currMBNum)<<2))->regionMode >= REGMODE_SPLITTED)
+
+/* this can be used as isBlock(...,INTRA) or isBlock(...,INTER_COPY) */
+#define isBlock(object_list,currMBNum,comp,regMode) \
+ (isSplitted(object_list,currMBNum) ? \
+ ((object_list+((currMBNum)<<2)+(comp))->regionMode == REGMODE_##regMode##_8x8) : \
+ ((object_list+((currMBNum)<<2))->regionMode == REGMODE_##regMode))
+
+/* this can be used as getParam(...,mv) or getParam(...,xMin) or getParam(...,yMin) */
+#define getParam(object_list,currMBNum,comp,param) \
+ (isSplitted(object_list,currMBNum) ? \
+ ((object_list+((currMBNum)<<2)+(comp))->param) : \
+ ((object_list+((currMBNum)<<2))->param))
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/erc_globals.h b/Src/h264dec/ldecod/inc/erc_globals.h
new file mode 100644
index 00000000..63ba4e2e
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/erc_globals.h
@@ -0,0 +1,52 @@
+
+/*!
+ ************************************************************************
+ * \file erc_globals.h
+ *
+ * \brief
+ * global header file for error concealment module
+ *
+ * \author
+ * - Viktor Varsa <viktor.varsa@nokia.com>
+ * - Ye-Kui Wang <wyk@ieee.org>
+ ************************************************************************
+ */
+
+#ifndef _ERC_GLOBALS_H_
+#define _ERC_GLOBALS_H_
+
+#include "defines.h"
+
+/* "block" means an 8x8 pixel area */
+
+/* Region modes */
+#define REGMODE_INTER_COPY 0 //!< Copy region
+#define REGMODE_INTER_PRED 1 //!< Inter region with motion vectors
+#define REGMODE_INTRA 2 //!< Intra region
+#define REGMODE_SPLITTED 3 //!< Any region mode higher than this indicates that the region
+ //!< is splitted which means 8x8 block
+#define REGMODE_INTER_COPY_8x8 4
+#define REGMODE_INTER_PRED_8x8 5
+#define REGMODE_INTRA_8x8 6
+
+//! YUV pixel domain image arrays for a video frame
+typedef struct frame_s
+{
+ VideoParameters *p_Vid;
+ imgpel *yptr;
+ imgpel *uptr;
+ imgpel *vptr;
+} frame;
+
+//! region structure stores information about a region that is needed for concealment
+typedef struct object_buffer
+{
+ byte regionMode; //!< region mode as above
+ int xMin; //!< X coordinate of the pixel position of the top-left corner of the region
+ int yMin; //!< Y coordinate of the pixel position of the top-left corner of the region
+ short mv[3]; //!< motion vectors in 1/4 pixel units: mvx = mv[0], mvy = mv[1],
+ //!< and ref_frame = mv[2]
+} objectBuffer_t;
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/errorconcealment.h b/Src/h264dec/ldecod/inc/errorconcealment.h
new file mode 100644
index 00000000..36650e25
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/errorconcealment.h
@@ -0,0 +1,20 @@
+
+
+/*!
+ ****************************************************************************
+ * \file errorconcealment.h
+ *
+ * \brief
+ * Header file for errorconcealment.c
+ *
+ ****************************************************************************
+ */
+
+#ifndef _ERRORCONCEALMENT_H_
+#define _ERRORCONCEALMENT_H_
+
+extern int set_ec_flag(VideoParameters *p_Vid, int se);
+extern void reset_ec_flags(VideoParameters *p_Vid);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/fmo.h b/Src/h264dec/ldecod/inc/fmo.h
new file mode 100644
index 00000000..df749bba
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/fmo.h
@@ -0,0 +1,30 @@
+
+/*!
+ ***************************************************************************
+ *
+ * \file fmo.h
+ *
+ * \brief
+ * Support for Flexilble Macroblock Ordering (FMO)
+ *
+ * \date
+ * 19 June, 2002
+ *
+ * \author
+ * Stephan Wenger stewe@cs.tu-berlin.de
+ **************************************************************************/
+
+#ifndef _FMO_H_
+#define _FMO_H_
+
+
+extern int fmo_init (VideoParameters *p_Vid);
+extern int FmoFinit (VideoParameters *p_Vid);
+
+extern int FmoGetNumberOfSliceGroup(VideoParameters *p_Vid);
+extern int FmoGetLastMBOfPicture (VideoParameters *p_Vid);
+extern int FmoGetLastMBInSliceGroup(VideoParameters *p_Vid, int SliceGroup);
+extern int FmoGetSliceGroupId (VideoParameters *p_Vid, int mb);
+extern int FmoGetNextMBNr (VideoParameters *p_Vid, int CurrentMbNr);
+
+#endif
diff --git a/Src/h264dec/ldecod/inc/global.h b/Src/h264dec/ldecod/inc/global.h
new file mode 100644
index 00000000..6d2677e6
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/global.h
@@ -0,0 +1,1230 @@
+
+/*!
+ ************************************************************************
+ * \file
+ * global.h
+ * \brief
+ * global definitions for H.264 decoder.
+ * \author
+ * Copyright (C) 1999 Telenor Satellite Services,Norway
+ * Ericsson Radio Systems, Sweden
+ *
+ * Inge Lille-Langoy <inge.lille-langoy@telenor.com>
+ *
+ * Telenor Satellite Services
+ * Keysers gt.13 tel.: +47 23 13 86 98
+ * N-0130 Oslo,Norway fax.: +47 22 77 79 80
+ *
+ * Rickard Sjoberg <rickard.sjoberg@era.ericsson.se>
+ *
+ * Ericsson Radio Systems
+ * KI/ERA/T/VV
+ * 164 80 Stockholm, Sweden
+ *
+ ************************************************************************
+ */
+#ifndef _GLOBAL_H_
+#define _GLOBAL_H_
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <assert.h>
+#include <time.h>
+#include <sys/timeb.h>
+
+#include <bfc/platform/types.h>
+#include "win32.h"
+#include "defines.h"
+#include "ifunctions.h"
+#include "parsetcommon.h"
+#include "types.h"
+#include "frame.h"
+#include "nalucommon.h"
+#include "memcache.h"
+#include <mmintrin.h>
+#ifdef H264_IPP
+//#include "../tools/staticlib/ipp_px.h"
+#include "ippdefs.h"
+#include "ippcore.h"
+#include "ipps.h"
+#include "ippi.h"
+#include "ippvc.h"
+#endif
+/* benski> not the best place for this but it works for now */
+#ifdef _M_IX86
+// must be a multiple of 16
+#pragma warning(disable: 4799)
+static inline void memzero_cache32(void *dst, unsigned long i)
+{
+
+ __asm {
+ pxor mm0, mm0
+ mov edi, dst
+
+loopwrite:
+
+ movq 0[edi], mm0
+ movq 8[edi], mm0
+ movq 16[edi], mm0
+ movq 24[edi], mm0
+ lea edi, [edi+32]
+ sub i, 32
+ jg loopwrite
+
+ }
+}
+
+static inline void memzero_fast32(void *dst, unsigned long i)
+{
+
+ __asm {
+ pxor mm0, mm0
+ mov edi, dst
+
+loopwrite:
+
+ movntq 0[edi], mm0
+ movntq 8[edi], mm0
+ movntq 16[edi], mm0
+ movntq 24[edi], mm0
+
+ lea edi, [edi+32]
+ sub i, 32
+ jg loopwrite
+
+ }
+}
+
+static inline void memzero64(void *dst)
+{
+ __asm {
+ pxor mm0, mm0
+ mov edi, dst
+
+ movq 0[edi], mm0
+ movq 8[edi], mm0
+ movq 16[edi], mm0
+ movq 24[edi], mm0
+ movq 32[edi], mm0
+ movq 40[edi], mm0
+ movq 48[edi], mm0
+ movq 56[edi], mm0
+ }
+}
+
+static inline void memzero128(void *dst)
+{
+ __asm {
+ pxor mm0, mm0
+ mov edi, dst
+
+ movq 0[edi], mm0
+ movq 8[edi], mm0
+ movq 16[edi], mm0
+ movq 24[edi], mm0
+ movq 32[edi], mm0
+ movq 40[edi], mm0
+ movq 48[edi], mm0
+ movq 56[edi], mm0
+ movq 64[edi], mm0
+ movq 72[edi], mm0
+ movq 80[edi], mm0
+ movq 88[edi], mm0
+ movq 96[edi], mm0
+ movq 104[edi], mm0
+ movq 112[edi], mm0
+ movq 120[edi], mm0
+ }
+}
+
+static inline void memzero24(void *dst)
+{
+ __asm {
+ pxor mm0, mm0
+ mov edi, dst
+
+ movq 0[edi], mm0
+ movq 8[edi], mm0
+ movq 16[edi], mm0
+ }
+}
+
+static inline void memzero48(void *dst)
+{
+ __asm {
+ pxor mm0, mm0
+ mov edi, dst
+
+ movq 0[edi], mm0
+ movq 8[edi], mm0
+ movq 16[edi], mm0
+ movq 24[edi], mm0
+ movq 32[edi], mm0
+ movq 40[edi], mm0
+ }
+}
+
+static inline void memzero16(void *dst)
+{
+ __asm {
+ pxor mm0, mm0
+ mov edi, dst
+
+ movq 0[edi], mm0
+ movq 8[edi], mm0
+ }
+}
+
+static inline void memzero8(void *dst)
+{
+ __asm {
+ pxor mm0, mm0
+ mov edi, dst
+
+ movq 0[edi], mm0
+ }
+}
+
+static inline void memset_fast_end()
+{
+ _mm_empty();
+}
+
+// Very optimized memcpy() routine for all AMD Athlon and Duron family.
+// This code uses any of FOUR different basic copy methods, depending
+// on the transfer size.
+// NOTE: Since this code uses MOVNTQ (also known as "Non-Temporal MOV" or
+// "Streaming Store"), and also uses the software prefetchnta instructions,
+// be sure youre running on Athlon/Duron or other recent CPU before calling!
+
+#define TINY_BLOCK_COPY 64 // upper limit for movsd type copy
+// The smallest copy uses the X86 "movsd" instruction, in an optimized
+// form which is an "unrolled loop".
+
+#define IN_CACHE_COPY 64 * 1024 // upper limit for movq/movq copy w/SW prefetch
+// Next is a copy that uses the MMX registers to copy 8 bytes at a time,
+// also using the "unrolled loop" optimization. This code uses
+// the software prefetch instruction to get the data into the cache.
+
+#define UNCACHED_COPY 197 * 1024 // upper limit for movq/movntq w/SW prefetch
+// For larger blocks, which will spill beyond the cache, its faster to
+// use the Streaming Store instruction MOVNTQ. This write instruction
+// bypasses the cache and writes straight to main memory. This code also
+// uses the software prefetch instruction to pre-read the data.
+// USE 64 * 1024 FOR THIS VALUE IF YOURE ALWAYS FILLING A "CLEAN CACHE"
+
+#define BLOCK_PREFETCH_COPY infinity // no limit for movq/movntq w/block prefetch
+#define CACHEBLOCK 80h // number of 64-byte blocks (cache lines) for block prefetch
+// For the largest size blocks, a special technique called Block Prefetch
+// can be used to accelerate the read operations. Block Prefetch reads
+// one address per cache line, for a series of cache lines, in a short loop.
+// This is faster than using software prefetch. The technique is great for
+// getting maximum read bandwidth, especially in DDR memory systems.
+
+// Inline assembly syntax for use with Visual C++
+
+
+static void * memcpy_amd(void *dest, const void *src, size_t n)
+{
+ __asm {
+
+ mov ecx, [n] // number of bytes to copy
+ mov edi, [dest] // destination
+ mov esi, [src] // source
+ mov ebx, ecx // keep a copy of count
+
+ cld
+ cmp ecx, TINY_BLOCK_COPY
+ jb $memcpy_ic_3 // tiny? skip mmx copy
+
+ cmp ecx, 32*1024 // dont align between 32k-64k because
+ jbe $memcpy_do_align // it appears to be slower
+ cmp ecx, 64*1024
+ jbe $memcpy_align_done
+$memcpy_do_align:
+ mov ecx, 8 // a trick thats faster than rep movsb...
+ sub ecx, edi // align destination to qword
+ and ecx, 111b // get the low bits
+ sub ebx, ecx // update copy count
+ neg ecx // set up to jump into the array
+ add ecx, offset $memcpy_align_done
+ jmp ecx // jump to array of movsbs
+
+align 4
+ movsb
+ movsb
+ movsb
+ movsb
+ movsb
+ movsb
+ movsb
+ movsb
+
+$memcpy_align_done: // destination is dword aligned
+ mov ecx, ebx // number of bytes left to copy
+ shr ecx, 6 // get 64-byte block count
+ jz $memcpy_ic_2 // finish the last few bytes
+
+ cmp ecx, IN_CACHE_COPY/64 // too big 4 cache? use uncached copy
+ jae $memcpy_uc_test
+
+// This is small block copy that uses the MMX registers to copy 8 bytes
+// at a time. It uses the "unrolled loop" optimization, and also uses
+// the software prefetch instruction to get the data into the cache.
+align 16
+$memcpy_ic_1: // 64-byte block copies, in-cache copy
+
+ prefetchnta [esi + (200*64/34+192)] // start reading ahead
+
+ movq mm0, [esi+0] // read 64 bits
+ movq mm1, [esi+8]
+ movq [edi+0], mm0 // write 64 bits
+ movq [edi+8], mm1 // note: the normal movq writes the
+ movq mm2, [esi+16] // data to cache// a cache line will be
+ movq mm3, [esi+24] // allocated as needed, to store the data
+ movq [edi+16], mm2
+ movq [edi+24], mm3
+ movq mm0, [esi+32]
+ movq mm1, [esi+40]
+ movq [edi+32], mm0
+ movq [edi+40], mm1
+ movq mm2, [esi+48]
+ movq mm3, [esi+56]
+ movq [edi+48], mm2
+ movq [edi+56], mm3
+
+ add esi, 64 // update source pointer
+ add edi, 64 // update destination pointer
+ dec ecx // count down
+ jnz $memcpy_ic_1 // last 64-byte block?
+
+$memcpy_ic_2:
+ mov ecx, ebx // has valid low 6 bits of the byte count
+$memcpy_ic_3:
+ shr ecx, 2 // dword count
+ and ecx, 1111b // only look at the "remainder" bits
+ neg ecx // set up to jump into the array
+ add ecx, offset $memcpy_last_few
+ jmp ecx // jump to array of movsds
+
+$memcpy_uc_test:
+ cmp ecx, UNCACHED_COPY/64 // big enough? use block prefetch copy
+ jae $memcpy_bp_1
+
+$memcpy_64_test:
+ or ecx, ecx // _tail end of block prefetch will jump here
+ jz $memcpy_ic_2 // no more 64-byte blocks left
+
+// For larger blocks, which will spill beyond the cache, its faster to
+// use the Streaming Store instruction MOVNTQ. This write instruction
+// bypasses the cache and writes straight to main memory. This code also
+// uses the software prefetch instruction to pre-read the data.
+align 16
+$memcpy_uc_1: // 64-byte blocks, uncached copy
+
+ prefetchnta [esi + (200*64/34+192)] // start reading ahead
+
+ movq mm0,[esi+0] // read 64 bits
+ add edi,64 // update destination pointer
+ movq mm1,[esi+8]
+ add esi,64 // update source pointer
+ movq mm2,[esi-48]
+ movntq [edi-64], mm0 // write 64 bits, bypassing the cache
+ movq mm0,[esi-40] // note: movntq also prevents the CPU
+ movntq [edi-56], mm1 // from READING the destination address
+ movq mm1,[esi-32] // into the cache, only to be over-written
+ movntq [edi-48], mm2 // so that also helps performance
+ movq mm2,[esi-24]
+ movntq [edi-40], mm0
+ movq mm0,[esi-16]
+ movntq [edi-32], mm1
+ movq mm1,[esi-8]
+ movntq [edi-24], mm2
+ movntq [edi-16], mm0
+ dec ecx
+ movntq [edi-8], mm1
+ jnz $memcpy_uc_1 // last 64-byte block?
+
+ jmp $memcpy_ic_2 // almost done
+
+// For the largest size blocks, a special technique called Block Prefetch
+// can be used to accelerate the read operations. Block Prefetch reads
+// one address per cache line, for a series of cache lines, in a short loop.
+// This is faster than using software prefetch, in this case.
+// The technique is great for getting maximum read bandwidth,
+// especially in DDR memory systems.
+$memcpy_bp_1: // large blocks, block prefetch copy
+
+ cmp ecx, CACHEBLOCK // big enough to run another prefetch loop?
+ jl $memcpy_64_test // no, back to regular uncached copy
+
+ mov eax, CACHEBLOCK / 2 // block prefetch loop, unrolled 2X
+ add esi, CACHEBLOCK * 64 // move to the top of the block
+align 16
+$memcpy_bp_2:
+ mov edx, [esi-64] // grab one address per cache line
+ mov edx, [esi-128] // grab one address per cache line
+ sub esi, 128 // go reverse order
+ dec eax // count down the cache lines
+ jnz $memcpy_bp_2 // keep grabbing more lines into cache
+
+ mov eax, CACHEBLOCK // now that its in cache, do the copy
+align 16
+$memcpy_bp_3:
+ movq mm0, [esi ] // read 64 bits
+ movq mm1, [esi+ 8]
+ movq mm2, [esi+16]
+ movq mm3, [esi+24]
+ movq mm4, [esi+32]
+ movq mm5, [esi+40]
+ movq mm6, [esi+48]
+ movq mm7, [esi+56]
+ add esi, 64 // update source pointer
+ movntq [edi ], mm0 // write 64 bits, bypassing cache
+ movntq [edi+ 8], mm1 // note: movntq also prevents the CPU
+ movntq [edi+16], mm2 // from READING the destination address
+ movntq [edi+24], mm3 // into the cache, only to be over-written,
+ movntq [edi+32], mm4 // so that also helps performance
+ movntq [edi+40], mm5
+ movntq [edi+48], mm6
+ movntq [edi+56], mm7
+ add edi, 64 // update dest pointer
+
+ dec eax // count down
+
+ jnz $memcpy_bp_3 // keep copying
+ sub ecx, CACHEBLOCK // update the 64-byte block count
+ jmp $memcpy_bp_1 // keep processing chunks
+
+// The smallest copy uses the X86 "movsd" instruction, in an optimized
+// form which is an "unrolled loop". Then it handles the last few bytes.
+align 4
+ movsd
+ movsd // perform last 1-15 dword copies
+ movsd
+ movsd
+ movsd
+ movsd
+ movsd
+ movsd
+ movsd
+ movsd // perform last 1-7 dword copies
+ movsd
+ movsd
+ movsd
+ movsd
+ movsd
+ movsd
+
+$memcpy_last_few: // dword aligned from before movsds
+ mov ecx, ebx // has valid low 2 bits of the byte count
+ and ecx, 11b // the last few cows must come home
+ jz $memcpy_final // no more, lets leave
+ rep movsb // the last 1, 2, or 3 bytes
+
+$memcpy_final:
+// emms // clean up the MMX state
+ sfence // flush the write buffer
+ mov eax, [dest] // ret value = destination pointer
+
+ }
+}
+
+#elif defined(_M_X64)
+static inline void memzero24(void *dst)
+{
+ int32_t j;
+ int32_t *d = (int32_t *)dst;
+ for (j=0;j<24;j+=4)
+ {
+ d[j] = 0;
+ }
+}
+static inline void memset_fast_end() {}
+#else
+static inline void memzero_fast16(void *dst, unsigned long i)
+{
+ int32_t j;
+ int32_t *d = (int32_t *)dst;
+ for (j=0;j<i;j+=4)
+ {
+ d[j] = 0;
+ }
+}
+static inline void memzero24(void *dst)
+{
+ int32_t j;
+ int32_t *d = (int32_t *)dst;
+ for (j=0;j<24;j+=4)
+ {
+ d[j] = 0;
+ }
+}
+static inline void memset_fast_end() {}
+#endif
+
+#define UNDEFINED_REFERENCE ((int)0x80000000)
+typedef int32_t h264_ref_t;
+
+#define ET_SIZE 300 //!< size of error text buffer
+extern char errortext[ET_SIZE]; //!< buffer for error message for exit with error()
+extern int sse2_flag, mmx_flag, sse_flag, sse3_flag, sse4_1_flag;
+/***********************************************************************
+ * T y p e d e f i n i t i o n s f o r J M
+ ***********************************************************************
+ */
+
+typedef enum
+{
+ LumaComp = 0,
+ CrComp = 1,
+ CbComp = 2
+} Color_Component;
+
+/***********************************************************************
+ * D a t a t y p e s f o r C A B A C
+ ***********************************************************************
+ */
+
+typedef struct pix_pos
+{
+ int available;
+ int mb_addr;
+ short x;
+ short y;
+ short pos_x;
+ short pos_y;
+} PixelPos;
+
+//! struct to characterize the state of the arithmetic coding engine
+typedef struct
+{
+ unsigned int Drange;
+ unsigned int Dvalue;
+ int DbitsLeft;
+ byte *Dcodestrm;
+ int *Dcodestrm_len;
+} DecodingEnvironment;
+
+typedef DecodingEnvironment *DecodingEnvironmentPtr;
+
+typedef short MotionVector[2];
+
+//! definition of motion parameters
+typedef struct pic_motion
+{
+ h264_ref_t ref_pic_id;
+ h264_ref_t ref_id;
+ MotionVector mv;
+ char ref_idx;
+} PicMotion;
+
+// TODO: benski> might be more efficient to make a [list][subblock_y][subblock_x] array of these values instead of parallel arrays
+typedef struct motion_params
+{
+ PicMotion **motion[2];
+ byte ** moving_block;
+} MotionParams;
+
+//! struct for context management
+typedef struct
+{
+ uint16_t state; // index into state-table CP
+ unsigned char MPS; // Least Probable Symbol 0/1 CP
+ unsigned char dummy; // for alignment
+} BiContextType;
+
+typedef BiContextType *BiContextTypePtr;
+
+
+/**********************************************************************
+ * C O N T E X T S F O R T M L S Y N T A X E L E M E N T S
+ **********************************************************************
+ */
+
+#define NUM_MB_TYPE_CTX 11
+#define NUM_B8_TYPE_CTX 9
+#define NUM_MV_RES_CTX 10
+#define NUM_REF_NO_CTX 6
+#define NUM_DELTA_QP_CTX 4
+#define NUM_MB_AFF_CTX 4
+#define NUM_TRANSFORM_SIZE_CTX 3
+
+// structures that will be declared somewhere else
+struct storable_picture;
+struct datapartition;
+struct syntaxelement;
+
+typedef struct
+{
+ BiContextType mb_type_contexts [3][NUM_MB_TYPE_CTX];
+ BiContextType b8_type_contexts [2][NUM_B8_TYPE_CTX];
+ BiContextType mv_res_contexts [2][NUM_MV_RES_CTX];
+ BiContextType ref_no_contexts [2][NUM_REF_NO_CTX];
+ BiContextType delta_qp_contexts[NUM_DELTA_QP_CTX];
+ BiContextType mb_aff_contexts [NUM_MB_AFF_CTX];
+} MotionInfoContexts;
+
+#define NUM_IPR_CTX 2
+#define NUM_CIPR_CTX 4
+#define NUM_CBP_CTX 4
+#define NUM_BCBP_CTX 4
+#define NUM_MAP_CTX 15
+#define NUM_LAST_CTX 15
+#define NUM_ONE_CTX 5
+#define NUM_ABS_CTX 5
+
+
+typedef struct
+{
+ BiContextType transform_size_contexts [NUM_TRANSFORM_SIZE_CTX];
+ BiContextType ipr_contexts [NUM_IPR_CTX];
+ BiContextType cipr_contexts[NUM_CIPR_CTX];
+ BiContextType cbp_contexts [3][NUM_CBP_CTX];
+ BiContextType bcbp_contexts[NUM_BLOCK_TYPES][NUM_BCBP_CTX];
+ BiContextType map_contexts [2][NUM_BLOCK_TYPES][NUM_MAP_CTX+1]; // +1 for better alignment
+ BiContextType last_contexts[2][NUM_BLOCK_TYPES][NUM_LAST_CTX+1]; // +1 for better alignment
+ BiContextType one_contexts [NUM_BLOCK_TYPES][NUM_ONE_CTX];
+ BiContextType abs_contexts [NUM_BLOCK_TYPES][NUM_ABS_CTX];
+} TextureInfoContexts;
+
+
+//*********************** end of data type definition for CABAC *******************
+
+/***********************************************************************
+ * N e w D a t a t y p e s f o r T M L
+ ***********************************************************************
+ */
+
+/*! Buffer structure for decoded reference picture marking commands */
+typedef struct DecRefPicMarking_s
+{
+ int memory_management_control_operation;
+ int difference_of_pic_nums_minus1;
+ int long_term_pic_num;
+ int long_term_frame_idx;
+ int max_long_term_frame_idx_plus1;
+ struct DecRefPicMarking_s *Next;
+} DecRefPicMarking_t;
+
+
+//! definition of pic motion parameters
+typedef struct pic_motion_params2
+{
+ h264_ref_t ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
+ h264_ref_t ref_id; //!< reference picture identifier [list][subblock_y][subblock_x]
+ short mv[2]; //!< motion vector [list][subblock_x][subblock_y][component]
+ char ref_idx; //!< reference picture [list][subblock_y][subblock_x]
+ byte mb_field; //!< field macroblock indicator
+ byte field_frame; //!< indicates if co_located is field or frame.
+} PicMotionParams2;
+
+//! Macroblock
+typedef struct macroblock
+{
+ struct slice *p_Slice; //!< pointer to the current slice
+ struct img_par *p_Vid; //!< pointer to VideoParameters
+ struct inp_par *p_Inp;
+ int mbAddrX; //!< current MB address
+ int mb_x;
+ int mb_y;
+ int block_x;
+ int block_y;
+ int block_y_aff;
+ int pix_x;
+ int pix_y;
+ int pix_c_x;
+ int pix_c_y;
+
+ int subblock_x;
+ int subblock_y;
+
+ int qp; //!< QP luma
+ int qpc[2]; //!< QP chroma
+ int qp_scaled[MAX_PLANE]; //!< QP scaled for all comps.
+ Boolean is_lossless;
+ Boolean is_intra_block;
+ Boolean is_v_block;
+
+ short slice_nr;
+ short delta_quant; //!< for rate control
+
+ struct macroblock *mb_up; //!< pointer to neighboring MB (CABAC)
+ struct macroblock *mb_left; //!< pointer to neighboring MB (CABAC)
+
+ // some storage of macroblock syntax elements for global access
+ int mb_type;
+ short mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE][2]; //!< indices correspond to [forw,backw][block_y][block_x][x,y]
+ int cbp;
+ int64 cbp_blk [3];
+ int64 cbp_bits [3];
+ int64 cbp_bits_8x8[3];
+
+ int i16mode;
+ char b8mode[4];
+ char b8pdir[4];
+ char ei_flag; //!< error indicator flag that enables concealment
+ char dpl_flag; //!< error indicator flag that signals a missing data partition
+ char ipmode_DPCM;
+
+ short DFDisableIdc;
+ short DFAlphaC0Offset;
+ short DFBetaOffset;
+
+ char c_ipred_mode; //!< chroma intra prediction mode
+ Boolean mb_field;
+
+ int skip_flag;
+
+ int mb_addr_left, mb_addr_up, mb_addr_upper_right, mb_addr_upper_left;
+ Boolean mb_avail_left, mb_avail_up, mb_avail_upper_right, mb_avail_upper_left;
+
+ Boolean luma_transform_size_8x8_flag;
+ Boolean NoMbPartLessThan8x8Flag;
+
+ void (*itrans_8x8)(struct macroblock *currMB, ColorPlane pl, int ioff, int joff);
+
+ void (*GetMVPredictor) (struct macroblock *currMB, PixelPos *block,
+ short pmv[2], short ref_frame, struct pic_motion **motion, int mb_x, int mb_y, int blockshape_x, int blockshape_y);
+
+ int (*read_and_store_CBP_block_bit) (struct macroblock *currMB, DecodingEnvironmentPtr dep_dp, int type);
+ char (*readRefPictureIdx) (struct syntaxelement *currSE, struct datapartition *dP, int list);
+
+} Macroblock;
+
+//! Syntaxelement
+typedef struct syntaxelement
+{
+ int value1; //!< numerical value of syntax element
+ int value2; //!< for blocked symbols, e.g. run/level
+ int len; //!< length of code
+ //int inf; //!< info part of CAVLC code
+
+#if TRACE
+ #define TRACESTRING_SIZE 100 //!< size of trace string
+ char tracestring[TRACESTRING_SIZE]; //!< trace string
+#endif
+
+ //! for mapping of CAVLC to syntaxElement
+ void (*mapping)(int len, int info, int *value1, int *value2);
+} SyntaxElement;
+
+
+//! Bitstream
+typedef struct
+{
+ // CABAC Decoding
+ int read_len; //!< actual position in the codebuffer, CABAC only
+ int code_len; //!< overall codebuffer length, CABAC only
+ // CAVLC Decoding
+ int frame_bitoffset; //!< actual position in the codebuffer, bit-oriented, CAVLC only
+ int bitstream_length; //!< over codebuffer lnegth, byte oriented, CAVLC only
+
+ byte *streamBuffer; //!< actual codebuffer for read bytes
+} Bitstream;
+
+
+/* === 4x4 block typedefs === */
+// 32 bit precision
+typedef int h264_int_block_row_t[BLOCK_SIZE];
+typedef h264_int_block_row_t h264_int_block_t[BLOCK_SIZE];
+// 16 bit precision
+typedef int16_t h264_short_block_row_t[BLOCK_SIZE];
+typedef h264_short_block_row_t h264_short_block_t[BLOCK_SIZE];
+// 8 bit precision
+
+/* === 8x8 block typedefs === */
+// 32 bit precision
+typedef int h264_int_8x8block_row_t[BLOCK_SIZE_8x8];
+typedef h264_int_8x8block_row_t h264_int_8x8block_t[BLOCK_SIZE_8x8];
+// 16 bit precision
+typedef int16_t h264_short_8x8block_row_t[BLOCK_SIZE_8x8];
+typedef h264_short_8x8block_row_t h264_short_8x8block_t[BLOCK_SIZE_8x8];
+// 8 bit precision
+typedef imgpel h264_imgpel_8x8block_row_t[BLOCK_SIZE_8x8];
+typedef h264_imgpel_8x8block_row_t h264_imgpel_8x8block_t[BLOCK_SIZE_8x8];
+
+/* === 16x16 block typedefs === */
+// 32 bit precision
+typedef int h264_int_macroblock_row_t[MB_BLOCK_SIZE];
+typedef h264_int_macroblock_row_t h264_int_macroblock_t[MB_BLOCK_SIZE];
+// 16 bit precision
+typedef int16_t h264_short_macroblock_row_t[MB_BLOCK_SIZE];
+typedef h264_short_macroblock_row_t h264_short_macroblock_t[MB_BLOCK_SIZE];
+// 8 bit precision
+typedef imgpel h264_imgpel_macroblock_row_t[MB_BLOCK_SIZE];
+typedef h264_imgpel_macroblock_row_t h264_imgpel_macroblock_t[MB_BLOCK_SIZE];
+
+
+
+
+typedef int h264_pic_position[2];
+typedef byte h264_4x4_byte[BLOCK_SIZE][BLOCK_SIZE];
+typedef h264_4x4_byte h264_nz_coefficient[3];
+
+//! DataPartition
+typedef struct datapartition
+{
+
+ Bitstream *bitstream;
+ DecodingEnvironment de_cabac;
+
+} DataPartition;
+
+//! Slice
+typedef struct slice
+{
+ struct img_par *p_Vid;
+ struct inp_par *p_Inp;
+ pic_parameter_set_rbsp_t *active_pps;
+ seq_parameter_set_rbsp_t *active_sps;
+
+ struct colocated_params *p_colocated;
+ struct colocated_params *Co_located_JV[MAX_PLANE]; //!< p_colocated to be used during 4:4:4 independent mode decoding
+
+ int mb_aff_frame_flag;
+ int direct_spatial_mv_pred_flag; //!< Indicator for direct mode type (1 for Spatial, 0 for Temporal)
+ int num_ref_idx_l0_active; //!< number of available list 0 references
+ int num_ref_idx_l1_active; //!< number of available list 1 references
+
+ int qp;
+ int slice_qp_delta;
+ int qs;
+ int slice_qs_delta;
+ int slice_type; //!< slice type
+ int model_number; //!< cabac model number
+ PictureStructure structure; //!< Identify picture structure type
+ int start_mb_nr; //!< MUST be set by NAL even in case of ei_flag == 1
+ int max_part_nr;
+ int dp_mode; //!< data partitioning mode
+ int last_dquant;
+
+ // int last_mb_nr; //!< only valid when entropy coding == CABAC
+ DataPartition *partArr; //!< array of partitions
+ MotionInfoContexts *mot_ctx; //!< pointer to struct of context models for use in CABAC
+ TextureInfoContexts *tex_ctx; //!< pointer to struct of context models for use in CABAC
+
+ int mvscale[6][MAX_REFERENCE_PICTURES];
+
+ int ref_pic_list_reordering_flag_l0;
+ int *reordering_of_pic_nums_idc_l0;
+ int *abs_diff_pic_num_minus1_l0;
+ int *long_term_pic_idx_l0;
+ int ref_pic_list_reordering_flag_l1;
+ int *reordering_of_pic_nums_idc_l1;
+ int *abs_diff_pic_num_minus1_l1;
+ int *long_term_pic_idx_l1;
+
+
+ short DFDisableIdc; //!< Disable deblocking filter on slice
+ short DFAlphaC0Offset; //!< Alpha and C0 offset for filtering slice
+ short DFBetaOffset; //!< Beta offset for filtering slice
+
+ int pic_parameter_set_id; //!<the ID of the picture parameter set the slice is reffering to
+
+ int dpB_NotPresent; //!< non-zero, if data partition B is lost
+ int dpC_NotPresent; //!< non-zero, if data partition C is lost
+
+
+ __declspec(align(32)) h264_imgpel_macroblock_t mb_pred[MAX_PLANE];
+ __declspec(align(32)) h264_imgpel_macroblock_t mb_rec[MAX_PLANE];
+ __declspec(align(32)) union
+ {
+ __declspec(align(32)) h264_short_8x8block_t mb_rres8[MAX_PLANE][4];
+ __declspec(align(32)) h264_short_macroblock_t cof[MAX_PLANE];
+ __declspec(align(32)) h264_short_block_t cof4[MAX_PLANE][16]; // TODO: get this to work, one of these days
+ __declspec(align(32)) h264_short_macroblock_t ipcm[MAX_PLANE];
+ };
+
+ int cofu[16];
+
+ // Scaling matrix info
+ int InvLevelScale4x4_Intra[3][6][4][4];
+ int InvLevelScale4x4_Inter[3][6][4][4];
+ int InvLevelScale8x8_Intra[3][6][64];
+ int InvLevelScale8x8_Inter[3][6][64];
+
+ int *qmatrix[12];
+
+ // Cabac
+ // TODO: we could optimize coefficient reading by storing the levels/runs instead of coefficients
+ int16_t coeff[64]; // one more for EOB
+ int coeff_ctr;
+ int pos;
+
+ //weighted prediction
+ unsigned int apply_weights;
+ unsigned int luma_log2_weight_denom;
+ unsigned int chroma_log2_weight_denom;
+ int wp_weight[2][MAX_REFERENCE_PICTURES][3]; // weight in [list][index][component] order
+ int wp_offset[6][MAX_REFERENCE_PICTURES][3]; // offset in [list][index][component] order
+ int wbp_weight[6][MAX_REFERENCE_PICTURES][MAX_REFERENCE_PICTURES][3]; //weight in [list][fw_index][bw_index][component] order
+ int wp_round_luma;
+ int wp_round_chroma;
+
+ void (*read_CBP_and_coeffs_from_NAL) (Macroblock *currMB);
+ int (*decode_one_component ) (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, struct storable_picture *dec_picture);
+ int (*readSlice ) (struct img_par *, struct inp_par *);
+ int (*nal_startcode_follows ) (struct slice*, int );
+ void (*read_motion_info_from_NAL) (Macroblock *currMB);
+ void (*read_one_macroblock ) (Macroblock *currMB);
+ void (*interpret_mb_mode ) (Macroblock *currMB);
+ void (*compute_colocated ) (struct slice *currSlice, struct colocated_params *p, struct storable_picture **listX[6]);
+
+ void (*linfo_cbp_intra) (int len,int info,int *cbp, int *dummy);
+ void (*linfo_cbp_inter) (int len,int info,int *cbp, int *dummy);
+} Slice;
+
+//****************************** ~DM ***********************************
+
+// image parameters
+typedef struct img_par
+{
+ struct inp_par *p_Inp;
+ pic_parameter_set_rbsp_t *active_pps;
+ seq_parameter_set_rbsp_t *active_sps;
+ seq_parameter_set_rbsp_t SeqParSet[MAXSPS];
+ pic_parameter_set_rbsp_t PicParSet[MAXPPS];
+
+ struct sei_params *p_SEI;
+
+ struct old_slice_par *old_slice;
+ int number; //!< frame number
+ unsigned int current_mb_nr; // bitstream order
+ unsigned int num_dec_mb;
+ short current_slice_nr;
+ int *intra_block;
+
+ int qp; //!< quant for the current frame
+
+ int sp_switch; //!< 1 for switching sp, 0 for normal sp
+ int type; //!< image type INTER/INTRA
+ int width;
+ int height;
+ int width_cr; //!< width chroma
+ int height_cr; //!< height chroma
+ int mb_x;
+ int mb_y;
+ int block_x;
+ int block_y;
+ int pix_c_x;
+ int pix_c_y;
+
+ int allrefzero;
+
+ byte **ipredmode; //!< prediction type [90][74]
+ h264_nz_coefficient *nz_coeff;
+ int **siblock;
+ int cod_counter; //!< Current count of number of skipped macroblocks in a row
+
+ int structure; //!< Identify picture structure type
+
+ Slice *currentSlice; //!< pointer to current Slice data struct
+ Macroblock *mb_data; //!< array containing all MBs of a whole frame
+ Macroblock *mb_data_JV[MAX_PLANE]; //!< mb_data to be used for 4:4:4 independent mode
+ int colour_plane_id; //!< colour_plane_id of the current coded slice
+ int ChromaArrayType;
+
+ // For MB level frame/field coding
+ int mb_aff_frame_flag;
+
+ // for signalling to the neighbour logic that this is a deblocker call
+ int DeblockCall;
+ byte mixedModeEdgeFlag;
+
+ // picture error concealment
+ // concealment_head points to first node in list, concealment_end points to
+ // last node in list. Initialize both to NULL, meaning no nodes in list yet
+ struct concealment_node *concealment_head;
+ struct concealment_node *concealment_end;
+
+ DecRefPicMarking_t *dec_ref_pic_marking_buffer; //!< stores the memory management control operations
+
+ int num_ref_idx_l0_active; //!< number of forward reference
+ int num_ref_idx_l1_active; //!< number of backward reference
+
+ int slice_group_change_cycle;
+
+ int redundant_pic_cnt;
+
+ unsigned int pre_frame_num; //!< store the frame_num in the last decoded slice. For detecting gap in frame_num.
+ int non_conforming_stream;
+
+ // End JVT-D101
+ // POC200301: from unsigned int to int
+ int toppoc; //poc for this top field // POC200301
+ int bottompoc; //poc of bottom field of frame
+ int framepoc; //poc of this frame // POC200301
+ unsigned int frame_num; //frame_num for this frame
+ unsigned int field_pic_flag;
+ byte bottom_field_flag;
+
+ //the following is for slice header syntax elements of poc
+ // for poc mode 0.
+ unsigned int pic_order_cnt_lsb;
+ int delta_pic_order_cnt_bottom;
+ // for poc mode 1.
+ int delta_pic_order_cnt[3];
+
+ // ////////////////////////
+ // for POC mode 0:
+ signed int PrevPicOrderCntMsb;
+ unsigned int PrevPicOrderCntLsb;
+ signed int PicOrderCntMsb;
+
+ // for POC mode 1:
+ unsigned int AbsFrameNum;
+ signed int ExpectedPicOrderCnt, PicOrderCntCycleCnt, FrameNumInPicOrderCntCycle;
+ unsigned int PreviousFrameNum, FrameNumOffset;
+ int ExpectedDeltaPerPicOrderCntCycle;
+ int PreviousPOC, ThisPOC;
+ int PreviousFrameNumOffset;
+ // /////////////////////////
+
+ int idr_flag;
+ int nal_reference_idc; //!< nal_reference_idc from NAL unit
+
+ int idr_pic_id;
+
+ int MaxFrameNum;
+
+ unsigned int PicWidthInMbs;
+ unsigned int PicHeightInMapUnits;
+ unsigned int FrameHeightInMbs;
+ unsigned int PicHeightInMbs;
+ unsigned int PicSizeInMbs;
+ unsigned int FrameSizeInMbs;
+ unsigned int oldFrameSizeInMbs;
+
+ int no_output_of_prior_pics_flag;
+ int long_term_reference_flag;
+ int adaptive_ref_pic_buffering_flag;
+
+ int last_has_mmco_5;
+ int last_pic_bottom_field;
+
+ // Fidelity Range Extensions Stuff
+ short bitdepth_luma;
+ short bitdepth_chroma;
+ int bitdepth_scale[2];
+ int bitdepth_luma_qp_scale;
+ int bitdepth_chroma_qp_scale;
+ unsigned int dc_pred_value_comp[MAX_PLANE]; //!< component value for DC prediction (depends on component pel bit depth)
+ int max_pel_value_comp[MAX_PLANE]; //!< max value that one picture element (pixel) can take (depends on pic_unit_bitdepth)
+ int Transform8x8Mode;
+ int profile_idc;
+ int yuv_format;
+ int lossless_qpprime_flag;
+ int num_blk8x8_uv;
+ int num_uv_blocks;
+ int num_cdc_coeff;
+ int mb_cr_size_x;
+ int mb_cr_size_y;
+ int mb_cr_size_x_blk;
+ int mb_cr_size_y_blk;
+ int mb_size[3][2]; //!< component macroblock dimensions
+ int mb_size_blk[3][2]; //!< component macroblock dimensions
+ int mb_size_shift[3][2];
+ int subpel_x;
+ int subpel_y;
+ int shiftpel_x;
+ int shiftpel_y;
+
+ int max_vmv_r; //!< maximum vertical motion vector range in luma quarter frame pixel units for the current level_idc
+ int max_mb_vmv_r; //!< maximum vertical motion vector range in luma quarter pixel units for the current level_idc
+
+ // picture error concealment
+ int last_ref_pic_poc;
+ int ref_poc_gap;
+ int poc_gap;
+ int earlier_missing_poc;
+ unsigned int frame_to_conceal;
+ int IDR_concealment_flag;
+ int conceal_slice_type;
+
+ // random access point decoding
+ int recovery_point;
+ int recovery_point_found;
+ int recovery_frame_cnt;
+ int recovery_frame_num;
+ int recovery_poc;
+
+ int separate_colour_plane_flag;
+
+ int frame_number;
+ int init_bl_done;
+
+ // Redundant slices. Should be moved to another structure and allocated only if extended profile
+ unsigned int previous_frame_num; //!< frame number of previous slice
+ int ref_flag[17]; //!< 0: i-th previous frame is incorrect
+ //!< non-zero: i-th previous frame is correct
+ int Is_primary_correct; //!< if primary frame is correct, 0: incorrect
+ int Is_redundant_correct; //!< if redundant frame is correct, 0:incorrect
+ int redundant_slice_ref_idx; //!< reference index of redundant slice
+
+ //FILE *p_log; //!< SNR file
+ int LastAccessUnitExists;
+ int NALUCount;
+
+ Boolean global_init_done;
+
+ int *qp_per_matrix;
+ int *qp_rem_matrix;
+
+ struct frame_store *last_out_fs;
+ int pocs_in_dpb[100];
+
+
+ struct storable_picture *dec_picture;
+ struct storable_picture *dec_picture_JV[MAX_PLANE]; //!< dec_picture to be used during 4:4:4 independent mode decoding
+ struct storable_picture *no_reference_picture; //!< dummy storable picture for recovery point
+ struct storable_picture **listX[6];
+
+ // Error parameters
+ struct object_buffer *erc_object_list;
+ struct ercVariables_s *erc_errorVar;
+
+ int erc_mvperMB;
+ struct img_par *erc_img;
+ int ec_flag[SE_MAX_ELEMENTS]; //!< array to set errorconcealment
+
+ struct memory_input_struct *mem_input;
+
+ struct frame_store *out_buffer;
+
+ struct storable_picture *pending_output;
+ int pending_output_state;
+ int recovery_flag;
+
+ // dpb
+ struct decoded_picture_buffer *p_Dpb;
+
+ char listXsize[6];
+ // report
+ char cslice_type[9];
+ // FMO
+ int *MbToSliceGroupMap;
+ int *MapUnitToSliceGroupMap;
+ int NumberOfSliceGroups; // the number of slice groups -1 (0 == scan order, 7 == maximum)
+
+#if (ENABLE_OUTPUT_TONEMAPPING)
+ struct tone_mapping_struct_s *seiToneMapping;
+#endif
+
+ // benski> buffer of storablge pictures ready for output.
+ // might be able to optimize a tad by making a ringbuffer, but i doubt it matters
+ struct storable_picture **out_pictures;
+ size_t size_out_pictures;
+ size_t num_out_pictures;
+
+ ImageCache image_cache[2]; // [0] is luma [1] is chroma (shared for both planes)
+ MotionCache motion_cache;
+
+ h264_pic_position *PicPos; //! Helper array to access macroblock positions.
+
+ NALU_t *nalu; // a cache so we don't re-alloc every time
+
+ void (*getNeighbour) (const Macroblock *currMB, int xN, int yN, const int mb_size[2], PixelPos *pix);
+ void (*getNeighbourPX_NoPos)(const Macroblock *currMB, int xN, int yN, const int mb_size[2], PixelPos *pix);
+ void (*getNeighbourXP_NoPos)(const Macroblock *currMB, int xN, int yN, const int mb_size[2], PixelPos *pix);
+ void (*getNeighbourLuma) (const Macroblock *currMB, int xN, int yN, PixelPos *pix);
+ void (*getNeighbourPXLuma) (const Macroblock *currMB, int xN, int yN, PixelPos *pix);
+ void (*getNeighbourXPLuma) (const Macroblock *currMB, int xN, int yN, PixelPos *pix);
+ void (*getNeighbourLeftLuma)(const Macroblock *currMB, PixelPos *pix);
+ void (*getNeighbourNXLuma) (const Macroblock *currMB, int yN, PixelPos *pix); // xN<0, yN full range
+ void (*getNeighbourLeft) (const Macroblock *currMB, const int mb_size[2], PixelPos *pix); // xN<0, yN=0
+ void (*getNeighbourUp) (const Macroblock *currMB, const int mb_size[2], PixelPos *pix); // xN=0, yN<0
+ void (*getNeighbourNX) (const Macroblock *currMB, int yN, const int mb_size[2], PixelPos *pix); // xN<0, yN full range
+ void (*getNeighbourNP) (const Macroblock *currMB, int yN, const int mb_size[2], PixelPos *pix); // xN<0, yN>=0
+ void (*getNeighbourNPChromaNB)(const Macroblock *currMB, int yN, const int mb_size[2], PixelPos *pix); // xN<0, yN>=0
+ void (*getNeighbour0X) (const Macroblock *currMB, int yN, const int mb_size[2], PixelPos *pix); // xN=0, yN full range
+ void (*getNeighbour0XLuma) (const Macroblock *currMB, int yN, PixelPos *pix); // xN=0, yN full range
+ void (*getNeighbourX0) (const Macroblock *currMB, int xN, const int mb_size[2], PixelPos *pix); // xN full range, yN = 0
+ void (*getNeighbourUpLuma) (const Macroblock *currMB, PixelPos *pix); // xN=0, yN<0
+ void (*getNeighbourNPLumaNB)(const Macroblock *currMB, int yN, PixelPos *pix);
+ void (*getNeighbourPXLumaNB) (const Macroblock *currMB, int xN, int yN, PixelPos *pix);
+ void (*getNeighbourPXLumaNB_NoPos)(const Macroblock *currMB, int yN, PixelPos *pix);
+ void (*getNeighbourPPLumaNB) (const Macroblock *currMB, int xN, int yN, PixelPos *pix);
+ void (*getNeighbourXPLumaNB) (const Macroblock *currMB, int xN, int yN, PixelPos *pix);
+ void (*getNeighbourXPLumaNB_NoPos)(const Macroblock *currMB, int xN, int yN, PixelPos *pix);
+ void (*get_mb_block_pos) (const h264_pic_position *PicPos, int mb_addr, short *x, short *y);
+ void (*GetStrength) (byte Strength[16], Macroblock *MbQ, int dir,int edge, int mvlimit, struct storable_picture *p);
+ void (*EdgeLoopLuma) (ColorPlane pl, struct video_image *image, const byte Strength[16], Macroblock *MbQ, int dir, int edge, struct storable_picture *p);
+ void (*EdgeLoopChroma) (struct video_image *image, byte Strength[16], Macroblock *MbQ, int dir, int edge, int uv, struct storable_picture *p);
+} VideoParameters;
+
+// input parameters from configuration file
+typedef struct inp_par
+{
+ int intra_profile_deblocking; //!< Loop filter usage determined by flags and parameters in bitstream
+
+ // Output sequence format related variables
+ FrameFormat output; //!< output related information
+
+#ifdef _LEAKYBUCKET_
+ unsigned long R_decoder; //!< Decoder Rate in HRD Model
+ unsigned long B_decoder; //!< Decoder Buffer size in HRD model
+ unsigned long F_decoder; //!< Decoder Initial buffer fullness in HRD model
+ char LeakyBucketParamFile[FILE_NAME_SIZE]; //!< LeakyBucketParamFile
+#endif
+
+ // picture error concealment
+ int ref_poc_gap;
+ int poc_gap;
+} InputParameters;
+
+typedef struct old_slice_par
+{
+ unsigned field_pic_flag;
+ unsigned frame_num;
+ int nal_ref_idc;
+ unsigned pic_oder_cnt_lsb;
+ int delta_pic_oder_cnt_bottom;
+ int delta_pic_order_cnt[2];
+ byte bottom_field_flag;
+ byte idr_flag;
+ int idr_pic_id;
+ int pps_id;
+} OldSliceParams;
+
+typedef struct decoder_params
+{
+ InputParameters *p_Inp; //!< Input Parameters
+ VideoParameters *p_Vid; //!< Image Parameters
+
+} DecoderParams;
+
+#ifdef TRACE
+extern FILE *p_trace; //!< Trace file
+extern int bitcounter;
+#endif
+
+// prototypes
+
+extern void error(char *text, int code);
+
+// dynamic mem allocation
+extern int init_global_buffers(VideoParameters *p_Vid);
+extern void free_global_buffers(VideoParameters *p_Vid);
+
+extern int RBSPtoSODB(byte *streamBuffer, int last_byte_pos);
+extern int EBSPtoRBSP(byte *streamBuffer, int end_bytepos);
+
+void FreePartition (DataPartition *dp, int n);
+DataPartition *AllocPartition(int n);
+
+void tracebits(const char *trace_str, int len, int info,int value1);
+void tracebits2(const char *trace_str, int len, int info);
+
+unsigned CeilLog2 ( unsigned uiVal);
+unsigned CeilLog2_sf( unsigned uiVal);
+
+// For 4:4:4 independent mode
+extern void change_plane_JV( VideoParameters *p_Vid, int nplane );
+extern void make_frame_picture_JV(VideoParameters *p_Vid);
+
+
+#endif
+
+
diff --git a/Src/h264dec/ldecod/inc/header.h b/Src/h264dec/ldecod/inc/header.h
new file mode 100644
index 00000000..f3185b07
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/header.h
@@ -0,0 +1,22 @@
+/*!
+ *************************************************************************************
+ * \file header.h
+ *
+ * \brief
+ * Prototypes for header.c
+ *************************************************************************************
+ */
+
+#ifndef _HEADER_H_
+#define _HEADER_H_
+
+extern void FirstPartOfSliceHeader(Slice *currSlice);
+extern void RestOfSliceHeader (Slice *currSlice);
+
+extern void dec_ref_pic_marking(VideoParameters *p_Vid, Bitstream *currStream);
+
+extern void decode_poc(VideoParameters *p_Vid);
+extern int dumppoc(VideoParameters *p_Vid);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/image.h b/Src/h264dec/ldecod/inc/image.h
new file mode 100644
index 00000000..2540f3c5
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/image.h
@@ -0,0 +1,33 @@
+
+/*!
+ ************************************************************************
+ * \file image.h
+ *
+ * \brief
+ * prototypes for image.c
+ *
+ ************************************************************************
+ */
+
+#ifndef _IMAGE_H_
+#define _IMAGE_H_
+
+#include "mbuffer.h"
+
+extern int picture_order(VideoParameters *p_Vid);
+
+extern void decode_one_slice (Slice *currSlice);
+
+extern void exit_picture(VideoParameters *p_Vid, StorablePicture **dec_picture);
+extern int decode_one_frame(VideoParameters *p_Vid, uint64_t time_code);
+
+extern int is_new_picture(StorablePicture *dec_picture, Slice *currSlice, OldSliceParams *p_old_slice);
+extern void init_old_slice(OldSliceParams *p_old_slice);
+// For 4:4:4 independent mode
+extern void copy_dec_picture_JV( VideoParameters *p_Vid, StorablePicture *dst, StorablePicture *src );
+
+extern void frame_postprocessing(VideoParameters *p_Vid);
+extern void field_postprocessing(VideoParameters *p_Vid);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/intra16x16_pred.h b/Src/h264dec/ldecod/inc/intra16x16_pred.h
new file mode 100644
index 00000000..6680280a
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/intra16x16_pred.h
@@ -0,0 +1,25 @@
+/*!
+ *************************************************************************************
+ * \file intra16x16_pred.h
+ *
+ * \brief
+ * definitions for intra 16x16 prediction
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright,
+ * address and affiliation details)
+ * - Alexis Michael Tourapis <alexismt@ieee.org>
+ *
+ *************************************************************************************
+ */
+
+#ifndef _INTRA16x16_PRED_H_
+#define _INTRA16x16_PRED_H_
+
+#include "global.h"
+#include "mbuffer.h"
+
+extern int intrapred16x16(Macroblock *currMB, ColorPlane pl, int b8);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/intra4x4_pred.h b/Src/h264dec/ldecod/inc/intra4x4_pred.h
new file mode 100644
index 00000000..a50c5262
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/intra4x4_pred.h
@@ -0,0 +1,25 @@
+/*!
+ *************************************************************************************
+ * \file intra4x4_pred.h
+ *
+ * \brief
+ * definitions for intra 4x4 prediction
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright,
+ * address and affiliation details)
+ * - Alexis Michael Tourapis <alexismt@ieee.org>
+ *
+ *************************************************************************************
+ */
+
+#ifndef _INTRA4x4_PRED_H_
+#define _INTRA4x4_PRED_H_
+
+#include "global.h"
+#include "mbuffer.h"
+
+extern int intrapred(Macroblock *currMB, ColorPlane pl, int ioff, int joff, int img_block_x, int img_block_y);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/intra8x8_pred.h b/Src/h264dec/ldecod/inc/intra8x8_pred.h
new file mode 100644
index 00000000..ff238460
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/intra8x8_pred.h
@@ -0,0 +1,25 @@
+/*!
+ *************************************************************************************
+ * \file intra8x8_pred.h
+ *
+ * \brief
+ * definitions for intra 8x8 prediction
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright,
+ * address and affiliation details)
+ * - Alexis Michael Tourapis <alexismt@ieee.org>
+ *
+ *************************************************************************************
+ */
+
+#ifndef _INTRA8x8_PRED_H_
+#define _INTRA8x8_PRED_H_
+
+#include "global.h"
+#include "mbuffer.h"
+
+extern int intrapred8x8(Macroblock *currMB, ColorPlane pl, int ioff, int joff);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/leaky_bucket.h b/Src/h264dec/ldecod/inc/leaky_bucket.h
new file mode 100644
index 00000000..ad605a6a
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/leaky_bucket.h
@@ -0,0 +1,26 @@
+
+/*!
+ *************************************************************************************
+ * \file leaky_bucket.h
+ *
+ * \brief
+ * Header for Leaky Buffer parameters
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Shankar Regunathan <shanre@microsoft.com>
+ *************************************************************************************
+ */
+#ifndef _LEAKY_BUCKET_H_
+#define _LEAKY_BUCKET_H_
+
+#include "global.h"
+
+#ifdef _LEAKYBUCKET_
+// Leaky Bucket functions
+unsigned long GetBigDoubleWord(FILE *fp);
+void calc_buffer(InputParameters *p_Inp);
+#endif
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/loopfilter.h b/Src/h264dec/ldecod/inc/loopfilter.h
new file mode 100644
index 00000000..c8b739fa
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/loopfilter.h
@@ -0,0 +1,23 @@
+/*!
+ ************************************************************************
+ * \file
+ * loopfilter.h
+ * \brief
+ * external deblocking filter interface
+ ************************************************************************
+ */
+
+#ifndef _LOOPFILTER_H_
+#define _LOOPFILTER_H_
+
+#include "global.h"
+#include "mbuffer.h"
+
+extern void DeblockPicture(VideoParameters *p_Vid, StorablePicture *p) ;
+
+
+extern void EdgeLoopLumaNormal_Horiz(ColorPlane pl, VideoImage *image, const byte Strength[MB_BLOCK_SIZE], Macroblock *MbQ, int edge, StorablePicture *p);
+extern void EdgeLoopLumaNormal_Horiz_sse2(ColorPlane pl, VideoImage *image, const byte Strength[MB_BLOCK_SIZE], Macroblock *MbQ, int edge, StorablePicture *p);
+extern void EdgeLoopChromaNormal_Horiz(VideoImage *image, const byte Strength[16], Macroblock *MbQ, int edge, int uv, StorablePicture *p);
+
+#endif //_LOOPFILTER_H_
diff --git a/Src/h264dec/ldecod/inc/macroblock.h b/Src/h264dec/ldecod/inc/macroblock.h
new file mode 100644
index 00000000..d11547a4
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/macroblock.h
@@ -0,0 +1,177 @@
+/*!
+ ************************************************************************
+ * \file macroblock.h
+ *
+ * \brief
+ * Arrays for macroblock encoding
+ *
+ * \author
+ * Inge Lille-Langoy <inge.lille-langoy@telenor.com>
+ * Copyright (C) 1999 Telenor Satellite Services, Norway
+ ************************************************************************
+ */
+
+#ifndef _MACROBLOCK_H_
+#define _MACROBLOCK_H_
+
+#include "global.h"
+#include "mbuffer.h"
+#include "block.h"
+
+//! single scan pattern
+static const byte SNGL_SCAN[16][2] =
+{
+ {0,0},{1,0},{0,1},{0,2},
+ {1,1},{2,0},{3,0},{2,1},
+ {1,2},{0,3},{1,3},{2,2},
+ {3,1},{3,2},{2,3},{3,3}
+};
+
+static const byte SNGL_SCAN_1D[16] = { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15};
+static const byte SNGL_SCAN_DC[16] = { 0, 1, 2, 8, 3, 4, 5, 6, 9, 10, 11, 12, 7, 13, 14, 15};
+//! field scan pattern
+static const byte FIELD_SCAN[16][2] =
+{
+ {0,0},{0,1},{1,0},{0,2},
+ {0,3},{1,1},{1,2},{1,3},
+ {2,0},{2,1},{2,2},{2,3},
+ {3,0},{3,1},{3,2},{3,3}
+};
+
+static const byte FIELD_SCAN_1D[16] = {0, 4, 1, 8, 12, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15};
+static const byte FIELD_SCAN_DC[16] = {0, 2, 1, 8, 10, 3, 9, 11, 4, 6, 12, 14, 5, 7, 13, 15};
+//! used to control block sizes : Not used/16x16/16x8/8x16/8x8/8x4/4x8/4x4
+static const int BLOCK_STEP[8][2]=
+{
+ {0,0},{4,4},{4,2},{2,4},{2,2},{2,1},{1,2},{1,1}
+};
+
+//! single scan pattern
+static const byte SNGL_SCAN8x8[64][2] = {
+ {0,0}, {1,0}, {0,1}, {0,2}, {1,1}, {2,0}, {3,0}, {2,1}, {1,2}, {0,3}, {0,4}, {1,3}, {2,2}, {3,1}, {4,0}, {5,0},
+ {4,1}, {3,2}, {2,3}, {1,4}, {0,5}, {0,6}, {1,5}, {2,4}, {3,3}, {4,2}, {5,1}, {6,0}, {7,0}, {6,1}, {5,2}, {4,3},
+ {3,4}, {2,5}, {1,6}, {0,7}, {1,7}, {2,6}, {3,5}, {4,4}, {5,3}, {6,2}, {7,1}, {7,2}, {6,3}, {5,4}, {4,5}, {3,6},
+ {2,7}, {3,7}, {4,6}, {5,5}, {6,4}, {7,3}, {7,4}, {6,5}, {5,6}, {4,7}, {5,7}, {6,6}, {7,5}, {7,6}, {6,7}, {7,7}
+};
+
+static const byte SNGL_SCAN8x8_1D[64] =
+{
+ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
+};
+
+//! field scan pattern
+static const byte FIELD_SCAN8x8[64][2] = { // 8x8
+ {0,0}, {0,1}, {0,2}, {1,0}, {1,1}, {0,3}, {0,4}, {1,2}, {2,0}, {1,3}, {0,5}, {0,6}, {0,7}, {1,4}, {2,1}, {3,0},
+ {2,2}, {1,5}, {1,6}, {1,7}, {2,3}, {3,1}, {4,0}, {3,2}, {2,4}, {2,5}, {2,6}, {2,7}, {3,3}, {4,1}, {5,0}, {4,2},
+ {3,4}, {3,5}, {3,6}, {3,7}, {4,3}, {5,1}, {6,0}, {5,2}, {4,4}, {4,5}, {4,6}, {4,7}, {5,3}, {6,1}, {6,2}, {5,4},
+ {5,5}, {5,6}, {5,7}, {6,3}, {7,0}, {7,1}, {6,4}, {6,5}, {6,6}, {6,7}, {7,2}, {7,3}, {7,4}, {7,5}, {7,6}, {7,7}
+};
+
+static const byte FIELD_SCAN8x8_1D[64] =
+{
+ 0, 8, 16, 1, 9, 24, 32, 17,
+ 2, 25, 40, 48, 56, 33, 10, 3,
+ 18, 41, 49, 57, 26, 11, 4, 19,
+ 34, 42, 50, 58, 27, 12, 5, 20,
+ 35, 43, 51, 59, 28, 13, 6, 21,
+ 36, 44, 52, 60, 29, 14, 22, 37,
+ 45, 53, 61, 30, 7, 15, 38, 46,
+ 54, 62, 23, 31, 39, 47, 55, 63
+};
+//! single scan pattern
+static const byte SCAN_YUV422[8][2] =
+{
+ {0,0},{0,1},
+ {1,0},{0,2},
+ {0,3},{1,1},
+ {1,2},{1,3}
+};
+
+static const unsigned char cbp_blk_chroma[8][4] =
+{ {16, 17, 18, 19},
+ {20, 21, 22, 23},
+ {24, 25, 26, 27},
+ {28, 29, 30, 31},
+ {32, 33, 34, 35},
+ {36, 37, 38, 39},
+ {40, 41, 42, 43},
+ {44, 45, 46, 47}
+};
+
+static const unsigned char cofuv_blk_x[3][8][4] =
+{ { {0, 1, 0, 1},
+ {0, 1, 0, 1},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0} },
+
+ { {0, 1, 0, 1},
+ {0, 1, 0, 1},
+ {0, 1, 0, 1},
+ {0, 1, 0, 1},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0} },
+
+ { {0, 1, 0, 1},
+ {2, 3, 2, 3},
+ {0, 1, 0, 1},
+ {2, 3, 2, 3},
+ {0, 1, 0, 1},
+ {2, 3, 2, 3},
+ {0, 1, 0, 1},
+ {2, 3, 2, 3} }
+};
+
+static const unsigned char cofuv_blk_y[3][8][4] =
+{
+ { { 0, 0, 1, 1},
+ { 0, 0, 1, 1},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0} },
+
+ { { 0, 0, 1, 1},
+ { 2, 2, 3, 3},
+ { 0, 0, 1, 1},
+ { 2, 2, 3, 3},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0} },
+
+ { { 0, 0, 1, 1},
+ { 0, 0, 1, 1},
+ { 2, 2, 3, 3},
+ { 2, 2, 3, 3},
+ { 0, 0, 1, 1},
+ { 0, 0, 1, 1},
+ { 2, 2, 3, 3},
+ { 2, 2, 3, 3}}
+};
+
+
+extern void setup_slice_methods(Slice *currSlice);
+extern void get_neighbors(Macroblock *currMB, PixelPos *block, int mb_x, int mb_y, int blockshape_x);
+extern void get_neighbors0016(Macroblock *currMB, PixelPos *block);
+
+extern void start_macroblock (Slice *currSlice, Macroblock **currMB);
+extern int decode_one_macroblock(Macroblock *currMB, StorablePicture *dec_picture);
+extern Boolean exit_macroblock (Slice *currSlice, int eos_bit);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/mb_prediction.h b/Src/h264dec/ldecod/inc/mb_prediction.h
new file mode 100644
index 00000000..cea3bd45
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/mb_prediction.h
@@ -0,0 +1,33 @@
+
+/*!
+ *************************************************************************************
+ * \file mb_prediction.h
+ *
+ * \brief
+ * Functions for macroblock prediction
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Alexis Michael Tourapis <alexismt@ieee.org>
+ *************************************************************************************
+ */
+
+#ifndef _MB_PREDICTION_H_
+#define _MB_PREDICTION_H_
+
+extern int mb_pred_intra4x4 (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern int mb_pred_intra16x16 (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern int mb_pred_intra8x8 (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+
+extern void mb_pred_skip (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_sp_skip (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_p_inter8x8 (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_p_inter16x16(Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_p_inter16x8 (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_p_inter8x16 (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_b_dspatial (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_b_dtemporal (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_b_inter8x8 (Macroblock *currMB, ColorPlane curr_plane, struct video_image *image, StorablePicture *dec_picture);
+extern void mb_pred_ipcm (Macroblock *currMB);
+
+#endif
diff --git a/Src/h264dec/ldecod/inc/mbuffer.h b/Src/h264dec/ldecod/inc/mbuffer.h
new file mode 100644
index 00000000..c06e9fb0
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/mbuffer.h
@@ -0,0 +1,235 @@
+
+/*!
+ ***********************************************************************
+ * \file
+ * mbuffer.h
+ *
+ * \brief
+ * Frame buffer functions
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Karsten Sühring <suehring@hhi.de>
+ * - Alexis Michael Tourapis <alexismt@ieee.org>
+
+ * - Jill Boyce <jill.boyce@thomson.net>
+ * - Saurav K Bandyopadhyay <saurav@ieee.org>
+ * - Zhenyu Wu <Zhenyu.Wu@thomson.net
+ * - Purvin Pandit <Purvin.Pandit@thomson.net>
+ *
+ ***********************************************************************
+ */
+#ifndef _MBUFFER_H_
+#define _MBUFFER_H_
+
+#include "global.h"
+#include <bfc/platform/types.h>
+
+#define MAX_LIST_SIZE 33
+//! definition of pic motion parameters
+
+typedef struct pic_motion_params
+{
+ PicMotion **motion[2];
+ h264_ref_t ***field_references;
+ byte * mb_field; //!< field macroblock indicator
+ byte ** field_frame; //!< indicates if co_located is field or frame.
+ int padding[1];
+} PicMotionParams;
+
+typedef struct video_image
+{
+ imgpel **img;
+ imgpel *base_address;
+ size_t stride;
+ struct video_image *next; // for the memory cacher
+} VideoImage;
+//! definition a picture (field or frame)
+typedef struct storable_picture
+{
+ PictureStructure structure;
+
+ int poc;
+ int top_poc;
+ int bottom_poc;
+ int frame_poc;
+ h264_ref_t ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
+ h264_ref_t frm_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
+ h264_ref_t top_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
+ h264_ref_t bottom_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
+ unsigned frame_num;
+ unsigned recovery_frame;
+
+ int pic_num;
+ int long_term_pic_num;
+ int long_term_frame_idx;
+
+ byte is_long_term;
+ int used_for_reference;
+ int is_output;
+ int non_existing;
+
+ short max_slice_id;
+
+ int size_x, size_y, size_x_cr, size_y_cr;
+ int size_x_m1, size_y_m1, size_x_cr_m1, size_y_cr_m1;
+ int chroma_vector_adjustment;
+ int coded_frame;
+ int mb_aff_frame_flag;
+ unsigned PicWidthInMbs;
+ unsigned PicSizeInMbs;
+
+ //imgpel ** imgY; //!< Y picture component
+ union
+ {
+ VideoImage *plane_images[3]; // to ensure array alignment
+ struct
+ {
+ VideoImage *imgY;
+ VideoImage *imgUV[2]; //!< U and V picture components
+ };
+ };
+
+ struct pic_motion_params motion; //!< Motion info
+ struct pic_motion_params JVmotion[MAX_PLANE]; //!< Motion info for 4:4:4 independent mode decoding
+
+ short ** slice_id; //!< reference picture [mb_x][mb_y]
+
+ struct storable_picture *top_field; // for mb aff, if frame for referencing the top field
+ struct storable_picture *bottom_field; // for mb aff, if frame for referencing the bottom field
+ struct storable_picture *frame; // for mb aff, if field for referencing the combined frame
+
+ int slice_type;
+ int idr_flag;
+ int no_output_of_prior_pics_flag;
+ int long_term_reference_flag;
+ int adaptive_ref_pic_buffering_flag;
+
+ int chroma_format_idc;
+ int frame_mbs_only_flag;
+ int frame_cropping_flag;
+ int frame_cropping_rect_left_offset;
+ int frame_cropping_rect_right_offset;
+ int frame_cropping_rect_top_offset;
+ int frame_cropping_rect_bottom_offset;
+ int qp;
+ int chroma_qp_offset[2];
+ int slice_qp_delta;
+ DecRefPicMarking_t *dec_ref_pic_marking_buffer; //!< stores the memory management control operations
+
+ // picture error concealment
+ int concealed_pic; //indicates if this is a concealed picture
+
+ // variables for tone mapping
+ int seiHasTone_mapping;
+ int tone_mapping_model_id;
+ int tonemapped_bit_depth;
+ imgpel* tone_mapping_lut; //!< tone mapping look up table
+
+ int retain_count; // benski> we're going to reference count these things
+ uint64_t time_code; // user-passed timecode for this frame
+} StorablePicture;
+
+//! definition a picture (field or frame)
+typedef struct colocated_params
+{
+ int mb_adaptive_frame_field_flag;
+ int size_x, size_y;
+ byte is_long_term;
+
+ MotionParams frame;
+ MotionParams top;
+ MotionParams bottom;
+
+} ColocatedParams;
+
+//! Frame Stores for Decoded Picture Buffer
+typedef struct frame_store
+{
+ int is_used; //!< 0=empty; 1=top; 2=bottom; 3=both fields (or frame)
+ int is_reference; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
+ int is_long_term; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
+ int is_orig_reference; //!< original marking by nal_ref_idc: 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
+
+ int is_non_existent;
+
+ unsigned frame_num;
+ unsigned recovery_frame;
+
+ int frame_num_wrap;
+ int long_term_frame_idx;
+ int is_output;
+ int poc;
+
+ // picture error concealment
+ int concealment_reference;
+
+ StorablePicture *frame;
+ StorablePicture *top_field;
+ StorablePicture *bottom_field;
+
+} FrameStore;
+
+
+//! Decoded Picture Buffer
+typedef struct decoded_picture_buffer
+{
+ VideoParameters *p_Vid;
+ InputParameters *p_Inp;
+ FrameStore **fs;
+ FrameStore **fs_ref;
+ FrameStore **fs_ltref;
+ unsigned size;
+ unsigned used_size;
+ unsigned ref_frames_in_buffer;
+ unsigned ltref_frames_in_buffer;
+ int last_output_poc;
+ int max_long_term_pic_idx;
+
+ int init_done;
+ int num_ref_frames;
+
+ FrameStore *last_picture;
+} DecodedPictureBuffer;
+
+extern void init_dpb(VideoParameters *p_Vid);
+extern void free_dpb(VideoParameters *p_Vid);
+extern FrameStore* alloc_frame_store(void);
+extern void free_frame_store(VideoParameters *p_Vid, FrameStore* f);
+extern StorablePicture* alloc_storable_picture(VideoParameters *p_Vid, PictureStructure type, int size_x, int size_y, int size_x_cr, int size_y_cr);
+extern void free_storable_picture(VideoParameters *p_Vid, StorablePicture* p);
+extern void store_picture_in_dpb(VideoParameters *p_Vid, StorablePicture* p);
+extern void flush_dpb(VideoParameters *p_Vid);
+
+extern void dpb_split_field (VideoParameters *p_Vid, FrameStore *fs);
+extern void dpb_combine_field(VideoParameters *p_Vid, FrameStore *fs);
+extern void dpb_combine_field_yuv(VideoParameters *p_Vid, FrameStore *fs);
+
+extern void init_lists (Slice *currSlice);
+extern void reorder_ref_pic_list(VideoParameters *p_Vid, StorablePicture **list, char *list_size,
+ int num_ref_idx_lX_active_minus1, int *reordering_of_pic_nums_idc,
+ int *abs_diff_pic_num_minus1, int *long_term_pic_idx);
+
+extern void init_mbaff_lists(VideoParameters *p_Vid);
+extern void alloc_ref_pic_list_reordering_buffer(Slice *currSlice);
+extern void free_ref_pic_list_reordering_buffer(Slice *currSlice);
+
+extern void fill_frame_num_gap(VideoParameters *p_Vid);
+
+extern ColocatedParams* alloc_colocated(VideoParameters *p_Vid, int size_x, int size_y,int mb_adaptive_frame_field_flag);
+extern void free_colocated(VideoParameters *p_Vid, ColocatedParams* p);
+extern void compute_colocated (Slice *currSlice, ColocatedParams* p, StorablePicture **listX[6]);
+extern void compute_colocated_frames_mbs (Slice *currSlice, ColocatedParams* p, StorablePicture **listX[6]);
+
+// For 4:4:4 independent mode
+extern void compute_colocated_JV ( Slice *currSlice, ColocatedParams* p, StorablePicture **listX[6]);
+extern void copy_storable_param_JV( VideoParameters *p_Vid, PicMotionParams *JVplane, PicMotionParams *motion );
+
+// benski> decoded output pictures
+void out_storable_picture_get(VideoParameters *img, StorablePicture **pic);
+void out_storable_picture_add(VideoParameters *img, StorablePicture *pic);
+void out_storable_pictures_init(VideoParameters *img, size_t count);
+void out_storable_pictures_destroy(VideoParameters *img);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/mc_prediction.h b/Src/h264dec/ldecod/inc/mc_prediction.h
new file mode 100644
index 00000000..e3165e27
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/mc_prediction.h
@@ -0,0 +1,61 @@
+
+/*!
+ *************************************************************************************
+ * \file mc_prediction.h
+ *
+ * \brief
+ * definitions for motion compensated prediction
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright,
+ * address and affiliation details)
+ * - Alexis Michael Tourapis <alexismt@ieee.org>
+ *
+ *************************************************************************************
+ */
+
+#ifndef _MC_PREDICTION_H_
+#define _MC_PREDICTION_H_
+
+#include "global.h"
+#include "mbuffer.h"
+
+extern void get_block_luma (Macroblock *currMB, ColorPlane pl, StorablePicture *list, int x_pos, int y_pos, const short *motion_vector, int ver_block_size, int hor_block_size, h264_imgpel_macroblock_t block);
+
+extern void intra_cr_decoding (Macroblock *currMB, int yuv);
+extern void prepare_direct_params(Macroblock *currMB, StorablePicture *dec_picture, short pmvl0[2], short pmvl1[2],char *l0_rFrame, char *l1_rFrame);
+extern void perform_mc (Macroblock *currMB, ColorPlane pl, StorablePicture *dec_picture, int pred_dir, int i, int j, int list_offset, int block_size_x, int block_size_y, int curr_mb_field);
+extern void perform_mc16x16 (Macroblock *currMB, ColorPlane pl, StorablePicture *dec_picture, int pred_dir, int list_offset, int curr_mb_field);
+extern void perform_mc16x8 (Macroblock *currMB, ColorPlane pl, StorablePicture *dec_picture, int pred_dir, int i, int j, int list_offset, int curr_mb_field);
+extern void perform_mc8x8 (Macroblock *currMB, ColorPlane pl, StorablePicture *dec_picture, int pred_dir, int i, int j, int list_offset, int curr_mb_field);
+extern void perform_mc8x16 (Macroblock *currMB, ColorPlane pl, StorablePicture *dec_picture, int pred_dir, int i, int j, int list_offset, int curr_mb_field);
+
+void weighted_mc_prediction16x16_sse2(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+void weighted_mc_prediction16x16_ipp(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+void weighted_mc_prediction16x16_c(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+
+void weighted_mc_prediction16x8_sse2(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+void weighted_mc_prediction16x8_ipp(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+void weighted_mc_prediction16x8_c(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+
+void weighted_mc_prediction8x8_sse2(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+void weighted_mc_prediction8x8_ipp(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+void weighted_mc_prediction8x8_c(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+
+void weighted_bi_prediction8x8_sse2(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+void weighted_bi_prediction8x8_ipp(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+void weighted_bi_prediction8x8_c(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+
+void weighted_bi_prediction16x16_sse2(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+void weighted_bi_prediction16x16_ipp(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+void weighted_bi_prediction16x16_c(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+
+void weighted_bi_prediction16x8_sse2(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+void weighted_bi_prediction16x8_ipp(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+void weighted_bi_prediction16x8_c(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+
+void bi_prediction8x8_sse2(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0);
+void bi_prediction8x8_ipp(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/meminput.h b/Src/h264dec/ldecod/inc/meminput.h
new file mode 100644
index 00000000..babaf2f0
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/meminput.h
@@ -0,0 +1,26 @@
+#ifndef _MEMINPUT_H
+#define _MEMINPUT_H
+#pragma once
+
+#include "nalucommon.h"
+#include <bfc/platform/types.h>
+
+typedef struct memory_input_struct
+{
+ const uint8_t *user_buffer;
+ size_t user_buffer_size;
+ size_t user_buffer_read;
+
+ uint8_t *Buf;
+ int resetting;
+ int skip_b_frames;
+} memory_input_t;
+
+int GetMemoryNALU (VideoParameters *p_Vid, NALU_t *nalu);
+void OpenMemory(VideoParameters *p_Vid, const char *fn);
+void CloseMemory(VideoParameters *p_Vid);
+void malloc_mem_input(VideoParameters *p_Vid);
+void free_mem_input(VideoParameters *p_Vid);
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/nalu.h b/Src/h264dec/ldecod/inc/nalu.h
new file mode 100644
index 00000000..d10e6bfa
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/nalu.h
@@ -0,0 +1,28 @@
+
+/*!
+ **************************************************************************************
+ * \file
+ * nalu.h
+ * \brief
+ * Common NALU support functions
+ *
+ * \date 25 November 2002
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Stephan Wenger <stewe@cs.tu-berlin.de>
+ ***************************************************************************************
+ */
+
+
+#ifndef _NALU_H_
+#define _NALU_H_
+
+#include "nalucommon.h"
+
+extern void initBitsFile (VideoParameters *p_Vid);
+extern void CheckZeroByteNonVCL(VideoParameters *p_Vid, NALU_t *nalu);
+extern void CheckZeroByteVCL (VideoParameters *p_Vid, NALU_t *nalu);
+
+extern int read_next_nalu(VideoParameters *p_Vid, NALU_t *nalu);
+
+#endif
diff --git a/Src/h264dec/ldecod/inc/optim.h b/Src/h264dec/ldecod/inc/optim.h
new file mode 100644
index 00000000..bfcc07f8
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/optim.h
@@ -0,0 +1,46 @@
+#pragma once
+
+typedef struct optimized_functions
+{
+ //void (*itrans4x4)(const h264_short_macroblock_t tblock, const h264_imgpel_macroblock_t mb_pred, h264_imgpel_macroblock_t mb_rec, int pos_x, int pos_y);
+ void (*itrans8x8)(h264_imgpel_macroblock_row_t *mb_rec, const h264_imgpel_macroblock_row_t *mb_pred, const h264_short_8x8block_row_t *block, int pos_x);
+
+ void (*weighted_mc_prediction16x16)(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+ void (*weighted_mc_prediction16x8)(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+ void (*weighted_mc_prediction8x8)(h264_imgpel_macroblock_row_t *mb_pred, int wp_scale, int wp_offset, int weight_denom);
+
+ void (*weighted_bi_prediction16x16)(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+ void (*weighted_bi_prediction16x8)(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+ void (*weighted_bi_prediction8x8)(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0, int wp_scale_l0, int wp_scale_l1, int wp_offset, int weight_denom);
+
+ void (*bi_prediction8x8)(h264_imgpel_macroblock_row_t *mb_pred, const h264_imgpel_macroblock_t block_l0);
+
+ void (*copy_image_data_16x16_stride)(struct video_image *destination, int dest_x, int dest_y, const h264_imgpel_macroblock_t source);
+ int (*code_from_bitstream_2d_5_4)(SyntaxElement *sym, Bitstream *currStream, const uint8_t *lentab, const uint8_t *codtab, const uint8_t *masktab);
+ int (*code_from_bitstream_2d_17_4)(SyntaxElement *sym, Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
+ int (*code_from_bitstream_2d_16_1)(Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
+} OptimizedFunctions;
+
+extern OptimizedFunctions opt;
+
+/* define macros for these function calls. this way we could do specific builds that call the functions directly, if we have the need */
+#ifdef _DEBUG
+#define opt_itrans4x4 (itrans4x4_c)
+#else
+#define opt_itrans4x4 (itrans4x4_mmx)
+#endif
+#define opt_itrans8x8 (opt.itrans8x8)
+
+#define opt_weighted_mc_prediction16x16 (opt.weighted_mc_prediction16x16)
+#define opt_weighted_mc_prediction16x8 (opt.weighted_mc_prediction16x8)
+#define opt_weighted_mc_prediction8x8 (opt.weighted_mc_prediction8x8)
+
+#define opt_weighted_bi_prediction16x16 (opt.weighted_bi_prediction16x16)
+#define opt_weighted_bi_prediction16x8 (opt.weighted_bi_prediction16x8)
+#define opt_weighted_bi_prediction8x8 (opt.weighted_bi_prediction8x8)
+
+#define opt_bi_prediction8x8 (opt.bi_prediction8x8)
+#define opt_copy_image_data_16x16_stride (opt.copy_image_data_16x16_stride)
+#define opt_code_from_bitstream_2d_5_4 (opt.code_from_bitstream_2d_5_4)
+#define opt_code_from_bitstream_2d_17_4 (opt.code_from_bitstream_2d_17_4)
+#define opt_code_from_bitstream_2d_16_1 (opt.code_from_bitstream_2d_16_1) \ No newline at end of file
diff --git a/Src/h264dec/ldecod/inc/output.h b/Src/h264dec/ldecod/inc/output.h
new file mode 100644
index 00000000..69e06f85
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/output.h
@@ -0,0 +1,27 @@
+
+/*!
+ **************************************************************************************
+ * \file
+ * output.h
+ * \brief
+ * Picture writing routine headers
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Karsten Suehring <suehring@hhi.de>
+ ***************************************************************************************
+ */
+
+#ifndef _OUTPUT_H_
+#define _OUTPUT_H_
+
+
+extern void write_stored_frame(VideoParameters *p_Vid, FrameStore *fs);
+extern void direct_output (VideoParameters *p_Vid, StorablePicture *p);
+extern void init_out_buffer (VideoParameters *p_Vid);
+extern void uninit_out_buffer (VideoParameters *p_Vid);
+
+#if (PAIR_FIELDS_IN_OUTPUT)
+extern void flush_pending_output(VideoParameters *p_Vid);
+#endif
+
+#endif //_OUTPUT_H_
diff --git a/Src/h264dec/ldecod/inc/parset.h b/Src/h264dec/ldecod/inc/parset.h
new file mode 100644
index 00000000..c433c26d
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/parset.h
@@ -0,0 +1,56 @@
+
+/*!
+ **************************************************************************************
+ * \file
+ * parset.h
+ * \brief
+ * Picture and Sequence Parameter Sets, decoder operations
+ *
+ * \date 25 November 2002
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Stephan Wenger <stewe@cs.tu-berlin.de>
+ ***************************************************************************************
+ */
+
+
+#ifndef _PARSET_H_
+#define _PARSET_H_
+
+#include "parsetcommon.h"
+#include "nalucommon.h"
+
+static const byte ZZ_SCAN[16] =
+{ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
+};
+
+static const byte ZZ_SCAN8[64] =
+{ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
+};
+
+extern void Scaling_List(int *scalingList, int sizeOfScalingList, Boolean *UseDefaultScalingMatrix, Bitstream *s);
+
+extern void InitVUI(seq_parameter_set_rbsp_t *sps);
+extern int ReadVUI(DataPartition *p, seq_parameter_set_rbsp_t *sps);
+extern int ReadHRDParameters(DataPartition *p, hrd_parameters_t *hrd);
+
+extern void PPSConsistencyCheck (pic_parameter_set_rbsp_t *pps);
+extern void SPSConsistencyCheck (seq_parameter_set_rbsp_t *sps);
+
+extern void MakePPSavailable (VideoParameters *p_Vid, int id, pic_parameter_set_rbsp_t *pps);
+extern void MakeSPSavailable (VideoParameters *p_Vid, int id, seq_parameter_set_rbsp_t *sps);
+
+extern void ProcessSPS (VideoParameters *p_Vid, NALU_t *nalu);
+extern void ProcessPPS (VideoParameters *p_Vid, NALU_t *nalu);
+
+extern void UseParameterSet (Slice *currSlice, int PicParsetId);
+
+extern void CleanUpPPS(VideoParameters *p_Vid);
+
+extern void activate_sps (VideoParameters *p_Vid, seq_parameter_set_rbsp_t *sps);
+extern void activate_pps (VideoParameters *p_Vid, pic_parameter_set_rbsp_t *pps);
+
+#endif
diff --git a/Src/h264dec/ldecod/inc/parsetcommon.h b/Src/h264dec/ldecod/inc/parsetcommon.h
new file mode 100644
index 00000000..16a64098
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/parsetcommon.h
@@ -0,0 +1,202 @@
+
+/*!
+ **************************************************************************************
+ * \file
+ * parsetcommon.h
+ * \brief
+ * Picture and Sequence Parameter Sets, structures common to encoder and decoder
+ *
+ * \date 25 November 2002
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Stephan Wenger <stewe@cs.tu-berlin.de>
+ ***************************************************************************************
+ */
+
+
+
+// In the JVT syntax, frequently flags are used that indicate the presence of
+// certain pieces of information in the NALU. Here, these flags are also
+// present. In the encoder, those bits indicate that the values signaled to
+// be present are meaningful and that this part of the syntax should be
+// written to the NALU. In the decoder, the flag indicates that information
+// was received from the decoded NALU and should be used henceforth.
+// The structure names were chosen as indicated in the JVT syntax
+
+#ifndef _PARSETCOMMON_H_
+#define _PARSETCOMMON_H_
+
+#include "defines.h"
+
+#define MAXIMUMPARSETRBSPSIZE 1500
+#define MAXIMUMPARSETNALUSIZE 1500
+
+#define MAXSPS 32
+#define MAXPPS 256
+
+#define MAXIMUMVALUEOFcpb_cnt 32
+typedef struct
+{
+ unsigned int cpb_cnt_minus1; // ue(v)
+ unsigned int bit_rate_scale; // u(4)
+ unsigned int cpb_size_scale; // u(4)
+ unsigned int bit_rate_value_minus1 [MAXIMUMVALUEOFcpb_cnt]; // ue(v)
+ unsigned int cpb_size_value_minus1 [MAXIMUMVALUEOFcpb_cnt]; // ue(v)
+ unsigned int cbr_flag [MAXIMUMVALUEOFcpb_cnt]; // u(1)
+ unsigned int initial_cpb_removal_delay_length_minus1; // u(5)
+ unsigned int cpb_removal_delay_length_minus1; // u(5)
+ unsigned int dpb_output_delay_length_minus1; // u(5)
+ unsigned int time_offset_length; // u(5)
+} hrd_parameters_t;
+
+
+typedef struct
+{
+ Boolean aspect_ratio_info_present_flag; // u(1)
+ unsigned int aspect_ratio_idc; // u(8)
+ unsigned short sar_width; // u(16)
+ unsigned short sar_height; // u(16)
+ Boolean overscan_info_present_flag; // u(1)
+ Boolean overscan_appropriate_flag; // u(1)
+ Boolean video_signal_type_present_flag; // u(1)
+ unsigned int video_format; // u(3)
+ Boolean video_full_range_flag; // u(1)
+ Boolean colour_description_present_flag; // u(1)
+ unsigned int colour_primaries; // u(8)
+ unsigned int transfer_characteristics; // u(8)
+ unsigned int matrix_coefficients; // u(8)
+ Boolean chroma_location_info_present_flag; // u(1)
+ unsigned int chroma_sample_loc_type_top_field; // ue(v)
+ unsigned int chroma_sample_loc_type_bottom_field; // ue(v)
+ Boolean timing_info_present_flag; // u(1)
+ unsigned int num_units_in_tick; // u(32)
+ unsigned int time_scale; // u(32)
+ Boolean fixed_frame_rate_flag; // u(1)
+ Boolean nal_hrd_parameters_present_flag; // u(1)
+ hrd_parameters_t nal_hrd_parameters; // hrd_paramters_t
+ Boolean vcl_hrd_parameters_present_flag; // u(1)
+ hrd_parameters_t vcl_hrd_parameters; // hrd_paramters_t
+ // if ((nal_hrd_parameters_present_flag || (vcl_hrd_parameters_present_flag))
+ Boolean low_delay_hrd_flag; // u(1)
+ Boolean pic_struct_present_flag; // u(1)
+ Boolean bitstream_restriction_flag; // u(1)
+ Boolean motion_vectors_over_pic_boundaries_flag; // u(1)
+ unsigned int max_bytes_per_pic_denom; // ue(v)
+ unsigned int max_bits_per_mb_denom; // ue(v)
+ unsigned int log2_max_mv_length_vertical; // ue(v)
+ unsigned int log2_max_mv_length_horizontal; // ue(v)
+ unsigned int num_reorder_frames; // ue(v)
+ unsigned int max_dec_frame_buffering; // ue(v)
+} vui_seq_parameters_t;
+
+
+#define MAXnum_slice_groups_minus1 8
+typedef struct
+{
+ Boolean Valid; // indicates the parameter set is valid
+ unsigned int pic_parameter_set_id; // ue(v)
+ unsigned int seq_parameter_set_id; // ue(v)
+ Boolean entropy_coding_mode_flag; // u(1)
+ Boolean transform_8x8_mode_flag; // u(1)
+
+ Boolean pic_scaling_matrix_present_flag; // u(1)
+ int pic_scaling_list_present_flag[12]; // u(1)
+ int ScalingList4x4[6][16]; // se(v)
+ int ScalingList8x8[6][64]; // se(v)
+ Boolean UseDefaultScalingMatrix4x4Flag[6];
+ Boolean UseDefaultScalingMatrix8x8Flag[6];
+
+ // if( pic_order_cnt_type < 2 ) in the sequence parameter set
+ Boolean bottom_field_pic_order_in_frame_present_flag; // u(1)
+ unsigned int num_slice_groups_minus1; // ue(v)
+ unsigned int slice_group_map_type; // ue(v)
+ // if( slice_group_map_type = = 0 )
+ unsigned int run_length_minus1[MAXnum_slice_groups_minus1]; // ue(v)
+ // else if( slice_group_map_type = = 2 )
+ unsigned int top_left[MAXnum_slice_groups_minus1]; // ue(v)
+ unsigned int bottom_right[MAXnum_slice_groups_minus1]; // ue(v)
+ // else if( slice_group_map_type = = 3 || 4 || 5
+ Boolean slice_group_change_direction_flag; // u(1)
+ unsigned int slice_group_change_rate_minus1; // ue(v)
+ // else if( slice_group_map_type = = 6 )
+ unsigned int pic_size_in_map_units_minus1; // ue(v)
+ byte *slice_group_id; // complete MBAmap u(v)
+
+ int num_ref_idx_l0_active_minus1; // ue(v)
+ int num_ref_idx_l1_active_minus1; // ue(v)
+ Boolean weighted_pred_flag; // u(1)
+ unsigned int weighted_bipred_idc; // u(2)
+ int pic_init_qp_minus26; // se(v)
+ int pic_init_qs_minus26; // se(v)
+ int chroma_qp_index_offset; // se(v)
+
+ int second_chroma_qp_index_offset; // se(v)
+
+ Boolean deblocking_filter_control_present_flag; // u(1)
+ Boolean constrained_intra_pred_flag; // u(1)
+ Boolean redundant_pic_cnt_present_flag; // u(1)
+} pic_parameter_set_rbsp_t;
+
+
+#define MAXnum_ref_frames_in_pic_order_cnt_cycle 256
+typedef struct
+{
+ Boolean Valid; // indicates the parameter set is valid
+
+ unsigned int profile_idc; // u(8)
+ Boolean constrained_set0_flag; // u(1)
+ Boolean constrained_set1_flag; // u(1)
+ Boolean constrained_set2_flag; // u(1)
+ Boolean constrained_set3_flag; // u(1)
+ unsigned int level_idc; // u(8)
+ unsigned int seq_parameter_set_id; // ue(v)
+ unsigned int chroma_format_idc; // ue(v)
+
+ Boolean seq_scaling_matrix_present_flag; // u(1)
+ int seq_scaling_list_present_flag[12]; // u(1)
+ int ScalingList4x4[6][16]; // se(v)
+ int ScalingList8x8[6][64]; // se(v)
+ Boolean UseDefaultScalingMatrix4x4Flag[6];
+ Boolean UseDefaultScalingMatrix8x8Flag[6];
+
+ unsigned int bit_depth_luma_minus8; // ue(v)
+ unsigned int bit_depth_chroma_minus8; // ue(v)
+ unsigned int log2_max_frame_num_minus4; // ue(v)
+ unsigned int pic_order_cnt_type;
+ // if( pic_order_cnt_type == 0 )
+ unsigned int log2_max_pic_order_cnt_lsb_minus4; // ue(v)
+ // else if( pic_order_cnt_type == 1 )
+ Boolean delta_pic_order_always_zero_flag; // u(1)
+ int offset_for_non_ref_pic; // se(v)
+ int offset_for_top_to_bottom_field; // se(v)
+ unsigned int num_ref_frames_in_pic_order_cnt_cycle; // ue(v)
+ // for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ )
+ int offset_for_ref_frame[MAXnum_ref_frames_in_pic_order_cnt_cycle]; // se(v)
+ unsigned int num_ref_frames; // ue(v)
+ Boolean gaps_in_frame_num_value_allowed_flag; // u(1)
+ unsigned int pic_width_in_mbs_minus1; // ue(v)
+ unsigned int pic_height_in_map_units_minus1; // ue(v)
+ Boolean frame_mbs_only_flag; // u(1)
+ // if( !frame_mbs_only_flag )
+ Boolean mb_adaptive_frame_field_flag; // u(1)
+ Boolean direct_8x8_inference_flag; // u(1)
+ Boolean frame_cropping_flag; // u(1)
+ unsigned int frame_cropping_rect_left_offset; // ue(v)
+ unsigned int frame_cropping_rect_right_offset; // ue(v)
+ unsigned int frame_cropping_rect_top_offset; // ue(v)
+ unsigned int frame_cropping_rect_bottom_offset; // ue(v)
+ Boolean vui_parameters_present_flag; // u(1)
+ vui_seq_parameters_t vui_seq_parameters; // vui_seq_parameters_t
+ unsigned separate_colour_plane_flag; // u(1)
+} seq_parameter_set_rbsp_t;
+
+pic_parameter_set_rbsp_t *AllocPPS (void);
+seq_parameter_set_rbsp_t *AllocSPS (void);
+
+void FreePPS (pic_parameter_set_rbsp_t *pps);
+void FreeSPS (seq_parameter_set_rbsp_t *sps);
+
+int sps_is_equal(seq_parameter_set_rbsp_t *sps1, seq_parameter_set_rbsp_t *sps2);
+int pps_is_equal(pic_parameter_set_rbsp_t *pps1, pic_parameter_set_rbsp_t *pps2);
+
+#endif
diff --git a/Src/h264dec/ldecod/inc/quant.h b/Src/h264dec/ldecod/inc/quant.h
new file mode 100644
index 00000000..01bde65f
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/quant.h
@@ -0,0 +1,169 @@
+
+/*!
+ ************************************************************************
+ * \file quant.h
+ *
+ * \brief
+ * definitions for quantization functions
+ *
+ * \author
+ *
+ ************************************************************************
+ */
+
+#ifndef _QUANT_H_
+#define _QUANT_H_
+
+// exported variables
+static const int dequant_coef8[6][64] =
+{
+ {
+ 20, 19, 25, 19, 20, 19, 25, 19,
+ 19, 18, 24, 18, 19, 18, 24, 18,
+ 25, 24, 32, 24, 25, 24, 32, 24,
+ 19, 18, 24, 18, 19, 18, 24, 18,
+ 20, 19, 25, 19, 20, 19, 25, 19,
+ 19, 18, 24, 18, 19, 18, 24, 18,
+ 25, 24, 32, 24, 25, 24, 32, 24,
+ 19, 18, 24, 18, 19, 18, 24, 18
+ },
+ {
+ 22, 21, 28, 21, 22, 21, 28, 21,
+ 21, 19, 26, 19, 21, 19, 26, 19,
+ 28, 26, 35, 26, 28, 26, 35, 26,
+ 21, 19, 26, 19, 21, 19, 26, 19,
+ 22, 21, 28, 21, 22, 21, 28, 21,
+ 21, 19, 26, 19, 21, 19, 26, 19,
+ 28, 26, 35, 26, 28, 26, 35, 26,
+ 21, 19, 26, 19, 21, 19, 26, 19
+ },
+ {
+ 26, 24, 33, 24, 26, 24, 33, 24,
+ 24, 23, 31, 23, 24, 23, 31, 23,
+ 33, 31, 42, 31, 33, 31, 42, 31,
+ 24, 23, 31, 23, 24, 23, 31, 23,
+ 26, 24, 33, 24, 26, 24, 33, 24,
+ 24, 23, 31, 23, 24, 23, 31, 23,
+ 33, 31, 42, 31, 33, 31, 42, 31,
+ 24, 23, 31, 23, 24, 23, 31, 23
+ },
+ {
+ 28, 26, 35, 26, 28, 26, 35, 26,
+ 26, 25, 33, 25, 26, 25, 33, 25,
+ 35, 33, 45, 33, 35, 33, 45, 33,
+ 26, 25, 33, 25, 26, 25, 33, 25,
+ 28, 26, 35, 26, 28, 26, 35, 26,
+ 26, 25, 33, 25, 26, 25, 33, 25,
+ 35, 33, 45, 33, 35, 33, 45, 33,
+ 26, 25, 33, 25, 26, 25, 33, 25
+ },
+ {
+ 32, 30, 40, 30, 32, 30, 40, 30,
+ 30, 28, 38, 28, 30, 28, 38, 28,
+ 40, 38, 51, 38, 40, 38, 51, 38,
+ 30, 28, 38, 28, 30, 28, 38, 28,
+ 32, 30, 40, 30, 32, 30, 40, 30,
+ 30, 28, 38, 28, 30, 28, 38, 28,
+ 40, 38, 51, 38, 40, 38, 51, 38,
+ 30, 28, 38, 28, 30, 28, 38, 28
+ },
+ {
+ 36, 34, 46, 34, 36, 34, 46, 34,
+ 34, 32, 43, 32, 34, 32, 43, 32,
+ 46, 43, 58, 43, 46, 43, 58, 43,
+ 34, 32, 43, 32, 34, 32, 43, 32,
+ 36, 34, 46, 34, 36, 34, 46, 34,
+ 34, 32, 43, 32, 34, 32, 43, 32,
+ 46, 43, 58, 43, 46, 43, 58, 43,
+ 34, 32, 43, 32, 34, 32, 43, 32
+ }
+};
+
+
+//! Dequantization coefficients
+static const int dequant_coef[6][4][4] = {
+ {
+ { 10, 13, 10, 13},
+ { 13, 16, 13, 16},
+ { 10, 13, 10, 13},
+ { 13, 16, 13, 16}},
+ {
+ { 11, 14, 11, 14},
+ { 14, 18, 14, 18},
+ { 11, 14, 11, 14},
+ { 14, 18, 14, 18}},
+ {
+ { 13, 16, 13, 16},
+ { 16, 20, 16, 20},
+ { 13, 16, 13, 16},
+ { 16, 20, 16, 20}},
+ {
+ { 14, 18, 14, 18},
+ { 18, 23, 18, 23},
+ { 14, 18, 14, 18},
+ { 18, 23, 18, 23}},
+ {
+ { 16, 20, 16, 20},
+ { 20, 25, 20, 25},
+ { 16, 20, 16, 20},
+ { 20, 25, 20, 25}},
+ {
+ { 18, 23, 18, 23},
+ { 23, 29, 23, 29},
+ { 18, 23, 18, 23},
+ { 23, 29, 23, 29}}
+};
+
+static const int quant_coef[6][4][4] = {
+ {
+ { 13107, 8066, 13107, 8066},
+ { 8066, 5243, 8066, 5243},
+ { 13107, 8066, 13107, 8066},
+ { 8066, 5243, 8066, 5243}},
+ {
+ { 11916, 7490, 11916, 7490},
+ { 7490, 4660, 7490, 4660},
+ { 11916, 7490, 11916, 7490},
+ { 7490, 4660, 7490, 4660}},
+ {
+ { 10082, 6554, 10082, 6554},
+ { 6554, 4194, 6554, 4194},
+ { 10082, 6554, 10082, 6554},
+ { 6554, 4194, 6554, 4194}},
+ {
+ { 9362, 5825, 9362, 5825},
+ { 5825, 3647, 5825, 3647},
+ { 9362, 5825, 9362, 5825},
+ { 5825, 3647, 5825, 3647}},
+ {
+ { 8192, 5243, 8192, 5243},
+ { 5243, 3355, 5243, 3355},
+ { 8192, 5243, 8192, 5243},
+ { 5243, 3355, 5243, 3355}},
+ {
+ { 7282, 4559, 7282, 4559},
+ { 4559, 2893, 4559, 2893},
+ { 7282, 4559, 7282, 4559},
+ { 4559, 2893, 4559, 2893}}
+};
+
+// SP decoding parameter (EQ. 8-425)
+static const int A[4][4] = {
+ { 16, 20, 16, 20},
+ { 20, 25, 20, 25},
+ { 16, 20, 16, 20},
+ { 20, 25, 20, 25}
+};
+
+// exported functions
+// quantization initialization
+extern void init_qp_process (VideoParameters *p_Vid);
+extern void free_qp_matrices(VideoParameters *p_Vid);
+
+// For Q-matrix
+extern void assign_quant_params (Slice *currslice);
+extern void CalculateQuant4x4Param(Slice *currslice);
+
+
+#endif
+
diff --git a/Src/h264dec/ldecod/inc/sei.h b/Src/h264dec/ldecod/inc/sei.h
new file mode 100644
index 00000000..943428fd
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/sei.h
@@ -0,0 +1,100 @@
+
+/*!
+ *************************************************************************************
+ * \file sei.h
+ *
+ * \brief
+ * Prototypes for sei.c
+ *************************************************************************************
+ */
+
+#ifndef SEI_H
+#define SEI_H
+
+typedef enum {
+ SEI_BUFFERING_PERIOD = 0,
+ SEI_PIC_TIMING,
+ SEI_PAN_SCAN_RECT,
+ SEI_FILLER_PAYLOAD,
+ SEI_USER_DATA_REGISTERED_ITU_T_T35,
+ SEI_USER_DATA_UNREGISTERED,
+ SEI_RECOVERY_POINT,
+ SEI_DEC_REF_PIC_MARKING_REPETITION,
+ SEI_SPARE_PIC,
+ SEI_SCENE_INFO,
+ SEI_SUB_SEQ_INFO,
+ SEI_SUB_SEQ_LAYER_CHARACTERISTICS,
+ SEI_SUB_SEQ_CHARACTERISTICS,
+ SEI_FULL_FRAME_FREEZE,
+ SEI_FULL_FRAME_FREEZE_RELEASE,
+ SEI_FULL_FRAME_SNAPSHOT,
+ SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START,
+ SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END,
+ SEI_MOTION_CONSTRAINED_SLICE_GROUP_SET,
+ SEI_FILM_GRAIN_CHARACTERISTICS,
+ SEI_DEBLOCKING_FILTER_DISPLAY_PREFERENCE,
+ SEI_STEREO_VIDEO_INFO,
+ SEI_POST_FILTER_HINTS,
+ SEI_TONE_MAPPING,
+
+ SEI_MAX_ELEMENTS //!< number of maximum syntax elements
+} SEI_type;
+
+#define MAX_FN 256
+// tone mapping information
+#define MAX_CODED_BIT_DEPTH 12
+#define MAX_SEI_BIT_DEPTH 12
+#define MAX_NUM_PIVOTS (1<<MAX_CODED_BIT_DEPTH)
+
+#if (ENABLE_OUTPUT_TONEMAPPING)
+typedef struct tone_mapping_struct_s
+{
+ Boolean seiHasTone_mapping;
+ unsigned int tone_map_repetition_period;
+ unsigned char coded_data_bit_depth;
+ unsigned char sei_bit_depth;
+ unsigned int model_id;
+ unsigned int count;
+
+ imgpel lut[1<<MAX_CODED_BIT_DEPTH]; //<! look up table for mapping the coded data value to output data value
+
+ Bitstream *data;
+ int payloadSize;
+} ToneMappingSEI;
+
+#endif
+
+void InterpretSEIMessage(byte* msg, int size, VideoParameters *p_Vid);
+void interpret_spare_pic( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_subsequence_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_subsequence_layer_characteristics_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_subsequence_characteristics_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_scene_information( byte* payload, int size, VideoParameters *p_Vid ); // JVT-D099
+void interpret_user_data_registered_itu_t_t35_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_user_data_unregistered_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_pan_scan_rect_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_recovery_point_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_filler_payload_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_dec_ref_pic_marking_repetition_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_full_frame_freeze_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_full_frame_freeze_release_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_full_frame_snapshot_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_progressive_refinement_start_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_progressive_refinement_end_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_motion_constrained_slice_group_set_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_reserved_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_buffering_period_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_picture_timing_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_film_grain_characteristics_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_deblocking_filter_display_preference_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_stereo_video_info_info( byte* payload, int size, VideoParameters *p_Vid );
+void interpret_post_filter_hints_info( byte* payload, int size, VideoParameters *p_Vid );
+// functions for tone mapping SEI message
+void interpret_tone_mapping( byte* payload, int size, VideoParameters *p_Vid );
+
+#if (ENABLE_OUTPUT_TONEMAPPING)
+void tone_map(imgpel** imgX, imgpel* lut, int size_x, int size_y);
+void init_tone_mapping_sei(ToneMappingSEI *seiToneMapping);
+void update_tone_mapping_sei(ToneMappingSEI *seiToneMapping);
+#endif
+#endif
diff --git a/Src/h264dec/ldecod/inc/transform8x8.h b/Src/h264dec/ldecod/inc/transform8x8.h
new file mode 100644
index 00000000..88cfafee
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/transform8x8.h
@@ -0,0 +1,24 @@
+/*!
+ ***************************************************************************
+ *
+ * \file transform8x8.h
+ *
+ * \brief
+ * prototypes of 8x8 transform functions
+ *
+ * \date
+ * 9. October 2003
+ *
+ * \author
+ * Main contributors (see contributors.h for copyright, address and affiliation details)
+ * - Yuri Vatis
+ **************************************************************************/
+
+#ifndef _TRANSFORM8X8_H_
+#define _TRANSFORM8X8_H_
+
+extern void itrans8x8_mmx(h264_imgpel_macroblock_row_t *mb_rec, const h264_imgpel_macroblock_row_t *mb_pred, const h264_short_8x8block_row_t *block, int pos_x);
+extern void itrans8x8_sse2(h264_imgpel_macroblock_row_t *mb_rec, const h264_imgpel_macroblock_row_t *mb_pred, const h264_short_8x8block_row_t *block, int pos_x);
+extern void itrans8x8_c(h264_imgpel_macroblock_row_t *mb_rec, const h264_imgpel_macroblock_row_t *mb_pred, const h264_short_8x8block_row_t *block, int pos_x);
+extern void itrans8x8_lossless(h264_imgpel_macroblock_row_t *mb_rec, const h264_imgpel_macroblock_row_t *mb_pred, const h264_short_8x8block_row_t *block, int pos_x);
+#endif
diff --git a/Src/h264dec/ldecod/inc/vlc.h b/Src/h264dec/ldecod/inc/vlc.h
new file mode 100644
index 00000000..9a75ad3a
--- /dev/null
+++ b/Src/h264dec/ldecod/inc/vlc.h
@@ -0,0 +1,122 @@
+
+/*!
+ ************************************************************************
+ * \file vlc.h
+ *
+ * \brief
+ * header for (CA)VLC coding functions
+ *
+ * \author
+ * Karsten Suehring
+ *
+ ************************************************************************
+ */
+
+#ifndef _VLC_H_
+#define _VLC_H_
+
+#include <bfc/platform/types.h>
+
+//! gives CBP value from codeword number, both for intra and inter
+static const byte NCBP[2][48][2]=
+{
+ { // 0 1 2 3 4 5 6 7 8 9 10 11
+ {15, 0},{ 0, 1},{ 7, 2},{11, 4},{13, 8},{14, 3},{ 3, 5},{ 5,10},{10,12},{12,15},{ 1, 7},{ 2,11},
+ { 4,13},{ 8,14},{ 6, 6},{ 9, 9},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
+ { 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},
+ { 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0},{ 0, 0}
+ },
+ {
+ {47, 0},{31,16},{15, 1},{ 0, 2},{23, 4},{27, 8},{29,32},{30, 3},{ 7, 5},{11,10},{13,12},{14,15},
+ {39,47},{43, 7},{45,11},{46,13},{16,14},{ 3, 6},{ 5, 9},{10,31},{12,35},{19,37},{21,42},{26,44},
+ {28,33},{35,34},{37,36},{42,40},{44,39},{ 1,43},{ 2,45},{ 4,46},{ 8,17},{17,18},{18,20},{20,24},
+ {24,19},{ 6,21},{ 9,26},{22,28},{25,23},{32,27},{33,29},{34,30},{36,22},{40,25},{38,38},{41,41}
+ }
+};
+
+//! for the linfo_levrun_inter routine
+static const byte NTAB1[4][8][2] =
+{
+ {{1,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
+ {{1,1},{1,2},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
+ {{2,0},{1,3},{1,4},{1,5},{0,0},{0,0},{0,0},{0,0}},
+ {{3,0},{2,1},{2,2},{1,6},{1,7},{1,8},{1,9},{4,0}},
+};
+
+static const byte LEVRUN1[16]=
+{
+ 4,2,2,1,1,1,1,1,1,1,0,0,0,0,0,0,
+};
+
+
+static const byte NTAB2[4][8][2] =
+{
+ {{1,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
+ {{1,1},{2,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
+ {{1,2},{3,0},{4,0},{5,0},{0,0},{0,0},{0,0},{0,0}},
+ {{1,3},{1,4},{2,1},{3,1},{6,0},{7,0},{8,0},{9,0}},
+};
+
+//! for the linfo_levrun__c2x2 routine
+static const byte LEVRUN3[4] =
+{
+ 2,1,0,0
+};
+
+static const byte NTAB3[2][2][2] =
+{
+ {{1,0},{0,0}},
+ {{2,0},{1,1}},
+};
+
+extern int se_v (const char *tracestring, Bitstream *bitstream);
+extern int ue_v (const char *tracestring, Bitstream *bitstream);
+extern Boolean u_1 (const char *tracestring, Bitstream *bitstream);
+extern int u_v (int LenInBits, const char *tracestring, Bitstream *bitstream);
+extern int i_v (int LenInBits, const char *tracestring, Bitstream *bitstream);
+
+// CAVLC mapping
+extern void linfo_ue(int len, int info, int *value1, int *dummy);
+extern void linfo_se(int len, int info, int *value1, int *dummy);
+
+extern void linfo_cbp_intra_normal(int len,int info,int *cbp, int *dummy);
+extern void linfo_cbp_inter_normal(int len,int info,int *cbp, int *dummy);
+extern void linfo_cbp_intra_other(int len,int info,int *cbp, int *dummy);
+extern void linfo_cbp_inter_other(int len,int info,int *cbp, int *dummy);
+
+extern void linfo_levrun_inter(int len,int info,int *level,int *irun);
+extern void linfo_levrun_c2x2(int len,int info,int *level,int *irun);
+
+extern int uvlc_startcode_follows(Slice *currSlice, int dummy);
+
+extern int readSyntaxElement_VLC (SyntaxElement *sym, Bitstream *currStream);
+extern int readSyntaxElement_UVLC(SyntaxElement *, struct datapartition *);
+extern int readSyntaxElement_Intra4x4PredictionMode(SyntaxElement *sym, Bitstream *currStream);
+
+extern int GetVLCSymbol (const uint8_t buffer[],int totbitoffset,int *info, int bytecount);
+extern int GetVLCSymbol_IntraMode (const uint8_t buffer[],int totbitoffset,int *info, int bytecount);
+
+extern int readSyntaxElement_FLC (Bitstream *currStream, int numbits);
+extern int readSyntaxElement_NumCoeffTrailingOnes (SyntaxElement *sym, Bitstream *currStream, int vlcnum);
+extern int readSyntaxElement_NumCoeffTrailingOnesChromaDC(VideoParameters *p_Vid, SyntaxElement *sym, Bitstream *currStream);
+extern int readSyntaxElement_Level_VLC0 (Bitstream *currStream);
+extern int readSyntaxElement_Level_VLCN (int vlc, Bitstream *currStream);
+extern int readSyntaxElement_TotalZeros (Bitstream *currStream, int vlcnum);
+extern int readSyntaxElement_TotalZerosChromaDC (VideoParameters *p_Vid, Bitstream *currStream, int vlcnum);
+extern int readSyntaxElement_Run (Bitstream *currStream, int vlcnum);
+extern int GetBits (const uint8_t buffer[],int totbitoffset,int *info, int bitcount, int numbits);
+
+
+extern int more_rbsp_data (const uint8_t buffer[],int totbitoffset,int bytecount);
+
+int code_from_bitstream_2d_17_4_c(SyntaxElement *sym, Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
+int code_from_bitstream_2d_17_4_sse2(SyntaxElement *sym, Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
+
+int code_from_bitstream_2d_5_4_c(SyntaxElement *sym, Bitstream *currStream, const uint8_t *lentab, const uint8_t *codtab, const uint8_t *masktab);
+int code_from_bitstream_2d_5_4_sse2(SyntaxElement *sym, Bitstream *currStream, const uint8_t *lentab, const uint8_t *codtab, const uint8_t *masktab);
+
+int code_from_bitstream_2d_16_1_c(Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
+int code_from_bitstream_2d_16_1_sse2(Bitstream *currStream, const uint16_t *lentab, const uint16_t *codtab, const uint16_t *masktab);
+
+#endif
+