From d4cd668b89982dacc2493bf73cf4882bc1989e4e Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 2 Apr 2026 11:51:53 +0800 Subject: [PATCH] (gstreamer) update rochip gstreamer, fix record error --- .../gst/rkximage/gstkmsallocator.c | 5 +- .../gst/rkximage/gstkmsallocator.h | 5 +- .../gst/rkximage/gstkmsbufferpool.c | 5 +- .../gst/rkximage/gstkmsbufferpool.h | 5 +- .../gst/rkximage/gstkmsutils.c | 5 +- .../gst/rkximage/gstkmsutils.h | 5 +- .../gst/rkximage/ximagesink.c | 149 +++++++++++------- .../gst/rkximage/ximagesink.h | 26 ++- .../gst/rockchipmpp/gstmpp.c | 30 ++-- .../gst/rockchipmpp/gstmpp.h | 2 +- .../gst/rockchipmpp/gstmppallocator.c | 4 +- .../gst/rockchipmpp/gstmppalphadecodebin.c | 8 +- .../gst/rockchipmpp/gstmppdec.c | 99 +++++++++--- .../gst/rockchipmpp/gstmppdec.h | 5 + .../gst/rockchipmpp/gstmppenc.c | 93 ++++++++--- .../gst/rockchipmpp/gstmppenc.h | 5 +- .../gst/rockchipmpp/gstmpph264enc.c | 4 +- .../gst/rockchipmpp/gstmpph265enc.c | 4 +- .../gst/rockchipmpp/gstmppjpegdec.c | 9 +- .../gst/rockchipmpp/gstmppjpegenc.c | 8 +- 20 files changed, 321 insertions(+), 155 deletions(-) mode change 100644 => 100755 external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.h mode change 100644 => 100755 external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.h mode change 100644 => 100755 external/gstreamer-rockchip/gst/rkximage/gstkmsutils.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rkximage/gstkmsutils.h mode change 100644 => 100755 external/gstreamer-rockchip/gst/rkximage/ximagesink.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rkximage/ximagesink.h mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.h mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmppallocator.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmppalphadecodebin.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.h mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.h mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmpph264enc.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmpph265enc.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegdec.c mode change 100644 => 100755 external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegenc.c diff --git a/external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.c b/external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.c old mode 100644 new mode 100755 index e8484dcc37..16b286f2ad --- a/external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.c +++ b/external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.c @@ -1,10 +1,9 @@ /* GStreamer * * Copyright (C) 2016 Igalia + * Copyright (C) <2024> Rockchip Electronics Co., Ltd * - * Authors: - * Víctor Manuel Jáquez Leal - * Javier Martin + * Based on kmssink * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.h b/external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.h old mode 100644 new mode 100755 index 9d001266ba..eca49bf3f1 --- a/external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.h +++ b/external/gstreamer-rockchip/gst/rkximage/gstkmsallocator.h @@ -1,10 +1,9 @@ /* GStreamer * * Copyright (C) 2016 Igalia + * Copyright (C) <2024> Rockchip Electronics Co., Ltd * - * Authors: - * Víctor Manuel Jáquez Leal - * Javier Martin + * Based on kmssink * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.c b/external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.c old mode 100644 new mode 100755 index 7c02aa21f6..15db7b2f9d --- a/external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.c +++ b/external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.c @@ -1,10 +1,9 @@ /* * GStreamer * Copyright (C) 2016 Igalia + * Copyright (C) <2024> Rockchip Electronics Co., Ltd * - * Authors: - * Víctor Manuel Jáquez Leal - * Javier Martin + * Based on kmssink * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.h b/external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.h old mode 100644 new mode 100755 index 9e2d95b564..82c902c694 --- a/external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.h +++ b/external/gstreamer-rockchip/gst/rkximage/gstkmsbufferpool.h @@ -1,10 +1,9 @@ /* * GStreamer * Copyright (C) 2016 Igalia + * Copyright (C) <2024> Rockchip Electronics Co., Ltd * - * Authors: - * Víctor Manuel Jáquez Leal - * Javier Martin + * Based on kmssink * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.c b/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.c old mode 100644 new mode 100755 index f09bbbef2c..ec644db7fb --- a/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.c +++ b/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.c @@ -1,10 +1,9 @@ /* GStreamer * * Copyright (C) 2016 Igalia + * Copyright (C) <2024> Rockchip Electronics Co., Ltd * - * Authors: - * Víctor Manuel Jáquez Leal - * Javier Martin + * Based on kmssink * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.h b/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.h old mode 100644 new mode 100755 index 500405a1d9..5ad9fd0721 --- a/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.h +++ b/external/gstreamer-rockchip/gst/rkximage/gstkmsutils.h @@ -1,10 +1,9 @@ /* GStreamer * * Copyright (C) 2016 Igalia + * Copyright (C) <2024> Rockchip Electronics Co., Ltd * - * Authors: - * Víctor Manuel Jáquez Leal - * Javier Martin + * Based on kmssink * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/external/gstreamer-rockchip/gst/rkximage/ximagesink.c b/external/gstreamer-rockchip/gst/rkximage/ximagesink.c old mode 100644 new mode 100755 index b3f05b8199..cecff3f79b --- a/external/gstreamer-rockchip/gst/rkximage/ximagesink.c +++ b/external/gstreamer-rockchip/gst/rkximage/ximagesink.c @@ -1,3 +1,27 @@ +/* GStreamer + * + * Copyright (C) 2016 Igalia + * Copyright (C) <2005> Julien Moutte + * Copyright ({) <2024> Rockchip Electronics Co., Ltd + * + * Based on kmssink and ximagesink + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -217,6 +241,9 @@ drm_connector_is_used (int fd, drmModeRes * res, drmModeConnector * conn) gboolean result; drmModeCrtc *crtc; + if (conn->connection != DRM_MODE_CONNECTED) + return FALSE; + result = FALSE; crtc = drm_find_crtc_for_connector (fd, res, conn, NULL); if (crtc) { @@ -987,31 +1014,29 @@ gst_kms_sink_query (GstBaseSink * bsink, GstQuery * query) return GST_BASE_SINK_CLASS (parent_class)->query (bsink, query); } -/*ximagesink*/ static gboolean -xwindow_calculate_display_ratio (GstRkXImageSink * self, int *x, int *y, - gint * window_width, gint * window_height) +gst_kms_sink_calculate_display_ratio (GstRkXImageSink * self, + GstVideoInfo * vinfo, gint * scaled_width, gint * scaled_height) { guint dar_n, dar_d; + guint video_width, video_height; guint video_par_n, video_par_d; guint dpy_par_n, dpy_par_d; - gint video_width, video_height; - - video_width = GST_VIDEO_INFO_WIDTH (&self->vinfo); - video_height = GST_VIDEO_INFO_HEIGHT (&self->vinfo); - video_par_n = self->par_n; - video_par_d = self->par_d; + video_width = GST_VIDEO_INFO_WIDTH (vinfo); + video_height = GST_VIDEO_INFO_HEIGHT (vinfo); + video_par_n = GST_VIDEO_INFO_PAR_N (vinfo); + video_par_d = GST_VIDEO_INFO_PAR_D (vinfo); if (self->keep_aspect) { - *window_width = video_width; - *window_height = video_height; + gst_video_calculate_device_ratio (self->hdisplay, self->vdisplay, + self->mm_width, self->mm_height, &dpy_par_n, &dpy_par_d); + } else { + *scaled_width = video_width; + *scaled_height = video_height; goto out; } - gst_video_calculate_device_ratio (self->hdisplay, self->vdisplay, - self->mm_width, self->mm_height, &dpy_par_n, &dpy_par_d); - if (!gst_video_calculate_display_ratio (&dar_n, &dar_d, video_width, video_height, video_par_n, video_par_d, dpy_par_n, dpy_par_d)) return FALSE; @@ -1025,20 +1050,25 @@ xwindow_calculate_display_ratio (GstRkXImageSink * self, int *x, int *y, /* start with same height, because of interlaced video */ /* check hd / dar_d is an integer scale factor, and scale wd with the PAR */ - video_width = gst_util_uint64_scale_int (self->xwindow->height, dar_n, dar_d); - video_height = gst_util_uint64_scale_int (self->xwindow->width, dar_d, dar_n); - if (video_width < *window_width) { - *x += (self->xwindow->width - video_width) / 2; - *window_width = video_width; - *window_height = self->xwindow->height; + if (video_height % dar_d == 0) { + GST_DEBUG_OBJECT (self, "keeping video height"); + *scaled_width = (guint) + gst_util_uint64_scale_int (video_height, dar_n, dar_d); + *scaled_height = video_height; + } else if (video_width % dar_n == 0) { + GST_DEBUG_OBJECT (self, "keeping video width"); + *scaled_width = video_width; + *scaled_height = (guint) + gst_util_uint64_scale_int (video_width, dar_d, dar_n); } else { - *y += (self->xwindow->height - video_height) / 2; - *window_height = video_height; - *window_width = self->xwindow->width; + GST_DEBUG_OBJECT (self, "approximating while keeping video height"); + *scaled_width = (guint) + gst_util_uint64_scale_int (video_height, dar_n, dar_d); + *scaled_height = video_height; } out: - GST_DEBUG_OBJECT (self, "scaling to %dx%d", *window_width, *window_height); + GST_DEBUG_OBJECT (self, "scaling to %dx%d", *scaled_width, *scaled_height); return TRUE; } @@ -1074,18 +1104,6 @@ xwindow_get_window_position (GstRkXImageSink * ximagesink, int *x, int *y) return FALSE; } -static void -xwindow_get_render_rectangle (GstRkXImageSink * ximagesink, - gint * x, gint * y, gint * width, gint * height) -{ - if (ximagesink->save_rect.w != 0 && ximagesink->save_rect.h != 0) { - *width = ximagesink->save_rect.w; - *height = ximagesink->save_rect.h; - *x += ximagesink->save_rect.x; - *y += ximagesink->save_rect.y; - } -} - static void gst_x_image_sink_xwindow_fill_key (GstRkXImageSink * ximagesink, GstXWindow * xwindow, guint32 color) @@ -1139,7 +1157,10 @@ gst_x_image_sink_ximage_put (GstRkXImageSink * ximagesink, GstBuffer * buf) { GstVideoCropMeta *crop; GstVideoRectangle src = { 0, }; - GstVideoRectangle result = { 0, }; + gint video_width, video_height; + GstVideoRectangle dst = { 0, }; + GstVideoRectangle result; + gint window_x, window_y; GstBuffer *buffer = NULL; gboolean draw_border = FALSE; gboolean res = FALSE; @@ -1189,8 +1210,28 @@ gst_x_image_sink_ximage_put (GstRkXImageSink * ximagesink, GstBuffer * buf) src.w = GST_VIDEO_SINK_WIDTH (ximagesink); src.h = GST_VIDEO_SINK_HEIGHT (ximagesink); } - result.w = ximagesink->xwindow->width; - result.h = ximagesink->xwindow->height; + + video_width = src.w; + video_height = src.h; + + gst_kms_sink_calculate_display_ratio (ximagesink, &ximagesink->vinfo, + &src.w, &src.h); + + dst.w = ximagesink->render_rect.w; + dst.h = ximagesink->render_rect.h; + if (!dst.w || !dst.h) { + dst.w = ximagesink->xwindow->width; + dst.h = ximagesink->xwindow->height; + } + + gst_video_sink_center_rect (src, dst, &result, TRUE); + + result.x += ximagesink->render_rect.x; + result.y += ximagesink->render_rect.y; + + /* Restore the real source size */ + src.w = video_width; + src.h = video_height; g_mutex_lock (&ximagesink->x_lock); @@ -1211,12 +1252,9 @@ gst_x_image_sink_ximage_put (GstRkXImageSink * ximagesink, GstBuffer * buf) ximagesink->draw_border = FALSE; } - xwindow_get_window_position (ximagesink, &result.x, &result.y); - - xwindow_get_render_rectangle (ximagesink, &result.x, &result.y, &result.w, - &result.h); - xwindow_calculate_display_ratio (ximagesink, &result.x, &result.y, &result.w, - &result.h); + xwindow_get_window_position (ximagesink, &window_x, &window_y); + result.x += window_x; + result.y += window_y; if (GST_VIDEO_INFO_IS_AFBC (&ximagesink->vinfo)) /* The AFBC's width should align to 4 */ @@ -1247,7 +1285,6 @@ gst_x_image_sink_ximage_put (GstRkXImageSink * ximagesink, GstBuffer * buf) goto out; } - /* HACK: Disable vsync might cause tearing */ if (!g_getenv ("KMSSINK_DISABLE_VSYNC")) /* Wait for the previous frame to complete redraw */ @@ -1937,8 +1974,6 @@ gst_x_image_sink_setcaps (GstBaseSink * bsink, GstCaps * caps) GST_VIDEO_SINK_HEIGHT (ximagesink) = info.height; ximagesink->fps_n = info.fps_n; ximagesink->fps_d = info.fps_d; - ximagesink->par_n = info.par_n; - ximagesink->par_d = info.par_d; /* Notify application to set xwindow id now */ g_mutex_lock (&ximagesink->flow_lock); @@ -2319,13 +2354,11 @@ gst_x_image_sink_set_render_rectangle (GstVideoOverlay * overlay, gint x, gint y, gint width, gint height) { GstRkXImageSink *ximagesink = GST_X_IMAGE_SINK (overlay); - GST_DEBUG_OBJECT (ximagesink, "Set Render Rectangle" - "x %d y %d width %d height %d", x, y, width, height); - ximagesink->save_rect.w = width; - ximagesink->save_rect.h = height; - ximagesink->save_rect.x = x; - ximagesink->save_rect.y = y; + ximagesink->render_rect.x = x; + ximagesink->render_rect.y = y; + ximagesink->render_rect.w = width; + ximagesink->render_rect.h = height; gst_x_image_sink_expose (GST_VIDEO_OVERLAY (ximagesink)); } @@ -2543,10 +2576,10 @@ gst_x_image_sink_init (GstRkXImageSink * ximagesink) ximagesink->poll = gst_poll_new (TRUE); gst_video_info_init (&ximagesink->vinfo); - ximagesink->save_rect.x = 0; - ximagesink->save_rect.y = 0; - ximagesink->save_rect.w = 0; - ximagesink->save_rect.h = 0; + ximagesink->render_rect.x = 0; + ximagesink->render_rect.y = 0; + ximagesink->render_rect.w = 0; + ximagesink->render_rect.h = 0; ximagesink->paused = FALSE; diff --git a/external/gstreamer-rockchip/gst/rkximage/ximagesink.h b/external/gstreamer-rockchip/gst/rkximage/ximagesink.h old mode 100644 new mode 100755 index e446d4262c..1c06e164d4 --- a/external/gstreamer-rockchip/gst/rkximage/ximagesink.h +++ b/external/gstreamer-rockchip/gst/rkximage/ximagesink.h @@ -1,3 +1,27 @@ +/* GStreamer + * + * Copyright (C) 2016 Igalia + * Copyright (C) <2005> Julien Moutte + * Copyright (C) <2024> Rockchip Electronics Co., Ltd + * + * Based on kmssink and ximagesink + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + #ifndef __GST_X_IMAGE_SINK_H__ #define __GST_X_IMAGE_SINK_H__ @@ -184,7 +208,7 @@ struct _GstRkXImageSink GstPollFD pollfd; guint32 last_fb_id; - GstVideoRectangle save_rect; + GstVideoRectangle render_rect; gboolean paused; }; diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.c old mode 100644 new mode 100755 index 808e695629..188af1e96c --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.c @@ -450,32 +450,30 @@ gst_mpp_video_info_matched (GstVideoInfo * info, GstVideoInfo * other) } gboolean -gst_mpp_info_changed (GstVideoInfo * info, MppFrame * mframe) +gst_mpp_frame_info_changed (MppFrame * frame, MppFrame * other) { - MppFrameFormat mpp_format = mpp_frame_get_fmt (mframe); - gint width = mpp_frame_get_width (mframe); - gint height = mpp_frame_get_height (mframe); - gint hstride = mpp_frame_get_hor_stride (mframe); - gint vstride = mpp_frame_get_ver_stride (mframe); - GstVideoFormat format = gst_mpp_mpp_format_to_gst_format (mpp_format); - gboolean afbc = !!MPP_FRAME_FMT_IS_FBC (mpp_format); - - if (GST_VIDEO_INFO_FORMAT (info) != format) + if (!frame || !other) return TRUE; - if (GST_VIDEO_INFO_WIDTH (info) != width) + if (mpp_frame_get_fmt (frame) != mpp_frame_get_fmt (other)) return TRUE; - if (GST_VIDEO_INFO_HEIGHT (info) != height) + if (mpp_frame_get_width (frame) != mpp_frame_get_width (other)) return TRUE; - if (GST_MPP_VIDEO_INFO_HSTRIDE (info) != hstride) + if (mpp_frame_get_height (frame) != mpp_frame_get_height (other)) return TRUE; - if (GST_VIDEO_INFO_N_PLANES (info) == 1 || afbc) - return FALSE; + if (mpp_frame_get_offset_x (frame) != mpp_frame_get_offset_x (other)) + return TRUE; + + if (mpp_frame_get_offset_y (frame) != mpp_frame_get_offset_y (other)) + return TRUE; + + if (mpp_frame_get_hor_stride (frame) != mpp_frame_get_hor_stride (other)) + return TRUE; - if (GST_MPP_VIDEO_INFO_VSTRIDE (info) != vstride) + if (mpp_frame_get_ver_stride (frame) != mpp_frame_get_ver_stride (other)) return TRUE; return FALSE; diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.h b/external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.h old mode 100644 new mode 100755 index dac2daf9f9..8cab019f3f --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.h +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmpp.h @@ -97,7 +97,7 @@ gboolean gst_mpp_video_info_align (GstVideoInfo * info, gboolean gst_mpp_video_info_matched (GstVideoInfo * info, GstVideoInfo * other); -gboolean gst_mpp_info_changed (GstVideoInfo * info, MppFrame * mframe); +gboolean gst_mpp_frame_info_changed (MppFrame * frame, MppFrame * other); guint gst_mpp_get_pixel_stride (GstVideoInfo * info); diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppallocator.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppallocator.c old mode 100644 new mode 100755 index 4ceb4a42a4..b254859419 --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppallocator.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppallocator.c @@ -244,7 +244,9 @@ gst_mpp_allocator_alloc (GstAllocator * allocator, gsize size, mem = gst_mpp_allocator_import_mppbuf (allocator, mbuf); mpp_buffer_put (mbuf); - gst_memory_resize (mem, 0, size); + if (mem) + gst_memory_resize (mem, 0, size); + return mem; } diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppalphadecodebin.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppalphadecodebin.c old mode 100644 new mode 100755 index fca8e16ae9..6471c5c65b --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppalphadecodebin.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppalphadecodebin.c @@ -170,10 +170,10 @@ gst_mpp_alpha_decode_bin_constructed (GObject * obj) gst_ghost_pad_set_target (GST_GHOST_PAD (src_gpad), src_pad); gst_object_unref (src_pad); - g_object_set (queue, "max-size-bytes", 0, "max-size-time", 0, - "max-size-buffers", 1, NULL); - g_object_set (alpha_queue, "max-size-bytes", 0, "max-size-time", 0, - "max-size-buffers", 1, NULL); + g_object_set (queue, "max-size-bytes", 0, "max-size-time", + G_GUINT64_CONSTANT (0), "max-size-buffers", 1, NULL); + g_object_set (alpha_queue, "max-size-bytes", 0, "max-size-time", + G_GUINT64_CONSTANT (0), "max-size-buffers", 1, NULL); /* signal success, we will handle this in NULL->READY transition */ priv->constructed = TRUE; diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.c old mode 100644 new mode 100755 index 177202aa6f..4f5e447149 --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.c @@ -255,6 +255,7 @@ gst_mpp_dec_start (GstVideoDecoder * decoder) self->mpp_type = MPP_VIDEO_CodingUnused; self->seen_valid_pts = FALSE; self->convert = FALSE; + self->mpp_frame = NULL; self->input_state = NULL; @@ -305,8 +306,18 @@ gst_mpp_dec_stop (GstVideoDecoder * decoder) gst_mpp_dec_clear_allocator (decoder); + if (self->mpp_frame) { + mpp_frame_deinit (&self->mpp_frame); + self->mpp_frame = NULL; + } + mpp_destroy (self->mpp_ctx); + if (self->last_frame) { + gst_video_codec_frame_unref (self->last_frame); + self->last_frame = NULL; + } + GST_DEBUG_OBJECT (self, "stopped"); return TRUE; @@ -534,17 +545,45 @@ gst_mpp_dec_apply_info_change (GstVideoDecoder * decoder, MppFrame mframe) } if (afbc) { - /* HACK: MPP would align width to 64 for AFBC */ + /* HACK: Fake 64-aligned width for Mali DDK + * + * When importing AFBC dma-bufs, mali would re-calculate the row stride + * from width by itself. But the row stride aligning algorithms are + * different between MPP and Mali: + * + * MPP uses round_up_64(round_up_64(width) * bpp / 8) + * Mali uses round_up_64(width * bpp / 8) + * + * We need Mali to use the same row stride as MPP, so we fake a 64-aligned + * width here and crop to the real size later. + */ dst_width = GST_ROUND_UP_64 (dst_width); - /* HACK: MPP might have extra offsets for AFBC */ - dst_height += offset_y; + /* HACK: Fake hstride for Rockchip DRM driver + * + * When importing AFBC dma-bufs, the Rockchip DRM driver would calculate + * the pixel stride from pitch. But the pitch aligning algorithms are + * different between MPP and the driver: + * + * MPP uses round_up_64(round_up_64(width) * bpp / 8) + * Rockchip DRM driver expects (pixel_stride * bpp / 8) + * + * We need the driver to use the same pixel stride as MPP, so we + * re-calculate a fake hstride from the pixel stride (i.e. the 64-aligned + * fake width) here. + * + * NOTE: The hstride is not used by others for now. + */ + hstride = 0; + /* HACK: Fixup height and vstride with MPP's extra Y offsets + * + * The MPP might have extra rows for AFBC dma-bufs, and those rows are not + * counted in the height and vstride. + */ + dst_height += offset_y; if (vstride < dst_height) vstride = dst_height; - - /* HACK: Fake hstride for Rockchip VOP driver */ - hstride = 0; } if (!gst_mpp_dec_update_video_info (decoder, dst_format, @@ -697,6 +736,18 @@ gst_mpp_dec_get_frame (GstVideoDecoder * decoder, GstClockTime pts) frame->system_frame_number); out: + if (frame) { + if (self->last_frame) + gst_video_codec_frame_unref (self->last_frame); + + gst_video_codec_frame_ref (frame); + self->last_frame = frame; + } else if (self->last_frame) { + frame = self->last_frame; + GST_DEBUG_OBJECT (self, "reusing the last frame (#%d)", + frame->system_frame_number); + } + if (frame) { gst_video_codec_frame_ref (frame); @@ -908,16 +959,18 @@ gst_mpp_dec_loop (GstVideoDecoder * decoder) if (mpp_frame_get_discard (mframe) || mpp_frame_get_errinfo (mframe)) goto error; - if (!self->convert && gst_mpp_info_changed (&self->info, mframe)) { + if (!self->convert && gst_mpp_frame_info_changed (self->mpp_frame, mframe)) { self->task_ret = gst_mpp_dec_apply_info_change (decoder, mframe); if (self->task_ret != GST_FLOW_OK) goto info_change; } + /* Get gst buffer (might be converted) */ buffer = gst_mpp_dec_get_gst_buffer (decoder, mframe); if (!buffer) goto error; + /* Truncate MPP's extra data */ gst_buffer_resize (buffer, 0, GST_VIDEO_INFO_SIZE (&self->info)); mode = mpp_frame_get_mode (mframe); @@ -932,7 +985,8 @@ gst_mpp_dec_loop (GstVideoDecoder * decoder) /* HACK: Mark lockable to avoid copying in make_writable() while shared */ GST_MINI_OBJECT_FLAG_SET (buffer, GST_MINI_OBJECT_FLAG_LOCKABLE); - frame->output_buffer = buffer; + gst_buffer_replace (&frame->output_buffer, buffer); + gst_buffer_unref (buffer); GST_DEBUG_OBJECT (self, "finish frame ts=%" GST_TIME_FORMAT, GST_TIME_ARGS (frame->pts)); @@ -940,12 +994,19 @@ gst_mpp_dec_loop (GstVideoDecoder * decoder) gst_video_decoder_finish_frame (decoder, frame); out: - if (mpp_frame_get_eos (mframe)) { - GST_INFO_OBJECT (self, "got eos"); - self->task_ret = GST_FLOW_EOS; - } + if (mframe) { + if (mpp_frame_get_eos (mframe)) { + GST_INFO_OBJECT (self, "got eos"); + self->task_ret = GST_FLOW_EOS; + } - mpp_frame_deinit (&mframe); + if (self->mpp_frame) + mpp_frame_deinit (&self->mpp_frame); + + /* Save the last MPP frame for info change detection */ + mpp_frame_set_buffer (mframe, NULL); + self->mpp_frame = mframe; + } if (self->task_ret != GST_FLOW_OK) { GST_DEBUG_OBJECT (self, "leaving output thread: %s", @@ -1025,17 +1086,17 @@ gst_mpp_dec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame) start_time = gst_util_get_timestamp (); deadline_time = start_time + MPP_INPUT_TIMEOUT_MS * GST_MSECOND; + GST_VIDEO_DECODER_STREAM_UNLOCK (decoder); while (1) { - GST_VIDEO_DECODER_STREAM_UNLOCK (decoder); - if (klass->send_mpp_packet (decoder, mpkt, interval_ms)) { - GST_VIDEO_DECODER_STREAM_LOCK (decoder); + if (klass->send_mpp_packet (decoder, mpkt, interval_ms)) break; - } - GST_VIDEO_DECODER_STREAM_LOCK (decoder); - if (gst_util_get_timestamp () > deadline_time) + if (gst_util_get_timestamp () > deadline_time) { + GST_VIDEO_DECODER_STREAM_LOCK (decoder); goto send_error; + } } + GST_VIDEO_DECODER_STREAM_LOCK (decoder); /* NOTE: Sub-class takes over the MPP packet when success */ mpkt = NULL; diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.h b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.h old mode 100644 new mode 100755 index f5c1e8bb66..1ca2a973c7 --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.h +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppdec.h @@ -47,6 +47,9 @@ struct _GstMppDec /* final output video info */ GstVideoInfo info; + /* decoded MPP frame info */ + MppFrame mpp_frame; + /* specified output format */ GstVideoFormat format; @@ -85,6 +88,8 @@ struct _GstMppDec guint32 decoded_frames; + GstVideoCodecFrame *last_frame; + MppCodingType mpp_type; MppCtx mpp_ctx; MppApi *mpi; diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.c old mode 100644 new mode 100755 index 2a952ecd30..697395052e --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.c @@ -37,8 +37,6 @@ GST_DEBUG_CATEGORY (GST_CAT_DEFAULT); #define parent_class gst_mpp_enc_parent_class G_DEFINE_ABSTRACT_TYPE (GstMppEnc, gst_mpp_enc, GST_TYPE_VIDEO_ENCODER); -#define MPP_PENDING_MAX 16 /* Max number of MPP pending frame */ - #define GST_MPP_ENC_TASK_STARTED(encoder) \ (gst_pad_get_task_state ((encoder)->srcpad) == GST_TASK_STARTED) @@ -83,11 +81,15 @@ G_DEFINE_ABSTRACT_TYPE (GstMppEnc, gst_mpp_enc, GST_TYPE_VIDEO_ENCODER); /* Input isn't ARM AFBC by default */ static GstVideoFormat DEFAULT_PROP_ARM_AFBC = FALSE; +#define MPP_MAX_PENDING 16 /* Max number of MPP pending frames */ +static guint32 DEFAULT_PROP_MAX_PENDING = MPP_MAX_PENDING; + #define DEFAULT_FPS 30 enum { PROP_0, + PROP_MAX_PENDING, PROP_HEADER_MODE, PROP_RC_MODE, PROP_ROTATION, @@ -113,6 +115,8 @@ static const MppFrameFormat gst_mpp_enc_formats[] = { MPP_FMT_YUV444P, MPP_FMT_RGB565LE, MPP_FMT_BGR565LE, + MPP_FMT_RGB888, + MPP_FMT_BGR888, MPP_FMT_ARGB8888, MPP_FMT_ABGR8888, MPP_FMT_RGBA8888, @@ -170,6 +174,11 @@ gst_mpp_enc_set_property (GObject * object, GstMppEnc *self = GST_MPP_ENC (encoder); switch (prop_id) { + case PROP_MAX_PENDING:{ + self->max_pending = g_value_get_uint (value); + GST_MPP_ENC_BROADCAST (encoder); + return; + } case PROP_HEADER_MODE:{ MppEncHeaderMode header_mode = g_value_get_enum (value); if (self->header_mode == header_mode) @@ -282,6 +291,9 @@ gst_mpp_enc_get_property (GObject * object, GstMppEnc *self = GST_MPP_ENC (encoder); switch (prop_id) { + case PROP_MAX_PENDING: + g_value_set_uint (value, self->max_pending); + break; case PROP_HEADER_MODE: g_value_set_enum (value, self->header_mode); break; @@ -332,9 +344,7 @@ gst_mpp_enc_apply_properties (GstVideoEncoder * encoder) { GstMppEnc *self = GST_MPP_ENC (encoder); GstVideoInfo *info = &self->info; - gint fps_num = GST_VIDEO_INFO_FPS_N (info); - gint fps_denorm = GST_VIDEO_INFO_FPS_D (info); - gint fps = fps_num / fps_denorm; + gint fps = GST_VIDEO_INFO_FPS_N (info) / GST_VIDEO_INFO_FPS_D (info); if (!self->prop_dirty) return TRUE; @@ -449,7 +459,10 @@ gst_mpp_enc_reset (GstVideoEncoder * encoder, gboolean drain, gboolean final) self->flushing = TRUE; self->draining = drain; - gst_mpp_enc_stop_task (encoder, drain); + /* HACK: The MPP is not capable of handling resets properly. */ + self->draining = TRUE; + + gst_mpp_enc_stop_task (encoder, self->draining); self->flushing = final; self->draining = FALSE; @@ -473,7 +486,7 @@ static gboolean gst_mpp_enc_start (GstVideoEncoder * encoder) { GstMppEnc *self = GST_MPP_ENC (encoder); - MppPollType timeout = MPP_POLL_NON_BLOCK; + MppPollType timeout; GST_DEBUG_OBJECT (self, "starting"); @@ -488,9 +501,12 @@ gst_mpp_enc_start (GstVideoEncoder * encoder) if (mpp_create (&self->mpp_ctx, &self->mpi)) goto err_unref_alloc; + timeout = MPP_POLL_NON_BLOCK; if (self->mpi->control (self->mpp_ctx, MPP_SET_INPUT_TIMEOUT, &timeout)) goto err_destroy_mpp; + /* 1ms timeout for polling */ + timeout = 1; if (self->mpi->control (self->mpp_ctx, MPP_SET_OUTPUT_TIMEOUT, &timeout)) goto err_destroy_mpp; @@ -686,10 +702,12 @@ gst_mpp_enc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state) mpp_frame_set_width (self->mpp_frame, width); mpp_frame_set_height (self->mpp_frame, height); - if (!GST_VIDEO_INFO_FPS_N (info) || GST_VIDEO_INFO_FPS_N (info) > 240) { + if (!GST_VIDEO_INFO_FPS_N (info) || + GST_VIDEO_INFO_FPS_N (info) / GST_VIDEO_INFO_FPS_D (info) > 256) { GST_WARNING_OBJECT (self, "framerate (%d/%d) is insane!", GST_VIDEO_INFO_FPS_N (info), GST_VIDEO_INFO_FPS_D (info)); GST_VIDEO_INFO_FPS_N (info) = DEFAULT_FPS; + GST_VIDEO_INFO_FPS_D (info) = 1; } mpp_enc_cfg_set_s32 (self->mpp_cfg, "prep:format", format); @@ -761,7 +779,7 @@ gst_mpp_enc_propose_allocation (GstVideoEncoder * encoder, GstQuery * query) gst_buffer_pool_set_config (pool, config); - gst_query_add_allocation_pool (query, pool, size, MPP_PENDING_MAX, 0); + gst_query_add_allocation_pool (query, pool, size, 0, 0); gst_query_add_allocation_param (query, self->allocator, NULL); gst_object_unref (pool); @@ -820,10 +838,17 @@ gst_mpp_enc_convert (GstVideoEncoder * encoder, GstVideoCodecFrame * frame) src_hstride = GST_MPP_VIDEO_INFO_HSTRIDE (&src_info); src_vstride = GST_MPP_VIDEO_INFO_VSTRIDE (&src_info); + /** + * Update the strides of the dst video info temporarily to test if we + * can use the src buffer directly. + */ if (!gst_mpp_video_info_align (&dst_info, src_hstride, src_vstride) || !gst_mpp_enc_video_info_align (&dst_info) || - !gst_mpp_video_info_matched (&src_info, &dst_info)) + !gst_mpp_video_info_matched (&src_info, &dst_info)) { + /* Reset the temporarily modified dst video info. */ + dst_info = self->info; goto convert; + } gst_mpp_enc_apply_strides (encoder, src_hstride, src_vstride); if (!gst_mpp_enc_apply_properties (encoder)) @@ -863,11 +888,14 @@ convert: if (gst_video_frame_map (&src_frame, &src_info, inbuf, GST_MAP_READ)) { if (gst_video_frame_map (&dst_frame, &dst_info, outbuf, GST_MAP_WRITE)) { + GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder); if (!gst_video_frame_copy (&dst_frame, &src_frame)) { + GST_VIDEO_ENCODER_STREAM_LOCK (encoder); gst_video_frame_unmap (&dst_frame); gst_video_frame_unmap (&src_frame); goto err; } + GST_VIDEO_ENCODER_STREAM_LOCK (encoder); gst_video_frame_unmap (&dst_frame); } gst_video_frame_unmap (&src_frame); @@ -879,7 +907,6 @@ out: gst_buffer_copy_into (outbuf, inbuf, GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, 0); - dst_info = self->info; gst_buffer_add_video_meta_full (outbuf, GST_VIDEO_FRAME_FLAG_NONE, GST_VIDEO_INFO_FORMAT (&dst_info), GST_VIDEO_INFO_WIDTH (&dst_info), GST_VIDEO_INFO_HEIGHT (&dst_info), @@ -960,14 +987,14 @@ gst_mpp_enc_send_frame_locked (GstVideoEncoder * encoder) gst_video_codec_frame_unref (frame); - if (!self->mpi->encode_put_frame (self->mpp_ctx, mframe)) { - GST_DEBUG_OBJECT (self, "encoding frame %d", frame_number); - self->frames = g_list_delete_link (self->frames, self->frames); - return TRUE; + if (self->mpi->encode_put_frame (self->mpp_ctx, mframe)) { + mpp_frame_deinit (&mframe); + return FALSE; } - mpp_frame_deinit (mframe); - return FALSE; + GST_DEBUG_OBJECT (self, "encoding frame %d", frame_number); + self->frames = g_list_delete_link (self->frames, self->frames); + return TRUE; } static gboolean @@ -990,7 +1017,7 @@ gst_mpp_enc_poll_packet_locked (GstVideoEncoder * encoder) /* Deinit input frame */ meta = mpp_packet_get_meta (mpkt); if (!mpp_meta_get_frame (meta, KEY_INPUT_FRAME, &mframe)) - mpp_frame_deinit (mframe); + mpp_frame_deinit (&mframe); /* Wake up the frame producer */ self->pending_frames--; @@ -1075,7 +1102,7 @@ gst_mpp_enc_loop (GstVideoEncoder * encoder) /* Try sending ready frames to MPP (non-block) */ while (gst_mpp_enc_send_frame_locked (encoder)); - /* Try polling encoded packets from MPP (non-block) */ + /* Try polling encoded packets from MPP (1ms timeout) */ while (gst_mpp_enc_poll_packet_locked (encoder)); out: @@ -1110,9 +1137,7 @@ gst_mpp_enc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame) (GstTaskFunction) gst_mpp_enc_loop, encoder, NULL); } - GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder); buffer = gst_mpp_enc_convert (encoder, frame); - GST_VIDEO_ENCODER_STREAM_LOCK (encoder); if (G_UNLIKELY (!buffer)) goto not_negotiated; @@ -1120,10 +1145,12 @@ gst_mpp_enc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame) frame->output_buffer = buffer; /* Avoid holding too much frames */ - GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder); - GST_MPP_ENC_WAIT (encoder, self->pending_frames < MPP_PENDING_MAX - || self->flushing); - GST_VIDEO_ENCODER_STREAM_LOCK (encoder); + if (G_UNLIKELY (self->pending_frames >= self->max_pending)) { + GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder); + GST_MPP_ENC_WAIT (encoder, self->pending_frames < self->max_pending + || self->flushing); + GST_VIDEO_ENCODER_STREAM_LOCK (encoder); + } if (G_UNLIKELY (self->flushing)) goto flushing; @@ -1177,6 +1204,8 @@ gst_mpp_enc_init (GstMppEnc * self) { self->mpp_type = MPP_VIDEO_CodingUnused; + self->max_pending = DEFAULT_PROP_MAX_PENDING; + self->header_mode = DEFAULT_PROP_HEADER_MODE; self->sei_mode = DEFAULT_PROP_SEI_MODE; self->rc_mode = DEFAULT_PROP_RC_MODE; @@ -1272,6 +1301,7 @@ gst_mpp_enc_class_init (GstMppEncClass * klass) GstVideoEncoderClass *encoder_class = GST_VIDEO_ENCODER_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + const gchar *env; GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "mppenc", 0, "MPP encoder"); @@ -1287,6 +1317,16 @@ gst_mpp_enc_class_init (GstMppEncClass * klass) gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_mpp_enc_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_mpp_enc_get_property); + env = g_getenv ("GST_MPP_ENC_MAX_PENDING"); + if (env) + DEFAULT_PROP_MAX_PENDING = MAX (MIN (atoi (env), MPP_MAX_PENDING), 1); + + g_object_class_install_property (gobject_class, PROP_MAX_PENDING, + g_param_spec_uint ("max-pending", "Max pending frames", + "Max pending frames", + 1, MPP_MAX_PENDING, DEFAULT_PROP_MAX_PENDING, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_HEADER_MODE, g_param_spec_enum ("header-mode", "Header mode", "Header mode", @@ -1365,7 +1405,8 @@ no_rga: "Zero-copy encoded packet", DEFAULT_PROP_ZERO_COPY_PKT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - if (g_getenv ("GST_MPPENC_DEFAULT_ARM_AFBC")) + env = g_getenv ("GST_MPP_ENC_DEFAULT_ARM_AFBC"); + if (env && env[0] == '1') DEFAULT_PROP_ARM_AFBC = TRUE; g_object_class_install_property (gobject_class, PROP_ARM_AFBC, diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.h b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.h old mode 100644 new mode 100755 index 1d39f48159..ad8d228062 --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.h +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.h @@ -57,6 +57,9 @@ struct _GstMppEnc /* frame system numbers that are ready for sending to MPP */ GList *frames; + /* Max number of pending frames */ + guint32 max_pending; + guint32 required_keyframe_number; guint pending_frames; @@ -97,7 +100,7 @@ struct _GstMppEnc #define MPP_ENC_IN_FORMATS \ "NV12, I420, YUY2, UYVY, " \ - "BGR16, RGB16, " \ + "BGR16, RGB16, BGR, RGB, " \ "ABGR, ARGB, BGRA, RGBA, xBGR, xRGB, BGRx, RGBx" #ifdef HAVE_RGA diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmpph264enc.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmpph264enc.c old mode 100644 new mode 100755 index 6149c7a267..07b19d30a1 --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmpph264enc.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmpph264enc.c @@ -441,12 +441,12 @@ gst_mpp_h264_enc_class_init (GstMppH264EncClass * klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_QP_MIN_I, - g_param_spec_int ("qp-min-i", "Min Intra QP", + g_param_spec_uint ("qp-min-i", "Min Intra QP", "Min Intra QP (0 = default)", 0, 51, DEFAULT_PROP_QP_MIN_I, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_QP_MAX_I, - g_param_spec_int ("qp-max-i", "Max Intra QP", + g_param_spec_uint ("qp-max-i", "Max Intra QP", "Max Intra QP (0 = default)", 0, 51, DEFAULT_PROP_QP_MAX_I, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmpph265enc.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmpph265enc.c old mode 100644 new mode 100755 index e2b01b21ea..7e59eba37d --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmpph265enc.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmpph265enc.c @@ -316,12 +316,12 @@ gst_mpp_h265_enc_class_init (GstMppH265EncClass * klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_QP_MIN_I, - g_param_spec_int ("qp-min-i", "Min Intra QP", + g_param_spec_uint ("qp-min-i", "Min Intra QP", "Min Intra QP (0 = default)", 0, 51, DEFAULT_PROP_QP_MIN_I, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_QP_MAX_I, - g_param_spec_int ("qp-max-i", "Max Intra QP", + g_param_spec_uint ("qp-max-i", "Max Intra QP", "Max Intra QP (0 = default)", 0, 51, DEFAULT_PROP_QP_MAX_I, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegdec.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegdec.c old mode 100644 new mode 100755 index f2b6235cf8..089a233945 --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegdec.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegdec.c @@ -238,8 +238,13 @@ gst_mpp_jpeg_dec_set_format (GstVideoDecoder * decoder, guint align = GST_MPP_ALIGNMENT; if (!width || !height) { - GST_ERROR_OBJECT (self, "invalid input video info"); - return FALSE; + if (self->buf_size) { + GST_ERROR_OBJECT (self, "ignore invalid input video info"); + return TRUE; + } else { + GST_ERROR_OBJECT (self, "invalid input video info"); + return FALSE; + } } if (!pclass->set_format (decoder, state)) diff --git a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegenc.c b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegenc.c old mode 100644 new mode 100755 index ce4b5c1d97..fef801207d --- a/external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegenc.c +++ b/external/gstreamer-rockchip/gst/rockchipmpp/gstmppjpegenc.c @@ -80,7 +80,7 @@ GST_STATIC_PAD_TEMPLATE ("sink", GST_MPP_JPEG_ENC_SIZE_CAPS)); static void -gst_mpp_h264_enc_set_property (GObject * object, +gst_mpp_jpeg_enc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstVideoEncoder *encoder = GST_VIDEO_ENCODER (object); @@ -121,7 +121,7 @@ gst_mpp_h264_enc_set_property (GObject * object, } static void -gst_mpp_h264_enc_get_property (GObject * object, +gst_mpp_jpeg_enc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { GstVideoEncoder *encoder = GST_VIDEO_ENCODER (object); @@ -215,9 +215,9 @@ gst_mpp_jpeg_enc_class_init (GstMppJpegEncClass * klass) GST_DEBUG_FUNCPTR (gst_mpp_jpeg_enc_handle_frame); gobject_class->set_property = - GST_DEBUG_FUNCPTR (gst_mpp_h264_enc_set_property); + GST_DEBUG_FUNCPTR (gst_mpp_jpeg_enc_set_property); gobject_class->get_property = - GST_DEBUG_FUNCPTR (gst_mpp_h264_enc_get_property); + GST_DEBUG_FUNCPTR (gst_mpp_jpeg_enc_get_property); g_object_class_install_property (gobject_class, PROP_Q_FACTOR, g_param_spec_uint ("q-factor", "Quality Factor", -- 2.25.1