niimaqdxsrc: add support for JPEG PixelFormat

This commit is contained in:
Joshua M. Doe 2017-05-03 11:59:04 -04:00
parent 4a18d3e118
commit a4af051165
2 changed files with 27 additions and 9 deletions

View File

@ -215,6 +215,8 @@ ImaqDxCapsInfo imaq_dx_caps_infos[] = {
{"Bayer RG 16", 0, VIDEO_CAPS_MAKE_BAYER16 ("rggb16", "1234"), 16, 16, 1} {"Bayer RG 16", 0, VIDEO_CAPS_MAKE_BAYER16 ("rggb16", "1234"), 16, 16, 1}
, ,
{"Bayer GB 16", 0, VIDEO_CAPS_MAKE_BAYER16 ("gbrg16", "1234"), 16, 16, 1} {"Bayer GB 16", 0, VIDEO_CAPS_MAKE_BAYER16 ("gbrg16", "1234"), 16, 16, 1}
,
{"JPEG", 0, "image/jpeg", 8, 8, 1}
}; };
static const ImaqDxCapsInfo * static const ImaqDxCapsInfo *
@ -698,6 +700,11 @@ gst_niimaqdxsrc_fill (GstPushSrc * psrc, GstBuffer * buf)
goto error; goto error;
} }
if (src->is_jpeg) {
/* JPEG sources don't seem to give reliable callbacks, just pull clock */
timestamp = gst_clock_get_time (gst_element_get_clock (GST_ELEMENT (src)));
}
while (timestamp == GST_CLOCK_TIME_NONE) { while (timestamp == GST_CLOCK_TIME_NONE) {
/* wait 100 ms, shouldn't be needed if callback is working as expected */ /* wait 100 ms, shouldn't be needed if callback is working as expected */
GstNiImaqDxSrcTimeEntry *entry = GstNiImaqDxSrcTimeEntry *entry =
@ -1018,6 +1025,9 @@ gst_niimaqdxsrc_start (GstBaseSrc * bsrc)
goto error; goto error;
} }
if (src->is_jpeg) {
GST_DEBUG_OBJECT (src, "Source is JPEG, just use clock time");
} else {
GST_LOG_OBJECT (src, "Registering callback functions"); GST_LOG_OBJECT (src, "Registering callback functions");
rval = rval =
IMAQdxRegisterFrameDoneEvent (src->session, 1, IMAQdxRegisterFrameDoneEvent (src->session, 1,
@ -1028,6 +1038,7 @@ gst_niimaqdxsrc_start (GstBaseSrc * bsrc)
("Failed to register callback(s)"), (NULL)); ("Failed to register callback(s)"), (NULL));
goto error; goto error;
} }
}
gst_niimaqdxsrc_set_dx_attributes (src); gst_niimaqdxsrc_set_dx_attributes (src);
@ -1162,6 +1173,12 @@ gst_niimaqdxsrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
src->caps_info = gst_niimaqdxsrc_get_caps_info (pixel_format, endianness); src->caps_info = gst_niimaqdxsrc_get_caps_info (pixel_format, endianness);
if (g_strcmp0 (pixel_format, "JPEG") == 0) {
src->is_jpeg = TRUE;
} else {
src->is_jpeg = FALSE;
}
src->dx_row_stride = src->dx_row_stride =
gst_niimaqdxsrc_pixel_format_get_stride (pixel_format, endianness, gst_niimaqdxsrc_pixel_format_get_stride (pixel_format, endianness,
src->width); src->width);

View File

@ -76,6 +76,7 @@ struct _GstNiImaqDxSrc {
gint gst_framesize; gint gst_framesize;
guint8 *temp_buffer; guint8 *temp_buffer;
const ImaqDxCapsInfo *caps_info; const ImaqDxCapsInfo *caps_info;
gboolean is_jpeg;
uInt32 cumbufnum; uInt32 cumbufnum;
gint64 n_dropped_frames; gint64 n_dropped_frames;