summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2021-03-30 11:49:43 +0900
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-04-07 19:32:29 +0000
commit1f769839c09b38745f0b7c9aac127ea5432804f6 (patch)
tree5aa80a4183fd9268ce0ca4a0036e52ae1bf30370 /gst-libs
parentc36190cbda60bc3c9c6253ac4c43d0d206b6ac2a (diff)
downloadgstreamer-plugins-bad-1f769839c09b38745f0b7c9aac127ea5432804f6.tar.gz
codecs: vp9decoder: Port to GstVp9StatefulParser
Use newly implemented VP9 parser. Since new GstVp9FrameHeader struct holds all the information of the stream, baseclass will not pass parser object to new_sequence() method anymore. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2112>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/codecs/gstvp9decoder.c46
-rw-r--r--gst-libs/gst/codecs/gstvp9decoder.h4
-rw-r--r--gst-libs/gst/codecs/gstvp9picture.h11
3 files changed, 17 insertions, 44 deletions
diff --git a/gst-libs/gst/codecs/gstvp9decoder.c b/gst-libs/gst/codecs/gstvp9decoder.c
index e38ff4e74..3e02672c9 100644
--- a/gst-libs/gst/codecs/gstvp9decoder.c
+++ b/gst-libs/gst/codecs/gstvp9decoder.c
@@ -71,7 +71,7 @@ struct _GstVp9DecoderPrivate
gboolean had_sequence;
- GstVp9Parser *parser;
+ GstVp9StatefulParser *parser;
GstVp9Dpb *dpb;
gboolean wait_keyframe;
@@ -129,7 +129,7 @@ gst_vp9_decoder_start (GstVideoDecoder * decoder)
GstVp9Decoder *self = GST_VP9_DECODER (decoder);
GstVp9DecoderPrivate *priv = self->priv;
- priv->parser = gst_vp9_parser_new ();
+ priv->parser = gst_vp9_stateful_parser_new ();
priv->dpb = gst_vp9_dpb_new ();
priv->wait_keyframe = TRUE;
@@ -142,27 +142,16 @@ gst_vp9_decoder_stop (GstVideoDecoder * decoder)
GstVp9Decoder *self = GST_VP9_DECODER (decoder);
GstVp9DecoderPrivate *priv = self->priv;
- if (self->input_state) {
- gst_video_codec_state_unref (self->input_state);
- self->input_state = NULL;
- }
-
- if (priv->parser) {
- gst_vp9_parser_free (priv->parser);
- priv->parser = NULL;
- }
-
- if (priv->dpb) {
- gst_vp9_dpb_free (priv->dpb);
- priv->dpb = NULL;
- }
+ g_clear_pointer (&self->input_state, gst_video_codec_state_unref);
+ g_clear_pointer (&priv->parser, gst_vp9_stateful_parser_free);
+ g_clear_pointer (&priv->dpb, gst_vp9_dpb_free);
return TRUE;
}
static gboolean
gst_vp9_decoder_check_codec_change (GstVp9Decoder * self,
- const GstVp9FrameHdr * frame_hdr)
+ const GstVp9FrameHeader * frame_hdr)
{
GstVp9DecoderPrivate *priv = self->priv;
gboolean ret = TRUE;
@@ -187,7 +176,7 @@ gst_vp9_decoder_check_codec_change (GstVp9Decoder * self,
priv->had_sequence = TRUE;
if (klass->new_sequence)
- priv->had_sequence = klass->new_sequence (self, priv->parser, frame_hdr);
+ priv->had_sequence = klass->new_sequence (self, frame_hdr);
ret = priv->had_sequence;
}
@@ -276,7 +265,7 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder,
GstVp9DecoderClass *klass = GST_VP9_DECODER_GET_CLASS (self);
GstVp9DecoderPrivate *priv = self->priv;
GstBuffer *in_buf = frame->input_buffer;
- GstVp9FrameHdr frame_hdr;
+ GstVp9FrameHeader frame_hdr;
GstVp9Picture *picture = NULL;
GstVp9ParserResult pres;
GstMapInfo map;
@@ -289,7 +278,7 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder,
goto error;
}
- pres = gst_vp9_parser_parse_frame_header (priv->parser, &frame_hdr,
+ pres = gst_vp9_stateful_parser_parse_frame_header (priv->parser, &frame_hdr,
map.data, map.size);
if (pres != GST_VP9_PARSER_OK) {
@@ -324,15 +313,15 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder,
if (frame_hdr.show_existing_frame) {
GstVp9Picture *pic_to_dup;
- if (frame_hdr.frame_to_show >= GST_VP9_REF_FRAMES ||
- !priv->dpb->pic_list[frame_hdr.frame_to_show]) {
- GST_ERROR_OBJECT (self, "Invalid frame_to_show %d",
- frame_hdr.frame_to_show);
+ if (frame_hdr.frame_to_show_map_idx >= GST_VP9_REF_FRAMES ||
+ !priv->dpb->pic_list[frame_hdr.frame_to_show_map_idx]) {
+ GST_ERROR_OBJECT (self, "Invalid frame_to_show_map_idx %d",
+ frame_hdr.frame_to_show_map_idx);
goto unmap_and_error;
}
g_assert (klass->duplicate_picture);
- pic_to_dup = priv->dpb->pic_list[frame_hdr.frame_to_show];
+ pic_to_dup = priv->dpb->pic_list[frame_hdr.frame_to_show_map_idx];
picture = klass->duplicate_picture (self, pic_to_dup);
if (!picture) {
@@ -346,13 +335,6 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder,
picture->data = map.data;
picture->size = map.size;
- picture->subsampling_x = priv->parser->subsampling_x;
- picture->subsampling_y = priv->parser->subsampling_y;
- picture->bit_depth = priv->parser->bit_depth;
-
- memcpy (picture->segmentation, priv->parser->segmentation,
- sizeof (priv->parser->segmentation));
-
if (klass->new_picture) {
if (!klass->new_picture (self, frame, picture)) {
GST_ERROR_OBJECT (self, "new picture error");
diff --git a/gst-libs/gst/codecs/gstvp9decoder.h b/gst-libs/gst/codecs/gstvp9decoder.h
index f25252f5d..f75085bf8 100644
--- a/gst-libs/gst/codecs/gstvp9decoder.h
+++ b/gst-libs/gst/codecs/gstvp9decoder.h
@@ -23,7 +23,6 @@
#include <gst/codecs/codecs-prelude.h>
#include <gst/video/video.h>
-#include <gst/codecparsers/gstvp9parser.h>
#include <gst/codecs/gstvp9picture.h>
G_BEGIN_DECLS
@@ -85,8 +84,7 @@ struct _GstVp9DecoderClass
GstVideoDecoderClass parent_class;
gboolean (*new_sequence) (GstVp9Decoder * decoder,
- const GstVp9Parser * parser,
- const GstVp9FrameHdr * frame_hdr);
+ const GstVp9FrameHeader *frame_hdr);
/**
* GstVp9Decoder:new_picture:
diff --git a/gst-libs/gst/codecs/gstvp9picture.h b/gst-libs/gst/codecs/gstvp9picture.h
index dc7120276..29bcd18a0 100644
--- a/gst-libs/gst/codecs/gstvp9picture.h
+++ b/gst-libs/gst/codecs/gstvp9picture.h
@@ -21,7 +21,7 @@
#define __GST_VP9_PICTURE_H__
#include <gst/codecs/codecs-prelude.h>
-#include <gst/codecparsers/gstvp9parser.h>
+#include <gst/codecs/gstvp9statefulparser.h>
G_BEGIN_DECLS
@@ -40,12 +40,7 @@ struct _GstVp9Picture
/* From GstVideoCodecFrame */
guint32 system_frame_number;
- GstVp9FrameHdr frame_hdr;
-
- /* copied from parser */
- gint subsampling_x;
- gint subsampling_y;
- guint bit_depth;
+ GstVp9FrameHeader frame_hdr;
/* raw data and size (does not have ownership) */
const guint8 * data;
@@ -53,8 +48,6 @@ struct _GstVp9Picture
gpointer user_data;
GDestroyNotify notify;
-
- GstVp9Segmentation segmentation[GST_VP9_MAX_SEGMENTS];
};
GST_CODECS_API