Update of MixVBP from main MI-X repo.  MixVideo and MixVBP fixes for partial frame and multiple NAL handling to fix several decode issues.  Color conversion fix for encode.

Change-Id: Ide0888da73ce8c5a5d7f6039643cf4ed5b85cb45
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse.c
index a96285d..180e7b6 100644
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse.c
@@ -398,8 +398,8 @@
 
     pInfo->Is_first_frame_in_stream =1;
     pInfo->img.frame_count = 0;    
-    pInfo->last_I_frame_idc = 255;			   	
-
+    pInfo->last_I_frame_idc = 255;	
+    
     return;
 }
  
@@ -699,7 +699,7 @@
 	            {
 	               pInfo->dpb.fs[pInfo->dpb.fs_dec_idc].pic_type = (0x1 << FRAME_TYPE_STRUCTRUE_OFFSET)|(FRAME_TYPE_I << FRAME_TYPE_FRAME_OFFSET);
 	            }
-				pInfo->last_I_frame_idc = pInfo->dpb.fs_dec_idc;
+				   pInfo->last_I_frame_idc = pInfo->dpb.fs_dec_idc;
 				
 	            break;
             default:
@@ -735,6 +735,10 @@
             {
                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));
             }
+            if (pInfo->sei_rp_received)
+               pInfo->last_I_frame_idc = pInfo->dpb.fs_dec_idc;
+            else
+               pInfo->last_I_frame_idc = 255;
             break;
             default:
             break;
@@ -768,6 +772,11 @@
             {
                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);
+            else
+               pInfo->last_I_frame_idc = 255;
+
             break;
             default:
             break;
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_bsd.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_bsd.c
index c4e00ee..dbbe5c6 100644
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_bsd.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_bsd.c
@@ -1,228 +1,228 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2001-2006 Intel Corporation. All Rights Reserved.

-//

-//  Description:    h264 bistream decoding

-//

-///////////////////////////////////////////////////////////////////////*/

-

-

-#include "h264.h"

-#include "h264parse.h"

-#include "viddec_parser_ops.h"

-

-

-

-

-

-/**

-   get_codeNum     :Get codenum based on sec 9.1 of H264 spec.

-   @param      cxt : Buffer adress & size are part inputs, the cxt is updated

-                     with codeNum & sign on sucess.

-                     Assumption: codeNum is a max of 32 bits

-                     

-   @retval       1 : Sucessfuly found a code num, cxt is updated with codeNum, sign, and size of code.

-   @retval       0 : Couldn't find a code in the current buffer.

-   be freed.

-*/

-

-uint32_t h264_get_codeNum(void *parent, h264_Info* pInfo)

-{

-   int32_t    leadingZeroBits= 0;

-   uint32_t    temp = 0, match = 0, noOfBits = 0, count = 0;

-   uint32_t   codeNum =0;

-   uint32_t   bits_offset =0, byte_offset =0;

-   uint8_t    is_emul =0;

-   uint8_t    is_first_byte = 1;

-   uint32_t   length =0;

-   uint32_t   bits_need_add_in_first_byte =0;

-   int32_t    bits_operation_result=0;

-

-   //remove warning

-   pInfo = pInfo;   

-

-   ////// Step 1: parse through zero bits until we find a bit with value 1.

-   viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);

-

- 

-   while(!match)

-   {

-       if ((bits_offset != 0) && ( is_first_byte == 1))

-       {

-           //we handle byte at a time, if we have offset then for first

-           //   byte handle only 8 - offset bits 

-           noOfBits = (uint8_t)(8 - bits_offset);

-           bits_operation_result = viddec_pm_peek_bits(parent, &temp, noOfBits); 

-

-             

-           temp = (temp << bits_offset);

-           if(temp!=0)

-           {

-              bits_need_add_in_first_byte = bits_offset;

-           }          

-           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)

-	   {

-	      return MAX_INT32_VALUE;      

-	   }

-

-       if(temp != 0)    

-       {

-           // if byte!=0 we have at least one bit with value 1.

-           count=1;

-           while(((temp & 0x80) != 0x80) && (count <= noOfBits))

-           {

-               count++;

-               temp = temp <<1;

-           }

-           //At this point we get the bit position of 1 in current byte(count).

-            

-           match = 1;

-           leadingZeroBits += count;            

-       }

-       else

-       {

-           // we don't have a 1 in current byte 

-           leadingZeroBits += noOfBits;            

-       }

-

-       if(!match)

-       {

-           //actually move the bitoff by viddec_pm_get_bits

-           viddec_pm_get_bits(parent, &temp, noOfBits);           

-       }

-       else

-       {

-           //actually move the bitoff by viddec_pm_get_bits

-           viddec_pm_get_bits(parent, &temp, count);            

-       }        

-

-   }

-   ////// step 2: Now read the next (leadingZeroBits-1) bits to get the encoded value.

-

-

-   if(match)

-   {

-

-       viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);

-       /* bit position in current byte */

-       //count = (uint8_t)((leadingZeroBits + bits_offset)& 0x7);        

-       count = ((count + bits_need_add_in_first_byte)& 0x7);   

-        

-       leadingZeroBits --;

-       length =  leadingZeroBits;

-       codeNum = 0;

-       noOfBits = 8 - count;    

-

-        

-       while(leadingZeroBits > 0)

-       {

-           if(noOfBits < (uint32_t)leadingZeroBits)

-           {

-               viddec_pm_get_bits(parent, &temp, noOfBits);

-

-                  

-               codeNum = (codeNum << noOfBits) | temp;

-               leadingZeroBits -= noOfBits;

-           }

-           else

-           {

-               viddec_pm_get_bits(parent, &temp, leadingZeroBits);

-                

-               codeNum = (codeNum << leadingZeroBits) | temp;

-               leadingZeroBits = 0;

-           }

-    

-

-           noOfBits = 8;

-       }

-       // update codeNum = 2 ** (leadingZeroBits) -1 + read_bits(leadingZeroBits). 

-       codeNum = codeNum + (1 << length) -1;         

-

-    }

-

-    viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);

-    if(bits_offset!=0)

-    {

-      viddec_pm_peek_bits(parent, &temp, 8-bits_offset); 

-    }

-

-    return codeNum;

-}

-

-

-/*---------------------------------------*/

-/*---------------------------------------*/

-int32_t h264_GetVLCElement(void *parent, h264_Info* pInfo, uint8_t bIsSigned)

-{

-	int32_t sval = 0;

-	signed char sign;

-

-	sval = h264_get_codeNum(parent , pInfo);

-

- 	if(bIsSigned)  //get signed integer golomb code else the value is unsigned

-	{

-	  sign = (sval & 0x1)?1:-1;

-	  sval = (sval +1) >> 1;

-	  sval = sval * sign;

-	}

-

-	return sval;

-} // Ipp32s H264Bitstream::GetVLCElement(bool bIsSigned)

-

-///

-/// Check whether more RBSP data left in current NAL

-///

-uint8_t h264_More_RBSP_Data(void *parent, h264_Info * pInfo)

-{

-	uint8_t cnt = 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;

-

-   //remove warning

-   pInfo = pInfo; 

-

-	if (!viddec_pm_is_nomoredata(parent)) 

-		return 1;

-

-	viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);

-

-	shift_bits = 7-bits_offset; 

-

-	// read one byte

-	viddec_pm_get_cur_byte(parent, &cur_byte); 

-

-	ctr_bit = ((cur_byte)>> (shift_bits--)) & 0x01;

-

-	// a stop bit has to be one

-	if (ctr_bit==0) 

-		return 1;  

-

-	while (shift_bits>=0 && !cnt)

-	{

-		cnt |= (((cur_byte)>> (shift_bits--)) & 0x01);   // set up control bit

-	} 

-

-   return (cnt);  

-}

-

-

-

-///////////// EOF/////////////////////

-

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2001-2006 Intel Corporation. All Rights Reserved.
+//
+//  Description:    h264 bistream decoding
+//
+///////////////////////////////////////////////////////////////////////*/
+
+
+#include "h264.h"
+#include "h264parse.h"
+#include "viddec_parser_ops.h"
+
+
+
+
+
+/**
+   get_codeNum     :Get codenum based on sec 9.1 of H264 spec.
+   @param      cxt : Buffer adress & size are part inputs, the cxt is updated
+                     with codeNum & sign on sucess.
+                     Assumption: codeNum is a max of 32 bits
+                     
+   @retval       1 : Sucessfuly found a code num, cxt is updated with codeNum, sign, and size of code.
+   @retval       0 : Couldn't find a code in the current buffer.
+   be freed.
+*/
+
+uint32_t h264_get_codeNum(void *parent, h264_Info* pInfo)
+{
+   int32_t    leadingZeroBits= 0;
+   uint32_t    temp = 0, match = 0, noOfBits = 0, count = 0;
+   uint32_t   codeNum =0;
+   uint32_t   bits_offset =0, byte_offset =0;
+   uint8_t    is_emul =0;
+   uint8_t    is_first_byte = 1;
+   uint32_t   length =0;
+   uint32_t   bits_need_add_in_first_byte =0;
+   int32_t    bits_operation_result=0;
+
+   //remove warning
+   pInfo = pInfo;   
+
+   ////// Step 1: parse through zero bits until we find a bit with value 1.
+   viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);
+
+ 
+   while(!match)
+   {
+       if ((bits_offset != 0) && ( is_first_byte == 1))
+       {
+           //we handle byte at a time, if we have offset then for first
+           //   byte handle only 8 - offset bits 
+           noOfBits = (uint8_t)(8 - bits_offset);
+           bits_operation_result = viddec_pm_peek_bits(parent, &temp, noOfBits); 
+
+             
+           temp = (temp << bits_offset);
+           if(temp!=0)
+           {
+              bits_need_add_in_first_byte = bits_offset;
+           }          
+           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)
+	   {
+	      return MAX_INT32_VALUE;      
+	   }
+
+       if(temp != 0)    
+       {
+           // if byte!=0 we have at least one bit with value 1.
+           count=1;
+           while(((temp & 0x80) != 0x80) && (count <= noOfBits))
+           {
+               count++;
+               temp = temp <<1;
+           }
+           //At this point we get the bit position of 1 in current byte(count).
+            
+           match = 1;
+           leadingZeroBits += count;            
+       }
+       else
+       {
+           // we don't have a 1 in current byte 
+           leadingZeroBits += noOfBits;            
+       }
+
+       if(!match)
+       {
+           //actually move the bitoff by viddec_pm_get_bits
+           viddec_pm_get_bits(parent, &temp, noOfBits);           
+       }
+       else
+       {
+           //actually move the bitoff by viddec_pm_get_bits
+           viddec_pm_get_bits(parent, &temp, count);            
+       }        
+
+   }
+   ////// step 2: Now read the next (leadingZeroBits-1) bits to get the encoded value.
+
+
+   if(match)
+   {
+
+       viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);
+       /* bit position in current byte */
+       //count = (uint8_t)((leadingZeroBits + bits_offset)& 0x7);        
+       count = ((count + bits_need_add_in_first_byte)& 0x7);   
+        
+       leadingZeroBits --;
+       length =  leadingZeroBits;
+       codeNum = 0;
+       noOfBits = 8 - count;    
+
+        
+       while(leadingZeroBits > 0)
+       {
+           if(noOfBits < (uint32_t)leadingZeroBits)
+           {
+               viddec_pm_get_bits(parent, &temp, noOfBits);
+
+                  
+               codeNum = (codeNum << noOfBits) | temp;
+               leadingZeroBits -= noOfBits;
+           }
+           else
+           {
+               viddec_pm_get_bits(parent, &temp, leadingZeroBits);
+                
+               codeNum = (codeNum << leadingZeroBits) | temp;
+               leadingZeroBits = 0;
+           }
+    
+
+           noOfBits = 8;
+       }
+       // update codeNum = 2 ** (leadingZeroBits) -1 + read_bits(leadingZeroBits). 
+       codeNum = codeNum + (1 << length) -1;         
+
+    }
+
+    viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);
+    if(bits_offset!=0)
+    {
+      viddec_pm_peek_bits(parent, &temp, 8-bits_offset); 
+    }
+
+    return codeNum;
+}
+
+
+/*---------------------------------------*/
+/*---------------------------------------*/
+int32_t h264_GetVLCElement(void *parent, h264_Info* pInfo, uint8_t bIsSigned)
+{
+	int32_t sval = 0;
+	signed char sign;
+
+	sval = h264_get_codeNum(parent , pInfo);
+
+ 	if(bIsSigned)  //get signed integer golomb code else the value is unsigned
+	{
+	  sign = (sval & 0x1)?1:-1;
+	  sval = (sval +1) >> 1;
+	  sval = sval * sign;
+	}
+
+	return sval;
+} // Ipp32s H264Bitstream::GetVLCElement(bool bIsSigned)
+
+///
+/// Check whether more RBSP data left in current NAL
+///
+uint8_t h264_More_RBSP_Data(void *parent, h264_Info * pInfo)
+{
+	uint8_t cnt = 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;
+
+   //remove warning
+   pInfo = pInfo; 
+
+	if (!viddec_pm_is_nomoredata(parent)) 
+		return 1;
+
+	viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);
+
+	shift_bits = 7-bits_offset; 
+
+	// read one byte
+	viddec_pm_get_cur_byte(parent, &cur_byte); 
+
+	ctr_bit = ((cur_byte)>> (shift_bits--)) & 0x01;
+
+	// a stop bit has to be one
+	if (ctr_bit==0) 
+		return 1;  
+
+	while (shift_bits>=0 && !cnt)
+	{
+		cnt |= (((cur_byte)>> (shift_bits--)) & 0x01);   // set up control bit
+	} 
+
+   return (cnt);  
+}
+
+
+
+///////////// EOF/////////////////////
+
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_dpb.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_dpb.c
index d1b693b..5ad9d09 100644
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_dpb.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_dpb.c
@@ -1270,7 +1270,8 @@
 
 		int32_t idx, rp_found = 0;
 
-		if(pInfo->SliceHeader.num_ref_idx_l0_active == 1)
+		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)
 	         {
@@ -1329,6 +1330,7 @@
 					} 
 				}
 #endif
+
 				///// Set the reference to last I frame
 				if( (pInfo->last_I_frame_idc!=255)&&(pInfo->last_I_frame_idc!=p_list[0])) 
 				{
@@ -1336,8 +1338,9 @@
 					h264_dpb_unmark_for_reference(p_dpb, p_list[0]);
 					h264_dpb_remove_ref_list(p_dpb, p_list[0]);
 					p_list[0] = pInfo->last_I_frame_idc;
+               if (pInfo->SliceHeader.structure != FRAME)
+                  p_list[1] = (pInfo->last_I_frame_idc ^ 0x20);
 				}
-
 			}
 		}
 		
@@ -1398,7 +1401,10 @@
 	}
 
 	//// Check if need recover reference list with previous recovery point
-	h264_dpb_RP_check_list(pInfo);
+	if(!pInfo->img.second_field)
+   {  
+	   h264_dpb_RP_check_list(pInfo);
+   }
 
 
 	return;
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_math.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_math.c
index b5df6d9..2793dbd 100644
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_math.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_math.c
@@ -1,82 +1,82 @@
-//#include "math.h"

-// Arithmatic functions using add & subtract

-

-unsigned long mult_u(register unsigned long var1, register unsigned long var2)

-{

-

-	  register unsigned long var_out = 0;

-	

-	  while (var2 > 0)

-	  {

-

-	  	if (var2 & 0x01) 

-		{

-			var_out += var1;

-		}

-		var2 >>= 1;

-		var1 <<= 1;

-  }

-	return var_out;

-	

-}// mult_u

-

-unsigned long ldiv_mod_u(register unsigned long a, register unsigned long b, unsigned long * mod)

-{

-	register unsigned long div = b;

-	register unsigned long res = 0;

-	register unsigned long bit = 0x1;

-

-	if (!div)

-	{

-		*mod = 0;

-		return 0xffffffff ; // Div by 0

-	}

-

-	if (a < b)

-	{

-		*mod = a;

-		return 0; // It won't even go once

-	}

-

-	while(!(div & 0x80000000))

-	{

-		div <<= 1;

-		bit <<= 1;

-	}

-

-	while (bit)

-	{

-		if (div <= a)

-    		{

-		      res |= bit;

-		      a -= div;

-		 }

-	    div >>= 1;

-	    bit >>= 1;

-	}

- 	 *mod = a;

-  	return res;

-}// ldiv_mod_u

-

-

-unsigned ldiv_u(register unsigned a, register unsigned  b)

-{  

-	register unsigned div = b << 16;

-	register unsigned res = 0;

-	register unsigned bit = 0x10000;

-	

-	while (bit)

-  	{

-  		div >>= 1;

-		bit >>= 1;

-		if (div < a)

-		{

-			res |= bit;

-			a -= div;

-		}

-	} 

-	

-	return res;

-}

-

-

+//#include "math.h"
+// Arithmatic functions using add & subtract
+
+unsigned long mult_u(register unsigned long var1, register unsigned long var2)
+{
+
+	  register unsigned long var_out = 0;
+	
+	  while (var2 > 0)
+	  {
+
+	  	if (var2 & 0x01) 
+		{
+			var_out += var1;
+		}
+		var2 >>= 1;
+		var1 <<= 1;
+  }
+	return var_out;
+	
+}// mult_u
+
+unsigned long ldiv_mod_u(register unsigned long a, register unsigned long b, unsigned long * mod)
+{
+	register unsigned long div = b;
+	register unsigned long res = 0;
+	register unsigned long bit = 0x1;
+
+	if (!div)
+	{
+		*mod = 0;
+		return 0xffffffff ; // Div by 0
+	}
+
+	if (a < b)
+	{
+		*mod = a;
+		return 0; // It won't even go once
+	}
+
+	while(!(div & 0x80000000))
+	{
+		div <<= 1;
+		bit <<= 1;
+	}
+
+	while (bit)
+	{
+		if (div <= a)
+    		{
+		      res |= bit;
+		      a -= div;
+		 }
+	    div >>= 1;
+	    bit >>= 1;
+	}
+ 	 *mod = a;
+  	return res;
+}// ldiv_mod_u
+
+
+unsigned ldiv_u(register unsigned a, register unsigned  b)
+{  
+	register unsigned div = b << 16;
+	register unsigned res = 0;
+	register unsigned bit = 0x10000;
+	
+	while (bit)
+  	{
+  		div >>= 1;
+		bit >>= 1;
+		if (div < a)
+		{
+			res |= bit;
+			a -= div;
+		}
+	} 
+	
+	return res;
+}
+
+
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sei.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sei.c
index 829eb55..eadd6cc 100644
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sei.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sei.c
@@ -150,11 +150,7 @@
 
 #ifndef VBP
       //Push to current if we are in first frame, or we do not detect previous frame end
-		if( (pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done) ) {
-			viddec_pm_append_workitem( parent, &wi );
-		} else {
-			viddec_pm_append_workitem_next( parent, &wi );
-		}
+      viddec_pm_append_workitem( parent, &wi , !(pInfo->Is_first_frame_in_stream ||(!pInfo->is_current_workload_done)));
 #endif		
 
 		if(sei_msg_ptr->pic_struct < 3) {
@@ -296,17 +292,10 @@
 		sei_msg_ptr->pan_scan_rect_repetition_period = h264_GetVLCElement(parent, pInfo, false);
 		wi.h264_sei_pan_scan.pan_scan_rect_repetition_period = sei_msg_ptr->pan_scan_rect_repetition_period;
 	}
-
-#ifndef VBP
-	if((pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done)) //cur is first frame
-	{
-		viddec_pm_append_workitem( parent, &wi );
-	}
-	else
-	{
-		viddec_pm_append_workitem_next( parent, &wi );
-	}
-#endif
+#ifndef VBP	
+   //cur is first frame
+   viddec_pm_append_workitem( parent, &wi , !(pInfo->Is_first_frame_in_stream ||(!pInfo->is_current_workload_done)));
+#endif   
 
 	if(!sei_msg_ptr->pan_scan_rect_cancel_flag)
 	{
@@ -321,14 +310,10 @@
          viddec_fw_h264_pan_scan_set_right(&(wi.h264_pan_scan_rect), sei_msg_ptr->pan_scan_rect_right_offset[i]);
          viddec_fw_h264_pan_scan_set_top(&(wi.h264_pan_scan_rect), sei_msg_ptr->pan_scan_rect_top_offset[i]);
          viddec_fw_h264_pan_scan_set_bottom(&(wi.h264_pan_scan_rect), sei_msg_ptr->pan_scan_rect_bottom_offset[i]);
-
-#ifndef VBP
-			if(pInfo->Is_first_frame_in_stream) {		//cur is first frame
-				viddec_pm_append_workitem( parent, &wi );
-			} else {
-				viddec_pm_append_workitem_next( parent, &wi );
-			}
-#endif			
+#ifndef VBP         
+         //cur is first frame
+         viddec_pm_append_workitem( parent, &wi , !pInfo->Is_first_frame_in_stream);
+#endif         
 		}
 	}
 
@@ -402,14 +387,8 @@
     	{  
           viddec_pm_setup_userdata(&wi);
 #ifndef VBP          
-          if((pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done)) //cur is first frame
-          {
-              viddec_pm_append_workitem( parent, &wi );
-          }
-          else
-          {
-              viddec_pm_append_workitem_next( parent, &wi );
-          }
+          //cur is first frame
+          viddec_pm_append_workitem( parent, &wi , !(pInfo->Is_first_frame_in_stream ||(!pInfo->is_current_workload_done)));
 #endif          
           wi.user_data.size =0;    		
     	}          
@@ -420,16 +399,9 @@
 	if(0!=wi.user_data.size)
 	{
        viddec_pm_setup_userdata(&wi);
-
-#ifndef VBP   
-       if(pInfo->Is_first_frame_in_stream) //cur is first frame
-       {
-           viddec_pm_append_workitem( parent, &wi );
-       }
-       else
-       {
-           viddec_pm_append_workitem_next( parent, &wi );
-       }
+#ifndef VBP       
+       //cur is first frame
+       viddec_pm_append_workitem( parent, &wi , !pInfo->Is_first_frame_in_stream);
 #endif       
 	}
 	
@@ -474,15 +446,10 @@
     	if(11 == wi.user_data.size)
     	{  
           viddec_pm_setup_userdata(&wi);
-          if((pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done)) //cur is first frame
-          {
-              viddec_pm_append_workitem( parent, &wi );
-          }
-          else
-          {
-              viddec_pm_append_workitem_next( parent, &wi );
-          }
-          
+#ifndef VBP          
+          //cur is first frame
+          viddec_pm_append_workitem( parent, &wi , !(pInfo->Is_first_frame_in_stream ||(!pInfo->is_current_workload_done)));
+#endif         
           wi.user_data.size =0;     		
     	}    	
   	}
@@ -490,14 +457,10 @@
 	if(0!=wi.user_data.size)
 	{
        viddec_pm_setup_userdata(&wi);
-       if(pInfo->Is_first_frame_in_stream) //cur is first frame
-       {
-           viddec_pm_append_workitem( parent, &wi );
-       }
-       else
-       {
-           viddec_pm_append_workitem_next( parent, &wi );
-       }
+#ifndef VBP       
+       //cur is first frame
+       viddec_pm_append_workitem( parent, &wi , !pInfo->Is_first_frame_in_stream);
+#endif       
 	}
 	
 	return H264_STATUS_OK;
@@ -549,15 +512,10 @@
    viddec_fw_h264_h264_sei_recovery_set_exact_match_flag(&(wi.h264_sei_recovery_point), sei_msg_ptr->exact_match_flag);
    viddec_fw_h264_h264_sei_recovery_set_broken_link_flag(&(wi.h264_sei_recovery_point), sei_msg_ptr->broken_link_flag);
 	wi.h264_sei_recovery_point.changing_slice_group_idc = sei_msg_ptr->changing_slice_group_idc;
-
-	if((pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done)) //cur is first frame
-	{
-		viddec_pm_append_workitem( parent, &wi );
-	}
-	else
-	{
-		viddec_pm_append_workitem_next( parent, &wi );
-	}
+#ifndef VBP	
+   //cur is first frame
+   viddec_pm_append_workitem( parent, &wi , !(pInfo->Is_first_frame_in_stream ||(!pInfo->is_current_workload_done)));
+#endif   
 
 	return H264_STATUS_OK;
 }
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sh.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sh.c
index 3134ae0..29340ac 100644
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sh.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/h264parse_sh.c
@@ -728,6 +728,7 @@
 		}
 	}
 	
+
 	
 
 	SliceHeader->sh_dec_refpic.dec_ref_pic_marking_count = i;
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_parse.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_parse.c
index 9388d81..a763d00 100644
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_parse.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_parse.c
@@ -382,6 +382,8 @@
 			
 			h264_parse_emit_eos(parent, pInfo);
          h264_init_dpb(&(pInfo->dpb));
+
+         pInfo->is_current_workload_done=1;
 			
 			/* picture level info which will always be initialized */
 			//h264_init_Info_under_sps_pps_level(pInfo);
diff --git a/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_workload.c b/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_workload.c
index 4fc2f1a..2faa136 100644
--- a/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_workload.c
+++ b/mix_vbp/viddec_fw/fw/codecs/h264/parser/viddec_h264_workload.c
@@ -317,16 +317,8 @@
                                          (((uint32_t)(pInfo->active_SPS.ScalingList4x4[i][n_items*8+5]))<<8)+
                                          (((uint32_t)(pInfo->active_SPS.ScalingList4x4[i][n_items*8+6]))<<16)+
                                          (((uint32_t)(pInfo->active_SPS.ScalingList4x4[i][n_items*8+7]))<<24);
-               
-               if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-               {
-						viddec_pm_append_workitem( parent, &wi );
-               }
-               else
-               {
-                  viddec_pm_append_workitem_next( parent, &wi );            
-               }
-               
+               //cur is empty, fill new frame in cur
+               viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
             }
 
             break;
@@ -344,15 +336,8 @@
                                          (((uint32_t)(pInfo->active_PPS.ScalingList4x4[i][n_items*8+5]))<<8)+
                                          (((uint32_t)(pInfo->active_PPS.ScalingList4x4[i][n_items*8+6]))<<16)+
                                          (((uint32_t)(pInfo->active_PPS.ScalingList4x4[i][n_items*8+7]))<<24);
-               
-               if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-               {            
-                  viddec_pm_append_workitem( parent, &wi );
-               }
-               else
-               {
-                  viddec_pm_append_workitem_next( parent, &wi );            
-               }
+               //cur is empty, fill new frame in cur
+               viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
             }
 
          	break;
@@ -363,14 +348,8 @@
             wi.data.data_offset = i + (DEFAULT_QM << 4);
             wi.data.data_payload[0] = 0;
             wi.data.data_payload[1] = 0;    
-            if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-            {
-               viddec_pm_append_workitem( parent, &wi );
-            }
-            else
-            {
-               viddec_pm_append_workitem_next( parent, &wi );
-            }
+            //cur is empty, fill new frame in cur
+            viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
          	break;
          }
          default:
@@ -448,12 +427,8 @@
                                          (((uint32_t)(pInfo->active_SPS.ScalingList8x8[i-6][n_items*8+5]))<<8)+
                                          (((uint32_t)(pInfo->active_SPS.ScalingList8x8[i-6][n_items*8+6]))<<16)+
                                          (((uint32_t)(pInfo->active_SPS.ScalingList8x8[i-6][n_items*8+7]))<<24);
-               
-               if(pInfo->push_to_cur) {	//cur is empty, fill new frame in cur
-                   viddec_pm_append_workitem( parent, &wi );
-               } else {
-                  viddec_pm_append_workitem_next( parent, &wi );            
-               }               
+               //cur is empty, fill new frame in cur
+               viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
             }
             break;
          }
@@ -470,14 +445,9 @@
                                          (((uint32_t)(pInfo->active_PPS.ScalingList8x8[i-6][n_items*8+5]))<<8)+
                                          (((uint32_t)(pInfo->active_PPS.ScalingList8x8[i-6][n_items*8+6]))<<16)+
                                          (((uint32_t)(pInfo->active_PPS.ScalingList8x8[i-6][n_items*8+7]))<<24);
-               
-               if(pInfo->push_to_cur) { 	//cur is empty, fill new frame in cur
-                  viddec_pm_append_workitem( parent, &wi );
-               } else {	 
-                  viddec_pm_append_workitem_next( parent, &wi );            
-               }
+               //cur is empty, fill new frame in cur
+               viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
             }
-
          	break;
          }
          case (DEFAULT_QM):
@@ -485,12 +455,8 @@
             wi.data.data_offset = i + (DEFAULT_QM << 4);
             wi.data.data_payload[0] = 0;
             wi.data.data_payload[1] = 0;    
-            if(pInfo->push_to_cur) {		//cur is empty, fill new frame in cur
-               viddec_pm_append_workitem( parent, &wi );
-            } else {
-               viddec_pm_append_workitem_next( parent, &wi );            
-            }           
-
+            //cur is empty, fill new frame in cur
+            viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
          	break;
          }
          default:{
@@ -592,15 +558,9 @@
       viddec_fw_h264_sps_set_vui_parameters_present_flag(&(wi.h264_sps), pInfo->active_SPS.sps_disp.vui_parameters_present_flag);
 		wi.h264_sps.pic_width_in_mbs_minus1 = pInfo->active_SPS.sps_disp.pic_width_in_mbs_minus1;
 		wi.h264_sps.pic_height_in_map_units_minus1 = pInfo->active_SPS.sps_disp.pic_height_in_map_units_minus1;
-			
-		if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-		{
-			viddec_pm_append_workitem( parent, &wi );
-		}
-		else
-		{
-			viddec_pm_append_workitem_next( parent, &wi );
-		}
+
+      //cur is empty, fill new frame in cur
+      viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 
       viddec_fw_reset_workload_item(&wi);
 		if(pInfo->active_SPS.sps_disp.frame_cropping_flag)
@@ -610,15 +570,8 @@
          viddec_fw_h264_cropping_set_right(&(wi.h264_cropping), pInfo->active_SPS.sps_disp.frame_crop_rect_right_offset);
          viddec_fw_h264_cropping_set_top(&(wi.h264_cropping), pInfo->active_SPS.sps_disp.frame_crop_rect_top_offset);
          viddec_fw_h264_cropping_set_bottom(&(wi.h264_cropping), pInfo->active_SPS.sps_disp.frame_crop_rect_bottom_offset);
-         
-			if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-			{
-				viddec_pm_append_workitem( parent, &wi );
-			}
-			else
-			{
-				viddec_pm_append_workitem_next( parent, &wi );
-			}
+         //cur is empty, fill new frame in cur
+         viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 		}
       viddec_fw_reset_workload_item(&wi);
 		if(pInfo->active_SPS.sps_disp.vui_parameters_present_flag == 1)
@@ -664,14 +617,8 @@
             viddec_fw_h264_vui_set_low_delay_hrd_flag(&(wi.h264_vui), pInfo->active_SPS.sps_disp.vui_seq_parameters.low_delay_hrd_flag);
 			}
 
-			if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-			{
-				viddec_pm_append_workitem( parent, &wi );
-			}
-			else
-			{
-				viddec_pm_append_workitem_next( parent, &wi );
-			}			
+         //cur is empty, fill new frame in cur
+         viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 		}
 
       viddec_fw_reset_workload_item(&wi);
@@ -682,17 +629,9 @@
          
          wi.h264_vui_time_info.num_units_in_tick = pInfo->active_SPS.sps_disp.vui_seq_parameters.num_units_in_tick;
          wi.h264_vui_time_info.time_scale = pInfo->active_SPS.sps_disp.vui_seq_parameters.time_scale;         		
-         if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-			{
-				viddec_pm_append_workitem( parent, &wi );
-			}
-			else
-			{
-				viddec_pm_append_workitem_next( parent, &wi );
-			}
-		}      
-
-
+         //cur is empty, fill new frame in cur
+         viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
+		}
 		pInfo->Is_SPS_updated =0;
       
    }
@@ -795,14 +734,8 @@
          
          if(data_writed&0x1)
          {
-            if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-            {      
-               viddec_pm_append_workitem( parent, &wi );
-            }
-            else
-            {
-               viddec_pm_append_workitem_next( parent, &wi );      
-            }               
+             //cur is empty, fill new frame in cur
+             viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
          }
          data_writed ++;
       }
@@ -896,15 +829,8 @@
    wi.data.data_payload[0] = slice_data.h264_bsd_slice_p1;
    wi.data.data_payload[1] = slice_data.h264_bsd_slice_p2;
 
-   if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-   {         
-      viddec_pm_append_workitem( parent , &wi);
-   }
-   else
-   {
-      viddec_pm_append_workitem_next( parent , &wi);       
-   }  
-
+   //cur is empty, fill new frame in cur
+   viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 
    ///////////////////////////predict weight table item and data if have///////////////////////////
    if(pInfo->h264_pwt_enabled)
@@ -916,7 +842,7 @@
 
       if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
       {            
-         viddec_pm_append_workitem( parent , &wi);
+          viddec_pm_append_workitem( parent , &wi, false);
 
          wi.vwi_type = VIDDEC_WORKLOAD_H264_PWT_ES_BYTES;
          wi.es.es_flags = 0;
@@ -924,7 +850,7 @@
       }
       else
       {
-         viddec_pm_append_workitem_next( parent , &wi);
+          viddec_pm_append_workitem( parent , &wi, true);
 
          wi.vwi_type = VIDDEC_WORKLOAD_H264_PWT_ES_BYTES;
          wi.es.es_flags = 0;
@@ -951,13 +877,8 @@
          wi.data.data_offset = bits_offset;
          wi.data.data_payload[0]=0;
          wi.data.data_payload[1]=0;
-
-         if(pInfo->push_to_cur) {			//cur is empty, fill new frame in cur
-            viddec_pm_append_workitem( parent , &wi);            
-         }
-         else {
-            viddec_pm_append_workitem_next( parent , &wi);                
-         }          
+         //cur is empty, fill new frame in cur
+         viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
       }
    }
 
@@ -1004,16 +925,8 @@
       wi.data.data_payload[0] = pl[0];
       wi.data.data_payload[1] = pl[1];
       pl += 2;
-      
-      if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-      {
-         
-         viddec_pm_append_workitem( parent, &wi );
-      }
-      else
-      {
-         viddec_pm_append_workitem_next( parent, &wi );         
-      }
+      //cur is empty, fill new frame in cur
+      viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
    }     
 
 	return;
@@ -1059,15 +972,8 @@
 		wi.ref_frame.reference_id = pInfo->dpb.frame_id_need_to_be_displayed[i];
 		wi.ref_frame.luma_phys_addr = 0;
 		wi.ref_frame.chroma_phys_addr = 0;
-
-		if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-		{		   
-		   viddec_pm_append_workitem( parent, &wi );
-		}
-		else
-		{
-		   viddec_pm_append_workitem_next( parent, &wi );		   
-		}
+      //cur is empty, fill new frame in cur
+      viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 	}  
 	pInfo->dpb.frame_numbers_need_to_be_displayed =0;
    
@@ -1081,16 +987,8 @@
 	   wi.ref_frame.reference_id = pInfo->dpb.frame_id_need_to_be_removed[i];
 	   wi.ref_frame.luma_phys_addr = 0;
 	   wi.ref_frame.chroma_phys_addr = 0;
-
-	   if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-	   {	      
-	      viddec_pm_append_workitem( parent, &wi );
-	   }
-	   else
-	   {
-	      viddec_pm_append_workitem_next( parent, &wi );	      
-	   }
-
+      //cur is empty, fill new frame in cur
+      viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 	}  
 	pInfo->dpb.frame_numbers_need_to_be_removed =0;
 
@@ -1103,16 +1001,8 @@
 	   wi.ref_frame.reference_id = pInfo->dpb.frame_id_need_to_be_dropped[i];
 	   wi.ref_frame.luma_phys_addr = 0;
 	   wi.ref_frame.chroma_phys_addr = 0;
