mixvbp: h264 parser refinement

BZ: 131068

1) remove redundant code;
2) add debug messages;

Change-Id: I1a624a257fcfcd1eb25519912797c41dae7f42a8
Signed-off-by: Dan Liang <dan.liang@intel.com>
Reviewed-on: http://android.intel.com:8080/139258
Reviewed-by: Shi, PingX <pingx.shi@intel.com>
Tested-by: Shi, PingX <pingx.shi@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: cactus <cactus@intel.com>
diff --git a/mixvbp/vbp_manager/include/viddec_pm.h b/mixvbp/vbp_manager/include/viddec_pm.h
index e5fb679..31bd0f4 100755
--- a/mixvbp/vbp_manager/include/viddec_pm.h
+++ b/mixvbp/vbp_manager/include/viddec_pm.h
@@ -28,11 +28,8 @@
     uint8_t late_frame_detect;
     uint8_t frame_start_found;
     uint32_t next_workload_error_eos;
-#ifdef VBP
+
     uint32_t codec_data[MAX_CODEC_CXT_SIZE<<3];
-#else
-    uint32_t codec_data[MAX_CODEC_CXT_SIZE>>2];
-#endif
 } viddec_pm_cxt_t;
 
 
diff --git a/mixvbp/vbp_manager/include/viddec_pm_utils_bstream.h b/mixvbp/vbp_manager/include/viddec_pm_utils_bstream.h
index 999a067..ab2569f 100755
--- a/mixvbp/vbp_manager/include/viddec_pm_utils_bstream.h
+++ b/mixvbp/vbp_manager/include/viddec_pm_utils_bstream.h
@@ -9,11 +9,7 @@
 
 typedef struct
 {
-#ifdef VBP
     uint8_t *buf;
-#else
-    uint8_t buf[CUBBY_SIZE + 8 + MIN_DATA];/* extra 8 bytes for alignmet, extra 8 bytes for old data */
-#endif
     uint32_t buf_st; /* start pos in buf */
     uint32_t buf_end; /* first invalid byte in buf */
     uint32_t buf_index; /* current index in buf */
@@ -30,10 +26,8 @@
 
 typedef struct
 {
-#ifdef VBP
     /* counter of emulation prevention byte */
     uint32_t emulation_byte_counter;
-#endif
     /* After First pass of scan we figure out how many bytes are in the current access unit(N bytes). We store
        the bstream buffer's first valid byte index wrt to accessunit in this variable */
     uint32_t au_pos;
@@ -72,17 +66,17 @@
  */
 static inline void viddec_pm_utils_bstream_get_au_offsets(viddec_pm_utils_bstream_cxt_t *cxt, uint32_t *bit, uint32_t *byte, uint8_t *is_emul)
 {
-    uint32_t phase=cxt->phase;
+    uint32_t phase = cxt->phase;
 
     *bit = cxt->bstrm_buf.buf_bitoff;
     *byte = cxt->au_pos + (cxt->bstrm_buf.buf_index - cxt->bstrm_buf.buf_st);
     if (cxt->phase > 0)
     {
-        phase = phase - ((cxt->bstrm_buf.buf_bitoff != 0)? 1: 0 );
+        phase = phase - ((cxt->bstrm_buf.buf_bitoff != 0) ? 1 : 0);
     }
     /* Assumption: we will never be parked on 0x3 byte of emulation prevention sequence */
     *is_emul = (cxt->is_emul_reqd) && (phase > 0) &&
                (cxt->bstrm_buf.buf[cxt->bstrm_buf.buf_index] == 0) &&
-               (cxt->bstrm_buf.buf[cxt->bstrm_buf.buf_index+1] == 0x3);
+               (cxt->bstrm_buf.buf[cxt->bstrm_buf.buf_index + 1] == 0x3);
 }
 #endif
diff --git a/mixvbp/vbp_manager/include/viddec_pm_utils_list.h b/mixvbp/vbp_manager/include/viddec_pm_utils_list.h
index 0e650d5..ac8a329 100755
--- a/mixvbp/vbp_manager/include/viddec_pm_utils_list.h
+++ b/mixvbp/vbp_manager/include/viddec_pm_utils_list.h
@@ -3,11 +3,7 @@
 
 /* Limitation:This is the maximum numbers of es buffers between start codes. Needs to change if we encounter
    a case if this is not sufficent */
-#ifdef VBP
 #define MAX_IBUFS_PER_SC 512
-#else
-#define MAX_IBUFS_PER_SC 64
-#endif
 
 /* This structure is for storing information on byte position in the current access unit.
    stpos is the au byte index of first byte in current es buffer.edpos is the au byte index+1 of last
@@ -32,19 +28,5 @@
 
 /* This function initialises the list to default values */
 void viddec_pm_utils_list_init(viddec_pm_utils_list_t *cxt);
-#ifndef VBP
-/* This function adds a new entry to list and will emit tags if needed */
-uint32_t viddec_pm_utils_list_addbuf(viddec_pm_utils_list_t *list, viddec_input_buffer_t *es_buf);
 
-/* This function updates au byte position of the current list. This should be called after sc codes are detected and before
-   syntax parsing as get bits requires this to be initialized. */
-void viddec_pm_utils_list_updatebytepos(viddec_pm_utils_list_t *list, uint8_t sc_prefix_length);
-
-/* This function walks through the list and removes consumed buffers based on total bytes. It then moves
-   unused entires to the top of list. */
-void viddec_pm_utils_list_remove_used_entries(viddec_pm_utils_list_t *list, uint32_t length);
-
-/* this function returns 1 if the requested byte is not found. If found returns list and offset into list */
-uint32_t viddec_pm_utils_list_getbyte_position(viddec_pm_utils_list_t *list, uint32_t byte, uint32_t *list_index, uint32_t *offset);
-#endif
 #endif
diff --git a/mixvbp/vbp_manager/vbp_h264_parser.c b/mixvbp/vbp_manager/vbp_h264_parser.c
index 3f6400d..0a8f141 100755
--- a/mixvbp/vbp_manager/vbp_h264_parser.c
+++ b/mixvbp/vbp_manager/vbp_h264_parser.c
@@ -177,16 +177,6 @@
         ETRACE ("Failed to set entry point." );
         return VBP_LOAD;
     }
-#ifdef VBP
-    pcontext->parser_ops->is_wkld_done = NULL;
-#else
-    pcontext->parser_ops->is_wkld_done = dlsym(pcontext->fd_parser, "viddec_h264_wkld_done");
-    if (NULL == pcontext->parser_ops->is_wkld_done)
-    {
-        ETRACE ("Failed to set entry point." );
-        return VBP_LOAD;
-    }
-#endif
 
     pcontext->parser_ops->flush = dlsym(pcontext->fd_parser, "viddec_h264_flush");;
     if (NULL == pcontext->parser_ops->flush)
@@ -884,27 +874,37 @@
     codec_data->crop_right = 0;
     codec_data->crop_top = 0;
     codec_data->crop_bottom = 0;
-    if(parser->info.active_SPS.sps_disp.frame_cropping_flag) {
+    if(parser->info.active_SPS.sps_disp.frame_cropping_flag)
+    {
         int CropUnitX = 0, CropUnitY = 0, SubWidthC = 0, SubHeightC = 0;
         int ChromaArrayType = 0;
-        if(parser->info.active_SPS.sps_disp.separate_colour_plane_flag == 0) {
-            if(parser->info.active_SPS.sps_disp.chroma_format_idc == 1) {
+        if(parser->info.active_SPS.sps_disp.separate_colour_plane_flag == 0)
+        {
+            if(parser->info.active_SPS.sps_disp.chroma_format_idc == 1)
+            {
                 SubWidthC = 2;
                 SubHeightC = 2;
-            } else if( parser->info.active_SPS.sps_disp.chroma_format_idc == 2) {
+            }
+            else if( parser->info.active_SPS.sps_disp.chroma_format_idc == 2)
+            {
                 SubWidthC = 2;
                 SubHeightC = 1;
-            } else if( parser->info.active_SPS.sps_disp.chroma_format_idc == 3) {
+            }
+            else if( parser->info.active_SPS.sps_disp.chroma_format_idc == 3)
+            {
                 SubWidthC = 1;
                 SubHeightC = 1;
             }
             ChromaArrayType = parser->info.active_SPS.sps_disp.chroma_format_idc;
         }
 
-        if(ChromaArrayType == 0) {
+        if(ChromaArrayType == 0)
+        {
             CropUnitX = 1;
             CropUnitY = 2 - parser->info.active_SPS.sps_disp.frame_mbs_only_flag;
-        } else {
+        }
+        else
+        {
             CropUnitX = SubWidthC;
             CropUnitY = SubHeightC * ( 2 - parser->info.active_SPS.sps_disp.frame_mbs_only_flag);
         }
@@ -1226,10 +1226,8 @@
 
     slc_parms->num_ref_idx_l0_active_minus1 = 0;
     slc_parms->num_ref_idx_l1_active_minus1 = 0;
-    if (slice_header->slice_type == h264_PtypeI)
-    {
-    }
-    else if (slice_header->slice_type == h264_PtypeP)
+
+    if (slice_header->slice_type == h264_PtypeP)
     {
         slc_parms->num_ref_idx_l0_active_minus1 = slice_header->num_ref_idx_l0_active - 1;
     }
@@ -1238,7 +1236,7 @@
         slc_parms->num_ref_idx_l0_active_minus1 = slice_header->num_ref_idx_l0_active - 1;
         slc_parms->num_ref_idx_l1_active_minus1 = slice_header->num_ref_idx_l1_active - 1;
     }
-    else
+    else if (slice_header->slice_type != h264_PtypeI)
     {
         WTRACE("slice type %d is not supported.", slice_header->slice_type);
     }
@@ -1249,24 +1247,17 @@
     slc_parms->slice_alpha_c0_offset_div2 = slice_header->slice_alpha_c0_offset_div2;
     slc_parms->slice_beta_offset_div2 = slice_header->slice_beta_offset_div2;
 
-
     vbp_set_pre_weight_table_h264(h264_parser, slc_parms);
     vbp_set_slice_ref_list_h264(h264_parser, slc_parms);
 
-
     pic_data->num_slices++;
 
-    //vbp_update_reference_frames_h264_methodB(pic_data);
     if (pic_data->num_slices > MAX_NUM_SLICES)
     {
         ETRACE("number of slices per picture exceeds the limit (%d).", MAX_NUM_SLICES);
         return VBP_DATA;
     }
 
-    /*if (pic_data->num_slices > 1)
-    {
-        ITRACE("number of slices per picture is %d.", pic_data->num_slices);
-    }*/
     return VBP_OK;
 }
 
@@ -1395,7 +1386,7 @@
     num_of_picture_parameter_sets = *cur_data++;
     if (num_of_picture_parameter_sets > 1)
     {
-        /* g_warning("num_of_picture_parameter_sets is %d.", num_of_picture_parameter_sets); */
+        VTRACE("num_of_picture_parameter_sets is %d.", num_of_picture_parameter_sets);
     }
 
     for (i = 0; i < num_of_picture_parameter_sets; i++)
@@ -1460,7 +1451,7 @@
         return *p;
 
     default:
-        WTRACE("invalid NAL_length_size: %d.", NAL_length_size);
+        WTRACE("invalid NAL_length_size: %d.", *NAL_length_size);
         /* default to 4 bytes for length */
         *NAL_length_size = 4;
         return vbp_utils_ntohl(p);
@@ -1514,7 +1505,7 @@
             NAL_length = vbp_get_NAL_length_h264(cubby->buf + size_parsed, &parser_private->NAL_length_size);
             if (NAL_length <= 0 || NAL_length > size_left - parser_private->NAL_length_size)
             {
-                ETRACE("Invalid NAL_length parsed.");
+                ETRACE("Invalid NAL_length parsed: 0x%x", NAL_length);
                 break;
             }
 
@@ -1565,7 +1556,6 @@
         }
     }
 
-
     if (parser_private->bitstream_pattern == H264_BS_SC_PREFIXED)
     {
         viddec_sc_parse_cubby_cxt_t cubby;
@@ -1629,7 +1619,6 @@
         cxt->list.data[0].edpos = cxt->parse_cubby.size;
     }
 
-
     return VBP_OK;
 }
 
@@ -1653,7 +1642,7 @@
     switch (parser->info.nal_unit_type)
     {
     case h264_NAL_UNIT_TYPE_SLICE:
-        //ITRACE("slice header is parsed.");
+        VTRACE("slice header is parsed.");
         error = vbp_add_pic_data_h264(pcontext, i);
         if (VBP_OK == error)
         {
@@ -1662,7 +1651,7 @@
         break;
 
     case  h264_NAL_UNIT_TYPE_IDR:
-        //ITRACE("IDR header is parsed.");
+        VTRACE("IDR header is parsed.");
         error = vbp_add_pic_data_h264(pcontext, i);
         if (VBP_OK == error)
         {
@@ -1670,7 +1659,7 @@
         }
         break;
     case h264_NAL_UNIT_TYPE_SEI:
-        //ITRACE("SEI header is parsed.");
+        VTRACE("SEI header is parsed.");
         break;
 
     case h264_NAL_UNIT_TYPE_SPS:
@@ -1682,7 +1671,7 @@
         break;
 
     case h264_NAL_UNIT_TYPE_Acc_unit_delimiter:
-        //ITRACE("ACC unit delimiter is parsed.");
+        VTRACE("ACC unit delimiter is parsed.");
         break;
 
     case h264_NAL_UNIT_TYPE_EOSeq:
diff --git a/mixvbp/vbp_manager/vbp_utils.c b/mixvbp/vbp_manager/vbp_utils.c
index 78bbb0e..0da65b5 100755
--- a/mixvbp/vbp_manager/vbp_utils.c
+++ b/mixvbp/vbp_manager/vbp_utils.c
@@ -387,18 +387,16 @@
         error = ops->parse_syntax((void *)cxt, (void *)&(cxt->codec_data[0]));
 
         /* can't return error for now. Neet further investigation */
-#if 0
         if (0 != error)
         {
-            ETRACE("failed to parse the syntax: %d!", error);
-            return error;
+            WTRACE("failed to parse the syntax: %d!", error);
         }
-#endif
 
         /* process parsing result */
         error = pcontext->func_process_parsing_result(pcontext, i);
 
         if (VBP_MULTI == error) {
+            ITRACE("Multiple frames are found in one bufffer.");
             return VBP_OK;
         }
         else if (0 != error)
diff --git a/mixvbp/vbp_manager/viddec_parse_sc.c b/mixvbp/vbp_manager/viddec_parse_sc.c
index b3f8d0b..d64a229 100755
--- a/mixvbp/vbp_manager/viddec_parse_sc.c
+++ b/mixvbp/vbp_manager/viddec_parse_sc.c
@@ -1,6 +1,5 @@
 #include "viddec_pm_parse.h"
 
-#ifndef MFDBIGENDIAN
 uint32_t viddec_parse_sc(void *in, void *pcxt, void *sc_state)
 {
     uint8_t *ptr;
@@ -93,126 +92,3 @@
     return ret;
 }
 
-#else
-#define FIRST_STARTCODE_BYTE        0x00
-#define SECOND_STARTCODE_BYTE       0x00
-#define THIRD_STARTCODE_BYTE        0x01
-
-/* BIG ENDIAN: Must be the second and fourth byte of the bytestream for this to work */
-/* LITTLE ENDIAN: Must be the second and fourth byte of the bytestream for this to work */
-/* these are little-endian defines */
-#define SC_BYTE_MASK0               0x00ff0000  /* little-endian */
-#define SC_BYTE_MASK1               0x000000ff  /* little-endian */
-
-/* Parse for Sc code of pattern 0x00 0x00 0xXX in the current buffer. Returns either sc found or success.
-   The conext is updated with current phase and sc_code position in the buffer.
-*/
-uint32_t viddec_parse_sc(void *in, void *pcxt, void *sc_state)
-{
-    uint8_t *ptr;
-    uint32_t size;
-    uint32_t data_left=0, phase = 0, ret = 0;
-    viddec_sc_parse_cubby_cxt_t *cxt;
-    /* What is phase?: phase is a value between [0-4], we keep track of consecutive '0's with this.
-       Any time a '0' is found its incremented by 1(uptp 2) and reset to '0' if a zero not found.
-       if 0xXX code is found and current phase is 2, its changed to 3 which means we found the pattern
-       we are looking for. Its incremented to 4 once we see a byte after this pattern */
-    cxt = ( viddec_sc_parse_cubby_cxt_t *)in;
-    size = 0;
-    data_left = cxt->size;
-    ptr = cxt->buf;
-    phase = cxt->phase;
-    cxt->sc_end_pos = -1;
-    pcxt=pcxt;
-
-    /* parse until there is more data and start code not found */
-    while ((data_left > 0) &&(phase < 3))
-    {
-        /* Check if we are byte aligned & phase=0, if thats the case we can check
-           work at a time instead of byte*/
-        if (((((uint32_t)ptr) & 0x3) == 0) && (phase == 0))
-        {
-            while (data_left > 3)
-            {
-                uint32_t data;
-                char mask1 = 0, mask2=0;
-
-                data = *((uint32_t *)ptr);
-                mask1 = (FIRST_STARTCODE_BYTE != (data & SC_BYTE_MASK0));
-                mask2 = (FIRST_STARTCODE_BYTE != (data & SC_BYTE_MASK1));
-                /* If second byte and fourth byte are not zero's then we cannot have a start code here as we need
-                   two consecutive zero bytes for a start code pattern */
-                if (mask1 && mask2)
-                {/* Success so skip 4 bytes and start over */
-                    ptr+=4;
-                    size+=4;
-                    data_left-=4;
-                    continue;
-                }
-                else
-                {
-                    break;
-                }
-            }
-        }
-
-        /* At this point either data is not on a word boundary or phase > 0 or On a word boundary but we detected
-           two zero bytes in the word so we look one byte at a time*/
-        if (data_left > 0)
-        {
-            if (*ptr == FIRST_STARTCODE_BYTE)
-            {/* Phase can be 3 only if third start code byte is found */
-                phase++;
-                ptr++;
-                size++;
-                data_left--;
-                if (phase > 2)
-                {
-                    phase = 2;
-
-                    if ( (((uint32_t)ptr) & 0x3) == 0 )
-                    {
-                        while ( data_left > 3 )
-                        {
-                            if (*((uint32_t *)ptr) != 0)
-                            {
-                                break;
-                            }
-                            ptr+=4;
-                            size+=4;
-                            data_left-=4;
-                        }
-                    }
-                }
-            }
-            else
-            {
-                if ((*ptr == THIRD_STARTCODE_BYTE) && (phase == 2))
-                {/* Match for start code so update context with byte position */
-                    phase = 3;
-                    cxt->sc_end_pos = size;
-                }
-                else
-                {
-                    phase = 0;
-                }
-                ptr++;
-                size++;
-                data_left--;
-            }
-        }
-    }
-    if ((data_left > 0) && (phase == 3))
-    {
-        viddec_sc_prefix_state_t *state = (viddec_sc_prefix_state_t *)sc_state;
-        cxt->sc_end_pos++;
-        state->next_sc = cxt->buf[cxt->sc_end_pos];
-        state->second_scprfx_length = 3;
-        phase++;
-        ret = 1;
-    }
-    cxt->phase = phase;
-    /* Return SC found only if phase is 4, else always success */
-    return ret;
-}
-#endif
diff --git a/mixvbp/vbp_manager/viddec_pm_parser_ops.c b/mixvbp/vbp_manager/viddec_pm_parser_ops.c
index 1ba8aa8..8c0a1ec 100755
--- a/mixvbp/vbp_manager/viddec_pm_parser_ops.c
+++ b/mixvbp/vbp_manager/viddec_pm_parser_ops.c
@@ -4,6 +4,7 @@
 #include "viddec_parser_ops.h"
 #include "viddec_pm_utils_bstream.h"
 #include "viddec_fw_common_defs.h"
+#include <vbp_trace.h>
 
 int32_t viddec_pm_get_bits(void *parent, uint32_t *data, uint32_t num_bits)
 {
@@ -14,7 +15,7 @@
     ret = viddec_pm_utils_bstream_peekbits(&(cxt->getbits), data, num_bits, 1);
     if (ret == -1)
     {
-        DEB("FAILURE!!!! getbits returned %d\n", ret);
+        VTRACE("FAILURE? getbits returned %d", ret);
     }
 
     return ret;
diff --git a/mixvbp/vbp_manager/viddec_pm_utils_bstream.c b/mixvbp/vbp_manager/viddec_pm_utils_bstream.c
index 6939fef..72d210b 100755
--- a/mixvbp/vbp_manager/viddec_pm_utils_bstream.c
+++ b/mixvbp/vbp_manager/viddec_pm_utils_bstream.c
@@ -51,95 +51,12 @@
     return ret;
 }
 
-#ifndef VBP
-/*
-  This function returns true if cubby buffer has the last byte of access unit.
-*/
-uint8_t viddec_pm_utils_bstream_nomoredata(viddec_pm_utils_bstream_cxt_t *cxt)
-{
-    uint32_t last_byte_offset_plus_one=0;
-    uint8_t ret = 0;
-    /* Check to see if the last byte Acces unit offset is the last byte for current access unit.
-     End represents the first invalid byte, so (end - st) will give number of bytes.*/
-    last_byte_offset_plus_one = cxt->au_pos + (cxt->bstrm_buf.buf_end - cxt->bstrm_buf.buf_st);
-    if ((int32_t)last_byte_offset_plus_one >= cxt->list->total_bytes)
-    {
-        ret = 1;
-    }
-    return ret;
-}
-#endif
 
 /* This function initializes scratch buffer, which is used for staging already read data, due to DMA limitations */
 static inline void viddec_pm_utils_bstream_scratch_init(viddec_pm_utils_bstream_scratch_cxt_t *cxt)
 {
-    cxt->st = cxt->size = cxt->bitoff=0;
+    cxt->st = cxt->size = cxt->bitoff = 0;
 }
-#ifndef VBP
-/* This function tells us how much more data is in the current es buffer from current position. Its used to figure out if
-   we need to go to next es buffer
-*/
-static inline uint32_t viddec_pm_utils_bstream_datafromindex(viddec_pm_utils_list_t *list, uint32_t index, uint32_t offset)
-{
-    uint32_t ret=0;
-    int32_t val=0;
-    val = (list->data[index].edpos <= (uint32_t)list->total_bytes) ? list->data[index].edpos: (uint32_t)list->total_bytes;
-    val = val - (int32_t)offset;
-    if (val > 0) ret = (uint32_t)val;
-    return val;
-}
-
-/* This function seeks to byte offset position starting from lst_index, if more data is present in current ES buffer pointed by
- lst_index returns the remaining data in current buffer along with physical address of byte offset. The lst_index parameter
- at returns index of ES buffer in list which has byte_offset
-*/
-static inline uint32_t viddec_pm_utils_bstream_maxbytes_from_index(viddec_pm_utils_bstream_cxt_t *cxt,
-        uint32_t *lst_index,
-        uint32_t byte_offset,
-        uint32_t *physaddr)
-{
-    viddec_pm_utils_list_t *list;
-    uint32_t last_byte_offst=0, bytes_left=0;/* default return value is 0 bytes */
-
-    list = cxt->list;
-    while (*lst_index < list->num_items)
-    {
-        /* Check to see if we reached the buffer with last valid byte of current access unit, List can have data beyond current access unit */
-        last_byte_offst = (list->data[*lst_index].edpos <= (uint32_t)list->total_bytes) ? list->data[*lst_index].edpos: (uint32_t)list->total_bytes;
-        if (byte_offset < last_byte_offst)
-        {/* Found a match so return with data remaining */
-            bytes_left = viddec_pm_utils_bstream_datafromindex(list, *lst_index, byte_offset);
-            *physaddr = viddec_pm_utils_bstream_getphys(cxt, byte_offset, *lst_index);
-            break;
-        }
-        *lst_index+=1;
-    }
-    return bytes_left;
-}
-
-/* This function is for copying trailing bytes of cubby bitstream buffer to scratch buffer */
-static inline void viddec_pm_utils_bstream_scratch_copyto(viddec_pm_utils_bstream_scratch_cxt_t *cxt, uint8_t *data, uint32_t num_bytes)
-{
-    uint32_t i=0;
-    for (i=0; i<num_bytes; i++)
-    {
-        cxt->buf_scratch[i] = *data;
-        data++;
-        cxt->size++;
-    }
-}
-
-/* This function is for copying trailing bytes from scratch buffer to  bitstream buffer */
-static inline void viddec_pm_utils_bstream_scratch_copyfrom(viddec_pm_utils_bstream_scratch_cxt_t *cxt, uint8_t *data)
-{
-    uint32_t i=0;
-    for (i=0; i<cxt->size; i++)
-    {
-        *data = cxt->buf_scratch[i];
-        data++;
-    }
-}
-#endif
 
 /* This function populates requested number of bytes into data parameter, skips emulation prevention bytes if needed */
 static inline int32_t viddec_pm_utils_getbytes(viddec_pm_utils_bstream_buf_cxt_t *bstream,
@@ -158,7 +75,7 @@
     while (valid_bytes_read < num_bytes)
     {
         cur_byte = bstream->buf[bstream->buf_index + *act_bytes];
-        if (emul_reqd && (cur_byte == 0x3) &&(*phase == 2))
+        if (emul_reqd && (cur_byte == 0x3) && (*phase == 2))
         {/* skip emulation byte. we update the phase only if emulation prevention is enabled */
             *phase = 0;
         }
@@ -174,18 +91,18 @@
                 if (cur_byte == 0)
                 {
                     /* Update phase only if emulation prevention is required */
-                    *phase +=( ((*phase < 2) && emul_reqd ) ? 1: 0 );
+                    *phase += (((*phase < 2) && emul_reqd) ? 1: 0);
                 }
                 else
                 {
-                    *phase=0;
+                    *phase = 0;
                 }
             }
             valid_bytes_read++;
         }
         *act_bytes +=1;
     }
-    /* Check to see if we reached end during above operation. We might be out of range buts it safe since our array
+    /* Check to see if we reached end during above operation. We might be out of range buts it's safe since our array
        has at least MIN_DATA extra bytes and the maximum out of bounds we will go is 5 bytes */
     if ((bstream->buf_index + *act_bytes -1) >= bstream->buf_end)
     {
@@ -200,27 +117,7 @@
 */
 static inline void viddec_pm_utils_check_bstream_reload(viddec_pm_utils_bstream_cxt_t *cxt, uint32_t *data_left)
 {
-#ifdef VBP
     *data_left = viddec_pm_utils_bstream_bytesincubby(&(cxt->bstrm_buf));
-#else
-    uint8_t isReload=0;
-
-    *data_left = viddec_pm_utils_bstream_bytesincubby(&(cxt->bstrm_buf));
-    /* If we have minimum data we should continue, else try to read more data */
-    if (*data_left <MIN_DATA)
-    {
-        /* Check to see if we already read last byte of current access unit */
-        isReload = !(viddec_pm_utils_bstream_nomoredata(cxt) == 1);
-        while (isReload)
-        {
-            /* We have more data in access unit so keep reading until we get at least minimum data */
-            viddec_pm_utils_bstream_reload(cxt);
-            *data_left = viddec_pm_utils_bstream_bytesincubby(&(cxt->bstrm_buf));
-            /* Break out of loop if we reached last byte or we have enough data */
-            isReload = !((*data_left >= MIN_DATA) || (viddec_pm_utils_bstream_nomoredata(cxt) == 1));
-        }
-    }
-#endif
 }
 
 /*
@@ -232,12 +129,12 @@
     if ((bits & 0x7) == 0)
     {
         bstream->buf_bitoff = 0;
-        bstream->buf_index +=bytes;
+        bstream->buf_index += bytes;
     }
     else
     {
         bstream->buf_bitoff = bits & 0x7;
-        bstream->buf_index +=(bytes - 1);
+        bstream->buf_index += (bytes - 1);
     }
 }
 
@@ -255,110 +152,21 @@
     if (cxt->is_emul_reqd &&
             (cxt->phase >= 2) &&
             (bstream->buf_bitoff == 0) &&
-            (bstream->buf[bstream->buf_index] == 0x3) )
+            (bstream->buf[bstream->buf_index] == 0x3))
     {
         bstream->buf_index += 1;
         cxt->phase = 0;
     }
 }
 
-#ifndef VBP
-/*
-  This function gets physical address of the requested au offset(pos).
-*/
-
-uint32_t viddec_pm_utils_bstream_getphys(viddec_pm_utils_bstream_cxt_t *cxt, uint32_t pos, uint32_t lst_index)
-{
-    uint32_t ret = 0, last_byte_offst=0;
-    viddec_pm_utils_list_t *list;
-
-    list = cxt->list;
-    while (lst_index < list->num_items)
-    {
-        last_byte_offst = (list->data[lst_index].edpos <= (uint32_t)list->total_bytes) ? list->data[lst_index].edpos: (uint32_t)list->total_bytes;
-        if (pos < last_byte_offst)
-        {
-#ifndef MFDBIGENDIAN
-            ret = (uint32_t)list->sc_ibuf[lst_index].buf;
-#else
-            ret = list->sc_ibuf[lst_index].phys;
-#endif
-            ret +=(pos - list->data[lst_index].stpos);
-            if (lst_index == 0) ret+=list->start_offset;
-            break;
-        }
-        lst_index++;
-    }
-    return ret;
-}
-
-/*
-  Actual reload function which uses dma to refill bitstream buffer.
-*/
-void viddec_pm_utils_bstream_reload(viddec_pm_utils_bstream_cxt_t *cxt)
-{
-    viddec_pm_utils_bstream_buf_cxt_t *bstream;
-
-    bstream = &(cxt->bstrm_buf);
-
-    /* Update current offset positions */
-    cxt->au_pos +=  (bstream->buf_index - bstream->buf_st);
-    bstream->buf_st = bstream->buf_index;
-    /* copy leftover bytes into scratch */
-    {
-        int32_t cur_bytes=0;
-        viddec_pm_utils_bstream_scratch_init(&(cxt->scratch));
-        cur_bytes = viddec_pm_utils_bstream_bytesincubby(&(cxt->bstrm_buf));
-        if (cur_bytes > 0)
-        {
-            viddec_pm_utils_bstream_scratch_copyto(&(cxt->scratch), &(bstream->buf[bstream->buf_index]), cur_bytes);
-            cxt->scratch.bitoff = bstream->buf_bitoff;
-        }
-    }
-    /* Initiate DMA and copyback scratch data */
-    {
-        uint32_t data_left = 0, ddr_mask=0;
-        /* calculate necesary aligmnets and copy data */
-        {
-            uint32_t ddr_addr=0, data_wrote=0;
-            uint32_t byte_pos;
-            /* byte pos points to the position from where we want to read data.*/
-            byte_pos = cxt->au_pos + cxt->scratch.size;
-            data_left = viddec_pm_utils_bstream_maxbytes_from_index(cxt, &(cxt->list_off), byte_pos, &ddr_addr);
-            if (data_left > CUBBY_SIZE)
-            {
-                data_left = CUBBY_SIZE;
-            }
-            if (data_left != 0)
-            {
-                ddr_mask = ddr_addr & 0x3;
-                ddr_addr = ddr_addr & ~0x3;
-                data_wrote = cp_using_dma(ddr_addr, (uint32_t)&(bstream->buf[MIN_DATA]), (data_left + ddr_mask), 0, 1);
-            }
-        }
-        /* copy scratch data back to buffer and update offsets */
-        {
-            uint32_t index=0;
-            index = MIN_DATA + ddr_mask;
-            index -= cxt->scratch.size;
-            viddec_pm_utils_bstream_scratch_copyfrom(&(cxt->scratch), &(bstream->buf[index]));
-            bstream->buf_st = bstream->buf_index = index;
-            bstream->buf_end = data_left + cxt->scratch.size + bstream->buf_st;
-            bstream->buf_bitoff = cxt->scratch.bitoff;
-        }
-    }
-}
-#endif
 
 /*
   Init function called by parser manager after sc code detected.
 */
 void viddec_pm_utils_bstream_init(viddec_pm_utils_bstream_cxt_t *cxt, viddec_pm_utils_list_t *list, uint32_t is_emul)
 {
-#ifdef VBP
-    cxt->emulation_byte_counter = 0;
-#endif
 
+    cxt->emulation_byte_counter = 0;
     cxt->au_pos = 0;
     cxt->list = list;
     cxt->list_off = 0;
@@ -393,7 +201,7 @@
 int32_t viddec_pm_utils_bstream_skipbits(viddec_pm_utils_bstream_cxt_t *cxt, uint32_t num_bits)
 {
     int32_t ret = -1;
-    uint32_t data_left=0;
+    uint32_t data_left = 0;
     viddec_pm_utils_bstream_buf_cxt_t *bstream;
 
     bstream = &(cxt->bstrm_buf);
@@ -402,24 +210,22 @@
     {
         uint8_t bytes_required=0;
 
-        bytes_required = (bstream->buf_bitoff + num_bits + 7)>>3;
+        bytes_required = (bstream->buf_bitoff + num_bits + 7) >> 3;
         if (bytes_required <= data_left)
         {
             viddec_pm_utils_getbits_t data;
             uint32_t act_bytes =0;
-            if (viddec_pm_utils_getbytes(bstream, &data,  &act_bytes, &(cxt->phase), bytes_required, cxt->is_emul_reqd, (bstream->buf_bitoff == 0)) != -1)
+            if (viddec_pm_utils_getbytes(bstream, &data, &act_bytes, &(cxt->phase), bytes_required, cxt->is_emul_reqd, (bstream->buf_bitoff == 0)) != -1)
             {
-                uint32_t total_bits=0;
-                total_bits=num_bits+bstream->buf_bitoff;
+                uint32_t total_bits = 0;
+                total_bits = num_bits + bstream->buf_bitoff;
                 viddec_pm_utils_update_skipoffsets(bstream, total_bits, act_bytes);
-                ret=1;
+                ret = 1;
 
-#ifdef VBP
                 if (act_bytes > bytes_required)
                 {
                     cxt->emulation_byte_counter = act_bytes - bytes_required;
                 }
-#endif
             }
         }
     }
@@ -438,11 +244,11 @@
 
     if ((num_bits <= 32) && (num_bits > 0) && (data_left != 0))
     {
-        uint32_t bytes_required=0;
+        uint32_t bytes_required = 0;
         viddec_pm_utils_bstream_buf_cxt_t *bstream;
 
         bstream = &(cxt->bstrm_buf);
-        bytes_required = (bstream->buf_bitoff + num_bits + 7)>>3;
+        bytes_required = (bstream->buf_bitoff + num_bits + 7) >> 3;
 
         /* Step 2: Make sure we have bytes for requested bits */
         if (bytes_required <= data_left)
@@ -450,22 +256,21 @@
             uint32_t act_bytes, phase;
             viddec_pm_utils_getbits_t data;
             phase = cxt->phase;
-            /* Step 3: Due to emualtion prevention bytes sometimes the bytes_required > actual_required bytes */
+            /* Step 3: Due to emualtion prevention bytes sometimes the bytes_required < actual_required bytes */
             if (viddec_pm_utils_getbytes(bstream, &data, &act_bytes, &phase, bytes_required, cxt->is_emul_reqd, (bstream->buf_bitoff == 0)) != -1)
             {
-                uint32_t total_bits=0;
-                uint32_t shift_by=0;
+                uint32_t total_bits = 0;
+                uint32_t shift_by = 0;
                 /* zero out upper bits */
                 /* LIMITATION:For some reason compiler is optimizing it to NOP if i do both shifts
                    in single statement */
                 data.byte[0] <<= bstream->buf_bitoff;
                 data.byte[0] >>= bstream->buf_bitoff;
 
-#ifndef MFDBIGENDIAN
                 data.word[0] = SWAP_WORD(data.word[0]);
                 data.word[1] = SWAP_WORD(data.word[1]);
-#endif
-                total_bits = num_bits+bstream->buf_bitoff;
+
+                total_bits = num_bits + bstream->buf_bitoff;
                 if (total_bits > 32)
                 {
                     /* We have to use both the words to get required data */
@@ -484,15 +289,13 @@
                     viddec_pm_utils_update_skipoffsets(bstream, total_bits, act_bytes);
                     cxt->phase = phase;
 
-#ifdef VBP
                     if (act_bytes > bytes_required)
                     {
                         cxt->emulation_byte_counter += act_bytes - bytes_required;
                     }
-#endif
                 }
 
-                ret =1;
+                ret = 1;
             }
         }
     }
diff --git a/mixvbp/vbp_plugin/h264/Android.mk b/mixvbp/vbp_plugin/h264/Android.mk
index f015988..2045d32 100755
--- a/mixvbp/vbp_plugin/h264/Android.mk
+++ b/mixvbp/vbp_plugin/h264/Android.mk
@@ -2,32 +2,31 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES :=			\
-	h264parse.c			\
-	h264parse_bsd.c			\
-	h264parse_math.c		\
-	h264parse_mem.c			\
-	h264parse_sei.c			\
-	h264parse_sh.c			\
-	h264parse_pps.c			\
-	h264parse_sps.c			\
-	h264parse_dpb.c			\
-	viddec_h264_parse.c		\
+LOCAL_SRC_FILES :=      \
+    h264parse.c         \
+    h264parse_bsd.c     \
+    h264parse_math.c    \
+    h264parse_mem.c     \
+    h264parse_sei.c     \
+    h264parse_sh.c      \
+    h264parse_pps.c     \
+    h264parse_sps.c     \
+    h264parse_dpb.c     \
+    viddec_h264_parse.c \
 	mix_vbp_h264_stubs.c
 
-LOCAL_CFLAGS := -DVBP -DHOST_ONLY
-
-LOCAL_C_INCLUDES :=							   \
-	$(LOCAL_PATH)/include		   \
-	$(MIXVBP_DIR)/include		   \
-	$(MIXVBP_DIR)/vbp_manager/include	   \
-	$(MIXVBP_DIR)/vbp_manager/h264/include
+LOCAL_C_INCLUDES :=                   \
+    $(LOCAL_PATH)/include             \
+    $(MIXVBP_DIR)/include             \
+    $(MIXVBP_DIR)/vbp_manager/include \
+    $(MIXVBP_DIR)/vbp_manager/h264/include
 
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := libmixvbp_h264
 
-LOCAL_SHARED_LIBRARIES :=		\
-	libmixvbp
+LOCAL_SHARED_LIBRARIES := \
+    libmixvbp             \
+    liblog
 
 include $(BUILD_SHARED_LIBRARY)
 
@@ -48,18 +47,18 @@
         secvideo/baytrail/viddec_h264secure_parse.c \
         mix_vbp_h264_stubs.c
 
-LOCAL_CFLAGS := -DVBP -DHOST_ONLY -DUSE_AVC_SHORT_FORMAT
+LOCAL_CFLAGS := -DUSE_AVC_SHORT_FORMAT
 
 LOCAL_C_INCLUDES :=   \
-	$(LOCAL_PATH)/include   \
-	$(MIXVBP_DIR)/include    \
-	$(MIXVBP_DIR)/vbp_manager/include   \
-	$(MIXVBP_DIR)/vbp_manager/h264/include
+    $(LOCAL_PATH)/include   \
+    $(MIXVBP_DIR)/include   \
+    $(MIXVBP_DIR)/vbp_manager/include   \
+    $(MIXVBP_DIR)/vbp_manager/h264/include
 
 
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := libmixvbp_h264secure
-LOCAL_SHARED_LIBRARIES := libmixvbp
+LOCAL_SHARED_LIBRARIES := libmixvbp liblog
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/mixvbp/vbp_plugin/h264/h264parse.c b/mixvbp/vbp_plugin/h264/h264parse.c
index 9e36b7c..d4f9c9e 100755
--- a/mixvbp/vbp_plugin/h264/h264parse.c
+++ b/mixvbp/vbp_plugin/h264/h264parse.c
@@ -14,6 +14,8 @@
 #include "h264.h"
 #include "h264parse.h"
 #include "h264parse_dpb.h"
+#include <vbp_trace.h>
+
 
 
 /* ------------------------------------------------------------------------------------------ */
@@ -38,22 +40,22 @@
            58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
         };
 
-    lastScale      = 8;
-    nextScale      = 8;
+    lastScale   = 8;
+    nextScale   = 8;
     scanj = 0;
 
-    for (j=0; j<sizeOfScalingList; j++)
+    for (j = 0; j < sizeOfScalingList; j++)
     {
-        scanj = (sizeOfScalingList==16)?ZZ_SCAN[j]:ZZ_SCAN8[j];
+        scanj = (sizeOfScalingList == 16) ? ZZ_SCAN[j] : ZZ_SCAN8[j];
 
-        if (nextScale!=0)
+        if (nextScale != 0)
         {
             delta_scale = h264_GetVLCElement(parent, pInfo, true);
             nextScale = (lastScale + delta_scale + 256) % 256;
-            *UseDefaultScalingMatrix = (uint8_t) (scanj==0 && nextScale==0);
+            *UseDefaultScalingMatrix = (uint8_t)(scanj == 0 && nextScale == 0);
         }
 
-        scalingList[scanj] = (nextScale==0) ? lastScale:nextScale;
+        scalingList[scanj] = (nextScale == 0) ? lastScale : nextScale;
         lastScale = scalingList[scanj];
     }
 
@@ -75,54 +77,47 @@
     ///////////////////////////////////////////////////
     if ((SliceHeader->first_mb_in_slice == 0) || (SliceHeader->pic_parameter_id != pInfo->active_PPS.pic_parameter_set_id))
     {
-#ifndef WIN32
         h264_Parse_Copy_Pps_From_DDR(pInfo, &pInfo->active_PPS, SliceHeader->pic_parameter_id);
 
         if (pInfo->active_PPS.seq_parameter_set_id >= MAX_NUM_SPS)
         {
-            return H264_PPS_INVALID_PIC_ID;			/// Invalid PPS detected
+            WTRACE("Invalid PPS detected");
+            return H264_PPS_INVALID_PIC_ID;
         }
 
         if (pInfo->active_PPS.seq_parameter_set_id != pInfo->active_SPS.seq_parameter_set_id)
         {
+            pInfo->Is_SPS_updated = 1;
+            h264_Parse_Copy_Sps_From_DDR(pInfo, &pInfo->active_SPS, pInfo->active_PPS.seq_parameter_set_id);
+            h264_Parse_Clear_Sps_Updated_Flag(pInfo, pInfo->active_PPS.seq_parameter_set_id);
+        }
+        else if (h264_Parse_Check_Sps_Updated_Flag(pInfo, pInfo->active_PPS.seq_parameter_set_id))
+        {
             pInfo->Is_SPS_updated =1;
             h264_Parse_Copy_Sps_From_DDR(pInfo, &pInfo->active_SPS, pInfo->active_PPS.seq_parameter_set_id);
             h264_Parse_Clear_Sps_Updated_Flag(pInfo, pInfo->active_PPS.seq_parameter_set_id);
         }
-        else
-        {
-            if (h264_Parse_Check_Sps_Updated_Flag(pInfo, pInfo->active_PPS.seq_parameter_set_id))
-            {
-                pInfo->Is_SPS_updated =1;
-                h264_Parse_Copy_Sps_From_DDR(pInfo, &pInfo->active_SPS, pInfo->active_PPS.seq_parameter_set_id);
-                h264_Parse_Clear_Sps_Updated_Flag(pInfo, pInfo->active_PPS.seq_parameter_set_id);
-            }
-        }
-
-#else
-        pInfo->active_PPS = PPS_GL[SliceHeader->pic_parameter_id];
-        pInfo->active_SPS = SPS_GL[pInfo->active_PPS.seq_parameter_set_id];
-#endif
 
         if (pInfo->active_SPS.seq_parameter_set_id >= MAX_NUM_SPS)
         {
-            return H264_PPS_INVALID_PIC_ID;			//// Invalid SPS detected
+            WTRACE("Invalid SPS detected");
+            return H264_PPS_INVALID_PIC_ID;
         }
     }
-    else {
-        if ((pInfo->active_PPS.seq_parameter_set_id >= MAX_NUM_SPS)  || (pInfo->active_SPS.seq_parameter_set_id >= MAX_NUM_SPS))
+    else
+    {
+        if ((pInfo->active_PPS.seq_parameter_set_id >= MAX_NUM_SPS)
+            || (pInfo->active_SPS.seq_parameter_set_id >= MAX_NUM_SPS))
         {
-            return H264_PPS_INVALID_PIC_ID;			/// Invalid PPS detected
+            WTRACE("Invalid SPS detected");
+            return H264_PPS_INVALID_PIC_ID;
         }
     }
 
-
     pInfo->img.PicWidthInMbs    = (pInfo->active_SPS.sps_disp.pic_width_in_mbs_minus1 + 1);
-    //pInfo->img.PicHeightInMapUnits = (pInfo->active_SPS.sps_disp.pic_height_in_map_units_minus1 + 1);
     pInfo->img.FrameHeightInMbs = pInfo->active_SPS.sps_disp.frame_mbs_only_flag?				\
-                                  (pInfo->active_SPS.sps_disp.pic_height_in_map_units_minus1 + 1):	\
-                                  ((pInfo->active_SPS.sps_disp.pic_height_in_map_units_minus1 + 1)<<1);
-
+                                  (pInfo->active_SPS.sps_disp.pic_height_in_map_units_minus1 + 1) :	\
+                                  ((pInfo->active_SPS.sps_disp.pic_height_in_map_units_minus1 + 1) << 1);
 
     return H264_STATUS_OK;
 };   //// End of h264_active_par_set
@@ -144,8 +139,6 @@
     //// Part2/3: depend on the active parset
     //////////////////////////////////////////////////
 
-    //retStatus = h264_Parse_Slice_Header_1(pInfo);
-
     SliceHeader->sh_error = 0;
 
     if (h264_Parse_Slice_Header_1(parent, pInfo, SliceHeader) == H264_STATUS_OK)
@@ -156,25 +149,26 @@
         retStatus = h264_active_par_set(pInfo, SliceHeader);
     }
 
-    if (retStatus == H264_STATUS_OK) {
+    if (retStatus == H264_STATUS_OK)
+    {
         switch (pInfo->active_SPS.profile_idc)
         {
         case h264_ProfileBaseline:
         case h264_ProfileMain:
         case h264_ProfileExtended:
-            pInfo->active_PPS.transform_8x8_mode_flag=0;
-            pInfo->active_PPS.pic_scaling_matrix_present_flag =0;
+            pInfo->active_PPS.transform_8x8_mode_flag = 0;
+            pInfo->active_PPS.pic_scaling_matrix_present_flag = 0;
             pInfo->active_PPS.second_chroma_qp_index_offset = pInfo->active_PPS.chroma_qp_index_offset;
 
         default:
             break;
         }
 
-        if ( h264_Parse_Slice_Header_2(parent, pInfo, SliceHeader) != H264_STATUS_OK)
+        if (h264_Parse_Slice_Header_2(parent, pInfo, SliceHeader) != H264_STATUS_OK)
         {
             SliceHeader->sh_error |= 2;
         }
-        else	if ( h264_Parse_Slice_Header_3(parent, pInfo, SliceHeader) != H264_STATUS_OK)
+        else if (h264_Parse_Slice_Header_3(parent, pInfo, SliceHeader) != H264_STATUS_OK)
         {
             SliceHeader->sh_error |= 4;
         }
@@ -214,30 +208,13 @@
 {
     h264_Status ret = H264_STATUS_ERROR;
 
-    //h264_NAL_Unit_t* NAL = &pInfo->NAL;
     uint32_t code;
-#if 0
-    viddec_pm_get_bits(void * parent,uint32_t * data,uint32_t num_bits)(parent, &code, 24);
-    viddec_pm_get_bits(parent, &code, 1);   //forbidden_zero_bit
-
-    viddec_pm_get_bits(parent, &code, 2);
-    SliceHeader->nal_ref_idc = (uint8_t)code;
-
-    viddec_pm_get_bits(parent, &code, 5);
-    pInfo->nal_unit_type = (uint8_t)code;
-#else
-#ifdef VBP
-    if ( viddec_pm_get_bits(parent, &code, 8) != -1)
-#else
-    //// 24bit SC, 1 bit: forbidden_zero_bit, 2 bitrs: nal_ref_idc, 5 bits: nal_unit_type
-    if ( viddec_pm_get_bits(parent, &code, 32) != -1)
-#endif
+    if (viddec_pm_get_bits(parent, &code, 8) != -1)
     {
-        *nal_ref_idc = (uint8_t)((code>>5)&0x3);
-        pInfo->nal_unit_type = (uint8_t)((code>>0)&0x1f);
+        *nal_ref_idc = (uint8_t)((code >> 5) & 0x3);
+        pInfo->nal_unit_type = (uint8_t)((code >> 0) & 0x1f);
         ret = H264_STATUS_OK;
     }
-#endif
 
     return ret;
 }
@@ -348,7 +325,7 @@
     pInfo->h264_pwt_end_bit_offset = 0;
     pInfo->h264_pwt_enabled = 0;
 
-    for (i=0; i<32; i++)
+    for (i = 0; i < 32; i++)
     {
         pInfo->slice_ref_list0[i] = 0;
         pInfo->slice_ref_list1[i] = 0;
@@ -370,8 +347,6 @@
 
     pInfo->sei_rp_received = 0;
     pInfo->last_I_frame_idc = 255;
-    pInfo->wl_err_curr = 0;
-    pInfo->wl_err_next = 0;
 
     pInfo->primary_pic_type_plus_one = 0;
     pInfo->sei_b_state_ready = 0;
@@ -424,34 +399,27 @@
 
     if (cur_slice.structure != FRAME)
     {
-        if ( ( MPD_DPB_FS_NULL_IDC != pInfo->dpb.fs_dec_idc)&&(3 != viddec_h264_get_is_used(&(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc])) )
-                &&(0 != viddec_h264_get_is_used(&(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc])) ))
+        if (( MPD_DPB_FS_NULL_IDC != pInfo->dpb.fs_dec_idc)
+            && (3 != viddec_h264_get_is_used(&(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc])))
+            && (0 != viddec_h264_get_is_used(&(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc]))))
         {
-            if ((cur_slice.frame_num == old_slice.frame_num)||(cur_slice.idr_flag))
+            if ((cur_slice.frame_num == old_slice.frame_num) || cur_slice.idr_flag)
             {
-
                 if (old_slice.structure != cur_slice.structure)
                 {
-
-                    if (((cur_slice.structure == TOP_FIELD &&old_slice.structure == BOTTOM_FIELD) || // Condition 1:
-                            (old_slice.structure == TOP_FIELD && cur_slice.structure == BOTTOM_FIELD)) &&    \
-                            ((old_slice.nal_ref_idc ==0 && cur_slice.nal_ref_idc == 0)              || // Condition 2:
-                             (old_slice.nal_ref_idc !=0 &&cur_slice.nal_ref_idc != 0)))
+                    if (((cur_slice.structure == TOP_FIELD && old_slice.structure == BOTTOM_FIELD) || // Condition 1:
+                         (old_slice.structure == TOP_FIELD && cur_slice.structure == BOTTOM_FIELD)) &&    \
+                            ((old_slice.nal_ref_idc == 0 && cur_slice.nal_ref_idc == 0)              || // Condition 2:
+                             (old_slice.nal_ref_idc != 0 && cur_slice.nal_ref_idc != 0)))
                     {
                         //pInfo->img.second_field = 1;
                         result = 1;
                     }
                 }
             }
-
-
         }
-
-
     }
 
-
-
     return result;
 
 } //// End of h264_is_second_field
