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

Method createVideoFormatDesc

framework/codec/Apple/AppleVideoToolBox.cpp:263–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261 }
262
263 int AFVTBDecoder::createVideoFormatDesc(const uint8_t *pData, int size, int width, int height, CFDictionaryRef &decoder_spec,
264 CMFormatDescriptionRef &cm_fmt_desc)
265 {
266 OSStatus status;
267 int ret;
268
269 if (pData == nullptr || size == 0) {
270 return -EINVAL;
271 }
272
273 CFMutableDictionaryRef par =
274 CFDictionaryCreateMutable(nullptr, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
275 CFMutableDictionaryRef atoms =
276 CFDictionaryCreateMutable(nullptr, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
277 CFMutableDictionaryRef extensions =
278 CFDictionaryCreateMutable(nullptr, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
279 /* CVPixelAspectRatio dict */
280 Stream_meta *meta = ((Stream_meta *) (*(mPInMeta)));
281
282
283 float HSpacing = 1.0;
284 float VSpacing = 1.0;
285
286 if (meta->displayHeight && meta->displayWidth) {
287 VSpacing = (float) meta->displayHeight / height;
288 HSpacing = (float) meta->displayWidth / width;
289 }
290 dict_set_f32(par, CFSTR("HorizontalSpacing"), HSpacing);
291 dict_set_f32(par, CFSTR("VerticalSpacing"), VSpacing);
292
293
294 /* SampleDescriptionExtensionAtoms dict */
295 switch (mVideoCodecType) {
296 case kCMVideoCodecType_H264:
297 dict_set_data(atoms, CFSTR("avcC"), (uint8_t *) pData, size);
298 break;
299
300 case kCMVideoCodecType_HEVC:
301 dict_set_data(atoms, CFSTR("hvcC"), (uint8_t *) pData, size);
302 break;
303
304 case kCMVideoCodecType_MPEG4Video:
305 dict_set_data(atoms, CFSTR("esds"), (uint8_t *) pData, size);
306 break;
307
308 default:
309 break;
310 }
311
312 /* Extensions dict */
313 dict_set_string(extensions, CFSTR("CVImageBufferChromaLocationBottomField"), "left");
314 dict_set_string(extensions, CFSTR("CVImageBufferChromaLocationTopField"), "left");
315 dict_set_boolean(extensions, CFSTR("FullRangeVideo"), FALSE);
316 dict_set_object(extensions, CFSTR("CVPixelAspectRatio"), (CFTypeRef *) par);
317 dict_set_object(extensions, CFSTR("SampleDescriptionExtensionAtoms"), (CFTypeRef *) atoms);
318
319 if (width <= 0 || height <= 0) {
320 parserInfo info{0};

Callers

nothing calls this directly

Calls 7

dict_set_f32Function · 0.85
dict_set_dataFunction · 0.85
dict_set_stringFunction · 0.85
dict_set_booleanFunction · 0.85
dict_set_objectFunction · 0.85
parser_extradataFunction · 0.85

Tested by

no test coverage detected