summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2004-02-05 23:15:00 +0000
committerDavid Schleef <ds@schleef.org>2004-02-05 23:15:00 +0000
commitc0ada861f26952e053c92202238966b6ce1f7050 (patch)
tree9f434ed75755595a5ca665186bd82dc70615395c
parent23e23f0fadd93ebeb928d997961d46588e1e2bab (diff)
ext/dv/gstdvdec.c: Revert last change, because it Just Doesn't Compile.
Original commit message from CVS: * ext/dv/gstdvdec.c: (gst_dvdec_init), (gst_dvdec_loop): Revert last change, because it Just Doesn't Compile.
-rw-r--r--ChangeLog5
-rw-r--r--ext/dv/gstdvdec.c191
2 files changed, 85 insertions, 111 deletions
diff --git a/ChangeLog b/ChangeLog
index d7173d44..aee52ccd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-05 David Schleef <ds@schleef.org>
+
+ * ext/dv/gstdvdec.c: (gst_dvdec_init), (gst_dvdec_loop): Revert
+ last change, because it Just Doesn't Compile.
+
2004-02-05 Benjamin Otte <in7y118@public.uni-hamburg.de>
* ext/mad/gstid3tag.c: (gst_id3_tag_chain):
diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c
index c88c1b1d..c18bf590 100644
--- a/ext/dv/gstdvdec.c
+++ b/ext/dv/gstdvdec.c
@@ -93,12 +93,12 @@ GST_STATIC_PAD_TEMPLATE
"format = (fourcc) YUY2, "
"width = (int) 720, "
"height = (int) { "
- G_STRINGIFY(NTSC_HEIGHT) ", "
- G_STRINGIFY(PAL_HEIGHT)
+ G_STRINGIFY(NTSC_HEIGHT) ", "
+ G_STRINGIFY(PAL_HEIGHT)
" }, "
"framerate = (double) { "
- G_STRINGIFY(PAL_FRAMERATE) ", "
- G_STRINGIFY(NTSC_FRAMERATE)
+ G_STRINGIFY(PAL_FRAMERATE) ", "
+ G_STRINGIFY(NTSC_FRAMERATE)
" }; "
"video/x-raw-rgb, "
@@ -186,10 +186,6 @@ static gboolean gst_dvdec_sink_convert (GstPad *pad, GstFormat src_format, gi
static gboolean gst_dvdec_src_convert (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value);
-static GstPadLinkReturn gst_dvdec_video_link (GstPad *pad,
- const GstCaps *caps);
-static GstCaps* gst_dvdec_video_getcaps (GstPad *pad);
-
static const GstEventMask*
gst_dvdec_get_event_masks (GstPad *pad);
static gboolean gst_dvdec_handle_src_event (GstPad *pad, GstEvent *event);
@@ -314,25 +310,22 @@ gst_dvdec_init(GstDVDec *dvdec)
gst_pad_set_formats_function (dvdec->sinkpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_formats));
dvdec->videosrcpad = gst_pad_new_from_template (gst_static_pad_template_get (&video_src_temp), "video");
+ gst_element_add_pad (GST_ELEMENT (dvdec), dvdec->videosrcpad);
gst_pad_set_query_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_src_query));
gst_pad_set_query_type_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_src_query_types));
gst_pad_set_event_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_handle_src_event));
gst_pad_set_event_mask_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_event_masks));
gst_pad_set_convert_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_src_convert));
gst_pad_set_formats_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_formats));
- gst_pad_set_link_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_video_link));
- gst_pad_set_getcaps_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_video_getcaps));
- gst_element_add_pad (GST_ELEMENT (dvdec), dvdec->videosrcpad);
-
+
dvdec->audiosrcpad = gst_pad_new_from_template (gst_static_pad_template_get (&audio_src_temp), "audio");
+ gst_element_add_pad(GST_ELEMENT(dvdec),dvdec->audiosrcpad);
gst_pad_set_query_function (dvdec->audiosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_src_query));
gst_pad_set_query_type_function (dvdec->audiosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_src_query_types));
gst_pad_set_event_function (dvdec->audiosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_handle_src_event));
gst_pad_set_event_mask_function (dvdec->audiosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_event_masks));
gst_pad_set_convert_function (dvdec->audiosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_src_convert));
gst_pad_set_formats_function (dvdec->audiosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_formats));
- gst_pad_use_explicit_caps (dvdec->audiosrcpad);
- gst_element_add_pad (GST_ELEMENT(dvdec), dvdec->audiosrcpad);
gst_element_set_loop_function (GST_ELEMENT (dvdec), gst_dvdec_loop);
@@ -342,15 +335,11 @@ gst_dvdec_init(GstDVDec *dvdec)
dvdec->need_discont = FALSE;
dvdec->framerate = 0;
dvdec->height = 0;
- dvdec->frequency = 0;
- dvdec->channels = 0;
-
dvdec->clamp_luma = FALSE;
dvdec->clamp_chroma = FALSE;
dvdec->quality = DV_QUALITY_BEST;
dvdec->loop = FALSE;
- dvdec->found_header = FALSE;
-
+
for (i = 0; i <4; i++) {
dvdec->audio_buffers[i] = (gint16 *)g_malloc (DV_AUDIO_MAX_SAMPLES * sizeof (gint16));
}
@@ -668,92 +657,6 @@ gst_dvdec_handle_src_event (GstPad *pad, GstEvent *event)
return res;
}
-static GstCaps*
-gst_dvdec_video_getcaps (GstPad *pad)
-{
- GstDVDec *dvdec;
- GstCaps *caps;
- GstPadTemplate *src_pad_template;
-
- dvdec = GST_DVDEC (gst_pad_get_parent (pad));
- src_pad_template = gst_static_pad_template_get (&video_src_temp);
- caps = gst_caps_copy(gst_pad_template_get_caps (src_pad_template));
-
- if (dvdec->found_header)
- {
- int i;
-
- /* set the height */
- for (i = 0; i < gst_caps_get_size (caps); i++)
- {
- GstStructure *structure = gst_caps_get_structure (caps, i);
- gst_structure_set(structure,
- "height", G_TYPE_INT, dvdec->height,
- "framerate", G_TYPE_DOUBLE, dvdec->, NULL
- );
- }
- }
-
- return caps;
-}
-
-static GstPadLinkReturn
-gst_dvdec_video_link (GstPad *pad, const GstCaps *caps)
-{
- /* if we did not find a header yet, return delayed */
- if (!dvdec->found_header)
- return GST_PAD_LINK_DELAYED;
-
-
-
- for (i=0; i < gst_caps_get_size(caps); i++) {
- GstStructure *to_try_struct = gst_caps_get_structure (caps, i);
- GstCaps *try_caps =
- gst_caps_new_full (gst_structure_copy(to_try_struct), NULL);
-
- /* try each format */
- if (gst_pad_try_set_caps (dvdec->videosrcpad, try_caps) > 0) {
- negotiated_caps = try_caps;
- break;
- }
-
- gst_caps_free(try_caps);
- }
-
- gst_caps_free (caps);
-
- /* Check if we negotiated caps successfully */
- if (negotiated_caps != NULL) {
- GstStructure *structure = gst_caps_get_structure (negotiated_caps, 0);
- guint32 fourcc;
-
- /* it worked, try to find what it was again */
- gst_structure_get_fourcc (structure, "format", &fourcc);
-
- if (fourcc == GST_STR_FOURCC ("RGB ")) {
- gint bpp;
-
- gst_structure_get_int (structure, "bpp", &bpp);
- if (bpp == 24) {
- dvdec->space = e_dv_color_rgb;
- dvdec->bpp = 3;
- }
- else {
- dvdec->space = e_dv_color_bgr0;
- dvdec->bpp = 4;
- }
- }
- else {
- dvdec->space = e_dv_color_yuv;
- dvdec->bpp = 2;
- }
- } else {
- GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL), (NULL));
- return;
- }
- }
-}
-
static void
gst_dvdec_push (GstDVDec *dvdec, GstBuffer *outbuf, GstPad *pad, GstClockTime ts)
{
@@ -788,7 +691,6 @@ gst_dvdec_loop (GstElement *element)
GstFormat format;
guint64 ts;
gfloat fps;
- const GstCaps *cur_caps;
dvdec = GST_DVDEC (element);
@@ -799,11 +701,11 @@ gst_dvdec_loop (GstElement *element)
return;
}
dv_parse_header (dvdec->decoder, inframe);
-
- /* after parsing the header we know the length of the data */
+ /* after parsing the header we know the size of the data */
dvdec->PAL = dv_system_50_fields (dvdec->decoder);
- dvdec->framerate = fps = (dvdec->PAL ? PAL_FRAMERATE : NTSC_FRAMERATE);
+ dvdec->framerate = (dvdec->PAL ? 2500 : 2997);
+ fps = (dvdec->PAL ? PAL_FRAMERATE : NTSC_FRAMERATE);
dvdec->height = height = (dvdec->PAL ? PAL_HEIGHT : NTSC_HEIGHT);
length = (dvdec->PAL ? PAL_BUFFER : NTSC_BUFFER);
@@ -819,10 +721,77 @@ gst_dvdec_loop (GstElement *element)
return;
}
+ /* if we did not negotiate yet, do it now */
+ if (!GST_PAD_CAPS (dvdec->videosrcpad)) {
+ GstCaps *caps = NULL;
+ GstCaps *negotiated_caps = NULL;
+ GstPadTemplate *src_pad_template;
+ int i;
+
+ /* try to fix our height */
+ src_pad_template = gst_static_pad_template_get (&video_src_temp);
+ caps = gst_caps_copy(gst_pad_template_get_caps (src_pad_template));
+
+ for (i = 0; i < gst_caps_get_size (caps); i++)
+ {
+ GstStructure *structure = gst_caps_get_structure (caps, i);
+ gst_structure_set(structure,
+ "height", G_TYPE_INT, height,
+ "framerate", G_TYPE_INT, fps, NULL
+ );
+ }
+
+ for (i=0; i < gst_caps_get_size(caps); i++) {
+ GstStructure *to_try_struct = gst_caps_get_structure (caps, i);
+ GstCaps *try_caps =
+ gst_caps_new_full (gst_structure_copy(to_try_struct), NULL);
+
+ /* try each format */
+ if (gst_pad_try_set_caps (dvdec->videosrcpad, try_caps) > 0) {
+ negotiated_caps = try_caps;
+ break;
+ }
+
+ gst_caps_free(try_caps);
+ }
+
+ gst_caps_free (caps);
+
+ /* Check if we negotiated caps successfully */
+ if (negotiated_caps != NULL) {
+ GstStructure *structure = gst_caps_get_structure (negotiated_caps, 0);
+ guint32 fourcc;
+
+ /* it worked, try to find what it was again */
+ gst_structure_get_fourcc (structure, "format", &fourcc);
+
+ if (fourcc == GST_STR_FOURCC ("RGB ")) {
+ gint bpp;
+
+ gst_structure_get_int (structure, "bpp", &bpp);
+ if (bpp == 24) {
+ dvdec->space = e_dv_color_rgb;
+ dvdec->bpp = 3;
+ }
+ else {
+ dvdec->space = e_dv_color_bgr0;
+ dvdec->bpp = 4;
+ }
+ }
+ else {
+ dvdec->space = e_dv_color_yuv;
+ dvdec->bpp = 2;
+ }
+ } else {
+ GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL), (NULL));
+ return;
+ }
+ }
+
format = GST_FORMAT_TIME;
gst_pad_query (dvdec->videosrcpad, GST_QUERY_POSITION, &format, &ts);
- dvdec->next_ts += GST_SECOND / dvdec->framerate;
+ dvdec->next_ts += (GST_SECOND*100) / dvdec->framerate;
if (GST_PAD_IS_LINKED (dvdec->audiosrcpad)) {
gint16 *a_ptr;
@@ -832,7 +801,7 @@ gst_dvdec_loop (GstElement *element)
/* if we did not negotiate yet, do it now */
if (!GST_PAD_CAPS (dvdec->audiosrcpad)) {
- gst_pad_set_explicit_caps (dvdec->audiosrcpad,
+ gst_pad_try_set_caps (dvdec->audiosrcpad,
gst_caps_new_simple (
"audio/x-raw-int",
"rate", G_TYPE_INT, dvdec->decoder->audio->frequency,