You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
lavc/videotoolbox: fix H.264 hwaccel init issue
Fixes VTDecompressionSessionCreate() error. Signed-off-by: Rick Kern <kernrj@gmail.com>
This commit is contained in:
@@ -487,23 +487,53 @@ static CFDictionaryRef videotoolbox_buffer_attributes_create(int width,
|
|||||||
return buffer_attributes;
|
return buffer_attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CMVideoFormatDescriptionRef videotoolbox_format_desc_create(CMVideoCodecType codec_type,
|
static CMVideoFormatDescriptionRef videotoolbox_format_desc_create(AVCodecContext *avctx,
|
||||||
|
CMVideoCodecType codec_type,
|
||||||
CFDictionaryRef decoder_spec,
|
CFDictionaryRef decoder_spec,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
CMFormatDescriptionRef cm_fmt_desc;
|
CMFormatDescriptionRef cm_fmt_desc = NULL;
|
||||||
OSStatus status;
|
int status;
|
||||||
|
H264Context *h = codec_type == kCMVideoCodecType_H264 ? avctx->priv_data : NULL;
|
||||||
|
|
||||||
status = CMVideoFormatDescriptionCreate(kCFAllocatorDefault,
|
if (h && h->ps.sps->data_size && h->ps.pps->data_size) {
|
||||||
codec_type,
|
int ps_count = 2;
|
||||||
width,
|
const uint8_t **ps_data = av_malloc(sizeof(uint8_t*) * ps_count);
|
||||||
height,
|
size_t *ps_sizes = av_malloc(sizeof(size_t) * ps_count);
|
||||||
decoder_spec, // Dictionary of extension
|
|
||||||
&cm_fmt_desc);
|
|
||||||
|
|
||||||
if (status)
|
ps_data[0] = h->ps.sps->data;
|
||||||
return NULL;
|
ps_sizes[0] = h->ps.sps->data_size;
|
||||||
|
|
||||||
|
ps_data[1] = h->ps.pps->data;
|
||||||
|
ps_sizes[1] = h->ps.pps->data_size;
|
||||||
|
|
||||||
|
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(NULL,
|
||||||
|
ps_count,
|
||||||
|
ps_data,
|
||||||
|
ps_sizes,
|
||||||
|
4,
|
||||||
|
&cm_fmt_desc);
|
||||||
|
av_freep(&ps_sizes);
|
||||||
|
av_freep(&ps_data);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Error creating H.264 format description: %d\n", status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
status = CMVideoFormatDescriptionCreate(kCFAllocatorDefault,
|
||||||
|
codec_type,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
decoder_spec, // Dictionary of extension
|
||||||
|
&cm_fmt_desc);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Error creating format description: %d\n", status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return cm_fmt_desc;
|
return cm_fmt_desc;
|
||||||
}
|
}
|
||||||
@@ -543,7 +573,8 @@ static int videotoolbox_default_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
decoder_spec = videotoolbox_decoder_config_create(videotoolbox->cm_codec_type, avctx);
|
decoder_spec = videotoolbox_decoder_config_create(videotoolbox->cm_codec_type, avctx);
|
||||||
|
|
||||||
videotoolbox->cm_fmt_desc = videotoolbox_format_desc_create(videotoolbox->cm_codec_type,
|
videotoolbox->cm_fmt_desc = videotoolbox_format_desc_create(avctx,
|
||||||
|
videotoolbox->cm_codec_type,
|
||||||
decoder_spec,
|
decoder_spec,
|
||||||
avctx->width,
|
avctx->width,
|
||||||
avctx->height);
|
avctx->height);
|
||||||
|
Reference in New Issue
Block a user