diff --git a/src/gstducatih264dec.c b/src/gstducatih264dec.c
index 6009c41404193649b66109cb67853551c4bb2825..e5eeba07a49321db6115cf3afd0cfa3bf9634c4e 100644 (file)
--- a/src/gstducatih264dec.c
+++ b/src/gstducatih264dec.c
"framerate = (fraction)[ 0, max ],"
"profile = (string) {high, high-10-intra, high-10, high-4:2:2-intra, "
"high-4:2:2, high-4:4:4-intra, high-4:4:4, cavlc-4:4:4-intra}, "
- "level = (string) {1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2, 5.1};")
+ "level = (string) {1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2};")
);
static const struct
if (ret) {
IH264VDEC_Params *params = (IH264VDEC_Params *) self->params;
+
self->params->displayDelay = IVIDDEC3_DECODE_ORDER;
params->maxNumRefFrames = IH264VDEC_NUM_REFFRAMES_AUTO;
params->pConstantMemory = 0;
latency = 0;
/* Take into account the backlog frames for reordering */
- latency *= (self->backlog_maxframes + 1);
+ latency *= (vdec->backlog_maxframes + 1);
if (min == GST_CLOCK_TIME_NONE)
min = latency;
static gboolean
gst_ducati_h264dec_set_sink_caps (GstDucatiVidDec * self, GstCaps * caps)
{
- GstDucatiH264Dec *h264dec = GST_DUCATIH264DEC (self);
GstStructure *structure;
GST_DEBUG_OBJECT (self, "set_sink_caps: %" GST_PTR_FORMAT, caps);
}
#endif
- h264dec->backlog_maxframes = -1;
+ self->backlog_maxframes = -1;
structure = gst_caps_get_structure (caps, 0);
if (structure) {
- gint num_ref_frames = -1;
+ gint num_ref_frames = -1, num_reorder_frames = -1;
+ const char *profile;
+
+ /* baseline profile does not use B frames (and I'll say constrained-baseline
+ is unlikely either from the name, it's not present in my H264 spec... */
+ profile = gst_structure_get_string (structure, "profile");
+ if (profile && (!strcmp (profile, "baseline")
+ || !strcmp (profile, "constrained-baseline"))) {
+ GST_DEBUG_OBJECT (self, "No need for reordering for %s profile", profile);
+ self->backlog_maxframes = 0;
+ goto no_b_frames;
+ }
+
+
if (gst_structure_get_int (structure, "num-ref-frames", &num_ref_frames)
&& num_ref_frames >= 0) {
- if (num_ref_frames > MAX_BACKLOG_FRAMES) {
- h264dec->backlog_maxframes = MAX_BACKLOG_FRAMES;
+ ((IH264VDEC_Params *) self->params)->maxNumRefFrames = num_ref_frames;
+ }
+ if (gst_structure_get_int (structure, "num-reorder-frames",
+ &num_reorder_frames)
+ && num_reorder_frames >= 0) {
+ if (num_reorder_frames > MAX_BACKLOG_FRAMES) {
+ self->backlog_maxframes = MAX_BACKLOG_FRAMES;
GST_WARNING_OBJECT (self,
"Stream needs %d frames for reordering, we can only accomodate %d",
- num_ref_frames, MAX_BACKLOG_FRAMES);
+ num_reorder_frames, MAX_BACKLOG_FRAMES);
} else {
- h264dec->backlog_maxframes = num_ref_frames;
+ self->backlog_maxframes = num_reorder_frames;
GST_INFO_OBJECT (self, "Num frames for reordering: %d",
- h264dec->backlog_maxframes);
+ self->backlog_maxframes);
}
}
}
/* If not present, use the spec forumula for a bound */
- if (h264dec->backlog_maxframes < 0) {
- h264dec->backlog_maxframes =
- gst_ducati_h264dec_get_max_dpb_size (self, caps);
+ if (self->backlog_maxframes < 0) {
+ self->backlog_maxframes = gst_ducati_h264dec_get_max_dpb_size (self, caps);
GST_WARNING_OBJECT (self,
- "num-ref-frames not found on caps, defaulting to %d",
- h264dec->backlog_maxframes);
- }
-
- return TRUE;
-}
-
-/* The following few functions reorder buffers by timestamp, on the
- assumption that buffers are properly timestamped by presentation
- time, but pushed in any (but presumably decode) order.
- They also assume all incoming buffers have a valid timestamp.
- */
-
-static GstFlowReturn
-gst_ducati_h264dec_push_earliest (GstDucatiH264Dec * self)
-{
- GstClockTime earliest_ts = GST_CLOCK_TIME_NONE;
- guint earliest_index = 0, i;
- GstBuffer *buf;
-
- if (self->backlog_nframes == 0)
- return GST_FLOW_OK;
-
- /* work out which frame has the earliest ts */
- for (i = 0; i < self->backlog_nframes; i++) {
- GstClockTime ts = GST_BUFFER_TIMESTAMP (self->backlog_frames[i]);
- if (earliest_ts == GST_CLOCK_TIME_NONE || ts < earliest_ts) {
- earliest_ts = ts;
- earliest_index = i;
- }
+ "num-reorder-frames not found on caps, defaulting to %d",
+ self->backlog_maxframes);
}
- /* send it, giving away the ref */
- buf = self->backlog_frames[earliest_index];
- self->backlog_frames[earliest_index] =
- self->backlog_frames[--self->backlog_nframes];
- GST_DEBUG_OBJECT (self, "Actually pushing backlog buffer %" GST_PTR_FORMAT,
- buf);
- return gst_pad_push (GST_DUCATIVIDDEC (self)->srcpad, buf);
-}
-
-static GstFlowReturn
-gst_ducati_h264dec_push_output (GstDucatiVidDec * self, GstBuffer * buf)
-{
- GstDucatiH264Dec *h264dec = GST_DUCATIH264DEC (self);
- GstFlowReturn ret = GST_FLOW_OK;
-
- /* add the frame to the list, the array will own the ref */
- GST_DEBUG_OBJECT (self, "Adding buffer %" GST_PTR_FORMAT " to backlog", buf);
- h264dec->backlog_frames[h264dec->backlog_nframes++] = buf;
+no_b_frames:
- /* push till we have no more than the max needed, or error */
- while (h264dec->backlog_nframes > h264dec->backlog_maxframes) {
- ret = gst_ducati_h264dec_push_earliest (h264dec);
- if (ret != GST_FLOW_OK)
- break;
- }
-
- return ret;
-}
-
-static void
-gst_ducati_h264dec_on_flush (GstDucatiVidDec * self, gboolean eos)
-{
- GstDucatiH264Dec *h264dec = GST_DUCATIH264DEC (self);
-
- /* push everything on the backlog, ignoring errors */
- while (h264dec->backlog_nframes > 0) {
- gst_ducati_h264dec_push_earliest (h264dec);
- }
+ return TRUE;
}
/* GObject vmethod implementations */
bclass->can_drop_frame =
GST_DEBUG_FUNCPTR (gst_ducati_h264dec_can_drop_frame);
bclass->query = GST_DEBUG_FUNCPTR (gst_ducati_h264dec_query);
- bclass->push_output = GST_DEBUG_FUNCPTR (gst_ducati_h264dec_push_output);
- bclass->on_flush = GST_DEBUG_FUNCPTR (gst_ducati_h264dec_on_flush);
bclass->set_sink_caps = GST_DEBUG_FUNCPTR (gst_ducati_h264dec_set_sink_caps);
}
gst_ducati_h264dec_init (GstDucatiH264Dec * self,
GstDucatiH264DecClass * gclass)
{
- self->backlog_maxframes = 0;
- self->backlog_nframes = 0;
}