diff options
author | Edward Hervey <edward@collabora.com> | 2012-11-11 14:06:04 +0100 |
---|---|---|
committer | Edward Hervey <edward@collabora.com> | 2013-03-31 12:44:18 +0200 |
commit | f3d0de8376640c71da79dae4be154c0b0daa1ac9 (patch) | |
tree | 6fa98c9596583970cc2ab445e7229459b69ef2c2 | |
parent | 6d6dcf2e3b4438b759028d487455b22ea80e727c (diff) |
!!PENDING VDPAU H264 WORKvdpau
Attempt to find a potentially better API for codecparsers lib
-rw-r--r-- | gst-libs/gst/codecparsers/gsth264meta.c | 22 | ||||
-rw-r--r-- | gst-libs/gst/codecparsers/gsth264meta.h | 22 | ||||
-rw-r--r-- | gst/videoparsers/gsth264parse.h | 6 | ||||
-rw-r--r-- | sys/vdpau/gstvdpsink.c | 4 | ||||
-rw-r--r-- | sys/vdpau/h264/gstvdph264dec.c | 49 |
5 files changed, 53 insertions, 50 deletions
diff --git a/gst-libs/gst/codecparsers/gsth264meta.c b/gst-libs/gst/codecparsers/gsth264meta.c index a459b6f91..7e807beb1 100644 --- a/gst-libs/gst/codecparsers/gsth264meta.c +++ b/gst-libs/gst/codecparsers/gsth264meta.c @@ -37,9 +37,8 @@ gst_h264_meta_init (GstH264Meta * h264_meta, h264_meta->pps = NULL; h264_meta->sei = NULL; - h264_meta->num_slices = 0; - memset (&h264_meta->slices, 0, GST_MAX_H264_SLICE * sizeof (GstH264SliceHdr)); - memset (&h264_meta->slice_offsets, 0, GST_MAX_H264_SLICE * sizeof (gsize)); + h264_meta->slices = NULL; + h264_meta->slice_offsets = NULL; return TRUE; } @@ -150,6 +149,14 @@ gst_h264_meta_add_sei (GstH264Meta * meta, const GstH264SEIMessage * sei) meta->sei = g_list_append (meta->sei, g_slice_dup (GstH264SEIMessage, sei)); } +/** + * gst_h264_meta_add_slice: + * @meta: a #GstH264Meta + * @slice: the #GstH264SliceHdr to add to the meta + * @offset: the offset in bytes of the slice in the buffer + * + * Adds information about a slice to the @meta + */ void gst_h264_meta_add_slice (GstH264Meta * meta, const GstH264SliceHdr * slice, gsize offset) @@ -157,10 +164,7 @@ gst_h264_meta_add_slice (GstH264Meta * meta, const GstH264SliceHdr * slice, GST_DEBUG ("Adding slice, type:%d, first_mb_in_slice:%d, offset:%" G_GSIZE_FORMAT, slice->type, slice->first_mb_in_slice, offset); - g_return_if_fail (meta->num_slices < 16); - - meta->slice_offsets[meta->num_slices] = offset; - meta->slices[meta->num_slices] = *slice; - - meta->num_slices++; + meta->slices = + g_list_append (meta->slices, g_memdup (slice, sizeof (GstH264SliceHdr))); + meta->slice_offsets = g_list_append (meta->slice_offsets, (gpointer) offset); } diff --git a/gst-libs/gst/codecparsers/gsth264meta.h b/gst-libs/gst/codecparsers/gsth264meta.h index 1fe9c7635..df222f36c 100644 --- a/gst-libs/gst/codecparsers/gsth264meta.h +++ b/gst-libs/gst/codecparsers/gsth264meta.h @@ -37,12 +37,6 @@ GType gst_h264_meta_api_get_type (void); #define GST_H264_META_INFO (gst_h264_meta_get_info()) const GstMetaInfo * gst_h264_meta_get_info (void); -/* Maximum number of slices supported per frame */ -#define GST_MAX_H264_SLICE 16 - -/* Maximum number of SEI mesasge per frame */ -#define GST_MAX_H264_SEI 8 - /** * GstH264Meta: * @meta: parent #GstMeta @@ -50,10 +44,17 @@ const GstMetaInfo * gst_h264_meta_get_info (void); * @pps: List of #Gsth264PPS present in the buffer * @sei: List of #GstH264SEIMessage present in the buffer * @slices: List of #GstH264SliceHdr present in the buffer - * @slice_offset: array of offset (as #gsize) present in the buffer, the + * @slice_offset: List of offset (as #gsize) present in the buffer, the * order and index of the offset is the same as the @slices. * - * Extra buffer metadata describing the contents of a H264 Video frame + * Extra buffer metadata describing the contents of a H264 Video frame. + * + * Can be used by elements (mainly decoders) to avoid having to parse + * H264 packets if it can be done upstream. + * + * The contents of the @sps, @pps, @sei, @slices, @slice_offset lists are + * only valid during the lifetime of the #GstH264Meta. If elements wish + * to use those for longer, they are required to make a copy. */ struct _GstH264Meta { GstMeta meta; @@ -62,9 +63,8 @@ struct _GstH264Meta { GList *pps; GList *sei; - guint8 num_slices; - GstH264SliceHdr slices[GST_MAX_H264_SLICE]; - gsize slice_offsets[GST_MAX_H264_SLICE]; + GList *slices; + GList *slice_offsets; }; diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index 8aa5fd22d..2d3929aa9 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -110,10 +110,10 @@ struct _GstH264Parse /* Presence of items */ gboolean sps_present, pps_present; - GstH264SEIMessage sei[GST_MAX_H264_SEI]; + GstH264SEIMessage sei[16]; guint num_sei; - GstH264SliceHdr current_slices[GST_MAX_H264_SLICE]; - gsize slice_offsets[GST_MAX_H264_SLICE]; + GstH264SliceHdr current_slices[16]; + gsize slice_offsets[16]; guint num_slices; /* props */ diff --git a/sys/vdpau/gstvdpsink.c b/sys/vdpau/gstvdpsink.c index d694fe064..f26f81c4e 100644 --- a/sys/vdpau/gstvdpsink.c +++ b/sys/vdpau/gstvdpsink.c @@ -852,8 +852,8 @@ gst_vdp_sink_show_frame (GstBaseSink * bsink, GstBuffer * outbuf) g_mutex_lock (vdp_sink->x_lock); status = - device->vdp_presentation_queue_query_surface_status (vdp_sink-> - window->queue, surface, &queue_status, &pres_time); + device->vdp_presentation_queue_query_surface_status (vdp_sink->window-> + queue, surface, &queue_status, &pres_time); g_mutex_unlock (vdp_sink->x_lock); if (queue_status == VDP_PRESENTATION_QUEUE_STATUS_QUEUED) { diff --git a/sys/vdpau/h264/gstvdph264dec.c b/sys/vdpau/h264/gstvdph264dec.c index 6f45d58a6..3b453df5e 100644 --- a/sys/vdpau/h264/gstvdph264dec.c +++ b/sys/vdpau/h264/gstvdph264dec.c @@ -279,36 +279,37 @@ gst_vdp_h264_dec_create_bitstream_buffers (GstVdpH264Dec * h264_dec, { VdpBitstreamBuffer *bufs; guint i; - gsize offset = 0; + GList *tmp, *next; + guint num_slices = g_list_length (meta->slices); - bufs = g_new (VdpBitstreamBuffer, meta->num_slices); + bufs = g_new (VdpBitstreamBuffer, num_slices); + /* Convert list of offsets to array of data/size */ + for (tmp = meta->slice_offsets, i = 0; i < num_slices; i++, tmp = next) { + gsize curoffset = (gsize) tmp->data; + gsize nextoffs; - for (i = 0; i < meta->num_slices; i++) { - offset = meta->slice_offsets[i]; - bufs[i].bitstream = info->data + offset; + next = tmp->next; + + bufs[i].bitstream = info->data + curoffset; /* FIXME : REMOVE THIS vv */ if (i == 0) - bufs[i].bitstream = info->data + offset + 1; + bufs[i].bitstream = info->data + curoffset + 1; /* FIXME : REMOVE THIS ^^ */ - if (i == meta->num_slices - 1) - offset = (gsize) info->size; + if (next == NULL) + nextoffs = (gsize) info->size; else - offset = meta->slice_offsets[i + 1]; - - g_assert (offset != 0); + nextoffs = (gsize) next->data; - bufs[i].bitstream_bytes = offset - meta->slice_offsets[i]; + bufs[i].bitstream_bytes = nextoffs - curoffset; /* FIXME : REMOVE THIS vv */ if (i == 0) bufs[i].bitstream_bytes--; /* FIXME : REMOVE THIS ^^ */ - GST_LOG_OBJECT (h264_dec, "Slice %d (nalu_type:%d)", i, - meta->slices[i].slice_type); GST_DEBUG_OBJECT (h264_dec, - "meta->slice_offsets[%d]:%d, offset:%d, size:%d", i, - meta->slice_offsets[i], offset, bufs[i].bitstream_bytes); + "meta->slice_offsets[%d]:%d, next offset:%d, size:%d", i, + curoffset, nextoffs, bufs[i].bitstream_bytes); GST_MEMDUMP_OBJECT (h264_dec, "Slice", bufs[i].bitstream, MIN (bufs[i].bitstream_bytes, 128)); bufs[i].struct_version = VDP_BITSTREAM_BUFFER_VERSION; @@ -402,7 +403,6 @@ gst_vdp_h264_dec_handle_frame (GstVideoDecoder * video_decoder, VdpPictureInfoH264 info; VdpBitstreamBuffer *bufs; GstH264SliceHdr *first_slice; - guint i; GstMapInfo map; GST_DEBUG ("handle_frame"); @@ -411,7 +411,7 @@ gst_vdp_h264_dec_handle_frame (GstVideoDecoder * video_decoder, if (G_UNLIKELY (h264_meta == NULL)) goto no_h264_meta; - if (G_UNLIKELY (h264_meta->num_slices == 0)) + if (G_UNLIKELY (h264_meta->slices == NULL)) goto no_slices; /* Handle PPS/SPS/SEI if present */ @@ -432,16 +432,14 @@ gst_vdp_h264_dec_handle_frame (GstVideoDecoder * video_decoder, } } - first_slice = &h264_meta->slices[0]; + first_slice = (GstH264SliceHdr *) h264_meta->slices->data; if (!h264_dec->got_idr && first_slice->slice_type != GST_H264_NAL_SLICE_IDR) goto no_idr; /* Handle slices */ - for (i = 0; i < h264_meta->num_slices; i++) { - GstH264SliceHdr *slice = &h264_meta->slices[i]; - - GST_LOG_OBJECT (h264_dec, "Handling slice #%d", i); + for (tmp = h264_meta->slices; tmp; tmp = tmp->next) { + GstH264SliceHdr *slice = (GstH264SliceHdr *) tmp->data; slice->pps = h264_dec->pps[slice->pps_id]; } @@ -460,14 +458,15 @@ gst_vdp_h264_dec_handle_frame (GstVideoDecoder * video_decoder, gst_vdp_h264_dec_init_frame_info (h264_dec, h264_frame, first_slice); h264_frame->frame = frame; gst_vdp_h264_dec_fill_info (&info, h264_dec, h264_frame, first_slice); - info.slice_count = h264_meta->num_slices; + info.slice_count = g_list_length (h264_meta->slices); if (!gst_buffer_map (frame->input_buffer, &map, GST_MAP_READ)) goto map_fail; bufs = gst_vdp_h264_dec_create_bitstream_buffers (h264_dec, h264_meta, &map); ret = gst_vdp_decoder_render (GST_VDP_DECODER (h264_dec), - (VdpPictureInfo *) & info, h264_meta->num_slices, bufs, frame); + (VdpPictureInfo *) & info, g_list_length (h264_meta->slices), bufs, + frame); g_free (bufs); gst_buffer_unmap (frame->input_buffer, &map); |