]> Creatis software - gdcm.git/blob - src/gdcmmpeg2/src/mpeg2dec/store.c
> // Don't waste time checking tags where VM is OB and OW, since we know
[gdcm.git] / src / gdcmmpeg2 / src / mpeg2dec / store.c
1 /* store.c, picture output routines                                         */
2
3 /* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
4
5 /*
6  * Disclaimer of Warranty
7  *
8  * These software programs are available to the user without any license fee or
9  * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
10  * any and all warranties, whether express, implied, or statuary, including any
11  * implied warranties or merchantability or of fitness for a particular
12  * purpose.  In no event shall the copyright-holder be liable for any
13  * incidental, punitive, or consequential damages of any kind whatsoever
14  * arising from the use of these programs.
15  *
16  * This disclaimer of warranty extends to the user of these programs and user's
17  * customers, employees, agents, transferees, successors, and assigns.
18  *
19  * The MPEG Software Simulation Group does not represent or warrant that the
20  * programs furnished hereunder are free of infringement of any third-party
21  * patents.
22  *
23  * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
24  * are subject to royalty fees to patent holders.  Many of these patents are
25  * general enough such that they are unavoidable regardless of implementation
26  * design.
27  *
28  */
29
30 #include <stdlib.h> /* for malloc */
31 #include <string.h> /* for strcat */
32
33 #include "config.h"
34 #include "global.h"
35
36 /* private prototypes */
37 static void store_one _ANSI_ARGS_((char *outname, unsigned char *src[],
38   int offset, int incr, int height));
39 static void store_yuv _ANSI_ARGS_((char *outname, unsigned char *src[],
40   int offset, int incr, int height));
41 static void store_sif _ANSI_ARGS_((char *outname, unsigned char *src[],
42   int offset, int incr, int height));
43 static void store_ppm_tga _ANSI_ARGS_((char *outname, unsigned char *src[],
44   int offset, int incr, int height, int tgaflag));
45 static void store_in_mem _ANSI_ARGS_((char *outmem, unsigned char *src[],
46   int offset, int incr, int height));
47 static void store_yuv1 _ANSI_ARGS_((char *name, unsigned char *src,
48   int offset, int incr, int width, int height));
49 static void putbyte _ANSI_ARGS_((int c));
50 static void putword _ANSI_ARGS_((int w));
51 static void mem_putbyte _ANSI_ARGS_((int c));
52 /*static void mem_putword _ANSI_ARGS_((int w));*/
53 static void conv422to444 _ANSI_ARGS_((unsigned char *src, unsigned char *dst));
54 static void conv420to422 _ANSI_ARGS_((unsigned char *src, unsigned char *dst));
55
56 #define OBFRSIZE 4096
57 static unsigned char obfr[OBFRSIZE];
58 static unsigned char *optr;
59 static ostream *outfile;
60 unsigned char *static_malloc[6] = {0,0,0,0,0,0}; /*worse case there is 6 buffer in this impl unit.*/
61
62 void FreeStaticBuffer()
63 {
64   int i;
65   for(i=0;i<6;++i)
66     free(static_malloc[i]);
67 }
68
69 /*
70  * store a picture as either one frame or two fields
71  */
72 void Write_Frame(src,frame)
73 unsigned char *src[];
74 int frame;
75 {
76   char outname[FILENAME_LENGTH];
77
78   if (progressive_sequence || progressive_frame || Frame_Store_Flag)
79   {
80     /* progressive */
81     my_sprintf(outname,Output_Picture_Filename,frame,'f');
82     store_one(outname,src,0,Coded_Picture_Width,vertical_size);
83   }
84   else
85   {
86     /* interlaced */
87     my_sprintf(outname,Output_Picture_Filename,frame,'a');
88     store_one(outname,src,0,Coded_Picture_Width<<1,vertical_size>>1);
89
90     my_sprintf(outname,Output_Picture_Filename,frame,'b');
91     store_one(outname,src,
92       Coded_Picture_Width,Coded_Picture_Width<<1,vertical_size>>1);
93   }
94 }
95
96 /*
97  * store one frame or one field
98  */
99 static void store_one(outname,src,offset,incr,height)
100 char *outname;
101 unsigned char *src[];
102 int offset, incr, height;
103 {
104   switch (Output_Type)
105   {
106   case T_YUV:
107     store_yuv(outname,src,offset,incr,height);
108     break;
109   case T_SIF:
110     store_sif(outname,src,offset,incr,height);
111     break;
112   case T_TGA:
113     store_ppm_tga(outname,src,offset,incr,height,1);
114     break;
115   case T_PPM:
116     store_ppm_tga(outname,src,offset,incr,height,0);
117     break;
118   case T_MEM:
119     store_in_mem(OUTMEM,src,offset,incr,height);
120     break;
121 #ifdef DISPLAY
122   case T_X11:
123     dither(src);
124     break;
125 #endif
126   default:
127     break;
128   }
129 }
130
131 /* separate headerless files for y, u and v */
132 static void store_yuv(outname,src,offset,incr,height)
133 char *outname;
134 unsigned char *src[];
135 int offset,incr,height;
136 {
137   int hsize;
138   char tmpname[FILENAME_LENGTH];
139
140   hsize = horizontal_size;
141
142   my_sprintf(tmpname,"%s.Y",outname);
143   store_yuv1(tmpname,src[0],offset,incr,hsize,height);
144
145   if (chroma_format!=CHROMA444)
146   {
147     offset>>=1; incr>>=1; hsize>>=1;
148   }
149
150   if (chroma_format==CHROMA420)
151   {
152     height>>=1;
153   }
154
155   my_sprintf(tmpname,"%s.U",outname);
156   store_yuv1(tmpname,src[1],offset,incr,hsize,height);
157
158   my_sprintf(tmpname,"%s.V",outname);
159   store_yuv1(tmpname,src[2],offset,incr,hsize,height);
160 }
161
162 /* auxiliary routine */
163 static void store_yuv1(name,src,offset,incr,width,height)
164 char *name;
165 unsigned char *src;
166 int offset,incr,width,height;
167 {
168   int i, j;
169   unsigned char *p;
170   ostream file;
171
172   if (!Quiet_Flag)
173     my_fprintf("saving %s\n",name);
174
175   outfile = &file;
176   if(!my_fopen(name, "wb", outfile))
177   {
178     my_sprintf(Error_Text,"Couldn't create %s\n",name);
179     Error(Error_Text);
180   }
181
182   optr=obfr;
183
184   for (i=0; i<height; i++)
185   {
186     p = src + offset + incr*i;
187     for (j=0; j<width; j++)
188       putbyte(*p++);
189   }
190
191   if (optr!=obfr)
192     my_fwrite(obfr,optr-obfr,1,outfile);
193
194   my_fclose(outfile);
195 }
196
197 /*
198  * store as headerless file in U,Y,V,Y format
199  */
200 static void store_sif (outname,src,offset,incr,height)
201 char *outname;
202 unsigned char *src[];
203 int offset, incr, height;
204 {
205   int i,j;
206   unsigned char *py, *pu, *pv;
207   static unsigned char *u422, *v422;
208   ostream file;
209
210   if (chroma_format==CHROMA444)
211     Error("4:4:4 not supported for SIF format");
212
213   if (chroma_format==CHROMA422)
214   {
215     u422 = src[1];
216     v422 = src[2];
217   }
218   else
219   {
220     if (!u422)
221     {
222       if (!(u422 = (unsigned char *)malloc((Coded_Picture_Width>>1)
223                                            *Coded_Picture_Height)))
224         Error("malloc failed");
225       static_malloc[0] = u422;
226       if (!(v422 = (unsigned char *)malloc((Coded_Picture_Width>>1)
227                                            *Coded_Picture_Height)))
228         Error("malloc failed");
229       static_malloc[1] = v422;
230     }
231   
232     conv420to422(src[1],u422);
233     conv420to422(src[2],v422);
234   }
235
236   strcat(outname,".SIF");
237
238   if (!Quiet_Flag)
239     my_fprintf("saving %s\n",outname);
240
241   outfile = &file;
242   if(!my_fopen(outname, "wb", outfile))
243   {
244     my_sprintf(Error_Text,"Couldn't create %s\n",outname);
245     Error(Error_Text);
246   }
247
248   optr = obfr;
249
250   for (i=0; i<height; i++)
251   {
252     py = src[0] + offset + incr*i;
253     pu = u422 + (offset>>1) + (incr>>1)*i;
254     pv = v422 + (offset>>1) + (incr>>1)*i;
255
256     for (j=0; j<horizontal_size; j+=2)
257     {
258       putbyte(*pu++);
259       putbyte(*py++);
260       putbyte(*pv++);
261       putbyte(*py++);
262     }
263   }
264
265   if (optr!=obfr)
266     my_fwrite(obfr,optr-obfr,1,outfile);
267
268   my_fclose(outfile);
269 }
270
271 /*
272  * store as PPM (PBMPLUS) or uncompressed Truevision TGA ('Targa') file
273  */
274 static void store_ppm_tga(outname,src,offset,incr,height,tgaflag)
275 char *outname;
276 unsigned char *src[];
277 int offset, incr, height;
278 int tgaflag;
279 {
280   int i, j;
281   int y, u, v, r, g, b;
282   int crv, cbu, cgu, cgv;
283   unsigned char *py, *pu, *pv;
284   static unsigned char tga24[14] = {0,0,2,0,0,0,0, 0,0,0,0,0,24,32};
285   char header[FILENAME_LENGTH];
286   static unsigned char *u422, *v422, *u444, *v444;
287   ostream file;
288
289   if (chroma_format==CHROMA444)
290   {
291     u444 = src[1];
292     v444 = src[2];
293   }
294   else
295   {
296     if (!u444)
297     {
298       if (chroma_format==CHROMA420)
299       {
300         if (!(u422 = (unsigned char *)malloc((Coded_Picture_Width>>1)
301                                              *Coded_Picture_Height)))
302           Error("malloc failed");
303         static_malloc[2] = u422;
304         if (!(v422 = (unsigned char *)malloc((Coded_Picture_Width>>1)
305                                              *Coded_Picture_Height)))
306           Error("malloc failed");
307         static_malloc[3] = v422;
308       }
309
310       if (!(u444 = (unsigned char *)malloc(Coded_Picture_Width
311                                            *Coded_Picture_Height)))
312         Error("malloc failed");
313       static_malloc[4] = u444;
314
315       if (!(v444 = (unsigned char *)malloc(Coded_Picture_Width
316                                            *Coded_Picture_Height)))
317         Error("malloc failed");
318       static_malloc[5] = v444;
319     }
320
321     if (chroma_format==CHROMA420)
322     {
323       conv420to422(src[1],u422);
324       conv420to422(src[2],v422);
325       conv422to444(u422,u444);
326       conv422to444(v422,v444);
327     }
328     else
329     {
330       conv422to444(src[1],u444);
331       conv422to444(src[2],v444);
332     }
333   }
334
335   strcat(outname,tgaflag ? ".tga" : ".ppm");
336
337   if (!Quiet_Flag)
338     my_fprintf("saving %s\n",outname);
339
340   outfile = &file;
341   if(! my_fopen(outname, "wb", outfile))
342   {
343     my_sprintf(Error_Text,"Couldn't create %s\n",outname);
344     Error(Error_Text);
345   }
346
347   optr = obfr;
348
349   if (tgaflag)
350   {
351     /* TGA header */
352     for (i=0; i<12; i++)
353       putbyte(tga24[i]);
354
355     putword(horizontal_size); putword(height);
356     putbyte(tga24[12]); putbyte(tga24[13]);
357   }
358   else
359   {
360     /* PPM header */
361     my_sprintf(header,"P6\n%d %d\n255\n",horizontal_size,height);
362
363     for (i=0; header[i]!=0; i++)
364       putbyte(header[i]);
365   }
366
367   /* matrix coefficients */
368   crv = Inverse_Table_6_9[matrix_coefficients][0];
369   cbu = Inverse_Table_6_9[matrix_coefficients][1];
370   cgu = Inverse_Table_6_9[matrix_coefficients][2];
371   cgv = Inverse_Table_6_9[matrix_coefficients][3];
372   
373   for (i=0; i<height; i++)
374   {
375     py = src[0] + offset + incr*i;
376     pu = u444 + offset + incr*i;
377     pv = v444 + offset + incr*i;
378
379     for (j=0; j<horizontal_size; j++)
380     {
381       u = *pu++ - 128;
382       v = *pv++ - 128;
383       y = 76309 * (*py++ - 16); /* (255/219)*65536 */
384       r = Clip[(y + crv*v + 32768)>>16];
385       g = Clip[(y - cgu*u - cgv*v + 32768)>>16];
386       b = Clip[(y + cbu*u + 32786)>>16];
387
388       if (tgaflag)
389       {
390         putbyte(b); putbyte(g); putbyte(r);
391       }
392       else
393       {
394         putbyte(r); putbyte(g); putbyte(b);
395       }
396     }
397   }
398
399   if (optr!=obfr)
400     my_fwrite(obfr,optr-obfr,1,outfile);
401
402   my_fclose(outfile);
403 }
404
405 /*
406  * store as PPM (PBMPLUS) or uncompressed Truevision TGA ('Targa') file
407  */
408 static void store_in_mem(outmem,src,offset,incr,height)
409 char *outmem;
410 unsigned char *src[];
411 int offset, incr, height;
412 {
413   int i, j;
414   int y, u, v, r, g, b;
415   int crv, cbu, cgu, cgv;
416   unsigned char *py, *pu, *pv;
417   /*static unsigned char tga24[14] = {0,0,2,0,0,0,0, 0,0,0,0,0,24,32};*/
418   /*char header[FILENAME_LENGTH];*/
419   static unsigned char *u422, *v422, *u444, *v444;
420   /*ostream file;*/
421   outmem = OUTMEM;
422
423   if (chroma_format==CHROMA444)
424   {
425     u444 = src[1];
426     v444 = src[2];
427   }
428   else
429   {
430     if (!u444)
431     {
432       if (chroma_format==CHROMA420)
433       {
434         if (!(u422 = (unsigned char *)malloc((Coded_Picture_Width>>1)
435                                              *Coded_Picture_Height)))
436           Error("malloc failed");
437         static_malloc[2] = u422;
438         if (!(v422 = (unsigned char *)malloc((Coded_Picture_Width>>1)
439                                              *Coded_Picture_Height)))
440           Error("malloc failed");
441         static_malloc[3] = v422;
442       }
443
444       if (!(u444 = (unsigned char *)malloc(Coded_Picture_Width
445                                            *Coded_Picture_Height)))
446         Error("malloc failed");
447       static_malloc[4] = u444;
448
449       if (!(v444 = (unsigned char *)malloc(Coded_Picture_Width
450                                            *Coded_Picture_Height)))
451         Error("malloc failed");
452       static_malloc[5] = v444;
453     }
454
455     if (chroma_format==CHROMA420)
456     {
457       conv420to422(src[1],u422);
458       conv420to422(src[2],v422);
459       conv422to444(u422,u444);
460       conv422to444(v422,v444);
461     }
462     else
463     {
464       conv422to444(src[1],u444);
465       conv422to444(src[2],v444);
466     }
467   }
468
469   /*strcat(outname,tgaflag ? ".tga" : ".ppm");*/
470
471   /*if (!Quiet_Flag)
472     my_fprintf("saving %s\n",outname);*/
473
474  /* outfile = &file;
475   if(! my_fopen(outname, "wb", outfile))
476   {
477     my_sprintf(Error_Text,"Couldn't create %s\n",outname);
478     Error(Error_Text);
479   }*/
480
481   optr = obfr;
482
483 #if 0
484   if (tgaflag)
485   {
486     /* TGA header */
487     for (i=0; i<12; i++)
488       putbyte(tga24[i]);
489
490     putword(horizontal_size); putword(height);
491     putbyte(tga24[12]); putbyte(tga24[13]);
492   }
493   else
494   {
495     /* PPM header */
496     my_sprintf(header,"P6\n%d %d\n255\n",horizontal_size,height);
497
498     for (i=0; header[i]!=0; i++)
499       putbyte(header[i]);
500   }
501 #endif
502
503   /* matrix coefficients */
504   crv = Inverse_Table_6_9[matrix_coefficients][0];
505   cbu = Inverse_Table_6_9[matrix_coefficients][1];
506   cgu = Inverse_Table_6_9[matrix_coefficients][2];
507   cgv = Inverse_Table_6_9[matrix_coefficients][3];
508   
509   for (i=0; i<height; i++)
510   {
511     py = src[0] + offset + incr*i;
512     pu = u444 + offset + incr*i;
513     pv = v444 + offset + incr*i;
514
515     for (j=0; j<horizontal_size; j++)
516     {
517       u = *pu++ - 128;
518       v = *pv++ - 128;
519       y = 76309 * (*py++ - 16); /* (255/219)*65536 */
520       r = Clip[(y + crv*v + 32768)>>16];
521       g = Clip[(y - cgu*u - cgv*v + 32768)>>16];
522       b = Clip[(y + cbu*u + 32786)>>16];
523
524
525 #if 0
526       if (tgaflag)
527       {
528         putbyte(b); putbyte(g); putbyte(r);
529       }
530       else
531       {
532         putbyte(r); putbyte(g); putbyte(b);
533       }
534 #else
535      mem_putbyte(r); mem_putbyte(g); mem_putbyte(b);
536 #endif
537     }
538   }
539
540   if (optr!=obfr)
541     {
542     /*my_fwrite(obfr,optr-obfr,1,outfile);*/
543     memcpy(OUTMEM,obfr,optr-obfr); OUTMEM+=(optr-obfr);
544     }
545
546   /*my_fclose(outfile);*/
547 }
548
549 static void putbyte(c)
550 int c;
551 {
552   *optr++ = c;
553
554   if (optr == obfr+OBFRSIZE)
555   {
556     my_fwrite(obfr,OBFRSIZE,1,outfile);
557     optr = obfr;
558   }
559 }
560
561 static void putword(w)
562 int w;
563 {
564   putbyte(w); putbyte(w>>8);
565 }
566
567 static void mem_putbyte(c)
568 int c;
569 {
570   *optr++ = c;
571
572   if (optr == obfr+OBFRSIZE)
573   {
574     /*my_fwrite(obfr,OBFRSIZE,1,outfile);*/
575     memcpy(OUTMEM,obfr,OBFRSIZE);OUTMEM+=OBFRSIZE;
576     optr = obfr;
577   }
578 }
579
580 /*static void mem_putword(w)
581 int w;
582 {
583   mem_putbyte(w); mem_putbyte(w>>8);
584 }*/
585
586 /* horizontal 1:2 interpolation filter */
587 static void conv422to444(src,dst)
588 unsigned char *src,*dst;
589 {
590   int i, i2, w, j, im3, im2, im1, ip1, ip2, ip3;
591
592   w = Coded_Picture_Width>>1;
593
594   if (base.MPEG2_Flag)
595   {
596     for (j=0; j<Coded_Picture_Height; j++)
597     {
598       for (i=0; i<w; i++)
599       {
600         i2 = i<<1;
601         im2 = (i<2) ? 0 : i-2;
602         im1 = (i<1) ? 0 : i-1;
603         ip1 = (i<w-1) ? i+1 : w-1;
604         ip2 = (i<w-2) ? i+2 : w-1;
605         ip3 = (i<w-3) ? i+3 : w-1;
606
607         /* FIR filter coefficients (*256): 21 0 -52 0 159 256 159 0 -52 0 21 */
608         /* even samples (0 0 256 0 0) */
609         dst[i2] = src[i];
610
611         /* odd samples (21 -52 159 159 -52 21) */
612         dst[i2+1] = Clip[(int)(21*(src[im2]+src[ip3])
613                         -52*(src[im1]+src[ip2]) 
614                        +159*(src[i]+src[ip1])+128)>>8];
615       }
616       src+= w;
617       dst+= Coded_Picture_Width;
618     }
619   }
620   else
621   {
622     for (j=0; j<Coded_Picture_Height; j++)
623     {
624       for (i=0; i<w; i++)
625       {
626
627         i2 = i<<1;
628         im3 = (i<3) ? 0 : i-3;
629         im2 = (i<2) ? 0 : i-2;
630         im1 = (i<1) ? 0 : i-1;
631         ip1 = (i<w-1) ? i+1 : w-1;
632         ip2 = (i<w-2) ? i+2 : w-1;
633         ip3 = (i<w-3) ? i+3 : w-1;
634
635         /* FIR filter coefficients (*256): 5 -21 70 228 -37 11 */
636         dst[i2] =   Clip[(int)(  5*src[im3]
637                          -21*src[im2]
638                          +70*src[im1]
639                         +228*src[i]
640                          -37*src[ip1]
641                          +11*src[ip2]+128)>>8];
642
643        dst[i2+1] = Clip[(int)(  5*src[ip3]
644                          -21*src[ip2]
645                          +70*src[ip1]
646                         +228*src[i]
647                          -37*src[im1]
648                          +11*src[im2]+128)>>8];
649       }
650       src+= w;
651       dst+= Coded_Picture_Width;
652     }
653   }
654 }
655
656 /* vertical 1:2 interpolation filter */
657 static void conv420to422(src,dst)
658 unsigned char *src,*dst;
659 {
660   int w, h, i, j, j2;
661   int jm6, jm5, jm4, jm3, jm2, jm1, jp1, jp2, jp3, jp4, jp5, jp6, jp7;
662
663   w = Coded_Picture_Width>>1;
664   h = Coded_Picture_Height>>1;
665
666   if (progressive_frame)
667   {
668     /* intra frame */
669     for (i=0; i<w; i++)
670     {
671       for (j=0; j<h; j++)
672       {
673         j2 = j<<1;
674         jm3 = (j<3) ? 0 : j-3;
675         jm2 = (j<2) ? 0 : j-2;
676         jm1 = (j<1) ? 0 : j-1;
677         jp1 = (j<h-1) ? j+1 : h-1;
678         jp2 = (j<h-2) ? j+2 : h-1;
679         jp3 = (j<h-3) ? j+3 : h-1;
680
681         /* FIR filter coefficients (*256): 5 -21 70 228 -37 11 */
682         /* New FIR filter coefficients (*256): 3 -16 67 227 -32 7 */
683         dst[w*j2] =     Clip[(int)(  3*src[w*jm3]
684                              -16*src[w*jm2]
685                              +67*src[w*jm1]
686                             +227*src[w*j]
687                              -32*src[w*jp1]
688                              +7*src[w*jp2]+128)>>8];
689
690         dst[w*(j2+1)] = Clip[(int)(  3*src[w*jp3]
691                              -16*src[w*jp2]
692                              +67*src[w*jp1]
693                             +227*src[w*j]
694                              -32*src[w*jm1]
695                              +7*src[w*jm2]+128)>>8];
696       }
697       src++;
698       dst++;
699     }
700   }
701   else
702   {
703     /* intra field */
704     for (i=0; i<w; i++)
705     {
706       for (j=0; j<h; j+=2)
707       {
708         j2 = j<<1;
709
710         /* top field */
711         jm6 = (j<6) ? 0 : j-6;
712         jm4 = (j<4) ? 0 : j-4;
713         jm2 = (j<2) ? 0 : j-2;
714         jp2 = (j<h-2) ? j+2 : h-2;
715         jp4 = (j<h-4) ? j+4 : h-2;
716         jp6 = (j<h-6) ? j+6 : h-2;
717
718         /* Polyphase FIR filter coefficients (*256): 2 -10 35 242 -18 5 */
719         /* New polyphase FIR filter coefficients (*256): 1 -7 30 248 -21 5 */
720         dst[w*j2] = Clip[(int)(  1*src[w*jm6]
721                          -7*src[w*jm4]
722                          +30*src[w*jm2]
723                         +248*src[w*j]
724                          -21*src[w*jp2]
725                           +5*src[w*jp4]+128)>>8];
726
727         /* Polyphase FIR filter coefficients (*256): 11 -38 192 113 -30 8 */
728         /* New polyphase FIR filter coefficients (*256):7 -35 194 110 -24 4 */
729         dst[w*(j2+2)] = Clip[(int)( 7*src[w*jm4]
730                              -35*src[w*jm2]
731                             +194*src[w*j]
732                             +110*src[w*jp2]
733                              -24*src[w*jp4]
734                               +4*src[w*jp6]+128)>>8];
735
736         /* bottom field */
737         jm5 = (j<5) ? 1 : j-5;
738         jm3 = (j<3) ? 1 : j-3;
739         jm1 = (j<1) ? 1 : j-1;
740         jp1 = (j<h-1) ? j+1 : h-1;
741         jp3 = (j<h-3) ? j+3 : h-1;
742         jp5 = (j<h-5) ? j+5 : h-1;
743         jp7 = (j<h-7) ? j+7 : h-1;
744
745         /* Polyphase FIR filter coefficients (*256): 11 -38 192 113 -30 8 */
746         /* New polyphase FIR filter coefficients (*256):7 -35 194 110 -24 4 */
747         dst[w*(j2+1)] = Clip[(int)( 7*src[w*jp5]
748                              -35*src[w*jp3]
749                             +194*src[w*jp1]
750                             +110*src[w*jm1]
751                              -24*src[w*jm3]
752                               +4*src[w*jm5]+128)>>8];
753
754         dst[w*(j2+3)] = Clip[(int)(  1*src[w*jp7]
755                              -7*src[w*jp5]
756                              +30*src[w*jp3]
757                             +248*src[w*jp1]
758                              -21*src[w*jm1]
759                               +5*src[w*jm3]+128)>>8];
760       }
761       src++;
762       dst++;
763     }
764   }
765 }