return AVERROR_EXTERNAL;
}
+ frame->crop_right = 0;
+ frame->crop_left = 0;
+ frame->crop_top = 0;
+ frame->crop_bottom = 0;
+
frame->data[3] = (uint8_t*)ref->pixbuf;
if (ref->hw_frames_ctx) {
AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx);
VTContext *vtctx = avctx->internal->hwaccel_priv_data;
- frame->crop_right = 0;
- frame->crop_left = 0;
- frame->crop_top = 0;
- frame->crop_bottom = 0;
-
if (vtctx->reconfig_needed == true) {
vtctx->reconfig_needed = false;
av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox decoder needs reconfig, restarting..\n");
goto fail;
}
+ bool full_range = avctx->color_range == AVCOL_RANGE_JPEG;
vtctx->vt_ctx->cv_pix_fmt_type =
- av_map_videotoolbox_format_from_pixfmt(hw_frames->sw_format);
+ av_map_videotoolbox_format_from_pixfmt2(hw_frames->sw_format, full_range);
if (!vtctx->vt_ctx->cv_pix_fmt_type) {
av_log(avctx, AV_LOG_ERROR, "Unknown sw_format.\n");
err = AVERROR(EINVAL);
.end_frame = videotoolbox_hevc_end_frame,
.frame_params = videotoolbox_frame_params,
.init = videotoolbox_common_init,
- .uninit = ff_videotoolbox_uninit,
+ .uninit = videotoolbox_uninit,
.priv_data_size = sizeof(VTContext),
};
.priv_data_size = sizeof(VTContext),
};
-static AVVideotoolboxContext *av_videotoolbox_alloc_context_with_pix_fmt(enum AVPixelFormat pix_fmt)
+static AVVideotoolboxContext *av_videotoolbox_alloc_context_with_pix_fmt(enum AVPixelFormat pix_fmt,
+ bool full_range)
{
AVVideotoolboxContext *ret = av_mallocz(sizeof(*ret));
if (ret) {
ret->output_callback = videotoolbox_decoder_callback;
- OSType cv_pix_fmt_type = av_map_videotoolbox_format_from_pixfmt(pix_fmt);
+ OSType cv_pix_fmt_type = av_map_videotoolbox_format_from_pixfmt2(pix_fmt, full_range);
if (cv_pix_fmt_type == 0) {
cv_pix_fmt_type = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
}
AVVideotoolboxContext *av_videotoolbox_alloc_context(void)
{
- return av_videotoolbox_alloc_context_with_pix_fmt(AV_PIX_FMT_NONE);
+ return av_videotoolbox_alloc_context_with_pix_fmt(AV_PIX_FMT_NONE, false);
}
int av_videotoolbox_default_init(AVCodecContext *avctx)
int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx)
{
- avctx->hwaccel_context = vtctx ?: av_videotoolbox_alloc_context_with_pix_fmt(videotoolbox_best_pixel_format(avctx));
+ enum AVPixelFormat pix_fmt = videotoolbox_best_pixel_format(avctx);
+ bool full_range = avctx->color_range == AVCOL_RANGE_JPEG;
+ avctx->hwaccel_context = vtctx ?: av_videotoolbox_alloc_context_with_pix_fmt(pix_fmt, full_range);
if (!avctx->hwaccel_context)
return AVERROR(ENOMEM);
return videotoolbox_start(avctx);