File: scale_table.c

package info (click to toggle)
gavl 1.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 14,912 kB
  • sloc: ansic: 437,319; sh: 10,487; makefile: 238
file content (704 lines) | stat: -rw-r--r-- 19,042 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
/*****************************************************************
 * gavl - a general purpose audio/video processing library
 *
 * Copyright (c) 2001 - 2011 Members of the Gmerlin project
 * gmerlin-general@lists.sourceforge.net
 * http://gmerlin.sourceforge.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * *****************************************************************/

#include <stdlib.h>
#include <stdio.h>
#include <float.h>
#include <math.h>

#include <gavl/gavl.h>
#include <scale.h>

#define BLUR_THRESHOLD 5.0e-3

// #define DUMP_TABLE

/* Conversion between src and dst coordinates */

#define DST_TO_SRC(c) ((double)c)/scale_factor+src_off

#define ROUND(val) (val >= 0.0) ? (int)(val+0.5):(int)(val-0.5)

static void shift_borders(gavl_video_scale_table_t * tab, int src_width);

static void normalize_table(gavl_video_scale_table_t * tab);

static void alloc_table(gavl_video_scale_table_t * tab,
                        int num_pixels);

static void check_clip(gavl_video_scale_table_t * tab);

static void get_preblur_coeffs(double scale_factor,
                               gavl_video_options_t * opt,
                               int * num_ret,
                               float ** coeffs_ret);

static void convolve_preblur(float * src_1, int src_len_1,
                             float * src_2, int src_len_2,
                             float * dst);

/*
 * Creation of the scale tables, the most ugly part.
 * The tables are for one dimension only, for 2D scaling, we'll have 2 tables.
 * 
 * We have 3 values: src_size (double), src_off (double)
 * and dst_size (int).
 *
 * The scale factor is dst_size / src_size. src_off is the coordinate of the
 * first destination pixel in source coordinates.
 *
 * When src_offset is zero, we'll have a pattern like this
 * (for upscaling by a factor of 2):
 *
 * src: | x     | x     |
 * dst: | x | x | x | x |
 * 
 * For a src_offset of -0.25, we'll have
 *
 * src: |   x   |   x   |
 * dst: | x | x | x | x |
 *
 * The table is created in the follwing steps:
 *
 * - Calculate the floating point filter coefficiens for each destination pixel
 *   
 * - Shift the indixes of the source pixels such that no source pixels are outside
 *   the image. The nonexistant pixels beyond the borders (whose values are needed
 *   for scaling) are assumed to have the same color as the nearest pixel at the
 *   image border
 *
 * - Convert the floating point coefficients to integer with the specified bit
 *   resolution requested by the scaling routine.
 *
 */
                    
