23 #include <CoreFoundation/CFDictionary.h>
24 #include <CoreFoundation/CFNumber.h>
25 #include <CoreFoundation/CFData.h>
34 CFDictionaryRef user_info,
37 CVImageBufferRef image_buffer)
44 if (vda_ctx->
cv_pix_fmt_type != CVPixelBufferGetPixelFormatType(image_buffer))
47 vda_ctx->
cv_buffer = CVPixelBufferRetain(image_buffer);
53 CFDataRef coded_frame;
54 uint32_t flush_flags = 1 << 0;
56 coded_frame = CFDataCreate(kCFAllocatorDefault,
60 status = VDADecoderDecode(vda_ctx->
decoder, 0, coded_frame,
NULL);
62 if (kVDADecoderNoErr == status)
63 status = VDADecoderFlush(vda_ctx->
decoder, flush_flags);
65 CFRelease(coded_frame);
139 CFMutableDictionaryRef config_info;
140 CFMutableDictionaryRef buffer_attributes;
141 CFMutableDictionaryRef io_surface_properties;
142 CFNumberRef cv_pix_fmt;
150 if (extradata_size >= 4 && (extradata[4] & 0x03) != 0x03) {
153 if (!(rw_extradata =
av_malloc(extradata_size)))
156 memcpy(rw_extradata, extradata, extradata_size);
158 rw_extradata[4] |= 0x03;
160 avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, extradata_size);
164 avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size);
167 config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
169 &kCFTypeDictionaryKeyCallBacks,
170 &kCFTypeDictionaryValueCallBacks);
172 height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->
height);
173 width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->
width);
174 format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->
format);
176 CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
177 CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
178 CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
179 CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data);
181 buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
183 &kCFTypeDictionaryKeyCallBacks,
184 &kCFTypeDictionaryValueCallBacks);
185 io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
187 &kCFTypeDictionaryKeyCallBacks,
188 &kCFTypeDictionaryValueCallBacks);
189 cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault,
192 CFDictionarySetValue(buffer_attributes,
193 kCVPixelBufferPixelFormatTypeKey,
195 CFDictionarySetValue(buffer_attributes,
196 kCVPixelBufferIOSurfacePropertiesKey,
197 io_surface_properties);
199 status = VDADecoderCreate(config_info,
209 CFRelease(config_info);
210 CFRelease(io_surface_properties);
211 CFRelease(cv_pix_fmt);
212 CFRelease(buffer_attributes);
219 OSStatus status = kVDADecoderNoErr;
222 status = VDADecoderDestroy(vda_ctx->
decoder);