diff options
author | Jan Schmidt <jan@centricular.com> | 2016-10-03 17:00:54 +0300 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2020-07-10 18:45:49 +0300 |
commit | 38ef8c2411fec2c8319d36a76b58b9c716f0b2a9 (patch) | |
tree | e2dc6dc5d3a59d05c68e88f3e31073fb371c2cd1 /sys | |
parent | da86cec40e375d4196b5ea73b7421075b6d2ad98 (diff) |
rpicamsrc: Don't try and set H264 params with JPEG codec
Diffstat (limited to 'sys')
-rw-r--r-- | sys/rpicamsrc/RaspiCapture.c | 88 | ||||
-rw-r--r-- | sys/rpicamsrc/gstrpicamsrc.c | 24 |
2 files changed, 63 insertions, 49 deletions
diff --git a/sys/rpicamsrc/RaspiCapture.c b/sys/rpicamsrc/RaspiCapture.c index ad4798f7f..b3608ca78 100644 --- a/sys/rpicamsrc/RaspiCapture.c +++ b/sys/rpicamsrc/RaspiCapture.c @@ -1428,7 +1428,6 @@ static MMAL_STATUS_T create_encoder_component(RASPIVID_STATE *state) vcos_log_error("Unable to set max QP"); goto error; } - } if (config->encoding == MMAL_ENCODING_H264) @@ -1448,57 +1447,60 @@ static MMAL_STATUS_T create_encoder_component(RASPIVID_STATE *state) } } - - if (mmal_port_parameter_set_boolean(encoder_input, MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT, config->immutableInput) != MMAL_SUCCESS) + if (config->encoding != MMAL_ENCODING_JPEG) { - vcos_log_error("Unable to set immutable input flag"); - // Continue rather than abort.. - } + if (mmal_port_parameter_set_boolean(encoder_input, MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT, config->immutableInput) != MMAL_SUCCESS) + { + vcos_log_error("Unable to set immutable input flag"); + // Continue rather than abort.. + } - //set INLINE HEADER flag to generate SPS and PPS for every IDR if requested - if (mmal_port_parameter_set_boolean(encoder_output, MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER, config->bInlineHeaders) != MMAL_SUCCESS) - { - vcos_log_error("failed to set INLINE HEADER FLAG parameters"); - // Continue rather than abort.. - } + //set INLINE HEADER flag to generate SPS and PPS for every IDR if requested + if (mmal_port_parameter_set_boolean(encoder_output, MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER, config->bInlineHeaders) != MMAL_SUCCESS) + { + vcos_log_error("failed to set INLINE HEADER FLAG parameters"); + // Continue rather than abort.. + } + } - //set INLINE VECTORS flag to request motion vector estimates - if (config->encoding == MMAL_ENCODING_H264 && - mmal_port_parameter_set_boolean(encoder_output, MMAL_PARAMETER_VIDEO_ENCODE_INLINE_VECTORS, config->inlineMotionVectors) != MMAL_SUCCESS) - { - vcos_log_error("failed to set INLINE VECTORS parameters"); - // Continue rather than abort.. - } + if (config->encoding == MMAL_ENCODING_H264) + { + //set INLINE VECTORS flag to request motion vector estimates + if (mmal_port_parameter_set_boolean(encoder_output, MMAL_PARAMETER_VIDEO_ENCODE_INLINE_VECTORS, config->inlineMotionVectors) != MMAL_SUCCESS) + { + vcos_log_error("failed to set INLINE VECTORS parameters"); + // Continue rather than abort.. + } - // Adaptive intra refresh settings - if (config->encoding == MMAL_ENCODING_H264 && - config->intra_refresh_type != -1) - { - MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T param; + // Adaptive intra refresh settings + if (config->intra_refresh_type != -1) + { + MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T param; - /* Need to memset, apparently mmal_port_parameter_get() - * doesn't retrieve all parameters, causing random failures - * when we set it - */ - memset (¶m, 0, sizeof (MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T)); + /* Need to memset, apparently mmal_port_parameter_get() + * doesn't retrieve all parameters, causing random failures + * when we set it + */ + memset (¶m, 0, sizeof (MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T)); - param.hdr.id = MMAL_PARAMETER_VIDEO_INTRA_REFRESH; - param.hdr.size = sizeof(param); + param.hdr.id = MMAL_PARAMETER_VIDEO_INTRA_REFRESH; + param.hdr.size = sizeof(param); - // Get first so we don't overwrite anything unexpectedly - status = mmal_port_parameter_get(encoder_output, ¶m.hdr); + // Get first so we don't overwrite anything unexpectedly + status = mmal_port_parameter_get(encoder_output, ¶m.hdr); - param.refresh_mode = config->intra_refresh_type; + param.refresh_mode = config->intra_refresh_type; - //if (state->intra_refresh_type == MMAL_VIDEO_INTRA_REFRESH_CYCLIC_MROWS) - // param.cir_mbs = 10; + //if (state->intra_refresh_type == MMAL_VIDEO_INTRA_REFRESH_CYCLIC_MROWS) + // param.cir_mbs = 10; - status = mmal_port_parameter_set(encoder_output, ¶m.hdr); - if (status != MMAL_SUCCESS) - { + status = mmal_port_parameter_set(encoder_output, ¶m.hdr); + if (status != MMAL_SUCCESS) + { vcos_log_error("Unable to set H264 intra-refresh values"); - goto error; - } + goto error; + } + } } if (config->encoding == MMAL_ENCODING_JPEG) @@ -1506,14 +1508,14 @@ static MMAL_STATUS_T create_encoder_component(RASPIVID_STATE *state) status = mmal_port_parameter_set_uint32(encoder_output, MMAL_PARAMETER_JPEG_Q_FACTOR, config->jpegQuality); if (status != MMAL_SUCCESS) { vcos_log_error("Unable to set JPEG quality"); - goto error; + // Continue after warning } #ifdef MMAL_PARAMETER_JPEG_RESTART_INTERVAL status = mmal_port_parameter_set_uint32(encoder_output, MMAL_PARAMETER_JPEG_RESTART_INTERVAL, config->jpegRestartInterval); if (status != MMAL_SUCCESS) { vcos_log_error("Unable to set JPEG restart interval"); - goto error; + // Continue after warning } #endif } diff --git a/sys/rpicamsrc/gstrpicamsrc.c b/sys/rpicamsrc/gstrpicamsrc.c index 3bf9ab6fc..542c3bb24 100644 --- a/sys/rpicamsrc/gstrpicamsrc.c +++ b/sys/rpicamsrc/gstrpicamsrc.c @@ -250,10 +250,10 @@ gst_rpi_cam_src_sensor_mode_get_type (void) {C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_1920x1080), "1920x1080 16:9 1-30fps", "1920x1080"}, {C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_2592x1944_FAST), - "2592x1944 4:3 1-15fps", + "2592x1944 4:3 1-15fps / 3240x2464 15fps w/ v.2 board", "2592x1944-fast"}, {C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_2592x1944_SLOW), - "2592x1944 4:3 0.1666-1fps", "2592x1944-slow"}, + "2592x1944 4:3 0.1666-1fps / 3240x2464 15fps w/ v.2 board", "2592x1944-slow"}, {C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_1296x972), "1296x972 4:3 1-42fps", "1296x972"}, {C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_1296x730), "1296x730 16:9 1-49fps", @@ -1254,14 +1254,26 @@ gst_rpi_cam_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter) { GstRpiCamSrc *src = GST_RPICAMSRC (bsrc); GstCaps *caps; + gint i; + caps = gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (bsrc)); if (src->capture_state == NULL) goto done; /* FIXME: Retrieve limiting parameters from the camera module, max width/height fps-range */ caps = gst_caps_make_writable (caps); - gst_caps_set_simple (caps, "width", GST_TYPE_INT_RANGE, 1, 1920, "height", - GST_TYPE_INT_RANGE, 1, 1080, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, - 90, 1, NULL); + for (i = 0; i < gst_caps_get_size (caps); i++) { + GstStructure *s = gst_caps_get_structure (caps, i); + if (gst_structure_has_name (s, "video/x-h264")) { + gst_caps_set_simple (caps, "width", GST_TYPE_INT_RANGE, 1, 1920, "height", + GST_TYPE_INT_RANGE, 1, 1080, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, + 90, 1, NULL); + } + else { + gst_caps_set_simple (caps, "width", GST_TYPE_INT_RANGE, 1, 3240, "height", + GST_TYPE_INT_RANGE, 1, 2464, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, + 90, 1, NULL); + } + } done: GST_DEBUG_OBJECT (src, "get_caps returning %" GST_PTR_FORMAT, caps); return caps; @@ -1295,7 +1307,7 @@ gst_rpi_cam_src_set_caps (GstBaseSrc * bsrc, GstCaps * caps) } } else if (gst_structure_has_name (structure, "image/jpeg")) { - src->capture_config.encoding = MMAL_ENCODING_MJPEG; + src->capture_config.encoding = MMAL_ENCODING_JPEG; } else { /* Raw caps */ |