void gavl_video_scale_table_init(gavl_video_scale_table_t * tab,
                                 gavl_video_options_t * opt,
                                 double src_off, double src_size,
                                 int dst_size, int src_width)
  {
  int widen;

  double t;
  int i, j, src_index_min, src_index_nearest;
  double src_index_f;
  float widen_factor;
  float * preblur_factors = NULL;
  int num_preblur_factors = 0;
  int num_tmp_factors = 0;
  float * tmp_factors = NULL;
  
  gavl_video_scale_get_weight weight_func;
  
  double scale_factor;
  scale_factor = (double)(dst_size) / src_size;

  widen = 0;

  if(!dst_size)
    return;
  
  if(scale_factor < 1.0)
    {
    switch(opt->downscale_filter)
      {
      case GAVL_DOWNSCALE_FILTER_AUTO: //!< Auto selection based on quality
        if(opt->quality < 2)
          break;
        else
          {
          get_preblur_coeffs(scale_factor,
                             opt,
                             &num_preblur_factors,
                             &preblur_factors);
          }
        break;
      case GAVL_DOWNSCALE_FILTER_NONE: //!< Fastest method, might produce heavy aliasing artifacts
        break;
      case GAVL_DOWNSCALE_FILTER_WIDE: //!< Widen the filter curve according to the scaling ratio. 
        if(opt->downscale_blur > BLUR_THRESHOLD)
          widen = 1;
        break;
      case GAVL_DOWNSCALE_FILTER_GAUSS: //!< Do a Gaussian preblur
        get_preblur_coeffs(scale_factor,
                           opt,
                           &num_preblur_factors,
                           &preblur_factors);
        break;
      }
    }
  
  //  src_off = -0.25;
  
  /* Get the kernel generator */

  weight_func =
    gavl_video_scale_get_weight_func(opt, &tab->factors_per_pixel);

  num_tmp_factors = tab->factors_per_pixel;
  
  if(num_preblur_factors)
    {
    tmp_factors = malloc(sizeof(*tmp_factors) * num_tmp_factors);
    
    tab->factors_per_pixel += num_preblur_factors - 1;
    }
  
  if(widen)
    {
    widen_factor = ceil(opt->downscale_blur / scale_factor);
    tab->factors_per_pixel *= (int)(widen_factor);
    }
  else
    widen_factor = 1.0;

  
  //  fprintf(stderr, "tab->factors_per_pixel: %d, src_width: %d\n",
  //          tab->factors_per_pixel, src_width);
  
  
  if(tab->factors_per_pixel > src_width)
    {
    switch(src_width)
      {
      case 1:
        opt->scale_mode = GAVL_SCALE_NEAREST;
        //        fprintf(stderr, "gavl: Changing scale mode to nearest (image too small)\n");
        break;
      case 2:
      case 3:
        opt->scale_mode = GAVL_SCALE_BILINEAR;
        //        fprintf(stderr, "gavl: Changing scale mode to bilinear (image too small)\n");
        break;
      default:
        opt->scale_mode = GAVL_SCALE_CUBIC_BSPLINE;
        //        fprintf(stderr, "gavl: Changing scale mode to bspline (image too small)\n");
        break;
      }
    weight_func =
      gavl_video_scale_get_weight_func(opt, &tab->factors_per_pixel);
    }
  
  //  fprintf(stderr, "gavl_video_scale_table_init: %f %f %d %d\n", 
  //          src_off, src_size, dst_size, tab->factors_per_pixel);
  
  /* (Re)allocate memory */

  alloc_table(tab, dst_size);
 
  
  for(i = 0; i < dst_size; i++)
    {

    /* src_index_f:       Fractional source index */
    /* src_index_nearest: Nearest integer source index */
    
    src_index_f = DST_TO_SRC((double)i);

    //    fprintf(stderr, "dst: %d -> src: %f (offset: s: %.2f)\n", i, src_index_f,
    //            src_off);
    
    //    if(src_index_f > src_size - 1.0)
    //      src_index_f = src_size - 1.0;
    
    src_index_nearest = ROUND(src_index_f);

    tab->pixels[i].index = src_index_nearest - tab->factors_per_pixel/2;
    src_index_min = src_index_nearest - num_tmp_factors/2;
#if 0
    if(((double)src_index_nearest < src_index_f) && !(tab->factors_per_pixel % 2))
      {
      src_index_min++;
      tab->pixels[i].index++;
      }
#endif
    //    fprintf(stderr, "src_index_f: %f, src_index_nearest: %d, src_index_min: %d, pixel.index: %d, dst_index: %d\n",
    //            src_index_f, src_index_nearest, src_index_min,
    //            tab->pixels[i].index,
    //            i);
    
    /* For nearest neighbour, we don't need any factors */
    if(tab->factors_per_pixel == 1)
      {
      if(tab->pixels[i].index < 0)
        tab->pixels[i].index = 0;
      if(tab->pixels[i].index > src_width - 1)
        tab->pixels[i].index = src_width - 1;
      continue;
      }
    
    /* Normalized distance of the destination pixel to the first source pixel
       in src coordinates */    

    if(num_preblur_factors)
      {
      t = (src_index_f - src_index_min)/widen_factor;
      for(j = 0; j < num_tmp_factors; j++)
        {
        tmp_factors[j] = weight_func(opt, t);
        //        fprintf(stderr, "j: %d, t: %f, w: %f\n", j, t, weight_func(opt, t));
        t -= 1.0;
        }
      
      convolve_preblur(tmp_factors, num_tmp_factors,
                       preblur_factors, num_preblur_factors,
                       tab->pixels[i].factor_f);
      }
    else
      {
      t = (src_index_f - tab->pixels[i].index)/widen_factor;
      for(j = 0; j < tab->factors_per_pixel; j++)
        {
        tab->pixels[i].factor_f[j] = weight_func(opt, t);
        //      fprintf(stderr, "j: %d, t: %f, w: %f\n", j, t, weight_func(opt, t));
        t -= 1.0 /widen_factor;
        }
      }
#if 0
    for(j = 0; j < tab->factors_per_pixel; j++)
      {
      fprintf(stderr, "%d %f\n", j,
              tab->pixels[i].factor_f[j]);
      }
#endif
    }

  //  fprintf(stderr, "Before shift\n");
  //  gavl_video_scale_table_dump(tab);
  
  shift_borders(tab, src_width);
  // if(opt->scale_mode == GAVL_SCALE_SINC_LANCZOS)
  normalize_table(tab);
  
  check_clip(tab);

  if(tmp_factors)
    free(tmp_factors);
  if(preblur_factors)
    free(preblur_factors);
    
  //  fprintf(stderr, "After shift %d\n", src_width);
  //if(deinterlace || (total_fields == 2))
#ifdef DUMP_TABLE
  gavl_video_scale_table_dump(tab);
#endif  
  }

