Home | History | Annotate | Download | only in parser
      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 I or BI picture in
     10 //  advanced profile bitstream.
     11 //
     12 */
     13 
     14 #include "vc1parse.h"
     15 #include "viddec_fw_debug.h"
     16 /*------------------------------------------------------------------------------
     17  * Parse picture layer.  This function parses progressive I or BI picture for
     18  * advanced profile bitstream.
     19  * Table 18 of SMPTE 421M after processing up to POSTPROC by
     20  * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock
     21  * layer.
     22  *------------------------------------------------------------------------------
     23  */
     24 
     25 vc1_Status vc1_ParsePictureHeader_ProgressiveIpicture_Adv(void* ctxt, vc1_Info *pInfo)
     26 {
     27     vc1_Status status = VC1_STATUS_OK;
     28     vc1_metadata_t *md = &pInfo->metadata;
     29     vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
     30 
     31     if ((status = vc1_DecodeBitplane(ctxt, pInfo,
     32         md->widthMB, md->heightMB, BPP_ACPRED)) != VC1_STATUS_OK)
     33     {
     34         return status;
     35     }
     36 
     37     if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))
     38     {
     39         VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
     40         if (picLayerHeader->CONDOVER)
     41         {
     42             VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
     43             if (! picLayerHeader->CONDOVER)
     44                 picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;
     45             else
     46             {
     47                 picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;
     48                 if ((status = vc1_DecodeBitplane(ctxt, pInfo,
     49                     md->widthMB,
     50                     md->heightMB, BPP_OVERFLAGS)) != VC1_STATUS_OK)
     51                 {
     52                     return status;
     53                 }
     54             }
     55         }
     56         else
     57             picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;
     58     }
     59 
     60     VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
     61     if (picLayerHeader->TRANSACFRM)
     62     {
     63         VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
     64         picLayerHeader->TRANSACFRM += 2;
     65     }
     66 
     67     VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
     68     if (picLayerHeader->TRANSACFRM2)
     69     {
     70         VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
     71         picLayerHeader->TRANSACFRM2 += 2;
     72     }
     73 
     74     VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
     75 
     76     status = vc1_VOPDQuant(ctxt, pInfo);
     77 
     78     /* Skip parsing of macroblock layer. */
     79 
     80     return status;
     81 }
     82 
     83 /*------------------------------------------------------------------------------
     84  * Parse picture layer.  This function parses interlace I or BI frame for
     85  * advanced profile bitstream.
     86  * Table 82 of SMPTE 421M after processing up to POSTPROC by
     87  * vc1_ParsePictureHeader_Adv() but stopping before processing of macroblock
     88  * layer.
     89  *------------------------------------------------------------------------------
     90  */
     91 
     92 vc1_Status vc1_ParsePictureHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo)
     93 {
     94     vc1_Status status = VC1_STATUS_OK;
     95     vc1_metadata_t *md = &pInfo->metadata;
     96     vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
     97 
     98     if ((status = vc1_DecodeBitplane(ctxt, pInfo,
     99         md->widthMB, md->heightMB, BPP_FIELDTX)) != VC1_STATUS_OK)
    100     {
    101         return status;
    102     }
    103 
    104     if ((status = vc1_DecodeBitplane(ctxt, pInfo,
    105         md->widthMB, md->heightMB, BPP_ACPRED)) != VC1_STATUS_OK)
    106     {
    107         return status;
    108     }
    109 
    110     if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))
    111     {
    112         VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
    113         if (picLayerHeader->CONDOVER)
    114         {
    115             VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
    116             if (! picLayerHeader->CONDOVER)
    117                 picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;
    118             else
    119             {
    120                 picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;
    121                 if ((status = vc1_DecodeBitplane(ctxt, pInfo,
    122                     md->widthMB,
    123                     md->heightMB, BPP_OVERFLAGS)) != VC1_STATUS_OK)
    124                 {
    125                     return status;
    126                 }
    127             }
    128         }
    129         else
    130             picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;
    131     }
    132 
    133     VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
    134     if (picLayerHeader->TRANSACFRM)
    135     {
    136         VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
    137         picLayerHeader->TRANSACFRM += 2;
    138     }
    139 
    140     VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
    141     if (picLayerHeader->TRANSACFRM2)
    142     {
    143         VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
    144         picLayerHeader->TRANSACFRM2 += 2;
    145     }
    146 
    147     VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
    148 
    149     status = vc1_VOPDQuant(ctxt, pInfo);
    150 
    151     /* Skip parsing of macroblock layer. */
    152 
    153     return status;
    154 }
    155 
    156 /*------------------------------------------------------------------------------
    157  * Parse picture layer.  This function parses interlace I or BI field for
    158  * advanced profile bitstream.
    159  * Table 87 of SMPTE 421M after processing up to BFRACTION by
    160  * vc1_ParseFieldHeader_Adv() but stopping before processing of macroblock
    161  * layer.
    162  *------------------------------------------------------------------------------
    163  */
    164 
    165 vc1_Status vc1_ParseFieldHeader_InterlaceIpicture_Adv(void* ctxt, vc1_Info *pInfo)
    166 {
    167     uint32_t tempValue;
    168     vc1_Status status = VC1_STATUS_OK;
    169     vc1_metadata_t *md = &pInfo->metadata;
    170     vc1_PictureLayerHeader *picLayerHeader = &pInfo->picLayerHeader;
    171 
    172     // Reset MVMODE when the second field is an I picture
    173     // to avoid carrying forward the mvmode values from previous field
    174     // especially the intensity compensation value
    175     picLayerHeader->MVMODE = 0;
    176 
    177     VC1_GET_BITS9(5, picLayerHeader->PQINDEX);
    178     if ((status = vc1_CalculatePQuant(pInfo)) != VC1_STATUS_OK) {
    179         DEB("Error parsing I field \n");
    180         return status;
    181     }
    182 
    183     if (picLayerHeader->PQINDEX <= 8)
    184     {
    185         VC1_GET_BITS9(1, picLayerHeader->HALFQP);
    186     }
    187     else
    188         picLayerHeader->HALFQP = 0;
    189 
    190     if (md->QUANTIZER == 1) {
    191         VC1_GET_BITS9(1, picLayerHeader->PQUANTIZER);
    192         picLayerHeader->UniformQuant = picLayerHeader->PQUANTIZER;
    193     }
    194 
    195     if (md->POSTPROCFLAG == 1)
    196         VC1_GET_BITS9(2, tempValue); /* POSTPROC. */
    197 
    198     if ((status = vc1_DecodeBitplane(ctxt, pInfo,
    199     md->widthMB, (md->heightMB+1)/2, BPP_ACPRED)) !=
    200     VC1_STATUS_OK)
    201     {
    202         DEB("Error parsing I field \n");
    203         return status;
    204     }
    205 
    206     if ((md->OVERLAP == 1) && (picLayerHeader->PQUANT <= 8))
    207     {
    208         VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
    209         if (picLayerHeader->CONDOVER)
    210         {
    211             VC1_GET_BITS9(1, picLayerHeader->CONDOVER);
    212             if (! picLayerHeader->CONDOVER)
    213                 picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_ALL;
    214             else
    215             {
    216                 picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_SOME;
    217 
    218 		if ((status = vc1_DecodeBitplane(ctxt, pInfo,
    219 		    md->widthMB,
    220 		    (md->heightMB+1)/2, BPP_OVERFLAGS)) !=
    221 		    VC1_STATUS_OK)
    222 		{
    223 		    DEB("Error parsing I field \n");
    224 		    return status;
    225 		}
    226             }
    227         }
    228         else
    229             picLayerHeader->CONDOVER = VC1_CONDOVER_FLAG_NONE;
    230     }
    231 
    232     VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
    233     if (picLayerHeader->TRANSACFRM)
    234     {
    235         VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM);
    236         picLayerHeader->TRANSACFRM += 2;
    237     }
    238 
    239     VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
    240     if (picLayerHeader->TRANSACFRM2)
    241     {
    242         VC1_GET_BITS9(1, picLayerHeader->TRANSACFRM2);
    243         picLayerHeader->TRANSACFRM2 += 2;
    244     }
    245 
    246     VC1_GET_BITS9(1, picLayerHeader->TRANSDCTAB);
    247 
    248     status = vc1_VOPDQuant(ctxt, pInfo);
    249     if (status != VC1_STATUS_OK) {
    250         DEB("Error parsing I field \n");
    251         return status;
    252     }
    253 
    254     /* Skip parsing of macroblock layer. */
    255 
    256     return status;
    257 }
    258