diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.c index 1e36031999..508aa1626a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.c @@ -841,8 +841,8 @@ gst_mpeg2_decoder_start_current_picture (GstMpeg2Decoder * decoder, /* If subclass didn't update output state at this point, * marking this picture as a discont and stores current input state */ if (priv->input_state_changed) { - priv->current_picture->discont_state = - gst_video_codec_state_ref (decoder->input_state); + gst_mpeg2_picture_set_discont_state (priv->current_picture, + decoder->input_state); priv->input_state_changed = FALSE; } @@ -942,7 +942,8 @@ gst_mpeg2_decoder_ensure_current_picture (GstMpeg2Decoder * decoder, picture->needed_for_output = TRUE; /* This allows accessing the frame from the picture. */ - picture->system_frame_number = priv->current_frame->system_frame_number; + GST_CODEC_PICTURE_FRAME_NUMBER (picture) = + priv->current_frame->system_frame_number; picture->type = priv->pic_hdr.pic_type; picture->tsn = priv->pic_hdr.tsn; priv->current_pts = @@ -956,8 +957,8 @@ gst_mpeg2_decoder_ensure_current_picture (GstMpeg2Decoder * decoder, picture, (picture->structure == GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME) ? "frame" : "field", - picture->system_frame_number, picture->pic_order_cnt, picture->type, - picture->first_field); + GST_CODEC_PICTURE_FRAME_NUMBER (picture), + picture->pic_order_cnt, picture->type, picture->first_field); return gst_mpeg2_decoder_start_current_picture (decoder, slice); } @@ -1066,7 +1067,8 @@ gst_mpeg2_decoder_handle_slice (GstMpeg2Decoder * decoder, if (ret != GST_FLOW_OK) { GST_WARNING_OBJECT (decoder, "Subclass didn't want to decode picture %p (frame_num %d, poc %d)", - priv->current_picture, priv->current_picture->system_frame_number, + priv->current_picture, + GST_CODEC_PICTURE_FRAME_NUMBER (priv->current_picture), priv->current_picture->pic_order_cnt); return ret; } @@ -1155,12 +1157,12 @@ gst_mpeg2_decoder_do_output_picture (GstMpeg2Decoder * decoder, frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (decoder), - to_output->system_frame_number); + GST_CODEC_PICTURE_FRAME_NUMBER (to_output)); if (!frame) { GST_ERROR_OBJECT (decoder, "No available codec frame with frame number %d", - to_output->system_frame_number); + GST_CODEC_PICTURE_FRAME_NUMBER (to_output)); UPDATE_FLOW_RETURN (ret, GST_FLOW_ERROR); gst_mpeg2_picture_unref (to_output); @@ -1197,7 +1199,8 @@ gst_mpeg2_decoder_output_current_picture (GstMpeg2Decoder * decoder) GST_LOG_OBJECT (decoder, "Add picture %p (frame_num %d, poc %d, type 0x%x), into DPB", picture, - picture->system_frame_number, picture->pic_order_cnt, picture->type); + GST_CODEC_PICTURE_FRAME_NUMBER (picture), picture->pic_order_cnt, + picture->type); while (gst_mpeg2_dpb_need_bump (priv->dpb)) { GstMpeg2Picture *to_output; @@ -1345,7 +1348,8 @@ gst_mpeg2_decoder_drain_output_queue (GstMpeg2Decoder * self, guint num, GST_LOG_OBJECT (self, "Output picture %p (frame_num %d, poc %d, pts: %" GST_TIME_FORMAT "), from DPB", - output_frame->picture, output_frame->picture->system_frame_number, + output_frame->picture, + GST_CODEC_PICTURE_FRAME_NUMBER (output_frame->picture), output_frame->picture->pic_order_cnt, GST_TIME_ARGS (output_frame->frame->pts)); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.h b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.h index 2fa4fc3ede..3fb35fc98c 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.h @@ -95,7 +95,7 @@ struct _GstMpeg2DecoderClass * * Optional. Called whenever new #GstMpeg2Picture is created. * Subclass can set implementation specific user data - * on the #GstMpeg2Picture via gst_mpeg2_picture_set_user_data() + * on the #GstMpeg2Picture via gst_mpeg2_picture_set_user_data * * Since: 1.20 */ @@ -111,7 +111,7 @@ struct _GstMpeg2DecoderClass * * Called when a new field picture is created for interlaced field picture. * Subclass can attach implementation specific user data on @second_field via - * gst_mpeg2_picture_set_user_data() + * gst_mpeg2_picture_set_user_data * * Since: 1.20 */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.c index fd87ab39f1..b1addbdc21 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.c @@ -23,6 +23,7 @@ #endif #include "gstmpeg2picture.h" +#include "gstcodecpicture-private.h" GST_DEBUG_CATEGORY_EXTERN (gst_mpeg2_decoder_debug); #define GST_CAT_DEFAULT gst_mpeg2_decoder_debug @@ -37,13 +38,7 @@ _gst_mpeg2_picture_free (GstMpeg2Picture * picture) if (picture->first_field) gst_mpeg2_picture_unref (picture->first_field); - if (picture->notify) - picture->notify (picture->user_data); - - if (picture->discont_state) - gst_video_codec_state_unref (picture->discont_state); - - g_free (picture); + gst_codec_picture_free (GST_CODEC_PICTURE (picture)); } /** @@ -74,50 +69,6 @@ gst_mpeg2_picture_new (void) return pic; } -/** - * gst_mpeg2_picture_set_user_data: - * @picture: a #GstMpeg2Picture - * @user_data: private data - * @notify: (closure user_data): a #GDestroyNotify - * - * Sets @user_data on the picture and the #GDestroyNotify that will be called when - * the picture is freed. - * - * If a @user_data was previously set, then the previous set @notify will be called - * before the @user_data is replaced. - * - * Since: 1.20 - */ -void -gst_mpeg2_picture_set_user_data (GstMpeg2Picture * picture, gpointer user_data, - GDestroyNotify notify) -{ - g_return_if_fail (GST_IS_MPEG2_PICTURE (picture)); - - if (picture->notify) - picture->notify (picture->user_data); - - picture->user_data = user_data; - picture->notify = notify; -} - -/** - * gst_mpeg2_picture_get_user_data: - * @picture: a #GstMpeg2Picture - * - * Gets private data set on the picture via - * gst_mpeg2_picture_set_user_data() previously. - * - * Returns: (transfer none): The previously set user_data - * - * Since: 1.20 - */ -gpointer -gst_mpeg2_picture_get_user_data (GstMpeg2Picture * picture) -{ - return picture->user_data; -} - struct _GstMpeg2Dpb { GstMpeg2Picture *ref_pic_list[2]; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.h b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.h index c9614895b3..33ad74d651 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.h @@ -22,6 +22,7 @@ #define __GST_MPEG2_PICTURE_H__ #include +#include #include #include @@ -79,10 +80,8 @@ struct _GstMpeg2Slice struct _GstMpeg2Picture { /*< private >*/ - GstMiniObject parent; + GstCodecPicture parent; - /* From GstVideoCodecFrame */ - guint32 system_frame_number; gboolean needed_for_output; /* For interlaced streams */ GstMpeg2Picture *first_field; @@ -93,12 +92,6 @@ struct _GstMpeg2Picture gint tsn; GstMpegVideoPictureStructure structure; GstMpegVideoPictureType type; - - /* decoder input state if this picture is discont point */ - GstVideoCodecState *discont_state; - - gpointer user_data; - GDestroyNotify notify; }; /** @@ -148,14 +141,27 @@ gst_clear_mpeg2_picture (GstMpeg2Picture ** picture) } } -GST_CODECS_API -void gst_mpeg2_picture_set_user_data (GstMpeg2Picture * picture, - gpointer user_data, - GDestroyNotify notify); +static inline void +gst_mpeg2_picture_set_user_data (GstMpeg2Picture * picture, gpointer user_data, + GDestroyNotify notify) +{ + gst_codec_picture_set_user_data (GST_CODEC_PICTURE (picture), + user_data, notify); +} -GST_CODECS_API -gpointer gst_mpeg2_picture_get_user_data (GstMpeg2Picture * picture); +static inline gpointer +gst_mpeg2_picture_get_user_data (GstMpeg2Picture * picture) +{ + return gst_codec_picture_get_user_data (GST_CODEC_PICTURE (picture)); +} +static inline void +gst_mpeg2_picture_set_discont_state (GstMpeg2Picture * picture, + GstVideoCodecState * discont_state) +{ + gst_codec_picture_set_discont_state (GST_CODEC_PICTURE (picture), + discont_state); +} /** * GstMpeg2Dpb: diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp index 54406f7d1a..641a4c2345 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11mpeg2dec.cpp @@ -747,8 +747,8 @@ gst_d3d11_mpeg2_dec_output_picture (GstMpeg2Decoder * decoder, } if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec, - picture->discont_state, inner->width, inner->height, view_buffer, - &frame->output_buffer)) { + GST_CODEC_PICTURE (picture)->discont_state, inner->width, + inner->height, view_buffer, &frame->output_buffer)) { GST_ERROR_OBJECT (self, "Failed to copy buffer"); goto error; } diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c index 00dd1612de..93eb0ccac4 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c @@ -577,8 +577,10 @@ gst_v4l2_codec_mpeg2_dec_start_picture (GstMpeg2Decoder * decoder, /* *INDENT-OFF* */ self->v4l2_picture = (struct v4l2_ctrl_mpeg2_picture) { - .backward_ref_ts = next_picture ? next_picture->system_frame_number * 1000 : GST_CLOCK_TIME_NONE, - .forward_ref_ts = prev_picture ? prev_picture->system_frame_number * 1000 : GST_CLOCK_TIME_NONE, + .backward_ref_ts = next_picture ? + GST_CODEC_PICTURE_FRAME_NUMBER (next_picture) * 1000 : GST_CLOCK_TIME_NONE, + .forward_ref_ts = prev_picture ? + GST_CODEC_PICTURE_FRAME_NUMBER (prev_picture) * 1000 : GST_CLOCK_TIME_NONE, .intra_dc_precision = slice->pic_ext ? slice->pic_ext->intra_dc_precision : 0, .flags = (slice->pic_ext && slice->pic_ext->top_field_first ? V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST : 0) | (slice->pic_ext && slice->pic_ext->frame_pred_frame_dct ? V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT : 0 ) | @@ -680,21 +682,23 @@ gst_v4l2_codec_mpeg2_dec_output_picture (GstMpeg2Decoder * decoder, GstV4l2CodecMpeg2Dec *self = GST_V4L2_CODEC_MPEG2_DEC (decoder); GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder); GstV4l2Request *request = gst_mpeg2_picture_get_user_data (picture); + GstCodecPicture *codec_picture = GST_CODEC_PICTURE (picture); gint ret; - if (picture->discont_state) { + if (codec_picture->discont_state) { if (!gst_video_decoder_negotiate (vdec)) { GST_ERROR_OBJECT (vdec, "Could not re-negotiate with updated state"); return FALSE; } } - GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number); + GST_DEBUG_OBJECT (self, "Output picture %u", + codec_picture->system_frame_number); ret = gst_v4l2_request_set_done (request); if (ret == 0) { GST_ELEMENT_ERROR (self, STREAM, DECODE, - ("Decoding frame %u took too long", picture->system_frame_number), + ("Decoding frame %u took too long", codec_picture->system_frame_number), (NULL)); goto error; } else if (ret < 0) { @@ -706,7 +710,8 @@ gst_v4l2_codec_mpeg2_dec_output_picture (GstMpeg2Decoder * decoder, if (gst_v4l2_request_failed (request)) { GST_ELEMENT_ERROR (self, STREAM, DECODE, - ("Failed to decode frame %u", picture->system_frame_number), (NULL)); + ("Failed to decode frame %u", codec_picture->system_frame_number), + (NULL)); goto error; } @@ -801,16 +806,17 @@ gst_v4l2_codec_mpeg2_dec_submit_bitstream (GstV4l2CodecMpeg2Dec * self, self->bitstream); } else { GstVideoCodecFrame *frame; + guint32 system_frame_number = GST_CODEC_PICTURE_FRAME_NUMBER (picture); frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self), - picture->system_frame_number); + system_frame_number); g_return_val_if_fail (frame, FALSE); if (!gst_v4l2_codec_mpeg2_dec_ensure_output_buffer (self, frame)) goto done; request = gst_v4l2_decoder_alloc_request (self->decoder, - picture->system_frame_number, self->bitstream, frame->output_buffer); + system_frame_number, self->bitstream, frame->output_buffer); gst_video_codec_frame_unref (frame); } diff --git a/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c b/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c index 5e67b48a49..86db58edc2 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c @@ -518,8 +518,8 @@ gst_va_mpeg2_dec_output_picture (GstMpeg2Decoder * decoder, GST_LOG_OBJECT (self, "Outputting picture %p (poc %d)", picture, picture->pic_order_cnt); - ret = gst_va_base_dec_process_output (base, frame, picture->discont_state, - picture->buffer_flags); + ret = gst_va_base_dec_process_output (base, frame, + GST_CODEC_PICTURE (picture)->discont_state, picture->buffer_flags); gst_mpeg2_picture_unref (picture); if (ret)