mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 19:25:18 +00:00
vp8decoder: Port to GstCodecPicture struct
... and remove unused "pts" variable from GstVp8Picture struct Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5285>
This commit is contained in:
parent
a5ddf7af3b
commit
4571fac946
8 changed files with 53 additions and 94 deletions
|
@ -422,10 +422,9 @@ gst_vp8_decoder_handle_frame (GstVideoDecoder * decoder,
|
|||
|
||||
picture = gst_vp8_picture_new ();
|
||||
picture->frame_hdr = frame_hdr;
|
||||
picture->pts = GST_BUFFER_PTS (in_buf);
|
||||
picture->data = map.data;
|
||||
picture->size = map.size;
|
||||
picture->system_frame_number = frame->system_frame_number;
|
||||
GST_CODEC_PICTURE_FRAME_NUMBER (picture) = frame->system_frame_number;
|
||||
|
||||
if (klass->new_picture) {
|
||||
ret = klass->new_picture (self, frame, picture);
|
||||
|
@ -474,7 +473,7 @@ gst_vp8_decoder_handle_frame (GstVideoDecoder * 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) {
|
||||
picture->discont_state = gst_video_codec_state_ref (self->input_state);
|
||||
gst_vp8_picture_set_discont_state (picture, self->input_state);
|
||||
priv->input_state_changed = FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ struct _GstVp8Decoder
|
|||
* @new_picture: Optional.
|
||||
* Called whenever new #GstVp8Picture is created.
|
||||
* Subclass can set implementation specific user data
|
||||
* on the #GstVp8Picture via gst_vp8_picture_set_user_data()
|
||||
* on the #GstVp8Picture via gst_vp8_picture_set_user_data
|
||||
* @start_picture: Optional.
|
||||
* Called per one #GstVp8Picture to notify subclass to prepare
|
||||
* decoding process for the #GstVp8Picture
|
||||
|
|
|
@ -22,26 +22,13 @@
|
|||
#endif
|
||||
|
||||
#include "gstvp8picture.h"
|
||||
#include "gstcodecpicture-private.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_vp8_decoder_debug);
|
||||
#define GST_CAT_DEFAULT gst_vp8_decoder_debug
|
||||
|
||||
GST_DEFINE_MINI_OBJECT_TYPE (GstVp8Picture, gst_vp8_picture);
|
||||
|
||||
static void
|
||||
_gst_vp8_picture_free (GstVp8Picture * picture)
|
||||
{
|
||||
GST_TRACE ("Free picture %p", picture);
|
||||
|
||||
if (picture->notify)
|
||||
picture->notify (picture->user_data);
|
||||
|
||||
if (picture->discont_state)
|
||||
gst_video_codec_state_unref (picture->discont_state);
|
||||
|
||||
g_free (picture);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vp8_picture_new:
|
||||
*
|
||||
|
@ -55,53 +42,12 @@ gst_vp8_picture_new (void)
|
|||
GstVp8Picture *pic;
|
||||
|
||||
pic = g_new0 (GstVp8Picture, 1);
|
||||
pic->pts = GST_CLOCK_TIME_NONE;
|
||||
|
||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (pic), 0,
|
||||
GST_TYPE_VP8_PICTURE, NULL, NULL,
|
||||
(GstMiniObjectFreeFunction) _gst_vp8_picture_free);
|
||||
(GstMiniObjectFreeFunction) gst_codec_picture_free);
|
||||
|
||||
GST_TRACE ("New picture %p", pic);
|
||||
|
||||
return pic;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vp8_picture_set_user_data:
|
||||
* @picture: a #GstVp8Picture
|
||||
* @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.
|
||||
*/
|
||||
void
|
||||
gst_vp8_picture_set_user_data (GstVp8Picture * picture, gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
g_return_if_fail (GST_IS_VP8_PICTURE (picture));
|
||||
|
||||
if (picture->notify)
|
||||
picture->notify (picture->user_data);
|
||||
|
||||
picture->user_data = user_data;
|
||||
picture->notify = notify;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vp8_picture_get_user_data:
|
||||
* @picture: a #GstVp8Picture
|
||||
*
|
||||
* Gets private data set on the picture via
|
||||
* gst_vp8_picture_set_user_data() previously.
|
||||
*
|
||||
* Returns: (transfer none): The previously set user_data
|
||||
*/
|
||||
gpointer
|
||||
gst_vp8_picture_get_user_data (GstVp8Picture * picture)
|
||||
{
|
||||
return picture->user_data;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define __GST_VP8_PICTURE_H__
|
||||
|
||||
#include <gst/codecs/codecs-prelude.h>
|
||||
#include <gst/codecs/gstcodecpicture.h>
|
||||
#include <gst/codecparsers/gstvp8parser.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
|
@ -36,23 +37,13 @@ typedef struct _GstVp8Picture GstVp8Picture;
|
|||
struct _GstVp8Picture
|
||||
{
|
||||
/*< private >*/
|
||||
GstMiniObject parent;
|
||||
|
||||
GstClockTime pts;
|
||||
/* From GstVideoCodecFrame */
|
||||
guint32 system_frame_number;
|
||||
GstCodecPicture parent;
|
||||
|
||||
GstVp8FrameHdr frame_hdr;
|
||||
|
||||
/* raw data and size (does not have ownership) */
|
||||
const guint8 * data;
|
||||
gsize size;
|
||||
|
||||
/* decoder input state if this picture is discont point */
|
||||
GstVideoCodecState *discont_state;
|
||||
|
||||
gpointer user_data;
|
||||
GDestroyNotify notify;
|
||||
};
|
||||
|
||||
GST_CODECS_API
|
||||
|
@ -90,13 +81,27 @@ gst_clear_vp8_picture (GstVp8Picture ** picture)
|
|||
}
|
||||
}
|
||||
|
||||
GST_CODECS_API
|
||||
void gst_vp8_picture_set_user_data (GstVp8Picture * picture,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
static inline void
|
||||
gst_vp8_picture_set_user_data (GstVp8Picture * picture, gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
gst_codec_picture_set_user_data (GST_CODEC_PICTURE (picture),
|
||||
user_data, notify);
|
||||
}
|
||||
|
||||
GST_CODECS_API
|
||||
gpointer gst_vp8_picture_get_user_data (GstVp8Picture * picture);
|
||||
static inline gpointer
|
||||
gst_vp8_picture_get_user_data (GstVp8Picture * picture)
|
||||
{
|
||||
return gst_codec_picture_get_user_data (GST_CODEC_PICTURE (picture));
|
||||
}
|
||||
|
||||
static inline void
|
||||
gst_vp8_picture_set_discont_state (GstVp8Picture * picture,
|
||||
GstVideoCodecState * discont_state)
|
||||
{
|
||||
gst_codec_picture_set_discont_state (GST_CODEC_PICTURE (picture),
|
||||
discont_state);
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -645,8 +645,8 @@ gst_d3d11_vp8_dec_output_picture (GstVp8Decoder * 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;
|
||||
}
|
||||
|
|
|
@ -648,7 +648,8 @@ gst_nv_vp8_dec_output_picture (GstVp8Decoder * decoder,
|
|||
}
|
||||
|
||||
ret = gst_nv_decoder_finish_surface (self->decoder,
|
||||
vdec, picture->discont_state, surface, &frame->output_buffer);
|
||||
vdec, GST_CODEC_PICTURE (picture)->discont_state, surface,
|
||||
&frame->output_buffer);
|
||||
if (ret != GST_FLOW_OK)
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -444,17 +444,20 @@ gst_v4l2_codec_vp8_dec_fill_references (GstV4l2CodecVp8Dec * self)
|
|||
{
|
||||
GstVp8Decoder *decoder = &self->parent;
|
||||
|
||||
if (decoder->last_picture)
|
||||
if (decoder->last_picture) {
|
||||
self->frame_header.last_frame_ts =
|
||||
decoder->last_picture->system_frame_number * 1000;
|
||||
GST_CODEC_PICTURE_FRAME_NUMBER (decoder->last_picture) * 1000;
|
||||
}
|
||||
|
||||
if (decoder->golden_ref_picture)
|
||||
if (decoder->golden_ref_picture) {
|
||||
self->frame_header.golden_frame_ts =
|
||||
decoder->golden_ref_picture->system_frame_number * 1000;
|
||||
GST_CODEC_PICTURE_FRAME_NUMBER (decoder->golden_ref_picture) * 1000;
|
||||
}
|
||||
|
||||
if (decoder->alt_ref_picture)
|
||||
if (decoder->alt_ref_picture) {
|
||||
self->frame_header.alt_frame_ts =
|
||||
decoder->alt_ref_picture->system_frame_number * 1000;
|
||||
GST_CODEC_PICTURE_FRAME_NUMBER (decoder->alt_ref_picture) * 1000;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Passing references: last %u, golden %u, alt %u",
|
||||
(guint32) self->frame_header.last_frame_ts / 1000,
|
||||
|
@ -624,14 +627,14 @@ gst_v4l2_codec_vp8_dec_end_picture (GstVp8Decoder * decoder,
|
|||
}
|
||||
|
||||
frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self),
|
||||
picture->system_frame_number);
|
||||
GST_CODEC_PICTURE_FRAME_NUMBER (picture));
|
||||
g_return_val_if_fail (frame, GST_FLOW_ERROR);
|
||||
g_warn_if_fail (frame->output_buffer == NULL);
|
||||
frame->output_buffer = buffer;
|
||||
gst_video_codec_frame_unref (frame);
|
||||
|
||||
request = gst_v4l2_decoder_alloc_request (self->decoder,
|
||||
picture->system_frame_number, self->bitstream, buffer);
|
||||
GST_CODEC_PICTURE_FRAME_NUMBER (picture), self->bitstream, buffer);
|
||||
if (!request) {
|
||||
GST_ELEMENT_ERROR (decoder, RESOURCE, NO_SPACE_LEFT,
|
||||
("Failed to allocate a media request object."), (NULL));
|
||||
|
@ -722,16 +725,18 @@ gst_v4l2_codec_vp8_dec_output_picture (GstVp8Decoder * decoder,
|
|||
GstV4l2CodecVp8Dec *self = GST_V4L2_CODEC_VP8_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
GstV4l2Request *request = gst_vp8_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) {
|
||||
|
@ -748,7 +753,8 @@ gst_v4l2_codec_vp8_dec_output_picture (GstVp8Decoder * 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ gst_va_vp8_dec_end_picture (GstVp8Decoder * decoder, GstVp8Picture * picture)
|
|||
GstVaDecodePicture *va_pic;
|
||||
|
||||
GST_LOG_OBJECT (base, "end picture %p, (system_frame_number %d)",
|
||||
picture, picture->system_frame_number);
|
||||
picture, GST_CODEC_PICTURE (picture)->system_frame_number);
|
||||
|
||||
va_pic = gst_vp8_picture_get_user_data (picture);
|
||||
|
||||
|
@ -392,13 +392,15 @@ gst_va_vp8_dec_output_picture (GstVp8Decoder * decoder,
|
|||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVaVp8Dec *self = GST_VA_VP8_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
GstCodecPicture *codec_picture = GST_CODEC_PICTURE (picture);
|
||||
gboolean ret;
|
||||
|
||||
GST_LOG_OBJECT (self,
|
||||
"Outputting picture %p (system_frame_number %d)",
|
||||
picture, picture->system_frame_number);
|
||||
picture, codec_picture->system_frame_number);
|
||||
|
||||
ret = gst_va_base_dec_process_output (base, frame, picture->discont_state, 0);
|
||||
ret = gst_va_base_dec_process_output (base, frame,
|
||||
codec_picture->discont_state, 0);
|
||||
gst_vp8_picture_unref (picture);
|
||||
|
||||
if (ret)
|
||||
|
|
Loading…
Reference in a new issue