@@ -472,8 +440,6 @@
         return 1;
     }
 
-
-
     result |= (old_slice.pic_parameter_id != cur_slice.pic_parameter_id);
     result |= (old_slice.frame_num != cur_slice.frame_num);
     result |= (old_slice.field_pic_flag != cur_slice.field_pic_flag);
@@ -511,9 +477,9 @@
 {
     int result = 0;
 
-    if ( (h264_NAL_UNIT_TYPE_SLICE==pInfo->old_nal_unit_type)||(h264_NAL_UNIT_TYPE_IDR==pInfo->old_nal_unit_type) )
+    if ((h264_NAL_UNIT_TYPE_SLICE == pInfo->old_nal_unit_type)
+        || (h264_NAL_UNIT_TYPE_IDR == pInfo->old_nal_unit_type))
     {
-
         switch ( pInfo->nal_unit_type )
         {
         case h264_NAL_UNIT_TYPE_Acc_unit_delimiter:
@@ -527,29 +493,22 @@
         case h264_NAL_UNIT_TYPE_Reserved3:
         case h264_NAL_UNIT_TYPE_Reserved4:
         case h264_NAL_UNIT_TYPE_Reserved5:
-        {
             pInfo->img.current_slice_num = 0;
 
-            if ((pInfo->img.structure == FRAME) || (pInfo->img.second_field)) {
+            if ((pInfo->img.structure == FRAME) || (pInfo->img.second_field))
+            {
                 pInfo->is_frame_boundary_detected_by_non_slice_nal =1;
                 pInfo->is_current_workload_done=1;
                 result=1;
             }
             break;
-        }
         default:
             break;
         }
-
     }
-
     return result;
-
 }
 
-
-
-
 /* ------------------------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------------------------ */
@@ -570,7 +529,7 @@
         pInfo->old_slice.bottom_field_flag = pInfo->SliceHeader.bottom_field_flag;
     }
 