-
-	   if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-	   {	      
-	      viddec_pm_append_workitem( parent, &wi );
-	   }
-	   else
-	   {
-	      viddec_pm_append_workitem_next( parent, &wi );	      
-	   }
-
+      //cur is empty, fill new frame in cur
+      viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 	}  
 	pInfo->dpb.frame_numbers_need_to_be_dropped =0;	
 	
@@ -1128,19 +1018,11 @@
 	      wi.ref_frame.reference_id = fs_id;
 	      wi.ref_frame.luma_phys_addr = 0;
 	      wi.ref_frame.chroma_phys_addr = 0;
-
-	      if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-	      {	      
-	         viddec_pm_append_workitem( parent, &wi );
-	      }
-	      else
-	      {
-	         viddec_pm_append_workitem_next( parent, &wi );	      
-	      } 
+         //cur is empty, fill new frame in cur
+         viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 	   }
 	}
    
-   
 	/////////////////////updata dpb frames info (poc)/////////////////////
 	nitems = pInfo->dpb.used_size;
 	for(i=0; i<nitems; i++)
@@ -1179,17 +1061,8 @@
 	            break;
 	         };
 	      }
-	    
-
-	      if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-	      {	      
-	         viddec_pm_append_workitem( parent, &wi );
-	      }
-	      else
-	      {
-	         viddec_pm_append_workitem_next( parent, &wi );	      
-	      }         
-	      
+         //cur is empty, fill new frame in cur
+         viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 	   }
 	}
     
@@ -1226,16 +1099,9 @@
    wi.ref_frame.luma_phys_addr = 0;
    wi.ref_frame.chroma_phys_addr = 0;
 
-   if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-   {        
-      viddec_pm_append_workitem( parent, &wi );
-   }
-   else
-   {
-      viddec_pm_append_workitem_next( parent, &wi );        
-   }
+   //cur is empty, fill new frame in cur
+   viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 
-  	//// 
 	//// Now we can flush out all frames in DPB fro display	
 
    if(MPD_DPB_FS_NULL_IDC != pInfo->dpb.fs_dec_idc)
@@ -1260,15 +1126,8 @@
 		wi.ref_frame.reference_id = pInfo->dpb.frame_id_need_to_be_displayed[i];
 		wi.ref_frame.luma_phys_addr = 0;
 		wi.ref_frame.chroma_phys_addr = 0;
-
-		if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
-		{		   
-		   viddec_pm_append_workitem( parent, &wi );
-		}
-		else
-		{
-		   viddec_pm_append_workitem_next( parent, &wi );		   
-		}
+      //cur is empty, fill new frame in cur
+      viddec_pm_append_workitem( parent, &wi , !pInfo->push_to_cur);
 	}  
 	pInfo->dpb.frame_numbers_need_to_be_displayed =0;
    
@@ -1285,12 +1144,12 @@
 
 	   if(pInfo->push_to_cur) //cur is empty, fill new frame in cur
 	   {	      
-	      viddec_pm_append_workitem( parent, &wi );
+          viddec_pm_append_workitem( parent, &wi , false);
 			viddec_pm_set_next_frame_error_on_eos(parent, VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE);
 	   }
 	   else
 	   {
-	      viddec_pm_append_workitem_next( parent, &wi );	      
+          viddec_pm_append_workitem( parent, &wi , true);
 			viddec_pm_set_next_frame_error_on_eos(parent, pInfo->wl_err_next);
 	   }
 	}  
diff --git a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_fw_mp4_workload.c b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_fw_mp4_workload.c
index 5632728..4a53b8b 100644
--- a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_fw_mp4_workload.c
+++ b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_fw_mp4_workload.c
@@ -2,7 +2,9 @@
 #include "viddec_parser_ops.h"
 #include "viddec_fw_mp4.h"
 #include "viddec_mp4_parse.h"
+#ifdef ANDROID
 #include "viddec_types.h"
+#endif
 
 uint32_t viddec_fw_mp4_populate_attr(viddec_workload_t *wl, viddec_mp4_parser_t *parser)
 {
@@ -76,7 +78,7 @@
     wi.vwi_payload[1] = vol_info.vol_size;
     wi.vwi_payload[2] = vol_info.vol_item;
 
-    result = viddec_pm_append_workitem(parent, &wi);
+    result = viddec_pm_append_workitem(parent, &wi, false);
 
     return result;
 } // viddec_fw_mp4_insert_vol_workitem
@@ -125,7 +127,7 @@
     wi.vwi_payload[1] = vop_info.vop_data;
     wi.vwi_payload[2] = vop_info.bit_offset;
 
-    result = viddec_pm_append_workitem(parent, &wi);
+    result = viddec_pm_append_workitem(parent, &wi, false);
 
     return result;
 } // viddec_fw_mp4_insert_vop_workitem
@@ -150,7 +152,7 @@
     wi.vwi_payload[1] = svh_info.pad1;
     wi.vwi_payload[2] = svh_info.pad2;
 
-    result = viddec_pm_append_workitem(parent, &wi);
+    result = viddec_pm_append_workitem(parent, &wi, false);
 
     return result;
 } // viddec_fw_mp4_insert_vpsh_workitem
@@ -196,7 +198,7 @@
         wi.vwi_payload[1] = sprite_info.warping_mv_code[1];
         wi.vwi_payload[2] = sprite_info.warping_mv_code[2];
 
-        result = viddec_pm_append_workitem(parent, &wi);
+        result = viddec_pm_append_workitem(parent, &wi, false);
     }
 
     return result;
@@ -213,7 +215,7 @@
     wi.vwi_payload[1] = vol->TRD;
     wi.vwi_payload[2] = vol->TRB;
 
-    result = viddec_pm_append_workitem(parent, &wi);
+    result = viddec_pm_append_workitem(parent, &wi, false);
 
     return result;
 } // viddec_fw_mp4_insert_bvop_workitem
@@ -251,7 +253,7 @@
 
         qmat += 3;
 
-        result = viddec_pm_append_workitem(parent, &wi);
+        result = viddec_pm_append_workitem(parent, &wi, false);
     }
 
     return result;
@@ -283,7 +285,7 @@
     wi.ref_frame.reference_id = 0;
     wi.ref_frame.luma_phys_addr = 0;
     wi.ref_frame.chroma_phys_addr = 0;
-    result = viddec_pm_append_workitem(parent, &wi);
+    result = viddec_pm_append_workitem(parent, &wi, false);
 
     return result;
 } // viddec_fw_mp4_insert_past_frame_workitem
@@ -297,7 +299,7 @@
     wi.ref_frame.reference_id = 0;
     wi.ref_frame.luma_phys_addr = 0;
     wi.ref_frame.chroma_phys_addr = 0;
-    result = viddec_pm_append_workitem(parent, &wi);
+    result = viddec_pm_append_workitem(parent, &wi, false);
 
     return result;
 } // viddec_fw_mp4_insert_future_frame_workitem
@@ -313,7 +315,7 @@
     wi.ref_reorder.ref_reorder_00010203 = 0x01010203;
     wi.ref_reorder.ref_reorder_04050607 = 0x04050607;
 
-    result = viddec_pm_append_workitem(parent, &wi);
+    result = viddec_pm_append_workitem(parent, &wi, false);
 
     return result;
 } // viddec_fw_mp4_insert_reorder_workitem
diff --git a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_parse.c b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_parse.c
index 17db475..6a4a8ac 100644
--- a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_parse.c
+++ b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_parse.c
@@ -6,7 +6,9 @@
 #include "viddec_mp4_videoobjectlayer.h"
 #include "viddec_mp4_videoobjectplane.h"
 #include "viddec_mp4_visualobject.h"
+#ifdef ANDROID
 #include "viddec_types.h"
+#endif
 
 extern uint32_t viddec_parse_sc_mp4(void *in, void *pcxt, void *sc_state);
 
@@ -23,7 +25,7 @@
     viddec_mp4_parser_t *parser = (viddec_mp4_parser_t *) ctxt;
     int result = VIDDEC_PARSE_SUCESS;
     uint8_t frame_boundary = false;
-    uint8_t force_frame_complete = false;
+    uint8_t emit_workload = false;
 
     //DEB("entering is_wkld_done: next_sc: 0x%x, sc_seen: %d\n", next_sc, parser->sc_seen);
 
@@ -38,15 +40,35 @@
                         ((SHORT_THIRD_STARTCODE_BYTE & 0xFC) == (next_sc & 0xFC)) || 
                         (MP4_SC_GROUP_OF_VOP == next_sc)    );
 
-    // EOS and discontinuity should force workload completion.
-    force_frame_complete = ((VIDDEC_PARSE_EOS == next_sc) || (VIDDEC_PARSE_DISCONTINUITY == next_sc));
+    // Mark workload is ready to be emitted based on the start codes seen.
+    if (frame_boundary)
+    {
+        uint8_t vol_error_found = false, frame_complete = false;
+        
+        // Frame is considered complete and without errors, if a VOL was received since startup and
+        // if a VOP was received for this workload (or) if short video header is found.
+        frame_complete = ( ((parser->sc_seen & MP4_SC_SEEN_VOL) && (parser->sc_seen & MP4_SC_SEEN_VOP)) ||
+                           (parser->sc_seen & MP4_SC_SEEN_SVH) );
 
-    if(frame_boundary | force_frame_complete)
+        // For non SVH case, the video object layer data should be followed by video object plane data
+        // If not, error occurred and we need to throw the current workload as error.
+        vol_error_found = ( (parser->prev_sc == MP4_SC_VIDEO_OBJECT_LAYER_MIN) &&
+                            !(MP4_SC_VIDEO_OBJECT_PLANE == next_sc) );
+        
+        emit_workload = (frame_complete || vol_error_found);
+
+        //DEB("emit workload: frame_complete: %d, vol_error_found %d\n", frame_complete, vol_error_found);
+    }
+
+    // EOS and discontinuity should force workload completion.
+    emit_workload |= ((VIDDEC_PARSE_EOS == next_sc) || (VIDDEC_PARSE_DISCONTINUITY == next_sc));
+
+    if(emit_workload)
     {
         *codec_specific_errors = 0;
 
-        // Frame is considered complete and without errors, if a VOL was received since startup and 
-        // if a VOP was received for this workload.
+        // If the frame is not complete but we have received force frame complete because of EOS or
+        // discontinuity, we mark the workload as not decodeable.
         if (!((parser->sc_seen & MP4_SC_SEEN_VOL) && (parser->sc_seen & MP4_SC_SEEN_VOP)) && !(parser->sc_seen & MP4_SC_SEEN_SVH))
             *codec_specific_errors |= VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE;
 
diff --git a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_parse.h b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_parse.h
index 12447a4..e9f8bbf 100644
--- a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_parse.h
+++ b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_parse.h
@@ -299,13 +299,18 @@
     uint16_t        num_gobs_in_vop;
     uint16_t        num_macroblocks_in_gob;
     uint8_t         num_rows_in_gob;
-
 #if 0
     uint8_t         gob_number;
-    int         gob_header_empty;
-    int         gob_frame_id;
-    int         quant_scale;
+    int             gob_header_empty;
+    int             gob_frame_id;
+    int             quant_scale;
 #endif
+    uint8_t         vop_rounding_type;
+    //the following are required for PLUSPTYPE
+    uint8_t         ufep;
+    uint16_t        pixel_aspect_ratio_code;
+    uint16_t        picture_width_indication;
+    uint16_t        picture_height_indication;
 } mp4_VideoObjectPlaneH263;
 
 typedef struct
diff --git a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_shortheader.c b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_shortheader.c
index 7e17984..7603cd7 100644
--- a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_shortheader.c
+++ b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_shortheader.c
@@ -1,5 +1,7 @@
 #include "viddec_mp4_shortheader.h"
+#ifdef ANDROID
 #include "viddec_types.h"
+#endif
 
 typedef struct
 {
@@ -25,37 +27,222 @@
     unsigned int data;
     mp4_VideoObjectPlaneH263 *svh = &(parser->info.VisualObject.VideoObject.VideoObjectPlaneH263);
     int32_t getbits = 0;
+    uint8_t pei = 0;
     
     do
     {
-        getbits = viddec_pm_get_bits(parent, &data, 27);
+        //temporal reference
+        getbits = viddec_pm_get_bits(parent, &data, 8);
         BREAK_GETBITS_REQD_MISSING(getbits, ret);
-
-        data = data >> 1; // zero_bit
-        svh->vop_quant = (data & 0x1F);
-        data = data >> 9; // vop_quant + four_reserved_zero_bits
-        svh->picture_coding_type = (data & 0x1);
-        data = data >> 1; // vop_quant + four_reserved_zero_bits
+        svh->temporal_reference = (data & 0xff);
+        //marker bit
+        getbits = viddec_pm_get_bits(parent, &data, 1);
+        BREAK_GETBITS_REQD_MISSING(getbits, ret);
+        if( 1 != (data & 0x1))
+        {
+            ret = MP4_STATUS_NOTSUPPORT;
+            break;
+        }
+        //zero bit
+        getbits = viddec_pm_get_bits(parent, &data, 1);
+        BREAK_GETBITS_REQD_MISSING(getbits, ret);
+        if( 0 != (data & 0x1))
+        {
+            ret = MP4_STATUS_NOTSUPPORT;
+            break;
+        }
+        //split_screen_indicator, document_camera_indicator, full_picture_freeze_release
+        getbits = viddec_pm_get_bits(parent, &data, 3);
+        BREAK_GETBITS_REQD_MISSING(getbits, ret);
+        //source format
+        getbits = viddec_pm_get_bits(parent, &data, 3);
+        BREAK_GETBITS_REQD_MISSING(getbits, ret);
         svh->source_format = (data & 0x7);
-        data = data >> 8; // source_format + full_picture_freeze_release + document_camera_indicator + split_screen_indicator + zero_bit + marker_bit
-        svh->temporal_reference = data;
-
-        if (svh->source_format == 0 || svh->source_format > 5)
+        if (svh->source_format == 0 || svh->source_format == 6)
         {
             DEB("Error: Bad value for VideoPlaneWithShortHeader.source_format\n");
             ret = MP4_STATUS_NOTSUPPORT;
             break;
         }
-
-        for (;;) 
+        
+        if(svh->source_format != 7)
+        {
+            //picture coding type
+            getbits = viddec_pm_get_bits(parent, &data, 1);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            svh->picture_coding_type = (data & 0x1);            
+            //reserved zero bits
+            getbits = viddec_pm_get_bits(parent, &data, 4);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            if( 0 != (data & 0xf))
+            {
+                ret = MP4_STATUS_NOTSUPPORT;
+                break;
+            }
+            //vop quant
+            getbits = viddec_pm_get_bits(parent, &data, 5);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            svh->vop_quant = (data & 0x1f);
+            //zero bit
+            getbits = viddec_pm_get_bits(parent, &data, 1);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            if( 0 != (data & 0x1))
+            {
+                ret = MP4_STATUS_NOTSUPPORT;
+                break;
+            }
+        }
+        else //extended PTYPE (PLUSPTYPE)
+        {
+            //ufep
+            getbits = viddec_pm_get_bits(parent, &data, 3);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            svh->ufep = (data & 0x7); //ufep
+            if(svh->ufep == 0x0)
+            {
+                DEB("Info: don't support to handle the 0x000 case of Update Full Extended PTYPE\n");
+                ret = MP4_STATUS_NOTSUPPORT;
+                break;
+            }
+            else if (svh->ufep == 0x1)
+            {
+                //source format
+                getbits = viddec_pm_get_bits(parent, &data, 3);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                svh->source_format = (data & 0x7);
+                if(svh->source_format < 1 || svh->source_format > 6)
+                {
+                    DEB("Error: bad value of source_format\n");
+                    ret = MP4_STATUS_PARSE_ERROR;
+                    break;
+                }
+                //optional indicators
+                getbits = viddec_pm_get_bits(parent, &data, 8);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                if( 0 != (data & 0xff))
+                {
+                    ret = MP4_STATUS_PARSE_ERROR;
+                    break;
+                }
+                //reserved zero bits
+                getbits = viddec_pm_get_bits(parent, &data, 3);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                if( 0 != (data & 0x7))
+                {
+                    ret = MP4_STATUS_PARSE_ERROR;
+                    break;
+                }
+                //marker bit
+                getbits = viddec_pm_get_bits(parent, &data, 1);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                if( 1 != (data & 0x1))
+                {
+                    ret = MP4_STATUS_PARSE_ERROR;
+                    break;
+                }
+                //reserved zero bits
+                getbits = viddec_pm_get_bits(parent, &data, 3);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                if( 0 != (data & 0x7))
+                {
+                    ret = MP4_STATUS_PARSE_ERROR;
+                    break;
+                }
+            }
+            else
+            {
+                DEB("Info: don't support to handle the other case of Update Full Extended PTYPE\n");
+                ret = MP4_STATUS_NOTSUPPORT;
+                break;
+            }
+            //MPPTYPE
+            //picture coding type
+            getbits = viddec_pm_get_bits(parent, &data, 3);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            svh->picture_coding_type = (data & 0x7);
+            if(svh->picture_coding_type > 1)
+            {
+                DEB("Info: only support I and P frames\n");
+                ret = MP4_STATUS_NOTSUPPORT;
+                break;
+            }
+            //optional RPR mode
+            getbits = viddec_pm_get_bits(parent, &data, 1);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            if( 0 != (data & 0x1))
+            {
+                ret = MP4_STATUS_PARSE_ERROR;
+                break;
+            }
+            //optional PRU mode
+            getbits = viddec_pm_get_bits(parent, &data, 1);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            if( 0 != (data & 0x1))
+            {
+                ret = MP4_STATUS_PARSE_ERROR;
+                break;
+            }
+            //vop rounding type
+            getbits = viddec_pm_get_bits(parent, &data, 1);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            svh->vop_rounding_type = (data & 0x1);
+            //reserved zero bits
+            getbits = viddec_pm_get_bits(parent, &data, 2);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            if( 0 != (data & 0x3))
+            {
+                ret = MP4_STATUS_PARSE_ERROR;
+                break;
+            }
+            //marker bit
+            getbits = viddec_pm_get_bits(parent, &data, 1);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            if( 1 != (data & 0x1))
+            {
+                ret = MP4_STATUS_PARSE_ERROR;
+                break;
+            }
+            //cpm
+            getbits = viddec_pm_get_bits(parent, &data, 1);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            if(svh->ufep == 1 && svh->source_format == 6)
+            {   //CPFMT
+                getbits = viddec_pm_get_bits(parent, &data, 4);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                svh->pixel_aspect_ratio_code = (data & 0xf);
+                //
+                getbits = viddec_pm_get_bits(parent, &data, 9);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                svh->picture_width_indication = (data & 0x1ff);
+                //marker bit
+                getbits = viddec_pm_get_bits(parent, &data, 1);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                if( 1 != (data & 0x1))
+                {
+                    ret = MP4_STATUS_PARSE_ERROR;
+                    break;
+                }
+                //
+                getbits = viddec_pm_get_bits(parent, &data, 9);
+                BREAK_GETBITS_REQD_MISSING(getbits, ret);
+                svh->picture_height_indication = (data & 0x1ff);
+            }
+            viddec_pm_get_bits(parent, &data, 5);
+            BREAK_GETBITS_REQD_MISSING(getbits, ret);
+            svh->vop_quant = (data & 0x1f);
+        }
+        //PEI
+        do
         {
             getbits = viddec_pm_get_bits(parent, &data, 1); // pei
             BREAK_GETBITS_FAIL(getbits, ret);
-            if (!data)
-                break;
-            getbits = viddec_pm_get_bits(parent, &data, 8); // psupp
-            BREAK_GETBITS_FAIL(getbits, ret);
-        }
+            pei = (data & 0x1);
+            if(0 != pei)
+            {
+                getbits = viddec_pm_get_bits(parent, &data, 8); // psupp
+                BREAK_GETBITS_FAIL(getbits, ret);
+            }
+        }while( 1 == pei);
 
         // Anything after this needs to be fed to the decoder as PIXEL_ES
     } while(0);
@@ -72,6 +259,7 @@
     mp4_VideoObjectPlane_t  *vop = &(pInfo->VisualObject.VideoObject.VideoObjectPlane);
     mp4_VideoObjectPlaneH263 *svh = &(pInfo->VisualObject.VideoObject.VideoObjectPlaneH263);
     uint8_t index = 0;
+    uint8_t k = 0;
 
     ret = mp4_Parse_VideoObjectPlane_svh(parent, parser);
     if(ret == MP4_STATUS_OK)
@@ -94,7 +282,7 @@
         vol->fixed_vop_time_increment = 1001;
         vol->aspect_ratio_info = MP4_ASPECT_RATIO_12_11;
 
-        vop->vop_rounding_type = 0;
+        vop->vop_rounding_type = svh->vop_rounding_type;
         vop->vop_fcode_forward = 1;
         vop->vop_coded = 1;
         vop->vop_coding_type = svh->picture_coding_type ? MP4_VOP_TYPE_P: MP4_VOP_TYPE_I;
@@ -104,12 +292,41 @@
         vst->transfer_characteristics = 1;
         vst->matrix_coefficients = 6;
 
-        index = svh->source_format - 1;
-        vol->video_object_layer_width = svh_src_fmt_defaults[index].vop_width;
-        vol->video_object_layer_height = svh_src_fmt_defaults[index].vop_height;
-        svh->num_macroblocks_in_gob = svh_src_fmt_defaults[index].num_macroblocks_in_gob;
-        svh->num_gobs_in_vop = svh_src_fmt_defaults[index].num_gobs_in_vop;
-        svh->num_rows_in_gob = svh_src_fmt_defaults[index].num_rows_in_gob;
+        if(svh->source_format >= 1 && svh->source_format <= 5)
+        {
+            index = svh->source_format - 1;
+            vol->video_object_layer_width = svh_src_fmt_defaults[index].vop_width;
+            vol->video_object_layer_height = svh_src_fmt_defaults[index].vop_height;
+            svh->num_macroblocks_in_gob = svh_src_fmt_defaults[index].num_macroblocks_in_gob;
+            svh->num_gobs_in_vop = svh_src_fmt_defaults[index].num_gobs_in_vop;
+            svh->num_rows_in_gob = svh_src_fmt_defaults[index].num_rows_in_gob;
+        }
+        else if(svh->source_format == 6) //custom format
+        {
+            vol->video_object_layer_width = (svh->picture_width_indication + 1)*4;
+            vol->video_object_layer_height = (svh->picture_height_indication)*4;
+            if(vol->video_object_layer_height < 404)
+            {
+                k = 1;
+            }
+            else if (vol->video_object_layer_height < 804)
+            {
+                k = 2;
+            }
+            else
+            {
+                k = 4;
+            }
+            svh->num_macroblocks_in_gob = (vol->video_object_layer_width/16)*k;
+            svh->num_gobs_in_vop = (vol->video_object_layer_height)/(16*k);
+            svh->num_rows_in_gob = k;
+        }
+        else
+        {
+            DEB("Error: Bad value for VideoPlaneWithShortHeader.source_format\n");
+            ret = MP4_STATUS_NOTSUPPORT;
+            return ret;
+        }
     }
 
     mp4_set_hdr_bitstream_error(parser, false, ret);
@@ -126,7 +343,7 @@
 
         viddec_fw_mp4_vpsh_set_source_format(&wi.mp4_vpsh, svh->source_format);
 
-        ret = viddec_pm_append_workitem(parent, &wi);
+        ret = viddec_pm_append_workitem(parent, &wi, false);
         if(ret == 1)
             ret = MP4_STATUS_OK;
     }
diff --git a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_videoobjectlayer.c b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_videoobjectlayer.c
index 9145342..e92a26d 100644
--- a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_videoobjectlayer.c
+++ b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_videoobjectlayer.c
@@ -1,5 +1,7 @@
 #include "viddec_mp4_videoobjectlayer.h"
+#ifdef ANDROID
 #include "viddec_types.h"
+#endif
 
 const unsigned char mp4_DefaultIntraQuantMatrix[64] = {
     8, 17, 18, 19, 21, 23, 25, 27, 
@@ -583,7 +585,7 @@
         viddec_fw_mp4_vol_set_fixed_vop_time_increment(&wi.mp4_vol, vidObjLay->fixed_vop_time_increment);
         viddec_fw_mp4_vol_set_vop_time_increment_resolution(&wi.mp4_vol, vidObjLay->vop_time_increment_resolution);
 
-        ret = viddec_pm_append_workitem(parent, &wi);
+        ret = viddec_pm_append_workitem(parent, &wi, false);
         if(ret == 1)
             ret = MP4_STATUS_OK;
 
diff --git a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_videoobjectplane.c b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_videoobjectplane.c
index cf761e3..5d1ae0f 100644
--- a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_videoobjectplane.c
+++ b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_videoobjectplane.c
@@ -1,5 +1,7 @@
 #include "viddec_mp4_videoobjectplane.h"
+#ifdef ANDROID
 #include "viddec_types.h"
+#endif
 
 mp4_Status_t mp4_Parse_GroupOfVideoObjectPlane(void *parent, viddec_mp4_parser_t *parser)
 {
@@ -55,7 +57,7 @@
         viddec_fw_mp4_gvop_set_closed_gov(&wi.mp4_gvop, data->closed_gov);
         viddec_fw_mp4_gvop_set_time_code(&wi.mp4_gvop, time_code);
 
-        ret = viddec_pm_append_workitem(parent, &wi);
+        ret = viddec_pm_append_workitem(parent, &wi, false);
         if(ret == 1)
             ret = MP4_STATUS_OK;
     }
diff --git a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_visualobject.c b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_visualobject.c
index 49e7887..35a352d 100644
--- a/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_visualobject.c
+++ b/mix_vbp/viddec_fw/fw/codecs/mp4/parser/viddec_mp4_visualobject.c
@@ -1,5 +1,7 @@
 #include "viddec_mp4_visualobject.h"
+#ifdef ANDROID
 #include "viddec_types.h"
+#endif
 
 static inline uint8_t mp4_pvt_isValid_verID(uint8_t id)
 {
@@ -214,7 +216,7 @@
             }
         }
 
-        ret = viddec_pm_append_workitem(parent, &wi);
+        ret = viddec_pm_append_workitem(parent, &wi, false);
         if(ret == 1)
             ret = MP4_STATUS_OK;
     }
@@ -263,7 +265,7 @@
         if (wi.user_data.size >= 11)
         {
             viddec_pm_setup_userdata(&wi);
-            ret = viddec_pm_append_workitem(parent, &wi);
+            ret = viddec_pm_append_workitem(parent, &wi, false);
             wi.user_data.size = 0;
         }
     }
@@ -276,7 +278,7 @@
             wi.user_data.data_payload[i] = 0;
         }
         viddec_pm_setup_userdata(&wi);
-        ret = viddec_pm_append_workitem(parent, &wi);
+        ret = viddec_pm_append_workitem(parent, &wi, false);
         wi.user_data.size = 0;
     }
 
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/include/vc1common.h b/mix_vbp/viddec_fw/fw/codecs/vc1/include/vc1common.h
index d57a9bf..66a93df 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/include/vc1common.h
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/include/vc1common.h
@@ -31,6 +31,15 @@
    VIDDEC_WORKLOAD_VC1_BITPLANE0,
    VIDDEC_WORKLOAD_VC1_BITPLANE1,
    VIDDEC_WORKLOAD_VC1_BITPLANE2,
+   VIDDEC_WORKLOAD_VC1_REGS_SEQ_ENTRY,
+   VIDDEC_WORKLOAD_VC1_REGS_SIZE_AND_AP_RANGEMAP,  
+   VIDDEC_WORKLOAD_VC1_REGS_INT_COM_FW,
+   VIDDEC_WORKLOAD_VC1_REGS_INT_COM_BW,   
+   VIDDEC_WORKLOAD_VC1_REGS_STRUCT_FIELD_AND_SMP_RANGEMAP_INFO,
+   VIDDEC_WORKLOAD_VC1_REGS_SLICE_FRAME_TYPE_INFO,
+   VIDDEC_WORKLOAD_VC1_REGS_SLICE_CONTROL_INFO,
+   VIDDEC_WORKLOAD_VC1_REGS_SLICE_OTHER_INFO, 
+   VIDDEC_WORKLOAD_VC1_REGS_REF_FRAME_TYPE,
    VIDDEC_WORKLOAD_VC1_PAST_FRAME   = VIDDEC_WORKLOAD_REF_FRAME_SOURCE_0,
    VIDDEC_WORKLOAD_VC1_FUTURE_FRAME,
 };
@@ -75,7 +84,7 @@
    /* 0x08 */ uint32_t coded_size;
    /* 0x0c */ uint32_t stream_format2;
    /* 0x10 */ uint32_t entrypoint1;
-   /* 0x14 */ uint32_t range_map;
+   /* 0x14 */ uint32_t ap_range_map;
    /* 0x18 */ uint32_t frame_type;
    /* 0x1c */ uint32_t recon_control;
    /* 0x20 */ uint32_t mv_control;
@@ -93,7 +102,7 @@
    /* 0x58 */ uint32_t intcomp_fwd_bot;
    /* 0x5c */ uint32_t intcomp_bwd_top;
    /* 0x60 */ uint32_t intcomp_bwd_bot;
-   /* 0x64 */ uint32_t _stuffing;
+   /* 0x14 */ uint32_t smp_range_map;
 } VC1D_SPR_REGS;
 
 /*
@@ -105,6 +114,7 @@
    VC1_FRAME_CURRENT_DIS,
    VC1_FRAME_PAST,
    VC1_FRAME_FUTURE,
+   VC1_FRAME_ALT
 };
 
 #endif  //_VC1_COMMON_H_
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/mix_vbp_vc1_stubs.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/mix_vbp_vc1_stubs.c
index a2d6721..72b770f 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/mix_vbp_vc1_stubs.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/mix_vbp_vc1_stubs.c
@@ -10,7 +10,21 @@
   return;
 }
 
+
 int32_t vc1_parse_emit_current_frame( void *parent,  vc1_viddec_parser_t   *parser )
 {
    return(0);
 }
+
+
+void vc1_parse_emit_frame_start(void *parent, vc1_viddec_parser_t *parser)
+{
+}
+
+void vc1_parse_emit_second_field_start(void *parent, vc1_viddec_parser_t *parser)
+{
+}
+
+void vc1_parse_emit_current_slice(void *parent, vc1_viddec_parser_t *parser)
+{
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1.h b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1.h
index 8416b24..a2607d7 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1.h
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1.h
@@ -187,6 +187,7 @@
    int anchor[2];   /* one per field */
    int rr_en;       /* range reduction enable flag at sequence layer */ 
    int rr_frm;      /* range reduction flag at picture layer */
+   int tff;
 } ref_frame_t;
 
 typedef struct
@@ -194,7 +195,8 @@
     uint32_t      sc_seen_since_last_wkld;
     uint32_t      sc_seen;
     uint32_t      is_frame_start;
-	uint8_t is_reference_picture; 
+    uint32_t      is_second_start;
+	 uint32_t      is_reference_picture; 
     uint32_t      intcomp_last[4]; /* for B frames */
     uint32_t      intcomp_top[2];
     uint32_t      intcomp_bot[2];
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse.c
index a033385..d98b38a 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse.c
@@ -95,7 +95,7 @@
         viddec_fw_vc1_set_rcv_maxbframes(&wi.vc1_sh_struct_a_c, rcv.struct_c.MAXBFRAMES);
         viddec_fw_vc1_set_rcv_finterpflag(&wi.vc1_sh_struct_a_c, rcv.struct_c.FINTERPFLAG);
 
-        result = viddec_pm_append_workitem(ctxt, &wi);
+        result = viddec_pm_append_workitem(ctxt, &wi, false);
     }
 
     return status;
@@ -125,9 +125,10 @@
     if(result == 1)
     {
         md->PROFILE = sh.seq_flags.PROFILE;
-#ifdef VBP
         md->LEVEL = sh.seq_flags.LEVEL;
-#endif
+        md->CHROMAFORMAT = sh.seq_flags.COLORDIFF_FORMAT;
+        md->FRMRTQ = sh.seq_flags.FRMRTQ_POSTPROC;
+        md->BITRTQ = sh.seq_flags.BITRTQ_POSTPROC;        
     }
 
     result = viddec_pm_get_bits(ctxt, &sh.max_size, 32);
@@ -230,7 +231,7 @@
         viddec_fw_vc1_set_psf(&wi_sl.vc1_sl, sh.seq_max_size.PSF);
         viddec_fw_vc1_set_display_ext(&wi_sl.vc1_sl, sh.seq_max_size.DISPLAY_EXT);
 
-        result = viddec_pm_append_workitem(ctxt, &wi_sl);
+        result = viddec_pm_append_workitem(ctxt, &wi_sl, false);
 
         // send DISPLAY EXTENSION metadata if present
         if (sh.seq_max_size.DISPLAY_EXT)
@@ -258,7 +259,7 @@
             viddec_fw_vc1_set_disp_color_prim(&wi_de.vc1_sl_de, sh.seq_color_format.COLOR_PRIM);
             viddec_fw_vc1_set_disp_transfer_char(&wi_de.vc1_sl_de, sh.seq_color_format.TRANSFER_CHAR);
 
-            result = viddec_pm_append_workitem(ctxt, &wi_de);
+            result = viddec_pm_append_workitem(ctxt, &wi_de, false);
         }
     }
 
@@ -298,6 +299,8 @@
         result = viddec_pm_skip_bits(ctxt, hrd_bits);
 
         md->REFDIST = 0;
+        md->BROKEN_LINK = ep.ep_flags.BROKEN_LINK;
+        md->CLOSED_ENTRY = ep.ep_flags.CLOSED_ENTRY;
         md->PANSCAN_FLAG = ep.ep_flags.PANSCAN_FLAG;
         md->REFDIST_FLAG = ep.ep_flags.REFDIST_FLAG;
         md->LOOPFILTER = ep.ep_flags.LOOPFILTER;
@@ -370,14 +373,9 @@
         viddec_fw_vc1_set_ep_range_mapuv_flag(&wi.vc1_ep, ep.RANGE_MAPUV_FLAG);
         viddec_fw_vc1_set_ep_range_mapuv(&wi.vc1_ep, ep.RANGE_MAPUV);
 
-        result = viddec_pm_append_workitem(ctxt, &wi);
+        result = viddec_pm_append_workitem(ctxt, &wi, false);
     }
 
-#ifdef VBP
-    md->BROKEN_LINK = ep.ep_flags.BROKEN_LINK;
-    md->CLOSED_ENTRY = ep.ep_flags.CLOSED_ENTRY;
-#endif
-    
     DEB("ep: res: %dx%d\n", ep.ep_size.CODED_WIDTH, ep.ep_size.CODED_HEIGHT);
     DEB("md: after ep: res: %dx%d\n", md->width, md->height);
     return status;
@@ -534,7 +532,7 @@
         if (wi.user_data.size >= 11)
         {
             viddec_pm_setup_userdata(&wi);
-            viddec_pm_append_workitem(ctxt, &wi);
+            viddec_pm_append_workitem(ctxt, &wi,false);
             wi.user_data.size = 0;
         }
         if(user_data == 0x80) // flushing byte
@@ -549,7 +547,7 @@
             wi.user_data.data_payload[i] = 0;
         }
         viddec_pm_setup_userdata(&wi);
-        viddec_pm_append_workitem(ctxt, &wi);
+        viddec_pm_append_workitem(ctxt, &wi,false);
         wi.user_data.size = 0;
     }
 
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse.h b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse.h
index d0e2f00..16e0497 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse.h
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse.h
@@ -1,136 +1,140 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.

-//

-//  Description: Common functions for parsing VC-1 bitstreams.

-//

-*/

-

-#ifndef _VC1PARSE_H_

-#define _VC1PARSE_H_

-

-#include "viddec_parser_ops.h"

-#include "vc1.h"

-

-/** @weakgroup vc1parse_defs VC-1 Parse Definitions */

-/** @ingroup vc1parse_defs */