void 
gavl_video_scale_table_init_convolve(gavl_video_scale_table_t * tab,
                                     gavl_video_options_t * opt,
                                     int num_coeffs, const float * coeffs,
                                     int size)
  {
  int i, j;
  tab->factors_per_pixel = num_coeffs * 2 + 1;
  alloc_table(tab, size);
  
  for(i = 0; i < size; i++)
    {
    tab->pixels[i].index = i - num_coeffs;
    for(j = 0; j < tab->factors_per_pixel; j++)
      tab->pixels[i].factor_f[j] = coeffs[j];
    }

  shift_borders(tab, size);

  if(opt->conversion_flags & GAVL_CONVOLVE_NORMALIZE)
    normalize_table(tab);   
  else
    tab->normalized = 0;
  
  check_clip(tab);

  //  gavl_video_scale_table_dump(tab);
  }

static void alloc_table(gavl_video_scale_table_t * tab,
                        int dst_size)
  {
  int i;
  if(tab->pixels_alloc < dst_size)
    {
    tab->pixels_alloc = dst_size + 128;
    tab->pixels = realloc(tab->pixels, tab->pixels_alloc * sizeof(*(tab->pixels)));
    }

  tab->num_pixels = dst_size;
  
  if(tab->factors_alloc < dst_size * tab->factors_per_pixel)
    {
    tab->factors_alloc =  dst_size * tab->factors_per_pixel + 128;
    tab->factors_f = realloc(tab->factors_f, tab->factors_alloc * sizeof(*(tab->factors_f)));
    tab->factors_i = realloc(tab->factors_i, tab->factors_alloc * sizeof(*(tab->factors_i)));
    }

  for(i = 0; i < dst_size; i++)
    {
    /* Set the factor pointers */
    tab->pixels[i].factor_f = tab->factors_f + i * tab->factors_per_pixel;
    tab->pixels[i].factor_i = tab->factors_i + i * tab->factors_per_pixel;
    }
  }



static void normalize_table(gavl_video_scale_table_t * tab)
  {
  int i, j;
  float sum;
  
  for(i = 0; i < tab->num_pixels; i++)
    {
    sum = 0.0;
    for(j = 0; j < tab->factors_per_pixel; j++)
      sum += tab->pixels[i].factor_f[j];

    /* This is to prevent accidental setting of clipping functions due to
       rounding errors. For usual applications, it should not be noticable
    */
    sum += FLT_EPSILON;
    
    // fprintf(stderr, "sum: %f\n", sum);
    
    for(j = 0; j < tab->factors_per_pixel; j++)
      tab->pixels[i].factor_f[j] /= sum;
    }
  tab->normalized = 1;
  }

/* Shift the borders of the table such that no indices are out of range.
   The values in the pixels beyond the border are assumed to be the same as
   the border pixel. */

/* shift_up() for shift = 2, num = 5
   
   | f0 | f1 | f2 | f3 | f4 |

   ->

   | S  | f3 | f4 |  0 |  0 |

   with S = f0 + f1 + f2
   
*/
   
static void shift_up(float * fac, int num, int shift)
  {
  int j;
  /* Add all out-of-range coefficients up into the first
     coefficient of the new array */
  for(j = 0; j < shift; j++)
    fac[shift] += fac[j];

  /* Move Coefficients to new locations */
  for(j = 0; j < num - shift; j++)
    fac[j] = fac[j + shift];
  
  /* Zero unused entries */
  for(j = num - shift; j < num; j++)
    fac[j] = 0.0;
  }

