[cvs] / xvidcore / src / utils / mbtransquant.c Repository:
ViewVC logotype

Diff of /xvidcore/src/utils/mbtransquant.c

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

revision 1.11.2.5, Tue Nov 12 16:05:27 2002 UTC revision 1.13, Sat Sep 21 03:07:56 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    *                                                                            *   *  - MacroBlock transfer and quantization -
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) 2002-2001 Michael Militzer <isibaar@xvid.org>
7    *  software module in hardware or software products are advised that its     *   *               2002-2001 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    *  mbtransquant.c                                                            *   * $Id$
33    *                                                                            *   *
34    *  Copyright (C) 2001 - Peter Ross <pross@cs.rmit.edu.au>                    *   ****************************************************************************/
   *  Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org>                  *  
   *                                                                            *  
   *  For more information visit the XviD homepage: http://www.xvid.org         *  
   *                                                                            *  
   ******************************************************************************/  
   
  /******************************************************************************  
   *                                                                            *  
   *  Revision history:                                                         *  
   *                                                                            *  
   *  29.03.2002 interlacing speedup - used transfer strides instead of             *  
   *             manual field-to-frame conversion                                                           *  
   *  26.03.2002 interlacing support - moved transfers outside loops                        *  
   *  22.12.2001 get_dc_scaler() moved to common.h                                                          *  
   *  19.11.2001 introduced coefficient thresholding (Isibaar)                  *  
   *  17.11.2001 initial version                                                *  
   *                                                                            *  
   ******************************************************************************/  
35    
36  #include <string.h>  #include <string.h>
37    
# Line 65  Line 47 
47  #include "../quant/quant_h263.h"  #include "../quant/quant_h263.h"
48  #include "../encoder.h"  #include "../encoder.h"
49    
 MBFIELDTEST_PTR MBFieldTest;  
   
50  #define MIN(X, Y) ((X)<(Y)?(X):(Y))  #define MIN(X, Y) ((X)<(Y)?(X):(Y))
51  #define MAX(X, Y) ((X)>(Y)?(X):(Y))  #define MAX(X, Y) ((X)>(Y)?(X):(Y))
52    
53  #define TOOSMALL_LIMIT  1       /* skip blocks having a coefficient sum below this value */  #define TOOSMALL_LIMIT 3                /* skip blocks having a coefficient sum below this value */
54    
55    /* this isnt pretty, but its better than 20 ifdefs */
56    
57  void  void
58  MBTransQuantIntra(const MBParam * pParam,  MBTransQuantIntra(const MBParam * pParam,
# Line 193  Line 175 
175          stop_interlacing_timer();          stop_interlacing_timer();
176    
177          for (i = 0; i < 6; i++) {          for (i = 0; i < 6; i++) {
                 uint32_t increase_limit = (iQuant == 1) ? 1 : 0;  
   
178                  /*                  /*
179                   *  no need to transfer 8->16-bit                   *  no need to transfer 8->16-bit
180                   * (this is performed already in motion compensation)                   * (this is performed already in motion compensation)
# Line 213  Line 193 
193                          stop_quant_timer();                          stop_quant_timer();
194                  }                  }
195    
196                  if ((sum >= TOOSMALL_LIMIT + increase_limit) || (qcoeff[i*64] != 0) ||                  if ((sum >= TOOSMALL_LIMIT) || (qcoeff[i*64] != 0) ||
197                          (qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) {                          (qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) {
198    
199                          if (pParam->m_quant_type == H263_QUANT) {                          if (pParam->m_quant_type == H263_QUANT) {
# Line 578  Line 558 
558    
559    
560    
561  /* permute block and return field dct choice */  /* if sum(diff between field lines) < sum(diff between frame lines), use field dct */
562    
563    
564  uint32_t  uint32_t
565  MBDecideFieldDCT(int16_t data[6 * 64])  MBDecideFieldDCT(int16_t data[6 * 64])
566  {  {
         uint32_t field = MBFieldTest(data);  
   
         if (field) {  
                 MBFrameToField(data);  
         }  
   
         return field;  
 }  
567    
   
 /* if sum(diff between field lines) < sum(diff between frame lines), use field dct */  
   
 uint32_t  
 MBFieldTest_c(int16_t data[6 * 64])  
 {  
568          const uint8_t blocks[] =          const uint8_t blocks[] =
569                  { 0 * 64, 0 * 64, 0 * 64, 0 * 64, 2 * 64, 2 * 64, 2 * 64, 2 * 64 };                  { 0 * 64, 0 * 64, 0 * 64, 0 * 64, 2 * 64, 2 * 64, 2 * 64, 2 * 64 };
570          const uint8_t lines[] = { 0, 16, 32, 48, 0, 16, 32, 48 };          const uint8_t lines[] = { 0, 16, 32, 48, 0, 16, 32, 48 };
# Line 632  Line 598 
598                  }                  }
599          }          }
600    
601          return (frame >= (field + 350));          if (frame > field) {
602                    MBFrameToField(data);
603            }
604    
605            return (frame > field);
606  }  }
607    
608    

Legend:
Removed from v.1.11.2.5  
changed lines
  Added in v.1.13

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