-/*@{*/

-

-/* This macro gets the next less-than-nine bits from the bitstream.  It is

-assumed that numBits is less than ten. */

-#ifdef VC1_VERBOSE

-#include <stdio.h>

-#define AUTO_TRACE OS_INFO("trace: %s\n", __FUNCTION__)

-#define DEBUGBITS(arg1, args ...) OS_INFO( arg1, ## args)

-#else

-#define AUTO_TRACE

-#define DEBUGBITS(...)

-#endif

-

-extern void *memset(void *s, int32_t c, uint32_t n);

-

-/* This macro gets the next numBits from the bitstream. */

-#define VC1_GET_BITS VC1_GET_BITS9

-#define VC1_GET_BITS9(numBits, value) \

-{   uint32_t __tmp__; \

-    viddec_pm_get_bits(ctxt, (uint32_t*)&__tmp__, numBits ); \

-    value = __tmp__;\

-    DEBUGBITS("BIT:%40s= 0x%x\tNo. of bits=%d\tbyte = %02x\t%s[%d]\n", #value, value, numBits, 0, __FILE__, __LINE__); \

-}

-

-#define VC1_PEEK_BITS(numBits, value) \

-{   uint32_t __tmp__; \

-    viddec_pm_peek_bits(ctxt, (uint32_t*)&__tmp__, numBits ); \

-    value = __tmp__;\

-    DEBUGBITS("PEEK%40s= 0x%x\tNo. of bits=%d\tbyte = %02x\t%s[%d]\n", #value, value, numBits, 0, __FILE__, __LINE__); \

-}

-

-/* This macro asserts if the condition is not true. */

-#ifdef VC1_VERBOSE

-#define VC1_ASSERT(condition) \

-{ \

-    if (! (condition)) \

-        OS_INFO("Failed " #condition "!\n"); \

-}

-#else

-#define VC1_ASSERT(condition)

-#endif

-

-/*@}*/

-

-/** @weakgroup vc1parse VC-1 Parse Functions */

-/** @ingroup vc1parse */

-/*@{*/

-

-extern const uint8_t VC1_MVMODE_LOW_TBL[];

-extern const uint8_t VC1_MVMODE_HIGH_TBL[];

-extern const int32_t VC1_BITPLANE_IMODE_TBL[];

-extern const int32_t VC1_BITPLANE_K_TBL[];

-extern const int32_t VC1_BFRACTION_TBL[];

-extern const int32_t VC1_REFDIST_TBL[];

-

-void vc1_end_frame(vc1_viddec_parser_t *parser);

-

-/* Top-level functions to parse bitstream layers for rcv format. */

-vc1_Status vc1_ParseRCVSequenceLayer (void* ctxt, vc1_Info *pInfo);

-

-/* Top-level functions to parse bitstream layers for the various profiles. */

-vc1_Status vc1_ParseSequenceLayer(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParseEntryPointLayer(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParseSliceLayer(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureLayer(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParseFieldLayer(void* ctxt, vc1_Info *pInfo);

-

-/* Top-level functions to parse headers for various picture layers for the

-simple and main profiles. */

-vc1_Status vc1_ParsePictureHeader(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureHeader_ProgressiveIpicture(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureHeader_ProgressivePpicture(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureHeader_ProgressiveBpicture(void* ctxt, vc1_Info *pInfo);

-

-/* Top-level functions to parse common part of the headers for various picture

-layers for the advanced profile. */

-vc1_Status vc1_ParsePictureHeader_Adv(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParseFieldHeader_Adv (void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureFieldHeader_Adv(void* ctxt, vc1_Info *pInfo);

-

-/* Functions to parse remainder part of the headers for various progressive

-picture layers for the advanced profile. */

-vc1_Status vc1_ParsePictureHeader_ProgressiveIpicture_Adv(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureHeader_ProgressivePpicture_Adv(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureHeader_ProgressiveBpicture_Adv(void* ctxt, vc1_Info *pInfo);

-

-/* Functions to parse remainder part of the headers for various interlace frame

-layers for the advanced profile. */

-vc1_Status vc1_ParsePictureHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureHeader_InterlacePpicture_Adv(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParsePictureHeader_InterlaceBpicture_Adv(void* ctxt, vc1_Info *pInfo);

-

-/* Functions to parse remainder part of the headers for various interlace frame

-layers for the advanced profile. */

-vc1_Status vc1_ParseFieldHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParseFieldHeader_InterlacePpicture_Adv(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_ParseFieldHeader_InterlaceBpicture_Adv(void* ctxt, vc1_Info *pInfo);

-

-/* Functions to parse syntax element in bitstream. */

-vc1_Status vc1_MVRangeDecode(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_DMVRangeDecode(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_CalculatePQuant(vc1_Info *pInfo);

-vc1_Status vc1_VOPDQuant(void* ctxt, vc1_Info *pInfo);

-vc1_Status vc1_DecodeBitplane(void* ctxt, vc1_Info *pInfo, uint32_t width, uint32_t height, vc1_bpp_type_t bptype);

-vc1_Status vc1_DecodeHuffmanOne(void* ctxt, int32_t *pDst, const int32_t *pDecodeTable);

-vc1_Status vc1_DecodeHuffmanPair(void* ctxt, const int32_t *pDecodeTable, int8_t *pFirst, int16_t *pSecond);

-

-void vc1_start_new_frame(void *parent, vc1_viddec_parser_t *parser);

-int32_t vc1_parse_emit_current_frame(void *parent, vc1_viddec_parser_t *parser);

-

-/* function to handle user data */

-vc1_Status vc1_ParseAndAppendUserData(void* ctxt, uint32_t sc);

-

-/*@}*/

-

-#endif /* _VC1PARSE_H_. */

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
+//
+//  Description: Common functions for parsing VC-1 bitstreams.
+//
+*/
+
+#ifndef _VC1PARSE_H_
+#define _VC1PARSE_H_
+
+#include "viddec_parser_ops.h"
+#include "vc1.h"
+
+/** @weakgroup vc1parse_defs VC-1 Parse Definitions */
+/** @ingroup vc1parse_defs */
+/*@{*/
+
+/* This macro gets the next less-than-nine bits from the bitstream.  It is
+assumed that numBits is less than ten. */
+#ifdef VC1_VERBOSE
+#include <stdio.h>
+#define AUTO_TRACE OS_INFO("trace: %s\n", __FUNCTION__)
+#define DEBUGBITS(arg1, args ...) OS_INFO( arg1, ## args)
+#else
+#define AUTO_TRACE
+#define DEBUGBITS(...)
+#endif
+
+extern void *memset(void *s, int32_t c, uint32_t n);
+
+/* This macro gets the next numBits from the bitstream. */
+#define VC1_GET_BITS VC1_GET_BITS9
+#define VC1_GET_BITS9(numBits, value) \
+{   uint32_t __tmp__; \
+    viddec_pm_get_bits(ctxt, (uint32_t*)&__tmp__, numBits ); \
+    value = __tmp__;\
+    DEBUGBITS("BIT:%40s= 0x%x\tNo. of bits=%d\tbyte = %02x\t%s[%d]\n", #value, value, numBits, 0, __FILE__, __LINE__); \
+}
+
+#define VC1_PEEK_BITS(numBits, value) \
+{   uint32_t __tmp__; \
+    viddec_pm_peek_bits(ctxt, (uint32_t*)&__tmp__, numBits ); \
+    value = __tmp__;\
+    DEBUGBITS("PEEK%40s= 0x%x\tNo. of bits=%d\tbyte = %02x\t%s[%d]\n", #value, value, numBits, 0, __FILE__, __LINE__); \
+}
+
+/* This macro asserts if the condition is not true. */
+#ifdef VC1_VERBOSE
+#define VC1_ASSERT(condition) \
+{ \
+    if (! (condition)) \
+        OS_INFO("Failed " #condition "!\n"); \
+}
+#else
+#define VC1_ASSERT(condition)
+#endif
+
+/*@}*/
+
+/** @weakgroup vc1parse VC-1 Parse Functions */
+/** @ingroup vc1parse */
+/*@{*/
+
+extern const uint8_t VC1_MVMODE_LOW_TBL[];
+extern const uint8_t VC1_MVMODE_HIGH_TBL[];
+extern const int32_t VC1_BITPLANE_IMODE_TBL[];
+extern const int32_t VC1_BITPLANE_K_TBL[];
+extern const int32_t VC1_BFRACTION_TBL[];
+extern const int32_t VC1_REFDIST_TBL[];
+
+void vc1_end_frame(vc1_viddec_parser_t *parser);
+
+/* Top-level functions to parse bitstream layers for rcv format. */
+vc1_Status vc1_ParseRCVSequenceLayer (void* ctxt, vc1_Info *pInfo);
+
+/* Top-level functions to parse bitstream layers for the various profiles. */
+vc1_Status vc1_ParseSequenceLayer(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParseEntryPointLayer(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParseSliceLayer(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureLayer(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParseFieldLayer(void* ctxt, vc1_Info *pInfo);
+
+/* Top-level functions to parse headers for various picture layers for the
+simple and main profiles. */
+vc1_Status vc1_ParsePictureHeader(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureHeader_ProgressiveIpicture(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureHeader_ProgressivePpicture(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureHeader_ProgressiveBpicture(void* ctxt, vc1_Info *pInfo);
+
+/* Top-level functions to parse common part of the headers for various picture
+layers for the advanced profile. */
+vc1_Status vc1_ParsePictureHeader_Adv(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParseFieldHeader_Adv (void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureFieldHeader_Adv(void* ctxt, vc1_Info *pInfo);
+
+/* Functions to parse remainder part of the headers for various progressive
+picture layers for the advanced profile. */
+vc1_Status vc1_ParsePictureHeader_ProgressiveIpicture_Adv(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureHeader_ProgressivePpicture_Adv(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureHeader_ProgressiveBpicture_Adv(void* ctxt, vc1_Info *pInfo);
+
+/* Functions to parse remainder part of the headers for various interlace frame
+layers for the advanced profile. */
+vc1_Status vc1_ParsePictureHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureHeader_InterlacePpicture_Adv(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParsePictureHeader_InterlaceBpicture_Adv(void* ctxt, vc1_Info *pInfo);
+
+/* Functions to parse remainder part of the headers for various interlace frame
+layers for the advanced profile. */
+vc1_Status vc1_ParseFieldHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParseFieldHeader_InterlacePpicture_Adv(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_ParseFieldHeader_InterlaceBpicture_Adv(void* ctxt, vc1_Info *pInfo);
+
+/* Functions to parse syntax element in bitstream. */
+vc1_Status vc1_MVRangeDecode(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_DMVRangeDecode(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_CalculatePQuant(vc1_Info *pInfo);
+vc1_Status vc1_VOPDQuant(void* ctxt, vc1_Info *pInfo);
+vc1_Status vc1_DecodeBitplane(void* ctxt, vc1_Info *pInfo, uint32_t width, uint32_t height, vc1_bpp_type_t bptype);
+vc1_Status vc1_DecodeHuffmanOne(void* ctxt, int32_t *pDst, const int32_t *pDecodeTable);
+vc1_Status vc1_DecodeHuffmanPair(void* ctxt, const int32_t *pDecodeTable, int8_t *pFirst, int16_t *pSecond);
+
+void vc1_parse_emit_frame_start(void *parent, vc1_viddec_parser_t *parser);
+void vc1_parse_emit_second_field_start(void *parent, vc1_viddec_parser_t *parser);
+void vc1_parse_emit_current_slice(void *parent, vc1_viddec_parser_t *parser);
+
+
+
+
+/* function to handle user data */
+vc1_Status vc1_ParseAndAppendUserData(void* ctxt, uint32_t sc);
+
+/*@}*/
+
+#endif /* _VC1PARSE_H_. */
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bitplane.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bitplane.c
index 5ee9e18..b7dd271 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bitplane.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bitplane.c
@@ -369,20 +369,19 @@
         ResidualY = height & 1;
     }
 
-#ifndef VBP
     for (i = 0; i < ResidualX; i++)
     {
         int32_t ColSkip;
         VC1_GET_BITS(1, ColSkip);
 
-        if (1 == ColSkip)
+        //if (1 == ColSkip)
         {
             for(j = 0; j < height; j++)
             {
-                int32_t Value = 0;
-                VC1_GET_BITS(1, Value);
-                put_bit(Value, i, j, width, height,pBitplane->invert,
-                        pBitplane->databits);
+			int32_t Value = 0;
+			if (1 == ColSkip) VC1_GET_BITS(1, Value);
+			
+			put_bit(Value, i, j, width, height,pBitplane->invert,pBitplane->databits);
             }
         }
     }
@@ -391,51 +390,17 @@
     {
         int32_t RowSkip;
         VC1_GET_BITS(1, RowSkip);
-        if (1 == RowSkip)
+        //if (1 == RowSkip)
         {
             for (i = ResidualX; i < width; i++)
             {
-                int32_t Value = 0;
-                VC1_GET_BITS(1, Value);
-                put_bit(Value, i, j, width, height,pBitplane->invert,
-                        pBitplane->databits);
+				int32_t Value = 0;
+				if (1 == RowSkip) VC1_GET_BITS(1, Value);
+				
+				put_bit(Value, i, j, width, height,pBitplane->invert,pBitplane->databits);
             }
         }
     }
- #else
-	int32_t Value = 0;
-    for (i = 0; i < ResidualX; i++)
-    {
-        int32_t ColSkip;
-        VC1_GET_BITS(1, ColSkip);
-        Value = 0;
-		for(j = 0; j < height; j++)
-        {           
-			if (1 == ColSkip)
-        	{
-                VC1_GET_BITS(1, Value);
-        	}
-			put_bit(Value, i, j, width, height,pBitplane->invert,
-                        pBitplane->databits);
-        }
-    }
-
-    for (j = 0; j < ResidualY; j++)
-    {
-        int32_t RowSkip;
-        VC1_GET_BITS(1, RowSkip);
-        Value = 0;
-		for (i = ResidualX; i < width; i++)
-		{
-        	if (1 == RowSkip)
-        	{
-                VC1_GET_BITS(1, Value);
-        	}
-			put_bit(Value, i, j, width, height,pBitplane->invert,
-                        pBitplane->databits);
-        }
-    }
- #endif
 
     /* restore value */
     pBitplane->invert=tmp;
@@ -489,8 +454,7 @@
     VC1_GET_BITS(1, tempValue);
     bpp->invert = (uint8_t) tempValue;
 
-    if ((status = vc1_DecodeHuffmanOne(ctxt, &bpp->imode,
-                                       VC1_BITPLANE_IMODE_TBL)) != VC1_STATUS_OK)
+    if ((status = vc1_DecodeHuffmanOne(ctxt, &bpp->imode,VC1_BITPLANE_IMODE_TBL)) != VC1_STATUS_OK)
     {
         return status;
     }
@@ -531,14 +495,12 @@
                 for (j = 0; j < width; j++)
                 {
                     VC1_GET_BITS(1, tempValue);
-                    put_bit( tempValue, j, i, width, height, bpp->invert,
-                             bpp->databits);
+                    put_bit( tempValue, j, i, width, height, bpp->invert,bpp->databits);
                 }
             }
             else if (bpp->invert) { //TO TEST
                 for (j = 0; j < width; j++) {
-                    put_bit( 0, j, i, width, height, bpp->invert,
-                             bpp->databits);
+                    put_bit( 0, j, i, width, height, bpp->invert, bpp->databits);
                 }
             }
         }
@@ -555,14 +517,12 @@
                 for (j = 0; j < height; j++)
                 {
                     VC1_GET_BITS(1, tempValue);
-                    put_bit( tempValue, i, j, width, height, bpp->invert,
-                             bpp->databits);
+                    put_bit( tempValue, i, j, width, height, bpp->invert, bpp->databits);
                 }
             } 
             else if (bpp->invert) { // fill column with ones
                 for (j = 0; j < height; j++) {
-                    put_bit( 0, i, j, width, height, bpp->invert,
-                             bpp->databits);
+                    put_bit( 0, i, j, width, height, bpp->invert, bpp->databits);
                 }
             }//end for else  
         }
@@ -591,11 +551,12 @@
         {
             wi.vwi_type           =  bpnum;
             wi.data.data_offset   = (char *)pl - (char *)bit_dw; // offset within struct
+
             wi.data.data_payload[0] = pl[0];
             wi.data.data_payload[1] = pl[1];
             pl += 2;
 
-            viddec_pm_append_workitem( ctxt, &wi );
+            viddec_pm_append_workitem( ctxt, &wi, false);
         }
     }
 
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bpic.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bpic.c
index e73cde3..1b702e3 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bpic.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bpic.c
@@ -1,100 +1,100 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.

-//

-//  Description: Parses VC-1 picture layer for progressive B picture in simple

-//  or main profile bitstream.

-//

-*/

-

-#include "vc1parse.h"

-#include "viddec_fw_debug.h"    // For DEB

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses progressive B picture for main

- * profile bitstream.  This parser starts after PTYPE was parsed but stops

- * before parsing of macroblock layer.

- * Table 21 of SMPTE 421M after processing up to PTYPE for B picture.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureHeader_ProgressiveBpicture(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    if ((status = vc1_DecodeHuffmanPair(ctxt, VC1_BFRACTION_TBL,

-        &picLayerHeader->BFRACTION_NUM, &picLayerHeader->BFRACTION_DEN)) !=

-        VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    VC1_GET_BITS9(5, picLayerHeader->PQINDEX);

-    if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (picLayerHeader->PQINDEX <= 8)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->HALFQP);

-    }

-    else picLayerHeader->HALFQP=0;

-

-    if (md->QUANTIZER == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);

-    }

-

-    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-    picLayerHeader->MVMODE = (picLayerHeader->MVMODE == 1) ?

-        VC1_MVMODE_1MV : VC1_MVMODE_HPELBI_1MV;

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-        md->widthMB, md->heightMB, BPP_DIRECTMB)) != VC1_STATUS_OK)

-    {

-        return VC1_STATUS_OK;

-    }

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    VC1_GET_BITS9(2, picLayerHeader->MVTAB);

-    VC1_GET_BITS9(2, picLayerHeader->CBPTAB);

-

-    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (md->VSTRANSFORM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TTMBF);

-        if (picLayerHeader->TTMBF)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->TTFRM);

-        }

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

-

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
+//
+//  Description: Parses VC-1 picture layer for progressive B picture in simple
+//  or main profile bitstream.
+//
+*/
+
+#include "vc1parse.h"
+#include "viddec_fw_debug.h"    // For DEB
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses progressive B picture for main
+ * profile bitstream.  This parser starts after PTYPE was parsed but stops
+ * before parsing of macroblock layer.
+ * Table 21 of SMPTE 421M after processing up to PTYPE for B picture.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureHeader_ProgressiveBpicture(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    if ((status = vc1_DecodeHuffmanPair(ctxt, VC1_BFRACTION_TBL,
+        &picLayerHeader->BFRACTION_NUM, &picLayerHeader->BFRACTION_DEN)) !=
+        VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    VC1_GET_BITS9(5, picLayerHeader->PQINDEX);
+    if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (picLayerHeader->PQINDEX <= 8)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->HALFQP);
+    }
+    else picLayerHeader->HALFQP=0;
+
+    if (md->QUANTIZER == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);
+    }
+
+    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+    picLayerHeader->MVMODE = (picLayerHeader->MVMODE == 1) ?
+        VC1_MVMODE_1MV : VC1_MVMODE_HPELBI_1MV;
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+        md->widthMB, md->heightMB, BPP_DIRECTMB)) != VC1_STATUS_OK)
+    {
+        return VC1_STATUS_OK;
+    }
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    VC1_GET_BITS9(2, picLayerHeader->MVTAB);
+    VC1_GET_BITS9(2, picLayerHeader->CBPTAB);
+
+    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (md->VSTRANSFORM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TTMBF);
+        if (picLayerHeader->TTMBF)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->TTFRM);
+        }
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
+
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bpic_adv.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bpic_adv.c
index 4074309..7a6a8e0 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bpic_adv.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_bpic_adv.c
@@ -1,257 +1,257 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.

-//

-//  Description: Parses VC-1 picture layer for progressive B picture in advanced

-//  profile bitstream.

-//

-*/

-

-#include "vc1parse.h"

-#include "viddec_fw_debug.h"    // For DEB

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses progressive B picture for advanced

- * profile bitstream.

- * Table 22 of SMPTE 421M after processing up to POSTPROC by

- * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureHeader_ProgressiveBpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-    picLayerHeader->MVMODE = (picLayerHeader->MVMODE == 1) ?

-        VC1_MVMODE_1MV : VC1_MVMODE_HPELBI_1MV;

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-        md->widthMB, md->heightMB, BPP_DIRECTMB)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    VC1_GET_BITS9(2, picLayerHeader->MVTAB);

-    VC1_GET_BITS9(2, picLayerHeader->CBPTAB);

-

-    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (md->VSTRANSFORM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TTMBF);

-        if (picLayerHeader->TTMBF == 1)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->TTFRM);

-        }

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses interlace B frame for advanced

- * profile bitstream.

- * Table 84 of SMPTE 421M after processing up to POSTPROC by

- * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureHeader_InterlaceBpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    if ((status = vc1_DecodeHuffmanPair(ctxt, VC1_BFRACTION_TBL,

-                                        &picLayerHeader->BFRACTION_NUM, &picLayerHeader->BFRACTION_DEN)) !=

-        VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if ((status = vc1_DMVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    VC1_GET_BITS9(1, picLayerHeader->INTCOMP);

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-        md->widthMB, md->heightMB, BPP_DIRECTMB)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    // EPC picLayerHeader->MVMODE = VC1_MVMODE_1MV;

-    VC1_GET_BITS9(2, picLayerHeader->MBMODETAB);

-    VC1_GET_BITS9(2, picLayerHeader->MVTAB); /* IMVTAB. */

-    VC1_GET_BITS9(3, picLayerHeader->CBPTAB); /* ICBPTAB. */

-    VC1_GET_BITS9(2, picLayerHeader->MV2BPTAB); /* 2MVBPTAB. */

-    VC1_GET_BITS9(2, picLayerHeader->MV4BPTAB); /* 4MVBPTAB. */

-

-    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (md->VSTRANSFORM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TTMBF);

-        if (picLayerHeader->TTMBF == 1)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->TTFRM);

-        }

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses interlace B field for advanced

- * profile bitstream.

- * Table 89 of SMPTE 421M after processing up to BFRACTION by

- * vc1_ParseFieldHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParseFieldHeader_InterlaceBpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    uint8_t bit_count;

-    const uint8_t *table;

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader* picLayerHeader = &pInfo->picLayerHeader;

-

-    VC1_GET_BITS9(5, picLayerHeader->PQINDEX);

-

-    if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (picLayerHeader->PQINDEX <= 8)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->HALFQP);

-    }

-    else

-        picLayerHeader->HALFQP = 0;

-

-    if (md->QUANTIZER == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);

-        picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;

-    }

-

-    if (md->POSTPROCFLAG == 1)

-    {

-        VC1_GET_BITS9(2, picLayerHeader->POSTPROC);

-    }

-

-    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if ((status = vc1_DMVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (picLayerHeader->PQUANT > 12)

-        table = VC1_MVMODE_LOW_TBL;

-    else

-        table = VC1_MVMODE_HIGH_TBL;

-

-    bit_count = 0;

-    VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-    while ((picLayerHeader->MVMODE == 0) && (bit_count < 2))

-    {

-        VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-        bit_count++;

-    }

-    if ((bit_count == 2) && (picLayerHeader->MVMODE == 0))

-        bit_count++;

-    picLayerHeader->MVMODE = table[bit_count];

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-	md->widthMB, (md->heightMB+1)/2, BPP_FORWARDMB)) !=

-	VC1_STATUS_OK)

-    {

-        return status;

-    } 

-

-    VC1_GET_BITS9(3, picLayerHeader->MBMODETAB);

-    VC1_GET_BITS9(3, picLayerHeader->MVTAB); /* IMVTAB. */

-    VC1_GET_BITS9(3, picLayerHeader->CBPTAB); /* ICBPTAB. */

-

-    if (picLayerHeader->MVMODE == VC1_MVMODE_MIXED_MV)

-    {

-        VC1_GET_BITS9(2, picLayerHeader->MV4BPTAB); /* 4MVBPTAB. */

-    }

-

-    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (md->VSTRANSFORM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TTMBF);

-        if (picLayerHeader->TTMBF == 1)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->TTFRM);

-        }

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
+//
+//  Description: Parses VC-1 picture layer for progressive B picture in advanced
+//  profile bitstream.
+//
+*/
+
+#include "vc1parse.h"
+#include "viddec_fw_debug.h"    // For DEB
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses progressive B picture for advanced
+ * profile bitstream.
+ * Table 22 of SMPTE 421M after processing up to POSTPROC by
+ * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureHeader_ProgressiveBpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+    picLayerHeader->MVMODE = (picLayerHeader->MVMODE == 1) ?
+        VC1_MVMODE_1MV : VC1_MVMODE_HPELBI_1MV;
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+        md->widthMB, md->heightMB, BPP_DIRECTMB)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    VC1_GET_BITS9(2, picLayerHeader->MVTAB);
+    VC1_GET_BITS9(2, picLayerHeader->CBPTAB);
+
+    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (md->VSTRANSFORM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TTMBF);
+        if (picLayerHeader->TTMBF == 1)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->TTFRM);
+        }
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses interlace B frame for advanced
+ * profile bitstream.
+ * Table 84 of SMPTE 421M after processing up to POSTPROC by
+ * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureHeader_InterlaceBpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    if ((status = vc1_DecodeHuffmanPair(ctxt, VC1_BFRACTION_TBL,
+                                        &picLayerHeader->BFRACTION_NUM, &picLayerHeader->BFRACTION_DEN)) !=
+        VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if ((status = vc1_DMVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    VC1_GET_BITS9(1, picLayerHeader->INTCOMP);
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+        md->widthMB, md->heightMB, BPP_DIRECTMB)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    // EPC picLayerHeader->MVMODE = VC1_MVMODE_1MV;
+    VC1_GET_BITS9(2, picLayerHeader->MBMODETAB);
+    VC1_GET_BITS9(2, picLayerHeader->MVTAB); /* IMVTAB. */
+    VC1_GET_BITS9(3, picLayerHeader->CBPTAB); /* ICBPTAB. */
+    VC1_GET_BITS9(2, picLayerHeader->MV2BPTAB); /* 2MVBPTAB. */
+    VC1_GET_BITS9(2, picLayerHeader->MV4BPTAB); /* 4MVBPTAB. */
+
+    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (md->VSTRANSFORM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TTMBF);
+        if (picLayerHeader->TTMBF == 1)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->TTFRM);
+        }
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses interlace B field for advanced
+ * profile bitstream.
+ * Table 89 of SMPTE 421M after processing up to BFRACTION by
+ * vc1_ParseFieldHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParseFieldHeader_InterlaceBpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    uint8_t bit_count;
+    const uint8_t *table;
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader* picLayerHeader = &pInfo->picLayerHeader;
+
+    VC1_GET_BITS9(5, picLayerHeader->PQINDEX);
+
+    if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (picLayerHeader->PQINDEX <= 8)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->HALFQP);
+    }
+    else
+        picLayerHeader->HALFQP = 0;
+
+    if (md->QUANTIZER == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);
+        picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;
+    }
+
+    if (md->POSTPROCFLAG == 1)
+    {
+        VC1_GET_BITS9(2, picLayerHeader->POSTPROC);
+    }
+
+    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if ((status = vc1_DMVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (picLayerHeader->PQUANT > 12)
+        table = VC1_MVMODE_LOW_TBL;
+    else
+        table = VC1_MVMODE_HIGH_TBL;
+
+    bit_count = 0;
+    VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+    while ((picLayerHeader->MVMODE == 0) && (bit_count < 2))
+    {
+        VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+        bit_count++;
+    }
+    if ((bit_count == 2) && (picLayerHeader->MVMODE == 0))
+        bit_count++;
+    picLayerHeader->MVMODE = table[bit_count];
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+	md->widthMB, (md->heightMB+1)/2, BPP_FORWARDMB)) !=
+	VC1_STATUS_OK)
+    {
+        return status;
+    } 
+
+    VC1_GET_BITS9(3, picLayerHeader->MBMODETAB);
+    VC1_GET_BITS9(3, picLayerHeader->MVTAB); /* IMVTAB. */
+    VC1_GET_BITS9(3, picLayerHeader->CBPTAB); /* ICBPTAB. */
+
+    if (picLayerHeader->MVMODE == VC1_MVMODE_MIXED_MV)
+    {
+        VC1_GET_BITS9(2, picLayerHeader->MV4BPTAB); /* 4MVBPTAB. */
+    }
+
+    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (md->VSTRANSFORM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TTMBF);
+        if (picLayerHeader->TTMBF == 1)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->TTFRM);
+        }
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_common_defs.h b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_common_defs.h
index 9e621fc..149e364 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_common_defs.h
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_common_defs.h
@@ -146,12 +146,15 @@
 {
     // From Sequence Layer for Advanced Profile
     uint8_t  PROFILE;                   /**  2 bit(s). */
-#ifdef VBP
-    uint8_t  LEVEL;
-#endif
-    uint8_t  POSTPROCFLAG;              /**  1 bit(s). */
+    uint8_t  LEVEL;                     /**  3 bit(s). */
+    uint8_t  CHROMAFORMAT;              /**  2 bit(s). */
+    uint8_t  FRMRTQ;                    /**  3 bit(s). */
+    
+    uint8_t  BITRTQ;                    /**  5 bit(s). */    
+    uint8_t  POSTPROCFLAG;              /**  1 bit(s). */    
     uint8_t  PULLDOWN;                  /**  1 bit(s). */
     uint8_t  INTERLACE;                 /**  1 bit(s). */
+    
     uint8_t  TFCNTRFLAG;                /**  1 bit(s). */
     uint8_t  FINTERPFLAG;               /**  1 bit(s). */
     uint8_t  PSF;                       /**  1 bit(s). */
@@ -162,18 +165,24 @@
     uint8_t  MULTIRES;                  /**  1 bit(s). */
 
     // From EntryPoint Layer for Advanced Profile
+    uint8_t BROKEN_LINK;
+    uint8_t CLOSED_ENTRY;
+    
     uint8_t PANSCAN_FLAG;
     uint8_t REFDIST_FLAG;
     uint8_t LOOPFILTER;
     uint8_t FASTUVMC;
+    
     uint8_t EXTENDED_MV;
     uint8_t DQUANT;
     uint8_t VSTRANSFORM;
     uint8_t OVERLAP;
+    
     uint8_t QUANTIZER;
     uint8_t EXTENDED_DMV;
     uint8_t RANGE_MAPY_FLAG;
     uint8_t RANGE_MAPY;
+    
     uint8_t RANGE_MAPUV_FLAG;
     uint8_t RANGE_MAPUV;
 
@@ -187,7 +196,9 @@
     uint8_t  INTCOMPFIELD;              /**  ? bit(s)? */
     uint8_t  LUMSCALE2;                 /**  6 bit(s). */
     uint8_t  LUMSHIFT2;                 /**  6 bit(s). */
+    
     uint8_t bp_raw[VC1_MAX_BITPLANE_CHUNKS]; 
+    uint8_t res_1;
 
     // From SequenceLayerHeader, EntryPointHeader or Struct_A
     uint16_t width;
@@ -196,8 +207,6 @@
     uint16_t heightMB;
 
 #ifdef VBP
-    uint8_t CLOSED_ENTRY;
-    uint8_t BROKEN_LINK;
     uint8_t SYNCMARKER;
 #endif
     
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_huffman.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_huffman.c
index c2f5985..5dc9b4d 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_huffman.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_huffman.c
@@ -1,97 +1,97 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.

-//

-//  Description: Parses VLC syntax elements within VC-1 bitstream.

-//

-*/

-

-#include "vc1parse.h"

-

-/*----------------------------------------------------------------------------*/

-

-vc1_Status vc1_DecodeHuffmanOne(void* ctxt, int32_t *pDst, const int32_t *pDecodeTable)

-{

-    uint32_t tempValue;

-    const int32_t *pTable = pDecodeTable;

-    vc1_Status status = VC1_STATUS_OK;

-    int32_t i, j, maxBits, loopCount, totalBits, value;

-

-    maxBits = *pTable++;

-    loopCount = *pTable++;

-    totalBits = 0;

-    for (i = 0; i < loopCount; i++)

-        totalBits += *pTable++;

-

-    if (totalBits != maxBits)

-        return VC1_STATUS_PARSE_ERROR;

-

-    value = 0;

-    for (i = 0; i < maxBits; i++)

-    {

-        VC1_GET_BITS9(1, tempValue);

-        value = (value << 1) | tempValue;

-        loopCount = *pTable++;

-        if (loopCount == -1)

-            break;

-        for (j = 0; j < loopCount; j++)

-        {

-            if (value == *pTable++)

-            {

-                *pDst = *pTable;

-                return status;

-            }

-            else

-                pTable++;

-        }

-    }

-

-    return status;

-}

-

-/*----------------------------------------------------------------------------*/

-

-vc1_Status vc1_DecodeHuffmanPair(void* ctxt, const int32_t *pDecodeTable,

-                                 int8_t *pFirst, int16_t *pSecond)

-{

-    uint32_t tempValue;

-    const int32_t *pTable = pDecodeTable;

-    vc1_Status status = VC1_STATUS_OK;

-    int32_t i, j, maxBits, loopCount, totalBits, value;

-

-    maxBits = *pTable++;

-    loopCount = *pTable++;

-    totalBits = 0;

-    for (i = 0; i < loopCount; i++)

-        totalBits += *pTable++;

-

-    if (totalBits != maxBits)

-        return VC1_STATUS_PARSE_ERROR;

-

-    value = 0;

-    for (i = 0; i < maxBits; i++)

-    {

-        VC1_GET_BITS9(1, tempValue);

-        value = (value << 1) | tempValue;

-        loopCount = *pTable++;

-        if (loopCount == -1)

-            break;

-        for (j = 0; j < loopCount; j++)

-        {

-            if (value == *pTable++)

-            {

-                *pFirst = *pTable++;

-                *pSecond = *pTable;

-                return status;

-            }

-            else

-                pTable += 2;

-        }

-    }

-

-    return status;

-}

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
+//
+//  Description: Parses VLC syntax elements within VC-1 bitstream.
+//
+*/
+
+#include "vc1parse.h"
+
+/*----------------------------------------------------------------------------*/
+
+vc1_Status vc1_DecodeHuffmanOne(void* ctxt, int32_t *pDst, const int32_t *pDecodeTable)
+{
+    uint32_t tempValue;
+    const int32_t *pTable = pDecodeTable;
+    vc1_Status status = VC1_STATUS_OK;
+    int32_t i, j, maxBits, loopCount, totalBits, value;
+
+    maxBits = *pTable++;
+    loopCount = *pTable++;
+    totalBits = 0;
+    for (i = 0; i < loopCount; i++)
+        totalBits += *pTable++;
+
+    if (totalBits != maxBits)
+        return VC1_STATUS_PARSE_ERROR;
+
+    value = 0;
+    for (i = 0; i < maxBits; i++)
+    {
+        VC1_GET_BITS9(1, tempValue);
+        value = (value << 1) | tempValue;
+        loopCount = *pTable++;
+        if (loopCount == -1)
+            break;
+        for (j = 0; j < loopCount; j++)
+        {
+            if (value == *pTable++)
+            {
+                *pDst = *pTable;
+                return status;
+            }
+            else
+                pTable++;
+        }
+    }
+
+    return status;
+}
+
+/*----------------------------------------------------------------------------*/
+
+vc1_Status vc1_DecodeHuffmanPair(void* ctxt, const int32_t *pDecodeTable,
+                                 int8_t *pFirst, int16_t *pSecond)
+{
+    uint32_t tempValue;
+    const int32_t *pTable = pDecodeTable;
+    vc1_Status status = VC1_STATUS_OK;
+    int32_t i, j, maxBits, loopCount, totalBits, value;
+
+    maxBits = *pTable++;
+    loopCount = *pTable++;
+    totalBits = 0;
+    for (i = 0; i < loopCount; i++)
+        totalBits += *pTable++;
+
+    if (totalBits != maxBits)
+        return VC1_STATUS_PARSE_ERROR;
+
+    value = 0;
+    for (i = 0; i < maxBits; i++)
+    {
+        VC1_GET_BITS9(1, tempValue);
+        value = (value << 1) | tempValue;
+        loopCount = *pTable++;
+        if (loopCount == -1)
+            break;
+        for (j = 0; j < loopCount; j++)
+        {
+            if (value == *pTable++)
+            {
+                *pFirst = *pTable++;
+                *pSecond = *pTable;
+                return status;
+            }
+            else
+                pTable += 2;
+        }
+    }
+
+    return status;
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ipic_adv.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ipic_adv.c
index 03aeb79..e478250 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ipic_adv.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ipic_adv.c
@@ -1,257 +1,257 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.

-//

-//  Description: Parses VC-1 picture layer for progressive I or BI picture in

-//  advanced profile bitstream.

-//

-*/

-

-#include "vc1parse.h"

-#include "viddec_fw_debug.h"

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses progressive I or BI picture for

- * advanced profile bitstream.

- * Table 18 of SMPTE 421M after processing up to POSTPROC by

- * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureHeader_ProgressiveIpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-        md->widthMB, md->heightMB, BPP_ACPRED)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))

