videoeditorengine/h263decoder/src/decblock.cpp
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 * Block decoding functions.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #include "h263dConfig.h"
       
    23 
       
    24 #include "decblock.h"
       
    25 #include "blkfunc.h"
       
    26 #include "viddemux.h"
       
    27 #include "idct.h"   
       
    28 
       
    29 
       
    30 /* {{-output"dblfree.txt"}} */
       
    31 /*
       
    32  * dblFree
       
    33  *    
       
    34  *
       
    35  * Parameters:
       
    36  *    None.
       
    37  *
       
    38  * Function:
       
    39  *    This function deinitializes the module.
       
    40  *    Any functions of this module must not be called after dblFree (except 
       
    41  *    for dblLoad).
       
    42  *
       
    43  * Returns:
       
    44  *    >= 0  if succeeded
       
    45  *    < 0   if failed
       
    46  *
       
    47  */
       
    48 
       
    49 int dblFree(void)
       
    50 /* {{-output"dblfree.txt"}} */
       
    51 {
       
    52    return 0;
       
    53 }
       
    54 
       
    55 
       
    56 /* {{-output"dblload.txt"}} */
       
    57 /*
       
    58  * dblLoad
       
    59  *    
       
    60  *
       
    61  * Parameters:
       
    62  *    None.
       
    63  *
       
    64  * Function:
       
    65  *    This function initializes the module.
       
    66  *    dblLoad has to be called before any other function of this module
       
    67  *    is used.
       
    68  *
       
    69  * Returns:
       
    70  *    >= 0  if succeeded
       
    71  *    < 0   if failed
       
    72  *
       
    73  */
       
    74 
       
    75 int dblLoad(void)
       
    76 /* {{-output"dblload.txt"}} */
       
    77 {    
       
    78    return 0;
       
    79 }
       
    80 
       
    81 
       
    82 /* {{-output"dblIdctAndDequant.txt"}} */
       
    83 /*
       
    84  * dblIdctAndDequant
       
    85  *
       
    86  * Parameters:
       
    87  *    block          block array (length 64)
       
    88  *    quant          quantization information
       
    89  *    skip           must be 1 if INTRADC is in the block, otherwise 0
       
    90  *
       
    91  * Function:
       
    92  *    This function makes the dequantization, the clipping and the inverse
       
    93  *    cosine transform for the given block.
       
    94  *
       
    95  * Returns:
       
    96  *    Nothing.
       
    97  *
       
    98  * Error codes:
       
    99  *    None.
       
   100  *
       
   101  */
       
   102 
       
   103 void dblIdctAndDequant(int *block, int quant, int skip)
       
   104 /* {{-output"dblIdctAndDequant.txt"}} */
       
   105 {
       
   106 
       
   107    int rec, i, *tmpBlock, level;
       
   108 
       
   109    /* See section 6.2.1 of H.263 Recommendation for Inverse Quantization
       
   110       formulas. */
       
   111 
       
   112    /* If odd quantization parameter */
       
   113    if (quant & 1) {
       
   114 
       
   115       for (i = 64 - skip, tmpBlock = block + skip; i; i--, tmpBlock++) {
       
   116 
       
   117          if (!(*tmpBlock))
       
   118             continue;
       
   119 
       
   120          level = *tmpBlock;
       
   121 
       
   122          if (level > 0) {
       
   123             rec = quant * ((level << 1) + 1);
       
   124             *tmpBlock = (rec < 2048) ? rec : 2047;
       
   125          }
       
   126 
       
   127          else {
       
   128             rec = -(quant * (((-level) << 1) + 1));
       
   129             *tmpBlock = (rec < -2048) ? -2048 : rec;
       
   130          }
       
   131       }
       
   132    }
       
   133 
       
   134    /* Else even quantization parameter */
       
   135    else {
       
   136 
       
   137       /* For loop copy-pasted from the previous case due to speed 
       
   138          optimization */
       
   139       for (i = 64 - skip, tmpBlock = block + skip; i; i--, tmpBlock++) {
       
   140 
       
   141          if (!(*tmpBlock))
       
   142             continue;
       
   143 
       
   144          level = *tmpBlock;
       
   145 
       
   146          if (level > 0) {
       
   147             rec = quant * ((level << 1) + 1) - 1;
       
   148             *tmpBlock = (rec < 2048) ? rec : 2047;
       
   149          }
       
   150 
       
   151          else {
       
   152             rec = -(quant * (((-level) << 1) + 1) - 1);
       
   153             *tmpBlock = (rec < -2048) ? -2048 : rec;
       
   154          }
       
   155       }
       
   156    }
       
   157    idct(block);
       
   158 }
       
   159 
       
   160 
       
   161 /*
       
   162  * dblIdct
       
   163  *
       
   164  * Parameters:
       
   165  *    block          block array (length 64)
       
   166  *
       
   167  * Function:
       
   168  *    This function makes the inverse
       
   169  *    cosine transform for the given block.
       
   170  *
       
   171  * Returns:
       
   172  *    Nothing.
       
   173  *
       
   174  * Error codes:
       
   175  *    None.
       
   176  *
       
   177  */
       
   178 
       
   179 void dblIdct(int *block)
       
   180 
       
   181 {
       
   182    idct(block);
       
   183 }
       
   184 // End of File