-    pInfo->old_slice.nal_ref_idc   = pInfo->SliceHeader.nal_ref_idc;
+    pInfo->old_slice.nal_ref_idc = pInfo->SliceHeader.nal_ref_idc;
 
     pInfo->old_slice.structure = pInfo->SliceHeader.structure;
 
@@ -618,7 +577,8 @@
     pInfo->img.MbaffFrameFlag  = pInfo->active_SPS.sps_disp.mb_adaptive_frame_field_flag & (!(pInfo->SliceHeader.field_pic_flag));
     pInfo->img.pic_order_cnt_type = pInfo->active_SPS.pic_order_cnt_type;
 
-    if (pInfo->img.pic_order_cnt_type == 1) {
+    if (pInfo->img.pic_order_cnt_type == 1)
+    {
         pInfo->img.num_ref_frames_in_pic_order_cnt_cycle = pInfo->active_SPS.num_ref_frames_in_pic_order_cnt_cycle;
         pInfo->img.delta_pic_order_always_zero_flag = pInfo->active_SPS.delta_pic_order_always_zero_flag;
         pInfo->img.offset_for_non_ref_pic = pInfo->active_SPS.offset_for_non_ref_pic;
@@ -646,27 +606,24 @@
         pInfo->sei_information.recovery_frame_num = pInfo->img.frame_num;
 
 
-
     /////////////////////////////////////////////////Resolution Change
     pInfo->img.curr_has_mmco_5 = 0;
 
-    if ( (pInfo->img.PicWidthInMbs != p_dpb->PicWidthInMbs)||
-            (pInfo->img.FrameHeightInMbs != p_dpb->FrameHeightInMbs) )
+    if ((pInfo->img.PicWidthInMbs != p_dpb->PicWidthInMbs)||
+        (pInfo->img.FrameHeightInMbs != p_dpb->FrameHeightInMbs))
     {
-        int32_t no_output_old_pics = (pInfo->SliceHeader.idr_flag)? pInfo->img.no_output_of_prior_pics_flag : 0;
+        int32_t no_output_old_pics = (pInfo->SliceHeader.idr_flag) ? pInfo->img.no_output_of_prior_pics_flag : 0;
 
         // If resolution changed, reset the soft DPB here
         h264_dpb_reset_dpb(pInfo, pInfo->img.PicWidthInMbs, pInfo->img.FrameHeightInMbs, 1, no_output_old_pics);
     }
 
     return;
-
 } ///// End of init new frame
 
 
 void h264_update_frame_type(h264_Info * pInfo )
 {
-
 //update frame type
     if (pInfo->img.structure == FRAME)
     {
@@ -682,7 +639,6 @@
         }
         else
         {
-#if 1
             switch (pInfo->SliceHeader.slice_type)
             {
             case h264_PtypeB:
@@ -706,10 +662,7 @@
                 break;
 
             }
-#endif
-
         }
-
     }
     else if (pInfo->img.structure == TOP_FIELD)
     {
@@ -726,12 +679,12 @@
                 break;
             case h264_PtypeSP:
             case h264_PtypeP:
-                if ( ((pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type) & (0x7 << FRAME_TYPE_TOP_OFFSET))>>FRAME_TYPE_TOP_OFFSET != FRAME_TYPE_B)
-                    pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_P << FRAME_TYPE_TOP_OFFSET)|(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_BOTTOM_OFFSET));
+                if (((pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type) & (0x7 << FRAME_TYPE_TOP_OFFSET)) >> FRAME_TYPE_TOP_OFFSET != FRAME_TYPE_B)
+                    pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_P << FRAME_TYPE_TOP_OFFSET) | (pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_BOTTOM_OFFSET));
                 break;
             case h264_PtypeI:
             case h264_PtypeSI:
-                if ( ((pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type) & (0x7 << FRAME_TYPE_TOP_OFFSET))>>FRAME_TYPE_TOP_OFFSET == FRAME_TYPE_INVALID)
+                if (((pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type) & (0x7 << FRAME_TYPE_TOP_OFFSET)) >> FRAME_TYPE_TOP_OFFSET == FRAME_TYPE_INVALID)
                 {
                     pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_I << FRAME_TYPE_TOP_OFFSET)|(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_BOTTOM_OFFSET));
                 }
@@ -752,25 +705,25 @@
     {
         if (pInfo->nal_unit_type == h264_NAL_UNIT_TYPE_IDR)
         {
-            pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_IDR << FRAME_TYPE_BOTTOM_OFFSET)|(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_TOP_OFFSET));;
+            pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_IDR << FRAME_TYPE_BOTTOM_OFFSET) | (pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_TOP_OFFSET));;
         }
         else
         {
             switch (pInfo->SliceHeader.slice_type)
             {
             case h264_PtypeB:
-                pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_B << FRAME_TYPE_BOTTOM_OFFSET)|(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_TOP_OFFSET));
+                pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_B << FRAME_TYPE_BOTTOM_OFFSET) | (pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_TOP_OFFSET));
                 break;
             case h264_PtypeSP:
             case h264_PtypeP:
-                if ( ((pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type) & (0x7 << FRAME_TYPE_BOTTOM_OFFSET))>>FRAME_TYPE_BOTTOM_OFFSET != FRAME_TYPE_B)
-                    pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_P << FRAME_TYPE_BOTTOM_OFFSET)|(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_TOP_OFFSET));
+                if ( ((pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type) & (0x7 << FRAME_TYPE_BOTTOM_OFFSET)) >> FRAME_TYPE_BOTTOM_OFFSET != FRAME_TYPE_B)
+                    pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_P << FRAME_TYPE_BOTTOM_OFFSET) | (pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_TOP_OFFSET));
                 break;
             case h264_PtypeI:
             case h264_PtypeSI:
-                if ( ((pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type) & (0x7 << FRAME_TYPE_BOTTOM_OFFSET))>>FRAME_TYPE_BOTTOM_OFFSET == FRAME_TYPE_INVALID)
+                if ( ((pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type) & (0x7 << FRAME_TYPE_BOTTOM_OFFSET)) >> FRAME_TYPE_BOTTOM_OFFSET == FRAME_TYPE_INVALID)
                 {
-                    pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_I << FRAME_TYPE_BOTTOM_OFFSET)|(pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_TOP_OFFSET));
+                    pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (FRAME_TYPE_I << FRAME_TYPE_BOTTOM_OFFSET) | (pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type & (0x7 << FRAME_TYPE_TOP_OFFSET));
                 }
                 if (pInfo->sei_rp_received)
                     pInfo->last_I_frame_idc = pInfo->dpb.fs_dec_idc + PUT_LIST_INDEX_FIELD_BIT(1);
@@ -782,7 +735,6 @@
                 break;
 
             }
-
         }
 
     }
diff --git a/mixvbp/vbp_plugin/h264/h264parse_bsd.c b/mixvbp/vbp_plugin/h264/h264parse_bsd.c
index 40c7559..84f94b2 100755
--- a/mixvbp/vbp_plugin/h264/h264parse_bsd.c
+++ b/mixvbp/vbp_plugin/h264/h264parse_bsd.c
@@ -60,20 +60,19 @@
 
 
             temp = (temp << bits_offset);
-            if (temp!=0)
+            if (temp != 0)
             {
                 bits_need_add_in_first_byte = bits_offset;
             }
-            is_first_byte =0;
+            is_first_byte = 0;
         }
         else
         {
             noOfBits = 8;/* always 8 bits as we read a byte at a time */
             bits_operation_result = viddec_pm_peek_bits(parent, &temp, 8);
-
         }
 
-        if (-1==bits_operation_result)
+        if (-1 == bits_operation_result)
         {
             return MAX_INT32_VALUE;
         }