-    {

-        VC1_GET_BITS9(1, picLayerHeader->CONDOVER);

-        if (picLayerHeader->CONDOVER)

-        {

-            VC1_GET_BITS9(1, picLayerHeader->CONDOVER);

-            if (! picLayerHeader->CONDOVER)

-                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;

-            else

-            {

-                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;

-                if ((status = vc1_DecodeBitplane(ctxt, pInfo,

-                    md->widthMB,

-                    md->heightMB, BPP_OVERFLAGS)) != VC1_STATUS_OK)

-                {

-                    return status;

-                }

-            }

-        }

-        else

-            picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);

-    if (picLayerHeader->TRANSACFRM2)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);

-        picLayerHeader->TRANSACFRM2 += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    status = vc1_VOPDQuant(ctxt, pInfo);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses interlace I or BI frame for

- * advanced profile bitstream.

- * Table 82 of SMPTE 421M after processing up to POSTPROC by

- * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo,

-        md->widthMB, md->heightMB, BPP_FIELDTX)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo,

-        md->widthMB, md->heightMB, BPP_ACPRED)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))

-    {

-        VC1_GET_BITS9(1, picLayerHeader->CONDOVER);

-        if (picLayerHeader->CONDOVER)

-        {

-            VC1_GET_BITS9(1, picLayerHeader->CONDOVER);

-            if (! picLayerHeader->CONDOVER)

-                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;

-            else

-            {

-                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;

-                if ((status = vc1_DecodeBitplane(ctxt, pInfo,

-                    md->widthMB,

-                    md->heightMB, BPP_OVERFLAGS)) != VC1_STATUS_OK)

-                {

-                    return status;

-                }

-            }

-        }

-        else

-            picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);

-    if (picLayerHeader->TRANSACFRM2)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);

-        picLayerHeader->TRANSACFRM2 += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    status = vc1_VOPDQuant(ctxt, pInfo);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses interlace I or BI field for

- * advanced profile bitstream.

- * Table 87 of SMPTE 421M after processing up to BFRACTION by

- * vc1_ParseFieldHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParseFieldHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    uint32_t tempValue;

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    // Reset MVMODE when the second field is an I picture

-    // to avoid carrying forward the mvmode values from previous field

-    // especially the intensity compensation value

-    picLayerHeader->MVMODE = 0;

-    

-    VC1_GET_BITS9(5, picLayerHeader->PQINDEX);

-    if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK) {

-        DEB("Error parsing I field \n");

-        return status;

-    }

-  

-    if (picLayerHeader->PQINDEX <= 8)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->HALFQP);

-    }

-    else

-        picLayerHeader->HALFQP = 0;

-

-    if (md->QUANTIZER == 1) {

-        VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);

-        picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;

-    }

-

-    if (md->POSTPROCFLAG == 1)

-        VC1_GET_BITS9(2, tempValue); /* POSTPROC. */

-    

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 

-    md->widthMB, (md->heightMB+1)/2, BPP_ACPRED)) !=

-    VC1_STATUS_OK)

-    {

-        DEB("Error parsing I field \n");

-        return status;

-    }  

-

-    if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))

-    {

-        VC1_GET_BITS9(1, picLayerHeader->CONDOVER);

-        if (picLayerHeader->CONDOVER)

-        {

-            VC1_GET_BITS9(1, picLayerHeader->CONDOVER);

-            if (! picLayerHeader->CONDOVER)

-                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;

-            else

-            {

-                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;

-                

-		if ((status = vc1_DecodeBitplane(ctxt, pInfo,

-		    md->widthMB,

-		    (md->heightMB+1)/2, BPP_OVERFLAGS)) !=

-		    VC1_STATUS_OK)

-		{

-		    DEB("Error parsing I field \n");

-		    return status;

-		}

-            }

-        }

-        else

-            picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);

-    if (picLayerHeader->TRANSACFRM2)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);

-        picLayerHeader->TRANSACFRM2 += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    status = vc1_VOPDQuant(ctxt, pInfo);

-    if (status != VC1_STATUS_OK) {

-        DEB("Error parsing I field \n");

-        return status;

-    }

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
+//
+//  Description: Parses VC-1 picture layer for progressive I or BI picture in
+//  advanced profile bitstream.
+//
+*/
+
+#include "vc1parse.h"
+#include "viddec_fw_debug.h"
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses progressive I or BI picture for
+ * advanced profile bitstream.
+ * Table 18 of SMPTE 421M after processing up to POSTPROC by
+ * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureHeader_ProgressiveIpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+        md->widthMB, md->heightMB, BPP_ACPRED)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))
+    {
+        VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
+        if (picLayerHeader->CONDOVER)
+        {
+            VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
+            if (! picLayerHeader->CONDOVER)
+                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;
+            else
+            {
+                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;
+                if ((status = vc1_DecodeBitplane(ctxt, pInfo,
+                    md->widthMB,
+                    md->heightMB, BPP_OVERFLAGS)) != VC1_STATUS_OK)
+                {
+                    return status;
+                }
+            }
+        }
+        else
+            picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
+    if (picLayerHeader->TRANSACFRM2)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
+        picLayerHeader->TRANSACFRM2 += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    status = vc1_VOPDQuant(ctxt, pInfo);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses interlace I or BI frame for
+ * advanced profile bitstream.
+ * Table 82 of SMPTE 421M after processing up to POSTPROC by
+ * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo,
+        md->widthMB, md->heightMB, BPP_FIELDTX)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo,
+        md->widthMB, md->heightMB, BPP_ACPRED)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))
+    {
+        VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
+        if (picLayerHeader->CONDOVER)
+        {
+            VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
+            if (! picLayerHeader->CONDOVER)
+                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;
+            else
+            {
+                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;
+                if ((status = vc1_DecodeBitplane(ctxt, pInfo,
+                    md->widthMB,
+                    md->heightMB, BPP_OVERFLAGS)) != VC1_STATUS_OK)
+                {
+                    return status;
+                }
+            }
+        }
+        else
+            picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
+    if (picLayerHeader->TRANSACFRM2)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
+        picLayerHeader->TRANSACFRM2 += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    status = vc1_VOPDQuant(ctxt, pInfo);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses interlace I or BI field for
+ * advanced profile bitstream.
+ * Table 87 of SMPTE 421M after processing up to BFRACTION by
+ * vc1_ParseFieldHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParseFieldHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    uint32_t tempValue;
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    // Reset MVMODE when the second field is an I picture
+    // to avoid carrying forward the mvmode values from previous field
+    // especially the intensity compensation value
+    picLayerHeader->MVMODE = 0;
+    
+    VC1_GET_BITS9(5, picLayerHeader->PQINDEX);
+    if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK) {
+        DEB("Error parsing I field \n");
+        return status;
+    }
+  
+    if (picLayerHeader->PQINDEX <= 8)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->HALFQP);
+    }
+    else
+        picLayerHeader->HALFQP = 0;
+
+    if (md->QUANTIZER == 1) {
+        VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);
+        picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;
+    }
+
+    if (md->POSTPROCFLAG == 1)
+        VC1_GET_BITS9(2, tempValue); /* POSTPROC. */
+    
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo, 
+    md->widthMB, (md->heightMB+1)/2, BPP_ACPRED)) !=
+    VC1_STATUS_OK)
+    {
+        DEB("Error parsing I field \n");
+        return status;
+    }  
+
+    if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))
+    {
+        VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
+        if (picLayerHeader->CONDOVER)
+        {
+            VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
+            if (! picLayerHeader->CONDOVER)
+                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;
+            else
+            {
+                picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;
+                
+		if ((status = vc1_DecodeBitplane(ctxt, pInfo,
+		    md->widthMB,
+		    (md->heightMB+1)/2, BPP_OVERFLAGS)) !=
+		    VC1_STATUS_OK)
+		{
+		    DEB("Error parsing I field \n");
+		    return status;
+		}
+            }
+        }
+        else
+            picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
+    if (picLayerHeader->TRANSACFRM2)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
+        picLayerHeader->TRANSACFRM2 += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    status = vc1_VOPDQuant(ctxt, pInfo);
+    if (status != VC1_STATUS_OK) {
+        DEB("Error parsing I field \n");
+        return status;
+    }
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_mv_com.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_mv_com.c
index 7cbcc34..55373b4 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_mv_com.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_mv_com.c
@@ -1,82 +1,82 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.

-//

-//  Description: Parses VC-1 syntax elements MVRANGE and DMVRANGE.

-//

-*/

-

-#include "vc1parse.h"

-

-/*------------------------------------------------------------------------------

- * Parse syntax element MVRANGE, which exists for main and advanced profiles.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_MVRangeDecode(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    if (md->EXTENDED_MV == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->MVRANGE);

-        if (picLayerHeader->MVRANGE)

-        {

-            VC1_GET_BITS9(1, picLayerHeader->MVRANGE);

-            if (picLayerHeader->MVRANGE)

-            {

-                VC1_GET_BITS9(1, picLayerHeader->MVRANGE);

-                picLayerHeader->MVRANGE += 1;

-            }

-            picLayerHeader->MVRANGE += 1;

-        }

-    }

-    else

-        picLayerHeader->MVRANGE = 0;

-

-    return status;

-}

-

-/*------------------------------------------------------------------------------

- * Parse syntax element DMVRANGE.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_DMVRangeDecode(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    if (md->EXTENDED_DMV == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->DMVRANGE);

-        if (picLayerHeader->DMVRANGE == 0)

-            picLayerHeader->DMVRANGE = VC1_DMVRANGE_NONE;

-        else

-        {

-            VC1_GET_BITS9(1, picLayerHeader->DMVRANGE);

-            if (picLayerHeader->DMVRANGE == 0)

-                picLayerHeader->DMVRANGE = VC1_DMVRANGE_HORIZONTAL_RANGE;

-            else

-            {

-                VC1_GET_BITS9(1, picLayerHeader->DMVRANGE);

-                if (picLayerHeader->DMVRANGE == 0)

-                    picLayerHeader->DMVRANGE = VC1_DMVRANGE_VERTICAL_RANGE;

-                else

-                {

-                    picLayerHeader->DMVRANGE =

-                        VC1_DMVRANGE_HORIZONTAL_VERTICAL_RANGE;

-                }

-            }

-        }

-    }

-

-    return status;

-}

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
+//
+//  Description: Parses VC-1 syntax elements MVRANGE and DMVRANGE.
+//
+*/
+
+#include "vc1parse.h"
+
+/*------------------------------------------------------------------------------
+ * Parse syntax element MVRANGE, which exists for main and advanced profiles.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_MVRangeDecode(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    if (md->EXTENDED_MV == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->MVRANGE);
+        if (picLayerHeader->MVRANGE)
+        {
+            VC1_GET_BITS9(1, picLayerHeader->MVRANGE);
+            if (picLayerHeader->MVRANGE)
+            {
+                VC1_GET_BITS9(1, picLayerHeader->MVRANGE);
+                picLayerHeader->MVRANGE += 1;
+            }
+            picLayerHeader->MVRANGE += 1;
+        }
+    }
+    else
+        picLayerHeader->MVRANGE = 0;
+
+    return status;
+}
+
+/*------------------------------------------------------------------------------
+ * Parse syntax element DMVRANGE.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_DMVRangeDecode(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    if (md->EXTENDED_DMV == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->DMVRANGE);
+        if (picLayerHeader->DMVRANGE == 0)
+            picLayerHeader->DMVRANGE = VC1_DMVRANGE_NONE;
+        else
+        {
+            VC1_GET_BITS9(1, picLayerHeader->DMVRANGE);
+            if (picLayerHeader->DMVRANGE == 0)
+                picLayerHeader->DMVRANGE = VC1_DMVRANGE_HORIZONTAL_RANGE;
+            else
+            {
+                VC1_GET_BITS9(1, picLayerHeader->DMVRANGE);
+                if (picLayerHeader->DMVRANGE == 0)
+                    picLayerHeader->DMVRANGE = VC1_DMVRANGE_VERTICAL_RANGE;
+                else
+                {
+                    picLayerHeader->DMVRANGE =
+                        VC1_DMVRANGE_HORIZONTAL_VERTICAL_RANGE;
+                }
+            }
+        }
+    }
+
+    return status;
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_pic_com_adv.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_pic_com_adv.c
index fa9c3c7..2b1c75a 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_pic_com_adv.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_pic_com_adv.c
@@ -1,403 +1,405 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.

-//

-//  Description: Parses VC-1 picture layer for advanced profile.

-//

-*/

-

-#include "vc1parse.h"

-#include "viddec_fw_debug.h"

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses the picture header for advanced

- * profile down to POSTPROC syntax element.

- * Table 18 of SMPTE 421M for progressive I or BI picture.

- * Table 20 of SMPTE 421M for progressive P picture.

- * Table 22 of SMPTE 421M for progressive B picture.

- * Table 23 of SMPTE 421M for skipped picture.

- * Table 82 of SMPTE 421M for interlace I or BI frame.

- * Table 83 of SMPTE 421M for interlace P frame.

- * Table 84 of SMPTE 421M for interlace B frame.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureHeader_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    uint32_t i = 0;

-    uint32_t tempValue;

-    vc1_Status status = VC1_STATUS_OK;

-    uint32_t number_of_pan_scan_window;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    if (md->INTERLACE == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->FCM);

-        if (picLayerHeader->FCM)

-        {

-            VC1_GET_BITS9(1, picLayerHeader->FCM);

-            if (picLayerHeader->FCM)

-            {

-                picLayerHeader->FCM = VC1_FCM_FIELD_INTERLACE;

-                return VC1_STATUS_PARSE_ERROR;

-            }

-            else

-                picLayerHeader->FCM = VC1_FCM_FRAME_INTERLACE;

-        }

-        else

-            picLayerHeader->FCM = VC1_FCM_PROGRESSIVE;

-    }

-    else

-        picLayerHeader->FCM = VC1_FCM_PROGRESSIVE;

-

-

-    VC1_GET_BITS9(1, picLayerHeader->PTYPE);

-    if (picLayerHeader->PTYPE)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->PTYPE);

-        if (picLayerHeader->PTYPE)

-        {

-            VC1_GET_BITS9(1, picLayerHeader->PTYPE);

-            if (picLayerHeader->PTYPE)

-            {

-                VC1_GET_BITS9(1, picLayerHeader->PTYPE);

-                if (picLayerHeader->PTYPE)

-                    picLayerHeader->PTYPE = VC1_SKIPPED_FRAME;

-                else

-                    picLayerHeader->PTYPE = VC1_BI_FRAME;

-            }

-            else

-                picLayerHeader->PTYPE = VC1_I_FRAME;

-        }

-        else

-            picLayerHeader->PTYPE = VC1_B_FRAME;

-    }

-    else

-        picLayerHeader->PTYPE = VC1_P_FRAME;

-

-    if (picLayerHeader->PTYPE != VC1_SKIPPED_FRAME)

-    {

-        if (md->TFCNTRFLAG)

-        {

-            VC1_GET_BITS9(8, picLayerHeader->TFCNTR); /* TFCNTR. */

-        }

-    }

-

-    if (md->PULLDOWN)

-    {

-        if ((md->INTERLACE == 0) || (md->PSF == 1))

-        {

-            VC1_GET_BITS9(2, picLayerHeader->RPTFRM);

-        }

-        else

-        {

-            VC1_GET_BITS9(1, picLayerHeader->TFF);

-            VC1_GET_BITS9(1, picLayerHeader->RFF);

-        }

-    }

-

-    if (md->PANSCAN_FLAG == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->PS_PRESENT); /* PS_PRESENT. */

-        if (picLayerHeader->PS_PRESENT == 1)

-        {

-            if ((md->INTERLACE == 1) &&

-                (md->PSF == 0))

-            {

-                if (md->PULLDOWN == 1)

-                    number_of_pan_scan_window = 2 + picLayerHeader->RFF;

-                else

-                    number_of_pan_scan_window = 2;

-            }

-            else

-            {

-                if (md->PULLDOWN == 1)

-                    number_of_pan_scan_window = 1 + picLayerHeader->RPTFRM;

-                else

-                    number_of_pan_scan_window = 1;

-            }

-            picLayerHeader->number_of_pan_scan_window = number_of_pan_scan_window;

-

-            for (i = 0; i < number_of_pan_scan_window; i++)

-            {

-                VC1_GET_BITS(18, picLayerHeader->PAN_SCAN_WINDOW[i].hoffset); /* PS_HOFFSET. */

-                VC1_GET_BITS(18, picLayerHeader->PAN_SCAN_WINDOW[i].voffset); /* PS_VOFFSET. */

-                VC1_GET_BITS(14, picLayerHeader->PAN_SCAN_WINDOW[i].width); /* PS_WIDTH. */

-                VC1_GET_BITS(14, picLayerHeader->PAN_SCAN_WINDOW[i].height); /* PS_HEIGHT. */

-            }

-        }

-    }

-

-    if (picLayerHeader->PTYPE != VC1_SKIPPED_FRAME)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->RNDCTRL);

-        md->RNDCTRL =  picLayerHeader->RNDCTRL;

-

-        if ((md->INTERLACE == 1) ||

-            (picLayerHeader->FCM != VC1_FCM_PROGRESSIVE))

-        {

-            VC1_GET_BITS9(1, picLayerHeader->UVSAMP);

-        }

-

-        if ((md->FINTERPFLAG == 1) &&

-            (picLayerHeader->FCM == VC1_FCM_PROGRESSIVE))

-        {

-            VC1_GET_BITS9(1, tempValue); /* INTERPFRM. */

-        }

-

-        if ((picLayerHeader->PTYPE == VC1_B_FRAME) &&

-            (picLayerHeader->FCM == VC1_FCM_PROGRESSIVE))

-        {

-            if ((status = vc1_DecodeHuffmanPair(ctxt, VC1_BFRACTION_TBL,

-                                                &picLayerHeader->BFRACTION_NUM, &picLayerHeader->BFRACTION_DEN))

-                != VC1_STATUS_OK)

-            {

-                return status;

-            }

-        }

-

-        VC1_GET_BITS9(5, picLayerHeader->PQINDEX);

-        if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK)

-            return status;

-

-        if (picLayerHeader->PQINDEX <= 8)

-        {

-            VC1_GET_BITS9(1, picLayerHeader->HALFQP);

-        }

-        else

-            picLayerHeader->HALFQP = 0;

-

-        if (md->QUANTIZER == 1)

-        {

-            VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);

-            picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;

-        }

-

-        if (md->POSTPROCFLAG == 1)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->POSTPROC);

-        }

-    }

-

-    return vc1_ParsePictureFieldHeader_Adv(ctxt, pInfo);

-}

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses the picture header for advanced

- * profile down to BFRACTION syntax element.

- * Table 85 of SMPTE 421M.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParseFieldHeader_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    uint32_t i = 0;

-    vc1_Status status = VC1_STATUS_OK;

-    uint32_t number_of_pan_scan_window;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    VC1_GET_BITS9(1, picLayerHeader->FCM);

-    if (picLayerHeader->FCM)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->FCM);

-        if (picLayerHeader->FCM)

-            picLayerHeader->FCM = VC1_FCM_FIELD_INTERLACE;

-        else

-            picLayerHeader->FCM = VC1_FCM_FRAME_INTERLACE;

-    }

-    else

-        picLayerHeader->FCM = VC1_FCM_PROGRESSIVE;

-    if (picLayerHeader->FCM != VC1_FCM_FIELD_INTERLACE)

-        return VC1_STATUS_PARSE_ERROR;

-

-    VC1_GET_BITS9(3, picLayerHeader->FPTYPE);

-    if (picLayerHeader->FPTYPE == 0)

-    {

-        picLayerHeader->PTypeField1 = VC1_I_FRAME;

-        picLayerHeader->PTypeField2 = VC1_I_FRAME;

-    }

-    else if (picLayerHeader->FPTYPE == 1)

-    {

-        picLayerHeader->PTypeField1 = VC1_I_FRAME;

-        picLayerHeader->PTypeField2 = VC1_P_FRAME;

-    }

-    else if (picLayerHeader->FPTYPE == 2)

-    {

-        picLayerHeader->PTypeField1 = VC1_P_FRAME;

-        picLayerHeader->PTypeField2 = VC1_I_FRAME;

-    }

-    else if (picLayerHeader->FPTYPE == 3)

-    {

-        picLayerHeader->PTypeField1 = VC1_P_FRAME;

-        picLayerHeader->PTypeField2 = VC1_P_FRAME;

-    }

-    else if (picLayerHeader->FPTYPE == 4)

-    {

-        picLayerHeader->PTypeField1 = VC1_B_FRAME;

-        picLayerHeader->PTypeField2 = VC1_B_FRAME;

-    }

-    else if (picLayerHeader->FPTYPE == 5)

-    {

-        picLayerHeader->PTypeField1 = VC1_B_FRAME;

-        picLayerHeader->PTypeField2 = VC1_BI_FRAME;

-    }

-    else if (picLayerHeader->FPTYPE == 6)

-    {

-        picLayerHeader->PTypeField1 = VC1_BI_FRAME;

-        picLayerHeader->PTypeField2 = VC1_B_FRAME;

-    }

-    else if (picLayerHeader->FPTYPE == 7)

-    {

-        picLayerHeader->PTypeField1 = VC1_BI_FRAME;

-        picLayerHeader->PTypeField2 = VC1_BI_FRAME;

-    }

-

-    if (md->TFCNTRFLAG)

-    {

-        VC1_GET_BITS9(8, picLayerHeader->TFCNTR); 

-    }

-

-    if (md->PULLDOWN == 1)

-    {

-        if (md->PSF == 1)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->RPTFRM); 

-        }

-        else

-        {

-            VC1_GET_BITS9(1, picLayerHeader->TFF);

-            VC1_GET_BITS9(1, picLayerHeader->RFF);

-        }

-    } else

-        picLayerHeader->TFF = 1;

-

-    if (md->PANSCAN_FLAG == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->PS_PRESENT); 

-        if (picLayerHeader->PS_PRESENT)

-        {

-            if (md->PULLDOWN)

-                number_of_pan_scan_window = 2 + picLayerHeader->RFF;

-            else

-                number_of_pan_scan_window = 2;

-            picLayerHeader->number_of_pan_scan_window =number_of_pan_scan_window;

-

-            for (i = 0; i < number_of_pan_scan_window; i++)

-            {

-                VC1_GET_BITS(18, picLayerHeader->PAN_SCAN_WINDOW[i].hoffset); /* PS_HOFFSET. */

-                VC1_GET_BITS(18, picLayerHeader->PAN_SCAN_WINDOW[i].voffset); /* PS_VOFFSET. */

-                VC1_GET_BITS(14, picLayerHeader->PAN_SCAN_WINDOW[i].width); /* PS_WIDTH. */

-                VC1_GET_BITS(14, picLayerHeader->PAN_SCAN_WINDOW[i].height); /* PS_HEIGHT. */

-            }

-        }

-    }

-    VC1_GET_BITS9(1, md->RNDCTRL);

-

-#ifdef VBP

-	picLayerHeader->RNDCTRL = md->RNDCTRL;

-#endif

-    

-    VC1_GET_BITS9(1, picLayerHeader->UVSAMP);

-

-    if ((md->REFDIST_FLAG == 1) && (picLayerHeader->FPTYPE <= 3))

-    {

-        int32_t tmp;

-        if ((status = vc1_DecodeHuffmanOne(ctxt, &tmp,

-                                           VC1_REFDIST_TBL)) != VC1_STATUS_OK)

-        {

-            return status;

-        }

-        md->REFDIST = tmp;

-    }

-

-    if ((picLayerHeader->FPTYPE >= 4) && (picLayerHeader->FPTYPE <= 7))

-    {

-        if ((status = vc1_DecodeHuffmanPair(ctxt, VC1_BFRACTION_TBL,

-                                            &picLayerHeader->BFRACTION_NUM, &picLayerHeader->BFRACTION_DEN)) !=

-            VC1_STATUS_OK)

-        {

-            return status;

-        }

-    }

-

-    if (picLayerHeader->CurrField == 0)

-    {

-        picLayerHeader->PTYPE = picLayerHeader->PTypeField1;

-        picLayerHeader->BottomField = (uint8_t) (1 - picLayerHeader->TFF);

-    }

-    else

-    {

-        picLayerHeader->BottomField = (uint8_t) (picLayerHeader->TFF);

-        picLayerHeader->PTYPE = picLayerHeader->PTypeField2;

-    }

-

-    return vc1_ParsePictureFieldHeader_Adv(ctxt, pInfo);

-}

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function calls the appropriate function to further

- * parse the picture header for advanced profile down to macroblock layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureFieldHeader_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_PARSE_ERROR;

-

-    if (pInfo->picLayerHeader.FCM == VC1_FCM_PROGRESSIVE)

-    {

-        if ((pInfo->picLayerHeader.PTYPE == VC1_I_FRAME) ||

-            (pInfo->picLayerHeader.PTYPE == VC1_BI_FRAME))

-        {

-            status = vc1_ParsePictureHeader_ProgressiveIpicture_Adv(ctxt, pInfo);

-        }

-        else if (pInfo->picLayerHeader.PTYPE == VC1_P_FRAME)

-            status = vc1_ParsePictureHeader_ProgressivePpicture_Adv(ctxt, pInfo);

-        else if (pInfo->picLayerHeader.PTYPE == VC1_B_FRAME)

-            status = vc1_ParsePictureHeader_ProgressiveBpicture_Adv(ctxt, pInfo);

-        else if (pInfo->picLayerHeader.PTYPE == VC1_SKIPPED_FRAME)

-            status = VC1_STATUS_OK;

-    }

-    else if (pInfo->picLayerHeader.FCM == VC1_FCM_FRAME_INTERLACE)

-    {

-        if ((pInfo->picLayerHeader.PTYPE == VC1_I_FRAME) ||

-            (pInfo->picLayerHeader.PTYPE == VC1_BI_FRAME))

-        {

-            status = vc1_ParsePictureHeader_InterlaceIpicture_Adv(ctxt, pInfo);

-        }

-        else if (pInfo->picLayerHeader.PTYPE == VC1_P_FRAME)

-            status = vc1_ParsePictureHeader_InterlacePpicture_Adv(ctxt, pInfo);

-        else if (pInfo->picLayerHeader.PTYPE == VC1_B_FRAME)

-            status = vc1_ParsePictureHeader_InterlaceBpicture_Adv(ctxt, pInfo);

-        else if (pInfo->picLayerHeader.PTYPE == VC1_SKIPPED_FRAME)

-            status = VC1_STATUS_OK;

-    }

-    else if (pInfo->picLayerHeader.FCM == VC1_FCM_FIELD_INTERLACE)

-    {

-        int ptype;

-        if( pInfo->picLayerHeader.CurrField == 0)

-            ptype = pInfo->picLayerHeader.PTypeField1;

-        else

-            ptype = pInfo->picLayerHeader.PTypeField2;

-

-        if ((ptype == VC1_I_FRAME) ||

-            (ptype == VC1_BI_FRAME))

-        {

-            status = vc1_ParseFieldHeader_InterlaceIpicture_Adv(ctxt, pInfo);

-        }

-        else if (ptype == VC1_P_FRAME)

-            status = vc1_ParseFieldHeader_InterlacePpicture_Adv(ctxt, pInfo);

-        else if (ptype == VC1_B_FRAME)

-            status = vc1_ParseFieldHeader_InterlaceBpicture_Adv(ctxt, pInfo);

-        else if (ptype == VC1_SKIPPED_FRAME)

-            status = VC1_STATUS_OK;

-    }

-

-    return status;

