23 #include <CoreFoundation/CFDictionary.h>
24 #include <CoreFoundation/CFNumber.h>
25 #include <CoreFoundation/CFData.h>
37 CFDictionaryRef user_info,
40 CVImageBufferRef image_buffer)
50 if (vda_ctx->
cv_pix_fmt_type != CVPixelBufferGetPixelFormatType(image_buffer))
53 vda_ctx->
cv_buffer = CVPixelBufferRetain(image_buffer);
59 CFDataRef coded_frame;
60 uint32_t flush_flags = 1 << 0;
62 coded_frame = CFDataCreate(kCFAllocatorDefault,
66 status = VDADecoderDecode(vda_ctx->
decoder, 0, coded_frame, NULL);
68 if (kVDADecoderNoErr == status)
69 status = VDADecoderFlush(vda_ctx->
decoder, flush_flags);
71 CFRelease(coded_frame);
120 CVPixelBufferRelease(context->
cv_buffer);
147 if (!context || !buffer) {
148 CVPixelBufferRelease(vda_ctx->
cv_buffer);
168 CFMutableDictionaryRef config_info;
169 CFMutableDictionaryRef buffer_attributes;
170 CFMutableDictionaryRef io_surface_properties;
171 CFNumberRef cv_pix_fmt;
179 if (extradata_size >= 4 && (extradata[4] & 0x03) != 0x03) {
182 if (!(rw_extradata =
av_malloc(extradata_size)))
185 memcpy(rw_extradata, extradata, extradata_size);
187 rw_extradata[4] |= 0x03;
189 avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, extradata_size);
193 avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size);
196 config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
198 &kCFTypeDictionaryKeyCallBacks,
199 &kCFTypeDictionaryValueCallBacks);
201 height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->
height);
202 width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->
width);
203 format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->
format);
205 CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
206 CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
207 CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
208 CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data);
210 buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
212 &kCFTypeDictionaryKeyCallBacks,
213 &kCFTypeDictionaryValueCallBacks);
214 io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
216 &kCFTypeDictionaryKeyCallBacks,
217 &kCFTypeDictionaryValueCallBacks);
218 cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault,
221 CFDictionarySetValue(buffer_attributes,
222 kCVPixelBufferPixelFormatTypeKey,
224 CFDictionarySetValue(buffer_attributes,
225 kCVPixelBufferIOSurfacePropertiesKey,
226 io_surface_properties);
228 status = VDADecoderCreate(config_info,
238 CFRelease(config_info);
239 CFRelease(io_surface_properties);
240 CFRelease(cv_pix_fmt);
241 CFRelease(buffer_attributes);
248 OSStatus status = kVDADecoderNoErr;
251 status = VDADecoderDestroy(vda_ctx->
decoder);