gst-decoder.c: minor cleanup
Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
Carlos Rafael Giani authored 7 years ago
Rob Clark committed 7 years ago
41 | 41 | GST_DEBUG_CATEGORY_EXTERN(kmscube_debug); |
42 | 42 | #define GST_CAT_DEFAULT kmscube_debug |
43 | 43 | |
44 | #define MAX_NUM_PLANES 3 | |
45 | ||
44 | 46 | struct decoder { |
45 | 47 | GMainLoop *loop; |
46 | 48 | GstElement *pipeline; |
82 | 84 | return GST_PAD_PROBE_OK; |
83 | 85 | } |
84 | 86 | |
85 | switch (dec->info.finfo->format) { | |
87 | switch (GST_VIDEO_INFO_FORMAT(&(dec->info))) { | |
86 | 88 | case GST_VIDEO_FORMAT_I420: |
87 | 89 | dec->format = DRM_FORMAT_YUV420; |
88 | 90 | break; |
263 | 265 | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, |
264 | 266 | pad_probe, dec, NULL); |
265 | 267 | |
266 | /* hack to make sure we get dmabuf's from v4l2video0dec.. */ | |
268 | /* callback needed to make sure we get dmabuf's from v4l2videoNdec.. */ | |
267 | 269 | decodebin = gst_bin_get_by_name(GST_BIN(dec->pipeline), "decode"); |
268 | 270 | g_signal_connect(decodebin, "element-added", G_CALLBACK(element_added_cb), dec); |
269 | 271 | |
321 | 323 | static EGLImage |
322 | 324 | buffer_to_image(struct decoder *dec, GstBuffer *buf) |
323 | 325 | { |
324 | struct { int fd, offset, stride; } planes[3]; | |
326 | struct { int fd, offset, stride; } planes[MAX_NUM_PLANES]; | |
325 | 327 | GstVideoMeta *meta = gst_buffer_get_video_meta(buf); |
326 | 328 | EGLImage image; |
327 | 329 | unsigned nmems = gst_buffer_n_memory(buf); |
411 | 413 | EGL_LINUX_DMA_BUF_EXT, NULL, attr); |
412 | 414 | } |
413 | 415 | |
416 | /* Cleanup */ | |
414 | 417 | for (unsigned i = 0; i < nmems; i++) |
415 | 418 | close(planes[i].fd); |
416 | 419 | |
425 | 428 | EGLImage frame = NULL; |
426 | 429 | |
427 | 430 | samp = gst_app_sink_pull_sample(GST_APP_SINK(dec->sink)); |
428 | if (!samp) | |
431 | if (!samp) { | |
432 | GST_DEBUG("got no appsink sample"); | |
429 | 433 | return NULL; |
434 | } | |
430 | 435 | |
431 | 436 | buf = gst_sample_get_buffer(samp); |
432 | 437 |