rpicamsrc: Don't try and set H264 params with JPEG codec

This commit is contained in:
Jan Schmidt 2016-10-03 14:00:54 +00:00 committed by Tim-Philipp Müller
parent da86cec40e
commit 38ef8c2411
2 changed files with 63 additions and 49 deletions

View file

@ -1428,7 +1428,6 @@ static MMAL_STATUS_T create_encoder_component(RASPIVID_STATE *state)
vcos_log_error("Unable to set max QP"); vcos_log_error("Unable to set max QP");
goto error; goto error;
} }
} }
if (config->encoding == MMAL_ENCODING_H264) if (config->encoding == MMAL_ENCODING_H264)
@ -1448,7 +1447,8 @@ static MMAL_STATUS_T create_encoder_component(RASPIVID_STATE *state)
} }
} }
if (config->encoding != MMAL_ENCODING_JPEG)
{
if (mmal_port_parameter_set_boolean(encoder_input, MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT, config->immutableInput) != MMAL_SUCCESS) 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"); vcos_log_error("Unable to set immutable input flag");
@ -1461,18 +1461,19 @@ static MMAL_STATUS_T create_encoder_component(RASPIVID_STATE *state)
vcos_log_error("failed to set INLINE HEADER FLAG parameters"); vcos_log_error("failed to set INLINE HEADER FLAG parameters");
// Continue rather than abort.. // Continue rather than abort..
} }
}
if (config->encoding == MMAL_ENCODING_H264)
{
//set INLINE VECTORS flag to request motion vector estimates //set INLINE VECTORS flag to request motion vector estimates
if (config->encoding == MMAL_ENCODING_H264 && if (mmal_port_parameter_set_boolean(encoder_output, MMAL_PARAMETER_VIDEO_ENCODE_INLINE_VECTORS, config->inlineMotionVectors) != MMAL_SUCCESS)
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"); vcos_log_error("failed to set INLINE VECTORS parameters");
// Continue rather than abort.. // Continue rather than abort..
} }
// Adaptive intra refresh settings // Adaptive intra refresh settings
if (config->encoding == MMAL_ENCODING_H264 && if (config->intra_refresh_type != -1)
config->intra_refresh_type != -1)
{ {
MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T param; MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T param;
@ -1500,20 +1501,21 @@ static MMAL_STATUS_T create_encoder_component(RASPIVID_STATE *state)
goto error; goto error;
} }
} }
}
if (config->encoding == MMAL_ENCODING_JPEG) if (config->encoding == MMAL_ENCODING_JPEG)
{ {
status = mmal_port_parameter_set_uint32(encoder_output, MMAL_PARAMETER_JPEG_Q_FACTOR, config->jpegQuality); status = mmal_port_parameter_set_uint32(encoder_output, MMAL_PARAMETER_JPEG_Q_FACTOR, config->jpegQuality);
if (status != MMAL_SUCCESS) { if (status != MMAL_SUCCESS) {
vcos_log_error("Unable to set JPEG quality"); vcos_log_error("Unable to set JPEG quality");
goto error; // Continue after warning
} }
#ifdef MMAL_PARAMETER_JPEG_RESTART_INTERVAL #ifdef MMAL_PARAMETER_JPEG_RESTART_INTERVAL
status = mmal_port_parameter_set_uint32(encoder_output, MMAL_PARAMETER_JPEG_RESTART_INTERVAL, config->jpegRestartInterval); status = mmal_port_parameter_set_uint32(encoder_output, MMAL_PARAMETER_JPEG_RESTART_INTERVAL, config->jpegRestartInterval);
if (status != MMAL_SUCCESS) { if (status != MMAL_SUCCESS) {
vcos_log_error("Unable to set JPEG restart interval"); vcos_log_error("Unable to set JPEG restart interval");
goto error; // Continue after warning
} }
#endif #endif
} }

View file

@ -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", {C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_1920x1080), "1920x1080 16:9 1-30fps",
"1920x1080"}, "1920x1080"},
{C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_2592x1944_FAST), {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"}, "2592x1944-fast"},
{C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_2592x1944_SLOW), {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", {C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_1296x972), "1296x972 4:3 1-42fps",
"1296x972"}, "1296x972"},
{C_ENUM (GST_RPI_CAM_SRC_SENSOR_MODE_1296x730), "1296x730 16:9 1-49fps", {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); GstRpiCamSrc *src = GST_RPICAMSRC (bsrc);
GstCaps *caps; GstCaps *caps;
gint i;
caps = gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (bsrc)); caps = gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (bsrc));
if (src->capture_state == NULL) if (src->capture_state == NULL)
goto done; goto done;
/* FIXME: Retrieve limiting parameters from the camera module, max width/height fps-range */ /* FIXME: Retrieve limiting parameters from the camera module, max width/height fps-range */
caps = gst_caps_make_writable (caps); caps = gst_caps_make_writable (caps);
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_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, GST_TYPE_INT_RANGE, 1, 1080, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1,
90, 1, NULL); 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: done:
GST_DEBUG_OBJECT (src, "get_caps returning %" GST_PTR_FORMAT, caps); GST_DEBUG_OBJECT (src, "get_caps returning %" GST_PTR_FORMAT, caps);
return 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")) { else if (gst_structure_has_name (structure, "image/jpeg")) {
src->capture_config.encoding = MMAL_ENCODING_MJPEG; src->capture_config.encoding = MMAL_ENCODING_JPEG;
} }
else { else {
/* Raw caps */ /* Raw caps */