@@ -81,7 +80,7 @@
         if (temp != 0)
         {
             // if byte!=0 we have at least one bit with value 1.
-            count=1;
+            count = 1;
             while (((temp & 0x80) != 0x80) && (count <= noOfBits))
             {
                 count++;
@@ -122,7 +121,7 @@
         count = ((count + bits_need_add_in_first_byte)& 0x7);
 
         leadingZeroBits --;
-        length =  leadingZeroBits;
+        length = leadingZeroBits;
         codeNum = 0;
         noOfBits = 8 - count;
 
@@ -174,8 +173,8 @@
 
     if (bIsSigned) //get signed integer golomb code else the value is unsigned
     {
-        sign = (sval & 0x1)?1:-1;
-        sval = (sval +1) >> 1;
+        sign = (sval & 0x1) ? 1 : -1;
+        sval = (sval + 1) >> 1;
         sval = sval * sign;
     }
 
@@ -189,11 +188,11 @@
 {
     uint8_t cnt = 0;
 
-    uint8_t  is_emul =0;
-    uint8_t 	cur_byte = 0;
-    int32_t  shift_bits =0;
+    uint8_t is_emul =0;
+    uint8_t cur_byte = 0;
+    int32_t shift_bits = 0;
     uint32_t ctr_bit = 0;
-    uint32_t bits_offset =0, byte_offset =0;
+    uint32_t bits_offset = 0, byte_offset =0;
 
     //remove warning
     pInfo = pInfo;
@@ -203,20 +202,20 @@
 
     viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);
 
-    shift_bits = 7-bits_offset;
+    shift_bits = 7 - bits_offset;
 
     // read one byte
     viddec_pm_get_cur_byte(parent, &cur_byte);
 
-    ctr_bit = ((cur_byte)>> (shift_bits--)) & 0x01;
+    ctr_bit = (cur_byte >> (shift_bits--)) & 0x01;
 
     // a stop bit has to be one
-    if (ctr_bit==0)
+    if (ctr_bit == 0)
         return 1;
 
-    while (shift_bits>=0 && !cnt)
+    while (shift_bits >= 0 && !cnt)
     {
-        cnt |= (((cur_byte)>> (shift_bits--)) & 0x01);   // set up control bit
+        cnt |= (((cur_byte) >> (shift_bits--)) & 0x01);   // set up control bit
     }
 
     return (cnt);
diff --git a/mixvbp/vbp_plugin/h264/h264parse_dpb.c b/mixvbp/vbp_plugin/h264/h264parse_dpb.c
index 5f660de..d238958 100755
--- a/mixvbp/vbp_plugin/h264/h264parse_dpb.c
+++ b/mixvbp/vbp_plugin/h264/h264parse_dpb.c
@@ -9,18 +9,14 @@
 
 #include "viddec_pm.h"
 
-
-//#include <limits.h>
 #include "h264parse.h"
 #include "h264parse_dpb.h"
-//#include "h264_debug.h"
+#include <vbp_trace.h>
 
 #ifndef NULL
 #define NULL 0
 #endif
-//#ifndef USER_MODE
-//#define NULL 0
-//#endif
+
 
 ///////////////////////// DPB init //////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
@@ -37,7 +33,7 @@
     //h264_memset(p_dpb, 0x0, sizeof(h264_DecodedPictureBuffer) );
 
 
-    for (i=0; i<NUM_DPB_FRAME_STORES; i++)
+    for (i = 0; i < NUM_DPB_FRAME_STORES; i++)
     {
         p_dpb->fs[i].fs_idc = MPD_DPB_FS_NULL_IDC;
         p_dpb->fs_dpb_idc[i] = MPD_DPB_FS_NULL_IDC;
@@ -108,18 +104,22 @@
             else
             {
                 uint32_t found_in_list = 0, i = 0;
-                for (i = 0; (i < p_dpb->ltref_frames_in_buffer) && (found_in_list == 0); i++) {
+                for (i = 0; (i < p_dpb->ltref_frames_in_buffer) && (found_in_list == 0); i++)
+                {
                     if (p_dpb->fs_ltref_idc[i] == p_dpb->active_fs->fs_idc) found_in_list = 1;
                 }
 
-                if (found_in_list == 0) h264_dpb_add_ltref_list(p_dpb, p_dpb->active_fs->fs_idc);
+                if (found_in_list == 0)
+                    h264_dpb_add_ltref_list(p_dpb, p_dpb->active_fs->fs_idc);
             }
         }
         else
         {
-            if (viddec_h264_get_dec_structure(p_dpb->active_fs) == FRAME) {
+            if (viddec_h264_get_dec_structure(p_dpb->active_fs) == FRAME)
+            {
                 h264_dpb_add_ref_list(p_dpb, p_dpb->active_fs->fs_idc);
-            } else
+            }
+            else
             {
                 uint32_t found_in_list = 0, i = 0;
 
@@ -162,7 +162,7 @@
     // Dodgy looking for embedded code here...
     if (size > 1)
     {
-        for (j = 0; j < size-1; j = j + 1) {
+        for (j = 0; j < size - 1; j = j + 1) {
             for (k = j + 1; k < size; k = k + 1) {
                 if ((desc & (sort_indices[j] < sort_indices[k]))|
                         (~desc & (sort_indices[j] > sort_indices[k])) )
@@ -232,23 +232,23 @@
     int32_t lterm;
 
     list_idx = 0;
-    lterm = (long_term)? 1:0;
+    lterm = (long_term)? 1 : 0;
 
-    if (list_size) {
-
-
+    if (list_size)
+    {
         top_idx = 0;
         bot_idx = 0;
 
-        if (currPicStructure == TOP_FIELD) {
-            while ((top_idx < list_size)||(bot_idx < list_size))
+        if (currPicStructure == TOP_FIELD)
+        {
+            while ((top_idx < list_size) || (bot_idx < list_size))
             {
                 /////////////////////////////////////////// ref Top Field
                 got_pic = 0;
                 while ((top_idx < list_size) & ~got_pic)
                 {
                     h264_dpb_set_active_fs(p_dpb, frame_list[top_idx]);
-                    if ((viddec_h264_get_is_used(p_dpb->active_fs))&0x1)
+                    if ((viddec_h264_get_is_used(p_dpb->active_fs)) & 0x1)
                     {
                         if (h264_dpb_pic_is_top_field_ref(p_dpb, long_term))
                         {
@@ -265,7 +265,7 @@
                 while ((bot_idx < list_size) & ~got_pic)
                 {
                     h264_dpb_set_active_fs(p_dpb, frame_list[bot_idx]);
-                    if ((viddec_h264_get_is_used(p_dpb->active_fs))&0x2)
+                    if ((viddec_h264_get_is_used(p_dpb->active_fs)) & 0x2)
                     {
                         if (h264_dpb_pic_is_bottom_field_ref(p_dpb, long_term))
                         {
@@ -281,14 +281,14 @@
 
         /////////////////////////////////////////////// current Bottom Field
         if (currPicStructure == BOTTOM_FIELD)	{
-            while ((top_idx < list_size)||(bot_idx < list_size))
+            while ((top_idx < list_size) || (bot_idx < list_size))
             {
                 /////////////////////////////////////////// ref Top Field
                 got_pic = 0;
                 while ((bot_idx < list_size) && (!(got_pic)))
                 {
                     h264_dpb_set_active_fs(p_dpb, frame_list[bot_idx]);
-                    if ((viddec_h264_get_is_used(p_dpb->active_fs))&0x2) {
+                    if ((viddec_h264_get_is_used(p_dpb->active_fs)) & 0x2) {
                         if (h264_dpb_pic_is_bottom_field_ref(p_dpb, long_term)) {
                             // short term ref pic
                             pic_list[list_idx] = PUT_LIST_LONG_TERM_BITS(lterm) + frame_list[bot_idx] + PUT_LIST_INDEX_FIELD_BIT(1);  // bottom_field
@@ -304,7 +304,7 @@
                 while ((top_idx < list_size) && (!(got_pic)))
                 {
                     h264_dpb_set_active_fs(p_dpb, frame_list[top_idx]);
-                    if ((viddec_h264_get_is_used(p_dpb->active_fs))&0x1) {
+                    if ((viddec_h264_get_is_used(p_dpb->active_fs)) & 0x1) {
                         if (h264_dpb_pic_is_top_field_ref(p_dpb, long_term)) {
                             // short term ref pic
                             pic_list[list_idx] = PUT_LIST_LONG_TERM_BITS(lterm) + frame_list[top_idx] + PUT_LIST_INDEX_FIELD_BIT(0);  // top_field
@@ -489,7 +489,8 @@
         if (pInfo->SliceHeader.slice_type == h264_PtypeP)
         {
             h264_list_sort(sort_fs_idc, list_sort_number, list0idx-p_dpb->listXsize[0], 0);
-            for (idx = p_dpb->listXsize[0]; idx < list0idx; idx++) {
+            for (idx = p_dpb->listXsize[0]; idx < list0idx; idx++)
+            {
                 p_dpb->listX_0[idx] = (1<<6) + sort_fs_idc[idx-p_dpb->listXsize[0]];
             }
             p_dpb->listXsize[0] = list0idx;
@@ -514,21 +515,27 @@
             h264_dpb_set_active_fs(p_dpb, p_dpb->fs_ref_idc[idx]);
             if (p_dpb->active_fs->frame.used_for_reference)
             {
-                if (p_dpb->active_fs->frame_num > pInfo->SliceHeader.frame_num) {
+                if (p_dpb->active_fs->frame_num > pInfo->SliceHeader.frame_num)
+                {
                     p_dpb->active_fs->frame_num_wrap = p_dpb->active_fs->frame_num - MaxFrameNum;
-                } else {
+                }
+                else
+                {
                     p_dpb->active_fs->frame_num_wrap = p_dpb->active_fs->frame_num;
                 }
 
-                if ((p_dpb->active_fs->frame.used_for_reference)&0x1) {
+                if ((p_dpb->active_fs->frame.used_for_reference) & 0x1)
+                {
                     p_dpb->active_fs->top_field.pic_num    = (p_dpb->active_fs->frame_num_wrap << 1) + add_top;
                 }
 
-                if ((p_dpb->active_fs->frame.used_for_reference)&0x2) {
+                if ((p_dpb->active_fs->frame.used_for_reference) & 0x2)
+                {
                     p_dpb->active_fs->bottom_field.pic_num = (p_dpb->active_fs->frame_num_wrap << 1) + add_bottom;
                 }
 
-                if (pInfo->SliceHeader.slice_type == h264_PtypeP) {
+                if (pInfo->SliceHeader.slice_type == h264_PtypeP)
+                {
                     sort_fs_idc[list0idx]      = p_dpb->fs_ref_idc[idx];
                     list_sort_number[list0idx] = p_dpb->active_fs->frame_num_wrap;
                     list0idx++;
@@ -539,7 +546,8 @@
         if (pInfo->SliceHeader.slice_type == h264_PtypeP)
         {
             h264_list_sort(sort_fs_idc, list_sort_number, list0idx, 1);
-            for (idx = 0; idx < list0idx; idx++) {
+            for (idx = 0; idx < list0idx; idx++)
+            {
                 gen_pic_fs_list0[idx] = sort_fs_idc[idx];
             }
 
@@ -557,11 +565,13 @@
         {
             h264_dpb_set_active_fs(p_dpb, p_dpb->fs_ltref_idc[idx]);
 
-            if (viddec_h264_get_is_long_term(p_dpb->active_fs)&0x1) {
+            if (viddec_h264_get_is_long_term(p_dpb->active_fs) & 0x1)
+            {
                 p_dpb->active_fs->top_field.long_term_pic_num    = (p_dpb->active_fs->top_field.long_term_frame_idx << 1) + add_top;
             }
 
-            if (viddec_h264_get_is_long_term(p_dpb->active_fs)&0x2) {
+            if (viddec_h264_get_is_long_term(p_dpb->active_fs) & 0x2)
+            {
                 p_dpb->active_fs->bottom_field.long_term_pic_num = (p_dpb->active_fs->bottom_field.long_term_frame_idx << 1) + add_bottom;
             }
 
@@ -576,19 +586,20 @@
         if (pInfo->SliceHeader.slice_type == h264_PtypeP)
         {
             h264_list_sort(sort_fs_idc, list_sort_number, listltidx, 0);
-            for (idx = 0; idx < listltidx; idx++) {
+            for (idx = 0; idx < listltidx; idx++) 
+            {
                 gen_pic_fs_listlt[idx] = sort_fs_idc[idx];
             }
             list0idx_1 = h264_dpb_gen_pic_list_from_frame_list(p_dpb, gen_pic_pic_list, gen_pic_fs_listlt, pInfo->img.structure, listltidx, 1);
 
-            for (idx = 0; idx < list0idx_1; idx++) {
+            for (idx = 0; idx < list0idx_1; idx++)
+            {
                 p_dpb->listX_0[p_dpb->listXsize[0]+idx] = gen_pic_pic_list[idx];
             }
             p_dpb->listXsize[0] += list0idx_1;
         }
     }
 
-
     if (pInfo->SliceHeader.slice_type == h264_PtypeI)
     {
         p_dpb->listXsize[0] = 0;
@@ -631,7 +642,7 @@
 
                     if (skip_picture == 0)
                     {
-                        if ((p_dpb->active_fs->frame.used_for_reference==3) && (!(p_dpb->active_fs->frame.is_long_term)))
+                        if ((p_dpb->active_fs->frame.used_for_reference == 3) && (!(p_dpb->active_fs->frame.is_long_term)))
                         {
                             if (pInfo->img.framepoc >= p_dpb->active_fs->frame.poc)
                             {
@@ -645,7 +656,8 @@
             }
 
             h264_list_sort(sort_fs_idc, list_sort_number, list0idx, 1);
-            for (idx = 0; idx < list0idx; idx++) {
+            for (idx = 0; idx < list0idx; idx++)
+            {
                 p_dpb->listX_0[idx] = sort_fs_idc[idx];
             }
 
@@ -680,17 +692,14 @@
             }
 
             h264_list_sort(sort_fs_idc, list_sort_number, list0idx-list0idx_1, 0);
-            for (idx = list0idx_1; idx < list0idx; idx++) {
+            for (idx = list0idx_1; idx < list0idx; idx++)
                 p_dpb->listX_0[idx] = sort_fs_idc[idx-list0idx_1];
-            }
 
-            for (idx = 0; idx < list0idx_1; idx++) {
+            for (idx = 0; idx < list0idx_1; idx++)
                 p_dpb->listX_1[list0idx-list0idx_1+idx] = p_dpb->listX_0[idx];
-            }
 
-            for (idx = list0idx_1; idx < list0idx; idx++) {
+            for (idx = list0idx_1; idx < list0idx; idx++)
                 p_dpb->listX_1[idx-list0idx_1] = p_dpb->listX_0[idx];
-            }
 
             p_dpb->listXsize[0] = list0idx;
             p_dpb->listXsize[1] = list0idx;
@@ -715,8 +724,8 @@
             h264_list_sort(sort_fs_idc, list_sort_number, list0idx, 0);
             for (idx = p_dpb->listXsize[0]; idx < (p_dpb->listXsize[0]+list0idx); idx = idx + 1)
             {
-                p_dpb->listX_0[idx] = (1<<6) + sort_fs_idc[idx-p_dpb->listXsize[0]];
-                p_dpb->listX_1[idx] = (1<<6) + sort_fs_idc[idx-p_dpb->listXsize[0]];
+                p_dpb->listX_0[idx] = (1 << 6) + sort_fs_idc[idx-p_dpb->listXsize[0]];
+                p_dpb->listX_1[idx] = (1 << 6) + sort_fs_idc[idx-p_dpb->listXsize[0]];
             }
 
             p_dpb->listXsize[0] += list0idx;
@@ -728,16 +737,20 @@
             {
                 h264_dpb_set_active_fs(p_dpb, p_dpb->fs_ref_idc[idx]);
 
-                if (viddec_h264_get_is_used(p_dpb->active_fs))	{
-                    if (check_non_existing) {
+                if (viddec_h264_get_is_used(p_dpb->active_fs))
+                {
+                    if (check_non_existing)
+                    {
                         if (viddec_h264_get_is_non_existent(p_dpb->active_fs))
                             skip_picture = 1;
                         else
                             skip_picture = 0;
                     }
 
-                    if (skip_picture == 0)  {
-                        if (pInfo->img.ThisPOC >= p_dpb->active_fs->frame.poc) {
+                    if (skip_picture == 0)
+                    {
+                        if (pInfo->img.ThisPOC >= p_dpb->active_fs->frame.poc)
+                        {
                             sort_fs_idc[list0idx]      = p_dpb->fs_ref_idc[idx];
                             list_sort_number[list0idx] = p_dpb->active_fs->frame.poc;
                             list0idx++;
@@ -747,7 +760,8 @@
             }
 
             h264_list_sort(sort_fs_idc, list_sort_number, list0idx, 1);
-            for (idx = 0; idx < list0idx; idx = idx + 1) {
+            for (idx = 0; idx < list0idx; idx = idx + 1)
+            {
                 gen_pic_fs_list0[idx] = sort_fs_idc[idx];
             }
 
@@ -759,15 +773,18 @@
                 h264_dpb_set_active_fs(p_dpb, p_dpb->fs_ref_idc[idx]);
                 if (viddec_h264_get_is_used(p_dpb->active_fs))
                 {
-                    if (check_non_existing) {
+                    if (check_non_existing)
+                    {
                         if (viddec_h264_get_is_non_existent(p_dpb->active_fs))
                             skip_picture = 1;
                         else
                             skip_picture = 0;
                     }
 
-                    if (skip_picture == 0) {
-                        if (pInfo->img.ThisPOC < p_dpb->active_fs->frame.poc) {
+                    if (skip_picture == 0)
+                    {
+                        if (pInfo->img.ThisPOC < p_dpb->active_fs->frame.poc)
+                        {
                             sort_fs_idc[list0idx-list0idx_1]      = p_dpb->fs_ref_idc[idx];
                             list_sort_number[list0idx-list0idx_1] = p_dpb->active_fs->frame.poc;
                             list0idx++;
@@ -863,12 +880,8 @@
             p_dpb->listXsize[1] = pInfo->SliceHeader.num_ref_idx_l1_active;
         }
 
-
-
     }
 
-
-
     /// DPB reorder list
     h264_dpb_reorder_lists(pInfo);
 
@@ -905,7 +918,7 @@
         }
         else // current picture is a field
         {
-            if (temp_fs->frame.used_for_reference&0x1)
+            if (temp_fs->frame.used_for_reference & 0x1)
                 if (!(temp_fs->top_field.is_long_term))
                     if (temp_fs->top_field.pic_num == pic_num)
                     {
@@ -952,12 +965,12 @@
         }
         else
         {
-            if (temp_fs->frame.used_for_reference&0x1)
+            if (temp_fs->frame.used_for_reference & 0x1)
                 if (temp_fs->top_field.is_long_term)
                     if (temp_fs->top_field.long_term_pic_num == long_term_pic_num)
                         return temp_fs;
 
-            if (temp_fs->frame.used_for_reference&0x2)
+            if (temp_fs->frame.used_for_reference & 0x2)
                 if (temp_fs->bottom_field.is_long_term)
                     if (temp_fs->bottom_field.long_term_pic_num == long_term_pic_num)
                     {
@@ -1247,9 +1260,9 @@
     // If the decoding start from RP and without exact point, all B frames belong to previous GOP should be throw away!
     //
 
-    if ((pInfo->SliceHeader.slice_type == h264_PtypeB)&&(pInfo->sei_b_state_ready ==0) && pInfo->sei_rp_received) {
-        pInfo->wl_err_curr |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
-        pInfo->wl_err_curr |= (FRAME << FIELD_ERR_OFFSET);
+    if ((pInfo->SliceHeader.slice_type == h264_PtypeB) && (pInfo->sei_b_state_ready ==0) && pInfo->sei_rp_received)
+    {
+        WTRACE("Error happens in %s, further clarification is needed...");
     }
 
 
@@ -1261,8 +1274,8 @@
 
         int32_t idx, rp_found = 0;
 
-        if ( ((pInfo->SliceHeader.num_ref_idx_l0_active == 1)&&(pInfo->SliceHeader.structure == FRAME)) ||
-                ((pInfo->SliceHeader.num_ref_idx_l0_active == 2)&&(pInfo->SliceHeader.structure != FRAME)) )
+        if (((pInfo->SliceHeader.num_ref_idx_l0_active == 1) && (pInfo->SliceHeader.structure == FRAME)) ||
+                ((pInfo->SliceHeader.num_ref_idx_l0_active == 2) && (pInfo->SliceHeader.structure != FRAME)))
         {
             if (pInfo->SliceHeader.sh_refpic_l0.ref_pic_list_reordering_flag)
             {
@@ -1368,7 +1381,7 @@
         {
 
         }
-        pInfo->dpb.listXsize[0]=pInfo->SliceHeader.num_ref_idx_l0_active;
+        pInfo->dpb.listXsize[0] = pInfo->SliceHeader.num_ref_idx_l0_active;
     } else if (currSliceType == h264_PtypeB)
     {
         /////////////////////////////////////////////// Reordering reference list for B slice
@@ -1388,7 +1401,7 @@
         {
 
         }
-        pInfo->dpb.listXsize[1]=pInfo->SliceHeader.num_ref_idx_l1_active;
+        pInfo->dpb.listXsize[1] = pInfo->SliceHeader.num_ref_idx_l1_active;
     }
 
     //// Check if need recover reference list with previous recovery point
@@ -1397,7 +1410,6 @@
         h264_dpb_RP_check_list(pInfo);
     }
 
-
     return;
 }
 
@@ -1446,11 +1458,14 @@
     int32_t first_field_non_ref = 0;
     int32_t idr_flag;
 
-    if (NonExisting) {
+    if (NonExisting)
+    {
         if (p_dpb->fs_non_exist_idc == MPD_DPB_FS_NULL_IDC)
             return;
         h264_dpb_set_active_fs(p_dpb, p_dpb->fs_non_exist_idc);
-    } else {
+    }
+    else
+    {
         if (p_dpb->fs_dec_idc == MPD_DPB_FS_NULL_IDC)
             return;
         h264_dpb_set_active_fs(p_dpb, p_dpb->fs_dec_idc);
@@ -1467,24 +1482,21 @@
 
         switch (viddec_h264_get_dec_structure(p_dpb->active_fs))
         {
-        case(TOP_FIELD)   : {
+        case(TOP_FIELD):
             p_dpb->active_fs->top_field.used_for_reference = used_for_reference;
             viddec_h264_set_is_top_used(p_dpb->active_fs, 1);
             //p_dpb->active_fs->crc_field_coded     = 1;
-        }
         break;
-        case(BOTTOM_FIELD): {
+        case(BOTTOM_FIELD):
             p_dpb->active_fs->bottom_field.used_for_reference = used_for_reference << 1;
             viddec_h264_set_is_bottom_used(p_dpb->active_fs, 1);
             //p_dpb->active_fs->crc_field_coded     = 1;
-        }
         break;
-        default: {
-            p_dpb->active_fs->frame.used_for_reference = used_for_reference?3:0;
+        default:
+            p_dpb->active_fs->frame.used_for_reference = used_for_reference ? 3 : 0;
             viddec_h264_set_is_frame_used(p_dpb->active_fs, 3);
             //if(pInfo->img.MbaffFrameFlag) p_dpb->active_fs->crc_field_coded  = 1;
 
-        }
         break;
         }
 
@@ -1492,18 +1504,22 @@
         //if (freeze_assert)  sei_information.disp_frozen = 1;
 
         idr_flag = use_old ? pInfo->old_slice.idr_flag : pInfo->SliceHeader.idr_flag;
-        if (idr_flag) {
+        if (idr_flag)
+        {
             h264_dpb_idr_memory_management (pInfo, &pInfo->active_SPS, pInfo->img.no_output_of_prior_pics_flag);
-        } else {
+        }
+        else
+        {
             // adaptive memory management
-            if (used_for_reference & pInfo->SliceHeader.sh_dec_refpic.adaptive_ref_pic_marking_mode_flag) {
+            if (used_for_reference & pInfo->SliceHeader.sh_dec_refpic.adaptive_ref_pic_marking_mode_flag)
+            {
                 h264_dpb_adaptive_memory_management(pInfo);
             }
         }
         // Reset the active frame store - could have changed in mem management ftns
         h264_dpb_set_active_fs(p_dpb, p_dpb->fs_dec_idc);
 
-        if ((viddec_h264_get_dec_structure(p_dpb->active_fs) == TOP_FIELD)||(viddec_h264_get_dec_structure(p_dpb->active_fs) == BOTTOM_FIELD))
+        if ((viddec_h264_get_dec_structure(p_dpb->active_fs) == TOP_FIELD) || (viddec_h264_get_dec_structure(p_dpb->active_fs) == BOTTOM_FIELD))
         {
             // check for frame store with same pic_number -- always true in my case, YH
             // when we allocate frame store for the second field, we make sure the frame store for the second
@@ -1526,7 +1542,7 @@
     { // Set up locals for non-existing frames
         used_for_reference = 1;
 
-        p_dpb->active_fs->frame.used_for_reference = used_for_reference?3:0;
+        p_dpb->active_fs->frame.used_for_reference = used_for_reference ? 3 : 0;
         viddec_h264_set_is_frame_used(p_dpb->active_fs, 3);
         viddec_h264_set_dec_structure(p_dpb->active_fs, FRAME);
         pInfo->img.structure = FRAME;
@@ -1552,12 +1568,18 @@
         }
     }
 
-    if (NonExisting) {
+    if (NonExisting)
+    {
         h264_dpb_sliding_window_memory_management(p_dpb, NonExisting, pInfo->active_SPS.num_ref_frames);
-    } else if (pInfo->SliceHeader.idr_flag == 0) {
-        if (used_for_reference) {
-            if (pInfo->img.second_field == 0) {
-                if (pInfo->SliceHeader.sh_dec_refpic.adaptive_ref_pic_marking_mode_flag == 0) {
+    }
+    else if (pInfo->SliceHeader.idr_flag == 0)
+    {
+        if (used_for_reference)
+        {
+            if (pInfo->img.second_field == 0)
+            {
+                if (pInfo->SliceHeader.sh_dec_refpic.adaptive_ref_pic_marking_mode_flag == 0)
+                {
                     h264_dpb_sliding_window_memory_management(p_dpb, NonExisting, pInfo->active_SPS.num_ref_frames);
                 }
             }
@@ -1577,7 +1599,8 @@
         // p_dpb->ref_frames_in_buffer + p_dpb->ltref_frames_in_buffer > p_dpb->BumpLevel,
         // which in itself is an error, but this means first_field_non_ref will
         // not get set and causes problems for h264_dpb_queue_update()
-        if ((pInfo->img.structure != FRAME) && (pInfo->img.second_field == 0)) {
+        if ((pInfo->img.structure != FRAME) && (pInfo->img.second_field == 0))
+        {
             if (used_for_reference ==	0)
                 if (p_dpb->ref_frames_in_buffer + p_dpb->ltref_frames_in_buffer == p_dpb->BumpLevel)
                     first_field_non_ref = 1;
@@ -1620,7 +1643,8 @@
                 else
                     p_dpb->OutputCtrl = 0;
             }
-            else {
+            else 
+            {
                 p_dpb->OutputCtrl = 0;
             }
         }
@@ -1637,7 +1661,8 @@
     // Do not output "direct output" pictures until the sempahore has been set that the pic is
     // decoded!!
     //
-    if (is_direct_output) {
+    if (is_direct_output)
+    {
         h264_dpb_queue_update(pInfo, 1, 1, 0,pInfo->active_SPS.num_ref_frames);
         //h264_dpb_remove_unused_frame_from_dpb(p_dpb, &flag);
     }
@@ -1645,13 +1670,13 @@
     //
     // Add reference pictures into Reference list
     //
-    if (used_for_reference) {
+    if (used_for_reference)
+    {
         h264_dpb_insert_ref_lists(&pInfo->dpb, NonExisting);
     }
 
     h264_dpb_remove_unused_frame_from_dpb(p_dpb, &flag);
 
-
     return;
 } ////////////// End of DPB store pic
 
@@ -1678,16 +1703,19 @@
 {
     h264_DecodedPictureBuffer *p_dpb = &pInfo->dpb;
 
-    if (NonExisting == 0) {
+    if (NonExisting == 0)
+    {
         h264_dpb_set_active_fs(p_dpb, p_dpb->fs_dec_idc);
         p_dpb->active_fs->frame_num = (use_old) ? pInfo->old_slice.frame_num : pInfo->SliceHeader.frame_num;
     }
-    else {
+    else
+    {
         h264_dpb_set_active_fs(p_dpb, p_dpb->fs_non_exist_idc);
         p_dpb->active_fs->frame_num = p_dpb->active_fs->frame.pic_num;
     }
 
-    if (add2dpb) {
+    if (add2dpb)
+    {
         p_dpb->fs_dpb_idc[p_dpb->used_size] = p_dpb->active_fs->fs_idc;
         p_dpb->used_size++;
     }
@@ -1695,9 +1723,10 @@
 
     switch (viddec_h264_get_dec_structure(p_dpb->active_fs))
     {
-    case FRAME : {
+    case FRAME :
+    {
         viddec_h264_set_is_frame_used(p_dpb->active_fs, 3);
-        p_dpb->active_fs->frame.used_for_reference = used_for_reference?3:0;
+        p_dpb->active_fs->frame.used_for_reference = used_for_reference ? 3 : 0;
         if (used_for_reference)
         {
             p_dpb->active_fs->frame.used_for_reference = 3;
@@ -1709,7 +1738,8 @@
 
     }
     break;
-    case TOP_FIELD : {
+    case TOP_FIELD :
+    {
         viddec_h264_set_is_top_used(p_dpb->active_fs, 1);
 
         p_dpb->active_fs->top_field.used_for_reference = used_for_reference;
@@ -1727,15 +1757,16 @@
         }
         else
         {
-            p_dpb->active_fs->frame.poc      = p_dpb->active_fs->top_field.poc;
+            p_dpb->active_fs->frame.poc = p_dpb->active_fs->top_field.poc;
         }
 
     }
     break;
-    case BOTTOM_FIELD : {
+    case BOTTOM_FIELD :
+    {
         viddec_h264_set_is_bottom_used(p_dpb->active_fs, 1);
 
-        p_dpb->active_fs->bottom_field.used_for_reference = (used_for_reference<<1);
+        p_dpb->active_fs->bottom_field.used_for_reference = (used_for_reference << 1);
         if (used_for_reference)
         {
             p_dpb->active_fs->frame.used_for_reference |= 0x2;
@@ -1745,7 +1776,8 @@
                 p_dpb->active_fs->long_term_frame_idx = p_dpb->active_fs->bottom_field.long_term_frame_idx;
             }
         }
-        if (viddec_h264_get_is_used(p_dpb->active_fs) == 3) {
+        if (viddec_h264_get_is_used(p_dpb->active_fs) == 3)
+        {
             h264_dpb_combine_field(p_dpb, use_old); // generate frame view
         }
         else
@@ -1794,7 +1826,7 @@
 
     unmark_done = 0;
 
-    for (idx =0; (idx < p_dpb->ref_frames_in_buffer) && (!(unmark_done)); idx++)
+    for (idx = 0; (idx < p_dpb->ref_frames_in_buffer) && (!(unmark_done)); idx++)
     {
         h264_dpb_set_active_fs(p_dpb, p_dpb->fs_ref_idc[idx]);
 
@@ -1825,7 +1857,7 @@
                How will this affect the reference list update ftn coming after??
 
             */
-            if ((p_dpb->active_fs->frame.used_for_reference&0x1) && (!(viddec_h264_get_is_long_term(p_dpb->active_fs)&0x01))&&
+            if ((p_dpb->active_fs->frame.used_for_reference & 0x1) && (!(viddec_h264_get_is_long_term(p_dpb->active_fs) & 0x01))&&
                     (p_dpb->active_fs->top_field.pic_num == picNumX) )
             {
                 p_dpb->active_fs->top_field.used_for_reference = 0;
@@ -1837,7 +1869,7 @@
                 if (p_dpb->active_fs->bottom_field.used_for_reference == 0)
                     h264_dpb_remove_ref_list(p_dpb, p_dpb->fs_ref_idc[idx]);
             }
-            if ((p_dpb->active_fs->frame.used_for_reference&0x2) && (!(viddec_h264_get_is_long_term(p_dpb->active_fs)&0x2)) &&
+            if ((p_dpb->active_fs->frame.used_for_reference & 0x2) && (!(viddec_h264_get_is_long_term(p_dpb->active_fs) & 0x2)) &&
                     (p_dpb->active_fs->bottom_field.pic_num == picNumX) )
             {
                 p_dpb->active_fs->bottom_field.used_for_reference = 0;
@@ -1886,7 +1918,7 @@
 
         if (pInfo->img.structure == FRAME)
         {
-            if ((p_dpb->active_fs->frame.used_for_reference==3) && (viddec_h264_get_is_long_term(p_dpb->active_fs)==3) &&
+            if ((p_dpb->active_fs->frame.used_for_reference == 3) && (viddec_h264_get_is_long_term(p_dpb->active_fs) == 3) &&
                     (p_dpb->active_fs->frame.long_term_pic_num == long_term_pic_num))
             {
                 h264_dpb_unmark_for_long_term_reference(p_dpb, p_dpb->fs_ltref_idc[idx]);
@@ -1897,7 +1929,7 @@
         else
         {
             /// Check top field
-            if ((p_dpb->active_fs->frame.used_for_reference&0x1) && (viddec_h264_get_is_long_term(p_dpb->active_fs)&0x1) &&
+            if ((p_dpb->active_fs->frame.used_for_reference & 0x1) && (viddec_h264_get_is_long_term(p_dpb->active_fs) & 0x1) &&
                     (p_dpb->active_fs->top_field.long_term_pic_num == long_term_pic_num) )
             {
                 p_dpb->active_fs->top_field.used_for_reference = 0;
@@ -1913,7 +1945,7 @@
             }
 
             /// Check Bottom field
-            if ((p_dpb->active_fs->frame.used_for_reference&0x2) && (viddec_h264_get_is_long_term(p_dpb->active_fs)&0x2) &&
+            if ((p_dpb->active_fs->frame.used_for_reference & 0x2) && (viddec_h264_get_is_long_term(p_dpb->active_fs) & 0x2) &&
                     (p_dpb->active_fs->bottom_field.long_term_pic_num == long_term_pic_num) )
             {
                 p_dpb->active_fs->bottom_field.used_for_reference = 0;
@@ -1949,18 +1981,18 @@
     int32_t pic_struct = INVALID;
     int32_t found = 0;
 
-    for (idx =0; (idx < p_dpb->ref_frames_in_buffer) && (!(found)); idx++)
+    for (idx = 0; (idx < p_dpb->ref_frames_in_buffer) && (!(found)); idx++)
     {
         h264_dpb_set_active_fs(p_dpb, p_dpb->fs_ref_idc[idx]);
 
-        if ((p_dpb->active_fs->frame.used_for_reference&0x1) && (!(viddec_h264_get_is_long_term(p_dpb->active_fs)&0x01))&&
+        if ((p_dpb->active_fs->frame.used_for_reference & 0x1) && (!(viddec_h264_get_is_long_term(p_dpb->active_fs) & 0x01))&&
                 (p_dpb->active_fs->top_field.pic_num == picNumX) )
         {
             found = 1;
             pic_struct = TOP_FIELD;
 
         }
-        if ((p_dpb->active_fs->frame.used_for_reference&0x2) && (!(viddec_h264_get_is_long_term(p_dpb->active_fs)&0x2)) &&
+        if ((p_dpb->active_fs->frame.used_for_reference & 0x2) && (!(viddec_h264_get_is_long_term(p_dpb->active_fs) & 0x2)) &&
                 (p_dpb->active_fs->bottom_field.pic_num == picNumX) )
         {
             found = 1;
@@ -1988,18 +2020,24 @@
     int32_t currPicNum;
     int32_t polarity = 0;
 
-    if (pInfo->img.structure == FRAME) {
+    if (pInfo->img.structure == FRAME)
+    {
         currPicNum = pInfo->img.frame_num;
-    } else {
+    }
+    else
+    {
         currPicNum = (pInfo->img.frame_num << 1) + 1;
     }
 
     picNumX = currPicNum - (difference_of_pic_nums_minus1 + 1);
 
     // remove frames / fields with same long_term_frame_idx
-    if (pInfo->img.structure == FRAME) {
+    if (pInfo->img.structure == FRAME)
+    {
         h264_dpb_unmark_long_term_frame_for_reference_by_frame_idx(p_dpb, long_term_frame_idx);
-    } else {
+    }
+    else
+    {
         polarity = h264_dpb_get_pic_struct_by_pic_num(p_dpb, picNumX);
 
         if (polarity != INVALID)
@@ -2182,7 +2220,8 @@
         }
     }
 
-    if (found) {
+    if (found)
+    {
         if (is_complement == 0)
         {
             h264_dpb_unmark_for_long_term_reference(p_dpb, p_dpb->fs_ltref_idc[idx-1]);
@@ -2332,40 +2371,40 @@
     {
         switch (pInfo->SliceHeader.sh_dec_refpic.memory_management_control_operation[idx])
         {
-        case   1: {	//Mark a short-term reference picture as	�unused for reference?
+        case   1: 
+            //Mark a short-term reference picture as unused for reference?
             h264_dpb_mm_unmark_short_term_for_reference(pInfo,
                     pInfo->SliceHeader.sh_dec_refpic.difference_of_pic_num_minus1[idx]);
-        }
         break;
-        case   2: {	//Mark a long-term reference picture as 	�unused for reference?
+        case   2: 
+            //Mark a long-term reference picture as unused for reference?
             h264_dpb_mm_unmark_long_term_for_reference(pInfo,
                     pInfo->SliceHeader.sh_dec_refpic.long_term_pic_num[idx]);
-        }
         break;
-        case  3: {		//Mark a short-term reference picture as	"used for long-term reference" and assign a long-term frame index to it
+        case  3:
+            //Mark a short-term reference picture as    "used for long-term reference" and assign a long-term frame index to it
             h264_dpb_mm_assign_long_term_frame_idx(pInfo,
                                                    pInfo->SliceHeader.sh_dec_refpic.difference_of_pic_num_minus1[idx],
                                                    pInfo->SliceHeader.sh_dec_refpic.long_term_frame_idx[idx]);
-        }
         break;
-        case  4: {	//Specify the maximum long-term frame index and
+        case  4:
+            //Specify the maximum long-term frame index and
             //mark all long-term reference pictureshaving long-term frame indices greater than
             //the maximum value as "unused for reference"
             h264_dpb_mm_update_max_long_term_frame_idx (&pInfo->dpb,
                     pInfo->SliceHeader.sh_dec_refpic.max_long_term_frame_idx_plus1[idx]);
-        }
         break;
-        case  5: {		//Mark all reference pictures as	"unused for reference" and set the MaxLongTermFrameIdx variable to
+        case  5:
+            //Mark all reference pictures as    "unused for reference" and set the MaxLongTermFrameIdx variable to
             // "no long-term frame indices"
             h264_dpb_mm_unmark_all_short_term_for_reference(&pInfo->dpb);
             h264_dpb_mm_update_max_long_term_frame_idx(&pInfo->dpb, 0);
             pInfo->img.last_has_mmco_5 = 1;
-        }
         break;
-        case   6: {	//Mark the current picture as	"used for long-term reference" and assign a long-term frame index to it
+        case   6:
+            //Mark the current picture as   "used for long-term reference" and assign a long-term frame index to it
             h264_dpb_mm_mark_current_picture_long_term(&pInfo->dpb,
                     pInfo->SliceHeader.sh_dec_refpic.long_term_frame_idx[idx]);
-        }
         break;
         }
         idx++;
@@ -2375,7 +2414,7 @@
     if (pInfo->img.last_has_mmco_5)
     {
         pInfo->img.frame_num = 0;
-        pInfo->SliceHeader.frame_num=0;
+        pInfo->SliceHeader.frame_num = 0;
         h264_dpb_set_active_fs(p_dpb, p_dpb->fs_dec_idc);
 
         if (viddec_h264_get_dec_structure(p_dpb->active_fs) == FRAME)
@@ -2436,12 +2475,12 @@
         // If the previous picture was an unpaired field, mark it as a dangler
         if (p_dpb->used_size)
         {
-            idx = p_dpb->used_size-1;
+            idx = p_dpb->used_size - 1;
             prev_idc = p_dpb->fs_dpb_idc[idx];
             if (prev_idc != MPD_DPB_FS_NULL_IDC)
             {
                 h264_dpb_set_active_fs(p_dpb, p_dpb->fs_dpb_idc[idx]);
-                p_dpb->active_fs->frame_num =0;
+                p_dpb->active_fs->frame_num = 0;
             }
         }
         pInfo->img.PreviousFrameNumOffset = 0;
@@ -2451,7 +2490,8 @@
     }
 
     // Check for gaps in frame_num
-    if (pInfo->SliceHeader.idr_flag) {
+    if (pInfo->SliceHeader.idr_flag)
+    {
         pInfo->img.PreviousFrameNum = pInfo->img.frame_num;
     }
     // Have we re-started following a recovery point message?
@@ -2464,9 +2504,12 @@
     */
     else if (pInfo->img.frame_num != pInfo->img.PreviousFrameNum)
     {
-        if (MaxFrameNum) {
+        if (MaxFrameNum)
+        {
             ldiv_mod_u((uint32_t)(pInfo->img.PreviousFrameNum + 1), (uint32_t)MaxFrameNum, &temp);
-        } else {
+        }
+        else
+        {
             temp = (uint32_t)pInfo->img.PreviousFrameNum + 1;
         }
         prev_frame_num_plus1_wrap = temp;
@@ -2479,16 +2522,13 @@
 
 
     //if(active_sps->gaps_in_frame_num_value_allowed_flag == 0) {
-    if (pInfo->img.gaps_in_frame_num && (active_sps->gaps_in_frame_num_value_allowed_flag == 0)) {
+    if (pInfo->img.gaps_in_frame_num && (active_sps->gaps_in_frame_num_value_allowed_flag == 0))
+    {
         // infer an unintentional loss of pictures
         // only invoke following process for a conforming bitstream
         // when gaps_in_frame_num_value_allowed_flag is equal to 1
         pInfo->img.gaps_in_frame_num = 0;
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        pInfo->sw_bail = 1;
-#endif
-#endif
+
         //mfd_printf("ERROR STREAM??\n");
         ////// Error handling here----
     }
@@ -2503,12 +2543,13 @@
     // If the previous picture was an unpaired field, mark it as a dangler
     if (p_dpb->used_size)
     {
-        idx = p_dpb->used_size-1;
+        idx = p_dpb->used_size - 1;
         prev_idc = p_dpb->fs_dpb_idc[idx];
         if (prev_idc != MPD_DPB_FS_NULL_IDC)
         {
             h264_dpb_set_active_fs(p_dpb, p_dpb->fs_dpb_idc[idx]);
-            if (viddec_h264_get_is_used(p_dpb->active_fs) != 3) {
+            if (viddec_h264_get_is_used(p_dpb->active_fs) != 3)
+            {
                 h264_dpb_mark_dangling_field(p_dpb, p_dpb->active_fs->fs_idc);  //, DANGLING_TYPE_GAP_IN_FRAME
             }
         }
@@ -2563,8 +2604,8 @@
 {
     h264_dpb_set_active_fs(p_dpb, fs_idc);
 
-    if (viddec_h264_get_is_used(p_dpb->active_fs)&0x1)  p_dpb->active_fs->top_field.used_for_reference = 0;
-    if (viddec_h264_get_is_used(p_dpb->active_fs)&0x2)  p_dpb->active_fs->bottom_field.used_for_reference = 0;
+    if (viddec_h264_get_is_used(p_dpb->active_fs) & 0x1)  p_dpb->active_fs->top_field.used_for_reference = 0;
+    if (viddec_h264_get_is_used(p_dpb->active_fs) & 0x2)  p_dpb->active_fs->bottom_field.used_for_reference = 0;
     if (viddec_h264_get_is_used(p_dpb->active_fs) == 3) p_dpb->active_fs->frame.used_for_reference = 0;
 
     p_dpb->active_fs->frame.used_for_reference = 0;
@@ -2586,13 +2627,13 @@
 {
     h264_dpb_set_active_fs(p_dpb, fs_idc);
 
-    if (viddec_h264_get_is_used(p_dpb->active_fs)&0x1)
+    if (viddec_h264_get_is_used(p_dpb->active_fs) & 0x1)
     {
         p_dpb->active_fs->top_field.used_for_reference = 0;
         p_dpb->active_fs->top_field.is_long_term = 0;
     }
 
-    if (viddec_h264_get_is_used(p_dpb->active_fs)&0x2)
+    if (viddec_h264_get_is_used(p_dpb->active_fs) & 0x2)
     {
         p_dpb->active_fs->bottom_field.used_for_reference = 0;
         p_dpb->active_fs->bottom_field.is_long_term = 0;
@@ -2674,13 +2715,13 @@
     *flag = 0;
     if (p_dpb->active_fs->frame.used_for_reference)
         *flag = 1;
-    else if (viddec_h264_get_is_used(p_dpb->active_fs) ==3) // frame
+    else if (viddec_h264_get_is_used(p_dpb->active_fs) == 3) // frame
         *flag = p_dpb->active_fs->frame.used_for_reference;
     else
     {
-        if (viddec_h264_get_is_used(p_dpb->active_fs)&0x1) // top field
+        if (viddec_h264_get_is_used(p_dpb->active_fs) & 0x1) // top field
             *flag = p_dpb->active_fs->top_field.used_for_reference;
-        if (viddec_h264_get_is_used(p_dpb->active_fs)&0x2) // bottom field
+        if (viddec_h264_get_is_used(p_dpb->active_fs) & 0x2) // bottom field
             *flag = *flag ||  p_dpb->active_fs->bottom_field.used_for_reference;
     }
 }
@@ -2752,7 +2793,8 @@
             p_dpb->fs_ltref_idc[i] = MPD_DPB_FS_NULL_IDC;
 
         ////////////////////////////////////////// Reset DPB and dpb list
-        for (i = 0; i < p_dpb->used_size; i++) {
+        for (i = 0; i < p_dpb->used_size; i++)
+        {
             p_dpb->fs[p_dpb->fs_dpb_idc[i]].fs_idc = MPD_DPB_FS_NULL_IDC;
             p_dpb->fs_dpb_idc[i] = MPD_DPB_FS_NULL_IDC;
         }
@@ -2962,10 +3004,10 @@
 
     /////Remove unused frame from dpb-list
     i = idx;
-    while ( (i + 1)< p_dpb->used_size)
+    while ((i + 1)< p_dpb->used_size)
     {
         p_dpb->fs_dpb_idc[i] = p_dpb->fs_dpb_idc[i + 1];
-        i ++;
+        i++;
     }
     p_dpb->fs_dpb_idc[i] = MPD_DPB_FS_NULL_IDC;
 
@@ -3147,9 +3189,9 @@
     //p_dpb->active_fs->frame.poc = p_dpb->active_fs->poc;
 
 
-    p_dpb->active_fs->frame.used_for_reference = p_dpb->active_fs->top_field.used_for_reference |(p_dpb->active_fs->bottom_field.used_for_reference);
+    p_dpb->active_fs->frame.used_for_reference = p_dpb->active_fs->top_field.used_for_reference | (p_dpb->active_fs->bottom_field.used_for_reference);
 
-    p_dpb->active_fs->frame.is_long_term = p_dpb->active_fs->top_field.is_long_term |(p_dpb->active_fs->bottom_field.is_long_term <<1);
+    p_dpb->active_fs->frame.is_long_term = p_dpb->active_fs->top_field.is_long_term | (p_dpb->active_fs->bottom_field.is_long_term << 1);
 
     if (p_dpb->active_fs->frame.is_long_term)
         p_dpb->active_fs->frame.long_term_frame_idx = p_dpb->active_fs->long_term_frame_idx;
@@ -3389,7 +3431,7 @@
                     // It should only happen in errored streams, and can happen if this picture had an MMCO,
                     // thus disabling h264_dpb_sliding_window_memory_management(), which would normally have
                     // unmarked the oldest reference frame.
-                    h264_dpb_sliding_window_memory_management(p_dpb, 0,num_ref_frames);
+                    h264_dpb_sliding_window_memory_management(p_dpb, 0, num_ref_frames);
                     h264_dpb_remove_unused_frame_from_dpb(p_dpb, &flag);
 
                     if (flag == 0) {
@@ -3493,14 +3535,17 @@
     }
 
     // output frames in POC order
-    if (output_all) {
-        while ((p_dpb->used_size > 0) && (p_dpb->used_size - keep_complement)) {
+    if (output_all)
+    {
+        while ((p_dpb->used_size > 0) && (p_dpb->used_size - keep_complement))
+        {
             h264_dpb_queue_update(pInfo, 1, 0, 0,num_ref_frames);
         }
     }
 
     flag = 1;
-    while (flag) {
+    while (flag)
+    {
         h264_dpb_remove_unused_frame_from_dpb(p_dpb, &flag);
     }
 
@@ -3543,7 +3588,8 @@
     }
 
     // initialize software DPB
-    if (p_dpb->active_fs) {
+    if (p_dpb->active_fs)
+    {
         viddec_h264_set_dec_structure(p_dpb->active_fs, INVALID);
     }
     h264_dpb_idr_memory_management(pInfo, &pInfo->active_SPS, no_output_of_prior_pics_flag);  // implied no_output_of_prior_pics_flag==1
@@ -3629,7 +3675,8 @@
     h264_DecodedPictureBuffer *p_dpb = &pInfo->dpb;
 
 
-    while ( dpb_setup_free_fb(p_dpb, &idc, &pip_setting)  != 0 ) {
+    while ( dpb_setup_free_fb(p_dpb, &idc, &pip_setting)  != 0 )
+    {
         ///
         /// Generally this is triggered a error case, no more frame buffer avaliable for next
         /// What we do here is just remove one with min-POC before get more info
@@ -3649,9 +3696,12 @@
     }
 
 
-    if (NonExisting) {
+    if (NonExisting)
+    {
         p_dpb->fs_non_exist_idc = idc;
-    } else {
+    }
+    else
+    {
         p_dpb->fs_dec_idc = idc;
     }
 
@@ -3670,7 +3720,7 @@
     viddec_h264_set_is_non_existent(p_dpb->active_fs, NonExisting);
     viddec_h264_set_is_output(p_dpb->active_fs, (NonExisting?1:0));
 
-    p_dpb->active_fs->pic_type = ((FRAME_TYPE_INVALID<<FRAME_TYPE_TOP_OFFSET)|(FRAME_TYPE_INVALID<<FRAME_TYPE_BOTTOM_OFFSET));			//----
+    p_dpb->active_fs->pic_type = ((FRAME_TYPE_INVALID << FRAME_TYPE_TOP_OFFSET) | (FRAME_TYPE_INVALID << FRAME_TYPE_BOTTOM_OFFSET));
 
     // Only put members in here which will not be reset somewhere else
     // and which could be used before they are overwritten again with
@@ -3705,7 +3755,7 @@
     {
         if (dpb_ptr->fs_dpb_idc[dpb_ptr->used_size-1] != MPD_DPB_FS_NULL_IDC)
         {
-            h264_dpb_set_active_fs(dpb_ptr, dpb_ptr->fs_dpb_idc[dpb_ptr->used_size-1]);
+            h264_dpb_set_active_fs(dpb_ptr, dpb_ptr->fs_dpb_idc[dpb_ptr->used_size - 1]);
             if (viddec_h264_get_is_used(dpb_ptr->active_fs) != 3)
             {
                 prev_pic_unpaired_field = 1;
@@ -3720,13 +3770,15 @@
             {
                 // If we establish the previous pic was an unpaired field and this picture is not
                 // its complement, the previous picture was a dangling field
-                if (pInfo->img.second_field == 0) {
+                if (pInfo->img.second_field == 0)
+                {
                     while (dpb_ptr->used_size > dpb_ptr->BumpLevel)
                         h264_dpb_queue_update(pInfo, 1, 0, 0,pInfo->active_SPS.num_ref_frames); // flush a frame
                 }
             }
         }
-        else if (prev_pic_unpaired_field) {
+        else if (prev_pic_unpaired_field)
+        {
             while (dpb_ptr->used_size > dpb_ptr->BumpLevel)
                 h264_dpb_queue_update(pInfo, 1, 0, 0,pInfo->active_SPS.num_ref_frames); // flush a frame
         }
@@ -3758,13 +3810,13 @@
 
     if (dpb_ptr->used_size)
     {
-        idx = dpb_ptr->used_size-1;
+        idx = dpb_ptr->used_size - 1;
         prev_idc = dpb_ptr->fs_dpb_idc[idx];
     }
 
     if (prev_idc != MPD_DPB_FS_NULL_IDC)
     {
-        h264_dpb_set_active_fs(dpb_ptr, dpb_ptr->fs_dpb_idc[dpb_ptr->used_size-1]);
+        h264_dpb_set_active_fs(dpb_ptr, dpb_ptr->fs_dpb_idc[dpb_ptr->used_size - 1]);
         if (viddec_h264_get_is_used(dpb_ptr->active_fs) != 3)
         {
             //PRINTF(MFD_NONE, " FN: %d p_dpb->active_fs->is_used = %d \n", (h264_frame_number+1), p_dpb->active_fs->is_used);
@@ -3787,7 +3839,8 @@
                 h264_dpb_mark_dangling_field(dpb_ptr, dpb_ptr->active_fs->fs_idc);  //, DANGLING_TYPE_FIELD
         }
     }
-    else if (prev_pic_unpaired_field) {
+    else if (prev_pic_unpaired_field)
+    {
         h264_dpb_mark_dangling_field(dpb_ptr, dpb_ptr->active_fs->fs_idc);		//, DANGLING_TYPE_FRAME
     }
 
@@ -3806,7 +3859,8 @@
 
     ////////////// TODO: THe following init
 #if 1
-    if ( pInfo->img.second_field) {
+    if ( pInfo->img.second_field)
+    {
         //p_dpb->active_fs->second_dsn = pInfo->img.dsn;
         //p_dpb->active_fs->prev_dsn = pInfo->img.prev_dsn;
         if (dpb_ptr->active_fs->pic_type == FRAME_TYPE_IDR ||
@@ -3904,15 +3958,15 @@
 
 void h264_hdr_decoding_poc (h264_Info * pInfo,int32_t NonExisting, int32_t frame_num)
 {
-    int32_t MaxPicOrderCntLsb = (1<<(pInfo->active_SPS.log2_max_pic_order_cnt_lsb_minus4+4));
+    int32_t MaxPicOrderCntLsb = (1<<(pInfo->active_SPS.log2_max_pic_order_cnt_lsb_minus4 + 4));
     int32_t delta_pic_order_count[2];
     int32_t MaxFrameNum = 1 << (pInfo->active_SPS.log2_max_frame_num_minus4 + 4);
 
     int32_t AbsFrameNum =0;
-    int32_t ExpectedDeltaPerPicOrderCntCycle =0;
+    int32_t ExpectedDeltaPerPicOrderCntCycle = 0;
     int32_t PicOrderCntCycleCnt = 0;
-    int32_t FrameNumInPicOrderCntCycle =0;
-    int32_t ExpectedPicOrderCnt =0;
+    int32_t FrameNumInPicOrderCntCycle = 0;
+    int32_t ExpectedPicOrderCnt = 0;
 
     int32_t actual_frame_num =0;
 
@@ -3947,26 +4001,28 @@
 
         // Calculate the MSBs of current picture
         if ((pInfo->img.pic_order_cnt_lsb < pInfo->img.PrevPicOrderCntLsb)  &&
-                ((pInfo->img.PrevPicOrderCntLsb - pInfo->img.pic_order_cnt_lsb )>=(MaxPicOrderCntLsb>>1)) )
+                ((pInfo->img.PrevPicOrderCntLsb - pInfo->img.pic_order_cnt_lsb ) >= (MaxPicOrderCntLsb >> 1)))
         {
             pInfo->img.CurrPicOrderCntMsb = pInfo->img.PicOrderCntMsb + MaxPicOrderCntLsb;
-        } else if ((pInfo->img.pic_order_cnt_lsb  >  pInfo->img.PrevPicOrderCntLsb)  &&
+        }
+        else if ((pInfo->img.pic_order_cnt_lsb  >  pInfo->img.PrevPicOrderCntLsb)  &&
                    ((pInfo->img.pic_order_cnt_lsb - pInfo->img.PrevPicOrderCntLsb ) > (MaxPicOrderCntLsb>>1)) )
         {
             pInfo->img.CurrPicOrderCntMsb = pInfo->img.PicOrderCntMsb - MaxPicOrderCntLsb;
-        } else
+        } 
+        else
         {
             pInfo->img.CurrPicOrderCntMsb = pInfo->img.PicOrderCntMsb;
         }
 
         // 2nd
 
-        if (pInfo->img.field_pic_flag==0)
+        if (pInfo->img.field_pic_flag == 0)
         {
             //frame pix
             pInfo->img.toppoc = pInfo->img.CurrPicOrderCntMsb + pInfo->img.pic_order_cnt_lsb;
             pInfo->img.bottompoc = pInfo->img.toppoc + pInfo->img.delta_pic_order_cnt_bottom;
-            pInfo->img.ThisPOC = pInfo->img.framepoc = (pInfo->img.toppoc < pInfo->img.bottompoc)? pInfo->img.toppoc : pInfo->img.bottompoc; // POC200301
+            pInfo->img.ThisPOC = pInfo->img.framepoc = (pInfo->img.toppoc < pInfo->img.bottompoc) ? pInfo->img.toppoc : pInfo->img.bottompoc; // POC200301
         }
         else if (pInfo->img.bottom_field_flag==0)
         {  //top field
@@ -3988,7 +4044,7 @@
         }
 
         break;
-    case 1: {
+    case 1:
         if (NonExisting)
         {
             delta_pic_order_count[0] = 0;
@@ -4007,14 +4063,6 @@
         if (pInfo->SliceHeader.idr_flag)
         {
             pInfo->img.FrameNumOffset         = 0;
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            if (pInfo->img.frame_num)
-            {
-                pInfo->sw_bail = 1;
-            }
-#endif
-#endif
         }
         else
         {
@@ -4060,16 +4108,12 @@
             FrameNumInPicOrderCntCycle = temp;
 
             //ExpectedPicOrderCnt +=pInfo->active_SPS.expectedDeltaPerPOCCycle;
-#ifndef USER_MODE
             h264_Parse_Copy_Offset_Ref_Frames_From_DDR(pInfo, offset_for_ref_frame, pInfo->active_SPS.seq_parameter_set_id);
             for (i = 0; i <= FrameNumInPicOrderCntCycle; i++)
                 ExpectedPicOrderCnt += offset_for_ref_frame[i];
-#else
-            for (i = 0; i <= FrameNumInPicOrderCntCycle; i++)
-                ExpectedPicOrderCnt += pInfo->active_SPS.offset_for_ref_frame[i];
-#endif
         }
-        else {
+        else
+        {
             ExpectedPicOrderCnt = 0;
         }
 
@@ -4105,9 +4149,9 @@
         pInfo->img.PreviousFrameNum=pInfo->img.frame_num;
         pInfo->img.PreviousFrameNumOffset=pInfo->img.FrameNumOffset;
 
-    }
     break;
-    case 2: {     // POC MODE 2
+    case 2:
+        // POC MODE 2
         if (pInfo->SliceHeader.idr_flag)
         {
             pInfo->img.FrameNumOffset = 0;
@@ -4115,14 +4159,6 @@
             pInfo->img.toppoc = 0;
             pInfo->img.bottompoc = 0;
             pInfo->img.ThisPOC = 0;
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            if (pInfo->img.frame_num)
-            {
-                pInfo->sw_bail = 1;
-            }
-#endif
-#endif
         }
         else
         {
@@ -4137,8 +4173,8 @@
                 pInfo->img.FrameNumOffset = pInfo->img.PreviousFrameNumOffset;
 
             AbsFrameNum = pInfo->img.FrameNumOffset + actual_frame_num;
-            if (pInfo->SliceHeader.nal_ref_idc == 0) pInfo->img.ThisPOC = (AbsFrameNum<<1) - 1;
-            else                     pInfo->img.ThisPOC = (AbsFrameNum<<1);
+            if (pInfo->SliceHeader.nal_ref_idc == 0) pInfo->img.ThisPOC = (AbsFrameNum << 1) - 1;
+            else                     pInfo->img.ThisPOC = (AbsFrameNum << 1);
 
             if (!(pInfo->img.field_pic_flag))
             {
@@ -4161,7 +4197,6 @@
         //CONFORMANCE_ISSUE
         pInfo->img.PreviousFrameNum = pInfo->img.frame_num;
         pInfo->img.PreviousFrameNumOffset = pInfo->img.FrameNumOffset;
-    }
     break;
     default:
         break;
@@ -4189,7 +4224,7 @@
 
     switch (pInfo->img.pic_order_cnt_type)
     {
-    case  0: {
+    case  0:
         pInfo->img.PreviousFrameNum   = actual_frame_num;
         if ((disposable_flag == 0) && (NonExisting == 0))
         {
@@ -4197,22 +4232,18 @@
                                             pInfo->SliceHeader.pic_order_cnt_lsb;
             pInfo->img.PicOrderCntMsb     = pInfo->img.CurrPicOrderCntMsb;
         }
-    }
     break;
-    case  1: {
+    case  1:
         pInfo->img.PreviousFrameNum       = actual_frame_num;
         pInfo->img.PreviousFrameNumOffset = pInfo->img.FrameNumOffset;
-    }
     break;
-    case  2: {
+    case  2:
         pInfo->img.PreviousFrameNum       = actual_frame_num;
         pInfo->img.PreviousFrameNumOffset = pInfo->img.FrameNumOffset;
-
-    }
     break;
 
-    default: {
-    } break;
+    default:
+    break;
     }
 
     return;
diff --git a/mixvbp/vbp_plugin/h264/h264parse_mem.c b/mixvbp/vbp_plugin/h264/h264parse_mem.c
index b5a0145..0c39b17 100755
--- a/mixvbp/vbp_plugin/h264/h264parse_mem.c
+++ b/mixvbp/vbp_plugin/h264/h264parse_mem.c
@@ -45,7 +45,6 @@
 }
 
 
-#ifndef USER_MODE
 
 //h264_Parse_Copy_Sps_To_DDR () copy local sps to ddr mem
 void h264_Parse_Copy_Pps_To_DDR(h264_Info* pInfo, pic_param_set_ptr PPS, uint32_t nPPSId)
@@ -193,6 +192,3 @@
 //end of h264_Parse_Clear_Sps_Updated_Flag
 
 
-#endif
-
-
diff --git a/mixvbp/vbp_plugin/h264/h264parse_pps.c b/mixvbp/vbp_plugin/h264/h264parse_pps.c
index 17f0930..2c4cc52 100755
--- a/mixvbp/vbp_plugin/h264/h264parse_pps.c
+++ b/mixvbp/vbp_plugin/h264/h264parse_pps.c
@@ -1,7 +1,6 @@
-
-
 #include "h264.h"
 #include "h264parse.h"
+#include <vbp_trace.h>
 
 /*---------------------------------------------*/
 /*---------------------------------------------*/
@@ -11,39 +10,26 @@
     h264_Status ret = H264_PPS_ERROR;
 
     //h264_PicParameterSet_t* PictureParameterSet = &pInfo->PictureParameterSet;
-    uint32_t code=0, i = 0;
+    uint32_t code = 0, i = 0;
 
     do {
         ///// PPS par1: pic_parameter_set_id & seq_parameter_set_id
         code = h264_GetVLCElement(parent, pInfo, false);
-        if (code > MAX_PIC_PARAMS) {
+        if (code > MAX_PIC_PARAMS)
+        {
+            ETRACE("PPS id is out of range: %d", code);
             break;
         }
         PictureParameterSet->pic_parameter_set_id = (uint8_t)code;
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if (code > 255)
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
-
         code = h264_GetVLCElement(parent, pInfo, false);
-        if (code > MAX_NUM_SPS-1) {
+        if (code > MAX_NUM_SPS - 1)
+        {
+            ETRACE("SPS id in PPS is bad: %d", code);
             break;
         }
         PictureParameterSet->seq_parameter_set_id = (uint8_t)code;
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if (code > 31)
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
         ///// entropy_coding_mode_flag
         viddec_pm_get_bits(parent, &code, 1);
         PictureParameterSet->entropy_coding_mode_flag = (uint8_t)code;
@@ -53,31 +39,22 @@
 
         PictureParameterSet->num_slice_groups_minus1 = h264_GetVLCElement(parent, pInfo, false);
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if (PictureParameterSet->num_slice_groups_minus1 > 8)
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
         //
         // In main profile, FMO is excluded and num_slice_groups_minus1 should be 0
         //
         if (PictureParameterSet->num_slice_groups_minus1 > 0) //MAX_NUM_SLICE_GRPS)
+        {
+            ETRACE("FMO is not supported");
             break;
+        }
 
-        PictureParameterSet->num_ref_idx_l0_active = h264_GetVLCElement(parent, pInfo, false)+1;
-        PictureParameterSet->num_ref_idx_l1_active = h264_GetVLCElement(parent, pInfo, false)+1;
+        PictureParameterSet->num_ref_idx_l0_active = h264_GetVLCElement(parent, pInfo, false) + 1;
+        PictureParameterSet->num_ref_idx_l1_active = h264_GetVLCElement(parent, pInfo, false) + 1;
 
         //// PPS->num_ref_idx_l0_active --- [0,32]
         if (((PictureParameterSet->num_ref_idx_l0_active) > MAX_NUM_REF_FRAMES) || ((PictureParameterSet->num_ref_idx_l1_active) > MAX_NUM_REF_FRAMES))
         {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
+            ETRACE("The number in the ref list is greater than 32");
             break;
         }
 
@@ -85,39 +62,19 @@
         viddec_pm_get_bits(parent, &code, 1);
         PictureParameterSet->weighted_pred_flag = (uint8_t)code;
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if (code > 2)
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
         viddec_pm_get_bits(parent, &code, 2);
         PictureParameterSet->weighted_bipred_idc = (uint8_t)code;
 
         //// QP
         PictureParameterSet->pic_init_qp_minus26 = h264_GetVLCElement(parent, pInfo, true);
         PictureParameterSet->pic_init_qs_minus26 = h264_GetVLCElement(parent, pInfo, true);
-        if (((PictureParameterSet->pic_init_qp_minus26+26) > MAX_QP) || ((PictureParameterSet->pic_init_qs_minus26+26) > MAX_QP))
+        if (((PictureParameterSet->pic_init_qp_minus26 + 26) > MAX_QP) || ((PictureParameterSet->pic_init_qs_minus26 + 26) > MAX_QP))
         {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
+            ETRACE("QP is greater than 51");
             break;
         }
         PictureParameterSet->chroma_qp_index_offset = h264_GetVLCElement(parent, pInfo, true);
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if ((12 < PictureParameterSet->chroma_qp_index_offset) || (-12 > PictureParameterSet->chroma_qp_index_offset) )
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
         //// Deblocking ctl parameters
         viddec_pm_get_bits(parent, &code, 1);
         PictureParameterSet->deblocking_filter_control_present_flag = (uint8_t)code;
@@ -129,52 +86,36 @@
             break;
         PictureParameterSet->redundant_pic_cnt_present_flag = (uint8_t)code;
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if (code && (pInfo->active_SPS.profile_idc != h264_ProfileBaseline))
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
         //// Check if have more RBSP Data for additional parameters
         if (h264_More_RBSP_Data(parent, pInfo))
         {
-            viddec_pm_get_bits(parent,  &code, 1);
+            viddec_pm_get_bits(parent, &code, 1);
             PictureParameterSet->transform_8x8_mode_flag = (uint8_t)code;
 
-            if ( viddec_pm_get_bits(parent, &code, 1) == -1)
+            if (viddec_pm_get_bits(parent, &code, 1) == -1)
                 break;
             PictureParameterSet->pic_scaling_matrix_present_flag = (uint8_t)code;
 
             if (PictureParameterSet->pic_scaling_matrix_present_flag)
             {
                 uint32_t n_ScalingList = 6 + (PictureParameterSet->transform_8x8_mode_flag << 1);
-                for (i=0; i<n_ScalingList; i++)
+                for (i = 0; i < n_ScalingList; i++)
                 {
-                    if ( viddec_pm_get_bits(parent, &code, 1) == -1)
+                    if (viddec_pm_get_bits(parent, &code, 1) == -1)
                         break;
                     PictureParameterSet->pic_scaling_list_present_flag[i] = (uint8_t)code;
 
                     if (PictureParameterSet->pic_scaling_list_present_flag[i])
                     {
-                        if (i<6)
+                        if (i < 6)
                             h264_Scaling_List(parent, PictureParameterSet->ScalingList4x4[i], 16, &PictureParameterSet->UseDefaultScalingMatrix4x4Flag[i], pInfo);
                         else
-                            h264_Scaling_List(parent, PictureParameterSet->ScalingList8x8[i-6], 64, &PictureParameterSet->UseDefaultScalingMatrix8x8Flag[i-6], pInfo);
+                            h264_Scaling_List(parent, PictureParameterSet->ScalingList8x8[i - 6], 64, &PictureParameterSet->UseDefaultScalingMatrix8x8Flag[i - 6], pInfo);
                     }
                 }
             }
 
             PictureParameterSet->second_chroma_qp_index_offset = h264_GetVLCElement(parent, pInfo, true); //fix
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            if((PictureParameterSet->second_chroma_qp_index_offset>12) || (PictureParameterSet->second_chroma_qp_index_offset < -12))
-            {
-                pInfo->sw_bail = 1;
-            }
-#endif
-#endif
         }
         else
         {
diff --git a/mixvbp/vbp_plugin/h264/h264parse_sei.c b/mixvbp/vbp_plugin/h264/h264parse_sei.c
index 12f793d..df18cc3 100755
--- a/mixvbp/vbp_plugin/h264/h264parse_sei.c
+++ b/mixvbp/vbp_plugin/h264/h264parse_sei.c
@@ -7,6 +7,7 @@
 #include "h264parse_dpb.h"
 
 #include "viddec_parser_ops.h"
+#include <vbp_trace.h>
 
 //////////////////////////////////////////////////////////////////////////////
 // avc_sei_stream_initialise ()
@@ -50,7 +51,10 @@
 
         sei_msg_ptr->seq_param_set_id = h264_GetVLCElement(parent, pInfo, false);
         if (sei_msg_ptr->seq_param_set_id >= NUM_SPS)
+        {
+            ETRACE("SEI parsing: SPS id is out of range: %d", sei_msg_ptr->seq_param_set_id);
             break;
+        }
 
         //check if this id is same as the id of the current SPS  //fix
 
@@ -133,18 +137,26 @@
         sei_msg_ptr->pic_struct = (uint8_t)code;
 
 
-        if ((sei_msg_ptr->pic_struct == 0) || (sei_msg_ptr->pic_struct == 7) || (sei_msg_ptr->pic_struct == 8)) {
+        if ((sei_msg_ptr->pic_struct == 0) || (sei_msg_ptr->pic_struct == 7) || (sei_msg_ptr->pic_struct == 8))
+        {
             pInfo->sei_information.scan_format = SEI_SCAN_FORMAT_PROGRESSIVE;
-        } else {
+        }
+        else
+        {
             pInfo->sei_information.scan_format = SEI_SCAN_FORMAT_INTERLACED;
         }
 
 
-        if (sei_msg_ptr->pic_struct < 3) {
+        if (sei_msg_ptr->pic_struct < 3)
+        {
             NumClockTS = 1;
-        } else if ((sei_msg_ptr->pic_struct < 5) || (sei_msg_ptr->pic_struct == 7)) {
+        }
+        else if ((sei_msg_ptr->pic_struct < 5) || (sei_msg_ptr->pic_struct == 7))
+        {
             NumClockTS = 2;
-        } else {
+        }
+        else
+        {
             NumClockTS = 3;
         }
 
@@ -389,7 +401,8 @@
     pInfo->sei_information.capture_fn         = 1;
     pInfo->sei_information.broken_link_pic    = sei_msg_ptr->broken_link_flag;
 
-    if (pInfo->got_start)	{
+    if (pInfo->got_start)
+    {
         pInfo->img.recovery_point_found |= 2;
 
         //// Enable the RP recovery if no IDR ---Cisco
diff --git a/mixvbp/vbp_plugin/h264/h264parse_sh.c b/mixvbp/vbp_plugin/h264/h264parse_sh.c
index 9db8cee..0d8dc9d 100755
--- a/mixvbp/vbp_plugin/h264/h264parse_sh.c
+++ b/mixvbp/vbp_plugin/h264/h264parse_sh.c
@@ -3,6 +3,7 @@
 
 #include "h264.h"
 #include "h264parse.h"
+#include <vbp_trace.h>
 
 extern int32_t viddec_pm_get_au_pos(void *parent, uint32_t *bit, uint32_t *byte, unsigned char *is_emul);
 
@@ -25,30 +26,21 @@
 
         ///// slice_type
         slice_type = h264_GetVLCElement(parent, pInfo, false);
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if (slice_type > 9)
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
-        SliceHeader->slice_type = (slice_type%5);
 
-        if (SliceHeader->slice_type > h264_PtypeI)	{
+        SliceHeader->slice_type = (slice_type % 5);
+
+        if (SliceHeader->slice_type > h264_PtypeI)
+        {
+            WTRACE("Slice type (%d) is not supported", SliceHeader->slice_type);
             ret = H264_STATUS_NOTSUPPORT;
             break;
         }
 
-
         ////// pic_parameter_id
         data = h264_GetVLCElement(parent, pInfo, false);
-        if (data > MAX_PIC_PARAMS) {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
+        if (data > MAX_PIC_PARAMS)
+        {
+            WTRACE("pic_parameter_id is invalid", data);
             ret = H264_PPS_INVALID_PIC_ID;
             break;
         }
@@ -79,7 +71,7 @@
         //////////////////////////////////// Slice header part 2//////////////////
 
         /// Frame_num
-        viddec_pm_get_bits(parent, &code, pInfo->active_SPS.log2_max_frame_num_minus4+4);
+        viddec_pm_get_bits(parent, &code, pInfo->active_SPS.log2_max_frame_num_minus4 + 4);
         SliceHeader->frame_num = (int32_t)code;
 
         /// Picture structure
@@ -98,46 +90,39 @@
                 viddec_pm_get_bits(parent, &code, 1);
                 SliceHeader->bottom_field_flag = (uint8_t)code;
 
-                SliceHeader->structure = SliceHeader->bottom_field_flag? BOTTOM_FIELD: TOP_FIELD;
+                SliceHeader->structure = SliceHeader->bottom_field_flag ? BOTTOM_FIELD: TOP_FIELD;
             }
         }
 
         ////// Check valid or not of first_mb_in_slice
-        if (SliceHeader->structure == FRAME) {
+        if (SliceHeader->structure == FRAME)
+        {
             max_mb_num = pInfo->img.FrameHeightInMbs * pInfo->img.PicWidthInMbs;
-        } else {
-            max_mb_num = pInfo->img.FrameHeightInMbs * pInfo->img.PicWidthInMbs/2;
+        }
+        else
+        {
+            max_mb_num = pInfo->img.FrameHeightInMbs * pInfo->img.PicWidthInMbs / 2;
         }
 
-
         ///if(pInfo->img.MbaffFrameFlag)
-        if (pInfo->active_SPS.sps_disp.mb_adaptive_frame_field_flag & (!(pInfo->SliceHeader.field_pic_flag))) {
-            SliceHeader->first_mb_in_slice <<=1;
+        if (pInfo->active_SPS.sps_disp.mb_adaptive_frame_field_flag & (!(pInfo->SliceHeader.field_pic_flag)))
+        {
+            SliceHeader->first_mb_in_slice <<= 1;
         }
 
         if (SliceHeader->first_mb_in_slice >= max_mb_num)
             break;
 
-
         if (pInfo->nal_unit_type == h264_NAL_UNIT_TYPE_IDR)
         {
             SliceHeader->idr_pic_id = h264_GetVLCElement(parent, pInfo, false);
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            if (SliceHeader->idr_pic_id > 65535)
-            {
-                pInfo->sw_bail = 1;
-            }
-#endif
-#endif
         }
 
         if (pInfo->active_SPS.pic_order_cnt_type == 0)
         {
-            viddec_pm_get_bits(parent, &code , pInfo->active_SPS.log2_max_pic_order_cnt_lsb_minus4+4);
+            viddec_pm_get_bits(parent, &code , pInfo->active_SPS.log2_max_pic_order_cnt_lsb_minus4 + 4);
             SliceHeader->pic_order_cnt_lsb = (uint32_t)code;
 
-
             if ((pInfo->active_PPS.pic_order_present_flag) && !(SliceHeader->field_pic_flag))
             {
                 SliceHeader->delta_pic_order_cnt_bottom = h264_GetVLCElement(parent, pInfo, true);
@@ -162,7 +147,9 @@
             SliceHeader->redundant_pic_cnt = h264_GetVLCElement(parent, pInfo, false);
             if (SliceHeader->redundant_pic_cnt > 127)
                 break;
-        } else {
+        }
+        else
+        {
             SliceHeader->redundant_pic_cnt = 0;
         }
 
@@ -221,22 +208,25 @@
                 SliceHeader->num_ref_idx_l0_active = h264_GetVLCElement(parent, pInfo, false) + 1;
                 if (SliceHeader->slice_type == h264_PtypeB)
                 {
-                    SliceHeader->num_ref_idx_l1_active = h264_GetVLCElement(parent, pInfo, false)+1;
+                    SliceHeader->num_ref_idx_l1_active = h264_GetVLCElement(parent, pInfo, false) + 1;
                 }
             }
         }
 
-        if (SliceHeader->slice_type != h264_PtypeB) {
+        if (SliceHeader->slice_type != h264_PtypeB)
+        {
             SliceHeader->num_ref_idx_l1_active = 0;
         }
 
         if ((SliceHeader->num_ref_idx_l0_active > MAX_NUM_REF_FRAMES) || (SliceHeader->num_ref_idx_l1_active > MAX_NUM_REF_FRAMES))
         {
+            WTRACE("ref index greater than expected during slice header parsing.");
             break;
         }
 
         if (h264_Parse_Ref_Pic_List_Reordering(parent, pInfo, SliceHeader) != H264_STATUS_OK)
         {
+            WTRACE("ref list reordering failed during slice header parsing.");
             break;
         }
 
@@ -282,6 +272,7 @@
         {
             if (h264_Parse_Dec_Ref_Pic_Marking(parent, pInfo, SliceHeader) != H264_STATUS_OK)
             {
+                WTRACE("ref pic marking failed during slice header parsing.");
                 break;
             }
         }
@@ -297,26 +288,17 @@
 
         if (SliceHeader->cabac_init_idc > 2)
         {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
             break;
         }
 
         SliceHeader->slice_qp_delta = h264_GetVLCElement(parent, pInfo, true);
-        if ( (SliceHeader->slice_qp_delta > (25-pInfo->active_PPS.pic_init_qp_minus26)) || (SliceHeader->slice_qp_delta < -(26+pInfo->active_PPS.pic_init_qp_minus26)))
+        if ((SliceHeader->slice_qp_delta > (25 - pInfo->active_PPS.pic_init_qp_minus26)) || (SliceHeader->slice_qp_delta < -(26 + pInfo->active_PPS.pic_init_qp_minus26)))
         {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
+            WTRACE("slice_qp_delta value is invalid.");
             break;
         }
 
-        if ((SliceHeader->slice_type == h264_PtypeSP)|| (SliceHeader->slice_type == h264_PtypeSI) )
+        if ((SliceHeader->slice_type == h264_PtypeSP) || (SliceHeader->slice_type == h264_PtypeSI))
         {
             if (SliceHeader->slice_type == h264_PtypeSP)
             {
@@ -326,13 +308,9 @@
             }
             SliceHeader->slice_qs_delta = h264_GetVLCElement(parent, pInfo, true);
 
-            if ( (SliceHeader->slice_qs_delta > (25-pInfo->active_PPS.pic_init_qs_minus26)) || (SliceHeader->slice_qs_delta < -(26+pInfo->active_PPS.pic_init_qs_minus26)) )
+            if ((SliceHeader->slice_qs_delta > (25 - pInfo->active_PPS.pic_init_qs_minus26)) || (SliceHeader->slice_qs_delta < -(26+pInfo->active_PPS.pic_init_qs_minus26)) )
             {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-                pInfo->sw_bail = 1;
-#endif
-#endif
+                WTRACE("slice_qp_delta value is invalid.");
                 break;
             }
         }
@@ -345,11 +323,6 @@
                 slice_alpha_c0_offset = SliceHeader->slice_alpha_c0_offset_div2 << 1;
                 if (slice_alpha_c0_offset < -12 || slice_alpha_c0_offset > 12)
                 {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-                    pInfo->sw_bail = 1;
-#endif
-#endif
                     break;
                 }
 
@@ -357,11 +330,6 @@
                 slice_beta_offset = SliceHeader->slice_beta_offset_div2 << 1;
                 if (slice_beta_offset < -12 || slice_beta_offset > 12)
                 {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-                    pInfo->sw_bail = 1;
-#endif
-#endif
                     break;
                 }
             }
@@ -405,7 +373,6 @@
     int32_t reorder= -1;
     uint32_t code;
 
-
     if ((SliceHeader->slice_type != h264_PtypeI) && (SliceHeader->slice_type != h264_PtypeSI))
     {
         viddec_pm_get_bits(parent, &code, 1);
@@ -413,8 +380,7 @@
 
         if (SliceHeader->sh_refpic_l0.ref_pic_list_reordering_flag)
         {
-
-            reorder= -1;
+            reorder = -1;
             do
             {
                 reorder++;
@@ -445,7 +411,6 @@
 
         if (SliceHeader->sh_refpic_l1.ref_pic_list_reordering_flag)
         {
-
             reorder = -1;
             do
             {
@@ -472,46 +437,23 @@
 
 }
 
-#ifdef VBP
 h264_Status h264_Parse_Pred_Weight_Table(void *parent, h264_Info* pInfo,h264_Slice_Header_t *SliceHeader)
 {
-    uint32_t i =0, j=0;
+    uint32_t i = 0, j = 0;
     uint32_t flag;
 
     SliceHeader->sh_predwttbl.luma_log2_weight_denom = h264_GetVLCElement(parent, pInfo, false);
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-    if (SliceHeader->sh_predwttbl.luma_log2_weight_denom > 7)
-    {
-        pInfo->sw_bail = 1;
-    }
-#endif
-#endif
     if (pInfo->active_SPS.sps_disp.chroma_format_idc != 0)
     {
         SliceHeader->sh_predwttbl.chroma_log2_weight_denom = h264_GetVLCElement(parent,pInfo, false);
     }
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-    if (SliceHeader->sh_predwttbl.chroma_log2_weight_denom > 7)
-    {
-        pInfo->sw_bail = 1;
-    }
-#endif
-#endif
-    for (i=0; i< SliceHeader->num_ref_idx_l0_active; i++)
+
+    for (i = 0; i < SliceHeader->num_ref_idx_l0_active; i++)
     {
         viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
         SliceHeader->sh_predwttbl.luma_weight_l0_flag = flag;
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if ((-128 > flag) || (127 < flag))
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
+
         if (SliceHeader->sh_predwttbl.luma_weight_l0_flag)
         {
             SliceHeader->sh_predwttbl.luma_weight_l0[i] = h264_GetVLCElement(parent, pInfo, true);
@@ -527,17 +469,10 @@
         {
             viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
             SliceHeader->sh_predwttbl.chroma_weight_l0_flag = flag;
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            if ((-128 > flag) || (127 < flag))
-            {
-                pInfo->sw_bail = 1;
-            }
-#endif
-#endif
+
             if (SliceHeader->sh_predwttbl.chroma_weight_l0_flag)
             {
-                for (j=0; j <2; j++)
+                for (j = 0; j < 2; j++)
                 {
                     SliceHeader->sh_predwttbl.chroma_weight_l0[i][j] = h264_GetVLCElement(parent, pInfo, true);
                     SliceHeader->sh_predwttbl.chroma_offset_l0[i][j] = h264_GetVLCElement(parent, pInfo, true);
@@ -545,7 +480,7 @@
             }
             else
             {
-                for (j=0; j <2; j++)
+                for (j = 0; j < 2; j++)
                 {
                     SliceHeader->sh_predwttbl.chroma_weight_l0[i][j] = (1 << SliceHeader->sh_predwttbl.chroma_log2_weight_denom);
                     SliceHeader->sh_predwttbl.chroma_offset_l0[i][j] = 0;
@@ -557,18 +492,11 @@
 
     if (SliceHeader->slice_type == h264_PtypeB)
     {
-        for (i=0; i< SliceHeader->num_ref_idx_l1_active; i++)
+        for (i = 0; i < SliceHeader->num_ref_idx_l1_active; i++)
         {
             viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
             SliceHeader->sh_predwttbl.luma_weight_l1_flag = flag;
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            if ((-128 > flag) || (127 < flag))
-            {
-                pInfo->sw_bail = 1;
-            }
-#endif
-#endif
+
             if (SliceHeader->sh_predwttbl.luma_weight_l1_flag)
             {
                 SliceHeader->sh_predwttbl.luma_weight_l1[i] = h264_GetVLCElement(parent, pInfo, true);
@@ -584,17 +512,10 @@
             {
                 viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
                 SliceHeader->sh_predwttbl.chroma_weight_l1_flag = flag;
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-                if ((-128 > flag) || (127 < flag))
-                {
-                    pInfo->sw_bail = 1;
-                }
-#endif
-#endif
+
                 if (SliceHeader->sh_predwttbl.chroma_weight_l1_flag)
                 {
-                    for (j=0; j <2; j++)
+                    for (j = 0; j < 2; j++)
                     {
                         SliceHeader->sh_predwttbl.chroma_weight_l1[i][j] = h264_GetVLCElement(parent, pInfo, true);
                         SliceHeader->sh_predwttbl.chroma_offset_l1[i][j] = h264_GetVLCElement(parent, pInfo, true);
@@ -602,7 +523,7 @@
                 }
                 else
                 {
-                    for (j=0; j <2; j++)
+                    for (j = 0; j < 2; j++)
                     {
                         SliceHeader->sh_predwttbl.chroma_weight_l1[i][j] = (1 << SliceHeader->sh_predwttbl.chroma_log2_weight_denom);
                         SliceHeader->sh_predwttbl.chroma_offset_l1[i][j] = 0;
@@ -616,126 +537,6 @@
     return H264_STATUS_OK;
 } ///// End of h264_Parse_Pred_Weight_Table
 
-#else
-
-/*--------------------------------------------------------------------------------------------------*/
-//
-// Parse Prediction weight table
-// Note: This table will be reparsed in HW Accelerator, so needn't keep it in parser
-//
-/*--------------------------------------------------------------------------------------------------*/
-
-
-h264_Status h264_Parse_Pred_Weight_Table(void *parent, h264_Info* pInfo,h264_Slice_Header_t *SliceHeader)
-{
-    uint32_t i =0, j=0;
-    uint32_t flag, val;
-    //h264_Slice_Header_t* SliceHeader = &pInfo->SPS.SliceHeader;
-
-    //SliceHeader->sh_predwttbl.luma_log2_weight_denom = h264_GetVLCElement(pInfo, false, "luma_log2_weight_denom");
-    val = h264_GetVLCElement(parent, pInfo, false);
-
-    if (pInfo->active_SPS.sps_disp.chroma_format_idc != 0)
-    {
-        //SliceHeader->sh_predwttbl.chroma_log2_weight_denom = h264_GetVLCElement(pInfo, false, "chroma_log2_weight_denom");
-        val = h264_GetVLCElement(parent,pInfo, false);
-    }
-
-    for (i=0; i< SliceHeader->num_ref_idx_l0_active; i++)
-    {
-        //SliceHeader->sh_predwttbl.luma_weight_l0_flag = h264_GetBits(pInfo, 1, "luma_weight_l0_flag");
-        viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
-
-        //if(SliceHeader->sh_predwttbl.luma_weight_l0_flag)
-        if (flag)
-        {
-            //SliceHeader->sh_predwttbl.luma_weight_l0[i] = h264_GetVLCElement(pInfo, true, "luma_weight_l0");
-            val = h264_GetVLCElement(parent, pInfo, true);
-            //SliceHeader->sh_predwttbl.luma_offset_l0[i] = h264_GetVLCElement(pInfo, true, "luma_offset_l0");
-            val = h264_GetVLCElement(parent, pInfo, true);
-        }
-        else
-        {
-            //SliceHeader->sh_predwttbl.luma_weight_l0[i] = (1 << SliceHeader->sh_predwttbl.luma_log2_weight_denom);
-            //SliceHeader->sh_predwttbl.luma_offset_l0[i] = 0;
-        }
-
-        if (pInfo->active_SPS.sps_disp.chroma_format_idc != 0)
-        {
-            //SliceHeader->sh_predwttbl.chroma_weight_l0_flag = h264_GetBits(pInfo, 1, "chroma_weight_l0_flag");
-            viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
-            if (flag)
-            {
-                for (j=0; j <2; j++)
-                {
-                    //SliceHeader->sh_predwttbl.chroma_weight_l0[i][j] = h264_GetVLCElement(pInfo, true, "chroma_weight_l0");
-                    val = h264_GetVLCElement(parent, pInfo, true);
-                    //SliceHeader->sh_predwttbl.chroma_offset_l0[i][j] = h264_GetVLCElement(pInfo, true, "chroma_offset_l0");
-                    val = h264_GetVLCElement(parent, pInfo, true);
-                }
-            }
-            else
-            {
-                for (j=0; j <2; j++)
-                {
-                    //SliceHeader->sh_predwttbl.chroma_weight_l0[i][j] = (1 << SliceHeader->sh_predwttbl.chroma_log2_weight_denom);
-                    //SliceHeader->sh_predwttbl.chroma_offset_l0[i][j] = 0;
-                }
-            }
-        }
-
-    }
-
-    if (SliceHeader->slice_type == h264_PtypeB)
-    {
-        for (i=0; i< SliceHeader->num_ref_idx_l1_active; i++)
-        {
-            //SliceHeader->sh_predwttbl.luma_weight_l1_flag = h264_GetBits(pInfo, 1, "luma_weight_l1_flag");
-            viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
-            if (flag)
-            {
-                //SliceHeader->sh_predwttbl.luma_weight_l1[i] = h264_GetVLCElement(pInfo, true, "luma_weight_l1");
-                val = h264_GetVLCElement(parent, pInfo, true);
-                //SliceHeader->sh_predwttbl.luma_offset_l1[i] = h264_GetVLCElement(pInfo, true, "luma_offset_l1");
-                val = h264_GetVLCElement(parent, pInfo, true);
-            }
-            else
-            {
-                //SliceHeader->sh_predwttbl.luma_weight_l1[i] = (1 << SliceHeader->sh_predwttbl.luma_log2_weight_denom);
-                //SliceHeader->sh_predwttbl.luma_offset_l1[i] = 0;
-            }
-
-            if (pInfo->active_SPS.sps_disp.chroma_format_idc != 0)
-            {
-                //SliceHeader->sh_predwttbl.chroma_weight_l1_flag = h264_GetBits(pInfo, 1, "chroma_weight_l1_flag");
-                viddec_pm_get_bits(parent, (uint32_t *)&flag, 1);
-                if (flag)
-                {
-                    for (j=0; j <2; j++)
-                    {
-                        //SliceHeader->sh_predwttbl.chroma_weight_l1[i][j] = h264_GetVLCElement(pInfo, true, "chroma_weight_l1");
-                        val = h264_GetVLCElement(parent, pInfo, true);
-                        //SliceHeader->sh_predwttbl.chroma_offset_l1[i][j] = h264_GetVLCElement(pInfo, true, "chroma_offset_l1");
-                        val = h264_GetVLCElement(parent, pInfo, true);
-                    }
-                }
-                else
-                {
-                    for (j=0; j <2; j++)
-                    {
-                        //SliceHeader->sh_predwttbl.chroma_weight_l1[i][j] = (1 << SliceHeader->sh_predwttbl.chroma_log2_weight_denom);
-                        //SliceHeader->sh_predwttbl.chroma_offset_l1[i][j] = 0;
-                    }
-                }
-            }
-
-        }
-    }
-
-    return H264_STATUS_OK;
-} ///// End of h264_Parse_Pred_Weight_Table
-
-#endif
 
 /*--------------------------------------------------------------------------------------------------*/
 // The syntax elements specify marking of the reference pictures.
@@ -824,14 +625,9 @@
         }
     }
 
-
-
-
     SliceHeader->sh_dec_refpic.dec_ref_pic_marking_count = i;
 
     return H264_STATUS_OK;
 }
 
-
-
 //#endif
diff --git a/mixvbp/vbp_plugin/h264/h264parse_sps.c b/mixvbp/vbp_plugin/h264/h264parse_sps.c
index 431892b..909f550 100755
--- a/mixvbp/vbp_plugin/h264/h264parse_sps.c
+++ b/mixvbp/vbp_plugin/h264/h264parse_sps.c
@@ -3,9 +3,8 @@
 
 #include "h264.h"
 #include "h264parse.h"
-#ifdef VBP
-#include<math.h>
-#endif
+#include <math.h>
+#include <vbp_trace.h>
 
 
 /// SPS extension unit (unit_type = 13)
@@ -169,9 +168,8 @@
 
             viddec_pm_get_bits(parent, &code, 1);
             pVUI_Seq_Not_Used->video_full_range_flag = (uint8_t)code;
-#ifdef VBP
+
             SPS->sps_disp.vui_seq_parameters.video_full_range_flag = (uint8_t)code;
-#endif
 
             viddec_pm_get_bits(parent, &code, 1);
             SPS->sps_disp.vui_seq_parameters.colour_description_present_flag = (uint8_t)code;
@@ -186,9 +184,8 @@
 
                 viddec_pm_get_bits(parent, &code, 8);
                 pVUI_Seq_Not_Used->matrix_coefficients = (uint8_t)code;
-#ifdef VBP
+
                 SPS->sps_disp.vui_seq_parameters.matrix_coefficients = (uint8_t)code;
-#endif
             }
         }
 
@@ -294,42 +291,16 @@
     case h264_ProfileHigh:
         break;
     default:
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        pInfo->sw_bail = 1;
-#endif
-#endif
         return H264_SPS_INVALID_PROFILE;
         break;
     }
 
-    //SPS->constraint_set0_flag = h264_GetBits(pInfo, 1, "constraint_set0_flag");
-    //SPS->constraint_set1_flag = h264_GetBits(pInfo, 1, "constraint_set1_flag");		//should be 1
-    //SPS->constraint_set2_flag = h264_GetBits(pInfo, 1, "constraint_set2_flag");
-    //SPS->constraint_set3_flag = h264_GetBits(pInfo, 1, "constraint_set3_flag");
-
-#ifdef VBP
     viddec_pm_get_bits(parent, &code, 5);	 //constraint flag set0...set4 (h.264 Spec v2009)
     SPS->constraint_set_flags = (uint8_t)code;
 
     //// reserved_zero_3bits
     viddec_pm_get_bits(parent, (uint32_t *)&code, 3); //3bits zero reserved (h.264 Spec v2009)
-#else
 
-    viddec_pm_get_bits(parent, &code, 4);
-    SPS->constraint_set_flags = (uint8_t)code;
-
-    //// reserved_zero_4bits
-    viddec_pm_get_bits(parent, (uint32_t *)&code, 4);
-#endif
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-    if (code != 0)
-    {
-        pInfo->sw_bail = 1;
-    }
-#endif
-#endif
     viddec_pm_get_bits(parent, &code, 8);
     SPS->level_idc = (uint8_t)code;
 
@@ -353,11 +324,6 @@
     case h264_Level51:
         break;
     default:
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        pInfo->sw_bail = 1;
-#endif
-#endif
         return H264_SPS_INVALID_LEVEL;
     }
 
@@ -367,46 +333,44 @@
         //// seq_parameter_set_id ---[0,31]
         if (SPS->seq_parameter_set_id > MAX_NUM_SPS -1)
         {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
+            ETRACE("SPS id is out of range: %d", SPS->seq_parameter_set_id);
             break;
         }
-#ifdef VBP
         SPS->sps_disp.separate_colour_plane_flag = 0;
-#endif
 
         if ((SPS->profile_idc == h264_ProfileHigh) || (SPS->profile_idc == h264_ProfileHigh10) ||
-                (SPS->profile_idc == h264_ProfileHigh422) || (SPS->profile_idc == h264_ProfileHigh444)   )
+                (SPS->profile_idc == h264_ProfileHigh422) || (SPS->profile_idc == h264_ProfileHigh444))
         {
             //// chroma_format_idc ---[0,3], currently we don't support 444, so [0,2]
             data = h264_GetVLCElement(parent, pInfo, false);
             if ( data > H264_CHROMA_422)
                 break;
             SPS->sps_disp.chroma_format_idc = (uint8_t)data;
-            //if(SPS->sps_disp.chroma_format_idc == H264_CHROMA_444) {}
 
-#ifdef VBP
-            if(SPS->sps_disp.chroma_format_idc == H264_CHROMA_444) {
+            if(SPS->sps_disp.chroma_format_idc == H264_CHROMA_444)
+            {
                 viddec_pm_get_bits(parent, &code, 1);
                 SPS->sps_disp.separate_colour_plane_flag = (uint8_t)data;
             }
-#endif
+
             //// bit_depth_luma_minus8 ---[0,4], -----only support 8-bit pixel
             data = h264_GetVLCElement(parent, pInfo, false);
-            if ( data)
+            if (data)
+            {
+                ETRACE("A High Profile bitstream must have bit_depth_luma_minus8 equal to 0");
                 break;
+            }
             SPS->bit_depth_luma_minus8 = (uint8_t)data;
 
             //// bit_depth_chroma_minus8 ---[0,4]
             data = h264_GetVLCElement(parent, pInfo, false);
-            if ( data )
+            if (data)
+            {
+                ETRACE("A High Profile bitstream must have bit_depth_chroma_minus8 equal to 0");
                 break;
+            }
             SPS->bit_depth_chroma_minus8 = (uint8_t)data;
 
-
             viddec_pm_get_bits(parent, &code, 1);
             SPS->lossless_qpprime_y_zero_flag = (uint8_t)code;
 
@@ -418,14 +382,14 @@
                 //int n_ScalingList = (SPS->sps_disp.chroma_format_idc != H264_CHROMA_444) ? 8 : 12;
                 int n_ScalingList = 8;				/// We do not support 444 currrently
 
-                for (i=0; i<n_ScalingList; i++)
+                for (i = 0; i < n_ScalingList; i++)
                 {
                     viddec_pm_get_bits(parent, &code, 1);
                     SPS->seq_scaling_list_present_flag[i] = (uint8_t)code;
 
                     if (SPS->seq_scaling_list_present_flag[i])
                     {
-                        if (i<6)
+                        if (i < 6)
                             h264_Scaling_List(parent, SPS->ScalingList4x4[i], 16, &SPS->UseDefaultScalingMatrix4x4Flag[i], pInfo);
                         else
                             h264_Scaling_List(parent, SPS->ScalingList8x8[i-6], 64, &SPS->UseDefaultScalingMatrix8x8Flag[i-6], pInfo);
@@ -447,33 +411,28 @@
         data = (h264_GetVLCElement(parent, pInfo, false));
         if ( data > 12)
         {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
+            ETRACE("log2_max_frame_num_minus4 is over 12");
             break;
         }
         SPS->log2_max_frame_num_minus4 = (uint8_t)data;
 
         //// pic_order_cnt_type ---- [0,2]
         data = h264_GetVLCElement(parent, pInfo, false);
-        if ( data > 2)
+        if (data > 2)
         {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
+            ETRACE("pic_order_cnt_type is over 2");
             break;
         }
         SPS->pic_order_cnt_type = (uint8_t)data;
 
 
         SPS->expectedDeltaPerPOCCycle = 0;
-        if (SPS->pic_order_cnt_type == 0)	{
+        if (SPS->pic_order_cnt_type == 0)
+        {
             SPS->log2_max_pic_order_cnt_lsb_minus4 = h264_GetVLCElement(parent, pInfo, false);
-        } else if (SPS->pic_order_cnt_type == 1) {
+        }
+        else if (SPS->pic_order_cnt_type == 1)
+        {
             viddec_pm_get_bits(parent, &code, 1);
             SPS->delta_pic_order_always_zero_flag = (uint8_t)code;
 
@@ -484,29 +443,18 @@
             data = h264_GetVLCElement(parent, pInfo, false);
             if ( data > 255)
             {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-                pInfo->sw_bail = 1;
-#endif
-#endif
+                ETRACE("num_ref_frames_in_pic_order_cnt_cycle is out of range: %d", data);
                 break;
             }
             SPS->num_ref_frames_in_pic_order_cnt_cycle = (uint8_t)data;
 
-
             //Alloc memory for frame offset -- FIXME
-            for (i=0; i< SPS->num_ref_frames_in_pic_order_cnt_cycle; i++)
+            for (i = 0; i < SPS->num_ref_frames_in_pic_order_cnt_cycle; i++)
             {
                 /////SPS->offset_for_ref_frame[i] could be removed from SPS
-#ifndef USER_MODE
                 tmp = h264_GetVLCElement(parent, pInfo, true);
-                pOffset_ref_frame[i]=tmp;
+                pOffset_ref_frame[i] = tmp;
                 SPS->expectedDeltaPerPOCCycle += tmp;
-#else
-                tmp = h264_GetVLCElement(parent, pInfo, true);
-                SPS->offset_for_ref_frame[i]=tmp;
-                SPS->expectedDeltaPerPOCCycle += tmp;
-#endif
             }
         }
 
@@ -514,11 +462,7 @@
         data = h264_GetVLCElement(parent, pInfo, false);
         if ( data > 16)
         {
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-            pInfo->sw_bail = 1;
-#endif
-#endif
+            ETRACE("The number of reference frame should not be over 16, actuall: %d", data);
             break;
         }
         SPS->num_ref_frames = (uint8_t)data;
@@ -535,9 +479,7 @@
         /// err check for size
         PicWidthInMbs       = (SPS->sps_disp.pic_width_in_mbs_minus1 + 1);
         PicHeightInMapUnits = (SPS->sps_disp.pic_height_in_map_units_minus1 + 1);
-        FrameHeightInMbs    = SPS->sps_disp.frame_mbs_only_flag? PicHeightInMapUnits: (PicHeightInMapUnits<<1);
-        if ((PicWidthInMbs < 2) || (PicWidthInMbs > 128) || (FrameHeightInMbs < 2) || (FrameHeightInMbs>128))
-            break;
+        FrameHeightInMbs    = SPS->sps_disp.frame_mbs_only_flag ? PicHeightInMapUnits : (PicHeightInMapUnits << 1);
 
         if (!SPS->sps_disp.frame_mbs_only_flag)
         {
@@ -545,9 +487,6 @@
             SPS->sps_disp.mb_adaptive_frame_field_flag = (uint8_t)code;
         }
 
-        //SPS->frame_height_in_mbs = (2-SPS->sps_disp.frame_mbs_only_flag)*(SPS->sps_disp.pic_height_in_map_units_minus1+1);
-        //SPS->pic_size_in_map_units = (SPS->sps_disp.pic_width_in_mbs_minus1+1)*SPS->sps_disp.frame_height_in_mbs;
-
         viddec_pm_get_bits(parent, &code, 1);
         SPS->sps_disp.direct_8x8_inference_flag = (uint8_t)code;
 
@@ -563,21 +502,20 @@
         }
 
         //// when frame_mbs_only_flag is equal to 0, direct_8x8_inference_flag shall be equal to 1
-        if (SPS->sps_disp.frame_mbs_only_flag == 0 && SPS->sps_disp.direct_8x8_inference_flag == 0) {
+        if (SPS->sps_disp.frame_mbs_only_flag == 0 && SPS->sps_disp.direct_8x8_inference_flag == 0) 
+        {
+            ETRACE("frame_mbs_only_flag is equal to 0 but direct_8x8_inference_flag is not equal to 1");
             break;
         }
 
         ////// vui_parameters
-        if (viddec_pm_get_bits(parent, &code, 1) == -1)
-            break;
+        viddec_pm_get_bits(parent, &code, 1);
         SPS->sps_disp.vui_parameters_present_flag = (uint8_t)code;
         ret = H264_STATUS_OK;
 
         if (SPS->sps_disp.vui_parameters_present_flag)
         {
-#ifndef VBP
-            ret = h264_Parse_Vui_Parameters(parent, pInfo, SPS, pVUI_Seq_Not_Used);
-#else
+
             // Ignore VUI parsing result
             h264_Parse_Vui_Parameters(parent, pInfo, SPS, pVUI_Seq_Not_Used);
             if (SPS->sps_disp.vui_seq_parameters.nal_hrd_parameters_present_flag)
@@ -598,10 +536,9 @@
                 SPS->sps_disp.vui_seq_parameters.bit_rate_value = bit_rate_value;
              }*/
 
-#endif
         }
     } while (0);
-#ifdef VBP
+
     if (SPS->sps_disp.vui_seq_parameters.bit_rate_value == 0)
     {
         int maxBR = 0;
@@ -680,7 +617,6 @@
 
         SPS->sps_disp.vui_seq_parameters.bit_rate_value = maxBR *  cpbBrVclFactor;
     }
-#endif
 
     //h264_Parse_rbsp_trailing_bits(pInfo);
 
diff --git a/mixvbp/vbp_plugin/h264/include/h264.h b/mixvbp/vbp_plugin/h264/include/h264.h
index 6171e76..f0da7ed 100755
--- a/mixvbp/vbp_plugin/h264/include/h264.h
+++ b/mixvbp/vbp_plugin/h264/include/h264.h
@@ -14,34 +14,15 @@
 #ifndef _H264_H_
 #define _H264_H_
 
-#ifdef HOST_ONLY
 #include <stdio.h>
 #include <stdlib.h>
 #include <memory.h>
-#endif
 
 #include "stdint.h"
 
 #include "viddec_fw_common_defs.h"
 #include "h264parse_sei.h"
 
-#ifdef VBP
-//#define SW_ERROR_CONCEALEMNT
-#endif
-
-#ifdef WIN32
-#define mfd_printf OS_INFO
-#endif
-
-#ifdef H264_VERBOSE
-#define PRINTF(format, args...) OS_INFO("%s:  %s[%d]:: " format, __FILE__, __FUNCTION__ , __LINE__ ,  ## args )
-#else
-//#define PRINTF(args...)
-#endif
-
-//#pragma warning(disable : 4710) // function not inlined
-//#pragma warning(disable : 4514) // unreferenced inline function has been removed CL
-//#pragma warning(disable : 4100) // unreferenced formal parameter CL
 
 #ifdef __cplusplus
 extern "C" {
@@ -87,7 +68,7 @@
 #define MPD_DPB_FS_NULL_IDC			31            // May need to be changed if we alter gaps_in_frame_num to use 
 
 #define MFD_H264_MAX_FRAME_BUFFERS  17
-#define NUM_DPB_FRAME_STORES        (MFD_H264_MAX_FRAME_BUFFERS + 1)  // 1 extra for storign non-existent pictures.
+#define NUM_DPB_FRAME_STORES        (MFD_H264_MAX_FRAME_BUFFERS + 1)  // 1 extra for storing non-existent pictures.
 
 //Scalling Matrix Type
 #define PPS_QM                  0
@@ -108,8 +89,6 @@
 #define FRAME_TYPE_BOTTOM_OFFSET    0
 #define FRAME_TYPE_STRUCTRUE_OFFSET 6
 
-//// Error handling
-#define FIELD_ERR_OFFSET		17			//offset for Field error flag ----refer to the structure definition viddec_fw_workload_error_codes in viddec_fw_common_defs.h
 
 ////Bits Handling
 #define h264_bitfields_extract(x_32, start, mask)     (((x_32) >> (start)) & (mask) )
@@ -505,11 +484,10 @@
         uint8_t   aspect_ratio_idc;                                // u(8)
         uint8_t   video_signal_type_present_flag;                  // u(1)
         uint8_t   video_format;                                    // u(3)
-#ifdef VBP
+
         uint8_t   video_full_range_flag;                           // u(1)
         uint8_t   matrix_coefficients;                              // u(8)
         uint32_t  bit_rate_value;
-#endif
 
         uint8_t   colour_description_present_flag;                 // u(1)
         uint8_t   colour_primaries;                                // u(8)
@@ -684,7 +662,6 @@
         uint8_t		status;
     } OldSliceParams;
 
-#ifdef VBP
     typedef struct _h264__pred_weight_table
     {
         uint8_t luma_log2_weight_denom;
@@ -703,7 +680,6 @@
         int16_t chroma_weight_l1[32][2];
         int8_t chroma_offset_l1[32][2];
     } h264_pred_weight_table;
-#endif
 
     typedef struct _h264_Slice_Header
     {
@@ -723,9 +699,7 @@
         int32_t		slice_beta_offset_div2;								//SE
         int32_t		slice_group_change_cycle;							//UV
 
-#ifdef VBP
         h264_pred_weight_table  sh_predwttbl;
-#endif
 
         ///// Flags or IDs
         //h264_ptype_t	slice_type;											//UE
@@ -789,9 +763,7 @@
         uint8_t mb_adaptive_frame_field_flag;
         uint8_t direct_8x8_inference_flag;
         uint8_t frame_cropping_flag;
-#ifdef VBP
         uint8_t separate_colour_plane_flag;
-#endif
 
         uint16_t vui_parameters_present_flag;
         uint16_t chroma_format_idc;
@@ -1010,15 +982,6 @@
         uint8_t			last_I_frame_idc;
         uint8_t			sei_b_state_ready;
         uint8_t			gop_err_flag;
-
-
-        uint32_t		wl_err_curr;
-        uint32_t		wl_err_next;
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        uint32_t                sw_bail;
-#endif
-#endif
     } h264_Info;
 
 
@@ -1090,17 +1053,12 @@
 } slice_header_t;
 
 
-
-
 typedef struct _vbp_h264_sliceheader {
     slice_header_t          slice_header;
     dec_ref_pic_marking_t   ref_pic_marking;
 } vbp_h264_sliceheader;
 
 #endif
-
-
-
 #endif  //_H264_H_
 
 
diff --git a/mixvbp/vbp_plugin/h264/include/h264parse.h b/mixvbp/vbp_plugin/h264/include/h264parse.h
index 2e7b817..1467932 100755
--- a/mixvbp/vbp_plugin/h264/include/h264parse.h
+++ b/mixvbp/vbp_plugin/h264/include/h264parse.h
@@ -3,10 +3,8 @@
 
 #include "h264.h"
 
-#ifndef MFD_FIRMWARE
 #define true 1
 #define false 0
-#endif
 
 ////////////////////////////////////////////////////////////////////
 // The following part is only for Parser Debug
diff --git a/mixvbp/vbp_plugin/h264/secvideo/baytrail/viddec_h264secure_parse.c b/mixvbp/vbp_plugin/h264/secvideo/baytrail/viddec_h264secure_parse.c
index 103841e..9490ddd 100755
--- a/mixvbp/vbp_plugin/h264/secvideo/baytrail/viddec_h264secure_parse.c
+++ b/mixvbp/vbp_plugin/h264/secvideo/baytrail/viddec_h264secure_parse.c
@@ -1,12 +1,13 @@
 #include "viddec_parser_ops.h"
 
-#include "viddec_fw_workload.h"
 #include "viddec_pm.h"
 
 #include "h264.h"
 #include "h264parse.h"
 
 #include "h264parse_dpb.h"
+#include <vbp_trace.h>
+
 
 /* Init function which can be called to intialized local context on open and flush and preserve*/
 void viddec_h264secure_init(void *ctxt, uint32_t *persist_mem, uint32_t preserve)
@@ -22,9 +23,6 @@
     }
     /* picture level info which will always be initialized */
     h264_init_Info_under_sps_pps_level(pInfo);
-#ifdef SW_ERROR_CONCEALEMNT
-   pInfo->sw_bail = 0;
-#endif
     return;
 }
 
@@ -92,16 +90,6 @@
         pInfo->primary_pic_type_plus_one = 0;
 
 
-
-#ifndef VBP
-        if (pInfo->img.recovery_point_found == 0) {
-            pInfo->img.structure = FRAME;
-            pInfo->wl_err_curr |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
-            pInfo->wl_err_curr |= (FRAME << FIELD_ERR_OFFSET);
-            break;
-        }
-#endif
-
         ////////////////////////////////////////////////////////////////////////////
         // Step 2: Parsing slice header
         ////////////////////////////////////////////////////////////////////////////
@@ -120,26 +108,13 @@
 
         pInfo->sei_information.recovery_point = 0;
 
-        if (next_SliceHeader.sh_error & 3) {
-            pInfo->wl_err_curr |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
-
-            // Error type definition, refer to viddec_fw_common_defs.h
-            //		if error in top field, VIDDEC_FW_WORKLOAD_ERR_TOPFIELD			= (1 << 17)
-            //		if error in bottom field, VIDDEC_FW_WORKLOAD_ERR_BOTTOMFIELD	   = (1 << 18)
-            //		if this is frame based, both 2 bits should be set
-            pInfo->wl_err_curr |= (FRAME << FIELD_ERR_OFFSET);
-
+        if (next_SliceHeader.sh_error & 3)
+        {
             break;
         }
         pInfo->img.current_slice_num++;
 
 
-#ifdef DUMP_HEADER_INFO
-        dump_slice_header(pInfo, &next_SliceHeader);
-////h264_print_decoder_values(pInfo);
-#endif
-
-
         ////////////////////////////////////////////////////////////////////////////
         // Step 3: Processing if new picture coming
         //  1) if it's the second field
@@ -187,10 +162,6 @@
                 {
                     h264_dpb_gaps_in_frame_num_mem_management(pInfo);
                 }
-
-#ifdef DUMP_HEADER_INFO
-                dump_new_picture_attr(pInfo, pInfo->SliceHeader.frame_num);
-#endif
             }
             //
             /// Decoding POC
@@ -239,17 +210,6 @@
 
         h264_dpb_update_ref_lists( pInfo);
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if ((pInfo->dpb.ltref_frames_in_buffer + pInfo->dpb.ref_frames_in_buffer ) > pInfo->active_SPS.num_ref_frames)
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
-#ifdef DUMP_HEADER_INFO
-        dump_ref_list(pInfo);
-#endif
         /// Emit out the current "good" slice
         h264_parse_emit_current_slice(parent, pInfo);
 
@@ -260,8 +220,7 @@
     case h264_NAL_UNIT_TYPE_DPA:
     case h264_NAL_UNIT_TYPE_DPB:
     case h264_NAL_UNIT_TYPE_DPC:
-        //OS_INFO("***********************DP feature, not supported currently*******************\n");
-        pInfo->wl_err_curr |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
+        ETRACE("Data Partition is not supported currently\n");
         status = H264_STATUS_NOTSUPPORT;
         break;
 
@@ -301,11 +260,6 @@
             if (1==pInfo->active_SPS.pic_order_cnt_type) {
                 h264_Parse_Copy_Offset_Ref_Frames_To_DDR(pInfo,(int32_t *)pInfo->TMP_OFFSET_REFFRM_PADDR_GL,pInfo->active_SPS.seq_parameter_set_id);
             }
-
-#ifdef DUMP_HEADER_INFO
-            dump_sps(&(pInfo->active_SPS));
-#endif
-
         }
         ///// Restore the active SPS if new arrival's id changed
         if (old_sps_id>=MAX_NUM_SPS) {
@@ -358,9 +312,6 @@
             {
                 h264_Parse_Copy_Sps_From_DDR(pInfo, &(pInfo->active_SPS), old_sps_id);
             }
-#ifdef DUMP_HEADER_INFO
-            dump_pps(&(pInfo->active_PPS));
-#endif
         } else {
             if (old_sps_id<MAX_NUM_SPS)
                 h264_Parse_Copy_Sps_From_DDR(pInfo, &(pInfo->active_SPS), old_sps_id);
@@ -392,7 +343,6 @@
         break;
 
     case h264_NAL_UNIT_TYPE_Acc_unit_delimiter:
-#if 1
         ///// primary_pic_type
         {
             uint32_t code = 0xff;
@@ -410,7 +360,6 @@
             pInfo->number_of_first_au_info_nal_before_first_slice++;
             break;
         }
-#endif
 
     case h264_NAL_UNIT_TYPE_Reserved1:
     case h264_NAL_UNIT_TYPE_Reserved2:
diff --git a/mixvbp/vbp_plugin/h264/viddec_h264_parse.c b/mixvbp/vbp_plugin/h264/viddec_h264_parse.c
index db36c0b..2aa80b9 100755
--- a/mixvbp/vbp_plugin/h264/viddec_h264_parse.c
+++ b/mixvbp/vbp_plugin/h264/viddec_h264_parse.c
@@ -6,13 +6,10 @@
 #include "h264parse.h"
 
 #include "h264parse_dpb.h"
+#include <vbp_trace.h>
 
 /* Init function which can be called to intialized local context on open and flush and preserve*/
-#ifdef VBP
 void viddec_h264_init(void *ctxt, uint32_t *persist_mem, uint32_t preserve)
-#else
-static void viddec_h264_init(void *ctxt, uint32_t *persist_mem, uint32_t preserve)
-#endif
 {
     struct h264_viddec_parser* parser = ctxt;
     h264_Info * pInfo = &(parser->info);
@@ -20,16 +17,13 @@
     if (!preserve)
     {
         /* we don't initialize this data if we want to preserve
-           sequence and gop information */
+                 sequence and gop information.
+              */
         h264_init_sps_pps(parser,persist_mem);
     }
     /* picture level info which will always be initialized */
     h264_init_Info_under_sps_pps_level(pInfo);
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-   pInfo->sw_bail = 0;
-#endif
-#endif
+
     return;
 }
 
@@ -37,11 +31,7 @@
 /* ------------------------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------------------------ */
-#ifdef VBP
 uint32_t viddec_h264_parse(void *parent, void *ctxt)
-#else
-static uint32_t viddec_h264_parse(void *parent, void *ctxt)
-#endif
 {
     struct h264_viddec_parser* parser = ctxt;
 
@@ -49,7 +39,6 @@
 
     h264_Status status = H264_STATUS_ERROR;
 
-
     uint8_t nal_ref_idc = 0;
 
     ///// Parse NAL Unit header
@@ -59,25 +48,17 @@
     pInfo->nal_unit_type = 0;
 
     h264_Parse_NAL_Unit(parent, pInfo, &nal_ref_idc);
+    VTRACE("Start parsing NAL unit, type = %d", pInfo->nal_unit_type);
 
     ///// Check frame bounday for non-vcl elimitter
     h264_check_previous_frame_end(pInfo);
 
-    //OS_INFO("========================nal_type: %d=================\n", pInfo->nal_unit_type);
-    //DEBUG_WRITE(pInfo->nal_unit_type, pInfo->got_start, pInfo->wl_err_flag, pInfo->is_current_workload_done, 0, 0);
-#if 0
-    devh_SVEN_WriteModuleEvent( NULL,
-                                SVEN_MODULE_EVENT_GV_FW_PARSER_DEBUG_P0,
-                                pInfo->got_start,pInfo->nal_unit_type,  pInfo->wl_err_curr, pInfo->is_current_workload_done, 0, pInfo->img.frame_num);
-#endif
-
     //////// Parse valid NAL unit
-    switch ( pInfo->nal_unit_type )
+    switch (pInfo->nal_unit_type)
     {
     case h264_NAL_UNIT_TYPE_IDR:
-        if (pInfo->got_start)	{
+        if (pInfo->got_start)
             pInfo->img.recovery_point_found |= 1;
-        }
 
         pInfo->sei_rp_received = 0;
 
@@ -102,32 +83,22 @@
         h264_memset(&next_SliceHeader, 0x0, sizeof(h264_Slice_Header_t));
         next_SliceHeader.nal_ref_idc = nal_ref_idc;
 
-        if ( (1==pInfo->primary_pic_type_plus_one)&&(pInfo->got_start))
+        if ((1 == pInfo->primary_pic_type_plus_one) && (pInfo->got_start))
         {
-            pInfo->img.recovery_point_found |=4;
+            pInfo->img.recovery_point_found |= 4;
         }
         pInfo->primary_pic_type_plus_one = 0;
 
 
-
-#ifndef VBP
-        if (pInfo->img.recovery_point_found == 0) {
-            pInfo->img.structure = FRAME;
-            pInfo->wl_err_curr |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
-            pInfo->wl_err_curr |= (FRAME << FIELD_ERR_OFFSET);
-            break;
-        }
-#endif
-
         ////////////////////////////////////////////////////////////////////////////
         // Step 2: Parsing slice header
         ////////////////////////////////////////////////////////////////////////////
         /// PWT
-        pInfo->h264_pwt_start_byte_offset=0;
-        pInfo->h264_pwt_start_bit_offset=0;
-        pInfo->h264_pwt_end_byte_offset=0;
-        pInfo->h264_pwt_end_bit_offset=0;
-        pInfo->h264_pwt_enabled =0;
+        pInfo->h264_pwt_start_byte_offset = 0;
+        pInfo->h264_pwt_start_bit_offset = 0;
+        pInfo->h264_pwt_end_byte_offset = 0;
+        pInfo->h264_pwt_end_bit_offset = 0;
+        pInfo->h264_pwt_enabled = 0;
         /// IDR flag
         next_SliceHeader.idr_flag = (pInfo->nal_unit_type == h264_NAL_UNIT_TYPE_IDR);
 
@@ -137,26 +108,14 @@
 
         pInfo->sei_information.recovery_point = 0;
 
-        if (next_SliceHeader.sh_error & 3) {
-            pInfo->wl_err_curr |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
-
-            // Error type definition, refer to viddec_fw_common_defs.h
-            //		if error in top field, VIDDEC_FW_WORKLOAD_ERR_TOPFIELD			= (1 << 17)
-            //		if error in bottom field, VIDDEC_FW_WORKLOAD_ERR_BOTTOMFIELD	   = (1 << 18)
-            //		if this is frame based, both 2 bits should be set
-            pInfo->wl_err_curr |= (FRAME << FIELD_ERR_OFFSET);
-
+        if (next_SliceHeader.sh_error & 3)
+        {
+            ETRACE("Slice Header parsing error.\n");
             break;
         }
         pInfo->img.current_slice_num++;
 
 
-#ifdef DUMP_HEADER_INFO
-        dump_slice_header(pInfo, &next_SliceHeader);
-////h264_print_decoder_values(pInfo);
-#endif
-
-
         ////////////////////////////////////////////////////////////////////////////
         // Step 3: Processing if new picture coming
         //  1) if it's the second field
@@ -204,10 +163,6 @@
                 {
                     h264_dpb_gaps_in_frame_num_mem_management(pInfo);
                 }
-
-#ifdef DUMP_HEADER_INFO
-                dump_new_picture_attr(pInfo, pInfo->SliceHeader.frame_num);
-#endif
             }
             //
             /// Decoding POC
@@ -224,7 +179,6 @@
                 pInfo->SliceHeader.sh_error |= (pInfo->SliceHeader.structure << 17);
             }
 
-            //
             /// Emit out the New Frame
             if (pInfo->img.g_new_frame)
             {
@@ -256,17 +210,6 @@
 
         h264_dpb_update_ref_lists( pInfo);
 
-#ifdef VBP
-#ifdef SW_ERROR_CONCEALEMNT
-        if ((pInfo->dpb.ltref_frames_in_buffer + pInfo->dpb.ref_frames_in_buffer ) > pInfo->active_SPS.num_ref_frames)
-        {
-            pInfo->sw_bail = 1;
-        }
-#endif
-#endif
-#ifdef DUMP_HEADER_INFO
-        dump_ref_list(pInfo);
-#endif
         /// Emit out the current "good" slice
         h264_parse_emit_current_slice(parent, pInfo);
 
@@ -277,8 +220,7 @@
     case h264_NAL_UNIT_TYPE_DPA:
     case h264_NAL_UNIT_TYPE_DPB:
     case h264_NAL_UNIT_TYPE_DPC:
-        //OS_INFO("***********************DP feature, not supported currently*******************\n");
-        pInfo->wl_err_curr |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
+        ETRACE("Data Partition is not supported currently\n");
         status = H264_STATUS_NOTSUPPORT;
         break;
 
@@ -287,7 +229,8 @@
         status = H264_STATUS_OK;
 
         //OS_INFO("*****************************SEI**************************************\n");
-        if (pInfo->sps_valid) {
+        if (pInfo->sps_valid)
+        {
             //h264_user_data_t user_data; /// Replace with tmp buffer while porting to FW
             pInfo->number_of_first_au_info_nal_before_first_slice++;
             /// parsing the SEI info
@@ -311,26 +254,23 @@
 
 
         status = h264_Parse_SeqParameterSet(parent, pInfo, &(pInfo->active_SPS), &vui_seq_not_used, (int32_t *)pInfo->TMP_OFFSET_REFFRM_PADDR_GL);
-        if (status == H264_STATUS_OK) {
+        if (status == H264_STATUS_OK)
+        {
             h264_Parse_Copy_Sps_To_DDR(pInfo, &(pInfo->active_SPS), pInfo->active_SPS.seq_parameter_set_id);
             pInfo->sps_valid = 1;
 
-            if (1==pInfo->active_SPS.pic_order_cnt_type) {
+            if (1 == pInfo->active_SPS.pic_order_cnt_type)
+            {
                 h264_Parse_Copy_Offset_Ref_Frames_To_DDR(pInfo,(int32_t *)pInfo->TMP_OFFSET_REFFRM_PADDR_GL,pInfo->active_SPS.seq_parameter_set_id);
             }
-
-#ifdef DUMP_HEADER_INFO
-            dump_sps(&(pInfo->active_SPS));
-#endif
-
         }
         ///// Restore the active SPS if new arrival's id changed
-        if (old_sps_id>=MAX_NUM_SPS) {
+        if (old_sps_id >= MAX_NUM_SPS) {
             h264_memset(&(pInfo->active_SPS), 0x0, sizeof(seq_param_set_used));
             pInfo->active_SPS.seq_parameter_set_id = 0xff;
         }
         else {
-            if (old_sps_id!=pInfo->active_SPS.seq_parameter_set_id)  {
+            if (old_sps_id != pInfo->active_SPS.seq_parameter_set_id)  {
                 h264_Parse_Copy_Sps_From_DDR(pInfo, &(pInfo->active_SPS), old_sps_id);
             }
             else  {
@@ -375,13 +315,12 @@
             {
                 h264_Parse_Copy_Sps_From_DDR(pInfo, &(pInfo->active_SPS), old_sps_id);
             }
-#ifdef DUMP_HEADER_INFO
-            dump_pps(&(pInfo->active_PPS));
-#endif
-        } else {
-            if (old_sps_id<MAX_NUM_SPS)
+        }
+        else
+        {
+            if (old_sps_id < MAX_NUM_SPS)
                 h264_Parse_Copy_Sps_From_DDR(pInfo, &(pInfo->active_SPS), old_sps_id);
-            if (old_pps_id<MAX_NUM_PPS)
+            if (old_pps_id < MAX_NUM_PPS)
                 h264_Parse_Copy_Pps_From_DDR(pInfo, &(pInfo->active_PPS), old_pps_id);
         }
 
@@ -409,7 +348,6 @@
         break;
 
     case h264_NAL_UNIT_TYPE_Acc_unit_delimiter:
-#if 1
         ///// primary_pic_type
         {
             uint32_t code = 0xff;
@@ -427,7 +365,6 @@
             pInfo->number_of_first_au_info_nal_before_first_slice++;
             break;
         }
-#endif
 
     case h264_NAL_UNIT_TYPE_Reserved1:
     case h264_NAL_UNIT_TYPE_Reserved2:
@@ -481,75 +418,7 @@
     return status;
 }
 
-
-
-
-/* ------------------------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------------------------ */
-#ifndef VBP
-static uint32_t viddec_h264_is_frame_start(void *ctxt)
-{
-    struct h264_viddec_parser* parser = ctxt;
-    uint32_t ret = 0;
-
-    h264_Info * pInfo = &(parser->info);
-
-    if (pInfo->img.g_new_frame) {
-        ret = 1;
-    }
-
-    return ret;
-}
-#endif
-
-#ifndef VBP
-uint32_t viddec_h264_wkld_done(void *parent, void *ctxt, unsigned int next_sc,
-                               uint32_t *codec_specific_errors)
-{
-    struct h264_viddec_parser* parser = ctxt;
-    uint32_t ret = VIDDEC_PARSE_SUCESS;
-    h264_Info * pInfo = &(parser->info);
-    uint8_t is_stream_forced_to_complete=false;
-
-    is_stream_forced_to_complete = (VIDDEC_PARSE_EOS == next_sc) || (VIDDEC_PARSE_DISCONTINUITY == next_sc);
-
-    if (is_stream_forced_to_complete || (pInfo->is_current_workload_done))
-    {
-        viddec_workload_t 		 *wl;
-        viddec_frame_attributes_t *attrs;
-
-        wl = viddec_pm_get_header( parent );
-        attrs = &wl->attrs;
-
-        if ((attrs->cont_size.width < 32) || (attrs->cont_size.width > 2048) || (attrs->cont_size.height < 32) || (attrs->cont_size.height>2048))
-        {
-            attrs->cont_size.width = 32;
-            attrs->cont_size.height = 32;
-            pInfo->wl_err_curr |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
-            pInfo->wl_err_curr |= (FRAME << FIELD_ERR_OFFSET);
-        }
-
-        *codec_specific_errors = pInfo->wl_err_curr;
-        pInfo->wl_err_curr = pInfo->wl_err_next;
-        pInfo->wl_err_next = 0;
-
-        if (is_stream_forced_to_complete)
-        {
-            h264_parse_emit_eos(parent, pInfo);
-        }
-        ret = VIDDEC_PARSE_FRMDONE;
-    }
-
-    return ret;
-}
-#endif
-
-#ifdef VBP
 void viddec_h264_get_context_size(viddec_parser_memory_sizes_t *size)
-#else
-static void viddec_h264_get_context_size(viddec_parser_memory_sizes_t *size)
-#endif
 {
     /* Should return size of my structure */
     size->context_size = sizeof(struct h264_viddec_parser);
@@ -562,11 +431,7 @@
 /* ------------------------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------------------------ */
-#ifdef VBP
 void viddec_h264_flush(void *parent, void *ctxt)
-#else
-static void viddec_h264_flush(void *parent, void *ctxt)
-#endif
 {
     int i;
     struct h264_viddec_parser* parser = ctxt;
@@ -590,17 +455,4 @@
     return;
 }
 
-#ifndef VBP
-void viddec_h264_get_ops(viddec_parser_ops_t *ops)
-{
-    ops->init = viddec_h264_init;
-
-    ops->parse_syntax = viddec_h264_parse;
-    ops->get_cxt_size = viddec_h264_get_context_size;
-    ops->is_wkld_done = viddec_h264_wkld_done;
-    ops->is_frame_start = viddec_h264_is_frame_start;
-    ops->flush = viddec_h264_flush;
-    return;
-}
-#endif