简体   繁体   English

优化图像缓冲区

[英]Optimize image buffer

Here is a code that decodes a WebM frame and put them in a buffer这是一个解码 WebM 帧并将它们放入缓冲区的代码

image->planes[p] = pointer to the top left pixel 

image->linesize[p] = strides betwen rows 

framesArray = vector of unsigned char*

     while ( videoDec->getImage(*image) == VPXDecoder::NO_ERROR)
                        {



                                const int w = image->getWidth(p);
                                const int h = image->getHeight(p);

                                int offset = 0;
                                for (int y = 0; y < h; y++)
                                {
                                   // fwrite(image->planes[p] + offset, 1, w, pFile);
                                    for(int i=0;i<w;i++){
                                        framesArray.at(count)[i+(w*y)] = *(image->planes[p]+offset+ i) ;

                                }

                                offset += image->linesize[p];



                            }
}
.............................

How can I write intro buffer line by line not pixel by pixel or optimize the writing of frame intro buffer?如何逐行而不是逐像素写入介绍缓冲区或优化帧介绍缓冲区的写入?

if the source image and destination buffer share the same Width, Height and bit per pixel, you can use std::copy to copy the whole image into it.如果源图像和目标缓冲区共享相同的宽度、高度和每像素位,则可以使用 std::copy 将整个图像复制到其中。

std::copy(image->planes[p] + offset, image->planes[p] + (image->getHeight(p) * image->linesize[p], framesArray.begin()) ;

if it is same bit per pixel but different width and height, you can use std::copy by line.如果每个像素的位相同但宽度和高度不同,则可以按行使用 std::copy。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM