I was using sws_scale
to convert a group of RGB32 images to YUV420 format. Each image is very similar to the previous one and they only differ on a rectangle region Q.
My question is how to utilize Q to speed up the conversion process? An additional parameter should be added to sws_scale
function.
sws_scale( ctx, in_plane, in_stride, sliceY, height, out_plane, out_stride, Q){
// parameter out_plane stores the YUV420 data of previous image
Instead of scanning the whole image, scan through rectangle Q{
Do conversion
}
}
No such parameter exists in the current API but you can use sws_scale as is. You can create two contexts - one for whole picture and one for Q; in order to convert only Q:
Several caveats here to look for: firstly, since you use YUV420 as output format, you want to increase Q so it starts at even line/column and occupies even width/height (otherwise there can be some distorted color at Q border). Secondly, make sure pointers of all picture planes point to the same pixel - this requires different offsets for each plane depending on a pixel format. Thirdly, this works best if there's no scaling - otherwise resulting picture might not look exactly the same as it would with full-picture scale due to dithering.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.