/* shift_down() for shift = 2, num = 5
   
   | f0 | f1 | f2 | f3 | f4 |

   ->

   | 0  |  0 | f0 | f1 | S  |

   with S = f2 + f3 + f4
   
*/

static void shift_down(float * fac, int num, int shift)
  {
  int j;
  //  fprintf(stderr, "Shift down 1 %d\n", shift);
  /* Add all out-of-range coefficients up into the first
     coefficient of the new array */
  for(j = num - shift; j < num; j++)
    fac[num - shift - 1] += fac[j];

  /* Move Coefficients to new locations */
  for(j = num - 1; j >= shift; j--)
    fac[j] = fac[j-shift];
  
  /* Zero unused entries */
  for(j = 0; j < shift; j++)
    fac[j] = 0.0;
  }

static void shift_borders(gavl_video_scale_table_t * tab, int src_width)
  {
  int i, shift;
  
  for(i = 0; i < tab->num_pixels; i++)
    {
    //    fprintf(stderr, "Shift borders1 %d %d %d\n", tab->pixels[i].index,
    //            tab->factors_per_pixel, src_width);
    if(tab->pixels[i].index < 0)
      {
      shift = -tab->pixels[i].index;
      shift_up(tab->pixels[i].factor_f, tab->factors_per_pixel, shift);
      tab->pixels[i].index = 0;
      }

    if(tab->pixels[i].index + tab->factors_per_pixel > src_width)
      {
      shift = tab->pixels[i].index + tab->factors_per_pixel - src_width;
      
      shift_down(tab->pixels[i].factor_f, tab->factors_per_pixel, shift);
      tab->pixels[i].index = src_width - tab->factors_per_pixel;
      }
    //    fprintf(stderr, "Shift borders2 %d %d %d\n", tab->pixels[i].index,
    //            tab->factors_per_pixel, src_width);
    
    }
  
  }

void gavl_video_scale_table_dump(gavl_video_scale_table_t * tab)
  {
  int i, j;
  float sum;
  fprintf(stderr, "Scale table:\n");
  for(i = 0; i < tab->num_pixels; i++)
    {
    sum = 0.0;
    fprintf(stderr, " dst: %d", i);

    for(j = 0; j < tab->factors_per_pixel; j++)
      {
      //      fprintf(stderr, ", fac[%d]: %f [%d]", tab->pixels[i].index + j,
      //              tab->pixels[i].factor[j].fac_f,
      //              tab->pixels[i].factor[j].fac_i);

      fprintf(stderr, ", fac[%d]: %f (%d) ", tab->pixels[i].index + j,
              tab->pixels[i].factor_f[j], tab->pixels[i].factor_i[j]);
      
      sum += tab->pixels[i].factor_f[j];
      }
    
    fprintf(stderr, ", sum: %f\n", sum);
    }
  }

#if 0
static void gavl_video_scale_table_dump_int(gavl_video_scale_table_t * tab)
  {
  int i, j;
  int sum;
  fprintf(stderr, "Scale table:\n");
  for(i = 0; i < tab->num_pixels; i++)
    {
    sum = 0.0;
    fprintf(stderr, " dst: %d", i);

    for(j = 0; j < tab->factors_per_pixel; j++)
      {
      //      fprintf(stderr, ", fac[%d]: %f [%d]", tab->pixels[i].index + j,
      //              tab->pixels[i].factor[j].fac_f,
      //              tab->pixels[i].factor[j].fac_i);

      fprintf(stderr, ", fac[%d]: %d ", tab->pixels[i].index + j,
              tab->pixels[i].factor_i[j]);
      
      sum += tab->pixels[i].factor_i[j];
      }
    
    fprintf(stderr, ", sum: %d\n", sum);
    }
  }
#endif

