1/* /////////////////////////////////////////////////////////////////////// 2// 3// INTEL CORPORATION PROPRIETARY INFORMATION 4// This software is supplied under the terms of a license agreement or 5// nondisclosure agreement with Intel Corporation and may not be copied 6// or disclosed except in accordance with the terms of that agreement. 7// Copyright (c) 2008 Intel Corporation. All Rights Reserved. 8// 9// Description: Parses VC-1 picture layer for progressive P picture in simple 10// or main profile bitstream. 11// 12*/ 13 14#include "vc1parse.h" 15 16/*------------------------------------------------------------------------------ 17 * Parse picture layer. This function parses progressive P picture for simple 18 * or main profile bitstream. This parser starts after PTYPE was parsed but 19 * stops before parsing of macroblock layer. 20 * Table 19 of SMPTE 421M after processing up to PTYPE for P picture. 21 *------------------------------------------------------------------------------ 22 */ 23 24vc1_Status vc1_ParsePictureHeader_ProgressivePpicture(void* ctxt, vc1_Info *pInfo) 25{ 26 uint8_t bit_count; 27 const uint8_t *table; 28 uint32_t tempValue; 29 vc1_Status status = VC1_STATUS_OK; 30 vc1_metadata_t *md = &pInfo->metadata; 31 vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader; 32 33 /* rounding control is implied for simple and main profile, SMPTE 421M 8.3.7. 34 It toggles back and forth between 0 and 1 for P frames */ 35 if (md->PROFILE != VC1_PROFILE_ADVANCED) 36 { 37 picLayerHeader->RNDCTRL = md->RNDCTRL ^ 1 ; 38 md->RNDCTRL = picLayerHeader->RNDCTRL; 39 } 40 41 VC1_GET_BITS9(5, picLayerHeader->PQINDEX); 42 if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK) 43 return status; 44 45 if (picLayerHeader->PQINDEX <= 8) 46 { 47 VC1_GET_BITS9(1, picLayerHeader->HALFQP); 48 } 49 else picLayerHeader->HALFQP=0; 50 51 if (md->QUANTIZER == 1) 52 { 53 VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER); 54 picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER; 55 } 56 57 /* MVRANGE. */ 58 if ((status = vc1_MVRangeDecode(ctxt, pInfo)) != VC1_STATUS_OK) 59 return status; 60 61 if (md->MULTIRES == 1) 62 VC1_GET_BITS9(2, tempValue); /* RESPIC. */ 63 64 if (picLayerHeader->PQUANT > 12) 65 table = VC1_MVMODE_LOW_TBL; 66 else 67 table = VC1_MVMODE_HIGH_TBL; 68 69 bit_count = 0; 70 VC1_GET_BITS9(1, picLayerHeader->MVMODE); 71 while ((picLayerHeader->MVMODE == 0) && (bit_count < 3)) 72 { 73 VC1_GET_BITS9(1, picLayerHeader->MVMODE); 74 bit_count++; 75 } 76 if (bit_count == 3) 77 bit_count += picLayerHeader->MVMODE; 78 picLayerHeader->MVMODE = table[bit_count]; 79 80 if (picLayerHeader->MVMODE == VC1_MVMODE_INTENSCOMP) 81 { 82 bit_count = 0; 83 VC1_GET_BITS9(1, picLayerHeader->MVMODE2); 84 while ((picLayerHeader->MVMODE2 == 0) && (bit_count < 2)) 85 { 86 VC1_GET_BITS9(1, picLayerHeader->MVMODE2); 87 bit_count++; 88 } 89 if (bit_count == 2 && picLayerHeader->MVMODE2 == 0) 90 bit_count++; 91 picLayerHeader->MVMODE2 = table[bit_count]; 92 VC1_GET_BITS9(6, picLayerHeader->LUMSCALE); 93 VC1_GET_BITS9(6, picLayerHeader->LUMSHIFT); 94 } 95#ifdef VBP 96 else 97 picLayerHeader->MVMODE2 = 0; 98#else 99 else 100 picLayerHeader->MVMODE2 = picLayerHeader->MVMODE; 101#endif 102 103 if ((picLayerHeader->MVMODE == VC1_MVMODE_MIXED_MV) || 104 ((picLayerHeader->MVMODE == VC1_MVMODE_INTENSCOMP) && 105 (picLayerHeader->MVMODE2 == VC1_MVMODE_MIXED_MV))) 106 { 107 if ((status = vc1_DecodeBitplane(ctxt, pInfo, 108 md->widthMB, md->heightMB, BPP_MVTYPEMB)) 109 != VC1_STATUS_OK) 110 { 111 return status; 112 } 113 } 114 115 if ((status = vc1_DecodeBitplane(ctxt, pInfo, 116 md->widthMB, md->heightMB, BPP_SKIPMB)) != VC1_STATUS_OK) 117 { 118 return status; 119 } 120 121 VC1_GET_BITS9(2, picLayerHeader->MVTAB); 122 VC1_GET_BITS9(2, picLayerHeader->CBPTAB); 123 124 if ((status = vc1_VOPDQuant(ctxt, pInfo)) != VC1_STATUS_OK) 125 return status; 126 127 if (md->VSTRANSFORM == 1) 128 { 129 VC1_GET_BITS9(1, picLayerHeader->TTMBF); 130 if (picLayerHeader->TTMBF == 1) 131 { 132 VC1_GET_BITS9(2, picLayerHeader->TTFRM); 133 } 134 } 135 136 VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM); 137 if (picLayerHeader->TRANSACFRM == 1) 138 { 139 VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM); 140 picLayerHeader->TRANSACFRM += 2; 141 } 142 143 VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB); 144 145 /* Skip parsing of macroblock layer. */ 146 147 return status; 148} 149 150