-}

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
+//
+//  Description: Parses VC-1 picture layer for advanced profile.
+//
+*/
+
+#include "vc1parse.h"
+#include "viddec_fw_debug.h"
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses the picture header for advanced
+ * profile down to POSTPROC syntax element.
+ * Table 18 of SMPTE 421M for progressive I or BI picture.
+ * Table 20 of SMPTE 421M for progressive P picture.
+ * Table 22 of SMPTE 421M for progressive B picture.
+ * Table 23 of SMPTE 421M for skipped picture.
+ * Table 82 of SMPTE 421M for interlace I or BI frame.
+ * Table 83 of SMPTE 421M for interlace P frame.
+ * Table 84 of SMPTE 421M for interlace B frame.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureHeader_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    uint32_t i = 0;
+    uint32_t tempValue;
+    vc1_Status status = VC1_STATUS_OK;
+    uint32_t number_of_pan_scan_window;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    if (md->INTERLACE == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->FCM);
+        if (picLayerHeader->FCM)
+        {
+            VC1_GET_BITS9(1, picLayerHeader->FCM);
+            if (picLayerHeader->FCM)
+            {
+                picLayerHeader->FCM = VC1_FCM_FIELD_INTERLACE;
+                return VC1_STATUS_PARSE_ERROR;
+            }
+            else
+                picLayerHeader->FCM = VC1_FCM_FRAME_INTERLACE;
+        }
+        else
+            picLayerHeader->FCM = VC1_FCM_PROGRESSIVE;
+    }
+    else
+        picLayerHeader->FCM = VC1_FCM_PROGRESSIVE;
+
+
+    VC1_GET_BITS9(1, picLayerHeader->PTYPE);
+    if (picLayerHeader->PTYPE)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->PTYPE);
+        if (picLayerHeader->PTYPE)
+        {
+            VC1_GET_BITS9(1, picLayerHeader->PTYPE);
+            if (picLayerHeader->PTYPE)
+            {
+                VC1_GET_BITS9(1, picLayerHeader->PTYPE);
+                if (picLayerHeader->PTYPE)
+                    picLayerHeader->PTYPE = VC1_SKIPPED_FRAME;
+                else
+                    picLayerHeader->PTYPE = VC1_BI_FRAME;
+            }
+            else
+                picLayerHeader->PTYPE = VC1_I_FRAME;
+        }
+        else
+            picLayerHeader->PTYPE = VC1_B_FRAME;
+    }
+    else
+        picLayerHeader->PTYPE = VC1_P_FRAME;
+
+    if (picLayerHeader->PTYPE != VC1_SKIPPED_FRAME)
+    {
+        if (md->TFCNTRFLAG)
+        {
+            VC1_GET_BITS9(8, picLayerHeader->TFCNTR); /* TFCNTR. */
+        }
+    }
+
+    if (md->PULLDOWN)
+    {
+        if ((md->INTERLACE == 0) || (md->PSF == 1))
+        {
+            VC1_GET_BITS9(2, picLayerHeader->RPTFRM);
+        }
+        else
+        {
+            VC1_GET_BITS9(1, picLayerHeader->TFF);
+            VC1_GET_BITS9(1, picLayerHeader->RFF);
+        }
+    }
+
+    if (md->PANSCAN_FLAG == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->PS_PRESENT); /* PS_PRESENT. */
+        if (picLayerHeader->PS_PRESENT == 1)
+        {
+            if ((md->INTERLACE == 1) &&
+                (md->PSF == 0))
+            {
+                if (md->PULLDOWN == 1)
+                    number_of_pan_scan_window = 2 + picLayerHeader->RFF;
+                else
+                    number_of_pan_scan_window = 2;
+            }
+            else
+            {
+                if (md->PULLDOWN == 1)
+                    number_of_pan_scan_window = 1 + picLayerHeader->RPTFRM;
+                else
+                    number_of_pan_scan_window = 1;
+            }
+            picLayerHeader->number_of_pan_scan_window = number_of_pan_scan_window;
+
+            for (i = 0; i < number_of_pan_scan_window; i++)
+            {
+                VC1_GET_BITS(18, picLayerHeader->PAN_SCAN_WINDOW[i].hoffset); /* PS_HOFFSET. */
+                VC1_GET_BITS(18, picLayerHeader->PAN_SCAN_WINDOW[i].voffset); /* PS_VOFFSET. */
+                VC1_GET_BITS(14, picLayerHeader->PAN_SCAN_WINDOW[i].width); /* PS_WIDTH. */
+                VC1_GET_BITS(14, picLayerHeader->PAN_SCAN_WINDOW[i].height); /* PS_HEIGHT. */
+            }
+        }
+    }
+
+    if (picLayerHeader->PTYPE != VC1_SKIPPED_FRAME)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->RNDCTRL);
+        md->RNDCTRL =  picLayerHeader->RNDCTRL;
+
+        if ((md->INTERLACE == 1) ||
+            (picLayerHeader->FCM != VC1_FCM_PROGRESSIVE))
+        {
+            VC1_GET_BITS9(1, picLayerHeader->UVSAMP);
+        }
+
+        if ((md->FINTERPFLAG == 1) &&
+            (picLayerHeader->FCM == VC1_FCM_PROGRESSIVE))
+        {
+            VC1_GET_BITS9(1, tempValue); /* INTERPFRM. */
+        }
+
+        if ((picLayerHeader->PTYPE == VC1_B_FRAME) &&
+            (picLayerHeader->FCM == VC1_FCM_PROGRESSIVE))
+        {
+            if ((status = vc1_DecodeHuffmanPair(ctxt, VC1_BFRACTION_TBL,
+                                                &picLayerHeader->BFRACTION_NUM, &picLayerHeader->BFRACTION_DEN))
+                != VC1_STATUS_OK)
+            {
+                return status;
+            }
+        }
+
+        VC1_GET_BITS9(5, picLayerHeader->PQINDEX);
+        if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK)
+            return status;
+
+        if (picLayerHeader->PQINDEX <= 8)
+        {
+            VC1_GET_BITS9(1, picLayerHeader->HALFQP);
+        }
+        else
+            picLayerHeader->HALFQP = 0;
+
+        if (md->QUANTIZER == 1)
+        {
+            VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);
+            picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;
+        }
+
+        if (md->POSTPROCFLAG == 1)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->POSTPROC);
+        }
+    }
+
+    return vc1_ParsePictureFieldHeader_Adv(ctxt, pInfo);
+}
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses the picture header for advanced
+ * profile down to BFRACTION syntax element.
+ * Table 85 of SMPTE 421M.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParseFieldHeader_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    uint32_t i = 0;
+    vc1_Status status = VC1_STATUS_OK;
+    uint32_t number_of_pan_scan_window;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    VC1_GET_BITS9(1, picLayerHeader->FCM);
+    if (picLayerHeader->FCM)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->FCM);
+        if (picLayerHeader->FCM)
+            picLayerHeader->FCM = VC1_FCM_FIELD_INTERLACE;
+        else
+            picLayerHeader->FCM = VC1_FCM_FRAME_INTERLACE;
+    }
+    else
+        picLayerHeader->FCM = VC1_FCM_PROGRESSIVE;
+    if (picLayerHeader->FCM != VC1_FCM_FIELD_INTERLACE)
+        return VC1_STATUS_PARSE_ERROR;
+
+    VC1_GET_BITS9(3, picLayerHeader->FPTYPE);
+    if (picLayerHeader->FPTYPE == 0)
+    {
+        picLayerHeader->PTypeField1 = VC1_I_FRAME;
+        picLayerHeader->PTypeField2 = VC1_I_FRAME;
+    }
+    else if (picLayerHeader->FPTYPE == 1)
+    {
+        picLayerHeader->PTypeField1 = VC1_I_FRAME;
+        picLayerHeader->PTypeField2 = VC1_P_FRAME;
+    }
+    else if (picLayerHeader->FPTYPE == 2)
+    {
+        picLayerHeader->PTypeField1 = VC1_P_FRAME;
+        picLayerHeader->PTypeField2 = VC1_I_FRAME;
+    }
+    else if (picLayerHeader->FPTYPE == 3)
+    {
+        picLayerHeader->PTypeField1 = VC1_P_FRAME;
+        picLayerHeader->PTypeField2 = VC1_P_FRAME;
+    }
+    else if (picLayerHeader->FPTYPE == 4)
+    {
+        picLayerHeader->PTypeField1 = VC1_B_FRAME;
+        picLayerHeader->PTypeField2 = VC1_B_FRAME;
+    }
+    else if (picLayerHeader->FPTYPE == 5)
+    {
+        picLayerHeader->PTypeField1 = VC1_B_FRAME;
+        picLayerHeader->PTypeField2 = VC1_BI_FRAME;
+    }
+    else if (picLayerHeader->FPTYPE == 6)
+    {
+        picLayerHeader->PTypeField1 = VC1_BI_FRAME;
+        picLayerHeader->PTypeField2 = VC1_B_FRAME;
+    }
+    else if (picLayerHeader->FPTYPE == 7)
+    {
+        picLayerHeader->PTypeField1 = VC1_BI_FRAME;
+        picLayerHeader->PTypeField2 = VC1_BI_FRAME;
+    }
+
+    if (md->TFCNTRFLAG)
+    {
+        VC1_GET_BITS9(8, picLayerHeader->TFCNTR); 
+    }
+
+    if (md->PULLDOWN == 1)
+    {
+        if (md->PSF == 1)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->RPTFRM); 
+        }
+        else
+        {
+            VC1_GET_BITS9(1, picLayerHeader->TFF);
+            VC1_GET_BITS9(1, picLayerHeader->RFF);
+        }
+    } else
+        picLayerHeader->TFF = 1;
+
+    if (md->PANSCAN_FLAG == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->PS_PRESENT); 
+        if (picLayerHeader->PS_PRESENT)
+        {
+            if (md->PULLDOWN)
+                number_of_pan_scan_window = 2 + picLayerHeader->RFF;
+            else
+                number_of_pan_scan_window = 2;
+            picLayerHeader->number_of_pan_scan_window =number_of_pan_scan_window;
+
+            for (i = 0; i < number_of_pan_scan_window; i++)
+            {
+                VC1_GET_BITS(18, picLayerHeader->PAN_SCAN_WINDOW[i].hoffset); /* PS_HOFFSET. */
+                VC1_GET_BITS(18, picLayerHeader->PAN_SCAN_WINDOW[i].voffset); /* PS_VOFFSET. */
+                VC1_GET_BITS(14, picLayerHeader->PAN_SCAN_WINDOW[i].width); /* PS_WIDTH. */
+                VC1_GET_BITS(14, picLayerHeader->PAN_SCAN_WINDOW[i].height); /* PS_HEIGHT. */
+            }
+        }
+    }
+    VC1_GET_BITS9(1, md->RNDCTRL);
+
+#ifdef VBP
+	picLayerHeader->RNDCTRL = md->RNDCTRL;
+#endif
+    
+    VC1_GET_BITS9(1, picLayerHeader->UVSAMP);
+
+    if ((md->REFDIST_FLAG == 1) && (picLayerHeader->FPTYPE <= 3))
+    {
+        int32_t tmp;
+        if ((status = vc1_DecodeHuffmanOne(ctxt, &tmp,
+                                           VC1_REFDIST_TBL)) != VC1_STATUS_OK)
+        {
+            return status;
+        }
+        md->REFDIST = tmp;
+    } else if (md->REFDIST_FLAG == 0) {
+		md->REFDIST = 0;
+	}
+
+    if ((picLayerHeader->FPTYPE >= 4) && (picLayerHeader->FPTYPE <= 7))
+    {
+        if ((status = vc1_DecodeHuffmanPair(ctxt, VC1_BFRACTION_TBL,
+                                            &picLayerHeader->BFRACTION_NUM, &picLayerHeader->BFRACTION_DEN)) !=
+            VC1_STATUS_OK)
+        {
+            return status;
+        }
+    }
+
+    if (picLayerHeader->CurrField == 0)
+    {
+        picLayerHeader->PTYPE = picLayerHeader->PTypeField1;
+        picLayerHeader->BottomField = (uint8_t) (1 - picLayerHeader->TFF);
+    }
+    else
+    {
+        picLayerHeader->BottomField = (uint8_t) (picLayerHeader->TFF);
+        picLayerHeader->PTYPE = picLayerHeader->PTypeField2;
+    }
+
+    return vc1_ParsePictureFieldHeader_Adv(ctxt, pInfo);
+}
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function calls the appropriate function to further
+ * parse the picture header for advanced profile down to macroblock layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureFieldHeader_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_PARSE_ERROR;
+
+    if (pInfo->picLayerHeader.FCM == VC1_FCM_PROGRESSIVE)
+    {
+        if ((pInfo->picLayerHeader.PTYPE == VC1_I_FRAME) ||
+            (pInfo->picLayerHeader.PTYPE == VC1_BI_FRAME))
+        {
+            status = vc1_ParsePictureHeader_ProgressiveIpicture_Adv(ctxt, pInfo);
+        }
+        else if (pInfo->picLayerHeader.PTYPE == VC1_P_FRAME)
+            status = vc1_ParsePictureHeader_ProgressivePpicture_Adv(ctxt, pInfo);
+        else if (pInfo->picLayerHeader.PTYPE == VC1_B_FRAME)
+            status = vc1_ParsePictureHeader_ProgressiveBpicture_Adv(ctxt, pInfo);
+        else if (pInfo->picLayerHeader.PTYPE == VC1_SKIPPED_FRAME)
+            status = VC1_STATUS_OK;
+    }
+    else if (pInfo->picLayerHeader.FCM == VC1_FCM_FRAME_INTERLACE)
+    {
+        if ((pInfo->picLayerHeader.PTYPE == VC1_I_FRAME) ||
+            (pInfo->picLayerHeader.PTYPE == VC1_BI_FRAME))
+        {
+            status = vc1_ParsePictureHeader_InterlaceIpicture_Adv(ctxt, pInfo);
+        }
+        else if (pInfo->picLayerHeader.PTYPE == VC1_P_FRAME)
+            status = vc1_ParsePictureHeader_InterlacePpicture_Adv(ctxt, pInfo);
+        else if (pInfo->picLayerHeader.PTYPE == VC1_B_FRAME)
+            status = vc1_ParsePictureHeader_InterlaceBpicture_Adv(ctxt, pInfo);
+        else if (pInfo->picLayerHeader.PTYPE == VC1_SKIPPED_FRAME)
+            status = VC1_STATUS_OK;
+    }
+    else if (pInfo->picLayerHeader.FCM == VC1_FCM_FIELD_INTERLACE)
+    {
+        int ptype;
+        if( pInfo->picLayerHeader.CurrField == 0)
+            ptype = pInfo->picLayerHeader.PTypeField1;
+        else
+            ptype = pInfo->picLayerHeader.PTypeField2;
+
+        if ((ptype == VC1_I_FRAME) ||
+            (ptype == VC1_BI_FRAME))
+        {
+            status = vc1_ParseFieldHeader_InterlaceIpicture_Adv(ctxt, pInfo);
+        }
+        else if (ptype == VC1_P_FRAME)
+            status = vc1_ParseFieldHeader_InterlacePpicture_Adv(ctxt, pInfo);
+        else if (ptype == VC1_B_FRAME)
+            status = vc1_ParseFieldHeader_InterlaceBpicture_Adv(ctxt, pInfo);
+        else if (ptype == VC1_SKIPPED_FRAME)
+            status = VC1_STATUS_OK;
+    }
+
+    return status;
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ppic.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ppic.c
index ba9c756..f57c61d 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ppic.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ppic.c
@@ -92,11 +92,10 @@
         VC1_GET_BITS9(6, picLayerHeader->LUMSCALE);
         VC1_GET_BITS9(6, picLayerHeader->LUMSHIFT);
     }
-#ifdef VBP
     else
+#ifdef VBP   
         picLayerHeader->MVMODE2 = 0;
-#else
-    else
+#else        
         picLayerHeader->MVMODE2 = picLayerHeader->MVMODE;
 #endif
 
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ppic_adv.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ppic_adv.c
index 144c138..ff81282 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ppic_adv.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/vc1parse_ppic_adv.c
@@ -1,368 +1,368 @@
-/* ///////////////////////////////////////////////////////////////////////

-//

-//               INTEL CORPORATION PROPRIETARY INFORMATION

-//  This software is supplied under the terms of a license agreement or

-//  nondisclosure agreement with Intel Corporation and may not be copied

-//  or disclosed except in accordance with the terms of that agreement.

-//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.

-//

-//  Description: Parses VC-1 picture layer for progressive P picture in advanced

-//  profile bitstream.

-//

-*/

-

-#include "vc1parse.h"

-#include "viddec_fw_debug.h"

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses progressive P picture for advanced

- * profile bitstream.

- * Table 20 of SMPTE 421M after processing up to POSTPROC by

- * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureHeader_ProgressivePpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    uint8_t bit_count;

-    const uint8_t *table;

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    /* MVRANGE. */

-    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (picLayerHeader->PQUANT > 12)

-        table = VC1_MVMODE_LOW_TBL;

-    else

-        table = VC1_MVMODE_HIGH_TBL;

-

-    bit_count = 0;

-    VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-    while ((picLayerHeader->MVMODE == 0) && (bit_count < 3))

-    {

-        VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-        bit_count++;

-    }

-    if (bit_count == 3)

-        bit_count += picLayerHeader->MVMODE;

-    picLayerHeader->MVMODE = table[bit_count];

-

-    if (picLayerHeader->MVMODE == VC1_MVMODE_INTENSCOMP)

-    {

-        bit_count = 0;

-        VC1_GET_BITS9(1, picLayerHeader->MVMODE2);

-        while ((picLayerHeader->MVMODE2 == 0) && (bit_count < 2))

-        {

-            VC1_GET_BITS9(1, picLayerHeader->MVMODE2);

-            bit_count++;

-        }

-        if (bit_count == 2 && picLayerHeader->MVMODE2 == 0)

-            bit_count++;

-        picLayerHeader->MVMODE2 = table[bit_count];

-        VC1_GET_BITS9(6, picLayerHeader->LUMSCALE);

-        VC1_GET_BITS9(6, picLayerHeader->LUMSHIFT);

-        md->LUMSCALE2 = picLayerHeader->LUMSCALE;

-        md->LUMSHIFT2 = picLayerHeader->LUMSHIFT;

-    }

-    else

-#ifdef VBP    

-		picLayerHeader->MVMODE2 = 0;

-#else		

-        picLayerHeader->MVMODE2 = picLayerHeader->MVMODE;

-#endif

-

-    if ((picLayerHeader->MVMODE == VC1_MVMODE_MIXED_MV) ||

-        ((picLayerHeader->MVMODE == VC1_MVMODE_INTENSCOMP) &&

-         (picLayerHeader->MVMODE2 == VC1_MVMODE_MIXED_MV)))

-    {

-        if ((status = vc1_DecodeBitplane(ctxt, pInfo,

-            md->widthMB, md->heightMB, BPP_MVTYPEMB)) !=

-            VC1_STATUS_OK)

-        {

-            return status;

-        }

-    }

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo,

-        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    VC1_GET_BITS9(2, picLayerHeader->MVTAB);

-    VC1_GET_BITS9(2, picLayerHeader->CBPTAB);

-

-    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (md->VSTRANSFORM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TTMBF);

-        if (picLayerHeader->TTMBF == 1)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->TTFRM);

-        }

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses interlace P frame for advanced

- * profile bitstream.

- * Table 83 of SMPTE 421M after processing up to POSTPROC by

- * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParsePictureHeader_InterlacePpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-

-    /* MVRANGE. */

-    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    /* DMVRANGE. */

-    if ((status = vc1_DMVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    VC1_GET_BITS9(1, picLayerHeader->MV4SWITCH);

-

-    VC1_GET_BITS9(1, picLayerHeader->INTCOMP);

-    if (picLayerHeader->INTCOMP)

-    {

-        VC1_GET_BITS9(6, picLayerHeader->LUMSCALE);

-        VC1_GET_BITS9(6, picLayerHeader->LUMSHIFT);

-        md->LUMSCALE2 = picLayerHeader->LUMSCALE;

-        md->LUMSHIFT2 = picLayerHeader->LUMSHIFT;

-    }

-

-    if ((status = vc1_DecodeBitplane(ctxt, pInfo,

-        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)

-    {

-        return status;

-    }

-

-    VC1_GET_BITS9(2, picLayerHeader->MBMODETAB);

-    VC1_GET_BITS9(2, picLayerHeader->MVTAB); /* IMVTAB. */

-    VC1_GET_BITS9(3, picLayerHeader->CBPTAB); /* ICBPTAB. */

-    VC1_GET_BITS9(2, picLayerHeader->MV2BPTAB); /* 2MVBPTAB. */

-

-    if (picLayerHeader->MV4SWITCH == 1)

-    {

-        VC1_GET_BITS9(2, picLayerHeader->MV4BPTAB); /* 4MVBPTAB. */

-    }

-

-    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (md->VSTRANSFORM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TTMBF);

-        if (picLayerHeader->TTMBF == 1)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->TTFRM);

-        }

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

-

-/*------------------------------------------------------------------------------

- * Parse picture layer.  This function parses interlace P field for advanced

- * profile bitstream.

- * Table 88 of SMPTE 421M after processing up to BFRACTION by

- * vc1_ParseFieldHeader_Adv() but stopping before processing of macroblock

- * layer.

- *------------------------------------------------------------------------------

- */

-

-vc1_Status vc1_ParseFieldHeader_InterlacePpicture_Adv(void* ctxt, vc1_Info *pInfo)

-{

-    uint8_t bit_count;

-    const uint8_t *table;

-    vc1_Status status = VC1_STATUS_OK;

-    vc1_metadata_t *md = &pInfo->metadata;

-    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;

-   

-

-    VC1_GET_BITS9(5, picLayerHeader->PQINDEX);

-    if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (picLayerHeader->PQINDEX <= 8)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->HALFQP);

-    }

-    else

-        picLayerHeader->HALFQP = 0;

-

-

-    if (md->QUANTIZER == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);

-        picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;

-    }

-

-    if (md->POSTPROCFLAG == 1)

-    {

-        VC1_GET_BITS9(2, picLayerHeader->POSTPROC);

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->NUMREF);

-   

-    if (picLayerHeader->NUMREF == 0)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->REFFIELD);

-    }

-

-    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK) {

-        DEB("Error in vc1_MVRangeDecode \n");

-        return status;

-    }

-

-    if ((status = vc1_DMVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (picLayerHeader->PQUANT > 12)

-        table = VC1_MVMODE_LOW_TBL;

-    else

-        table = VC1_MVMODE_HIGH_TBL;

-

-    bit_count = 0;

-    VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-    while ((picLayerHeader->MVMODE == 0) && (bit_count < 2))

-    {

-        VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-        bit_count++;

-    }

-    if (bit_count == 2 && picLayerHeader->MVMODE == 0) {

-        VC1_GET_BITS9(1, picLayerHeader->MVMODE);

-

-        if ( picLayerHeader->MVMODE == 1)

-            bit_count ++;

-

-        bit_count++;

-    }

-    picLayerHeader->MVMODE = table[bit_count];

-

-    if (picLayerHeader->MVMODE == VC1_MVMODE_INTENSCOMP)

-    {

-        bit_count = 0;

-        VC1_GET_BITS9(1, picLayerHeader->MVMODE2);

-        while ((picLayerHeader->MVMODE2 == 0) && (bit_count < 2))

-        {

-            VC1_GET_BITS9(1, picLayerHeader->MVMODE2);

-            bit_count++;

-        }

-        if (bit_count == 2 && picLayerHeader->MVMODE2 == 0)

-            bit_count++;

-        picLayerHeader->MVMODE2 = table[bit_count];

-

-        VC1_GET_BITS9(1, md->INTCOMPFIELD);

-        if (md->INTCOMPFIELD == 1)

-            md->INTCOMPFIELD = VC1_INTCOMP_BOTH_FIELD;

-        else

-        {

-            VC1_GET_BITS9(1, md->INTCOMPFIELD);

-            if(md->INTCOMPFIELD == 1)

-                md->INTCOMPFIELD = VC1_INTCOMP_BOTTOM_FIELD;

-            else

-                md->INTCOMPFIELD = VC1_INTCOMP_TOP_FIELD;

-        }

-        VC1_GET_BITS9(6, picLayerHeader->LUMSCALE); /* LUMSCALE1. */

-        VC1_GET_BITS9(6, picLayerHeader->LUMSHIFT); /* LUMSHIFT1. */

-        if ( md->INTCOMPFIELD == VC1_INTCOMP_BOTTOM_FIELD ) {

-            md->LUMSCALE2 = picLayerHeader->LUMSCALE;

-            md->LUMSHIFT2 = picLayerHeader->LUMSHIFT;

-        }

-        if (md->INTCOMPFIELD == VC1_INTCOMP_BOTH_FIELD)

-        {

-            VC1_GET_BITS9(6, md->LUMSCALE2);

-            VC1_GET_BITS9(6, md->LUMSHIFT2);

-        }

-    }

-    else

-#ifdef VBP    

-		picLayerHeader->MVMODE2 = 0;

-#else		

-        picLayerHeader->MVMODE2 = picLayerHeader->MVMODE;

-#endif        

-

-    VC1_GET_BITS9(3, picLayerHeader->MBMODETAB);

-

-    if (picLayerHeader->NUMREF)

-    {

-        VC1_GET_BITS9(3, picLayerHeader->MVTAB); /* IMVTAB. */

-    }

-    else

-    {

-        VC1_GET_BITS9(2, picLayerHeader->MVTAB); /* IMVTAB. */

-    }

-

-    VC1_GET_BITS9(3, picLayerHeader->CBPTAB); /* ICBPTAB. */

-

-#ifdef VBP

-	if (picLayerHeader->MVMODE == VC1_MVMODE_MIXED_MV)

-#else	

-    if (picLayerHeader->MVMODE2 == VC1_MVMODE_MIXED_MV)

-#endif    

-    {

-        VC1_GET_BITS9(2, picLayerHeader->MV4BPTAB); /* 4MVBPTAB. */

-    }

-

-    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)

-        return status;

-

-    if (md->VSTRANSFORM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TTMBF);

-        if (picLayerHeader->TTMBF == 1)

-        {

-            VC1_GET_BITS9(2, picLayerHeader->TTFRM);

-        }

-    }

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-    if (picLayerHeader->TRANSACFRM == 1)

-    {

-        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);

-        picLayerHeader->TRANSACFRM += 2;

-    }

-    picLayerHeader->TRANSACFRM2 = 0;

-

-    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);

-

-    /* Skip parsing of macroblock layer. */

-

-    return status;

-}

+/* ///////////////////////////////////////////////////////////////////////
+//
+//               INTEL CORPORATION PROPRIETARY INFORMATION
+//  This software is supplied under the terms of a license agreement or
+//  nondisclosure agreement with Intel Corporation and may not be copied
+//  or disclosed except in accordance with the terms of that agreement.
+//        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
+//
+//  Description: Parses VC-1 picture layer for progressive P picture in advanced
+//  profile bitstream.
+//
+*/
+
+#include "vc1parse.h"
+#include "viddec_fw_debug.h"
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses progressive P picture for advanced
+ * profile bitstream.
+ * Table 20 of SMPTE 421M after processing up to POSTPROC by
+ * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureHeader_ProgressivePpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    uint8_t bit_count;
+    const uint8_t *table;
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    /* MVRANGE. */
+    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (picLayerHeader->PQUANT > 12)
+        table = VC1_MVMODE_LOW_TBL;
+    else
+        table = VC1_MVMODE_HIGH_TBL;
+
+    bit_count = 0;
+    VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+    while ((picLayerHeader->MVMODE == 0) && (bit_count < 3))
+    {
+        VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+        bit_count++;
+    }
+    if (bit_count == 3)
+        bit_count += picLayerHeader->MVMODE;
+    picLayerHeader->MVMODE = table[bit_count];
+
+    if (picLayerHeader->MVMODE == VC1_MVMODE_INTENSCOMP)
+    {
+        bit_count = 0;
+        VC1_GET_BITS9(1, picLayerHeader->MVMODE2);
+        while ((picLayerHeader->MVMODE2 == 0) && (bit_count < 2))
+        {
+            VC1_GET_BITS9(1, picLayerHeader->MVMODE2);
+            bit_count++;
+        }
+        if (bit_count == 2 && picLayerHeader->MVMODE2 == 0)
+            bit_count++;
+        picLayerHeader->MVMODE2 = table[bit_count];
+        VC1_GET_BITS9(6, picLayerHeader->LUMSCALE);
+        VC1_GET_BITS9(6, picLayerHeader->LUMSHIFT);
+        md->LUMSCALE2 = picLayerHeader->LUMSCALE;
+        md->LUMSHIFT2 = picLayerHeader->LUMSHIFT;
+    }
+    else
+#ifdef VBP    
+		picLayerHeader->MVMODE2 = 0;
+#else		
+        picLayerHeader->MVMODE2 = picLayerHeader->MVMODE;
+#endif
+
+    if ((picLayerHeader->MVMODE == VC1_MVMODE_MIXED_MV) ||
+        ((picLayerHeader->MVMODE == VC1_MVMODE_INTENSCOMP) &&
+         (picLayerHeader->MVMODE2 == VC1_MVMODE_MIXED_MV)))
+    {
+        if ((status = vc1_DecodeBitplane(ctxt, pInfo,
+            md->widthMB, md->heightMB, BPP_MVTYPEMB)) !=
+            VC1_STATUS_OK)
+        {
+            return status;
+        }
+    }
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo,
+        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    VC1_GET_BITS9(2, picLayerHeader->MVTAB);
+    VC1_GET_BITS9(2, picLayerHeader->CBPTAB);
+
+    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (md->VSTRANSFORM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TTMBF);
+        if (picLayerHeader->TTMBF == 1)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->TTFRM);
+        }
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses interlace P frame for advanced
+ * profile bitstream.
+ * Table 83 of SMPTE 421M after processing up to POSTPROC by
+ * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParsePictureHeader_InterlacePpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+
+    /* MVRANGE. */
+    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    /* DMVRANGE. */
+    if ((status = vc1_DMVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    VC1_GET_BITS9(1, picLayerHeader->MV4SWITCH);
+
+    VC1_GET_BITS9(1, picLayerHeader->INTCOMP);
+    if (picLayerHeader->INTCOMP)
+    {
+        VC1_GET_BITS9(6, picLayerHeader->LUMSCALE);
+        VC1_GET_BITS9(6, picLayerHeader->LUMSHIFT);
+        md->LUMSCALE2 = picLayerHeader->LUMSCALE;
+        md->LUMSHIFT2 = picLayerHeader->LUMSHIFT;
+    }
+
+    if ((status = vc1_DecodeBitplane(ctxt, pInfo,
+        md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK)
+    {
+        return status;
+    }
+
+    VC1_GET_BITS9(2, picLayerHeader->MBMODETAB);
+    VC1_GET_BITS9(2, picLayerHeader->MVTAB); /* IMVTAB. */
+    VC1_GET_BITS9(3, picLayerHeader->CBPTAB); /* ICBPTAB. */
+    VC1_GET_BITS9(2, picLayerHeader->MV2BPTAB); /* 2MVBPTAB. */
+
+    if (picLayerHeader->MV4SWITCH == 1)
+    {
+        VC1_GET_BITS9(2, picLayerHeader->MV4BPTAB); /* 4MVBPTAB. */
+    }
+
+    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (md->VSTRANSFORM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TTMBF);
+        if (picLayerHeader->TTMBF == 1)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->TTFRM);
+        }
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
+
+/*------------------------------------------------------------------------------
+ * Parse picture layer.  This function parses interlace P field for advanced
+ * profile bitstream.
+ * Table 88 of SMPTE 421M after processing up to BFRACTION by
+ * vc1_ParseFieldHeader_Adv() but stopping before processing of macroblock
+ * layer.
+ *------------------------------------------------------------------------------
+ */
+
+vc1_Status vc1_ParseFieldHeader_InterlacePpicture_Adv(void* ctxt, vc1_Info *pInfo)
+{
+    uint8_t bit_count;
+    const uint8_t *table;
+    vc1_Status status = VC1_STATUS_OK;
+    vc1_metadata_t *md = &pInfo->metadata;
+    vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
+   
+
+    VC1_GET_BITS9(5, picLayerHeader->PQINDEX);
+    if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (picLayerHeader->PQINDEX <= 8)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->HALFQP);
+    }
+    else
+        picLayerHeader->HALFQP = 0;
+
+
+    if (md->QUANTIZER == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);
+        picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;
+    }
+
+    if (md->POSTPROCFLAG == 1)
+    {
+        VC1_GET_BITS9(2, picLayerHeader->POSTPROC);
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->NUMREF);
+   
+    if (picLayerHeader->NUMREF == 0)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->REFFIELD);
+    }
+
+    if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK) {
+        DEB("Error in vc1_MVRangeDecode \n");
+        return status;
+    }
+
+    if ((status = vc1_DMVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (picLayerHeader->PQUANT > 12)
+        table = VC1_MVMODE_LOW_TBL;
+    else
+        table = VC1_MVMODE_HIGH_TBL;
+
+    bit_count = 0;
+    VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+    while ((picLayerHeader->MVMODE == 0) && (bit_count < 2))
+    {
+        VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+        bit_count++;
+    }
+    if (bit_count == 2 && picLayerHeader->MVMODE == 0) {
+        VC1_GET_BITS9(1, picLayerHeader->MVMODE);
+
+        if ( picLayerHeader->MVMODE == 1)
+            bit_count ++;
+
+        bit_count++;
+    }
+    picLayerHeader->MVMODE = table[bit_count];
+
+    if (picLayerHeader->MVMODE == VC1_MVMODE_INTENSCOMP)
+    {
+        bit_count = 0;
+        VC1_GET_BITS9(1, picLayerHeader->MVMODE2);
+        while ((picLayerHeader->MVMODE2 == 0) && (bit_count < 2))
+        {
+            VC1_GET_BITS9(1, picLayerHeader->MVMODE2);
+            bit_count++;
+        }
+        if (bit_count == 2 && picLayerHeader->MVMODE2 == 0)
+            bit_count++;
+        picLayerHeader->MVMODE2 = table[bit_count];
+
+        VC1_GET_BITS9(1, md->INTCOMPFIELD);
+        if (md->INTCOMPFIELD == 1)
+            md->INTCOMPFIELD = VC1_INTCOMP_BOTH_FIELD;
+        else
+        {
+            VC1_GET_BITS9(1, md->INTCOMPFIELD);
+            if(md->INTCOMPFIELD == 1)
+                md->INTCOMPFIELD = VC1_INTCOMP_BOTTOM_FIELD;
+            else
+                md->INTCOMPFIELD = VC1_INTCOMP_TOP_FIELD;
+        }
+        VC1_GET_BITS9(6, picLayerHeader->LUMSCALE); /* LUMSCALE1. */
+        VC1_GET_BITS9(6, picLayerHeader->LUMSHIFT); /* LUMSHIFT1. */
+        if ( md->INTCOMPFIELD == VC1_INTCOMP_BOTTOM_FIELD ) {
+            md->LUMSCALE2 = picLayerHeader->LUMSCALE;
+            md->LUMSHIFT2 = picLayerHeader->LUMSHIFT;
+        }
+        if (md->INTCOMPFIELD == VC1_INTCOMP_BOTH_FIELD)
+        {
+            VC1_GET_BITS9(6, md->LUMSCALE2);
+            VC1_GET_BITS9(6, md->LUMSHIFT2);
+        }
+    }
+    else
+#ifdef VBP    
+		picLayerHeader->MVMODE2 = 0;
+#else		
+        picLayerHeader->MVMODE2 = picLayerHeader->MVMODE;
+#endif        
+
+    VC1_GET_BITS9(3, picLayerHeader->MBMODETAB);
+
+    if (picLayerHeader->NUMREF)
+    {
+        VC1_GET_BITS9(3, picLayerHeader->MVTAB); /* IMVTAB. */
+    }
+    else
+    {
+        VC1_GET_BITS9(2, picLayerHeader->MVTAB); /* IMVTAB. */
+    }
+
+    VC1_GET_BITS9(3, picLayerHeader->CBPTAB); /* ICBPTAB. */
+
+#ifdef VBP
+	if (picLayerHeader->MVMODE == VC1_MVMODE_MIXED_MV)
+#else	
+    if (picLayerHeader->MVMODE2 == VC1_MVMODE_MIXED_MV)
+#endif    
+    {
+        VC1_GET_BITS9(2, picLayerHeader->MV4BPTAB); /* 4MVBPTAB. */
+    }
+
+    if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK)
+        return status;
+
+    if (md->VSTRANSFORM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TTMBF);
+        if (picLayerHeader->TTMBF == 1)
+        {
+            VC1_GET_BITS9(2, picLayerHeader->TTFRM);
+        }
+    }
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+    if (picLayerHeader->TRANSACFRM == 1)
+    {
+        VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
+        picLayerHeader->TRANSACFRM += 2;
+    }
+    picLayerHeader->TRANSACFRM2 = 0;
+
+    VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
+
+    /* Skip parsing of macroblock layer. */
+
+    return status;
+}
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/viddec_vc1_parse.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/viddec_vc1_parse.c
index 6af6f09..9ddc237 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/viddec_vc1_parse.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/viddec_vc1_parse.c
@@ -27,6 +27,7 @@
         parser->ref_frame[i].anchor[1] = 1;
         parser->ref_frame[i].intcomp_top = 0;
         parser->ref_frame[i].intcomp_bot = 0;
+        parser->ref_frame[i].tff=0;
     }
 
     parser->intcomp_top[0] = 0;
@@ -90,13 +91,14 @@
     ret = viddec_pm_get_bits(parent, &sc, 32);
 #endif
     sc = sc & 0xFF;
-    parser->is_frame_start = (sc == vc1_SCFrameHeader);
+    parser->is_frame_start = 0;
+    parser->is_second_start = 0;
     DEB("START_CODE = %02x\n", sc);
     switch( sc )
     {
         case vc1_SCSequenceHeader:
         {
-            uint32_t data=0;
+            uint32_t data;
             parser->ref_frame[0].anchor[0] = 1;
             parser->ref_frame[0].anchor[1] = 1;
             parser->ref_frame[1].anchor[0] = 1;
@@ -112,7 +114,7 @@
             else
             {
                 status = vc1_ParseRCVSequenceLayer(parent, &parser->info);
-            }            
+            }
             parser->sc_seen = VC1_SC_SEQ; 
             parser->sc_seen_since_last_wkld |= VC1_SC_SEQ; 
 #ifdef VBP
@@ -131,7 +133,7 @@
 #ifdef VBP
 			parser->start_code = VC1_SC_EP;
 #endif              
-			break;
+            break;
         }
 
         case vc1_SCFrameHeader:
@@ -149,17 +151,23 @@
             // Clear all bits indicating data below frm header
             parser->sc_seen &= VC1_FRM_MASK;
             parser->sc_seen_since_last_wkld |= VC1_SC_FRM; 
-            vc1_start_new_frame ( parent, parser );
+            //vc1_start_new_frame ( parent, parser );
+            
+            parser->is_frame_start = 1;
+            vc1_parse_emit_frame_start( parent, parser );            
 #ifdef VBP
 			parser->start_code = VC1_SC_FRM;
 #endif             
-			break;
+            break;
         }
 
         case vc1_SCSlice:
         {
             status = vc1_ParseSliceLayer(parent, &parser->info);
             parser->sc_seen_since_last_wkld |= VC1_SC_SLC; 
+
+            vc1_parse_emit_current_slice( parent, parser );
+
 #ifdef VBP
          	parser->start_code = VC1_SC_SLC;
 #endif   
@@ -203,14 +211,16 @@
             if((parser->info.picLayerHeader.PTypeField2 == VC1_I_FRAME) ||
                (parser->info.picLayerHeader.PTypeField2 == VC1_P_FRAME))
             {
-                vc1_swap_intcomp(parser);
+                //vc1_swap_intcomp(parser);
             }
-
             parser->sc_seen |= VC1_SC_FLD;
             parser->sc_seen_since_last_wkld |= VC1_SC_FLD; 
+
+            parser->is_second_start = 1;
+            vc1_parse_emit_second_field_start( parent, parser );
 #ifdef VBP
-			parser->start_code = VC1_SC_FLD;
-#endif 
+	    parser->start_code = VC1_SC_FLD;
+#endif             
             break;
         }
 
@@ -247,9 +257,7 @@
         }
     }
         
-    if( vc1_is_frame_start_code( sc ) ) {
-        vc1_parse_emit_current_frame( parent, parser );
-    }
+   
 
     return VIDDEC_PARSE_SUCESS;
 } // viddec_vc1_parse
diff --git a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/viddec_vc1_workload.c b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/viddec_vc1_workload.c
index b787831..b5bba2b 100644
--- a/mix_vbp/viddec_fw/fw/codecs/vc1/parser/viddec_vc1_workload.c
+++ b/mix_vbp/viddec_fw/fw/codecs/vc1/parser/viddec_vc1_workload.c
@@ -82,473 +82,6 @@
     return;
 } // translate_parser_info_to_frame_attributes
 
