~ubuntu-branches/ubuntu/saucy/vips/saucy

« back to all changes in this revision

Viewing changes to libvips/arithmetic/im_add.c

  • Committer: Bazaar Package Importer
  • Author(s): Jay Berkenbilt
  • Date: 2011-04-16 13:29:02 UTC
  • mfrom: (1.1.15 upstream) (2.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20110416132902-ursn6v03e9ls9jcl
Tags: 7.24.5-2
Oops...fix lintian errors from moved documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 *      - remove oil support again ... we'll try Orc instead
33
33
 * 29/10/10
34
34
 *      - move to VipsVector for Orc support
 
35
 * 28/2/11
 
36
 *      - argh vector int/uint was broken
35
37
 */
36
38
 
37
39
/*
350
352
        return( 0 );
351
353
}
352
354
 
353
 
/* Type promotion for addition. Sign and value preserving. Make sure these
354
 
 * match the case statement in add_buffer() above.
355
 
 */
356
 
static int bandfmt_add[10] = {
357
 
/* UC  C   US  S   UI  I  F  X  D  DX */
358
 
   US, S,  UI, I,  UI, I, F, X, D, DX
359
 
};
360
 
 
361
 
void
362
 
im__init_programs( VipsVector *vectors[IM_BANDFMT_LAST], 
363
 
        int format_table[IM_BANDFMT_LAST] )
 
355
VipsVector *
 
356
im__init_program( VipsVector *vectors[IM_BANDFMT_LAST], 
 
357
        VipsBandFmt format_table[IM_BANDFMT_LAST], VipsBandFmt fmt )
364
358
{
365
 
        int fmt;
366
 
 
367
 
        for( fmt = 0; fmt < IM_BANDFMT_LAST; fmt++ ) {
368
 
                int isize = im__sizeof_bandfmt[fmt];
369
 
                int osize = im__sizeof_bandfmt[format_table[fmt]];
370
 
 
371
 
                VipsVector *v;
372
 
 
373
 
                /* float and double are not handled (well) by ORC.
374
 
                 */
375
 
                if( fmt == IM_BANDFMT_DOUBLE || 
376
 
                        fmt == IM_BANDFMT_FLOAT ||      
377
 
                        fmt == IM_BANDFMT_COMPLEX ||
378
 
                        fmt == IM_BANDFMT_DPCOMPLEX )
379
 
                        continue;
380
 
 
381
 
                v = vectors[fmt] = 
382
 
                        vips_vector_new( "binary arith", osize );
383
 
                vips_vector_source_name( v, "s1", isize );
384
 
                vips_vector_source_name( v, "s2", isize );
385
 
 
386
 
                vips_vector_temporary( v, "t1", osize );
387
 
                vips_vector_temporary( v, "t2", osize );
388
 
        }
 
359
        int isize = im__sizeof_bandfmt[fmt];
 
360
        int osize = im__sizeof_bandfmt[format_table[fmt]];
 
361
 
 
362
        VipsVector *v;
 
363
 
 
364
        v = vips_vector_new( "binary arith", osize );
 
365
 
 
366
        vips_vector_source_name( v, "s1", isize );
 
367
        vips_vector_source_name( v, "s2", isize );
 
368
        vips_vector_temporary( v, "t1", osize );
 
369
        vips_vector_temporary( v, "t2", osize );
 
370
 
 
371
        vectors[fmt] = v;
 
372
 
 
373
        return( v );
389
374
}
390
375
 
391
376
void
408
393
#endif /*DEBUG*/
409
394
}
410
395
 
 
396
/* Type promotion for addition. Sign and value preserving. Make sure these
 
397
 * match the case statement in add_buffer() above.
 
398
 */
 
399
static int bandfmt_add[10] = {
 
400
/* UC  C   US  S   UI  I  F  X  D  DX */
 
401
   US, S,  UI, I,  UI, I, F, X, D, DX
 
402
};
 
403
 
411
404
static void
412
405
build_programs( void )
413
406
{
419
412
                return;
420
413
        done = TRUE;
421
414
 
422
 
        im__init_programs( add_vectors, bandfmt_add );
423
 
 
424
 
        v = add_vectors[IM_BANDFMT_UCHAR];
 
415
        v = im__init_program( add_vectors, bandfmt_add, IM_BANDFMT_UCHAR );
425
416
        vips_vector_asm2( v, "convubw", "t1", "s1" );
426
417
        vips_vector_asm2( v, "convubw", "t2", "s2" );
427
418
        vips_vector_asm3( v, "addw", "d1", "t1", "t2" ); 
428
419
 
429
 
        v = add_vectors[IM_BANDFMT_CHAR];
 
420
        v = im__init_program( add_vectors, bandfmt_add, IM_BANDFMT_CHAR );
430
421
        vips_vector_asm2( v, "convsbw", "t1", "s1" );
431
422
        vips_vector_asm2( v, "convsbw", "t2", "s2" );
432
423
        vips_vector_asm3( v, "addw", "d1", "t1", "t2" ); 
433
424
 
434
 
        v = add_vectors[IM_BANDFMT_USHORT];
 
425
        v = im__init_program( add_vectors, bandfmt_add, IM_BANDFMT_USHORT );
435
426
        vips_vector_asm2( v, "convuwl", "t1", "s1" );
436
427
        vips_vector_asm2( v, "convuwl", "t2", "s2" );
437
428
        vips_vector_asm3( v, "addl", "d1", "t1", "t2" );
438
429
 
439
 
        v = add_vectors[IM_BANDFMT_SHORT];
 
430
        v = im__init_program( add_vectors, bandfmt_add, IM_BANDFMT_SHORT );
440
431
        vips_vector_asm2( v, "convswl", "t1", "s1" );
441
432
        vips_vector_asm2( v, "convswl", "t2", "s2" );
442
433
        vips_vector_asm3( v, "addl", "d1", "t1", "t2" );
445
436
 
446
437
           uint/int are a little slower than C, on a c2d anyway
447
438
 
448
 
        v = add_vectors[IM_BANDFMT_UINT];
449
 
        vips_vector_asm3( v, "addl", "d1", "s1", "s2" );
450
 
 
451
 
        v = add_vectors[IM_BANDFMT_INT];
452
 
        vips_vector_asm3( v, "addl", "d1", "s1", "s2" );
 
439
           float/double/complex are not handled well
 
440
 
 
441
        v = im__init_program( add_vectors, IM_BANDFMT_UINT );
 
442
        vips_vector_asm3( v, "addl", "d1", "s1", "s2" );
 
443
 
 
444
        v = im__init_program( add_vectors, IM_BANDFMT_INT );
 
445
        vips_vector_asm3( v, "addl", "d1", "s1", "s2" );
 
446
 
453
447
         */
454
448
 
455
449
        im__compile_programs( add_vectors );