Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference
ResizeBatch_L
Resizes a batch of images of different sizes with a single call.
Syntax
IppStatus ippiResizeBatch_<mod>(const IppiBatchItem* pSrcBatch, const IppiBatchItem* pDstBatch, IppSizeL nBatchSize, IppiResizeBatchSpec* pSpec, Ipp8u* pBuffer);
Supported values for mod:
8u_C1R_L |
8u_C3R_L |
32f_C1R_L |
32f_C3R_L |
Threading Layer (TL) flavor:
IppStatus ippiResizeBatch_<mod>(const IppiBatchItem* pSrcBatch, const IppiBatchItem* pDstBatch, IppSizeL nBatchSize, IppiResizeBatchSpec* pSpec, Ipp8u* pBuffer);
Supported values for mod:
8u_C1R_LT |
8u_C3R_LT |
32f_C1R_LT |
32f_C3R_LT |
Include Files
ippi_l.h
Flavors with the _LT suffix: ippi_tl.h
Domain Dependencies
Headers: ippcore.h, ippvm.h, ipps.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib
Flavors with the _LT suffix additionally require ippcore_tl.h and ippcore_tl.lib.
Parameters
pSrcBatch |
Pointer to the descriptors of the source images of the batch. For a non-uniform batch it points to the array of nBatchSize elements. For a uniform batch, that is when the batchType that pSpec was initialized with carries ippBatchUniformSrc, it points to a single descriptor whose pMem pointer addresses the memory of the entire batch, without gaps. All of the fields of every descriptor must be set before the call. |
pDstBatch |
Pointer to the descriptors of the destination images of the batch. For a non-uniform batch it points to the array of nBatchSize elements. For a uniform batch, that is when the batchType that pSpec was initialized with carries ippBatchUniformDst, it points to a single descriptor whose pMem pointer addresses the memory of the entire batch, without gaps. |
nBatchSize |
Number of the images of the batch. Must not be negative. A batch of one image is legal, that image is simply the only one that is processed. An empty batch, that is nBatchSize equal to zero, is legal as well: no image is processed and the function returns the ippStsNoOperation warning. |
pSpec |
Pointer to the IppiResizeBatchSpec specification structure shared by the batch, initialized by the ResizeBatchInit_L function. It carries every parameter of the batch: the data type, the number of the channels, the interpolation method with the antialiasing flag, the parameters of the cubic filter, the accuracy hint, the border of the transform, and the batch type of the sizes. |
pBuffer |
Pointer to the single work buffer shared by the batch, sized by the ResizeBatchGetBufferSize_L function. The function uses it as the temporary buffer of the initialization of the single image specification structure as well, so no separate temporary buffer is passed here. |
Description
This function resizes every source image of the batch and writes the result to the destination image of the same index. The sizes of the image k of the batch are the ones given by its two descriptors, so the scale ratio
pDstBatch[k].size.width / pSrcBatch[k].size.width
and the corresponding vertical ratio differ from image to image. A group of images of arbitrary sizes is resized with a single call: the parameters of the transform are common to the whole batch, the sizes of the images are not.
All images of the batch share the specification structure and the work buffer, and every parameter of the transform is taken from pSpec: the data type, the number of the channels, the interpolation method with the antialiasing flag, the parameters of the cubic filter, the accuracy hint, the border, and the batch type of the sizes. The sizes, the pointers, and the steps of an image are the ones of its two descriptors, or the ones that the single descriptor of a uniform direction gives it: a uniform direction is one contiguous tensor of images of equal size, its array holds exactly one element, and the image of the index k of it begins at the byte k * size.height * step of that element. Because the scale ratio differs from image to image, the single image specification structure inside pSpec is rebuilt from the sizes of the current descriptor and from the shared parameters of pSpec before every image, which is why the batch cannot share it with a single image resize call that is in progress. That initialization needs a temporary buffer, and pBuffer is it: the two roles do not overlap in time, so the ResizeBatchGetBufferSize_L function sizes one buffer for both of them. When both the flags of the batchType parameter that pSpec was initialized with are set, all the images of the batch have the same sizes, so the structure is built once for the whole batch.
The number of the channels of the batch is stored in pSpec as well, so the flavor of this function must be the channel flavor of that number, otherwise it returns the ippStsNumChannelsErr status. All the images of the batch have the same number of the channels, and the channels of an image are interleaved, exactly as in the underlying single image resize, so the step field of a descriptor counts all the channels of a line.
Destination pixels that are mapped outside the source image are processed according to the border that pSpec was initialized with. The whole destination image is one region, so no destination offset can be specified: an offset would change the scale ratio that the specification structure describes. The IPPI_INTER_NN and the IPPI_INTER_SUPER methods do not use a border, so the border of pSpec is ignored for them. The set of the supported border types depends on the interpolation method and on the IPPI_ANTIALIASING flag, so the border is validated here and not by the Init function.
When the IPPI_ANTIALIASING flag is set in the interpolation of pSpec, the function uses the antialiasing flavor of the underlying single-image resize for the IPPI_INTER_LINEAR, the four cubic, IPPI_INTER_LANCZOS, and IPPI_INTER_LANCZOS3 methods. For the IPPI_INTER_NN and the IPPI_INTER_SUPER methods, which have no antialiasing flavor, the function returns the ippStsNoAntialiasing warning and resizes without it.
The parameters of the cubic filter are the ones stored in pSpec: its B and C, exactly as the border of the transform is. The ResizeBatchInit_L function sets the default ones, that is B = 0.0 and C = 0.75, which is the kernel of the OpenCV INTER_CUBIC interpolation; use the BatchSetCubicArgs function to replace them. Both parameters are used by the IPPI_INTER_CUBIC method only: each of the IPPI_INTER_CUBIC2P_ methods names a predefined kernel, whose B and C values the Init function stores instead. The number of lobes of the Lanczos filter is carried by the interpolation method of pSpec: IPPI_INTER_LANCZOS is the filter of two lobes and IPPI_INTER_LANCZOS3 the filter of three lobes.
Before calling this function, do the following:
Fill the pMem, step, and size fields of every descriptor of both directions, of nBatchSize descriptors for a non-uniform direction and of the single descriptor of a uniform one.
Compute the sizes of pSpec and of the temporary initialization buffer with the ResizeBatchGetSize_L function and allocate the memory.
Initialize pSpec with the data type, the number of the channels, the interpolation method, the accuracy hint, the border of the transform, the filter parameters, and the batch type of the sizes by the ResizeBatchInit_L function, and replace the parameters of the cubic filter with the BatchSetCubicArgs function if the default ones are not the wanted ones.
Compute the size of pBuffer with the ResizeBatchGetBufferSize_L function and allocate the memory. The temporary initialization buffer is the scratch space of that function only and can be released as soon as it has returned.
The single threaded flavors stop at the first image that returns an error and return its status, so the destination images of the remaining descriptors are left unchanged. A warning does not stop the processing: the whole batch is resized and the returned status is the warning of the image with the smallest index among the ones that warned.
The flavors with the _LT suffix distribute the images of the batch over the threads, so each thread resizes whole images. The memory passed in pSpec and pBuffer must be sized by ippiResizeBatchGetSize_LT and ippiResizeBatchGetBufferSize_LT, which reserve a private slice for every thread. Unlike the single threaded flavors, the _LT flavors resize every image of the batch even if one of them fails. If several images return a status other than ippStsNoErr, the returned status is the one of an unspecified image among them, because the order in which the threads complete is not defined.
Return Values
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error when one of the specified pointers, or one of the pMem fields of the descriptors that are read, is NULL. |
ippStsContextMatchErr |
Indicates an error when pSpec was not initialized by the ResizeBatchInit_L function. |
ippStsSizeErr |
Indicates an error when nBatchSize is negative or when one of the sizes of a descriptor is negative. |
ippStsDataTypeErr |
Indicates an error when pSpec was initialized for the other data type. |
ippStsNumChannelsErr |
Indicates an error when pSpec was initialized for another number of the channels. |
ippStsInterpolationErr |
Indicates an error when the interpolation method of pSpec has an illegal value. |
ippStsBorderErr |
Indicates an error when the border that pSpec was initialized with has an illegal value. |
ippStsNoAntialiasing |
Indicates a warning when the IPPI_ANTIALIASING flag of the interpolation of pSpec is set and its method is IPPI_INTER_NN or IPPI_INTER_SUPER. The antialiasing is ignored. |
ippStsNoOperation |
Indicates a warning when nBatchSize is zero, or when the width or the height of one of the images is zero. |
Example
/*******************************************************************************
* Copyright 2026 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/
// A simple example of resizing a batch of images of different sizes to one
// shared destination size using Intel(R) Integrated Performance Primitives
// (Intel(R) IPP) functions:
// ippiResizeBatchGetSize_L
// ippiResizeBatchInit_L
// ippiResizeBatchGetBufferSize_L
// ippiResizeBatch_8u_C1R_L
//
// The parameters that are shared by the whole batch, that is the data type, the
// interpolation method, the parameters of the cubic filter, the border of the
// transform and the batch type of the batch, are stored in the IppiResizeBatchSpec
// structure by the ippiResizeBatchInit_L function, so the resize itself takes the
// descriptors of both directions of the batch, the specification structure and the
// work buffer only. The single image specification structure is a part of the same
// memory block and the batch resize builds it there itself.
//
// The sources of this batch have their own sizes, so they are separate images of one
// descriptor each, while the destinations share one size and are allocated as a
// single contiguous tensor of BATCH_SIZE images. A direction of the batch that the
// batch type declares uniform must be such a tensor: its images follow one another
// without a gap and one descriptor describes all of them, so the destination
// descriptor array of this example holds exactly one item and batchType is
// ippBatchUniformDst.
#include <stdio.h>
#include <stdlib.h>
#include "ipp.h"
#define BATCH_SIZE 4
#define DST_WIDTH 64
#define DST_HEIGHT 64
/* The number of the channels of the images of the batch, 1 and 3 are supported. The resize
// function must be the channel flavor of that number: ippiResizeBatch_8u_C3R_L for a batch of
// NUM_CHANNELS equal to 3, whose images are allocated by ippiMalloc_8u_C3, and so on. */
#define NUM_CHANNELS 1
/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN \
exitLine: /* Label for Exit */
#define check_sts(st) \
if ((st) != ippStsNoErr) \
goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */
int main(void)
{
IppStatus status = ippStsNoErr;
int i;
/* Every source image has its own size, all are larger than the destination */
IppiSize srcSizes[BATCH_SIZE] = {{128, 128}, {256, 256}, {192, 192}, {160, 160}};
IppiSizeL dstSizeL = {DST_WIDTH, DST_HEIGHT};
Ipp8u *pSrcImages[BATCH_SIZE] = {NULL};
int srcSteps[BATCH_SIZE] = {0};
/* the destinations are one contiguous tensor of BATCH_SIZE images of the shared
// destination size, so they are one allocation of BATCH_SIZE * DST_HEIGHT rows */
Ipp8u *pDstTensor = NULL;
int dstStep = 0;
/* the sources have one descriptor per image and the uniform destinations one
// descriptor for the whole tensor */
IppiBatchItem srcBatch[BATCH_SIZE];
IppiBatchItem dstBatch[1];
IppiResizeBatchSpec *pSpec = NULL;
Ipp8u *pInitBuf = NULL;
Ipp8u *pBuffer = NULL;
IppSizeL specSize = 0, initBufSize = 0, bufSize = 0;
/* the interpolation method combined with the antialiasing flag by the bitwise OR, for
// example IPPI_INTER_LINEAR | IPPI_ANTIALIASING; here the antialiasing is off.*/
int interpolation = IPPI_INTER_LINEAR;
/* the border of the transform is one of the shared parameters of the batch, so it is an
// argument of the Init function and not of the resize itself */
IppiBorderType border = ippBorderRepl;
/* Allocate the source images and fill their descriptors, one per image */
for (i = 0; i < BATCH_SIZE; i++) {
pSrcImages[i] = ippiMalloc_8u_C1(srcSizes[i].width, srcSizes[i].height, &srcSteps[i]);
srcBatch[i].pMem = pSrcImages[i];
srcBatch[i].step = (IppSizeL)srcSteps[i];
srcBatch[i].size.width = srcSizes[i].width;
srcBatch[i].size.height = srcSizes[i].height;
}
/* Allocate the destination tensor and describe it by the single descriptor of the
// uniform destination direction. The image i of it begins at the byte
// i * size.height * step of pMem, which is where the batch resize writes it. */
pDstTensor = ippiMalloc_8u_C1(DST_WIDTH, DST_HEIGHT * BATCH_SIZE, &dstStep);
dstBatch[0].pMem = pDstTensor;
dstBatch[0].step = (IppSizeL)dstStep;
dstBatch[0].size = dstSizeL;
/* Step 1: compute sizes of the specification structure and of the temporary buffer of the
// initialization. The data type, the number of the channels and the interpolation method are
// arguments here, because the specification structure that carries them is not initialized
// yet */
check_sts(status = ippiResizeBatchGetSize_L(srcBatch, dstBatch, BATCH_SIZE, ipp8u, NUM_CHANNELS, interpolation, ippBatchUniformDst, &specSize,
&initBufSize));
pSpec = (IppiResizeBatchSpec *)ippsMalloc_8u_L(specSize);
/* the init buffer is a scratch space of the buffer size function of step 3 only, the resize
// of step 4 takes the work buffer alone */
if (initBufSize > 0)
pInitBuf = ippsMalloc_8u_L(initBufSize);
/* Step 2: initialize the parameters that are shared by the whole batch. The accuracy hint
// is ippAlgHintNone, that is the accurate flavor of the filters. The border needs no
// constant value, the supported types do not use one. The sources have their own sizes and
// the destinations are the contiguous tensor of one descriptor, so batchType is
// ippBatchUniformDst. The parameters of the cubic filter are the default ones, that is
// B = 0.0 and C = 0.75; call ippiBatchSetCubicArgs afterwards to replace them */
check_sts(status = ippiResizeBatchInit_L(srcBatch, dstBatch, BATCH_SIZE, ipp8u, NUM_CHANNELS, interpolation, ippAlgHintNone, border, NULL,
ippBatchUniformDst, pSpec));
/* Step 3: compute the size of the work buffer. All the parameters of the batch are in the
// specification structure now, so the descriptors and that structure are enough */
check_sts(status = ippiResizeBatchGetBufferSize_L(srcBatch, dstBatch, BATCH_SIZE, pSpec, pInitBuf, &bufSize));
pBuffer = ippsMalloc_8u_L(bufSize);
/* Step 4: resize the whole batch */
check_sts(status = ippiResizeBatch_8u_C1R_L(srcBatch, dstBatch, BATCH_SIZE, pSpec, pBuffer));
EXIT_MAIN
for (i = 0; i < BATCH_SIZE; i++)
ippiFree(pSrcImages[i]);
ippiFree(pDstTensor);
ippsFree(pSpec);
ippsFree(pInitBuf);
ippsFree(pBuffer);
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return (int)status;
}
See Also
Using Intel IPP Batch Resize Functions
ResizeBatchGetSize_L Computes the sizes of the specification structure and of the temporary initialization buffer for the batch resize.
ResizeBatchGetBufferSize_L Computes the size of the work buffer for the batch resize.
ResizeBatchInit_L Initializes the specification structure of a resize batch with the default filter parameters.
BatchSetCubicArgs Sets the parameters of the cubic filter in an initialized specification structure of a resize batch.
ResizeLinear Changes an image size using linear interpolation.