1 /* GStreamer NVENC plugin
2  * Copyright (C) 2015 Centricular Ltd
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include "gstnvh264enc.h"
25 
26 #include <gst/pbutils/codec-utils.h>
27 
28 #include <string.h>
29 
30 GST_DEBUG_CATEGORY_STATIC (gst_nv_h264_enc_debug);
31 #define GST_CAT_DEFAULT gst_nv_h264_enc_debug
32 
33 #if HAVE_NVENC_GST_GL
34 #include <cuda.h>
35 #include <cuda_runtime_api.h>
36 #include <cuda_gl_interop.h>
37 #include <gst/gl/gl.h>
38 #endif
39 
40 #define parent_class gst_nv_h264_enc_parent_class
41 G_DEFINE_TYPE (GstNvH264Enc, gst_nv_h264_enc, GST_TYPE_NV_BASE_ENC);
42 
43 #if HAVE_NVENC_GST_GL
44 #define GL_CAPS_STR \
45   ";" \
46   "video/x-raw(memory:GLMemory), " \
47   "format = (string) { NV12, Y444 }, " \
48   "width = (int) [ 16, 4096 ], height = (int) [ 16, 4096 ], " \
49   "framerate = (fraction) [0, MAX]," \
50   "interlace-mode = { progressive, mixed, interleaved } "
51 #else
52 #define GL_CAPS_STR ""
53 #endif
54 
55 /* *INDENT-OFF* */
56 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
57     GST_PAD_SINK,
58     GST_PAD_ALWAYS,
59     GST_STATIC_CAPS ("video/x-raw, " "format = (string) { NV12, I420 }, "       // TODO: YV12, Y444 support
60         "width = (int) [ 16, 4096 ], height = (int) [ 16, 4096 ], "
61         "framerate = (fraction) [0, MAX],"
62         "interlace-mode = { progressive, mixed, interleaved } "
63         GL_CAPS_STR
64     ));
65 
66 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
67     GST_PAD_SRC,
68     GST_PAD_ALWAYS,
69     GST_STATIC_CAPS ("video/x-h264, "
70         "width = (int) [ 1, 4096 ], height = (int) [ 1, 4096 ], "
71         "framerate = (fraction) [0/1, MAX], "
72         "stream-format = (string) byte-stream, " // TODO: avc support
73         "alignment = (string) au, "
74         "profile = (string) { high, main, baseline }") // TODO: a couple of others
75     );
76 /* *INDENT-ON* */
77 
78 static gboolean gst_nv_h264_enc_open (GstVideoEncoder * enc);
79 static gboolean gst_nv_h264_enc_close (GstVideoEncoder * enc);
80 static GstCaps *gst_nv_h264_enc_getcaps (GstVideoEncoder * enc,
81     GstCaps * filter);
82 static gboolean gst_nv_h264_enc_set_src_caps (GstNvBaseEnc * nvenc,
83     GstVideoCodecState * state);
84 static gboolean gst_nv_h264_enc_set_encoder_config (GstNvBaseEnc * nvenc,
85     GstVideoCodecState * state, NV_ENC_CONFIG * config);
86 static gboolean gst_nv_h264_enc_set_pic_params (GstNvBaseEnc * nvenc,
87     GstVideoCodecFrame * frame, NV_ENC_PIC_PARAMS * pic_params);
88 static void gst_nv_h264_enc_set_property (GObject * object, guint prop_id,
89     const GValue * value, GParamSpec * pspec);
90 static void gst_nv_h264_enc_get_property (GObject * object, guint prop_id,
91     GValue * value, GParamSpec * pspec);
92 static void gst_nv_h264_enc_finalize (GObject * obj);
93 
94 static void
gst_nv_h264_enc_class_init(GstNvH264EncClass * klass)95 gst_nv_h264_enc_class_init (GstNvH264EncClass * klass)
96 {
97   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
98   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
99   GstVideoEncoderClass *videoenc_class = GST_VIDEO_ENCODER_CLASS (klass);
100   GstNvBaseEncClass *nvenc_class = GST_NV_BASE_ENC_CLASS (klass);
101 
102   gobject_class->set_property = gst_nv_h264_enc_set_property;
103   gobject_class->get_property = gst_nv_h264_enc_get_property;
104   gobject_class->finalize = gst_nv_h264_enc_finalize;
105 
106   videoenc_class->open = GST_DEBUG_FUNCPTR (gst_nv_h264_enc_open);
107   videoenc_class->close = GST_DEBUG_FUNCPTR (gst_nv_h264_enc_close);
108 
109   videoenc_class->getcaps = GST_DEBUG_FUNCPTR (gst_nv_h264_enc_getcaps);
110 
111   nvenc_class->codec_id = NV_ENC_CODEC_H264_GUID;
112   nvenc_class->set_encoder_config = gst_nv_h264_enc_set_encoder_config;
113   nvenc_class->set_src_caps = gst_nv_h264_enc_set_src_caps;
114   nvenc_class->set_pic_params = gst_nv_h264_enc_set_pic_params;
115 
116   gst_element_class_add_static_pad_template (element_class, &sink_factory);
117   gst_element_class_add_static_pad_template (element_class, &src_factory);
118 
119   gst_element_class_set_static_metadata (element_class,
120       "NVENC H.264 Video Encoder",
121       "Codec/Encoder/Video/Hardware",
122       "Encode H.264 video streams using NVIDIA's hardware-accelerated NVENC encoder API",
123       "Tim-Philipp Müller <tim@centricular.com>\n"
124       "Matthew Waters <matthew@centricular.com>");
125 
126   GST_DEBUG_CATEGORY_INIT (gst_nv_h264_enc_debug,
127       "nvh264enc", 0, "Nvidia H.264 encoder");
128 }
129 
130 static void
gst_nv_h264_enc_init(GstNvH264Enc * nvenc)131 gst_nv_h264_enc_init (GstNvH264Enc * nvenc)
132 {
133 }
134 
135 static void
gst_nv_h264_enc_finalize(GObject * obj)136 gst_nv_h264_enc_finalize (GObject * obj)
137 {
138   G_OBJECT_CLASS (gst_nv_h264_enc_parent_class)->finalize (obj);
139 }
140 
141 static gboolean
_get_supported_profiles(GstNvH264Enc * nvenc)142 _get_supported_profiles (GstNvH264Enc * nvenc)
143 {
144   NVENCSTATUS nv_ret;
145   GUID profile_guids[64];
146   GValue list = G_VALUE_INIT;
147   GValue val = G_VALUE_INIT;
148   guint i, n, n_profiles;
149 
150   if (nvenc->supported_profiles)
151     return TRUE;
152 
153   nv_ret =
154       NvEncGetEncodeProfileGUIDCount (GST_NV_BASE_ENC (nvenc)->encoder,
155       NV_ENC_CODEC_H264_GUID, &n);
156   if (nv_ret != NV_ENC_SUCCESS)
157     return FALSE;
158 
159   nv_ret =
160       NvEncGetEncodeProfileGUIDs (GST_NV_BASE_ENC (nvenc)->encoder,
161       NV_ENC_CODEC_H264_GUID, profile_guids, G_N_ELEMENTS (profile_guids), &n);
162   if (nv_ret != NV_ENC_SUCCESS)
163     return FALSE;
164 
165   n_profiles = 0;
166   g_value_init (&list, GST_TYPE_LIST);
167   for (i = 0; i < n; i++) {
168     g_value_init (&val, G_TYPE_STRING);
169 
170     if (gst_nvenc_cmp_guid (profile_guids[i],
171             NV_ENC_H264_PROFILE_BASELINE_GUID)) {
172       g_value_set_static_string (&val, "baseline");
173       gst_value_list_append_value (&list, &val);
174       n_profiles++;
175     } else if (gst_nvenc_cmp_guid (profile_guids[i],
176             NV_ENC_H264_PROFILE_MAIN_GUID)) {
177       g_value_set_static_string (&val, "main");
178       gst_value_list_append_value (&list, &val);
179       n_profiles++;
180     } else if (gst_nvenc_cmp_guid (profile_guids[i],
181             NV_ENC_H264_PROFILE_HIGH_GUID)) {
182       g_value_set_static_string (&val, "high");
183       gst_value_list_append_value (&list, &val);
184       n_profiles++;
185     }
186     /* TODO: map HIGH_444, STEREO, CONSTRAINED_HIGH, SVC_TEMPORAL_SCALABILITY */
187 
188     g_value_unset (&val);
189   }
190 
191   if (n_profiles == 0)
192     return FALSE;
193 
194   GST_OBJECT_LOCK (nvenc);
195   nvenc->supported_profiles = g_new0 (GValue, 1);
196   *nvenc->supported_profiles = list;
197   GST_OBJECT_UNLOCK (nvenc);
198 
199   return TRUE;
200 }
201 
202 static gboolean
gst_nv_h264_enc_open(GstVideoEncoder * enc)203 gst_nv_h264_enc_open (GstVideoEncoder * enc)
204 {
205   GstNvH264Enc *nvenc = GST_NV_H264_ENC (enc);
206 
207   if (!GST_VIDEO_ENCODER_CLASS (gst_nv_h264_enc_parent_class)->open (enc))
208     return FALSE;
209 
210   /* Check if H.264 is supported */
211   {
212     uint32_t i, num = 0;
213     GUID guids[16];
214 
215     NvEncGetEncodeGUIDs (GST_NV_BASE_ENC (nvenc)->encoder, guids,
216         G_N_ELEMENTS (guids), &num);
217 
218     for (i = 0; i < num; ++i) {
219       if (gst_nvenc_cmp_guid (guids[i], NV_ENC_CODEC_H264_GUID))
220         break;
221     }
222     GST_INFO_OBJECT (enc, "H.264 encoding %ssupported", (i == num) ? "un" : "");
223     if (i == num) {
224       gst_nv_h264_enc_close (enc);
225       return FALSE;
226     }
227   }
228 
229   /* query supported input formats */
230   if (!_get_supported_profiles (nvenc)) {
231     GST_WARNING_OBJECT (nvenc, "No supported encoding profiles");
232     gst_nv_h264_enc_close (enc);
233     return FALSE;
234   }
235 
236   return TRUE;
237 }
238 
239 static gboolean
gst_nv_h264_enc_close(GstVideoEncoder * enc)240 gst_nv_h264_enc_close (GstVideoEncoder * enc)
241 {
242   GstNvH264Enc *nvenc = GST_NV_H264_ENC (enc);
243 
244   GST_OBJECT_LOCK (nvenc);
245   if (nvenc->supported_profiles)
246     g_value_unset (nvenc->supported_profiles);
247   g_free (nvenc->supported_profiles);
248   nvenc->supported_profiles = NULL;
249   GST_OBJECT_UNLOCK (nvenc);
250 
251   return GST_VIDEO_ENCODER_CLASS (gst_nv_h264_enc_parent_class)->close (enc);
252 }
253 
254 static GValue *
_get_interlace_modes(GstNvH264Enc * nvenc)255 _get_interlace_modes (GstNvH264Enc * nvenc)
256 {
257   NV_ENC_CAPS_PARAM caps_param = { 0, };
258   GValue *list = g_new0 (GValue, 1);
259   GValue val = G_VALUE_INIT;
260 
261   g_value_init (list, GST_TYPE_LIST);
262   g_value_init (&val, G_TYPE_STRING);
263 
264   g_value_set_static_string (&val, "progressive");
265   gst_value_list_append_value (list, &val);
266 
267   caps_param.version = NV_ENC_CAPS_PARAM_VER;
268   caps_param.capsToQuery = NV_ENC_CAPS_SUPPORT_FIELD_ENCODING;
269 
270   if (NvEncGetEncodeCaps (GST_NV_BASE_ENC (nvenc)->encoder,
271           NV_ENC_CODEC_H264_GUID, &caps_param,
272           &nvenc->interlace_modes) != NV_ENC_SUCCESS)
273     nvenc->interlace_modes = 0;
274 
275   if (nvenc->interlace_modes >= 1) {
276     g_value_set_static_string (&val, "interleaved");
277     gst_value_list_append_value (list, &val);
278     g_value_set_static_string (&val, "mixed");
279     gst_value_list_append_value (list, &val);
280     g_value_unset (&val);
281   }
282   /* TODO: figure out what nvenc frame based interlacing means in gst terms */
283 
284   return list;
285 }
286 
287 static GstCaps *
gst_nv_h264_enc_getcaps(GstVideoEncoder * enc,GstCaps * filter)288 gst_nv_h264_enc_getcaps (GstVideoEncoder * enc, GstCaps * filter)
289 {
290   GstNvH264Enc *nvenc = GST_NV_H264_ENC (enc);
291   GstCaps *supported_incaps = NULL;
292   GstCaps *template_caps, *caps;
293   GValue *input_formats = GST_NV_BASE_ENC (enc)->input_formats;
294 
295   GST_OBJECT_LOCK (nvenc);
296 
297   if (input_formats != NULL) {
298     GValue *val;
299 
300     template_caps = gst_pad_get_pad_template_caps (enc->sinkpad);
301     supported_incaps = gst_caps_copy (template_caps);
302     gst_caps_set_value (supported_incaps, "format", input_formats);
303 
304     val = _get_interlace_modes (nvenc);
305     gst_caps_set_value (supported_incaps, "interlace-mode", val);
306     g_value_unset (val);
307     g_free (val);
308 
309     GST_LOG_OBJECT (enc, "codec input caps %" GST_PTR_FORMAT, supported_incaps);
310     GST_LOG_OBJECT (enc, "   template caps %" GST_PTR_FORMAT, template_caps);
311     caps = gst_caps_intersect (template_caps, supported_incaps);
312     gst_caps_unref (template_caps);
313     gst_caps_unref (supported_incaps);
314     supported_incaps = caps;
315     GST_LOG_OBJECT (enc, "  supported caps %" GST_PTR_FORMAT, supported_incaps);
316   }
317 
318   GST_OBJECT_UNLOCK (nvenc);
319 
320   caps = gst_video_encoder_proxy_getcaps (enc, supported_incaps, filter);
321 
322   if (supported_incaps)
323     gst_caps_unref (supported_incaps);
324 
325   GST_DEBUG_OBJECT (nvenc, "  returning caps %" GST_PTR_FORMAT, caps);
326 
327   return caps;
328 }
329 
330 static gboolean
gst_nv_h264_enc_set_profile_and_level(GstNvH264Enc * nvenc,GstCaps * caps)331 gst_nv_h264_enc_set_profile_and_level (GstNvH264Enc * nvenc, GstCaps * caps)
332 {
333 #define N_BYTES_SPS 128
334   guint8 sps[N_BYTES_SPS];
335   NV_ENC_SEQUENCE_PARAM_PAYLOAD spp = { 0, };
336   GstStructure *s;
337   const gchar *profile;
338   GstCaps *allowed_caps;
339   GstStructure *s2;
340   const gchar *allowed_profile;
341   NVENCSTATUS nv_ret;
342   guint32 seq_size;
343 
344   spp.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER;
345   spp.inBufferSize = N_BYTES_SPS;
346   spp.spsId = 0;
347   spp.ppsId = 0;
348   spp.spsppsBuffer = &sps;
349   spp.outSPSPPSPayloadSize = &seq_size;
350   nv_ret = NvEncGetSequenceParams (GST_NV_BASE_ENC (nvenc)->encoder, &spp);
351   if (nv_ret != NV_ENC_SUCCESS) {
352     GST_ELEMENT_ERROR (nvenc, STREAM, ENCODE, ("Encode header failed."),
353         ("NvEncGetSequenceParams return code=%d", nv_ret));
354     return FALSE;
355   }
356 
357   if (seq_size < 8) {
358     GST_ELEMENT_ERROR (nvenc, STREAM, ENCODE, ("Encode header failed."),
359         ("NvEncGetSequenceParams returned incomplete data"));
360     return FALSE;
361   }
362 
363   /* skip nal header and identifier */
364   gst_codec_utils_h264_caps_set_level_and_profile (caps, &sps[5], 3);
365 
366   /* Constrained baseline is a strict subset of baseline. If downstream
367    * wanted baseline and we produced constrained baseline, we can just
368    * set the profile to baseline in the caps to make negotiation happy.
369    * Same goes for baseline as subset of main profile and main as a subset
370    * of high profile.
371    */
372   s = gst_caps_get_structure (caps, 0);
373   profile = gst_structure_get_string (s, "profile");
374 
375   allowed_caps = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (nvenc));
376 
377   if (allowed_caps == NULL)
378     goto no_peer;
379 
380   if (!gst_caps_can_intersect (allowed_caps, caps)) {
381     allowed_caps = gst_caps_make_writable (allowed_caps);
382     allowed_caps = gst_caps_truncate (allowed_caps);
383     s2 = gst_caps_get_structure (allowed_caps, 0);
384     gst_structure_fixate_field_string (s2, "profile", profile);
385     allowed_profile = gst_structure_get_string (s2, "profile");
386     if (!strcmp (allowed_profile, "high")) {
387       if (!strcmp (profile, "constrained-baseline")
388           || !strcmp (profile, "baseline") || !strcmp (profile, "main")) {
389         gst_structure_set (s, "profile", G_TYPE_STRING, "high", NULL);
390         GST_INFO_OBJECT (nvenc, "downstream requested high profile, but "
391             "encoder will now output %s profile (which is a subset), due "
392             "to how it's been configured", profile);
393       }
394     } else if (!strcmp (allowed_profile, "main")) {
395       if (!strcmp (profile, "constrained-baseline")
396           || !strcmp (profile, "baseline")) {
397         gst_structure_set (s, "profile", G_TYPE_STRING, "main", NULL);
398         GST_INFO_OBJECT (nvenc, "downstream requested main profile, but "
399             "encoder will now output %s profile (which is a subset), due "
400             "to how it's been configured", profile);
401       }
402     } else if (!strcmp (allowed_profile, "baseline")) {
403       if (!strcmp (profile, "constrained-baseline"))
404         gst_structure_set (s, "profile", G_TYPE_STRING, "baseline", NULL);
405     }
406   }
407   gst_caps_unref (allowed_caps);
408 
409 no_peer:
410 
411   return TRUE;
412 
413 #undef N_BYTES_SPS
414 }
415 
416 static gboolean
gst_nv_h264_enc_set_src_caps(GstNvBaseEnc * nvenc,GstVideoCodecState * state)417 gst_nv_h264_enc_set_src_caps (GstNvBaseEnc * nvenc, GstVideoCodecState * state)
418 {
419   GstNvH264Enc *h264enc = GST_NV_H264_ENC (nvenc);
420   GstVideoCodecState *out_state;
421   GstStructure *s;
422   GstCaps *out_caps;
423 
424   out_caps = gst_caps_new_empty_simple ("video/x-h264");
425   s = gst_caps_get_structure (out_caps, 0);
426 
427   /* TODO: add support for avc format as well */
428   gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream",
429       "alignment", G_TYPE_STRING, "au", NULL);
430 
431   if (!gst_nv_h264_enc_set_profile_and_level (h264enc, out_caps)) {
432     gst_caps_unref (out_caps);
433     return FALSE;
434   }
435 
436   out_state = gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (nvenc),
437       out_caps, state);
438 
439   GST_INFO_OBJECT (nvenc, "output caps: %" GST_PTR_FORMAT, out_state->caps);
440 
441   /* encoder will keep it around for us */
442   gst_video_codec_state_unref (out_state);
443 
444   /* TODO: would be nice to also send some tags with the codec name */
445   return TRUE;
446 }
447 
448 static gboolean
gst_nv_h264_enc_set_encoder_config(GstNvBaseEnc * nvenc,GstVideoCodecState * state,NV_ENC_CONFIG * config)449 gst_nv_h264_enc_set_encoder_config (GstNvBaseEnc * nvenc,
450     GstVideoCodecState * state, NV_ENC_CONFIG * config)
451 {
452   GstNvH264Enc *h264enc = GST_NV_H264_ENC (nvenc);
453   GstCaps *allowed_caps, *template_caps;
454   GUID selected_profile = NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID;
455   int level_idc = NV_ENC_LEVEL_AUTOSELECT;
456   GstVideoInfo *info = &state->info;
457 
458   template_caps = gst_static_pad_template_get_caps (&src_factory);
459   allowed_caps = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (h264enc));
460 
461   if (template_caps == allowed_caps) {
462     GST_INFO_OBJECT (h264enc, "downstream has ANY caps");
463   } else if (allowed_caps) {
464     GstStructure *s;
465     const gchar *profile;
466     const gchar *level;
467 
468     if (gst_caps_is_empty (allowed_caps)) {
469       gst_caps_unref (allowed_caps);
470       gst_caps_unref (template_caps);
471       return FALSE;
472     }
473 
474     allowed_caps = gst_caps_make_writable (allowed_caps);
475     allowed_caps = gst_caps_fixate (allowed_caps);
476     s = gst_caps_get_structure (allowed_caps, 0);
477 
478     profile = gst_structure_get_string (s, "profile");
479     if (profile) {
480       if (!strcmp (profile, "baseline")) {
481         selected_profile = NV_ENC_H264_PROFILE_BASELINE_GUID;
482       } else if (g_str_has_prefix (profile, "high-4:4:4")) {
483         selected_profile = NV_ENC_H264_PROFILE_HIGH_444_GUID;
484       } else if (g_str_has_prefix (profile, "high-10")) {
485         g_assert_not_reached ();
486       } else if (g_str_has_prefix (profile, "high-4:2:2")) {
487         g_assert_not_reached ();
488       } else if (g_str_has_prefix (profile, "high")) {
489         selected_profile = NV_ENC_H264_PROFILE_HIGH_GUID;
490       } else if (g_str_has_prefix (profile, "main")) {
491         selected_profile = NV_ENC_H264_PROFILE_MAIN_GUID;
492       } else {
493         g_assert_not_reached ();
494       }
495     }
496 
497     level = gst_structure_get_string (s, "level");
498     if (level)
499       /* matches values stored in NV_ENC_LEVEL */
500       level_idc = gst_codec_utils_h264_get_level_idc (level);
501 
502     gst_caps_unref (allowed_caps);
503   }
504   gst_caps_unref (template_caps);
505 
506   /* override some defaults */
507   GST_LOG_OBJECT (h264enc, "setting parameters");
508   config->profileGUID = selected_profile;
509   config->encodeCodecConfig.h264Config.level = level_idc;
510   config->encodeCodecConfig.h264Config.chromaFormatIDC = 1;
511   if (GST_VIDEO_INFO_FORMAT (info) == GST_VIDEO_FORMAT_Y444) {
512     GST_DEBUG_OBJECT (h264enc, "have Y444 input, setting config accordingly");
513     config->encodeCodecConfig.h264Config.separateColourPlaneFlag = 1;
514     config->encodeCodecConfig.h264Config.chromaFormatIDC = 3;
515   }
516 
517   config->encodeCodecConfig.h264Config.idrPeriod = config->gopLength;
518 
519   /* FIXME: make property */
520   config->encodeCodecConfig.h264Config.outputAUD = 1;
521 
522   return TRUE;
523 }
524 
525 static gboolean
gst_nv_h264_enc_set_pic_params(GstNvBaseEnc * enc,GstVideoCodecFrame * frame,NV_ENC_PIC_PARAMS * pic_params)526 gst_nv_h264_enc_set_pic_params (GstNvBaseEnc * enc, GstVideoCodecFrame * frame,
527     NV_ENC_PIC_PARAMS * pic_params)
528 {
529   /* encode whole picture in one single slice */
530   pic_params->codecPicParams.h264PicParams.sliceMode = 0;
531   pic_params->codecPicParams.h264PicParams.sliceModeData = 0;
532 
533   return TRUE;
534 }
535 
536 static void
gst_nv_h264_enc_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)537 gst_nv_h264_enc_set_property (GObject * object, guint prop_id,
538     const GValue * value, GParamSpec * pspec)
539 {
540   switch (prop_id) {
541     default:
542       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
543       break;
544   }
545 }
546 
547 static void
gst_nv_h264_enc_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)548 gst_nv_h264_enc_get_property (GObject * object, guint prop_id, GValue * value,
549     GParamSpec * pspec)
550 {
551   switch (prop_id) {
552     default:
553       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
554       break;
555   }
556 }
557