@@ -502,10 +502,9 @@ resample_ (ImageBuf &dst, const ImageBuf &src, bool interpolate,
502
502
ROI roi, int nthreads)
503
503
{
504
504
ASSERT (!src.deep () && !dst.deep ());
505
- ImageBufAlgo::parallel_image (roi, nthreads, [&](ROI roi){
505
+ ImageBufAlgo::parallel_image (roi, nthreads, [&,interpolate ](ROI roi){
506
506
const ImageSpec &srcspec (src.spec ());
507
507
const ImageSpec &dstspec (dst.spec ());
508
- int nchannels = src.nchannels ();
509
508
510
509
// Local copies of the source image window, converted to float
511
510
float srcfx = srcspec.full_x ;
@@ -519,27 +518,40 @@ resample_ (ImageBuf &dst, const ImageBuf &src, bool interpolate,
519
518
float dstfh = dstspec.full_height ;
520
519
float dstpixelwidth = 1 .0f / dstfw;
521
520
float dstpixelheight = 1 .0f / dstfh;
522
- float *pel = ALLOCA (float , nchannels);
523
521
524
- ImageBuf::Iterator<DSTTYPE> out (dst, roi);
525
- ImageBuf::ConstIterator<SRCTYPE> srcpel (src);
526
- for (int y = roi.ybegin ; y < roi.yend ; ++y) {
527
- // s,t are NDC space
528
- float t = (y-dstfy+0 .5f )*dstpixelheight;
529
- // src_xf, src_xf are image space float coordinates
530
- float src_yf = srcfy + t * srcfh;
531
- // src_x, src_y are image space integer coordinates of the floor
532
- int src_y = ifloor (src_yf);
533
- for (int x = roi.xbegin ; x < roi.xend ; ++x, ++out) {
534
- float s = (x-dstfx+0 .5f )*dstpixelwidth;
535
- float src_xf = srcfx + s * srcfw;
536
- int src_x = ifloor (src_xf);
537
- if (interpolate) {
522
+ if (interpolate) {
523
+ int nchannels = src.nchannels ();
524
+ float *pel = ALLOCA (float , nchannels);
525
+ ImageBuf::Iterator<DSTTYPE> out (dst, roi);
526
+ for (int y = roi.ybegin ; y < roi.yend ; ++y) {
527
+ // s,t are NDC space
528
+ float t = (y-dstfy+0 .5f )*dstpixelheight;
529
+ // src_xf, src_xf are image space float coordinates
530
+ float src_yf = srcfy + t * srcfh;
531
+ for (int x = roi.xbegin ; x < roi.xend ; ++x, ++out) {
532
+ float s = (x-dstfx+0 .5f )*dstpixelwidth;
533
+ float src_xf = srcfx + s * srcfw;
538
534
// Non-deep image, bilinearly interpolate
539
535
src.interppixel (src_xf, src_yf, pel);
540
536
for (int c = roi.chbegin ; c < roi.chend ; ++c)
541
537
out[c] = pel[c];
542
- } else {
538
+ }
539
+ }
540
+
541
+ } else { // vvv NO interpolate case
542
+ ImageBuf::Iterator<DSTTYPE,DSTTYPE> out (dst, roi);
543
+ ImageBuf::ConstIterator<SRCTYPE,DSTTYPE> srcpel (src);
544
+ for (int y = roi.ybegin ; y < roi.yend ; ++y) {
545
+ // s,t are NDC space
546
+ float t = (y-dstfy+0 .5f )*dstpixelheight;
547
+ // src_xf, src_xf are image space float coordinates
548
+ float src_yf = srcfy + t * srcfh;
549
+ // src_x, src_y are image space integer coordinates of the floor
550
+ int src_y = ifloor (src_yf);
551
+ for (int x = roi.xbegin ; x < roi.xend ; ++x, ++out) {
552
+ float s = (x-dstfx+0 .5f )*dstpixelwidth;
553
+ float src_xf = srcfx + s * srcfw;
554
+ int src_x = ifloor (src_xf);
543
555
// Non-deep image, just copy closest pixel
544
556
srcpel.pos (src_x, src_y, 0 );
545
557
for (int c = roi.chbegin ; c < roi.chend ; ++c)
0 commit comments