-void vc1_intcomp(vc1_viddec_parser_t *parser, vc1_Info *pInfo, VC1D_SPR_REGS *spr) 
-{
-    vc1_metadata_t *md = &pInfo->metadata;
-    vc1_PictureLayerHeader *pic = &pInfo->picLayerHeader;
-    uint32_t intcomp1 = 1;
-    uint32_t intcomp2 = 0;
-
-    // Get the intensity compensation from the bitstream
-    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SCALE_1, intcomp1, pic->LUMSCALE);
-    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SHIFT_1, intcomp1, pic->LUMSHIFT);
-
-    if(md->INTCOMPFIELD == VC1_INTCOMP_BOTH_FIELD) 
-    {
-        intcomp2 = 1;
-        BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SCALE_1, intcomp2, md->LUMSCALE2);
-        BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SHIFT_1, intcomp2, md->LUMSHIFT2);
-    }
-
-    switch(md->INTCOMPFIELD)
-    {
-        case VC1_INTCOMP_TOP_FIELD:
-            if(pic->CurrField == 0) // First field decoded
-            {
-                if(pic->TFF)
-                {
-                    //parser->intcomp_bot[0] = intcomp1 << 13;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_top, intcomp1);
-                }
-                else
-                {
-                    parser->intcomp_top[0] = intcomp1;
-                    parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = intcomp1;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_fwd_top, intcomp1);
-                }
-            }
-            else // Second field
-            {
-                if(pic->TFF)
-                {
-                    parser->intcomp_top[0] = intcomp1;
-                    parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = intcomp1;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_bwd_top, intcomp1);
-                }
-                else
-                {
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_top, intcomp1);
-                }
-            }
-            break;
-        case VC1_INTCOMP_BOTTOM_FIELD:
-            if(pic->CurrField == 0) // First field decoded
-            {
-                if(pic->TFF)
-                {
-                    parser->intcomp_bot[0] = intcomp1;
-                    parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_bot = intcomp1;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_fwd_bot, intcomp1);
-                }
-                else
-                {
-                    parser->intcomp_bot[0] = intcomp1 << 13;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_bot, intcomp1);
-                }
-            }
-            else // Second field
-            {
-                if(pic->TFF)
-                {
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_bot, intcomp1);
-                }
-                else
-                {
-                    parser->intcomp_bot[0] = intcomp1;
-                    parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_bot = intcomp1;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_bwd_bot, intcomp1);
-                }
-            }
-            break;
-        case VC1_INTCOMP_BOTH_FIELD:
-            if(pic->CurrField == 0) // First field decoded
-            {
-                if(pic->TFF)
-                {
-                    parser->intcomp_bot[0] = intcomp2;
-                    parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_bot = intcomp2;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_top, intcomp1);
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_fwd_bot, intcomp2);
-                }
-                else
-                {
-                    parser->intcomp_top[0] = intcomp2;
-                    parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = intcomp2;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_bot, intcomp1);
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_fwd_top, intcomp2);
-                }
-            }
-            else // Second field
-            {
-                if(pic->TFF)
-                {
-                    parser->intcomp_top[0] = intcomp1;
-                    parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = intcomp1;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_bwd_top, intcomp1);
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_bot, intcomp2);
-                }
-                else
-                {
-                    parser->intcomp_bot[0] = intcomp1;
-                    parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_bot = intcomp1;
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_bwd_bot, intcomp1);
-                    BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_top, intcomp2);
-                }
-            }
-            break;
-        default:
-            break;
-    } // switch on INTCOMPFIELD
-
-    return;
-} // vc1_intcomp
-
-static void handle_intensity_compensation(vc1_viddec_parser_t *parser, vc1_Info *pInfo, VC1D_SPR_REGS *spr)
-{
-    vc1_PictureLayerHeader *pic = &pInfo->picLayerHeader;
-    uint8_t intcomp_present = false;
-
-    if((pic->MVMODE == VC1_MVMODE_INTENSCOMP) || (pic->INTCOMP))
-    {
-        intcomp_present = true;
-        if(pic->FCM == VC1_FCM_FIELD_INTERLACE)  
-        {
-            vc1_intcomp(parser, pInfo, spr);
-        } 
-        else 
-        {
-            BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, spr->intcomp_fwd_top, 1);
-            BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SCALE_1, spr->intcomp_fwd_top, pic->LUMSCALE);
-            BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SHIFT_1, spr->intcomp_fwd_top, pic->LUMSHIFT);
-
-            if(parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm == VC1_FCM_FIELD_INTERLACE)
-            {
-               BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, spr->intcomp_fwd_bot, 1);
-               BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SCALE_2, spr->intcomp_fwd_bot, pic->LUMSCALE);
-               BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SHIFT_2, spr->intcomp_fwd_bot, pic->LUMSHIFT);
-            }
-
-            parser->intcomp_top[0] = spr->intcomp_fwd_top;
-            parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = spr->intcomp_fwd_top;
-            parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_bot = spr->intcomp_fwd_top;
-        }
-    }
-
-    // Propagate the previous picture's intensity compensation
-    if(pic->FCM == VC1_FCM_FIELD_INTERLACE)
-    {
-        if( (pic->CurrField) || 
-            ((pic->CurrField == 0) && (parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm == VC1_FCM_FIELD_INTERLACE)))
-        { 
-            spr->intcomp_fwd_top |= parser->intcomp_top[1];
-            spr->intcomp_fwd_bot |= parser->intcomp_bot[1];
-        }
-    }
-    if(pic->FCM == VC1_FCM_FRAME_INTERLACE)
-    {
-        if( (pic->CurrField) || 
-            ((pic->CurrField == 0) && (parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm == VC1_FCM_FIELD_INTERLACE)))
-        {
-            spr->intcomp_fwd_bot |= parser->intcomp_bot[1];
-        }
-    }
-
-    switch(pic->PTYPE)
-    {
-        case VC1_B_FRAME:
-            spr->intcomp_fwd_top = parser->intcomp_last[0];
-            spr->intcomp_fwd_bot = parser->intcomp_last[1];
-            spr->intcomp_bwd_top = parser->intcomp_last[2];
-            spr->intcomp_bwd_bot = parser->intcomp_last[3];
-            break;
-        case VC1_P_FRAME:
-            // If first field, store the intcomp values to propagate.
-            // If second field has valid intcomp values, store them
-            // to propagate.
-            if(pic->CurrField == 0) // first field
-            {
-                parser->intcomp_last[0] = spr->intcomp_fwd_top;
-                parser->intcomp_last[1] = spr->intcomp_fwd_bot;
-                parser->intcomp_last[2] = spr->intcomp_bwd_top;
-                parser->intcomp_last[3] = spr->intcomp_bwd_bot;
-            }
-            else // Second field
-            {
-                    parser->intcomp_last[0] |= spr->intcomp_fwd_top;
-                    parser->intcomp_last[1] |= spr->intcomp_fwd_bot;
-                    parser->intcomp_last[2] |= spr->intcomp_bwd_top;
-                    parser->intcomp_last[3] |= spr->intcomp_bwd_bot;
-            }
-            break;
-        case VC1_I_FRAME:
-        case VC1_BI_FRAME:
-            break;
-        default:
-            break;
-    }
-
-    return; 
-} // handle_intensity_compensation
-
-/**
- * This function populates the registers for range reduction (main profile) 
- * This function assumes pInfo->metadata.RANGERED is ON at the sequence layer (J.1.17)
- * A frame is marked as range reduced by the RANGEREDFRM flag at the picture layer,  
- * and the output of the decoded range reduced frame needs to be scaled up (8.1.1.4).
- * Previous reference frame needs be upscaled or downscaled based on the RR status of
- * current and previous frame (8.3.4.11)
- */
-static inline void vc1_fill_RR_hw_struct(vc1_viddec_parser_t *parser, vc1_Info *pInfo, VC1D_SPR_REGS *spr)
-{
-    vc1_PictureLayerHeader *pic = &pInfo->picLayerHeader;
-    int is_previous_ref_rr=0;
-   
-    /* range reduction applies to luma and chroma component 
-    which are the same register bit as RANGE_MAPY_FLAG, RANGE_MAPUV_FLAG */
-    BF_WRITE(VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_Y_FLAG, spr->range_map, pic->RANGEREDFRM);
-    BF_WRITE(VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_UV_FLAG, spr->range_map, pic->RANGEREDFRM); 
-    
-    /* Get the range reduced status of the previous frame */
-    switch (pic->PTYPE) 
-    {
-        case VC1_P_FRAME:
-        {
-            is_previous_ref_rr = parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].rr_frm;
-            break;
-        }
-        case VC1_B_FRAME:
-        {
-            is_previous_ref_rr = parser->ref_frame[VC1_REF_FRAME_T_MINUS_2].rr_frm;
-            break;
-        }
-        default:
-        {
-            break;
-        }
-    }
-
-    /* if current frame is RR and previous frame is not 
-        donwscale the reference pixel ( RANGE_REF_RED_TYPE =1 in register) */
-    if(pic->RANGEREDFRM) 
-    {
-        if(!is_previous_ref_rr) 
-        {
-            BF_WRITE(VC1_0_SEQPIC_RECON_CONTROL, RANGE_REF_RED_EN, spr->recon_control, 1);
-            BF_WRITE(VC1_0_SEQPIC_RECON_CONTROL, RANGE_REF_RED_TYPE, spr->recon_control, 1);
-        }
-    } 
-    else 
-    {  
-        /* if current frame is not RR but previous was RR,  scale up the reference frame ( RANGE_REF_RED_TYPE = 0) */
-        if(is_previous_ref_rr) 
-        {
-            BF_WRITE(VC1_0_SEQPIC_RECON_CONTROL, RANGE_REF_RED_EN, spr->recon_control, 1);
-            BF_WRITE(VC1_0_SEQPIC_RECON_CONTROL, RANGE_REF_RED_TYPE, spr->recon_control, 0);
-        }
-    } // end for RR upscale
-
-} // vc1_fill_RR_hw_struct
-
-/**
- * fill workload items that will load registers for HW decoder
- */
-static void vc1_fill_hw_struct(vc1_viddec_parser_t *parser, vc1_Info* pInfo, VC1D_SPR_REGS *spr)
-{
-    vc1_metadata_t *md = &pInfo->metadata;
-    vc1_PictureLayerHeader *pic = &pInfo->picLayerHeader;
-    int field = pic->CurrField;
-    int ptype;
-
-    ptype = pic->PTYPE;
-
-    LOG_CRIT("ptype = %d, field = %d, topfield = %d, slice = %d", ptype, pic->CurrField, pic->BottomField, pic->SLICE_ADDR);
-
-    /* Common to both fields */
-    BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_1, PROFILE, spr->stream_format1, md->PROFILE);
-
-    BF_WRITE(VC1_0_SEQPIC_CODED_SIZE, WIDTH, spr->coded_size, md->width);
-    BF_WRITE(VC1_0_SEQPIC_CODED_SIZE, HEIGHT, spr->coded_size, md->height);
-
-    BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_2, INTERLACE, spr->stream_format2, md->INTERLACE);
-
-    BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, LOOPFILTER,    spr->entrypoint1, md->LOOPFILTER);
-    BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, FASTUVMC,      spr->entrypoint1, md->FASTUVMC);
-    BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, EXTENDED_MV,   spr->entrypoint1, md->EXTENDED_MV);
-    BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, DQUANT,        spr->entrypoint1, md->DQUANT);
-    BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, VS_TRANSFORM,  spr->entrypoint1, md->VSTRANSFORM);
-    BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, OVERLAP,       spr->entrypoint1, md->OVERLAP);
-    BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, QUANTIZER,     spr->entrypoint1, md->QUANTIZER);
-    BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, EXTENDED_DMV,  spr->entrypoint1, md->EXTENDED_DMV);
-
-    /* if range reduction is indicated at seq. layer, populate range reduction registers for the frame*/
-    if(md->RANGERED)
-    {
-        vc1_fill_RR_hw_struct(parser, pInfo, spr );
-    } 
-    else 
-    { //range mapping
-        BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_Y_FLAG, spr->range_map, md->RANGE_MAPY_FLAG);
-        BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_Y, spr->range_map, md->RANGE_MAPY);
-        BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_UV_FLAG, spr->range_map, md->RANGE_MAPUV_FLAG);
-        BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_UV, spr->range_map, md->RANGE_MAPUV);
-    }
-
-    BF_WRITE(VC1_0_SEQPIC_FRAME_TYPE, FCM, spr->frame_type, pic->FCM);
-    BF_WRITE(VC1_0_SEQPIC_FRAME_TYPE, PTYPE, spr->frame_type, pic->PTYPE);
-
-    BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, RNDCTRL, spr->recon_control, md->RNDCTRL);
-    BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, UVSAMP, spr->recon_control, pic->UVSAMP);
-    BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, PQUANT, spr->recon_control, pic->PQUANT);
-    BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, HALFQP, spr->recon_control, pic->HALFQP);
-    BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, UNIFORM_QNT, spr->recon_control, pic->UniformQuant);
-    BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, POSTPROC, spr->recon_control, pic->POSTPROC);
-    BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, CONDOVER, spr->recon_control, pic->CONDOVER);
-    BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, PQINDEX_LE8, spr->recon_control, (pic->PQINDEX <= 8));
-
-    BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MVRANGE,   spr->mv_control, pic->MVRANGE);
-    if ( pic->MVMODE == VC1_MVMODE_INTENSCOMP)
-        BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MVMODE,    spr->mv_control, pic->MVMODE2);
-    else
-        BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MVMODE,    spr->mv_control, pic->MVMODE);
-    BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MVTAB,  spr->mv_control,  pic->MVTAB);
-    BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, DMVRANGE,  spr->mv_control, pic->DMVRANGE);
-    BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MV4SWITCH, spr->mv_control, pic->MV4SWITCH);
-    BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MBMODETAB, spr->mv_control, pic->MBMODETAB);
-    BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, NUMREF,    spr->mv_control,
-        pic->NUMREF || ((pic->PTYPE == VC1_B_FRAME) && ( pic->FCM == VC1_FCM_FIELD_INTERLACE )  ));
-    BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, REFFIELD,  spr->mv_control, pic->REFFIELD);
-
-    handle_intensity_compensation(parser, pInfo, spr);
-
-    BF_WRITE(VC1_0_SEQPIC_REFERENCE_B_FRACTION, BFRACTION_DEN, spr->ref_bfraction, pic->BFRACTION_DEN);
-    BF_WRITE(VC1_0_SEQPIC_REFERENCE_B_FRACTION, BFRACTION_NUM, spr->ref_bfraction, pic->BFRACTION_NUM);
-    BF_WRITE(VC1_0_SEQPIC_REFERENCE_B_FRACTION, REFDIST, spr->ref_bfraction, md->REFDIST);
-
-    // BLOCK CONTROL REGISTER Offset 0x2C
-    BF_WRITE( VC1_0_SEQPIC_BLOCK_CONTROL, CBPTAB, spr->blk_control, pic->CBPTAB);
-    BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, TTMFB, spr->blk_control, pic->TTMBF);
-    BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, TTFRM, spr->blk_control, pic->TTFRM);
-    BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, MV2BPTAB, spr->blk_control, pic->MV2BPTAB);
-    BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, MV4BPTAB, spr->blk_control, pic->MV4BPTAB);
-    if((field == 1) && (pic->SLICE_ADDR)) 
-    {
-        int mby = md->height * 2 + 2;
-        mby = (mby + 15 ) / 16;
-        pic->SLICE_ADDR -= (mby/2);
-    }
-    BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, INITIAL_MV_Y, spr->blk_control, pic->SLICE_ADDR);
-    BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, BP_RAW_ID2, spr->blk_control, md->bp_raw[0]);
-    BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, BP_RAW_ID1, spr->blk_control, md->bp_raw[1]);
-    BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, BP_RAW_ID0, spr->blk_control, md->bp_raw[2]);
-
-    BF_WRITE( VC1_0_SEQPIC_TRANSFORM_DATA, TRANSACFRM,  spr->trans_data, pic->TRANSACFRM);
-    BF_WRITE( VC1_0_SEQPIC_TRANSFORM_DATA, TRANSACFRM2, spr->trans_data, pic->TRANSACFRM2);
-    BF_WRITE( VC1_0_SEQPIC_TRANSFORM_DATA, TRANSDCTAB,  spr->trans_data, pic->TRANSDCTAB);
-
-    // When DQUANT is 1 or 2, we have the VOPDQUANT structure in the bitstream that
-    // controls the value calculated for ALTPQUANT
-    // ALTPQUANT must be in the range of 1 and 31 for it to be valid 
-    // DQUANTFRM is present only when DQUANT is 1 and ALTPQUANT setting should be dependent on DQUANT instead
-    if(md->DQUANT)
-    {
-        if(pic->PQDIFF == 7)
-            BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, PQUANT_ALT, spr->vop_dquant, pic->ABSPQ);
-        else if (pic->DQUANTFRM == 1)
-            BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, PQUANT_ALT, spr->vop_dquant, pic->PQUANT + pic->PQDIFF + 1);
-    }
-    BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, DQUANTFRM, spr->vop_dquant, pic->DQUANTFRM);
-    BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, DQPROFILE, spr->vop_dquant, pic->DQPROFILE);
-    BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, DQES,      spr->vop_dquant, pic->DQSBEDGE);
-    BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, DQBILEVEL, spr->vop_dquant, pic->DQBILEVEL);
-
-    BF_WRITE(VC1_0_SEQPIC_CURR_FRAME_ID,FCM, spr->ref_frm_id[VC1_FRAME_CURRENT_REF], pic->FCM );
-
-    if ( ptype == VC1_B_FRAME) {
-         // Forward reference is past reference and is the second temporally closest reference - hence minus_2
-         BF_WRITE(VC1_0_SEQPIC_FWD_REF_FRAME_ID, FCM, parser->spr.ref_frm_id[VC1_FRAME_PAST], parser->ref_frame[VC1_REF_FRAME_T_MINUS_2].fcm );
-         // Backward reference is future reference frame and is temporally the closest - hence minus_1
-         BF_WRITE(VC1_0_SEQPIC_BWD_REF_FRAME_ID, FCM, parser->spr.ref_frm_id[VC1_FRAME_FUTURE], parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm );
-    } else {
-         // Only Forward reference is valid and is the temporally closest reference - hence minus_1, backward is set same as forward
-         BF_WRITE(VC1_0_SEQPIC_FWD_REF_FRAME_ID, FCM, parser->spr.ref_frm_id[VC1_FRAME_PAST], parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm );
-         BF_WRITE(VC1_0_SEQPIC_BWD_REF_FRAME_ID, FCM, parser->spr.ref_frm_id[VC1_FRAME_FUTURE], parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm );
-    }
-
-    BF_WRITE( VC1_0_SEQPIC_FIELD_REF_FRAME_ID, TOP_FIELD,    spr->fieldref_ctrl_id, pic->BottomField);
-    BF_WRITE( VC1_0_SEQPIC_FIELD_REF_FRAME_ID, SECOND_FIELD, spr->fieldref_ctrl_id, pic->CurrField);
-    if(parser->info.picLayerHeader.PTYPE == VC1_I_FRAME)
-    {
-        BF_WRITE(VC1_0_SEQPIC_FIELD_REF_FRAME_ID, ANCHOR, spr->fieldref_ctrl_id, 1);
-    }
-    else
-    {
-        BF_WRITE(VC1_0_SEQPIC_FIELD_REF_FRAME_ID, ANCHOR, spr->fieldref_ctrl_id, parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].anchor[pic->CurrField]);
-    }
-
-    if( pic->FCM == VC1_FCM_FIELD_INTERLACE ) {
-        BF_WRITE(VC1_0_SEQPIC_IMAGE_STRUCTURE, IMG_STRUC, spr->imgstruct, (pic->BottomField) ? 2 : 1);
-    }
-
-    return;
-} // vc1_fill_hw_struct
-
-int32_t vc1_parse_emit_current_frame(void *parent, vc1_viddec_parser_t *parser)
-{
-   viddec_workload_item_t wi;
-   const uint32_t *pl;
-   int i;
-   int nitems;
-
-    if( parser->info.picLayerHeader.PTYPE == VC1_SKIPPED_FRAME ) {
-        translate_parser_info_to_frame_attributes( parent, parser );
-        return 0;
-    }
-
-   translate_parser_info_to_frame_attributes( parent, parser );
-   memset(&parser->spr, 0, sizeof(VC1D_SPR_REGS));
-   vc1_fill_hw_struct( parser, &parser->info, &parser->spr );
-
-   /* STUFF BSP Data Memory it into a variety of workload items */
-
-   pl = (const uint32_t *) &parser->spr;
-
-   // How many payloads must be generated
-   nitems = (sizeof(parser->spr) + 7) / 8; /* In QWORDs rounded up */
-
-
-   // Dump DMEM to an array of workitems
-   for( i = 0; (i < nitems) && ( (parser->info.picLayerHeader.SLICE_ADDR == 0) || parser->info.picture_info_has_changed ); i++ )
-   {
-      wi.vwi_type           = VIDDEC_WORKLOAD_DECODER_SPECIFIC;
-      wi.data.data_offset   = (unsigned int)pl - (unsigned int)&parser->spr; // offset within struct
-      wi.data.data_payload[0] = pl[0];
-      wi.data.data_payload[1] = pl[1];
-      pl += 2;
-
-      viddec_pm_append_workitem( parent, &wi );
-   }
-   
-   {
-      uint32_t bit, byte;
-      uint8_t is_emul;
-      viddec_pm_get_au_pos(parent, &bit, &byte, &is_emul);
-      // Send current bit offset and current slice
-      wi.vwi_type          = VIDDEC_WORKLOAD_VC1_BITOFFSET;
-      // If slice data starts in the middle of the emulation prevention sequence - 
-      // Eg: 00 00 03 01 - slice data starts at the second byte of 0s, we still feed the data 
-      // to the decoder starting at the first byte of 0s so that the decoder can detect the 
-      // emulation prevention. But the actual data starts are offset 8 in this bit sequence.
-      wi.vwi_payload[0]    = bit + (is_emul*8);
-      wi.vwi_payload[1]    = parser->info.picLayerHeader.SLICE_ADDR;
-      wi.vwi_payload[2]    = 0xdeaddead;
-      viddec_pm_append_workitem( parent, &wi );
-   }
-
-   viddec_pm_append_pixeldata( parent );
-
-   return(0);
-}
-
 /* sends VIDDEC_WORKLOAD_VC1_PAST_FRAME item */
 static inline void vc1_send_past_ref_items(void *parent)
 {
@@ -557,7 +90,7 @@
    wi.ref_frame.reference_id = 0;
    wi.ref_frame.luma_phys_addr = 0;
    wi.ref_frame.chroma_phys_addr = 0;
-   viddec_pm_append_workitem( parent, &wi );
+   viddec_pm_append_workitem( parent, &wi, false );
    return;
 }
 
@@ -569,7 +102,7 @@
    wi.ref_frame.reference_id = 0;
    wi.ref_frame.luma_phys_addr = 0;
    wi.ref_frame.chroma_phys_addr = 0;
-   viddec_pm_append_workitem( parent, &wi );
+   viddec_pm_append_workitem( parent, &wi, false );
    return;
 }
 
@@ -582,13 +115,612 @@
    wi.ref_reorder.ref_table_offset = 0;
    wi.ref_reorder.ref_reorder_00010203 = 0x01010203; //put reference frame index 1 as reference index 0
    wi.ref_reorder.ref_reorder_04050607 = 0x04050607; // index 4,5,6,7 stay the same
-   viddec_pm_append_workitem( parent, &wi );
+   viddec_pm_append_workitem( parent, &wi, false );
    return;
 } // send_reorder_ref_items
 
+
+/* sends VIDDEC_WORKLOAD_VC1_PAST_FRAME item */
+static inline void vc1_send_ref_fcm_items(void *parent, uint32_t past_fcm, uint32_t future_fcm)
+{
+   viddec_workload_item_t wi;
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_REF_FRAME_TYPE;
+   wi.vwi_payload[0]= 0;
+   wi.vwi_payload[1]= past_fcm;
+   wi.vwi_payload[2]= future_fcm;
+   viddec_pm_append_workitem( parent, &wi, false );
+   return;
+}
+
+
+
+/* send reorder frame item to host
+ * future frame gets push to past   */
+static inline void send_SEQ_ENTRY_registers(void *parent, vc1_viddec_parser_t *parser)
+{
+   uint32_t stream_format1 = 0;
+   uint32_t stream_format2 = 0;
+   uint32_t entrypoint1 = 0;
+   viddec_workload_item_t wi;
+
+   vc1_metadata_t *md = &(parser->info.metadata);
+
+
+
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_1, PROFILE, stream_format1, md->PROFILE);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_1, LEVEL, stream_format1, md->LEVEL);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_1, CHROMAFORMAT, stream_format1, md->CHROMAFORMAT);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_1, FRMRTQ, stream_format1, md->FRMRTQ);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_1, BITRTQ, stream_format1, md->BITRTQ);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_1, POSTPRO, stream_format1, md->POSTPROCFLAG);
+
+
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_2, PULLDOWN, stream_format2, md->PULLDOWN);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_2, INTERLACE, stream_format2, md->INTERLACE);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_2, TFCNTRFLAG, stream_format2, md->TFCNTRFLAG);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_2, FINTERPFLAG, stream_format2, md->FINTERPFLAG);
+   BF_WRITE(VC1_0_SEQPIC_STREAM_FORMAT_2, PSF, stream_format2, md->PSF);
+
+
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, BROKEN_LINK,   entrypoint1, md->BROKEN_LINK);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, CLOSED_ENTRY,  entrypoint1, md->CLOSED_ENTRY);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, PANSCAN_FLAG,  entrypoint1, md->PANSCAN_FLAG);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, REFDIST_FLAG,  entrypoint1, md->REFDIST_FLAG);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, LOOPFILTER,    entrypoint1, md->LOOPFILTER);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, FASTUVMC,      entrypoint1, md->FASTUVMC);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, EXTENDED_MV,   entrypoint1, md->EXTENDED_MV);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, DQUANT,        entrypoint1, md->DQUANT);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, VS_TRANSFORM,  entrypoint1, md->VSTRANSFORM);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, OVERLAP,       entrypoint1, md->OVERLAP);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, QUANTIZER,     entrypoint1, md->QUANTIZER);
+   BF_WRITE(VC1_0_SEQPIC_ENTRY_POINT_1, EXTENDED_DMV,  entrypoint1, md->EXTENDED_DMV);
+
+
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_SEQ_ENTRY;
+
+
+   wi.vwi_payload[0] = stream_format1;
+   wi.vwi_payload[1] = stream_format2;
+   wi.vwi_payload[2] = entrypoint1;
+
+   viddec_pm_append_workitem( parent, &wi, false );
+   return;
+} // send_reorder_ref_items
+
+
+/* send reorder frame item to host
+ * future frame gets push to past   */
+static inline void send_SIZE_AND_AP_RANGEMAP_registers(void *parent, vc1_viddec_parser_t *parser)
+{
+   uint32_t coded_size = 0;
+   uint32_t ap_range_map = 0;
+
+   viddec_workload_item_t wi;
+
+   vc1_metadata_t *md = &(parser->info.metadata);
+
+
+   BF_WRITE(VC1_0_SEQPIC_CODED_SIZE, WIDTH, coded_size, md->width);
+   BF_WRITE(VC1_0_SEQPIC_CODED_SIZE, HEIGHT, coded_size, md->height);
+
+
+   /* if range reduction is indicated at seq. layer, populate range reduction registers for the frame*/
+   if(VC1_PROFILE_ADVANCED == md->PROFILE)
+   {
+
+
+       BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_Y_FLAG, ap_range_map, md->RANGE_MAPY_FLAG);
+       BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_Y, ap_range_map, md->RANGE_MAPY);
+       BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_UV_FLAG, ap_range_map, md->RANGE_MAPUV_FLAG);
+       BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_UV, ap_range_map, md->RANGE_MAPUV);
+
+
+
+
+   }
+   else
+   {
+       ap_range_map = 0;
+   }
+
+
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_SIZE_AND_AP_RANGEMAP;
+
+   
+   wi.vwi_payload[0] = 0;
+   wi.vwi_payload[1] = coded_size;
+   wi.vwi_payload[2] = ap_range_map;
+
+   viddec_pm_append_workitem( parent, &wi, false );
+   return;
+} // send_reorder_ref_items
+
+
+
+/* send reorder frame item to host
+ * future frame gets push to past   */
+static inline void send_SLICE_FRAME_TYPE_INFO_registers(void *parent, vc1_viddec_parser_t *parser)
+{
+   uint32_t alt_frame_type = 0;
+   uint32_t frame_type = 0;
+
+   vc1_PictureLayerHeader *pic = &(parser->info.picLayerHeader);
+   viddec_workload_item_t wi;
+
+   vc1_metadata_t *md = &(parser->info.metadata);
+
+
+	BF_WRITE(VC1_0_SEQPIC_FRAME_TYPE, FCM, frame_type, pic->FCM);
+	BF_WRITE(VC1_0_SEQPIC_FRAME_TYPE, PTYPE, frame_type, pic->PTYPE);
+
+	alt_frame_type = frame_type;
+
+	if(VC1_PROFILE_ADVANCED == md->PROFILE)
+	{
+		if( (VC1_P_FRAME == pic->PTYPE)||(VC1_B_FRAME == pic->PTYPE) )
+		{
+			BF_WRITE(VC1_0_SEQPIC_ALT_FRAME_TYPE, PQUANT, alt_frame_type, pic->PQUANT);
+		}
+	}
+	else
+	{
+		if( VC1_SKIPPED_FRAME== pic->PTYPE)
+		{
+			BF_WRITE(VC1_0_SEQPIC_ALT_FRAME_TYPE, PQUANT, alt_frame_type, 0);
+		} else {
+			BF_WRITE(VC1_0_SEQPIC_ALT_FRAME_TYPE, PQUANT, alt_frame_type, pic->PQUANT);
+		}
+	}
+
+
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_SLICE_FRAME_TYPE_INFO;
+
+
+   wi.vwi_payload[0] = 0;
+   wi.vwi_payload[1] = frame_type;
+   wi.vwi_payload[2] = alt_frame_type;
+
+   viddec_pm_append_workitem( parent, &wi, false );
+   return;
+} // send_reorder_ref_items
+
+/* send reorder frame item to host
+ * future frame gets push to past   */
+static inline void send_SLICE_CONTROL_INFO_registers(void *parent, vc1_viddec_parser_t *parser)
+{
+   uint32_t recon_control = 0;
+   uint32_t mv_control = 0;
+   uint32_t blk_control = 0;
+
+   vc1_PictureLayerHeader *pic = &(parser->info.picLayerHeader);
+   viddec_workload_item_t wi;
+
+   int is_previous_ref_rr=0;
+
+   vc1_metadata_t *md = &(parser->info.metadata);
+
+
+   BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, RNDCTRL, recon_control, md->RNDCTRL);
+   BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, UVSAMP, recon_control, pic->UVSAMP);
+   BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, PQUANT, recon_control, pic->PQUANT);
+   BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, HALFQP, recon_control, pic->HALFQP);
+   BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, UNIFORM_QNT, recon_control, pic->UniformQuant);
+   BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, POSTPROC, recon_control, pic->POSTPROC);
+   BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, CONDOVER, recon_control, pic->CONDOVER);
+   BF_WRITE( VC1_0_SEQPIC_RECON_CONTROL, PQINDEX_LE8, recon_control, (pic->PQINDEX <= 8));
+
+   /* Get the range reduced status of the previous frame */
+   switch (pic->PTYPE)
+   {
+     case VC1_P_FRAME:
+     {
+         is_previous_ref_rr = parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].rr_frm;
+         break;
+     }
+     case VC1_B_FRAME:
+     {
+         is_previous_ref_rr = parser->ref_frame[VC1_REF_FRAME_T_MINUS_2].rr_frm;
+         break;
+     }
+     default:
+     {
+         break;
+     }
+   }
+
+   if(pic->RANGEREDFRM)
+   {
+
+       if(!is_previous_ref_rr)
+       {
+          BF_WRITE(VC1_0_SEQPIC_RECON_CONTROL, RANGE_REF_RED_EN, recon_control, 1);
+          BF_WRITE(VC1_0_SEQPIC_RECON_CONTROL, RANGE_REF_RED_TYPE, recon_control, 1);
+       }
+   }
+   else
+   {
+       /* if current frame is not RR but previous was RR,  scale up the reference frame ( RANGE_REF_RED_TYPE = 0) */
+       if(is_previous_ref_rr)
+       {
+           BF_WRITE(VC1_0_SEQPIC_RECON_CONTROL, RANGE_REF_RED_EN, recon_control, 1);
+           BF_WRITE(VC1_0_SEQPIC_RECON_CONTROL, RANGE_REF_RED_TYPE, recon_control, 0);
+       }
+   } // end for RR upscale
+
+
+
+
+
+   BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MVRANGE,   mv_control, pic->MVRANGE);
+   if ( pic->MVMODE == VC1_MVMODE_INTENSCOMP)
+       BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MVMODE,    mv_control, pic->MVMODE2);
+   else
+       BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MVMODE,    mv_control, pic->MVMODE);
+   BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MVTAB,  mv_control,  pic->MVTAB);
+   BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, DMVRANGE,  mv_control, pic->DMVRANGE);
+   BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MV4SWITCH, mv_control, pic->MV4SWITCH);
+   BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, MBMODETAB, mv_control, pic->MBMODETAB);
+   BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, NUMREF,    mv_control,
+       pic->NUMREF || ((pic->PTYPE == VC1_B_FRAME) && ( pic->FCM == VC1_FCM_FIELD_INTERLACE )  ));
+   BF_WRITE( VC1_0_SEQPIC_MOTION_VECTOR_CONTROL, REFFIELD,  mv_control, pic->REFFIELD);
+
+
+
+   // BLOCK CONTROL REGISTER Offset 0x2C
+   BF_WRITE( VC1_0_SEQPIC_BLOCK_CONTROL, CBPTAB, blk_control, pic->CBPTAB);
+   BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, TTMFB, blk_control, pic->TTMBF);
+   BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, TTFRM, blk_control, pic->TTFRM);
+   BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, MV2BPTAB, blk_control, pic->MV2BPTAB);
+   BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, MV4BPTAB, blk_control, pic->MV4BPTAB);
+   if((pic->CurrField == 1) && (pic->SLICE_ADDR))
+   {
+       int mby = md->height * 2 + 2;
+       mby = (mby + 15 ) / 16;
+       pic->SLICE_ADDR -= (mby/2);
+   }
+   BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, INITIAL_MV_Y, blk_control, pic->SLICE_ADDR);
+   BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, BP_RAW_ID2, blk_control, md->bp_raw[0]);
+   BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, BP_RAW_ID1, blk_control, md->bp_raw[1]);
+   BF_WRITE(VC1_0_SEQPIC_BLOCK_CONTROL, BP_RAW_ID0, blk_control, md->bp_raw[2]);
+
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_SLICE_CONTROL_INFO;
+
+
+   wi.vwi_payload[0] = recon_control;
+   wi.vwi_payload[1] = mv_control;
+   wi.vwi_payload[2] = blk_control;
+
+   viddec_pm_append_workitem( parent, &wi, false );
+   return;
+} // send_reorder_ref_items
+
+/* send reorder frame item to host
+ * future frame gets push to past   */
+static inline void send_SLICE_OTHER_INFO_registers(void *parent, vc1_viddec_parser_t *parser)
+{
+   uint32_t trans_data = 0;
+   uint32_t vop_dquant = 0;
+   uint32_t ref_bfraction = 0;
+
+   vc1_PictureLayerHeader *pic = &(parser->info.picLayerHeader);
+   viddec_workload_item_t wi;
+
+   vc1_metadata_t *md = &(parser->info.metadata);
+
+   BF_WRITE(VC1_0_SEQPIC_REFERENCE_B_FRACTION, BFRACTION_DEN, ref_bfraction, pic->BFRACTION_DEN);
+   BF_WRITE(VC1_0_SEQPIC_REFERENCE_B_FRACTION, BFRACTION_NUM, ref_bfraction, pic->BFRACTION_NUM);
+   BF_WRITE(VC1_0_SEQPIC_REFERENCE_B_FRACTION, REFDIST, ref_bfraction, md->REFDIST);
+
+   if(md->DQUANT)
+   {
+       if(pic->PQDIFF == 7)
+           BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, PQUANT_ALT, vop_dquant, pic->ABSPQ);
+       else if (pic->DQUANTFRM == 1)
+           BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, PQUANT_ALT, vop_dquant, pic->PQUANT + pic->PQDIFF + 1);
+   }
+   BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, DQUANTFRM, vop_dquant, pic->DQUANTFRM);
+   BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, DQPROFILE, vop_dquant, pic->DQPROFILE);
+   BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, DQES,      vop_dquant, pic->DQSBEDGE);
+   BF_WRITE( VC1_0_SEQPIC_VOP_DEQUANT, DQBILEVEL, vop_dquant, pic->DQBILEVEL);
+
+   BF_WRITE( VC1_0_SEQPIC_TRANSFORM_DATA, TRANSACFRM,  trans_data, pic->TRANSACFRM);
+   BF_WRITE( VC1_0_SEQPIC_TRANSFORM_DATA, TRANSACFRM2, trans_data, pic->TRANSACFRM2);
+   BF_WRITE( VC1_0_SEQPIC_TRANSFORM_DATA, TRANSDCTAB,  trans_data, pic->TRANSDCTAB);
+
+
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_SLICE_OTHER_INFO;
+
+
+   wi.vwi_payload[0] = trans_data;
+   wi.vwi_payload[1] = vop_dquant;
+   wi.vwi_payload[2] = ref_bfraction;
+
+   viddec_pm_append_workitem( parent, &wi, false );
+   return;
+} // send_reorder_ref_items
+
+
+
+/* send reorder frame item to host
+ * future frame gets push to past   */
+static inline void send_STRUCT_FIELD_AND_SMP_RANGEMAP_INFO_registers(void *parent, vc1_viddec_parser_t *parser)
+{
+   uint32_t imgstruct = 0;
+   uint32_t fieldref_ctrl_id = 0;
+   uint32_t smp_rangemap = 0;
+
+   vc1_PictureLayerHeader *pic = &(parser->info.picLayerHeader);
+   viddec_workload_item_t wi;
+
+   vc1_metadata_t *md = &(parser->info.metadata);
+
+   if( pic->FCM == VC1_FCM_FIELD_INTERLACE ) {
+       BF_WRITE(VC1_0_SEQPIC_IMAGE_STRUCTURE, IMG_STRUC, imgstruct, (pic->BottomField) ? 2 : 1);
+   }
+   
+   BF_WRITE( VC1_0_SEQPIC_FIELD_REF_FRAME_ID, TOP_FIELD,    fieldref_ctrl_id, pic->BottomField);
+   BF_WRITE( VC1_0_SEQPIC_FIELD_REF_FRAME_ID, SECOND_FIELD, fieldref_ctrl_id, pic->CurrField);
+   if(parser->info.picLayerHeader.PTYPE == VC1_I_FRAME)
+   {
+     BF_WRITE(VC1_0_SEQPIC_FIELD_REF_FRAME_ID, ANCHOR, fieldref_ctrl_id, 1);
+   }
+   else
+   {
+     BF_WRITE(VC1_0_SEQPIC_FIELD_REF_FRAME_ID, ANCHOR, fieldref_ctrl_id, parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].anchor[pic->CurrField]);
+   }
+
+   if(VC1_PROFILE_ADVANCED != md->PROFILE)
+   {
+      if(pic->RANGEREDFRM)
+      {
+         //BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_Y_FLAG, smp_rangemap, md->RANGE_MAPY_FLAG);
+         //BF_WRITE( VC1_0_SEQPIC_RANGE_MAP, RANGE_MAP_UV_FLAG, smp_rangemap, md->RANGE_MAPUV_FLAG);
+         smp_rangemap = 0x11;
+      }
+
+   }
+
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_STRUCT_FIELD_AND_SMP_RANGEMAP_INFO;
+
+
+   wi.vwi_payload[0] = imgstruct;
+   wi.vwi_payload[1] = fieldref_ctrl_id;
+   wi.vwi_payload[2] = smp_rangemap;
+
+   viddec_pm_append_workitem( parent, &wi, false );
+   return;
+} // send_reorder_ref_items
+
+
+/* send reorder frame item to host
+ * future frame gets push to past   */
+static inline void send_INT_COM_registers(void *parent, vc1_viddec_parser_t *parser)
+{
+   uint32_t intcomp_fwd_top = 0;
+   uint32_t intcomp_fwd_bot = 0;
+   uint32_t intcomp_bwd_top = 0;
+   uint32_t intcomp_bwd_bot = 0;
+   uint32_t intcomp_cur = 0;
+
+   uint32_t POS_2nd_INTCOMP = 13;
+   uint32_t MASK_1st_INTCOMP = 0x1fff;
+   uint32_t MASK_2nd_INTCOMP = 0x3ffe000;
+
+   vc1_PictureLayerHeader *pic = &(parser->info.picLayerHeader);
+   viddec_workload_item_t wi;
+
+   vc1_metadata_t *md = &(parser->info.metadata);
+
+
+
+   if(VC1_SKIPPED_FRAME == pic->PTYPE)
+   {
+      parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top =0;
+      return;
+   }
+
+   if( VC1_FCM_FIELD_INTERLACE != pic->FCM )
+   {
+
+      BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, intcomp_cur, 1);
+      BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SCALE_1, intcomp_cur, pic->LUMSCALE);
+      BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SHIFT_1, intcomp_cur, pic->LUMSHIFT);
+
+      if ( !((pic->MVMODE == VC1_MVMODE_INTENSCOMP) || (pic->INTCOMP)) )
+         intcomp_cur = 0;
+
+      if( (VC1_BI_FRAME==pic->PTYPE)||(VC1_B_FRAME==pic->PTYPE)  )
+      {
+         parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = 0;
+         parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_bot = 0;
+
+         intcomp_bwd_top = parser->intcomp_top[0];
+         intcomp_bwd_bot = parser->intcomp_bot[0];
+         intcomp_fwd_bot = parser->intcomp_bot[1];
+
+
+         if( parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].id != (-1) )
+         {
+            if (VC1_SKIPPED_FRAME != parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].type)
+                  intcomp_fwd_top = parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].intcomp_top;
+         }
+         else
+         {
+            if (VC1_SKIPPED_FRAME != parser->ref_frame[VC1_REF_FRAME_T_MINUS_2].type)
+               intcomp_fwd_top = parser->intcomp_top[1];
+         }
+      }
+      else
+      {  //I,P TYPE
+
+         parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = intcomp_cur;
+
+         if(VC1_FCM_FIELD_INTERLACE == parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm)
+         {
+            intcomp_fwd_top = parser->intcomp_top[1];
+            intcomp_fwd_top |= intcomp_cur << POS_2nd_INTCOMP;
+
+            intcomp_fwd_bot = parser->intcomp_bot[1];
+            intcomp_fwd_bot |= intcomp_cur << POS_2nd_INTCOMP;
+         }
+         else
+         {
+            intcomp_fwd_top = intcomp_cur;// << POS_2nd_INTCOMP;
+            intcomp_fwd_bot = 0;
+         }
+      }
+   }
+   else
+   {
+      //FIELD INTERLACE
+      //if(0!=md->INTCOMPFIELD)
+      //No debugging
+
+      if (md->INTCOMPFIELD == VC1_INTCOMP_BOTTOM_FIELD)
+      {
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, intcomp_cur, 1);
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SCALE_2, intcomp_cur, md->LUMSCALE2);
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SHIFT_2, intcomp_cur, md->LUMSHIFT2);
+      }
+      else
+      {
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_1, intcomp_cur, 1);
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SCALE_1, intcomp_cur, pic->LUMSCALE);
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SHIFT_1, intcomp_cur, pic->LUMSHIFT);
+      }
+
+      if(md->INTCOMPFIELD == VC1_INTCOMP_BOTH_FIELD)
+      {
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, INT_COMP_2, intcomp_cur, 1);
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SCALE_2, intcomp_cur, md->LUMSCALE2);
+         BF_WRITE(VC1_0_SEQPIC_INTENSITY_COMPENSATION, LUMA_SHIFT_2, intcomp_cur, md->LUMSHIFT2);
+      }
+
+      if(pic->MVMODE != VC1_MVMODE_INTENSCOMP)
+      {
+         intcomp_cur = 0;
+      }
+
+      if(pic->CurrField == 0)
+      {
+         if(pic->TFF)
+         {
+            parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = intcomp_cur;
+         }
+         else
+         {
+            parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_bot = intcomp_cur;
+         }
+      }
+      else
+      {
+         if(pic->TFF)
+         {
+            parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_bot = intcomp_cur;
+         }
+         else
+         {
+            parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].intcomp_top = intcomp_cur;
+         }
+      }
+
+      if(pic->CurrField == 1)
+      {  //SECOND FIELD
+
+         if(VC1_B_FRAME != pic->PTYPE)
+         {
+            if(pic->TFF)
+            {
+               intcomp_bwd_top = intcomp_cur & MASK_1st_INTCOMP;
+
+               intcomp_fwd_bot = (parser->intcomp_bot[1] & MASK_2nd_INTCOMP) >> POS_2nd_INTCOMP;  //???????
+               intcomp_fwd_bot |= (intcomp_cur & MASK_2nd_INTCOMP);
+
+               intcomp_fwd_top = parser->intcomp_top[1];
+            }
+            else
+            {
+               intcomp_bwd_bot= (intcomp_cur & MASK_2nd_INTCOMP)>>POS_2nd_INTCOMP;
+
+               intcomp_fwd_top = (parser->intcomp_top[1] & MASK_2nd_INTCOMP) >> POS_2nd_INTCOMP;
+               intcomp_fwd_top |= (intcomp_cur&MASK_1st_INTCOMP) << POS_2nd_INTCOMP;
+
+               intcomp_fwd_bot = parser->intcomp_bot[1];
+            }
+         }
+         else
+         {    //B TYPE
+            intcomp_fwd_top = parser->intcomp_top[1];
+            intcomp_fwd_bot = parser->intcomp_bot[1];
+
+            intcomp_bwd_top = parser->intcomp_top[0];
+            intcomp_bwd_bot = parser->intcomp_bot[0];
+         }
+      }
+      else
+      {  //FIRST FILED
+
+         if( (VC1_B_FRAME==pic->PTYPE)||(VC1_BI_FRAME==pic->PTYPE) )
+         {
+            if(VC1_SKIPPED_FRAME!=parser->ref_frame[VC1_REF_FRAME_T_MINUS_2].type)
+            {
+               intcomp_fwd_top = parser->intcomp_top[1];
+               intcomp_fwd_bot = parser->intcomp_bot[1];
+            }
+
+            intcomp_bwd_top = parser->intcomp_top[0];
+            intcomp_bwd_bot = parser->intcomp_bot[0];
+
+         }
+         else
+         {  //I,P TYPE
+
+            intcomp_fwd_top = parser->intcomp_top[1] & MASK_1st_INTCOMP;
+            intcomp_fwd_top |= (intcomp_cur&MASK_1st_INTCOMP)<<POS_2nd_INTCOMP;
+
+            intcomp_fwd_bot = parser->intcomp_bot[1] & MASK_1st_INTCOMP;
+            intcomp_fwd_bot |= (intcomp_cur & MASK_2nd_INTCOMP);
+         }   //pic->PTYPE == I,P TYPE
+      }   //pic->CurrField == 0
+   }  //VC1_FCM_FIELD_INTERLACE != pic->FCM
+
+   if ( (VC1_B_FRAME != pic->PTYPE) && (VC1_BI_FRAME != pic->PTYPE) )
+   {
+      parser->intcomp_top[1] = intcomp_fwd_top;
+      parser->intcomp_bot[1] = intcomp_fwd_bot;
+
+      parser->intcomp_top[0] = intcomp_bwd_top;
+      parser->intcomp_bot[0] = intcomp_bwd_bot;
+   }
+
+   //OS_INFO("intcomp_fwd_top = %d\n", intcomp_fwd_top);
+   //OS_INFO("intcomp_fwd_bot = %d\n", intcomp_fwd_bot);
+
+
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_INT_COM_FW;
+
+   wi.vwi_payload[0] = 0;
+   wi.vwi_payload[1] = intcomp_fwd_top;
+   wi.vwi_payload[2] = intcomp_fwd_bot;
+
+   viddec_pm_append_workitem( parent, &wi, false );
+
+   wi.vwi_type = VIDDEC_WORKLOAD_VC1_REGS_INT_COM_BW;
+
+   wi.vwi_payload[0] = 0;
+   wi.vwi_payload[1] = intcomp_bwd_top;
+   wi.vwi_payload[2] = intcomp_bwd_bot;
+
+   viddec_pm_append_workitem( parent, &wi, false );
+
+
+   return;
+} // send_reorder_ref_items
+
+
 /** update workload with more workload items for ref and update values to store...
  */
