Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoder maxperf-enable path #1

Closed
bmegli opened this issue Mar 7, 2023 · 7 comments
Closed

encoder maxperf-enable path #1

bmegli opened this issue Mar 7, 2023 · 7 comments

Comments

@bmegli
Copy link
Collaborator

bmegli commented Mar 7, 2023

g_object_class_install_property (gobject_class, PROP_MAX_PERF,
g_param_spec_boolean ("maxperf-enable",
"Enable or Disable Max Performance mode",
"Enable or Disable Max Performance mode",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
GST_PARAM_MUTABLE_READY));

@bmegli
Copy link
Collaborator Author

bmegli commented Mar 7, 2023

case PROP_MAX_PERF:
self->maxperf_enable = g_value_get_boolean (value);
break;

@bmegli
Copy link
Collaborator Author

bmegli commented Mar 7, 2023

if (video_enc->maxperf_enable) {
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
V4L2_CID_MPEG_VIDEO_MAX_PERFORMANCE, video_enc->maxperf_enable)) {
g_print ("S_EXT_CTRLS for MAX_PERFORMANCE failed\n");
return FALSE;
}
}

@bmegli
Copy link
Collaborator Author

bmegli commented Mar 7, 2023

#ifdef USE_V4L2_TARGET_NV
gboolean set_v4l2_video_mpeg_class (GstV4l2Object * v4l2object, guint label,
gint params);
#endif

@bmegli
Copy link
Collaborator Author

bmegli commented Mar 7, 2023

#ifdef USE_V4L2_TARGET_NV
gboolean
set_v4l2_video_mpeg_class (GstV4l2Object * v4l2object, guint label,
gint params)
{
struct v4l2_ext_control control;
struct v4l2_ext_controls ctrls;
gint ret;
v4l2_enc_virtual_buffer_size buffer_size = { params };
if (!GST_V4L2_IS_OPEN (v4l2object)) {
g_print ("V4L2 device is not open\n");
return FALSE;
}
memset (&control, 0, sizeof (control));
memset (&ctrls, 0, sizeof (ctrls));
ctrls.count = 1;
ctrls.controls = &control;
ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
control.id = label;
if (control.id == V4L2_CID_MPEG_VIDEOENC_VIRTUALBUFFER_SIZE) {
control.string = (gchar *) &buffer_size;
} else if ((control.id == V4L2_CID_MPEG_VIDEOENC_SLICE_INTRAREFRESH_PARAM) ||
(control.id == V4L2_CID_MPEG_VIDEOENC_NUM_REFERENCE_FRAMES)) {
control.string = (gchar *) &params;
} else {
control.value = params;
}
ret = v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
if (ret < 0) {
g_print ("Error while setting IOCTL\n");
if (errno == EINVAL)
g_print ("Invalid control\n");
return FALSE;
}
return TRUE;
}
#endif

@bmegli
Copy link
Collaborator Author

bmegli commented Mar 7, 2023

/**
* Control ID to enable maximum Performance.
*
* An integer value must be supplied with this control.
*
* @attention This control should be set after setting formats on both the planes
* and before requesting buffers on either plane.
*/
#define V4L2_CID_MPEG_VIDEO_MAX_PERFORMANCE (V4L2_CID_MPEG_BASE+554)

@bmegli
Copy link
Collaborator Author

bmegli commented Mar 7, 2023

@bmegli
Copy link
Collaborator Author

bmegli commented Mar 8, 2023

Conclusion

GStreamer maxperf-enable equivalent in Jetson Linux Multimedia API is encoder's:

Decoder's equivalent:

Some care has to be taken when it is called (see above docs)

@bmegli bmegli closed this as completed Mar 8, 2023
bmegli added a commit to Extend-Robotics/jetson-ffmpeg that referenced this issue Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant