MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / cvpxpool_create

Function cvpxpool_create

framework/utils/pixelBufferConvertor.cpp:194–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194CVPixelBufferPoolRef cvpxpool_create(const IAFFrame::videoInfo &src, unsigned count)
195{
196 int cvpx_format;
197 switch (src.format) {
198 case AF_PIX_FMT_UYVY422:
199 cvpx_format = kCVPixelFormatType_422YpCbCr8;
200 break;
201 case AF_PIX_FMT_NV12:
202 if (src.colorRange == AVCOL_RANGE_JPEG) {
203 cvpx_format = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
204 } else
205 cvpx_format = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
206 break;
207 case AF_PIX_FMT_YUV420P:
208 cvpx_format = kCVPixelFormatType_420YpCbCr8Planar;
209 break;
210 // case AV_PIX_FMT_BGR0:
211 // cvpx_format = kCVPixelFormatType_32BGRA;
212 // break;
213 // case AV_PIX_FMT_P010:
214 // cvpx_format = 'x420'; /* kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange */
215 // break;
216 default:
217 return nullptr;
218 }
219
220 /* destination pixel buffer attributes */
221 CFMutableDictionaryRef cvpx_attrs_dict = cfdict_create(5);
222 if (cvpx_attrs_dict == nullptr) return nullptr;
223 CFMutableDictionaryRef pool_dict = cfdict_create(2);
224 if (pool_dict == nullptr) {
225 CFRelease(cvpx_attrs_dict);
226 return nullptr;
227 }
228
229 CFMutableDictionaryRef io_dict = cfdict_create(0);
230 if (io_dict == nullptr) {
231 CFRelease(cvpx_attrs_dict);
232 CFRelease(pool_dict);
233 return nullptr;
234 }
235 CFDictionarySetValue(cvpx_attrs_dict, kCVPixelBufferIOSurfacePropertiesKey, io_dict);
236 CFRelease(io_dict);
237
238 cfdict_set_int32(cvpx_attrs_dict, kCVPixelBufferPixelFormatTypeKey, cvpx_format);
239 cfdict_set_int32(cvpx_attrs_dict, kCVPixelBufferWidthKey, src.width);
240 cfdict_set_int32(cvpx_attrs_dict, kCVPixelBufferHeightKey, src.height);
241 /* Required by CIFilter to render IOSurface */
242 cfdict_set_int32(cvpx_attrs_dict, kCVPixelBufferBytesPerRowAlignmentKey, 16);
243
244 cfdict_set_int32(pool_dict, kCVPixelBufferPoolMinimumBufferCountKey, count);
245 cfdict_set_int32(pool_dict, kCVPixelBufferPoolMaximumBufferAgeKey, 0);
246
247 CVPixelBufferPoolRef pool;
248 CVReturn err = CVPixelBufferPoolCreate(nullptr, pool_dict, cvpx_attrs_dict, &pool);
249 CFRelease(pool_dict);
250 CFRelease(cvpx_attrs_dict);
251 if (err != kCVReturnSuccess) {

Callers 1

initMethod · 0.85

Calls 2

cfdict_createFunction · 0.85
cfdict_set_int32Function · 0.85

Tested by

no test coverage detected