-void vc1_start_new_frame(void *parent, vc1_viddec_parser_t *parser)
+void vc1_parse_emit_frame_start(void *parent, vc1_viddec_parser_t *parser)
 {
    vc1_metadata_t *md = &(parser->info.metadata);
    viddec_workload_t *wl = viddec_pm_get_header(parent);
@@ -630,17 +762,20 @@
       {
           vc1_send_past_ref_items(parent);
           vc1_send_future_ref_items(parent);
+          vc1_send_ref_fcm_items(parent, parser->ref_frame[VC1_REF_FRAME_T_MINUS_2].fcm, parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm);
           break;
       }
       case VC1_SKIPPED_FRAME:
       {
          wl->is_reference_frame |= WORKLOAD_SKIPPED_FRAME;
            vc1_send_past_ref_items(parent);
+           vc1_send_ref_fcm_items(parent, parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm, vc1_PictureFormatNone);
           break;
       }
       case VC1_P_FRAME:
       {
           vc1_send_past_ref_items( parent);
+          vc1_send_ref_fcm_items(parent, parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].fcm, vc1_PictureFormatNone);
          break;
       }
     default:
@@ -668,15 +803,149 @@
         parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].type = parser->info.picLayerHeader.PTYPE;
         parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].rr_en = md->RANGERED;
         parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].rr_frm = parser->info.picLayerHeader.RANGEREDFRM;
+        parser->ref_frame[VC1_REF_FRAME_T_MINUS_0].tff = parser->info.picLayerHeader.TFF;
 
         LOG_CRIT("anchor[0] = %d, anchor[1] = %d",
             parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].anchor[0],
             parser->ref_frame[VC1_REF_FRAME_T_MINUS_1].anchor[1] );
     }
 
+    if( parser->info.picLayerHeader.PTYPE == VC1_SKIPPED_FRAME )
+    {
+       translate_parser_info_to_frame_attributes( parent, parser );
+       return;
+    }
+
+    translate_parser_info_to_frame_attributes( parent, parser );
+
+
+    send_SEQ_ENTRY_registers(parent, parser);
+    send_SIZE_AND_AP_RANGEMAP_registers(parent, parser);
+    send_SLICE_FRAME_TYPE_INFO_registers(parent, parser);
+    send_SLICE_CONTROL_INFO_registers(parent, parser);
+    send_SLICE_OTHER_INFO_registers(parent, parser);
+    send_STRUCT_FIELD_AND_SMP_RANGEMAP_INFO_registers(parent, parser);
+    send_INT_COM_registers(parent, parser);
+
+    {
+       viddec_workload_item_t wi;
+       uint32_t bit, byte;
+       uint8_t is_emul = 0;
+
+       viddec_pm_get_au_pos(parent, &bit, &byte, &is_emul);
+
+       // Send current bit offset and current slice
+       wi.vwi_type          = VIDDEC_WORKLOAD_VC1_BITOFFSET;
+
+       // If slice data starts in the middle of the emulation prevention sequence -
+       // Special Case1----[is_emul = 1]:
+       // Eg: 00 00 03 01 - slice data starts at the second byte of 0s, we still feed the data
+       // to the decoder starting at the first byte of 0s so that the decoder can detect the
+       // emulation prevention. But the actual data starts are offset 8 in this bit sequence.
+
+	   // Specail Case 2----[is_emul = 2]:
+	   // If slice data starts in the middle of the emulation prevention sequence -
+	   // Eg: [00 00] 03 00 - slice data starts at the third byte (0x03), we need readout this byte.
+	   //
+
+       wi.vwi_payload[0]    = bit + (is_emul*8) ;
+       wi.vwi_payload[1]    = 0xdeaddead;
+       wi.vwi_payload[2]    = 0xdeaddead;
+       viddec_pm_append_workitem( parent, &wi, false );
+    }
+
+
+    viddec_pm_append_pixeldata( parent );
+
     return;
 } // vc1_start_new_frame
 
+
+void vc1_parse_emit_second_field_start(void *parent, vc1_viddec_parser_t *parser)
+{
+
+   send_SLICE_FRAME_TYPE_INFO_registers(parent, parser);
+   send_SLICE_CONTROL_INFO_registers(parent, parser);
+   send_SLICE_OTHER_INFO_registers(parent, parser);
+   send_STRUCT_FIELD_AND_SMP_RANGEMAP_INFO_registers(parent, parser);
+   send_INT_COM_registers(parent, parser);
+
+    {
+       viddec_workload_item_t wi;
+       uint32_t bit, byte;
+       uint8_t is_emul = 0;
+
+       viddec_pm_get_au_pos(parent, &bit, &byte, &is_emul);
+
+
+	   // Send current bit offset and current slice
+       wi.vwi_type          = VIDDEC_WORKLOAD_VC1_BITOFFSET;
+       // If slice data starts in the middle of the emulation prevention sequence -
+       // Special Case1----[is_emul = 1]:
+       // Eg: 00 00 03 01 - slice data starts at the second byte of 0s, we still feed the data
+       // to the decoder starting at the first byte of 0s so that the decoder can detect the
+       // emulation prevention. But the actual data starts are offset 8 in this bit sequence.
+
+	   // Specail Case 2----[is_emul = 2]:
+	   // If slice data starts in the middle of the emulation prevention sequence -
+	   // Eg: [00 00] 03 00 - slice data starts at the third byte (0x03), we need readout this byte.
+	   //
+
+
+		wi.vwi_payload[0]	 = bit + (is_emul*8);
+		wi.vwi_payload[1]	 = 0xdeaddead;
+		wi.vwi_payload[2]	 = 0xdeaddead;
+		viddec_pm_append_workitem( parent, &wi, false );
+    }
+
+    viddec_pm_append_pixeldata( parent );
+
+   return;
+
+}
+
+
+void vc1_parse_emit_current_slice(void *parent, vc1_viddec_parser_t *parser)
+{
+   send_SLICE_FRAME_TYPE_INFO_registers(parent, parser);
+   send_SLICE_CONTROL_INFO_registers(parent, parser);
+   send_SLICE_OTHER_INFO_registers(parent, parser);
+   //send_STRUCT_FIELD_AND_SMP_RANGEMAP_INFO_registers(parent, parser);
+   //send_INT_COM_registers(parent, parser);
+
+    {
+       viddec_workload_item_t wi;
+       uint32_t bit, byte;
+       uint8_t is_emul = 0;
+
+       viddec_pm_get_au_pos(parent, &bit, &byte, &is_emul);
+
+      // Send current bit offset and current slice
+       wi.vwi_type          = VIDDEC_WORKLOAD_VC1_BITOFFSET;
+
+	  // If slice data starts in the middle of the emulation prevention sequence -
+	  // Special Case1----[is_emul = 1]:
+	  // Eg: 00 00 03 01 - slice data starts at the second byte of 0s, we still feed the data
+	  // to the decoder starting at the first byte of 0s so that the decoder can detect the
+	  // emulation prevention. But the actual data starts are offset 8 in this bit sequence.
+
+	  // Specail Case 2----[is_emul = 2]:
+	  // If slice data starts in the middle of the emulation prevention sequence -
+	  // Eg: [00 00] 03 00 - slice data starts at the third byte (0x03), we need readout this byte.
+	  //
+
+       wi.vwi_payload[0]    = bit + (is_emul*8);
+       wi.vwi_payload[1]    = 0xdeaddead;
+       wi.vwi_payload[2]    = 0xdeaddead;
+       viddec_pm_append_workitem( parent, &wi, false );
+    }
+
+    viddec_pm_append_pixeldata( parent );
+
+   return;
+}
+
+
 void vc1_end_frame(vc1_viddec_parser_t *parser)
 {
     /* update status of reference frames */
diff --git a/mix_vbp/viddec_fw/fw/include/viddec_fw_version.h b/mix_vbp/viddec_fw/fw/include/viddec_fw_version.h
index 099be69..227dd67 100644
--- a/mix_vbp/viddec_fw/fw/include/viddec_fw_version.h
+++ b/mix_vbp/viddec_fw/fw/include/viddec_fw_version.h
@@ -3,5 +3,5 @@
 
 #define VIDDEC_FW_MAJOR_NUM 0
 #define VIDDEC_FW_MINOR_NUM 8
-#define VIDDEC_FW_BUILD_NUM 11
+#define VIDDEC_FW_BUILD_NUM 16
 #endif
diff --git a/mix_vbp/viddec_fw/fw/parser/include/viddec_emitter.h b/mix_vbp/viddec_fw/fw/parser/include/viddec_emitter.h
index d887501..a8efafb 100644
--- a/mix_vbp/viddec_fw/fw/parser/include/viddec_emitter.h
+++ b/mix_vbp/viddec_fw/fw/parser/include/viddec_emitter.h
@@ -1,7 +1,10 @@
 #ifndef VIDDEC_EMITTER_H
 #define VIDDEC_EMITTER_H
-
+#ifndef ANDROID
+#include <stdint.h>
+#else
 #include "../../include/stdint.h"
+#endif
 #ifndef HOST_ONLY
 #define DDR_MEM_MASK 0x80000000
 #else
diff --git a/mix_vbp/viddec_fw/fw/parser/include/viddec_parser_ops.h b/mix_vbp/viddec_fw/fw/parser/include/viddec_parser_ops.h
index a61e340..0c643fa 100644
--- a/mix_vbp/viddec_fw/fw/parser/include/viddec_parser_ops.h
+++ b/mix_vbp/viddec_fw/fw/parser/include/viddec_parser_ops.h
@@ -55,13 +55,9 @@
  */
 int32_t viddec_pm_skip_bits(void *parent, uint32_t num_bits);
 
-/* This function appends a work item to current workload.
+/* This function appends a work item to current/next workload.
  */
-int32_t viddec_pm_append_workitem(void *parent, viddec_workload_item_t *item);
-
-/* This function appends a work item to next workload.
- */
-int32_t viddec_pm_append_workitem_next(void *parent, viddec_workload_item_t *item);
+int32_t viddec_pm_append_workitem(void *parent, viddec_workload_item_t *item, uint32_t next);
 
 /* This function gets current byte and bit positions and information on whether an emulation byte is present after
 current byte.
diff --git a/mix_vbp/viddec_fw/fw/parser/include/viddec_pm_utils_bstream.h b/mix_vbp/viddec_fw/fw/parser/include/viddec_pm_utils_bstream.h
index 1971a36..8dc2c53 100644
--- a/mix_vbp/viddec_fw/fw/parser/include/viddec_pm_utils_bstream.h
+++ b/mix_vbp/viddec_fw/fw/parser/include/viddec_pm_utils_bstream.h
@@ -4,7 +4,6 @@
 #include "viddec_pm_utils_list.h"
 
 #define CUBBY_SIZE 1024
-//#define CUBBY_SIZE 512
 #define SCRATCH_SIZE 20
 #define MIN_DATA     8
 
@@ -32,7 +31,7 @@
 typedef struct
 {
 #ifdef VBP
-	/* counter of emulation preventation byte */
+	/* 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
@@ -64,6 +63,13 @@
 
 uint8_t viddec_pm_utils_bstream_nomorerbspdata(viddec_pm_utils_bstream_cxt_t *cxt);
 
+void viddec_pm_utils_skip_if_current_is_emulation(viddec_pm_utils_bstream_cxt_t *cxt);
+
+/*
+  This function gets bit and byte position of where we are in the current AU. We always return the position of next byte to be
+  read.
+  is_emul on true indicates we are on second zero byte in emulation prevention sequence.
+ */
 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;
@@ -74,6 +80,7 @@
     {
         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);
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_h264_parser.c b/mix_vbp/viddec_fw/fw/parser/vbp_h264_parser.c
index 8695ef7..1b6b3d6 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_h264_parser.c
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_h264_parser.c
@@ -836,7 +836,7 @@
 	int pic_data_index = query_data->num_pictures - 1;
 	if (pic_data_index < 0)
 	{
-		WTRACE("MB address does not start from 0!");
+		ETRACE("MB address does not start from 0!");
 		return VBP_DATA;
 	}
 		
@@ -1256,6 +1256,7 @@
 	if (cxt->parse_cubby.size < 6)
 	{
 		/* need at least 6 bytes to start parsing the structure, see spec 15 */
+                ETRACE ("Need at least 6 bytes to start parsing\n" );
 		return VBP_DATA;
 	}
   
@@ -1299,6 +1300,8 @@
 		if (cur_data - cxt->parse_cubby.buf + 2 > cxt->parse_cubby.size)
 		{
 			/* need at least 2 bytes to parse sequence_parameter_set_length */
+
+		        ETRACE ("Need at least 2 bytes to parse sps." );
 			return VBP_DATA;
 		}
 
@@ -1311,6 +1314,7 @@
 		if (cur_data - cxt->parse_cubby.buf + sequence_parameter_set_length > cxt->parse_cubby.size)
 		{
 			/* need at least sequence_parameter_set_length bytes for SPS */
+		        ETRACE ("Need at least sequence paramter set length bytes." );
 			return VBP_DATA;
 		}
 
@@ -1328,6 +1332,7 @@
 	if (cur_data - cxt->parse_cubby.buf + 1 > cxt->parse_cubby.size)
 	{
 		/* need at least one more byte to parse num_of_picture_parameter_sets */
+		ETRACE ("need at least one more byte to parse num_of_picture_parameter_sets." );
 		return VBP_DATA;
 	}
 
@@ -1342,6 +1347,7 @@
 		if (cur_data - cxt->parse_cubby.buf + 2 > cxt->parse_cubby.size)
 		{
 			/* need at least 2 bytes to parse picture_parameter_set_length */
+                        ETRACE ("need at least 2 bytes to parse picture_parameter_set_length.");
 			return VBP_DATA;
 		}
 
@@ -1353,6 +1359,7 @@
 		if (cur_data - cxt->parse_cubby.buf + picture_parameter_set_length > cxt->parse_cubby.size)
 		{
 			/* need at least picture_parameter_set_length bytes for PPS */
+                        ETRACE("need at least picture_parameter_set_length bytes for PPS");
 			return VBP_DATA;
 		}
 
@@ -1420,12 +1427,26 @@
 	vbp_data_h264* query_data = (vbp_data_h264*)pcontext->query_data;
 	int i;
 
+#ifndef ANDROID
 	for (i = 0; i < MAX_NUM_PICTURES; i++)
 	{
 		query_data->pic_data[i].num_slices = 0;
 	}
 	query_data->num_pictures = 0;
+#else
+        ITRACE("pcontext->h264_frame_flag = %d\n", pcontext->h264_frame_flag);
+ 
+	if(pcontext->h264_frame_flag == 0)
+        {
+             for (i = 0; i < MAX_NUM_PICTURES; i++)
+             {
+                 query_data->pic_data[i].num_slices = 0;
+             }
+             query_data->num_pictures = 0;
+        }
 
+        pcontext->h264_frame_flag = 1;
+#endif
 	
   	cubby = &(cxt->parse_cubby);
 
@@ -1439,34 +1460,34 @@
 #ifndef ANDROID
   	while (size_left >= NAL_length_size)
   	{
-    	NAL_length = vbp_get_NAL_length_h264(cubby->buf + size_parsed);    	
+             NAL_length = vbp_get_NAL_length_h264(cubby->buf + size_parsed);    	
 
-    	size_parsed += NAL_length_size;
+    	     size_parsed += NAL_length_size;
 #else
 	while (size_left > 0)
 	{
-	NAL_length = size_left;
+	     NAL_length = size_left;
 #endif
     	  
-    	cxt->list.data[cxt->list.num_items].stpos = size_parsed;
-    	size_parsed += NAL_length; /* skip NAL bytes */
-    	/* end position is exclusive */
-    	cxt->list.data[cxt->list.num_items].edpos = size_parsed; 
-    	cxt->list.num_items++;
-    	if (cxt->list.num_items >= MAX_IBUFS_PER_SC)
-      	{
+    	     cxt->list.data[cxt->list.num_items].stpos = size_parsed;
+    	     size_parsed += NAL_length; /* skip NAL bytes */
+    	     /* end position is exclusive */
+    	     cxt->list.data[cxt->list.num_items].edpos = size_parsed; 
+    	     cxt->list.num_items++;
+    	     if (cxt->list.num_items >= MAX_IBUFS_PER_SC)
+      	     {
       		ETRACE("num of list items exceeds the limit (%d).", MAX_IBUFS_PER_SC);
       		break;
-      	}
+             }  
       
-    	size_left = cubby->size - size_parsed;
-   	}
+             size_left = cubby->size - size_parsed;
+        }
 
-  	if (size_left != 0)
-  	{
-    	WTRACE("Elementary stream is not aligned (%d).", size_left);
-  	}
-  	return VBP_OK;
+        if (size_left != 0)
+        {
+             WTRACE("Elementary stream is not aligned (%d).", size_left);
+        }
+        return VBP_OK;
 }
 
 /**
@@ -1488,7 +1509,7 @@
 	switch (parser->info.nal_unit_type)
     {
 		case h264_NAL_UNIT_TYPE_SLICE:       		
-       	/* ITRACE("slice header is parsed."); */
+       	ITRACE("slice header is parsed."); 
        	error = vbp_add_pic_data_h264(pcontext, i);
        	if (VBP_OK == error)
        	{
@@ -1497,7 +1518,7 @@
        	break;
        		
        	case  h264_NAL_UNIT_TYPE_IDR:
-       	/* ITRACE("IDR header is parsed."); */
+       	ITRACE("IDR header is parsed."); 
        	error = vbp_add_pic_data_h264(pcontext, i);
        	if (VBP_OK == error)
        	{
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_mp42_parser.c b/mix_vbp/viddec_fw/fw/parser/vbp_mp42_parser.c
index 87beca4..cabdb29 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_mp42_parser.c
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_mp42_parser.c
@@ -551,13 +551,13 @@
 					*sc_end_pos = size;
 					phase = 3;
 
-					if (normal_sc) {
-					} else {
-						/* For short start code since start code is in one nibble just return at this point */
-						phase += 1;
-						ret = 1;
-						break;
-					}
+					//if (normal_sc) {
+					//} else {
+					//	/* For short start code since start code is in one nibble just return at this point */
+					//	phase += 1;
+					//	ret = 1;
+					//	break;
+					//}
 				}
 				ptr++;
 				size++;
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_trace.h b/mix_vbp/viddec_fw/fw/parser/vbp_trace.h
index 9f2a21c..71e76fb 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_trace.h
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_trace.h
@@ -17,14 +17,24 @@
 
 #ifdef VBP_TRACE /* if VBP_TRACE is defined*/
 
+#ifndef ANDROID
+
 #include <stdio.h>
 #include <stdarg.h>
 
 extern void vbp_trace_util(const char* cat, const char* fun, int line, const char* format, ...);
-	
 #define VBP_TRACE_UTIL(cat, format, ...) \
 vbp_trace_util(cat, __FUNCTION__, __LINE__, format,  ##__VA_ARGS__)
 
+#else 
+
+#include <utils/Log.h>
+#define VBP_TRACE_UTIL(cat, format,  ...) \
+__android_log_print(ANDROID_LOG_VERBOSE, "mixvbp : "cat, "%s() : %d: "format, \
+__FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#endif
+
 
 #define ETRACE(format, ...) VBP_TRACE_UTIL("ERROR:   ",  format, ##__VA_ARGS__)
 #define WTRACE(format, ...) VBP_TRACE_UTIL("WARNING: ",  format, ##__VA_ARGS__)
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_utils.c b/mix_vbp/viddec_fw/fw/parser/vbp_utils.c
index c350342..e0a9806 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_utils.c
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_utils.c
@@ -144,6 +144,10 @@
 	*/
 	error = pcontext->func_init_parser_entries(pcontext);
 
+#ifdef ANDROID
+        pcontext->h264_frame_flag = 0;
+#endif
+
 cleanup:
 
 	if (VBP_OK != error)
@@ -545,6 +549,10 @@
 	{
 		*data = NULL;
 	}
+#ifdef ANDROID
+	pcontext->h264_frame_flag = 0;
+#endif
+
 	return error;
 }
 
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_utils.h b/mix_vbp/viddec_fw/fw/parser/vbp_utils.h
index 67ff3e8..69202f8 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_utils.h
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_utils.h
@@ -76,6 +76,10 @@
 	function_process_parsing_result func_process_parsing_result;
 	function_populate_query_data 	func_populate_query_data;
 
+#ifdef ANDROID
+	uint32 h264_frame_flag;
+#endif
+
 };
 
 /**
diff --git a/mix_vbp/viddec_fw/fw/parser/vbp_vc1_parser.c b/mix_vbp/viddec_fw/fw/parser/vbp_vc1_parser.c
index 502cdc6..4af107a 100644
--- a/mix_vbp/viddec_fw/fw/parser/vbp_vc1_parser.c
+++ b/mix_vbp/viddec_fw/fw/parser/vbp_vc1_parser.c
@@ -292,7 +292,8 @@
 			/* But even though we want the list to contain a segment as described */
 			/* above, we want the cubby buffer to start just past the prefix, or it will */
 			/* find the same SC again.  So I bump the cubby buffer past the prefix. */
-			cubby.buf = cubby.buf + 
+			cubby.buf = /*cubby.buf +*/
+				cxt->parse_cubby.buf +
 				cxt->list.data[cxt->list.num_items].stpos +
 				PREFIX_SIZE;
 
diff --git a/mix_vbp/viddec_fw/fw/parser/viddec_pm_parser_ops.c b/mix_vbp/viddec_fw/fw/parser/viddec_pm_parser_ops.c
index 9a7d828..6719ccf 100644
--- a/mix_vbp/viddec_fw/fw/parser/viddec_pm_parser_ops.c
+++ b/mix_vbp/viddec_fw/fw/parser/viddec_pm_parser_ops.c
@@ -41,24 +41,20 @@
     return ret;
 }
 
-int32_t viddec_pm_append_workitem(void *parent, viddec_workload_item_t *item)
+int32_t viddec_pm_append_workitem(void *parent, viddec_workload_item_t *item, uint32_t next)
 {
+#ifndef VBP
     int32_t ret = 1;
     viddec_pm_cxt_t *cxt;
-
+    viddec_emitter_wkld *emit;
+    
     cxt = (viddec_pm_cxt_t *)parent;
-    ret = viddec_emit_append(&(cxt->emitter.cur), item);
+    emit = (next) ? &(cxt->emitter.next) : &(cxt->emitter.cur);
+    ret = viddec_emit_append(emit, item);
     return ret;
-}
-
-int32_t viddec_pm_append_workitem_next(void *parent, viddec_workload_item_t *item)
-{
-    int32_t ret = 1;
-    viddec_pm_cxt_t *cxt;
-
-    cxt = (viddec_pm_cxt_t *)parent;
-    ret = viddec_emit_append(&(cxt->emitter.next), item);
-    return ret;
+#else
+	return 1;
+#endif
 }
 
 int32_t viddec_pm_get_au_pos(void *parent, uint32_t *bit, uint32_t *byte, uint8_t *is_emul)
@@ -67,6 +63,7 @@
     viddec_pm_cxt_t *cxt;
 
     cxt = (viddec_pm_cxt_t *)parent;
+    viddec_pm_utils_skip_if_current_is_emulation(&(cxt->getbits));
     viddec_pm_utils_bstream_get_au_offsets(&(cxt->getbits), bit, byte, is_emul);
 
     return ret;
@@ -82,6 +79,7 @@
     viddec_workload_item_t wi;
     
     cxt = (viddec_pm_cxt_t *)parent;
+    viddec_pm_utils_skip_if_current_is_emulation(&(cxt->getbits));
     viddec_pm_utils_bstream_get_au_offsets(&(cxt->getbits), &b_off, &start, &emul);
     if(emul) start--;
 
diff --git a/mix_vbp/viddec_fw/fw/parser/viddec_pm_utils_bstream.c b/mix_vbp/viddec_fw/fw/parser/viddec_pm_utils_bstream.c
index 8d3f329..31572a0 100644
--- a/mix_vbp/viddec_fw/fw/parser/viddec_pm_utils_bstream.c
+++ b/mix_vbp/viddec_fw/fw/parser/viddec_pm_utils_bstream.c
@@ -74,7 +74,8 @@
 }
 
 /* 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 */
+   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;
@@ -87,7 +88,8 @@
 
 /* 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 */
+ 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,
@@ -103,13 +105,7 @@
         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 */
-#if 1
-            int32_t val=0;
-            val = last_byte_offst - (int32_t)byte_offset;
-            if(val > 0) bytes_left = (uint32_t)val;
-#else
             bytes_left = viddec_pm_utils_bstream_datafromindex(list, *lst_index, byte_offset);
