mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
gst-libav: fix build with ffmpeg-5.0.0
Latest ffmpeg has removed avcodec_get_context_defaults(), and its documentation says a new AVCodecContext should be allocated for this purpose. The pointer returned by avcodec_find_decoder() is now const-qualified so we also need to adjust for it. And, AVCOL_RANGE_MPEG is now rejected with strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1531>
This commit is contained in:
parent
f97ab9edf7
commit
6ea56e7fd3
6 changed files with 54 additions and 66 deletions
|
@ -168,12 +168,7 @@ gst_ffmpegauddec_finalize (GObject * object)
|
|||
GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) object;
|
||||
|
||||
av_frame_free (&ffmpegdec->frame);
|
||||
|
||||
if (ffmpegdec->context != NULL) {
|
||||
gst_ffmpeg_avcodec_close (ffmpegdec->context);
|
||||
av_free (ffmpegdec->context);
|
||||
ffmpegdec->context = NULL;
|
||||
}
|
||||
avcodec_free_context (&ffmpegdec->context);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -193,14 +188,12 @@ gst_ffmpegauddec_close (GstFFMpegAudDec * ffmpegdec, gboolean reset)
|
|||
gst_ffmpeg_avcodec_close (ffmpegdec->context);
|
||||
ffmpegdec->opened = FALSE;
|
||||
|
||||
if (ffmpegdec->context->extradata) {
|
||||
av_free (ffmpegdec->context->extradata);
|
||||
ffmpegdec->context->extradata = NULL;
|
||||
}
|
||||
av_freep (&ffmpegdec->context->extradata);
|
||||
|
||||
if (reset) {
|
||||
if (avcodec_get_context_defaults3 (ffmpegdec->context,
|
||||
oclass->in_plugin) < 0) {
|
||||
avcodec_free_context (&ffmpegdec->context);
|
||||
ffmpegdec->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegdec->context == NULL) {
|
||||
GST_DEBUG_OBJECT (ffmpegdec, "Failed to set context defaults");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -219,8 +212,9 @@ gst_ffmpegauddec_start (GstAudioDecoder * decoder)
|
|||
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
||||
|
||||
GST_OBJECT_LOCK (ffmpegdec);
|
||||
gst_ffmpeg_avcodec_close (ffmpegdec->context);
|
||||
if (avcodec_get_context_defaults3 (ffmpegdec->context, oclass->in_plugin) < 0) {
|
||||
avcodec_free_context (&ffmpegdec->context);
|
||||
ffmpegdec->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegdec->context == NULL) {
|
||||
GST_DEBUG_OBJECT (ffmpegdec, "Failed to set context defaults");
|
||||
GST_OBJECT_UNLOCK (ffmpegdec);
|
||||
return FALSE;
|
||||
|
|
|
@ -175,10 +175,8 @@ gst_ffmpegaudenc_finalize (GObject * object)
|
|||
|
||||
/* clean up remaining allocated data */
|
||||
av_frame_free (&ffmpegaudenc->frame);
|
||||
gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
|
||||
gst_ffmpeg_avcodec_close (ffmpegaudenc->refcontext);
|
||||
av_free (ffmpegaudenc->context);
|
||||
av_free (ffmpegaudenc->refcontext);
|
||||
avcodec_free_context (&ffmpegaudenc->context);
|
||||
avcodec_free_context (&ffmpegaudenc->refcontext);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -193,9 +191,9 @@ gst_ffmpegaudenc_start (GstAudioEncoder * encoder)
|
|||
ffmpegaudenc->opened = FALSE;
|
||||
ffmpegaudenc->need_reopen = FALSE;
|
||||
|
||||
gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
|
||||
if (avcodec_get_context_defaults3 (ffmpegaudenc->context,
|
||||
oclass->in_plugin) < 0) {
|
||||
avcodec_free_context (&ffmpegaudenc->context);
|
||||
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegaudenc->context == NULL) {
|
||||
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -241,10 +239,10 @@ gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
|
|||
|
||||
/* close old session */
|
||||
if (ffmpegaudenc->opened) {
|
||||
gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
|
||||
avcodec_free_context (&ffmpegaudenc->context);
|
||||
ffmpegaudenc->opened = FALSE;
|
||||
if (avcodec_get_context_defaults3 (ffmpegaudenc->context,
|
||||
oclass->in_plugin) < 0) {
|
||||
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegaudenc->context == NULL) {
|
||||
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -286,11 +284,11 @@ gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
|
|||
/* open codec */
|
||||
if (gst_ffmpeg_avcodec_open (ffmpegaudenc->context, oclass->in_plugin) < 0) {
|
||||
gst_caps_unref (allowed_caps);
|
||||
gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
|
||||
avcodec_free_context (&ffmpegaudenc->context);
|
||||
GST_DEBUG_OBJECT (ffmpegaudenc, "avenc_%s: Failed to open FFMPEG codec",
|
||||
oclass->in_plugin->name);
|
||||
if (avcodec_get_context_defaults3 (ffmpegaudenc->context,
|
||||
oclass->in_plugin) < 0)
|
||||
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegaudenc->context == NULL)
|
||||
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults");
|
||||
|
||||
if ((oclass->in_plugin->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&
|
||||
|
@ -312,10 +310,10 @@ gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
|
|||
|
||||
if (!other_caps) {
|
||||
gst_caps_unref (allowed_caps);
|
||||
gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
|
||||
avcodec_free_context (&ffmpegaudenc->context);
|
||||
GST_DEBUG ("Unsupported codec - no caps found");
|
||||
if (avcodec_get_context_defaults3 (ffmpegaudenc->context,
|
||||
oclass->in_plugin) < 0)
|
||||
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegaudenc->context == NULL)
|
||||
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -331,10 +329,10 @@ gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
|
|||
|
||||
if (!gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (ffmpegaudenc),
|
||||
icaps)) {
|
||||
gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
|
||||
avcodec_free_context (&ffmpegaudenc->context);
|
||||
gst_caps_unref (icaps);
|
||||
if (avcodec_get_context_defaults3 (ffmpegaudenc->context,
|
||||
oclass->in_plugin) < 0)
|
||||
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegaudenc->context == NULL)
|
||||
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -403,8 +401,8 @@ buffer_info_free (void *opaque, guint8 * data)
|
|||
gst_buffer_unmap (info->buffer, &info->map);
|
||||
gst_buffer_unref (info->buffer);
|
||||
} else {
|
||||
av_free (info->ext_data);
|
||||
av_free (info->ext_data_array);
|
||||
av_freep (&info->ext_data);
|
||||
av_freep (&info->ext_data_array);
|
||||
}
|
||||
g_slice_free (BufferInfo, info);
|
||||
}
|
||||
|
|
|
@ -2355,7 +2355,7 @@ gst_ffmpeg_codecid_to_caps (enum AVCodecID codec_id,
|
|||
}
|
||||
|
||||
if (buildcaps) {
|
||||
AVCodec *codec;
|
||||
const AVCodec *codec;
|
||||
|
||||
if ((codec = avcodec_find_decoder (codec_id)) ||
|
||||
(codec = avcodec_find_encoder (codec_id))) {
|
||||
|
@ -3001,6 +3001,7 @@ gst_ffmpeg_videoinfo_to_context (GstVideoInfo * info, AVCodecContext * context)
|
|||
context->color_range = AVCOL_RANGE_JPEG;
|
||||
} else {
|
||||
context->color_range = AVCOL_RANGE_MPEG;
|
||||
context->strict_std_compliance = FF_COMPLIANCE_UNOFFICIAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4373,7 +4374,7 @@ gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
|
|||
audio = TRUE;
|
||||
} else if (!strncmp (mimetype, "audio/x-gst-av-", 15)) {
|
||||
gchar ext[16];
|
||||
AVCodec *codec;
|
||||
const AVCodec *codec;
|
||||
|
||||
if (strlen (mimetype) <= 30 &&
|
||||
sscanf (mimetype, "audio/x-gst-av-%s", ext) == 1) {
|
||||
|
@ -4385,7 +4386,7 @@ gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
|
|||
}
|
||||
} else if (!strncmp (mimetype, "video/x-gst-av-", 15)) {
|
||||
gchar ext[16];
|
||||
AVCodec *codec;
|
||||
const AVCodec *codec;
|
||||
|
||||
if (strlen (mimetype) <= 30 &&
|
||||
sscanf (mimetype, "video/x-gst-av-%s", ext) == 1) {
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
const gchar *
|
||||
gst_ffmpeg_get_codecid_longname (enum AVCodecID codec_id)
|
||||
{
|
||||
AVCodec *codec;
|
||||
const AVCodec *codec;
|
||||
/* Let's use what ffmpeg can provide us */
|
||||
|
||||
if ((codec = avcodec_find_decoder (codec_id)) ||
|
||||
|
|
|
@ -340,12 +340,7 @@ gst_ffmpegviddec_finalize (GObject * object)
|
|||
GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) object;
|
||||
|
||||
av_frame_free (&ffmpegdec->picture);
|
||||
|
||||
if (ffmpegdec->context != NULL) {
|
||||
gst_ffmpeg_avcodec_close (ffmpegdec->context);
|
||||
av_free (ffmpegdec->context);
|
||||
ffmpegdec->context = NULL;
|
||||
}
|
||||
avcodec_free_context (&ffmpegdec->context);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -395,13 +390,11 @@ gst_ffmpegviddec_close (GstFFMpegVidDec * ffmpegdec, gboolean reset)
|
|||
|
||||
gst_buffer_replace (&ffmpegdec->palette, NULL);
|
||||
|
||||
if (ffmpegdec->context->extradata) {
|
||||
av_free (ffmpegdec->context->extradata);
|
||||
ffmpegdec->context->extradata = NULL;
|
||||
}
|
||||
av_freep (&ffmpegdec->context->extradata);
|
||||
if (reset) {
|
||||
if (avcodec_get_context_defaults3 (ffmpegdec->context,
|
||||
oclass->in_plugin) < 0) {
|
||||
avcodec_free_context (&ffmpegdec->context);
|
||||
ffmpegdec->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegdec->context == NULL) {
|
||||
GST_DEBUG_OBJECT (ffmpegdec, "Failed to set context defaults");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1801,7 +1794,7 @@ gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpegdec,
|
|||
if (side_data) {
|
||||
GST_LOG_OBJECT (ffmpegdec,
|
||||
"Found CC side data of type AV_FRAME_DATA_A53_CC, size %d",
|
||||
side_data->size);
|
||||
(int) side_data->size);
|
||||
GST_MEMDUMP ("A53 CC", side_data->data, side_data->size);
|
||||
|
||||
/* do not add closed caption meta if it already exists */
|
||||
|
@ -2086,8 +2079,9 @@ gst_ffmpegviddec_start (GstVideoDecoder * decoder)
|
|||
oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
||||
|
||||
GST_OBJECT_LOCK (ffmpegdec);
|
||||
gst_ffmpeg_avcodec_close (ffmpegdec->context);
|
||||
if (avcodec_get_context_defaults3 (ffmpegdec->context, oclass->in_plugin) < 0) {
|
||||
avcodec_free_context (&ffmpegdec->context);
|
||||
ffmpegdec->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegdec->context == NULL) {
|
||||
GST_DEBUG_OBJECT (ffmpegdec, "Failed to set context defaults");
|
||||
GST_OBJECT_UNLOCK (ffmpegdec);
|
||||
return FALSE;
|
||||
|
@ -2382,10 +2376,10 @@ gst_ffmpegviddec_get_property (GObject * object,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_LOWRES:
|
||||
g_value_set_enum (value, ffmpegdec->context->lowres);
|
||||
g_value_set_enum (value, ffmpegdec->lowres);
|
||||
break;
|
||||
case PROP_SKIPFRAME:
|
||||
g_value_set_enum (value, ffmpegdec->context->skip_frame);
|
||||
g_value_set_enum (value, ffmpegdec->skip_frame);
|
||||
break;
|
||||
case PROP_DIRECT_RENDERING:
|
||||
g_value_set_boolean (value, ffmpegdec->direct_rendering);
|
||||
|
|
|
@ -224,8 +224,8 @@ gst_ffmpegvidenc_finalize (GObject * object)
|
|||
av_frame_free (&ffmpegenc->picture);
|
||||
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
||||
gst_ffmpeg_avcodec_close (ffmpegenc->refcontext);
|
||||
av_free (ffmpegenc->context);
|
||||
av_free (ffmpegenc->refcontext);
|
||||
av_freep (&ffmpegenc->context);
|
||||
av_freep (&ffmpegenc->refcontext);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -247,10 +247,10 @@ gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder,
|
|||
|
||||
/* close old session */
|
||||
if (ffmpegenc->opened) {
|
||||
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
||||
avcodec_free_context (&ffmpegenc->context);
|
||||
ffmpegenc->opened = FALSE;
|
||||
if (avcodec_get_context_defaults3 (ffmpegenc->context,
|
||||
oclass->in_plugin) < 0) {
|
||||
ffmpegenc->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegenc->context == NULL) {
|
||||
GST_DEBUG_OBJECT (ffmpegenc, "Failed to set context defaults");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -454,9 +454,9 @@ bad_input_fmt:
|
|||
}
|
||||
close_codec:
|
||||
{
|
||||
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
||||
if (avcodec_get_context_defaults3 (ffmpegenc->context,
|
||||
oclass->in_plugin) < 0)
|
||||
avcodec_free_context (&ffmpegenc->context);
|
||||
ffmpegenc->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegenc->context == NULL)
|
||||
GST_DEBUG_OBJECT (ffmpegenc, "Failed to set context defaults");
|
||||
goto cleanup_stats_in;
|
||||
}
|
||||
|
@ -896,8 +896,9 @@ gst_ffmpegvidenc_start (GstVideoEncoder * encoder)
|
|||
ffmpegenc->need_reopen = FALSE;
|
||||
|
||||
/* close old session */
|
||||
gst_ffmpeg_avcodec_close (ffmpegenc->context);
|
||||
if (avcodec_get_context_defaults3 (ffmpegenc->context, oclass->in_plugin) < 0) {
|
||||
avcodec_free_context (&ffmpegenc->context);
|
||||
ffmpegenc->context = avcodec_alloc_context3 (oclass->in_plugin);
|
||||
if (ffmpegenc->context == NULL) {
|
||||
GST_DEBUG_OBJECT (ffmpegenc, "Failed to set context defaults");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue