mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
rpicamsrc: Don't try and set H264 params with JPEG codec
This commit is contained in:
parent
da86cec40e
commit
38ef8c2411
2 changed files with 63 additions and 49 deletions
|
@ -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,57 +1447,60 @@ 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)
|
|
||||||
{
|
{
|
||||||
vcos_log_error("Unable to set immutable input flag");
|
if (mmal_port_parameter_set_boolean(encoder_input, MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT, config->immutableInput) != MMAL_SUCCESS)
|
||||||
// Continue rather than abort..
|
{
|
||||||
}
|
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
|
//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)
|
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");
|
vcos_log_error("failed to set INLINE HEADER FLAG parameters");
|
||||||
// Continue rather than abort..
|
// Continue rather than abort..
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//set INLINE VECTORS flag to request motion vector estimates
|
if (config->encoding == MMAL_ENCODING_H264)
|
||||||
if (config->encoding == MMAL_ENCODING_H264 &&
|
{
|
||||||
mmal_port_parameter_set_boolean(encoder_output, MMAL_PARAMETER_VIDEO_ENCODE_INLINE_VECTORS, config->inlineMotionVectors) != MMAL_SUCCESS)
|
//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..
|
vcos_log_error("failed to set INLINE VECTORS parameters");
|
||||||
}
|
// 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;
|
|
||||||
|
|
||||||
/* Need to memset, apparently mmal_port_parameter_get()
|
/* Need to memset, apparently mmal_port_parameter_get()
|
||||||
* doesn't retrieve all parameters, causing random failures
|
* doesn't retrieve all parameters, causing random failures
|
||||||
* when we set it
|
* when we set it
|
||||||
*/
|
*/
|
||||||
memset (¶m, 0, sizeof (MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T));
|
memset (¶m, 0, sizeof (MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T));
|
||||||
|
|
||||||
param.hdr.id = MMAL_PARAMETER_VIDEO_INTRA_REFRESH;
|
param.hdr.id = MMAL_PARAMETER_VIDEO_INTRA_REFRESH;
|
||||||
param.hdr.size = sizeof(param);
|
param.hdr.size = sizeof(param);
|
||||||
|
|
||||||
// Get first so we don't overwrite anything unexpectedly
|
// Get first so we don't overwrite anything unexpectedly
|
||||||
status = mmal_port_parameter_get(encoder_output, ¶m.hdr);
|
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)
|
//if (state->intra_refresh_type == MMAL_VIDEO_INTRA_REFRESH_CYCLIC_MROWS)
|
||||||
// param.cir_mbs = 10;
|
// param.cir_mbs = 10;
|
||||||
|
|
||||||
status = mmal_port_parameter_set(encoder_output, ¶m.hdr);
|
status = mmal_port_parameter_set(encoder_output, ¶m.hdr);
|
||||||
if (status != MMAL_SUCCESS)
|
if (status != MMAL_SUCCESS)
|
||||||
{
|
{
|
||||||
vcos_log_error("Unable to set H264 intra-refresh values");
|
vcos_log_error("Unable to set H264 intra-refresh values");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->encoding == MMAL_ENCODING_JPEG)
|
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);
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
gst_caps_set_simple (caps, "width", GST_TYPE_INT_RANGE, 1, 1920, "height",
|
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||||
GST_TYPE_INT_RANGE, 1, 1080, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1,
|
GstStructure *s = gst_caps_get_structure (caps, i);
|
||||||
90, 1, NULL);
|
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:
|
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 */
|
||||||
|
|
Loading…
Reference in a new issue