void gavl_video_scale_table_init_int(gavl_video_scale_table_t * tab,
                                     int bits)
  {
  int fac_max_i, i, j;
  float fac_max_f, sum_f;
  int sum_i, index;
  int min_index, max_index, fac_i_norm = 0;
  
  //  fac_max_i = (1<<bits) - 1;
  //  fprintf(stderr, "Init int %d\n", bits);
  fac_max_i = (1<<bits);
  fac_max_f = (float)(fac_max_i);

  index = 0;
  
  for(i = 0; i < tab->num_pixels; i++)
    {
    min_index = index;
    max_index = index;
    
    sum_i = 0;
    sum_f = 0.0;
    
    for(j = 0; j < tab->factors_per_pixel; j++)
      {
      tab->factors_i[index] =
        (int)(fac_max_f * tab->factors_f[index]+0.5);
      sum_i += tab->factors_i[index];
      sum_f += tab->factors_f[index];
      
      if(j)
        {
        if(tab->factors_i[index] > tab->factors_i[max_index])
          max_index = index;
        if(tab->factors_i[index] < tab->factors_i[min_index])
          min_index = index;
        }
      index++;
      }
   if(!i)
      fac_i_norm = (int)(sum_f * fac_max_i + 0.5);
    
    if(sum_i > fac_i_norm)
      tab->factors_i[max_index] -= (sum_i - fac_i_norm);
    else if(sum_i < fac_i_norm)
      tab->factors_i[min_index] += (fac_i_norm - sum_i);
    }
  //  gavl_video_scale_table_dump_int(tab);
  }

void gavl_video_scale_table_cleanup(gavl_video_scale_table_t * tab)
  {
  if(tab->pixels)
    free(tab->pixels);
  if(tab->factors_f)
    free(tab->factors_f);
  if(tab->factors_i)
    free(tab->factors_i);
  }

void gavl_video_scale_table_get_src_indices(gavl_video_scale_table_t * tab,
                                            int * start, int * size)
  {
  if(!tab->pixels)
    {
    *start = 0;
    *size = 0;
    }
  else
    {
    *start = tab->pixels[0].index;
    *size = tab->pixels[tab->num_pixels-1].index + tab->factors_per_pixel -
      *start;
    }
  }

void gavl_video_scale_table_shift_indices(gavl_video_scale_table_t * tab,
                                          int shift)
  {
  int i;
  if(!shift)
    return;
  for(i = 0; i < tab->num_pixels; i++)
    {
    tab->pixels[i].index += shift;
    }
  }

static void check_clip(gavl_video_scale_table_t * tab)
  {
  int i, j;
  float sum;

  tab->do_clip = 0;
  
  for(i = 0; i < tab->num_pixels; i++)
    {
    sum = 0.0;
    for(j = 0; j < tab->factors_per_pixel; j++)
      {
      sum += tab->pixels[i].factor_f[j];
      
      if(tab->pixels[i].factor_f[j] < 0.0 ||
         tab->pixels[i].factor_f[j] > 1.0)
        {
        tab->do_clip = 1;
        return;
        }
      }
    if(sum > 1.0)
      {
      tab->do_clip = 1;
      return;
      }
    }
  }

static void get_preblur_coeffs(double scale_factor,
                               gavl_video_options_t * opt,
                               int * num_ret,
                               float ** coeffs_ret)
  {
  *num_ret = 0;

  /* Gaussian lowpass */
  if(opt->downscale_filter == GAVL_DOWNSCALE_FILTER_GAUSS)
    {
    int i;
    float tmp;
    float f_co = 0.25 * scale_factor;
    int n = (int)(ceil(0.398 / f_co));

    if(n && (opt->downscale_blur >= BLUR_THRESHOLD))
      {
      *num_ret = 2 * n + 1;
      *coeffs_ret = malloc(*num_ret * sizeof(**coeffs_ret));
      
      for(i = -n; i <= n; i++)
        {
        tmp = 3.011 * f_co * (float)i / opt->downscale_blur;
        (*coeffs_ret)[i+n] = exp(-M_PI * tmp * tmp);
        }
      }
    }
  
  if(!(*num_ret))
    *coeffs_ret = NULL;
  
  }

static void convolve_preblur(float * src_1, int src_len_1,
                             float * src_2, int src_len_2,
                             float * dst)
  {
  int m, n, nmax;
  
  nmax = src_len_1 + src_len_2 - 1;
  
  for(n = 0; n < nmax; n++)
    {
    dst[n] = 0.0;

    for(m = 0; m < src_len_1; m++)
      {
      if((n - m >= 0) && (n - m < src_len_2))
        dst[n] += src_1[m] * src_2[n-m];
      }
    
    }
  
  
  }