[svn] / branches / release-1_0-branch / xvidcore / src / prediction / mbprediction.c Repository:
ViewVC logotype

Diff of /branches/release-1_0-branch/xvidcore/src/prediction/mbprediction.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 195, Wed Jun 12 20:38:41 2002 UTC revision 499, Sat Sep 21 03:11:36 2002 UTC
# Line 1  Line 1 
1   /******************************************************************************  /*****************************************************************************
2    *                                                                            *   *
3    *  This file is part of XviD, a free MPEG-4 video encoder/decoder            *   *  XVID MPEG-4 VIDEO CODEC
4    *                                                                            *   *  - Prediction functions -
5    *  XviD is an implementation of a part of one or more MPEG-4 Video tools     *   *
6    *  as specified in ISO/IEC 14496-2 standard.  Those intending to use this    *   *  Copyright(C) 2001-2002 - Michael Militzer <isibaar@xvid.org>
7    *  software module in hardware or software products are advised that its     *   *  Copyright(C) 2001-2002 - Peter Ross <pross@xvid.org>
8    *  use may infringe existing patents or copyrights, and any such use         *   *
9    *  would be at such party's own risk.  The original developer of this        *   *  This program is an implementation of a part of one or more MPEG-4
10    *  software module and his/her company, and subsequent editors and their     *   *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
11    *  companies, will have no liability for use of this software or             *   *  to use this software module in hardware or software products are
12    *  modifications or derivatives thereof.                                     *   *  advised that its use may infringe existing patents or copyrights, and
13    *                                                                            *   *  any such use would be at such party's own risk.  The original
14    *  XviD is free software; you can redistribute it and/or modify it           *   *  developer of this software module and his/her company, and subsequent
15    *  under the terms of the GNU General Public License as published by         *   *  editors and their companies, will have no liability for use of this
16    *  the Free Software Foundation; either version 2 of the License, or         *   *  software or modifications or derivatives thereof.
17    *  (at your option) any later version.                                       *   *
18    *                                                                            *   *  This program is free software; you can redistribute it and/or modify
19    *  XviD is distributed in the hope that it will be useful, but               *   *  it under the terms of the GNU General Public License as published by
20    *  WITHOUT ANY WARRANTY; without even the implied warranty of                *   *  the Free Software Foundation; either version 2 of the License, or
21    *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *   *  (at your option) any later version.
22    *  GNU General Public License for more details.                              *   *
23    *                                                                            *   *  This program is distributed in the hope that it will be useful,
24    *  You should have received a copy of the GNU General Public License         *   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25    *  along with this program; if not, write to the Free Software               *   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  *   *  GNU General Public License for more details.
27    *                                                                            *   *
28    ******************************************************************************/   *  You should have received a copy of the GNU General Public License
29     *  along with this program; if not, write to the Free Software
30   /******************************************************************************   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
31    *                                                                            *   *
32    *  mbprediction.c                                                            *   * $Id: mbprediction.c,v 1.9 2002-09-21 03:07:56 suxen_drol Exp $
33    *                                                                            *   *
34    *  Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org>                  *   ****************************************************************************/
   *  Copyright (C) 2001 - Peter Ross <pross@cs.rmit.edu.au>                    *  
   *                                                                            *  
   *  For more information visit the XviD homepage: http://www.xvid.org         *  
   *                                                                            *  
   ******************************************************************************/  
   
  /******************************************************************************  
   *                                                                            *  
   *  Revision history:                                                         *  
   *                                                                            *  
   *  12.12.2001 improved calc_acdc_prediction; removed need for memcpy         *  
   *  15.12.2001 moved pmv displacement to motion estimation                    *  
   *  30.11.2001 mmx cbp support                                                *  
   *  17.11.2001 initial version                                                *  
   *                                                                            *  
   ******************************************************************************/  
