[svn] / trunk / xvidcore / src / image / postprocessing.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/image/postprocessing.c

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

revision 1805, Thu Nov 27 00:47:03 2008 UTC revision 1911, Sat Dec 18 10:13:38 2010 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  - Postprocessing  functions -   *  - Postprocessing  functions -
5   *   *
6   *  Copyright(C) 2003-2004 Michael Militzer <isibaar@xvid.org>   *  Copyright(C) 2003-2010 Michael Militzer <isibaar@xvid.org>
7   *                    2004 Marc Fauconneau   *                    2004 Marc Fauconneau
8   *   *
9   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
# Line 20  Line 20 
20   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
21   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   *   *
23   * $Id: postprocessing.c,v 1.5 2008-11-27 00:47:03 Isibaar Exp $   * $Id: postprocessing.c,v 1.6 2010-12-18 10:13:38 Isibaar Exp $
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
# Line 54  Line 54 
54  }  }
55    
56  void  void
57  image_postproc(XVID_POSTPROC *tbls, IMAGE * img, int edged_width,  stripe_deblock_h(SMPDeblock *h)
                                 const MACROBLOCK * mbs, int mb_width, int mb_height, int mb_stride,  
                                 int flags, int brightness, int frame_num, int bvop)  
58  {  {
59          const int edged_width2 = edged_width /2;          const int stride = h->stride;
60            const int stride2 = stride /2;
61    
62          int i,j;          int i,j;
63          int quant;          int quant;
         int dering = flags & XVID_DERINGY;  
64    
65          /* luma: j,i in block units */          /* luma: j,i in block units */
66          if ((flags & XVID_DEBLOCKY))          if ((h->flags & XVID_DEBLOCKY))
67          {          {
68                  for (j = 1; j < mb_height*2; j++)               /* horizontal deblocking */                  int dering = h->flags & XVID_DERINGY;
69                  for (i = 0; i < mb_width*2; i++)  
70                    for (j = 1; j < h->stop_y; j++)         /* horizontal luma deblocking */
71                    for (i = h->start_x; i < h->stop_x; i++)
72                  {                  {
73                          quant = mbs[(j+0)/2*mb_stride + (i/2)].quant;                          quant = h->mbs[(j+0)/2*h->mb_stride + (i/2)].quant;
74                          deblock8x8_h(tbls, img->y + j*8*edged_width + i*8, edged_width, quant, dering);                          deblock8x8_h(h->tbls, h->img->y + j*8*stride + i*8, stride, quant, dering);
75                    }
76                  }                  }
77    
78                  for (j = 0; j < mb_height*2; j++)               /* vertical deblocking */          /* chroma */
79                  for (i = 1; i < mb_width*2; i++)          if ((h->flags & XVID_DEBLOCKUV))
80                  {                  {
81                          quant = mbs[(j+0)/2*mb_stride + (i/2)].quant;                  int dering = h->flags & XVID_DERINGUV;
82                          deblock8x8_v(tbls, img->y + j*8*edged_width + i*8, edged_width, quant, dering);  
83                    for (j = 1; j < h->stop_y/2; j++)               /* horizontal deblocking */
84                    for (i = h->start_x/2; i < h->stop_x/2; i++)
85                    {
86                            quant = h->mbs[(j+0)*h->mb_stride + i].quant;
87                            deblock8x8_h(h->tbls, h->img->u + j*8*stride2 + i*8, stride2, quant, dering);
88                            deblock8x8_h(h->tbls, h->img->v + j*8*stride2 + i*8, stride2, quant, dering);
89                    }
90                  }                  }
91          }          }
92    
93    void
94    stripe_deblock_v(SMPDeblock *h)
95    {
96            const int stride = h->stride;
97            const int stride2 = stride /2;
98    
99            int i,j;
100            int quant;
101    
102            /* luma: j,i in block units */
103            if ((h->flags & XVID_DEBLOCKY))
104            {
105                    int dering = h->flags & XVID_DERINGY;
106    
107                    for (j = h->start_y; j < h->stop_y; j++)                /* vertical deblocking */
108                    for (i = 1; i < h->stop_x; i++)
109                    {
110                            quant = h->mbs[(j+0)/2*h->mb_stride + (i/2)].quant;
111                            deblock8x8_v(h->tbls, h->img->y + j*8*stride + i*8, stride, quant, dering);
112                    }
113            }
114    
115          /* chroma */          /* chroma */
116          if ((flags & XVID_DEBLOCKUV))          if ((h->flags & XVID_DEBLOCKUV))
117          {          {
118                  dering = flags & XVID_DERINGUV;                  int dering = h->flags & XVID_DERINGUV;
119    
120                  for (j = 1; j < mb_height; j++)         /* horizontal deblocking */                  for (j = h->start_y/2; j < h->stop_y/2; j++)            /* vertical deblocking */
121                  for (i = 0; i < mb_width; i++)                  for (i = 1; i < h->stop_x/2; i++)
122                  {                  {
123                          quant = mbs[(j+0)*mb_stride + i].quant;                          quant = h->mbs[(j+0)*h->mb_stride + i].quant;
124                          deblock8x8_h(tbls, img->u + j*8*edged_width2 + i*8, edged_width2, quant, dering);                          deblock8x8_v(h->tbls, h->img->u + j*8*stride2 + i*8, stride2, quant, dering);
125                          deblock8x8_h(tbls, img->v + j*8*edged_width2 + i*8, edged_width2, quant, dering);                          deblock8x8_v(h->tbls, h->img->v + j*8*stride2 + i*8, stride2, quant, dering);
126                    }
127            }
128                  }                  }
129    
130                  for (j = 0; j < mb_height; j++)         /* vertical deblocking */  void
131                  for (i = 1; i < mb_width; i++)  image_postproc(XVID_POSTPROC *tbls, IMAGE * img, int edged_width,
132                                    const MACROBLOCK * mbs, int mb_width, int mb_height, int mb_stride,
133                                    int flags, int brightness, int frame_num, int bvop, int threads)
134                  {                  {
135                          quant = mbs[(j+0)*mb_stride + i].quant;          int k, num_threads = MAX(1, MIN(threads, 4));
136                          deblock8x8_v(tbls, img->u + j*8*edged_width2 + i*8, edged_width2, quant, dering);          SMPDeblock data[4];
137                          deblock8x8_v(tbls, img->v + j*8*edged_width2 + i*8, edged_width2, quant, dering);          void *status = NULL;
138    
139            /* horizontal deblocking, dispatch threads */
140            for (k = 0; k < num_threads; k++) {
141                    data[k].flags = flags;
142                    data[k].img = img;
143                    data[k].mb_stride = mb_stride;
144                    data[k].mbs = mbs;
145                    data[k].stride = edged_width;
146                    data[k].tbls = tbls;
147    
148                    data[k].start_x = (k*mb_width / num_threads)*2;
149                    data[k].stop_x = ((k+1)*mb_width / num_threads)*2;
150    
151                    data[k].stop_y = mb_height*2;
152                  }                  }
153    
154            /* create threads */
155            for (k = 1; k < num_threads; k++) {
156                    pthread_create(&data[k].handle, NULL,
157                                   (void*)stripe_deblock_h, (void*)&data[k]);
158          }          }
159    
160            stripe_deblock_h(&data[0]);
161    
162            /* wait until all threads are finished */
163            for (k = 1; k < num_threads; k++) {
164                    pthread_join(data[k].handle, &status);
165            }
166    
167    
168            /* vertical deblocking, dispatch threads */
169            for (k = 0; k < num_threads; k++) {
170                    data[k].start_y = (k*mb_height / num_threads)*2;
171                    data[k].stop_y = ((k+1)*mb_height / num_threads)*2;
172                    data[k].stop_x = mb_width*2;
173            }
174    
175            /* create threads */
176            for (k = 1; k < num_threads; k++) {
177                    pthread_create(&data[k].handle, NULL,
178                                   (void*)stripe_deblock_v, (void*)&data[k]);
179            }
180    
181            stripe_deblock_v(&data[0]);
182    
183            /* wait until all threads are finished */
184            for (k = 1; k < num_threads; k++) {
185                    pthread_join(data[k].handle, &status);
186            }
187    
188    
189          if (!bvop)          if (!bvop)
190                  tbls->prev_quant = mbs->quant;                  tbls->prev_quant = mbs->quant;
191    

Legend:
Removed from v.1805  
changed lines
  Added in v.1911

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