Android 下的PVPlayer的实现
2010-09-10 01:08:00 来源:WEB开发网resetVideoParameterFlags(); //视频改变的标志位还原
// copy parameters in case we need to adjust them
//得到新的宽和高,(包括视频和显示器,我们在横屏的时候就可以这样搞)
int displayWidth = iVideoDisplayWidth;
int displayHeight = iVideoDisplayHeight;
int frameWidth = iVideoWidth;
int frameHeight = iVideoHeight;
int frameSize;
// RGB-565 frames are 2 bytes/pixel //因为我们的数据都是565的16位的像素点
//&-2 表明取偶数
displayWidth = (displayWidth + 1) & -2;
displayHeight = (displayHeight + 1) & -2;
frameWidth = (frameWidth + 1) & -2;
frameHeight = (frameHeight + 1) & -2;
frameSize = frameWidth * frameHeight * 2;
// create frame buffer heap and register with surfaceflinger //然后分配两帧的数据
mFrameHeap = new MemoryHeapBase(frameSize * kBufferCount);
if (mFrameHeap->heapID() < 0) {
LOGE("Error creating frame buffer heap");
return false;
}
//分配之后把数据指明给buffer,这样我们的buffer是到是一个什么样的格式,长和宽分别是多少
ISurface::BufferHeap buffers(displayWidth, displayHeight,
frameWidth, frameHeight, PIXEL_FORMAT_RGB_565, mFrameHeap);
//然后注册这个buffer
mSurface->registerBuffers(buffers);
// create frame buffers
//mFrameBuffers[i]保存的是第I帧的起始位置
for (int i = 0; i < kBufferCount; i++) {
mFrameBuffers[i] = i * frameSize;
}
//然后初始化视频数据转换器
// initialize software color converter
iColorConverter = ColorConvert16::NewL();
iColorConverter->Init(displayWidth, displayHeight, frameWidth, displayWidth, displayHeight, displayWidth, CCROTATE_NONE);
iColorConverter->SetMemHeight(frameHeight);
iColorConverter->SetMode(1);
更多精彩
赞助商链接