35    
36  #include "../encoder.h"  #include "../encoder.h"
37  #include "mbprediction.h"  #include "mbprediction.h"
# Line 59  Line 43 
43  #define DIV_DIV(A,B)    ( (A) > 0 ? ((A)+((B)>>1))/(B) : ((A)-((B)>>1))/(B) )  #define DIV_DIV(A,B)    ( (A) > 0 ? ((A)+((B)>>1))/(B) : ((A)-((B)>>1))/(B) )
44    
45    
46    /*****************************************************************************
47     * Local inlined function
48     ****************************************************************************/
49    
50  static int __inline  static int __inline
51  rescale(int predict_quant,  rescale(int predict_quant,
52                  int current_quant,                  int current_quant,
# Line 69  Line 57 
57  }  }
58    
59    
60    /*****************************************************************************
61     * Local data
62     ****************************************************************************/
63    
64  static const int16_t default_acdc_values[15] = {  static const int16_t default_acdc_values[15] = {
65          1024,          1024,
66          0, 0, 0, 0, 0, 0, 0,          0, 0, 0, 0, 0, 0, 0,
# Line 76  Line 68 
68  };  };
69    
70    
71    /*****************************************************************************
72     * Functions
73     ****************************************************************************/
74    
75    
76  /*      get dc/ac prediction direction for a single block and place  /*      get dc/ac prediction direction for a single block and place
77          predictor values into MB->pred_values[j][..]          predictor values into MB->pred_values[j][..]
78  */  */
# Line 90  Line 87 
87                           int16_t qcoeff[64],                           int16_t qcoeff[64],
88                           uint32_t current_quant,                           uint32_t current_quant,
89                           int32_t iDcScaler,                           int32_t iDcScaler,
90                           int16_t predictors[8])                           int16_t predictors[8],
91                            const int bound)
92    
93  {  {
94            const int mbpos = (y * mb_width) + x;
95          int16_t *left, *top, *diag, *current;          int16_t *left, *top, *diag, *current;
96    
97          int32_t left_quant = current_quant;          int32_t left_quant = current_quant;
# Line 111  Line 111 
111    
112          // left macroblock          // left macroblock
113    
114          if (x &&          if (x && mbpos >= bound + 1  &&
115                  (pMBs[index - 1].mode == MODE_INTRA ||                  (pMBs[index - 1].mode == MODE_INTRA ||
116                   pMBs[index - 1].mode == MODE_INTRA_Q)) {                   pMBs[index - 1].mode == MODE_INTRA_Q)) {
117    
# Line 121  Line 121 
121          }          }
122          // top macroblock          // top macroblock
123    
124          if (y &&          if (mbpos >= bound + (int)mb_width &&
125                  (pMBs[index - mb_width].mode == MODE_INTRA ||                  (pMBs[index - mb_width].mode == MODE_INTRA ||
126                   pMBs[index - mb_width].mode == MODE_INTRA_Q)) {                   pMBs[index - mb_width].mode == MODE_INTRA_Q)) {
127    
# Line 130  Line 130 
130          }          }
131          // diag macroblock          // diag macroblock
132    
133          if (x && y &&          if (x && mbpos >= bound + (int)mb_width + 1 &&
134                  (pMBs[index - 1 - mb_width].mode == MODE_INTRA ||                  (pMBs[index - 1 - mb_width].mode == MODE_INTRA ||
135                   pMBs[index - 1 - mb_width].mode == MODE_INTRA_Q)) {                   pMBs[index - 1 - mb_width].mode == MODE_INTRA_Q)) {
136    
# Line 241  Line 241 
241          int16_t *pCurrent = pMB->pred_values[block];          int16_t *pCurrent = pMB->pred_values[block];
242          uint32_t i;          uint32_t i;
243    
244            DPRINTF(DPRINTF_COEFF,"predictor[0] %i", predictors[0]);
245    
246          dct_codes[0] += predictors[0];  // dc prediction          dct_codes[0] += predictors[0];  // dc prediction
247          pCurrent[0] = dct_codes[0] * iDcScaler;          pCurrent[0] = dct_codes[0] * iDcScaler;
248    
# Line 248  Line 250 
250                  for (i = 1; i < 8; i++) {                  for (i = 1; i < 8; i++) {
251                          int level = dct_codes[i] + predictors[i];                          int level = dct_codes[i] + predictors[i];
252    
253                            DPRINTF(DPRINTF_COEFF,"predictor[%i] %i",i, predictors[i]);
254    
255                          dct_codes[i] = level;                          dct_codes[i] = level;
256                          pCurrent[i] = level;                          pCurrent[i] = level;
257                          pCurrent[i + 7] = dct_codes[i * 8];                          pCurrent[i + 7] = dct_codes[i * 8];
# Line 255  Line 259 
259          } else if (acpred_direction == 2) {          } else if (acpred_direction == 2) {
260                  for (i = 1; i < 8; i++) {                  for (i = 1; i < 8; i++) {
261                          int level = dct_codes[i * 8] + predictors[i];                          int level = dct_codes[i * 8] + predictors[i];
262                            DPRINTF(DPRINTF_COEFF,"predictor[%i] %i",i*8, predictors[i]);
263    
264                          dct_codes[i * 8] = level;                          dct_codes[i * 8] = level;
265                          pCurrent[i + 7] = level;                          pCurrent[i + 7] = level;
# Line 379  Line 384 
384                          iDcScaler = get_dc_scaler(iQuant, (j < 4) ? 1 : 0);                          iDcScaler = get_dc_scaler(iQuant, (j < 4) ? 1 : 0);
385    
386                          predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64],                          predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64],
387                                                   iQuant, iDcScaler, predictors[j]);                                                   iQuant, iDcScaler, predictors[j], 0);
388    
389                          S += calc_acdc(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]);                          S += calc_acdc(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]);
390    

Legend:
Removed from v.195  
changed lines
  Added in v.499

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4