aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-multimedia/gstreamer/gstreamer1.0-omx/0003-gstomxvideoenc-add-fix-timestamp-property.patch
blob: a7e9bdd15247566526c7ee5c94e6520c6c95f78a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
From e40121374266c6e72901ce77c09673fb28f78380 Mon Sep 17 00:00:00 2001
From: Arindam Nath <arindam.nath@amd.com>
Date: Fri, 31 Jul 2015 12:48:45 +0530
Subject: [PATCH 3/4] gstomxvideoenc: add fix-timestamp property

The property will force element to calculate the timestamp (dts and pts) based on duration.

Signed-off-by: Brijesh Singh <brijeshkumar.singh@amd.com>
Signed-off-by: Arindam Nath <arindam.nath@amd.com>
---
 omx/gstomxvideoenc.c | 20 +++++++++++++++++++-
 omx/gstomxvideoenc.h |  3 +++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
index c372a0d..bba349a 100644
--- a/omx/gstomxvideoenc.c
+++ b/omx/gstomxvideoenc.c
@@ -101,7 +101,8 @@ enum
   PROP_SCALING_HEIGHT,
   PROP_CAPTURE,
   PROP_POS_X,
-  PROP_POS_Y
+  PROP_POS_Y,
+  PROP_FIX_TIMESTAMP
 };
 
 /* FIXME: Better defaults */
@@ -115,6 +116,7 @@ enum
 #define GST_OMX_VIDEO_ENC_CAPTURE_DEFAULT (FALSE)
 #define GST_OMX_VIDEO_ENC_POS_X_DEFAULT (0)
 #define GST_OMX_VIDEO_ENC_POS_Y_DEFAULT (0)
+#define GST_OMX_VIDEO_ENC_FIX_TIMESTAMP_DEFAULT FALSE
 
 /* class initialization */
 
@@ -207,6 +209,11 @@ gst_omx_video_enc_class_init (GstOMXVideoEncClass * klass)
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
           GST_PARAM_MUTABLE_READY));
 
+  g_object_class_install_property (gobject_class, PROP_FIX_TIMESTAMP,
+      g_param_spec_boolean ("fix-timestamp", "Calculate timestamp",
+          "Calculate timestamp (dts/pts) based on duration",
+          0, G_PARAM_READWRITE));
+
   element_class->change_state =
       GST_DEBUG_FUNCPTR (gst_omx_video_enc_change_state);
 
@@ -246,6 +253,8 @@ gst_omx_video_enc_init (GstOMXVideoEnc * self)
   self->capture = GST_OMX_VIDEO_ENC_CAPTURE_DEFAULT;
   self->pos_x = GST_OMX_VIDEO_ENC_POS_X_DEFAULT;
   self->pos_y = GST_OMX_VIDEO_ENC_POS_Y_DEFAULT;
+  self->prev_timestamp = 0;
+  self->fix_timestamp = GST_OMX_VIDEO_ENC_FIX_TIMESTAMP_DEFAULT;
 
   g_mutex_init (&self->drain_lock);
   g_cond_init (&self->drain_cond);
@@ -623,6 +632,9 @@ gst_omx_video_enc_set_property (GObject * object, guint prop_id,
     case PROP_POS_Y:
       self->pos_y = g_value_get_uint (value);
       break;
+    case PROP_FIX_TIMESTAMP:
+      self->fix_timestamp = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -666,6 +678,9 @@ gst_omx_video_enc_get_property (GObject * object, guint prop_id, GValue * value,
     case PROP_POS_Y:
       g_value_set_uint (value, self->pos_y);
       break;
+    case PROP_FIX_TIMESTAMP:
+      g_value_set_boolean (value, self->fix_timestamp);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -998,6 +1013,9 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
   GST_VIDEO_ENCODER_STREAM_LOCK (self);
   frame = gst_omx_video_enc_find_nearest_frame (self, buf);
 
+  GST_INFO_OBJECT (self, "dts %" GST_TIME_FORMAT " pts %" GST_TIME_FORMAT,
+    GST_TIME_ARGS(frame->dts), GST_TIME_ARGS(frame->pts));
+
   g_assert (klass->handle_output_frame);
   flow_ret = klass->handle_output_frame (self, self->enc_out_port, buf, frame);
 
diff --git a/omx/gstomxvideoenc.h b/omx/gstomxvideoenc.h
index 3de563b..064583f 100644
--- a/omx/gstomxvideoenc.h
+++ b/omx/gstomxvideoenc.h
@@ -60,6 +60,7 @@ struct _GstOMXVideoEnc
   gboolean started;
 
   GstClockTime last_upstream_ts;
+  GstClockTime prev_timestamp;
 
   /* Draining state */
   GMutex drain_lock;
@@ -77,6 +78,8 @@ struct _GstOMXVideoEnc
   guint32 quant_p_frames;
   guint32 quant_b_frames;
 
+  gboolean fix_timestamp;
+
   guint32 scaling_width;
   guint32 scaling_height;
 
-- 
1.9.1