-static int videotoolbox_set_frame(AVCodecContext *avctx, AVFrame *frame)
-{
- VTContext *vtctx = avctx->internal->hwaccel_priv_data;
- if (!frame->buf[0] || frame->data[3]) {
- av_log(avctx, AV_LOG_ERROR, "videotoolbox: invalid state\n");
- av_frame_unref(frame);
- return AVERROR_EXTERNAL;
- }
-
- CVPixelBufferRef *ref = (CVPixelBufferRef *)frame->buf[0]->data;
-
- if (*ref) {
- av_log(avctx, AV_LOG_ERROR, "videotoolbox: frame already set?\n");
- av_frame_unref(frame);
- return AVERROR_EXTERNAL;
- }
-
- *ref = vtctx->frame;
- vtctx->frame = NULL;
-
- return 0;
-}
-