H264Context *h = avctx->priv_data;
VDAContext *vda = avctx->internal->hwaccel_priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context;
- AVFrame *frame = &h->cur_pic_ptr->f;
+ AVFrame *frame = h->cur_pic_ptr->f;
int status;
if (!vda_ctx->decoder || !vda->bitstream)
H264Context *h = avctx->priv_data;
VDAContext *vda = avctx->internal->hwaccel_priv_data;
AVVDAContext *vda_ctx = avctx->hwaccel_context;
- AVFrame *frame = &h->cur_pic_ptr->f;
+ AVFrame *frame = h->cur_pic_ptr->f;
uint32_t flush_flags = 1 << 0; ///< kVDADecoderFlush_emitFrames
CFDataRef coded_frame;
OSStatus status;
CFRelease(coded_frame);
+ if (!vda->frame)
+ return AVERROR_UNKNOWN;
+
if (status != kVDADecoderNoErr) {
av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
return AVERROR_UNKNOWN;
}
- if (vda->frame) {
- av_buffer_unref(&frame->buf[0]);
+ av_buffer_unref(&frame->buf[0]);
- frame->buf[0] = av_buffer_create((uint8_t*)vda->frame,
- sizeof(vda->frame),
- release_buffer, NULL,
- AV_BUFFER_FLAG_READONLY);
- if (!frame->buf)
- return AVERROR(ENOMEM);
+ frame->buf[0] = av_buffer_create((uint8_t*)vda->frame,
+ sizeof(vda->frame),
+ release_buffer, NULL,
+ AV_BUFFER_FLAG_READONLY);
+ if (!frame->buf[0])
+ return AVERROR(ENOMEM);
- frame->data[3] = (uint8_t*)vda->frame;
- vda->frame = NULL;
- }
+ frame->data[3] = (uint8_t*)vda->frame;
+ vda->frame = NULL;
return 0;
}
CFMutableDictionaryRef buffer_attributes;
CFMutableDictionaryRef io_surface_properties;
CFNumberRef cv_pix_fmt;
- int32_t fmt = 'avc1', pix_fmt = kCVPixelFormatType_422YpCbCr8;
+ int32_t fmt = 'avc1', pix_fmt = vda_ctx->cv_pix_fmt_type;
// kCVPixelFormatType_420YpCbCr8Planar;