mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 15:56:42 +00:00
schro: Port to 0.11
Works with some sample files. There seems to be some timestamping issue though, but the 0.10 version also complains about that too.
This commit is contained in:
parent
470854b6e3
commit
db64b868ff
5 changed files with 139 additions and 142 deletions
|
@ -312,7 +312,7 @@ GST_PLUGINS_NONPORTED=" aiff asfmux \
|
||||||
decklink fbdev linsys shm vcd \
|
decklink fbdev linsys shm vcd \
|
||||||
apexsink bz2 cdaudio celt cog curl dc1394 dirac directfb resindvd \
|
apexsink bz2 cdaudio celt cog curl dc1394 dirac directfb resindvd \
|
||||||
gsettings jp2k ladspa mimic \
|
gsettings jp2k ladspa mimic \
|
||||||
musepack musicbrainz nas neon ofa openal opencv rsvg schro sdl smooth sndfile soundtouch spandsp timidity \
|
musepack musicbrainz nas neon ofa openal opencv rsvg sdl smooth sndfile soundtouch spandsp timidity \
|
||||||
wildmidi xvid apple_media lv2 teletextdec opus dvb"
|
wildmidi xvid apple_media lv2 teletextdec opus dvb"
|
||||||
AC_SUBST(GST_PLUGINS_NONPORTED)
|
AC_SUBST(GST_PLUGINS_NONPORTED)
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,8 @@ enum
|
||||||
|
|
||||||
static void gst_schro_dec_finalize (GObject * object);
|
static void gst_schro_dec_finalize (GObject * object);
|
||||||
|
|
||||||
static gboolean gst_schro_dec_sink_query (GstPad * pad, GstQuery * query);
|
static gboolean gst_schro_dec_sink_query (GstPad * pad, GstSchroDec * dec,
|
||||||
|
GstQuery * query);
|
||||||
|
|
||||||
static gboolean gst_schro_dec_start (GstBaseVideoDecoder * dec);
|
static gboolean gst_schro_dec_start (GstBaseVideoDecoder * dec);
|
||||||
static gboolean gst_schro_dec_stop (GstBaseVideoDecoder * dec);
|
static gboolean gst_schro_dec_stop (GstBaseVideoDecoder * dec);
|
||||||
|
@ -87,7 +88,7 @@ static gboolean gst_schro_dec_reset (GstBaseVideoDecoder * dec);
|
||||||
static GstFlowReturn gst_schro_dec_parse_data (GstBaseVideoDecoder *
|
static GstFlowReturn gst_schro_dec_parse_data (GstBaseVideoDecoder *
|
||||||
base_video_decoder, gboolean at_eos);
|
base_video_decoder, gboolean at_eos);
|
||||||
static GstFlowReturn gst_schro_dec_handle_frame (GstBaseVideoDecoder * decoder,
|
static GstFlowReturn gst_schro_dec_handle_frame (GstBaseVideoDecoder * decoder,
|
||||||
GstVideoFrame * frame);
|
GstVideoFrameState * frame);
|
||||||
static gboolean gst_schro_dec_finish (GstBaseVideoDecoder * base_video_decoder);
|
static gboolean gst_schro_dec_finish (GstBaseVideoDecoder * base_video_decoder);
|
||||||
static void gst_schrodec_send_tags (GstSchroDec * schro_dec);
|
static void gst_schrodec_send_tags (GstSchroDec * schro_dec);
|
||||||
|
|
||||||
|
@ -99,21 +100,27 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_schro_dec_src_template =
|
static GstStaticPadTemplate gst_schro_dec_src_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV (GST_SCHRO_YUV_LIST) ";"
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_SCHRO_YUV_LIST))
|
||||||
GST_VIDEO_CAPS_ARGB)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstSchroDec, gst_schro_dec, GstBaseVideoDecoder,
|
#define gst_schro_dec_parent_class parent_class
|
||||||
GST_TYPE_BASE_VIDEO_DECODER);
|
G_DEFINE_TYPE (GstSchroDec, gst_schro_dec, GST_TYPE_BASE_VIDEO_DECODER);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_schro_dec_base_init (gpointer g_class)
|
gst_schro_dec_class_init (GstSchroDecClass * klass)
|
||||||
{
|
{
|
||||||
|
GObjectClass *gobject_class;
|
||||||
|
GstElementClass *element_class;
|
||||||
|
GstBaseVideoDecoderClass *base_video_decoder_class;
|
||||||
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
base_video_decoder_class = GST_BASE_VIDEO_DECODER_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->finalize = gst_schro_dec_finalize;
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&gst_schro_dec_src_template));
|
gst_static_pad_template_get (&gst_schro_dec_src_template));
|
||||||
|
@ -123,18 +130,6 @@ gst_schro_dec_base_init (gpointer g_class)
|
||||||
gst_element_class_set_details_simple (element_class, "Dirac Decoder",
|
gst_element_class_set_details_simple (element_class, "Dirac Decoder",
|
||||||
"Codec/Decoder/Video",
|
"Codec/Decoder/Video",
|
||||||
"Decode Dirac streams", "David Schleef <ds@schleef.org>");
|
"Decode Dirac streams", "David Schleef <ds@schleef.org>");
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_schro_dec_class_init (GstSchroDecClass * klass)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class;
|
|
||||||
GstBaseVideoDecoderClass *base_video_decoder_class;
|
|
||||||
|
|
||||||
gobject_class = G_OBJECT_CLASS (klass);
|
|
||||||
base_video_decoder_class = GST_BASE_VIDEO_DECODER_CLASS (klass);
|
|
||||||
|
|
||||||
gobject_class->finalize = gst_schro_dec_finalize;
|
|
||||||
|
|
||||||
base_video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_schro_dec_start);
|
base_video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_schro_dec_start);
|
||||||
base_video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_schro_dec_stop);
|
base_video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_schro_dec_stop);
|
||||||
|
@ -150,12 +145,12 @@ gst_schro_dec_class_init (GstSchroDecClass * klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_schro_dec_init (GstSchroDec * schro_dec, GstSchroDecClass * klass)
|
gst_schro_dec_init (GstSchroDec * schro_dec)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_schro_dec_init");
|
GST_DEBUG ("gst_schro_dec_init");
|
||||||
|
|
||||||
gst_pad_set_query_function (GST_BASE_VIDEO_CODEC_SINK_PAD (schro_dec),
|
gst_pad_set_query_function (GST_BASE_VIDEO_CODEC_SINK_PAD (schro_dec),
|
||||||
gst_schro_dec_sink_query);
|
(GstPadQueryFunction) gst_schro_dec_sink_query);
|
||||||
|
|
||||||
schro_dec->decoder = schro_decoder_new ();
|
schro_dec->decoder = schro_decoder_new ();
|
||||||
}
|
}
|
||||||
|
@ -218,13 +213,10 @@ gst_schro_dec_sink_convert (GstPad * pad,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_schro_dec_sink_query (GstPad * pad, GstQuery * query)
|
gst_schro_dec_sink_query (GstPad * pad, GstSchroDec * dec, GstQuery * query)
|
||||||
{
|
{
|
||||||
GstSchroDec *dec;
|
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
|
|
||||||
dec = GST_SCHRO_DEC (gst_pad_get_parent (pad));
|
|
||||||
|
|
||||||
switch (GST_QUERY_TYPE (query)) {
|
switch (GST_QUERY_TYPE (query)) {
|
||||||
case GST_QUERY_CONVERT:
|
case GST_QUERY_CONVERT:
|
||||||
{
|
{
|
||||||
|
@ -240,13 +232,12 @@ gst_schro_dec_sink_query (GstPad * pad, GstQuery * query)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
res = gst_pad_query_default (pad, query);
|
res = gst_pad_query_default (pad, GST_OBJECT (dec), query);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
gst_object_unref (dec);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
GST_DEBUG_OBJECT (dec, "query failed");
|
GST_DEBUG_OBJECT (dec, "query failed");
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -410,7 +401,7 @@ gst_schro_dec_parse_data (GstBaseVideoDecoder * base_video_decoder,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE (parse_code)) {
|
if (SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE (parse_code)) {
|
||||||
GstVideoFrame *frame;
|
GstVideoFrameState *frame;
|
||||||
|
|
||||||
if (next != 0 && next != SCHRO_PARSE_HEADER_SIZE) {
|
if (next != 0 && next != SCHRO_PARSE_HEADER_SIZE) {
|
||||||
GST_WARNING ("next is not 0 or 13 in EOS packet (%d)", next);
|
GST_WARNING ("next is not 0 or 13 in EOS packet (%d)", next);
|
||||||
|
@ -491,7 +482,7 @@ gst_schro_dec_parse_data (GstBaseVideoDecoder * base_video_decoder,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCHRO_PARSE_CODE_IS_PICTURE (parse_code)) {
|
if (SCHRO_PARSE_CODE_IS_PICTURE (parse_code)) {
|
||||||
GstVideoFrame *frame;
|
GstVideoFrameState *frame;
|
||||||
guint8 tmp[4];
|
guint8 tmp[4];
|
||||||
|
|
||||||
frame = base_video_decoder->current_frame;
|
frame = base_video_decoder->current_frame;
|
||||||
|
@ -516,12 +507,12 @@ gst_schrodec_send_tags (GstSchroDec * schro_dec)
|
||||||
{
|
{
|
||||||
GstTagList *list;
|
GstTagList *list;
|
||||||
|
|
||||||
list = gst_tag_list_new ();
|
list = gst_tag_list_new_empty ();
|
||||||
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
||||||
GST_TAG_VIDEO_CODEC, "Dirac", NULL);
|
GST_TAG_VIDEO_CODEC, "Dirac", NULL);
|
||||||
|
|
||||||
gst_element_found_tags_for_pad (GST_ELEMENT_CAST (schro_dec),
|
gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (schro_dec),
|
||||||
GST_BASE_VIDEO_CODEC_SRC_PAD (schro_dec), list);
|
gst_event_new_tag (gst_tag_list_copy (list)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -568,7 +559,7 @@ gst_schro_dec_process (GstSchroDec * schro_dec, gboolean eos)
|
||||||
{
|
{
|
||||||
SchroFrame *schro_frame;
|
SchroFrame *schro_frame;
|
||||||
SchroTag *tag;
|
SchroTag *tag;
|
||||||
GstVideoFrame *frame;
|
GstVideoFrameState *frame;
|
||||||
|
|
||||||
GST_DEBUG ("got frame");
|
GST_DEBUG ("got frame");
|
||||||
|
|
||||||
|
@ -621,7 +612,7 @@ gst_schro_dec_process (GstSchroDec * schro_dec, gboolean eos)
|
||||||
|
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_schro_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder,
|
gst_schro_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder,
|
||||||
GstVideoFrame * frame)
|
GstVideoFrameState * frame)
|
||||||
{
|
{
|
||||||
GstSchroDec *schro_dec;
|
GstSchroDec *schro_dec;
|
||||||
SchroBuffer *input_buffer;
|
SchroBuffer *input_buffer;
|
||||||
|
|
|
@ -92,27 +92,22 @@ static void gst_schro_enc_get_property (GObject * object, guint prop_id,
|
||||||
static GstFlowReturn gst_schro_enc_process (GstSchroEnc * schro_enc);
|
static GstFlowReturn gst_schro_enc_process (GstSchroEnc * schro_enc);
|
||||||
|
|
||||||
static gboolean gst_schro_enc_set_format (GstBaseVideoEncoder *
|
static gboolean gst_schro_enc_set_format (GstBaseVideoEncoder *
|
||||||
base_video_encoder, GstVideoState * state);
|
base_video_encoder, GstVideoInfo * info);
|
||||||
static gboolean gst_schro_enc_start (GstBaseVideoEncoder * base_video_encoder);
|
static gboolean gst_schro_enc_start (GstBaseVideoEncoder * base_video_encoder);
|
||||||
static gboolean gst_schro_enc_stop (GstBaseVideoEncoder * base_video_encoder);
|
static gboolean gst_schro_enc_stop (GstBaseVideoEncoder * base_video_encoder);
|
||||||
static GstFlowReturn gst_schro_enc_finish (GstBaseVideoEncoder *
|
static GstFlowReturn gst_schro_enc_finish (GstBaseVideoEncoder *
|
||||||
base_video_encoder);
|
base_video_encoder);
|
||||||
static GstFlowReturn gst_schro_enc_handle_frame (GstBaseVideoEncoder *
|
static GstFlowReturn gst_schro_enc_handle_frame (GstBaseVideoEncoder *
|
||||||
base_video_encoder, GstVideoFrame * frame);
|
base_video_encoder, GstVideoFrameState * frame);
|
||||||
static GstFlowReturn gst_schro_enc_shape_output (GstBaseVideoEncoder *
|
static GstFlowReturn gst_schro_enc_shape_output (GstBaseVideoEncoder *
|
||||||
base_video_encoder, GstVideoFrame * frame);
|
base_video_encoder, GstVideoFrameState * frame);
|
||||||
static void gst_schro_enc_finalize (GObject * object);
|
static void gst_schro_enc_finalize (GObject * object);
|
||||||
|
|
||||||
#if SCHRO_CHECK_VERSION(1,0,12)
|
|
||||||
#define ARGB_CAPS ";" GST_VIDEO_CAPS_ARGB
|
|
||||||
#else
|
|
||||||
#define ARGB_CAPS
|
|
||||||
#endif
|
|
||||||
static GstStaticPadTemplate gst_schro_enc_sink_template =
|
static GstStaticPadTemplate gst_schro_enc_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV (GST_SCHRO_YUV_LIST) ARGB_CAPS)
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_SCHRO_YUV_LIST))
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_schro_enc_src_template =
|
static GstStaticPadTemplate gst_schro_enc_src_template =
|
||||||
|
@ -122,24 +117,8 @@ static GstStaticPadTemplate gst_schro_enc_src_template =
|
||||||
GST_STATIC_CAPS ("video/x-dirac;video/x-qt-part;video/x-mp4-part")
|
GST_STATIC_CAPS ("video/x-dirac;video/x-qt-part;video/x-mp4-part")
|
||||||
);
|
);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstSchroEnc, gst_schro_enc, GstBaseVideoEncoder,
|
#define gst_schro_enc_parent_class parent_class
|
||||||
GST_TYPE_BASE_VIDEO_ENCODER);
|
G_DEFINE_TYPE (GstSchroEnc, gst_schro_enc, GST_TYPE_BASE_VIDEO_ENCODER);
|
||||||
|
|
||||||
static void
|
|
||||||
gst_schro_enc_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_schro_enc_src_template));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_schro_enc_sink_template));
|
|
||||||
|
|
||||||
gst_element_class_set_details_simple (element_class, "Dirac Encoder",
|
|
||||||
"Codec/Encoder/Video",
|
|
||||||
"Encode raw video into Dirac stream", "David Schleef <ds@schleef.org>");
|
|
||||||
}
|
|
||||||
|
|
||||||
static GType
|
static GType
|
||||||
register_enum_list (const SchroEncoderSetting * setting)
|
register_enum_list (const SchroEncoderSetting * setting)
|
||||||
|
@ -170,10 +149,12 @@ static void
|
||||||
gst_schro_enc_class_init (GstSchroEncClass * klass)
|
gst_schro_enc_class_init (GstSchroEncClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
GstElementClass *element_class;
|
||||||
GstBaseVideoEncoderClass *basevideocoder_class;
|
GstBaseVideoEncoderClass *basevideocoder_class;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
gobject_class = G_OBJECT_CLASS (klass);
|
gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
element_class = GST_ELEMENT_CLASS (klass);
|
||||||
basevideocoder_class = GST_BASE_VIDEO_ENCODER_CLASS (klass);
|
basevideocoder_class = GST_BASE_VIDEO_ENCODER_CLASS (klass);
|
||||||
|
|
||||||
gobject_class->set_property = gst_schro_enc_set_property;
|
gobject_class->set_property = gst_schro_enc_set_property;
|
||||||
|
@ -214,6 +195,15 @@ gst_schro_enc_class_init (GstSchroEncClass * klass)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&gst_schro_enc_src_template));
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&gst_schro_enc_sink_template));
|
||||||
|
|
||||||
|
gst_element_class_set_details_simple (element_class, "Dirac Encoder",
|
||||||
|
"Codec/Encoder/Video",
|
||||||
|
"Encode raw video into Dirac stream", "David Schleef <ds@schleef.org>");
|
||||||
|
|
||||||
basevideocoder_class->set_format =
|
basevideocoder_class->set_format =
|
||||||
GST_DEBUG_FUNCPTR (gst_schro_enc_set_format);
|
GST_DEBUG_FUNCPTR (gst_schro_enc_set_format);
|
||||||
basevideocoder_class->start = GST_DEBUG_FUNCPTR (gst_schro_enc_start);
|
basevideocoder_class->start = GST_DEBUG_FUNCPTR (gst_schro_enc_start);
|
||||||
|
@ -226,7 +216,7 @@ gst_schro_enc_class_init (GstSchroEncClass * klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_schro_enc_init (GstSchroEnc * schro_enc, GstSchroEncClass * klass)
|
gst_schro_enc_init (GstSchroEnc * schro_enc)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_schro_enc_init");
|
GST_DEBUG ("gst_schro_enc_init");
|
||||||
|
|
||||||
|
@ -257,7 +247,7 @@ gst_schro_enc_finalize (GObject * object)
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
|
gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
|
||||||
GstVideoState * state)
|
GstVideoInfo * info)
|
||||||
{
|
{
|
||||||
GstSchroEnc *schro_enc = GST_SCHRO_ENC (base_video_encoder);
|
GstSchroEnc *schro_enc = GST_SCHRO_ENC (base_video_encoder);
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
@ -273,7 +263,7 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
|
||||||
schro_video_format_set_std_video_format (schro_enc->video_format,
|
schro_video_format_set_std_video_format (schro_enc->video_format,
|
||||||
SCHRO_VIDEO_FORMAT_CUSTOM);
|
SCHRO_VIDEO_FORMAT_CUSTOM);
|
||||||
|
|
||||||
switch (state->format) {
|
switch (GST_VIDEO_INFO_FORMAT (info)) {
|
||||||
case GST_VIDEO_FORMAT_I420:
|
case GST_VIDEO_FORMAT_I420:
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
case GST_VIDEO_FORMAT_YV12:
|
||||||
#if SCHRO_CHECK_VERSION(1,0,11)
|
#if SCHRO_CHECK_VERSION(1,0,11)
|
||||||
|
@ -303,20 +293,27 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
schro_enc->video_format->frame_rate_numerator = state->fps_n;
|
schro_enc->video_format->frame_rate_numerator = info->fps_n;
|
||||||
schro_enc->video_format->frame_rate_denominator = state->fps_d;
|
schro_enc->video_format->frame_rate_denominator = info->fps_d;
|
||||||
|
|
||||||
schro_enc->video_format->width = state->width;
|
schro_enc->video_format->width = info->width;
|
||||||
schro_enc->video_format->height = state->height;
|
schro_enc->video_format->height = info->height;
|
||||||
|
#if 0
|
||||||
schro_enc->video_format->clean_width = state->clean_width;
|
schro_enc->video_format->clean_width = state->clean_width;
|
||||||
schro_enc->video_format->clean_height = state->clean_height;
|
schro_enc->video_format->clean_height = state->clean_height;
|
||||||
schro_enc->video_format->left_offset = state->clean_offset_left;
|
schro_enc->video_format->left_offset = state->clean_offset_left;
|
||||||
schro_enc->video_format->top_offset = state->clean_offset_top;
|
schro_enc->video_format->top_offset = state->clean_offset_top;
|
||||||
|
#else
|
||||||
|
schro_enc->video_format->clean_width = info->width;
|
||||||
|
schro_enc->video_format->clean_height = info->height;
|
||||||
|
schro_enc->video_format->left_offset = 0;
|
||||||
|
schro_enc->video_format->top_offset = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
schro_enc->video_format->aspect_ratio_numerator = state->par_n;
|
schro_enc->video_format->aspect_ratio_numerator = info->par_n;
|
||||||
schro_enc->video_format->aspect_ratio_denominator = state->par_d;
|
schro_enc->video_format->aspect_ratio_denominator = info->par_d;
|
||||||
|
|
||||||
switch (state->format) {
|
switch (GST_VIDEO_INFO_FORMAT (info)) {
|
||||||
default:
|
default:
|
||||||
schro_video_format_set_std_signal_range (schro_enc->video_format,
|
schro_video_format_set_std_signal_range (schro_enc->video_format,
|
||||||
SCHRO_SIGNAL_RANGE_8BIT_VIDEO);
|
SCHRO_SIGNAL_RANGE_8BIT_VIDEO);
|
||||||
|
@ -357,37 +354,48 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
|
||||||
schro_enc->granule_offset = ~0;
|
schro_enc->granule_offset = ~0;
|
||||||
|
|
||||||
caps = gst_caps_new_simple ("video/x-dirac",
|
caps = gst_caps_new_simple ("video/x-dirac",
|
||||||
"width", G_TYPE_INT, state->width,
|
"width", G_TYPE_INT, info->width,
|
||||||
"height", G_TYPE_INT, state->height,
|
"height", G_TYPE_INT, info->height,
|
||||||
"framerate", GST_TYPE_FRACTION, state->fps_n,
|
"framerate", GST_TYPE_FRACTION, info->fps_n,
|
||||||
state->fps_d,
|
info->fps_d,
|
||||||
"pixel-aspect-ratio", GST_TYPE_FRACTION, state->par_n,
|
"pixel-aspect-ratio", GST_TYPE_FRACTION, info->par_n, info->par_d, NULL);
|
||||||
state->par_d, NULL);
|
|
||||||
|
GST_BUFFER_FLAG_SET (seq_header_buffer, GST_BUFFER_FLAG_HEADER);
|
||||||
|
|
||||||
GST_BUFFER_FLAG_SET (seq_header_buffer, GST_BUFFER_FLAG_IN_CAPS);
|
|
||||||
{
|
{
|
||||||
GValue array = { 0 };
|
GValue array = { 0 };
|
||||||
GValue value = { 0 };
|
GValue value = { 0 };
|
||||||
|
guint8 *outdata;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
int size;
|
GstMemory *seq_header_memory, *extra_header;
|
||||||
|
gsize size;
|
||||||
|
|
||||||
g_value_init (&array, GST_TYPE_ARRAY);
|
g_value_init (&array, GST_TYPE_ARRAY);
|
||||||
g_value_init (&value, GST_TYPE_BUFFER);
|
g_value_init (&value, GST_TYPE_BUFFER);
|
||||||
size = GST_BUFFER_SIZE (seq_header_buffer);
|
|
||||||
buf = gst_buffer_new_and_alloc (size + SCHRO_PARSE_HEADER_SIZE);
|
buf = gst_buffer_new ();
|
||||||
|
/* Add the sequence header */
|
||||||
|
seq_header_memory = gst_buffer_get_memory (seq_header_buffer, 0);
|
||||||
|
gst_buffer_append_memory (buf, seq_header_memory);
|
||||||
|
|
||||||
|
size = gst_buffer_get_size (buf) + SCHRO_PARSE_HEADER_SIZE;
|
||||||
|
outdata = g_malloc0 (SCHRO_PARSE_HEADER_SIZE);
|
||||||
|
|
||||||
|
GST_WRITE_UINT32_BE (outdata, 0x42424344);
|
||||||
|
GST_WRITE_UINT8 (outdata + 4, SCHRO_PARSE_CODE_END_OF_SEQUENCE);
|
||||||
|
GST_WRITE_UINT32_BE (outdata + 5, 0);
|
||||||
|
GST_WRITE_UINT32_BE (outdata + 9, size);
|
||||||
|
|
||||||
|
extra_header = gst_memory_new_wrapped (0, outdata, SCHRO_PARSE_HEADER_SIZE,
|
||||||
|
0, SCHRO_PARSE_HEADER_SIZE, outdata, g_free);
|
||||||
|
gst_buffer_append_memory (buf, extra_header);
|
||||||
|
|
||||||
/* ogg(mux) expects the header buffers to have 0 timestamps -
|
/* ogg(mux) expects the header buffers to have 0 timestamps -
|
||||||
set OFFSET and OFFSET_END accordingly */
|
set OFFSET and OFFSET_END accordingly */
|
||||||
GST_BUFFER_OFFSET (buf) = 0;
|
GST_BUFFER_OFFSET (buf) = 0;
|
||||||
GST_BUFFER_OFFSET_END (buf) = 0;
|
GST_BUFFER_OFFSET_END (buf) = 0;
|
||||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_HEADER);
|
||||||
|
|
||||||
memcpy (GST_BUFFER_DATA (buf), GST_BUFFER_DATA (seq_header_buffer), size);
|
|
||||||
GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + size + 0, 0x42424344);
|
|
||||||
GST_WRITE_UINT8 (GST_BUFFER_DATA (buf) + size + 4,
|
|
||||||
SCHRO_PARSE_CODE_END_OF_SEQUENCE);
|
|
||||||
GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + size + 5, 0);
|
|
||||||
GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + size + 9, size);
|
|
||||||
gst_value_set_buffer (&value, buf);
|
gst_value_set_buffer (&value, buf);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
gst_value_array_append_value (&array, &value);
|
gst_value_array_append_value (&array, &value);
|
||||||
|
@ -500,7 +508,7 @@ gst_schro_enc_finish (GstBaseVideoEncoder * base_video_encoder)
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_schro_enc_handle_frame (GstBaseVideoEncoder * base_video_encoder,
|
gst_schro_enc_handle_frame (GstBaseVideoEncoder * base_video_encoder,
|
||||||
GstVideoFrame * frame)
|
GstVideoFrameState * frame)
|
||||||
{
|
{
|
||||||
GstSchroEnc *schro_enc = GST_SCHRO_ENC (base_video_encoder);
|
GstSchroEnc *schro_enc = GST_SCHRO_ENC (base_video_encoder);
|
||||||
SchroFrame *schro_frame;
|
SchroFrame *schro_frame;
|
||||||
|
@ -529,7 +537,7 @@ gst_schro_enc_handle_frame (GstBaseVideoEncoder * base_video_encoder,
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_schro_enc_shape_output (GstBaseVideoEncoder * base_video_encoder,
|
gst_schro_enc_shape_output (GstBaseVideoEncoder * base_video_encoder,
|
||||||
GstVideoFrame * frame)
|
GstVideoFrameState * frame)
|
||||||
{
|
{
|
||||||
GstSchroEnc *schro_enc;
|
GstSchroEnc *schro_enc;
|
||||||
int delay;
|
int delay;
|
||||||
|
@ -563,9 +571,6 @@ gst_schro_enc_shape_output (GstBaseVideoEncoder * base_video_encoder,
|
||||||
GST_BUFFER_OFFSET_END (buf) = schro_enc->last_granulepos;
|
GST_BUFFER_OFFSET_END (buf) = schro_enc->last_granulepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_set_caps (buf,
|
|
||||||
GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder)));
|
|
||||||
|
|
||||||
return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
|
return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +578,7 @@ static GstFlowReturn
|
||||||
gst_schro_enc_process (GstSchroEnc * schro_enc)
|
gst_schro_enc_process (GstSchroEnc * schro_enc)
|
||||||
{
|
{
|
||||||
SchroBuffer *encoded_buffer;
|
SchroBuffer *encoded_buffer;
|
||||||
GstVideoFrame *frame;
|
GstVideoFrameState *frame;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
int presentation_frame;
|
int presentation_frame;
|
||||||
void *voidptr;
|
void *voidptr;
|
||||||
|
@ -603,10 +608,12 @@ gst_schro_enc_process (GstSchroEnc * schro_enc)
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
gpointer data;
|
||||||
|
|
||||||
buf = gst_buffer_new_and_alloc (sizeof (double) * 21);
|
data = g_malloc (sizeof (double) * 21);
|
||||||
schro_encoder_get_frame_stats (schro_enc->encoder,
|
schro_encoder_get_frame_stats (schro_enc->encoder,
|
||||||
(double *) GST_BUFFER_DATA (buf), 21);
|
(double *) data, 21);
|
||||||
|
buf = gst_buffer_new_wrapped (data, sizeof (double) * 21);
|
||||||
structure = gst_structure_new ("GstSchroEnc",
|
structure = gst_structure_new ("GstSchroEnc",
|
||||||
"frame-stats", GST_TYPE_BUFFER, buf, NULL);
|
"frame-stats", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
|
@ -50,54 +50,47 @@ gst_schro_buffer_wrap (GstBuffer * buf, GstVideoFormat format, int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
SchroFrame *frame;
|
SchroFrame *frame;
|
||||||
|
GstMapInfo info;
|
||||||
|
|
||||||
|
if (!gst_buffer_map (buf, &info, GST_MAP_READ))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case GST_VIDEO_FORMAT_I420:
|
case GST_VIDEO_FORMAT_I420:
|
||||||
frame =
|
frame = schro_frame_new_from_data_I420 (info.data, width, height);
|
||||||
schro_frame_new_from_data_I420 (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
case GST_VIDEO_FORMAT_YV12:
|
||||||
frame =
|
frame = schro_frame_new_from_data_YV12 (info.data, width, height);
|
||||||
schro_frame_new_from_data_YV12 (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_YUY2:
|
case GST_VIDEO_FORMAT_YUY2:
|
||||||
frame =
|
frame = schro_frame_new_from_data_YUY2 (info.data, width, height);
|
||||||
schro_frame_new_from_data_YUY2 (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
case GST_VIDEO_FORMAT_UYVY:
|
||||||
frame =
|
frame = schro_frame_new_from_data_UYVY (info.data, width, height);
|
||||||
schro_frame_new_from_data_UYVY (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
case GST_VIDEO_FORMAT_AYUV:
|
||||||
frame =
|
frame = schro_frame_new_from_data_AYUV (info.data, width, height);
|
||||||
schro_frame_new_from_data_AYUV (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
#if SCHRO_CHECK_VERSION(1,0,12)
|
#if SCHRO_CHECK_VERSION(1,0,12)
|
||||||
case GST_VIDEO_FORMAT_ARGB:
|
case GST_VIDEO_FORMAT_ARGB:
|
||||||
frame =
|
frame = schro_frame_new_from_data_ARGB (info.data, width, height);
|
||||||
schro_frame_new_from_data_ARGB (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if SCHRO_CHECK_VERSION(1,0,11)
|
#if SCHRO_CHECK_VERSION(1,0,11)
|
||||||
case GST_VIDEO_FORMAT_Y42B:
|
case GST_VIDEO_FORMAT_Y42B:
|
||||||
frame =
|
frame = schro_frame_new_from_data_Y42B (info.data, width, height);
|
||||||
schro_frame_new_from_data_Y42B (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_Y444:
|
case GST_VIDEO_FORMAT_Y444:
|
||||||
frame =
|
frame = schro_frame_new_from_data_Y444 (info.data, width, height);
|
||||||
schro_frame_new_from_data_Y444 (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_v210:
|
case GST_VIDEO_FORMAT_v210:
|
||||||
frame =
|
frame = schro_frame_new_from_data_v210 (info.data, width, height);
|
||||||
schro_frame_new_from_data_v210 (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_v216:
|
case GST_VIDEO_FORMAT_v216:
|
||||||
frame =
|
frame = schro_frame_new_from_data_v216 (info.data, width, height);
|
||||||
schro_frame_new_from_data_v216 (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_AYUV64:
|
case GST_VIDEO_FORMAT_AYUV64:
|
||||||
frame =
|
frame = schro_frame_new_from_data_AY64 (info.data, width, height);
|
||||||
schro_frame_new_from_data_AY64 (GST_BUFFER_DATA (buf), width, height);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
@ -106,10 +99,11 @@ gst_schro_buffer_wrap (GstBuffer * buf, GstVideoFormat format, int width,
|
||||||
}
|
}
|
||||||
schro_frame_set_free_callback (frame, gst_schro_frame_free, buf);
|
schro_frame_set_free_callback (frame, gst_schro_frame_free, buf);
|
||||||
|
|
||||||
|
gst_buffer_unmap (buf, &info);
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GST_BUFFER_FREE_FUNC
|
|
||||||
static void
|
static void
|
||||||
schro_buf_free_func (gpointer priv)
|
schro_buf_free_func (gpointer priv)
|
||||||
{
|
{
|
||||||
|
@ -117,43 +111,48 @@ schro_buf_free_func (gpointer priv)
|
||||||
|
|
||||||
schro_buffer_unref (buffer);
|
schro_buffer_unref (buffer);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* takes the reference */
|
/* takes the reference */
|
||||||
GstBuffer *
|
GstBuffer *
|
||||||
gst_schro_wrap_schro_buffer (SchroBuffer * buffer)
|
gst_schro_wrap_schro_buffer (SchroBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstBuffer *gstbuf;
|
GstMemory *mem;
|
||||||
|
GstBuffer *buf;
|
||||||
|
|
||||||
#ifdef GST_BUFFER_FREE_FUNC
|
mem =
|
||||||
gstbuf = gst_buffer_new ();
|
gst_memory_new_wrapped (0, buffer->data, buffer->length, 0,
|
||||||
GST_BUFFER_DATA (gstbuf) = buffer->data;
|
buffer->length, buffer, schro_buf_free_func);
|
||||||
GST_BUFFER_SIZE (gstbuf) = buffer->length;
|
buf = gst_buffer_new ();
|
||||||
GST_BUFFER_MALLOCDATA (gstbuf) = (void *) buffer;
|
gst_buffer_append_memory (buf, mem);
|
||||||
GST_BUFFER_FREE_FUNC (gstbuf) = schro_buf_free_func;
|
|
||||||
#else
|
|
||||||
gstbuf = gst_buffer_new_and_alloc (buffer->length);
|
|
||||||
memcpy (GST_BUFFER_DATA (gstbuf), buffer->data, buffer->length);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return gstbuf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_schro_buffer_free (SchroBuffer * buffer, void *priv)
|
gst_schro_buffer_free (SchroBuffer * buffer, void *priv)
|
||||||
{
|
{
|
||||||
gst_buffer_unref (GST_BUFFER (priv));
|
gst_memory_unref (GST_MEMORY_CAST (priv));
|
||||||
}
|
}
|
||||||
|
|
||||||
SchroBuffer *
|
SchroBuffer *
|
||||||
gst_schro_wrap_gst_buffer (GstBuffer * buffer)
|
gst_schro_wrap_gst_buffer (GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
SchroBuffer *schrobuf;
|
SchroBuffer *schrobuf;
|
||||||
|
GstMemory *mem;
|
||||||
|
GstMapInfo info;
|
||||||
|
|
||||||
schrobuf = schro_buffer_new_with_data (GST_BUFFER_DATA (buffer),
|
mem = gst_buffer_get_merged_memory (buffer);
|
||||||
GST_BUFFER_SIZE (buffer));
|
if (!gst_memory_map (mem, &info, GST_MAP_READ)) {
|
||||||
|
GST_ERROR ("Couldn't get readable memory from gstbuffer");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME : We can't control if data won't be read/write outside
|
||||||
|
* of schro ... */
|
||||||
|
schrobuf = schro_buffer_new_with_data (info.data, info.size);
|
||||||
|
gst_memory_unmap (mem, &info);
|
||||||
schrobuf->free = gst_schro_buffer_free;
|
schrobuf->free = gst_schro_buffer_free;
|
||||||
schrobuf->priv = buffer;
|
schrobuf->priv = mem;
|
||||||
|
|
||||||
return schrobuf;
|
return schrobuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
#include <schroedinger/schro.h>
|
#include <schroedinger/schro.h>
|
||||||
|
|
||||||
#if SCHRO_CHECK_VERSION(1,0,11)
|
#if SCHRO_CHECK_VERSION(1,0,11)
|
||||||
#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV, Y42B, Y444, v216, v210, AY64 }"
|
#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV, Y42B, Y444, v216, v210, AY64, ARGB }"
|
||||||
#else
|
#else
|
||||||
#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV }"
|
#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV, ARGB }"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SchroFrame *
|
SchroFrame *
|
||||||
|
|
Loading…
Reference in a new issue