]> Creatis software - gdcm.git/blob - src/gdcmmpeg2/src/mpeg2dec/store.c
Allow user to create mutiframes
[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   (void)outmem;
421
422   if (chroma_format==CHROMA444)
423   {
424     u444 = src[1];
425     v444 = src[2];
426   }
427   else
428   {
429     if (!u444)
430     {
431       if (chroma_format==CHROMA420)
432       {
433         if (!(u422 = (unsigned char *)malloc((Coded_Picture_Width>>1)
434                                              *Coded_Picture_Height)))
435           Error("malloc failed");
436         static_malloc[2] = u422;
437         if (!(v422 = (unsigned char *)malloc((Coded_Picture_Width>>1)
438                                              *Coded_Picture_Height)))
439           Error("malloc failed");
440         static_malloc[3] = v422;
441       }
442
443       if (!(u444 = (unsigned char *)malloc(Coded_Picture_Width
444                                            *Coded_Picture_Height)))
445         Error("malloc failed");
446       static_malloc[4] = u444;
447
448       if (!(v444 = (unsigned char *)malloc(Coded_Picture_Width
449                                            *Coded_Picture_Height)))
450         Error("malloc failed");
451       static_malloc[5] = v444;
452     }
453
454     if (chroma_format==CHROMA420)
455     {
456       conv420to422(src[1],u422);
457       conv420to422(src[2],v422);
458       conv422to444(u422,u444);
459       conv422to444(v422,v444);
460     }
461     else
462     {
463       conv422to444(src[1],u444);
464       conv422to444(src[2],v444);
465     }
466   }
467
468   /*strcat(outname,tgaflag ? ".tga" : ".ppm");*/
469
470   /*if (!Quiet_Flag)
471     my_fprintf("saving %s\n",outname);*/
472
473  /* outfile = &file;
474   if(! my_fopen(outname, "wb", outfile))
475   {
476     my_sprintf(Error_Text,"Couldn't create %s\n",outname);
477     Error(Error_Text);
478   }*/
479
480   optr = obfr;
481
482 #if 0
483   if (tgaflag)
484   {
485     /* TGA header */
486     for (i=0; i<12; i++)
487       putbyte(tga24[i]);
488
489     putword(horizontal_size); putword(height);
490     putbyte(tga24[12]); putbyte(tga24[13]);
491   }
492   else
493   {
494     /* PPM header */
495     my_sprintf(header,"P6\n%d %d\n255\n",horizontal_size,height);
496
497     for (i=0; header[i]!=0; i++)
498       putbyte(header[i]);
499   }
500 #endif
501
502   /* matrix coefficients */
503   crv = Inverse_Table_6_9[matrix_coefficients][0];
504   cbu = Inverse_Table_6_9[matrix_coefficients][1];
505   cgu = Inverse_Table_6_9[matrix_coefficients][2];
506   cgv = Inverse_Table_6_9[matrix_coefficients][3];
507   
508   for (i=0; i<height; i++)
509   {
510     py = src[0] + offset + incr*i;
511     pu = u444 + offset + incr*i;
512     pv = v444 + offset + incr*i;
513
514     for (j=0; j<horizontal_size; j++)
515     {
516       u = *pu++ - 128;
517       v = *pv++ - 128;
518       y = 76309 * (*py++ - 16); /* (255/219)*65536 */
519       r = Clip[(y + crv*v + 32768)>>16];
520       g = Clip[(y - cgu*u - cgv*v + 32768)>>16];
521       b = Clip[(y + cbu*u + 32786)>>16];
522
523
524 #if 0
525       if (tgaflag)
526       {
527         putbyte(b); putbyte(g); putbyte(r);
528       }
529       else
530       {
531         putbyte(r); putbyte(g); putbyte(b);
532       }
533 #else
534      mem_putbyte(r); mem_putbyte(g); mem_putbyte(b);
535 #endif
536     }
537   }
538
539   if (optr!=obfr)
540     {
541     /*my_fwrite(obfr,optr-obfr,1,outfile);*/
542     memcpy(OUTMEM,obfr,optr-obfr); OUTMEM+=(optr-obfr);
543     }
544
545   /*my_fclose(outfile);*/
546 }
547
548 static void putbyte(c)
549 int c;
550 {
551   *optr++ = c;
552
553   if (optr == obfr+OBFRSIZE)
554   {
555     my_fwrite(obfr,OBFRSIZE,1,outfile);
556     optr = obfr;
557   }
558 }
559
560 static void putword(w)
561 int w;
562 {
563   putbyte(w); putbyte(w>>8);
564 }
565
566 static void mem_putbyte(c)
567 int c;
568 {
569   *optr++ = c;
570
571   if (optr == obfr+OBFRSIZE)
572   {
573     /*my_fwrite(obfr,OBFRSIZE,1,outfile);*/
574     memcpy(OUTMEM,obfr,OBFRSIZE);OUTMEM+=OBFRSIZE;
575     optr = obfr;
576   }
577 }
578
579 /*static void mem_putword(w)
580 int w;
581 {
582   mem_putbyte(w); mem_putbyte(w>>8);
583 }*/
584
585 /* horizontal 1:2 interpolation filter */
586 static void conv422to444(src,dst)
587 unsigned char *src,*dst;
588 {
589   int i, i2, w, j, im3, im2, im1, ip1, ip2, ip3;
590
591   w = Coded_Picture_Width>>1;
592
593   if (base.MPEG2_Flag)
594   {
595     for (j=0; j<Coded_Picture_Height; j++)
596     {
597       for (i=0; i<w; i++)
598       {
599         i2 = i<<1;
600         im2 = (i<2) ? 0 : i-2;
601         im1 = (i<1) ? 0 : i-1;
602         ip1 = (i<w-1) ? i+1 : w-1;
603         ip2 = (i<w-2) ? i+2 : w-1;
604         ip3 = (i<w-3) ? i+3 : w-1;
605
606         /* FIR filter coefficients (*256): 21 0 -52 0 159 256 159 0 -52 0 21 */
607         /* even samples (0 0 256 0 0) */
608         dst[i2] = src[i];
609
610         /* odd samples (21 -52 159 159 -52 21) */
611         dst[i2+1] = Clip[(int)(21*(src[im2]+src[ip3])
612                         -52*(src[im1]+src[ip2]) 
613                        +159*(src[i]+src[ip1])+128)>>8];
614       }
615       src+= w;
616       dst+= Coded_Picture_Width;
617     }
618   }
619   else
620   {
621     for (j=0; j<Coded_Picture_Height; j++)
622     {
623       for (i=0; i<w; i++)
624       {
625
626         i2 = i<<1;
627         im3 = (i<3) ? 0 : i-3;
628         im2 = (i<2) ? 0 : i-2;
629         im1 = (i<1) ? 0 : i-1;
630         ip1 = (i<w-1) ? i+1 : w-1;
631         ip2 = (i<w-2) ? i+2 : w-1;
632         ip3 = (i<w-3) ? i+3 : w-1;
633
634         /* FIR filter coefficients (*256): 5 -21 70 228 -37 11 */
635         dst[i2] =   Clip[(int)(  5*src[im3]
636                          -21*src[im2]
637                          +70*src[im1]
638                         +228*src[i]
639                          -37*src[ip1]
640                          +11*src[ip2]+128)>>8];
641
642        dst[i2+1] = Clip[(int)(  5*src[ip3]
643                          -21*src[ip2]
644                          +70*src[ip1]
645                         +228*src[i]
646                          -37*src[im1]
647                          +11*src[im2]+128)>>8];
648       }
649       src+= w;
650       dst+= Coded_Picture_Width;
651     }
652   }
653 }
654
655 /* vertical 1:2 interpolation filter */
656 static void conv420to422(src,dst)
657 unsigned char *src,*dst;
658 {
659   int w, h, i, j, j2;
660   int jm6, jm5, jm4, jm3, jm2, jm1, jp1, jp2, jp3, jp4, jp5, jp6, jp7;
661
662   w = Coded_Picture_Width>>1;
663   h = Coded_Picture_Height>>1;
664
665   if (progressive_frame)
666   {
667     /* intra frame */
668     for (i=0; i<w; i++)
669     {
670       for (j=0; j<h; j++)
671       {
672         j2 = j<<1;
673         jm3 = (j<3) ? 0 : j-3;
674         jm2 = (j<2) ? 0 : j-2;
675         jm1 = (j<1) ? 0 : j-1;
676         jp1 = (j<h-1) ? j+1 : h-1;
677         jp2 = (j<h-2) ? j+2 : h-1;
678         jp3 = (j<h-3) ? j+3 : h-1;
679
680         /* FIR filter coefficients (*256): 5 -21 70 228 -37 11 */
681         /* New FIR filter coefficients (*256): 3 -16 67 227 -32 7 */
682         dst[w*j2] =     Clip[(int)(  3*src[w*jm3]
683                              -16*src[w*jm2]
684                              +67*src[w*jm1]
685                             +227*src[w*j]
686                              -32*src[w*jp1]
687                              +7*src[w*jp2]+128)>>8];
688
689         dst[w*(j2+1)] = Clip[(int)(  3*src[w*jp3]
690                              -16*src[w*jp2]
691                              +67*src[w*jp1]
692                             +227*src[w*j]
693                              -32*src[w*jm1]
694                              +7*src[w*jm2]+128)>>8];
695       }
696       src++;
697       dst++;
698     }
699   }
700   else
701   {
702     /* intra field */
703     for (i=0; i<w; i++)
704     {
705       for (j=0; j<h; j+=2)
706       {
707         j2 = j<<1;
708
709         /* top field */
710         jm6 = (j<6) ? 0 : j-6;
711         jm4 = (j<4) ? 0 : j-4;
712         jm2 = (j<2) ? 0 : j-2;
713         jp2 = (j<h-2) ? j+2 : h-2;
714         jp4 = (j<h-4) ? j+4 : h-2;
715         jp6 = (j<h-6) ? j+6 : h-2;
716
717         /* Polyphase FIR filter coefficients (*256): 2 -10 35 242 -18 5 */
718         /* New polyphase FIR filter coefficients (*256): 1 -7 30 248 -21 5 */
719         dst[w*j2] = Clip[(int)(  1*src[w*jm6]
720                          -7*src[w*jm4]
721                          +30*src[w*jm2]
722                         +248*src[w*j]
723                          -21*src[w*jp2]
724                           +5*src[w*jp4]+128)>>8];
725
726         /* Polyphase FIR filter coefficients (*256): 11 -38 192 113 -30 8 */
727         /* New polyphase FIR filter coefficients (*256):7 -35 194 110 -24 4 */
728         dst[w*(j2+2)] = Clip[(int)( 7*src[w*jm4]
729                              -35*src[w*jm2]
730                             +194*src[w*j]
731                             +110*src[w*jp2]
732                              -24*src[w*jp4]
733                               +4*src[w*jp6]+128)>>8];
734
735         /* bottom field */
736         jm5 = (j<5) ? 1 : j-5;
737         jm3 = (j<3) ? 1 : j-3;
738         jm1 = (j<1) ? 1 : j-1;
739         jp1 = (j<h-1) ? j+1 : h-1;
740         jp3 = (j<h-3) ? j+3 : h-1;
741         jp5 = (j<h-5) ? j+5 : h-1;
742         jp7 = (j<h-7) ? j+7 : h-1;
743
744         /* Polyphase FIR filter coefficients (*256): 11 -38 192 113 -30 8 */
745         /* New polyphase FIR filter coefficients (*256):7 -35 194 110 -24 4 */
746         dst[w*(j2+1)] = Clip[(int)( 7*src[w*jp5]
747                              -35*src[w*jp3]
748                             +194*src[w*jp1]
749                             +110*src[w*jm1]
750                              -24*src[w*jm3]
751                               +4*src[w*jm5]+128)>>8];
752
753         dst[w*(j2+3)] = Clip[(int)(  1*src[w*jp7]
754                              -7*src[w*jp5]
755                              +30*src[w*jp3]
756                             +248*src[w*jp1]
757                              -21*src[w*jm1]
758                               +5*src[w*jm3]+128)>>8];
759       }
760       src++;
761       dst++;
762     }
763   }
764 }