-#endif
             *physaddr = viddec_pm_utils_bstream_getphys(cxt, byte_offset, *lst_index);
             break;
         }
@@ -129,7 +125,7 @@
     }
 }
 
-/* This function is for copying trailing bytes from scratch buffer to  bitstream buffer*/
+/* 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;
@@ -221,6 +217,7 @@
     }
 #endif
 }
+
 /*
   This function moves the stream position by N bits(parameter bits). The bytes parameter tells us how many bytes were
   read for this N bits(can be different due to emulation bytes).
@@ -240,6 +237,27 @@
 }
 
 /*
+  This function skips emulation byte if necessary.
+  During Normal flow we skip emulation byte only if we read at least one bit after the the two zero bytes.
+  However in some cases we might send data to HW without reading the next bit, in which case we are on
+  emulation byte. To avoid sending invalid data, this function has to be called first to skip.
+*/
+   
+void viddec_pm_utils_skip_if_current_is_emulation(viddec_pm_utils_bstream_cxt_t *cxt)
+{
+    viddec_pm_utils_bstream_buf_cxt_t *bstream = &(cxt->bstrm_buf);
+
+    if(cxt->is_emul_reqd &&
+       (cxt->phase >= 2) &&
+       (bstream->buf_bitoff == 0) &&
+       (bstream->buf[bstream->buf_index] == 0x3) )
+    {
+        bstream->buf_index += 1;
+        cxt->phase = 0;
+    }
+}
+
+/*
   This function gets physical address of the requested au offset(pos).
 */
 
@@ -389,10 +407,12 @@
                 viddec_pm_utils_update_skipoffsets(bstream, total_bits, act_bytes);
                 ret=1;
                 
+#ifdef VBP                
                 if (act_bytes > bytes_required)
                 {
                 	cxt->emulation_byte_counter = act_bytes - bytes_required;
                 }
+#endif                
             }
         }
     }
@@ -444,7 +464,6 @@
                     /* We have to use both the words to get required data */
                     shift_by = total_bits - 32;
                     data.word[0] = (data.word[0] << shift_by) | ( data.word[1] >> (32 - shift_by));
-                    //total_bits -= shift_by;/* BUG */
                 }
                 else
                 {
@@ -458,10 +477,12 @@
                     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;
diff --git a/mix_vbp/viddec_fw/include/viddec_fw_common_defs.h b/mix_vbp/viddec_fw/include/viddec_fw_common_defs.h
index bc2c239..e034b86 100644
--- a/mix_vbp/viddec_fw/include/viddec_fw_common_defs.h
+++ b/mix_vbp/viddec_fw/include/viddec_fw_common_defs.h
@@ -61,6 +61,9 @@
 #define VIDDEC_FW_PARSER_IPC_HOST_INT    0x87654321
 #define EMITTER_WORKLOAD_ENTRIES    2048
 
+/* Maximum supported dependent views for H264 MVC. Based on spec this can be 1023 */
+#define MVC_MAX_SUPPORTED_VIEWS  1
+
 /* This enum defines priority level for opening a stream */
 enum viddec_stream_priority
 {
diff --git a/mix_vbp/viddec_fw/include/viddec_fw_frame_attr.h b/mix_vbp/viddec_fw/include/viddec_fw_frame_attr.h
index a816dd4..cdc0bff 100644
--- a/mix_vbp/viddec_fw/include/viddec_fw_frame_attr.h
+++ b/mix_vbp/viddec_fw/include/viddec_fw_frame_attr.h
@@ -58,6 +58,8 @@
 #ifndef VIDDEC_FW_FRAME_ATTR_H
 #define VIDDEC_FW_FRAME_ATTR_H
 
+#include "viddec_fw_item_types.h"
+
 #define VIDDEC_PANSCAN_MAX_OFFSETS 4
 #define VIDDEC_MAX_CPB_CNT 32
 
@@ -140,6 +142,7 @@
     */
     unsigned int repeat_first_field;
 
+
 }viddec_mpeg2_frame_attributes_t;
 
 /**
@@ -190,38 +193,49 @@
 */
 typedef struct viddec_h264_frame_attributes
 {
-	/**
-	used_for_reference : 1 means this frame is used as ref frame of others. 0 means no any frame ref to this frame
-	*/	 
-	///// This flag hasn't been enable so far
-	unsigned int used_for_reference;
+    /**
+       used_for_reference : 1 means this frame is used as ref frame of others. 0 means no any frame ref to this frame
+    */
+    unsigned int used_for_reference;
+    /**
+       Picture Order Count for the current frame/field.
+       This value is computed using information from the bitstream.
+       Refer to Section 8.2.1, function 8-1 of the ITU-T H.264 Specification.
+       These fileds will be supported in future
+    */
+    int top_field_poc;
+    int bottom_field_poc;
 
+    /**
+       Display size, which is cropped from content size. 
+       Currently, the cont_size is cropped, so this paramter is redundant, but in future, cont_size may be changed
+    */
+    viddec_rect_size_t cropped_size;
 
-	/** -   
-	Picture Order Count for the current frame/field.-    
-	This value is computed using information from the bitstream.-    
-	Refer to Section 8.2.1, function 8-1 of the ITU-T H.264 Specification.-   
-	*/
-	// These fileds will be supported in future
-	int top_field_poc;	
-	int bottom_field_poc;	
+    /**
+       top_field_first: 0 means bottom_field_POC is smaller than top_field_POC, else 1
+    */
+    unsigned int top_field_first;
+    
+    /**
+       field_frame_flag: 0 means all slice of this frame are frame-base encoded, else 1
+    */
+    unsigned int field_pic_flag;
 
-	/**
-	Display size, which is cropped from content size. 
-	Currently, the cont_size is cropped, so this paramter is redundant, but in future, cont_size may be changed
-	*/	 
-	viddec_rect_size_t cropped_size;
-
-	/**
-	top_field_first: 0 means bottom_field_POC is smaller than top_field_POC, else 1
-	*/	 
-	unsigned int top_field_first;
-	
-	/**
-	field_frame_flag: 0 means all slice of this frame are frame-base encoded, else 1
-	*/	 
-	unsigned int field_pic_flag;
-
+    /**
+       This data type holds view specific information of current frame.
+       The following information is packed into this data type:
+         view_id(0-9 bits):        Assigned 10 bit value in the encoded stream.
+         priority_id(10-15bits):   Assigned 6 bit priority id.
+         is_base_view(16th bit):   Flag on true indicates current frame belongs to base view, else dependent view.
+     */
+#define viddec_fw_h264_mvc_get_view_id(x)              viddec_fw_bitfields_extract( (x)->view_spcific_info, 0, 0x3FF)
+#define viddec_fw_h264_mvc_set_view_id(x, val)         viddec_fw_bitfields_insert( (x)->view_spcific_info, val, 0, 0x3FF)
+#define viddec_fw_h264_mvc_get_priority_id(x)          viddec_fw_bitfields_extract( (x)->view_spcific_info, 10, 0x3F)
+#define viddec_fw_h264_mvc_set_priority_id(x, val)     viddec_fw_bitfields_insert( (x)->view_spcific_info, val, 10, 0x3F)
+#define viddec_fw_h264_mvc_get_is_base_view(x)         viddec_fw_bitfields_extract( (x)->view_spcific_info, 16, 0x1)
+#define viddec_fw_h264_mvc_set_is_base_view(x, val)    viddec_fw_bitfields_insert( (x)->view_spcific_info, val, 16, 0x1)
+    unsigned int view_spcific_info;
 }viddec_h264_frame_attributes_t;
 
 /**
@@ -241,7 +255,6 @@
 This structure groups all the frame attributes that are exported by the firmware.
 The frame attributes are split into attributes that are common to all codecs and
 that are specific to codec type.
-As of this release, it is populated only for mpeg2 only.
 */
 typedef struct viddec_frame_attributes
 {
diff --git a/mix_vbp/viddec_fw/include/viddec_fw_item_types.h b/mix_vbp/viddec_fw/include/viddec_fw_item_types.h
index 66e5f59..3a69c6d 100644
--- a/mix_vbp/viddec_fw/include/viddec_fw_item_types.h
+++ b/mix_vbp/viddec_fw/include/viddec_fw_item_types.h
@@ -76,66 +76,107 @@
 #define viddec_fw_bitfields_extract(x_32, start, mask)     (((x_32) >> (start)) & (mask) )
 #define viddec_fw_bitfields_insert(x_32, val_32, start, mask) ((x_32) = (((x_32) & ~( (mask) << (start))) | (((val_32) & (mask)) << (start))))
 
+
 /* Workload items type. Each item here represents data that Parser detected ex:slice data which
  is used either by host or decoder.*/
 enum workload_item_type
 {
-    VIDDEC_WORKLOAD_INVALID=0x0,                   /* Unknown type */
-    VIDDEC_WORKLOAD_PIXEL_ES=0x100,                /* Slice data tag */
-    VIDDEC_WORKLOAD_TAG=0x200,                     /* Frame association tag */
-    VIDDEC_WORKLOAD_USERDATA=0x300,                /* user data tag */
-    VIDDEC_WORKLOAD_DECODER_INFO=0x400,            /* decoder specific data tag which decoder module understands*/
-    VIDDEC_WORKLOAD_IBUF_DONE=0x500,               /* Es buffer completely used tag */
-    VIDDEC_WORKLOAD_IBUF_CONTINUED=0x600,          /* Es buffer partially used tag */
-    VIDDEC_WORKLOAD_TAG_BUFFER_LOOSE_START=0x700,  /* ??? */
-    VIDDEC_WORKLOAD_REFERENCE_FRAME_REORDER=0x800, /* Reorder frames in DPB tag */
-    VIDDEC_WORKLOAD_DISPLAY_FRAME=0x900,           /* Display order in DPB tag, for H264 NOT required??? */
+    VIDDEC_WORKLOAD_INVALID                               =0x0,/* Unknown type */
+    VIDDEC_WORKLOAD_PIXEL_ES                              =0x100,/* Slice data tag */
+    VIDDEC_WORKLOAD_TAG                                   =0x200,/* Frame association tag */
+    VIDDEC_WORKLOAD_USERDATA                              =0x300,/* user data tag */
 
-    VIDDEC_WORKLOAD_SEQUENCE_INFO=0xa00,           /* MPEG2 Seq Hdr, H264 SPS, VC1 SeqLayer */
-    VIDDEC_WORKLOAD_DISPLAY_INFO=0xb00,            /* MPEG2 Seq Disp Ext, H264 VUI */
-    VIDDEC_WORKLOAD_GOP_INFO=0xc00,                /* MPEG2 GOP, VC1 Entrypoint */
-    VIDDEC_WORKLOAD_SEQ_USER_DATA=0xd00,           /* MPEG2, VC1 Sequence Level User data */
-    VIDDEC_WORKLOAD_GOP_USER_DATA=0xe00,           /* MPEG2, VC1 Gop Level User data */
-    VIDDEC_WORKLOAD_FRM_USER_DATA=0xf00,           /* MPEG2 Picture User data, VC1 Frame User data */
-    VIDDEC_WORKLOAD_FLD_USER_DATA=0x1000,          /* MPEG2, VC1 Field User data */
-    VIDDEC_WORKLOAD_SLC_USER_DATA=0x1100,          /* VC1 Slice User data */
-    VIDDEC_WORKLOAD_VISUAL_OBJ_USER_DATA=0x1200,   /* MPEG4 Visual Object User data */
-    VIDDEC_WORKLOAD_VIDEO_OBJ_USER_DATA=0x1300,    /* MPEG4 Video Object Layer User data */
+    VIDDEC_WORKLOAD_IBUF_DONE                             =0x500,/* Es buffer completely used tag */
+    VIDDEC_WORKLOAD_IBUF_CONTINUED                        =0x600,/* Es buffer partially used tag */
+    VIDDEC_WORKLOAD_IBUF_DISCONTINUITY                    =0x700,/* Discontinuity tag on first workload after discontinuity */
+    VIDDEC_WORKLOAD_REFERENCE_FRAME_REORDER               =0x800, /* Reorder frames in DPB tag */
+    VIDDEC_WORKLOAD_IBUF_EOS                              =0x900,/* EOS tag on last workload used for current stream */
+    VIDDEC_WORKLOAD_SEQUENCE_INFO                         =0xa00,/* MPEG2 Seq Hdr, H264 SPS, VC1 SeqLayer */
+    VIDDEC_WORKLOAD_DISPLAY_INFO                          =0xb00,/* MPEG2 Seq Disp Ext, H264 VUI */
+    VIDDEC_WORKLOAD_GOP_INFO                              =0xc00,/* MPEG2 GOP, VC1 Entrypoint */
+    VIDDEC_WORKLOAD_SEQ_USER_DATA                         =0xd00,/* MPEG2, VC1 Sequence Level User data */
+    VIDDEC_WORKLOAD_GOP_USER_DATA                         =0xe00,/* MPEG2, VC1 Gop Level User data */
+    VIDDEC_WORKLOAD_FRM_USER_DATA                         =0xf00,/* MPEG2 Picture User data, VC1 Frame User data */
 
-    VIDDEC_WORKLOAD_MPEG2_SEQ_EXT=0x1150,              /* MPEG2 Only - Sequence Extension */
-    VIDDEC_WORKLOAD_VC1_SEQ_HDR_STRUCT_A_C=0x1200,     /* VC1 Only */
+    VIDDEC_WORKLOAD_FLD_USER_DATA                         =0x1000,/* MPEG2, VC1 Field User data */
+    VIDDEC_WORKLOAD_SLC_USER_DATA                         =0x1100,/* VC1 Slice User data */
+    VIDDEC_WORKLOAD_VISUAL_OBJ_USER_DATA                  =0x1200,/* MPEG4 Visual Object User data */
+    VIDDEC_WORKLOAD_VC1_SEQ_HDR_STRUCT_A_C                =0x1200,/* VC1 Only */
+    VIDDEC_WORKLOAD_VIDEO_OBJ_USER_DATA                   =0x1300,/* MPEG4 Video Object Layer User data */
+    VIDDEC_WORKLOAD_H264_CROPPING                         =0x1400,/* H264 only */
+    VIDDEC_WORKLOAD_H264_PAN_SCAN                         =0x1500,/* H264 only */
+    VIDDEC_WORKLOAD_SEI_PIC_TIMING                        =0x1600,/* H264 only */
+    VIDDEC_WORKLOAD_SEI_PAN_SCAN_RECT                     =0x1700,/* H264 only */
+    VIDDEC_WORKLOAD_SEI_USER_DATA_REGISTERED              =0x1800,/* H264 only */
+    VIDDEC_WORKLOAD_SEI_USER_DATA_UNREGISTERED            =0x1900,/* H264 only */
+    VIDDEC_WORKLOAD_SEI_RECOVERY_POINT                    =0x1a00,/* H264 only */
+    VIDDEC_WORKLOAD_MPEG2_SEQ_EXT                         =0x1b00,/* MPEG2 Only - Sequence Extension */
+    VIDDEC_WORKLOAD_H264_MVC_SPS_VIEW_IDS                 =0x1c00,/* H264 only */     
+    VIDDEC_WORKLOAD_MPEG4_VISUAL_SEQ_OBJ                  =0x1d00,/* MPEG4 Only - Visual Sequence */
+    VIDDEC_WORKLOAD_MPEG4_VIDEO_OBJ                       =0x1e00,/* MPEG4 Only - Video Object Layer */
+    VIDDEC_WORKLOAD_MPEG4_GRP_VIDEO_OBJ                   =0x1f00,/* MPEG4 Only - Group of Video Object Planes */
 
-    VIDDEC_WORKLOAD_H264_CROPPING=0x1400,              /* H264 only */
-    VIDDEC_WORKLOAD_H264_PAN_SCAN=0x1500,              /* H264 only */
-    VIDDEC_WORKLOAD_H264_VUI_TIMING_INFO=0x2100,       /* H264 only */
-    VIDDEC_WORKLOAD_SEI_PIC_TIMING=0x1600,             /* H264 only */
-    VIDDEC_WORKLOAD_SEI_PAN_SCAN_RECT=0x1700,          /* H264 only */
-    VIDDEC_WORKLOAD_SEI_USER_DATA_REGISTERED=0x1800,   /* H264 only */
-    VIDDEC_WORKLOAD_SEI_USER_DATA_UNREGISTERED=0x1900, /* H264 only */
-    VIDDEC_WORKLOAD_SEI_RECOVERY_POINT=0x1a00,         /* H264 only */
-    VIDDEC_WORKLOAD_IBUF_EOS=0x1b00,          /* EOS tag on last workload used for current stream */
-    VIDDEC_WORKLOAD_IBUF_DISCONTINUITY=0x1c00,           /* Discontinuity tag on first workload after discontinuity */
-    
-    VIDDEC_WORKLOAD_MPEG4_VISUAL_SEQ_OBJ=0x1d00,       /* MPEG4 Only - Visual Sequence */
-    VIDDEC_WORKLOAD_MPEG4_VIDEO_OBJ=0x1e00,            /* MPEG4 Only - Video Object Layer */
-    VIDDEC_WORKLOAD_MPEG4_GRP_VIDEO_OBJ=0x1f00,        /* MPEG4 Only - Group of Video Object Planes */
-    VIDDEC_WORKLOAD_MPEG4_VIDEO_PLANE_SHORT=0x2000,    /* MPEG4 Only - Video Plane with Short Header */
+    VIDDEC_WORKLOAD_MPEG4_VIDEO_PLANE_SHORT               =0x2000,/* MPEG4 Only - Video Plane with Short Header */
+    VIDDEC_WORKLOAD_H264_VUI_TIMING_INFO                  =0x2100,/* H264 only */
 
-    VIDDEC_WORKLOAD_REF_FRAME_SOURCE_0 = 0x10000,   	/* required reference frames tag, last eight bits tell the id of frame in dpb */
-    VIDDEC_WORKLOAD_REF_FRAME_RELEASE_0 = 0x20000,  	/* release frames tag, last eight bits tell the id of frame in dpb */
-    VIDDEC_WORKLOAD_REF_FRAME_DISPLAY_0 = 0x30000,  	/* Display order in DPB tag, for H264 */
-	 VIDDEC_WORKLOAD_REF_FRAME_DROPOUT_0 = 0x40000,  	   /* Release frames but not display, for H264 */
-	 VIDDEC_WORKLOAD_EOS_RELEASE_FRAME_0 = 0x50000,		/* Release list while EOS, last eight bits tell the id of frame in dpb */
-	 VIDDEC_WORKLOAD_EOS_DISPLAY_FRAME_0 = 0x60000,		/* Diaplay list while EOS, last eight bits tell the id of frame in dpb */
-	 
-    VIDDEC_WORKLOAD_DPB_ACTIVE_FRAME_0  = 0x70000,   	/* required for H264 as it needs whole DPB for each frame */
-    VIDDEC_WORKLOAD_H264_REFR_LIST_0    =  0x80000,   /* ref list 0 for H264 */
-    VIDDEC_WORKLOAD_H264_REFR_LIST_1    =  0x90000,   /* ref list 1 for H264 */
-    VIDDEC_WORKLOAD_EOS_BEGIN_BOUNDARY  =  0xa0000,   /* eos items begin after this */
-    VIDDEC_WORKLOAD_DECODER_SPECIFIC = 0x100000,    /* pvt info for decoder tags */
+    VIDDEC_WORKLOAD_REF_FRAME_SOURCE_0                    =0x10000,/* required reference frames tag,last eight bits indicate index in dpb */
+    VIDDEC_WORKLOAD_REF_FRAME_RELEASE_0                   =0x20000,/* release frames tag, last eight bits indicate index in dpb*/
+    VIDDEC_WORKLOAD_REF_FRAME_DISPLAY_0                   =0x30000,/* Display order in DPB tag, for H264 */
+	 VIDDEC_WORKLOAD_REF_FRAME_DROPOUT_0                   =0x40000,/* Release frames but not display, for H264 */
+	 VIDDEC_WORKLOAD_EOS_RELEASE_FRAME_0                   =0x50000,/* Release list while EOS, last eight bits indicate index in dpb */
+	 VIDDEC_WORKLOAD_EOS_DISPLAY_FRAME_0                   =0x60000,/* Display list while EOS, last eight bits indicate index in dpb */
+    VIDDEC_WORKLOAD_DPB_ACTIVE_FRAME_0                    =0x70000,/* required for H264 as it needs whole DPB for each frame */
+    VIDDEC_WORKLOAD_H264_REFR_LIST_0                      =0x80000,/* ref list 0 for H264 */
+    VIDDEC_WORKLOAD_H264_REFR_LIST_1                      =0x90000,/* ref list 1 for H264 */
+    VIDDEC_WORKLOAD_EOS_BEGIN_BOUNDARY                    =0xa0000,/* eos items begin after this */
+
+    VIDDEC_WORKLOAD_DECODER_SPECIFIC                      =0x100000,/* pvt info for decoder tags */
     VIDDEC_WORKLOAD_MAX,
 };
 
+struct h264_witem_sps_mvc_id
+{
+    /*
+      0-9:    num_views_minus1
+      10-19:  start index of views in current item.
+      20-23:  Number of valid items.
+    */
+#define viddec_fw_h264_sps_mvc_id_get_num_views_minus1(x)         viddec_fw_bitfields_extract( (x)->num_views, 0, 0x3FF)
+#define viddec_fw_h264_sps_mvc_id_set_num_views_minus1(x, val)    viddec_fw_bitfields_insert( (x)->num_views, val, 0, 0x3FF)
+#define viddec_fw_h264_sps_mvc_id_get_cur_start_index(x)          viddec_fw_bitfields_extract( (x)->num_views, 10, 0x3FF)
+#define viddec_fw_h264_sps_mvc_id_set_cur_start_index(x, val)     viddec_fw_bitfields_insert( (x)->num_views, val, 10, 0x3FF)
+#define viddec_fw_h264_sps_mvc_id_get_num_cur_valid_items(x)      viddec_fw_bitfields_extract( (x)->num_views, 20, 0x7)
+#define viddec_fw_h264_sps_mvc_id_set_num_cur_valid_items(x, val) viddec_fw_bitfields_insert( (x)->num_views, val, 20, 0x7)
+    unsigned int num_views;
+
+    /* We pack six id's into two integers.Each packed_view(integer) contains three 10 bit ids at 0-9, 10-19, 20-29
+       These values can be extracted/set using viddec_fw_h264_sps_mvc_id_get_data_frm_index()
+       and viddec_fw_h264_sps_mvc_id_set_data_frm_index() functions.
+    */
+#define viddec_fw_h264_sps_mvc_id_max_packed_ids        6 /* Max number of packed ids in a workload item */
+    unsigned int packed_view[2];
+};
+
+/* This function extracts a 10 bit view id of index( <6) that was packed into h264_witem_sps_mvc_id structure */
+static inline unsigned int viddec_fw_h264_sps_mvc_id_get_data_frm_index(struct h264_witem_sps_mvc_id *data, unsigned int index)
+{
+    unsigned int start=0, *word;
+
+    start = ((index > 2) ?(index - 3) : index) *10;
+    word = &(data->packed_view[(index > 2) ? 1:0]);
+    return viddec_fw_bitfields_extract(*word, start, 0x3FF);
+}
+
+/* This function packs  a 10 bit view id(val) at index( <6) in h264_witem_sps_mvc_id structure */
+static inline void viddec_fw_h264_sps_mvc_id_set_data_frm_index(struct h264_witem_sps_mvc_id *data, unsigned int index, unsigned int val)
+{
+    unsigned int start=0, *word;
+
+    start = ((index > 2) ?(index - 3) : index) *10;
+    word = &(data->packed_view[(index > 2) ? 1:0]);
+    viddec_fw_bitfields_insert(*word, val, start, 0x3FF);
+}
+
 /* 16-byte workload */
 typedef struct viddec_workload_item
 {
@@ -500,6 +541,8 @@
             unsigned int pic_height_in_map_units_minus1;
         } h264_sps; // h264 item of type VIDDEC_WORKLOAD_SEQUENCE_INFO
 
+        struct h264_witem_sps_mvc_id h264_sps_mvc_id;
+
         struct
         {
 #define viddec_fw_h264_cropping_get_left(x)  viddec_fw_bitfields_extract( (x)->left_right, 16, 0xFFFF)
@@ -622,6 +665,7 @@
             unsigned int changing_slice_group_idc; /* 2bit value for slice_group idc */
 
         } h264_sei_recovery_point; // h264 item of type VIDDEC_WORKLOAD_SEI_RECOVERY_POINT
+        
 
         struct
         {
@@ -735,4 +779,6 @@
     };
 }viddec_workload_item_t;
 
+
+
 #endif /* VIDDEC_ITEM_TYPES_H */
diff --git a/mix_video/src/mixframemanager.c b/mix_video/src/mixframemanager.c
index e940262..97618c5 100644
--- a/mix_video/src/mixframemanager.c
+++ b/mix_video/src/mixframemanager.c
@@ -45,6 +45,10 @@
 	/* for vc1 in asf */
 	self->p_frame = NULL;
 	self->prev_timestamp = 0;
+
+#ifdef ANDROID	
+	self->timestamp_storage = NULL;
+#endif	
 }
 
 static void mix_framemanager_class_init(MixFrameManagerClass * klass) {
@@ -120,6 +124,15 @@
 		if (!fm->frame_array) {
 			goto cleanup;
 		}
+		
+
+#ifdef ANDROID		
+		fm->timestamp_storage = g_array_sized_new(FALSE, TRUE,
+				sizeof(guint64), INITIAL_FRAME_ARRAY_SIZE);
+		if (!fm->timestamp_storage) {
+			goto cleanup;
+		}
+#endif		
 	}
 
 	fm->frame_queue = g_queue_new();
@@ -180,6 +193,12 @@
 		g_queue_free(fm->frame_queue);
 		fm->frame_queue = NULL;
 	}
+#ifdef ANDROID	
+	if (fm->timestamp_storage) {
+		g_array_free(fm->timestamp_storage, TRUE);
+		fm->timestamp_storage = NULL;
+	}
+#endif	
 
 	fm->initialized = FALSE;
 
@@ -291,6 +310,12 @@
 		}
 	}
 
+#ifdef ANDROID	
+	if(fm->timestamp_storage) {
+		g_array_remove_range(fm->timestamp_storage, 0, fm->timestamp_storage->len);
+	}
+#endif
+
 	if (fm->frame_queue) {
 		guint len = fm->frame_queue->length;
 		if (len) {
@@ -385,6 +410,7 @@
 	return frame;
 }
 
+#ifdef ANDROID
 MixVideoFrame *get_expected_frame_from_array_DO(GPtrArray *array,
 	guint32 expected, guint32 *framedisplayorder) {
 
@@ -453,6 +479,7 @@
 
     return frame;
 }
+#endif /* ANDROID */
 
 void add_frame_into_array(GPtrArray *array, MixVideoFrame *mvf) {
 
@@ -484,6 +511,7 @@
 
 }
 
+#ifdef ANDROID
 gint frame_sorting_func_DO(gconstpointer a, gconstpointer b) {
 
     MixVideoFrame *fa = *((MixVideoFrame **) a);
@@ -537,6 +565,7 @@
     MIX_RESULT ret = MIX_RESULT_FAIL;
     guint32 displayorder = 0;
 
+
 first_frame:
 
     ret = mix_videoframe_get_displayorder(mvf, &displayorder);
@@ -687,6 +716,8 @@
 
     return ret;
 }
+#endif /* ANDROID */
+
 
 MIX_RESULT mix_framemanager_timestamp_based_enqueue(MixFrameManager *fm,
 		MixVideoFrame *mvf) {
@@ -982,11 +1013,35 @@
 
 	} else {
 
+#ifdef ANDROID
+		guint64 timestamp = 0;
+		mix_videoframe_get_timestamp(mvf, &timestamp);
+
+		/* add timestamp into timestamp storage */
+		if(fm->timestamp_storage) {
+			gint idx = 0;
+			gboolean found = FALSE;
+
+			if(fm->timestamp_storage->len) {
+				for(idx = 0; idx < fm->timestamp_storage->len; idx ++) {
+					if(timestamp == g_array_index(fm->timestamp_storage, guint64, idx)) {
+						found = TRUE;
+						break;
+					}
+				}
+			}
+
+			if(!found) {
+				g_array_append_val(fm->timestamp_storage, timestamp);
+			}
+		}
+#endif
+
 		if (fm->timebased_ordering) {
 #ifndef ANDROID
 			ret = mix_framemanager_timestamp_based_enqueue(fm, mvf);
 #else
-                        ret = mix_framemanager_displayorder_based_enqueue(fm, mvf);
+			ret = mix_framemanager_displayorder_based_enqueue(fm, mvf);
 #endif
 
 		} else {
@@ -999,6 +1054,21 @@
 	return ret;
 }
 
+#ifdef ANDROID
+gint timestamp_storage_sorting_func(gconstpointer a, gconstpointer b) {
+
+	guint64 ta = *((guint64 *)a);
+	guint64 tb = *((guint64 *)b);
+
+	if(ta > tb) {
+		return +1;
+	} else if(ta == tb) {
+		return 0;
+	}
+	return -1;
+}
+#endif
+
 MIX_RESULT mix_framemanager_dequeue(MixFrameManager *fm, MixVideoFrame **mvf) {
 
 	MIX_RESULT ret = MIX_RESULT_FAIL;
@@ -1020,6 +1090,17 @@
 	ret = MIX_RESULT_FRAME_NOTAVAIL;
 	*mvf = (MixVideoFrame *) g_queue_pop_head(fm->frame_queue);
 	if (*mvf) {
+#ifdef ANDORID
+		if(fm->timestamp_storage && fm->mode == MIX_FRAMEORDER_MODE_DISPLAYORDER) {
+			if(fm->timestamp_storage->len) {
+				guint64 ts;
+				g_array_sort(fm->timestamp_storage, timestamp_storage_sorting_func);
+				ts = g_array_index(val_array, guint64, 0)
+				mix_videoframe_set_timestamp(*mvf, ts);
+				g_array_remove_index_fast(fm->timestamp_storage, 0);
+			}
+		}
+#endif	
 		ret = MIX_RESULT_SUCCESS;
 	} else if (fm->eos) {
 		ret = MIX_RESULT_EOS;
@@ -1102,7 +1183,7 @@
 				/* sorting frames in the array by timestamp */
 				g_ptr_array_sort(fm->frame_array, frame_sorting_func);
 #else
-                                /* sorting frames is the array by displayorder */  
+                /* sorting frames is the array by displayorder */  
 				g_ptr_array_sort(fm->frame_array, frame_sorting_func_DO);
 #endif
 				
@@ -1120,9 +1201,7 @@
 		}
 	}
 	
-	
 	fm->eos = TRUE;
-
 	g_mutex_unlock(fm->lock);
 
 	return ret;
diff --git a/mix_video/src/mixframemanager.h b/mix_video/src/mixframemanager.h
index 43343d5..bde47ee 100644
--- a/mix_video/src/mixframemanager.h
+++ b/mix_video/src/mixframemanager.h
@@ -58,8 +58,10 @@
 	guint64 prev_timestamp;
 
 	gboolean timebased_ordering;
-
-        guint32 next_displayorder;
+#ifdef ANDROID
+	guint32 next_displayorder;
+	GArray *timestamp_storage;
+#endif	
 };
 
 /**
diff --git a/mix_video/src/mixvideoformat_h264.c b/mix_video/src/mixvideoformat_h264.c
index b65936e..18015fc 100644
--- a/mix_video/src/mixvideoformat_h264.c
+++ b/mix_video/src/mixvideoformat_h264.c
@@ -17,6 +17,15 @@
 static int mix_video_h264_counter = 0;
 #endif /* MIX_LOG_ENABLE */
 
+#ifdef ANDROID
+typedef struct _NalBuffer {
+	unsigned char *buffer;
+	unsigned int offset;
+	unsigned int length;
+	void *appdata;
+} NalBuffer;
+#endif
+
 /* The parent class. The pointer will be saved
  * in this class's initialization. The pointer
  * can be used for chaining method call if needed.
@@ -669,10 +678,39 @@
 
 		LOG_V( "Calling parse for current frame, parse handle %d, buf %x, size %d\n", (int)parent->parser_handle, (guint)bufin[i]->data, bufin[i]->size);
 
+#ifndef ANDROID		
 		pret = vbp_parse(parent->parser_handle, 
 			bufin[i]->data, 
 			bufin[i]->size,
 			FALSE);
+#else
+		/* we got an array of NALs for a frame */
+		{
+			gint nal_index = 0;
+			NalBuffer *nals = (NalBuffer *)bufin[i]->data;
+			gint nal_count = bufin[i]->size;
+			
+                        LOG_V("nal_count = %d\n", nal_count);
+			for(nal_index = 0; nal_index < nal_count; nal_index ++) {
+
+                                LOG_V("nals[%d].offset = 0x%x nals[nal_index].length = %d\n",
+                                                  nal_index, nals[nal_index].offset, nals[nal_index].length);
+
+				pret = vbp_parse(parent->parser_handle, 
+						nals[nal_index].buffer + nals[nal_index].offset, 
+						nals[nal_index].length, 
+						FALSE);                       
+                               
+                                LOG_V("nal_index = %d pret = 0x%x\n", nal_index, pret);
+
+				if(pret != VBP_OK && pret != VBP_DONE) {
+					ret = MIX_RESULT_FAIL;
+                                        LOG_E( "Error parsing data : pret = 0x%x\n", pret);
+					goto cleanup;
+				}
+			}
+		}
+#endif		
 
 		LOG_V( "Called parse for current frame\n");
 
diff --git a/mix_video/src/mixvideoformatenc_h264.c b/mix_video/src/mixvideoformatenc_h264.c
index e222ace..1a89173 100644
--- a/mix_video/src/mixvideoformatenc_h264.c
+++ b/mix_video/src/mixvideoformatenc_h264.c
@@ -1369,8 +1369,15 @@
         LOG_I( 
                 "input buf size = %d\n", bufin->size);			
         
-        guint8 *inbuf = bufin->data;      
-        
+        guint8 *inbuf = bufin->data;
+
+#ifndef ANDROID
+#define USE_SRC_FMT_YUV420
+#else
+#define USE_SRC_FMT_NV21
+#endif
+
+#ifdef USE_SRC_FMT_YUV420
         /*need to convert YUV420 to NV12*/
         dst_y = pvbuf +image->offsets[0];
         
@@ -1389,7 +1396,37 @@
             }
             dst_uv += image->pitches[1];
         }
-        
+#else //USE_SRC_FMT_NV12 or USE_SRC_FMT_NV21
+            int offset_uv = width * height;
+            guint8 *inbuf_uv = inbuf + offset_uv;
+            int height_uv = height / 2;
+            int width_uv = width;
+
+            dst_y = pvbuf + image->offsets[0];
+            for (i = 0; i < height; i++) {
+                memcpy (dst_y, inbuf + i * width, width);
+                dst_y += image->pitches[0];
+            }
+
+#ifdef USE_SRC_FMT_NV12
+            dst_uv = pvbuf + image->offsets[1];
+            for (i = 0; i < height_uv; i++) {
+                memcpy(dst_uv, inbuf_uv + i * width_uv, width_uv);
+                dst_uv += image->pitches[1];
+            }
+#else //USE_SRC_FMT_NV21
+            dst_uv = pvbuf + image->offsets[1];
+            for (i = 0; i < height_uv; i ++) {
+                for (j = 0; j < width_uv; j += 2) {
+                    dst_uv[j] = inbuf_uv[j+1];  //u
+                    dst_uv[j+1] = inbuf_uv[j];  //v
+                }
+                dst_uv += image->pitches[1];
+                inbuf_uv += width_uv;
+            }
+#endif
+#endif //USE_SRC_FMT_YUV420
+
         va_status = vaUnmapBuffer(va_display, image->buf);	
         if (va_status != VA_STATUS_SUCCESS)	 
         {