diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-01-25 14:50:50 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-01-25 14:51:25 +0100 |
commit | 21073e98cf0c939318d90cc1b07eecd308e70732 (patch) | |
tree | b06149ea0bbde911e85e6e1e2bc1d3356e0d6c27 /gst | |
parent | f5cf0caf9fd0eae937e5de5002c5de8f9c9b2765 (diff) | |
download | gstreamer-plugins-bad-21073e98cf0c939318d90cc1b07eecd308e70732.tar.gz |
port to new memory API
Diffstat (limited to 'gst')
-rw-r--r-- | gst/audiovisualizers/gstbaseaudiovisualizer.c | 14 | ||||
-rw-r--r-- | gst/audiovisualizers/gstspacescope.c | 17 | ||||
-rw-r--r-- | gst/audiovisualizers/gstspectrascope.c | 22 | ||||
-rw-r--r-- | gst/audiovisualizers/gstsynaescope.c | 19 | ||||
-rw-r--r-- | gst/audiovisualizers/gstwavescope.c | 17 | ||||
-rw-r--r-- | gst/bayer/gstbayer2rgb.c | 9 | ||||
-rw-r--r-- | gst/bayer/gstrgb2bayer.c | 6 | ||||
-rw-r--r-- | gst/dtmf/gstdtmfdetect.c | 9 | ||||
-rw-r--r-- | gst/dtmf/gstdtmfsrc.c | 6 | ||||
-rw-r--r-- | gst/dtmf/gstrtpdtmfdepay.c | 6 | ||||
-rw-r--r-- | gst/dvbsuboverlay/gstdvbsuboverlay.c | 14 | ||||
-rw-r--r-- | gst/dvdspu/gstdvdspu.c | 14 | ||||
-rw-r--r-- | gst/dvdspu/gstspu-pgs.c | 16 | ||||
-rw-r--r-- | gst/dvdspu/gstspu-vobsub.c | 22 | ||||
-rw-r--r-- | gst/mpegtsdemux/mpegtsbase.c | 11 | ||||
-rw-r--r-- | gst/mpegtsdemux/mpegtspacketizer.c | 120 | ||||
-rw-r--r-- | gst/mpegtsdemux/mpegtspacketizer.h | 5 | ||||
-rw-r--r-- | gst/mpegtsdemux/tsdemux.c | 41 |
18 files changed, 197 insertions, 171 deletions
diff --git a/gst/audiovisualizers/gstbaseaudiovisualizer.c b/gst/audiovisualizers/gstbaseaudiovisualizer.c index 6cb8a5837..fdd839cc3 100644 --- a/gst/audiovisualizers/gstbaseaudiovisualizer.c +++ b/gst/audiovisualizers/gstbaseaudiovisualizer.c @@ -792,7 +792,7 @@ gst_base_audio_visualizer_chain (GstPad * pad, GstObject * parent, GstBuffer *inbuf; guint64 dist, ts; guint avail, sbpf; - gpointer adata, vdata; + gpointer adata; gboolean (*render) (GstBaseAudioVisualizer * scope, GstBuffer * audio, GstBuffer * video); @@ -835,6 +835,7 @@ gst_base_audio_visualizer_chain (GstPad * pad, GstObject * parent, GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf); while (avail >= sbpf) { GstBuffer *outbuf; + GstMapInfo map; /* get timestamp of the current adapter content */ ts = gst_adapter_prev_timestamp (scope->adapter, &dist); @@ -881,11 +882,11 @@ gst_base_audio_visualizer_chain (GstPad * pad, GstObject * parent, GST_BUFFER_TIMESTAMP (outbuf) = ts; GST_BUFFER_DURATION (outbuf) = scope->frame_duration; - vdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE); + gst_buffer_map (outbuf, &map, GST_MAP_WRITE); if (scope->shader) { - memcpy (vdata, scope->pixelbuf, scope->bpf); + memcpy (map.data, scope->pixelbuf, scope->bpf); } else { - memset (vdata, 0, scope->bpf); + memset (map.data, 0, scope->bpf); } /* this can fail as the data size we need could have changed */ @@ -903,12 +904,13 @@ gst_base_audio_visualizer_chain (GstPad * pad, GstObject * parent, } else { /* run various post processing (shading and geometri transformation */ if (scope->shader) { - scope->shader (scope, vdata, scope->pixelbuf); + scope->shader (scope, map.data, scope->pixelbuf); } } } - gst_buffer_unmap (outbuf, vdata, scope->bpf); + gst_buffer_unmap (outbuf, &map); + gst_buffer_resize (outbuf, 0, scope->bpf); g_mutex_unlock (&scope->config_lock); ret = gst_pad_push (scope->srcpad, outbuf); diff --git a/gst/audiovisualizers/gstspacescope.c b/gst/audiovisualizers/gstspacescope.c index a8585b0a9..5e19794e8 100644 --- a/gst/audiovisualizers/gstspacescope.c +++ b/gst/audiovisualizers/gstspacescope.c @@ -429,16 +429,17 @@ gst_space_scope_render (GstBaseAudioVisualizer * base, GstBuffer * audio, GstBuffer * video) { GstSpaceScope *scope = GST_SPACE_SCOPE (base); - gsize asize; - guint32 *vdata = - (guint32 *) gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE); - gint16 *adata = (gint16 *) gst_buffer_map (audio, &asize, NULL, GST_MAP_READ); + GstMapInfo vmap, amap; guint num_samples; - num_samples = asize / (base->channels * sizeof (gint16)); - scope->process (base, vdata, adata, num_samples); - gst_buffer_unmap (video, vdata, -1); - gst_buffer_unmap (audio, adata, -1); + gst_buffer_map (audio, &amap, GST_MAP_READ); + gst_buffer_map (video, &vmap, GST_MAP_WRITE); + + num_samples = amap.size / (base->channels * sizeof (gint16)); + scope->process (base, (guint32 *) vmap.data, (gint16 *) amap.data, + num_samples); + gst_buffer_unmap (video, &vmap); + gst_buffer_unmap (audio, &amap); return TRUE; } diff --git a/gst/audiovisualizers/gstspectrascope.c b/gst/audiovisualizers/gstspectrascope.c index abe2f7e97..95ce6e71f 100644 --- a/gst/audiovisualizers/gstspectrascope.c +++ b/gst/audiovisualizers/gstspectrascope.c @@ -167,20 +167,24 @@ gst_spectra_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, GstBuffer * video) { GstSpectraScope *scope = GST_SPECTRA_SCOPE (bscope); - gsize asize; - guint32 *vdata = - (guint32 *) gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE); - gint16 *adata = (gint16 *) gst_buffer_map (audio, &asize, NULL, GST_MAP_READ); - gint16 *mono_adata = (gint16 *) g_memdup (adata, asize); + gint16 *mono_adata; GstFFTS16Complex *fdata = scope->freq_data; guint x, y, off; guint l, h = bscope->height - 1; gfloat fr, fi; guint w = bscope->width; + GstMapInfo amap, vmap; + guint32 *vdata; + + gst_buffer_map (audio, &amap, GST_MAP_READ); + gst_buffer_map (video, &vmap, GST_MAP_WRITE); + vdata = (guint32 *) vmap.data; + + mono_adata = (gint16 *) g_memdup (amap.data, amap.size); if (bscope->channels > 1) { guint ch = bscope->channels; - guint num_samples = asize / (ch * sizeof (gint16)); + guint num_samples = amap.size / (ch * sizeof (gint16)); guint i, c, v, s = 0; /* deinterleave and mixdown adata */ @@ -196,7 +200,7 @@ gst_spectra_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, /* run fft */ gst_fft_s16_window (scope->fft_ctx, mono_adata, GST_FFT_WINDOW_HAMMING); gst_fft_s16_fft (scope->fft_ctx, mono_adata, fdata); - g_free (adata); + g_free (mono_adata); /* draw lines */ for (x = 0; x < bscope->width; x++) { @@ -215,8 +219,8 @@ gst_spectra_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, add_pixel (&vdata[off], 0x007F7F7F); } } - gst_buffer_unmap (video, vdata, -1); - gst_buffer_unmap (audio, adata, -1); + gst_buffer_unmap (video, &vmap); + gst_buffer_unmap (audio, &amap); return TRUE; } diff --git a/gst/audiovisualizers/gstsynaescope.c b/gst/audiovisualizers/gstsynaescope.c index c851d6f84..bba42962a 100644 --- a/gst/audiovisualizers/gstsynaescope.c +++ b/gst/audiovisualizers/gstsynaescope.c @@ -205,10 +205,9 @@ gst_synae_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, GstBuffer * video) { GstSynaeScope *scope = GST_SYNAE_SCOPE (bscope); - gsize asize; - guint32 *vdata = - (guint32 *) gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE); - gint16 *adata = (gint16 *) gst_buffer_map (audio, &asize, NULL, GST_MAP_READ); + GstMapInfo amap, vmap; + guint32 *vdata; + gint16 *adata; gint16 *adata_l = scope->adata_l; gint16 *adata_r = scope->adata_r; GstFFTS16Complex *fdata_l = scope->freq_data_l; @@ -221,7 +220,7 @@ gst_synae_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, guint *shade = scope->shade; //guint w2 = w /2; guint ch = bscope->channels; - guint num_samples = asize / (ch * sizeof (gint16)); + guint num_samples; gint i, j, b; gint br, br1, br2; gint clarity; @@ -229,6 +228,14 @@ gst_synae_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, gdouble frl, fil, frr, fir; const guint sl = 30; + gst_buffer_map (video, &vmap, GST_MAP_WRITE); + gst_buffer_map (audio, &amap, GST_MAP_READ); + + vdata = (guint32 *) vmap.data; + adata = (gint16 *) amap.data; + + num_samples = amap.size / (ch * sizeof (gint16)); + /* deinterleave */ for (i = 0, j = 0; i < num_samples; i++) { adata_l[i] = adata[j++]; @@ -297,6 +304,8 @@ gst_synae_scope_render (GstBaseAudioVisualizer * bscope, GstBuffer * audio, } } } + gst_buffer_unmap (video, &vmap); + gst_buffer_unmap (audio, &amap); return TRUE; } diff --git a/gst/audiovisualizers/gstwavescope.c b/gst/audiovisualizers/gstwavescope.c index 0efe457cd..df2a3451b 100644 --- a/gst/audiovisualizers/gstwavescope.c +++ b/gst/audiovisualizers/gstwavescope.c @@ -407,19 +407,18 @@ gst_wave_scope_render (GstBaseAudioVisualizer * base, GstBuffer * audio, GstBuffer * video) { GstWaveScope *scope = GST_WAVE_SCOPE (base); - guint32 *vdata; - gsize asize; - gint16 *adata; + GstMapInfo amap, vmap; guint num_samples; - adata = gst_buffer_map (audio, &asize, NULL, GST_MAP_READ); - vdata = gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE); + gst_buffer_map (audio, &amap, GST_MAP_READ); + gst_buffer_map (video, &vmap, GST_MAP_WRITE); - num_samples = asize / (base->channels * sizeof (gint16)); - scope->process (base, vdata, adata, num_samples); + num_samples = amap.size / (base->channels * sizeof (gint16)); + scope->process (base, (guint32 *) vmap.data, (gint16 *) amap.data, + num_samples); - gst_buffer_unmap (video, vdata, -1); - gst_buffer_unmap (audio, adata, -1); + gst_buffer_unmap (video, &vmap); + gst_buffer_unmap (audio, &amap); return TRUE; } diff --git a/gst/bayer/gstbayer2rgb.c b/gst/bayer/gstbayer2rgb.c index 8c2e31b14..69d439056 100644 --- a/gst/bayer/gstbayer2rgb.c +++ b/gst/bayer/gstbayer2rgb.c @@ -447,18 +447,19 @@ gst_bayer2rgb_transform (GstBaseTransform * base, GstBuffer * inbuf, GstBuffer * outbuf) { GstBayer2RGB *filter = GST_BAYER2RGB (base); - uint8_t *input, *output; + GstMapInfo map; + uint8_t *output; GstVideoFrame frame; GST_DEBUG ("transforming buffer"); - input = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_READ); + gst_buffer_map (inbuf, &map, GST_MAP_READ); gst_video_frame_map (&frame, &filter->info, inbuf, GST_MAP_WRITE); output = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0); gst_bayer2rgb_process (filter, output, filter->width * 4, - input, filter->width); + map.data, filter->width); gst_video_frame_unmap (&frame); - gst_buffer_unmap (inbuf, input, -1); + gst_buffer_unmap (inbuf, &map); return GST_FLOW_OK; } diff --git a/gst/bayer/gstrgb2bayer.c b/gst/bayer/gstrgb2bayer.c index 69aedb908..9213e5e1d 100644 --- a/gst/bayer/gstrgb2bayer.c +++ b/gst/bayer/gstrgb2bayer.c @@ -229,6 +229,7 @@ gst_rgb2bayer_transform (GstBaseTransform * trans, GstBuffer * inbuf, GstBuffer * outbuf) { GstRGB2Bayer *rgb2bayer = GST_RGB_2_BAYER (trans); + GstMapInfo map; guint8 *dest; guint8 *src; int i, j; @@ -238,7 +239,8 @@ gst_rgb2bayer_transform (GstBaseTransform * trans, GstBuffer * inbuf, gst_video_frame_map (&frame, &rgb2bayer->info, inbuf, GST_MAP_READ); - dest = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_READ); + gst_buffer_map (outbuf, &map, GST_MAP_READ); + dest = map.data; src = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0); for (j = 0; j < height; j++) { @@ -256,7 +258,7 @@ gst_rgb2bayer_transform (GstBaseTransform * trans, GstBuffer * inbuf, } } } - gst_buffer_unmap (outbuf, dest, -1); + gst_buffer_unmap (outbuf, &map); gst_video_frame_unmap (&frame); return GST_FLOW_OK; diff --git a/gst/dtmf/gstdtmfdetect.c b/gst/dtmf/gstdtmfdetect.c index 5bc98af17..037028534 100644 --- a/gst/dtmf/gstdtmfdetect.c +++ b/gst/dtmf/gstdtmfdetect.c @@ -161,17 +161,16 @@ gst_dtmf_detect_transform_ip (GstBaseTransform * trans, GstBuffer * buf) gint dtmf_count; gchar dtmfbuf[MAX_DTMF_DIGITS] = ""; gint i; - gpointer data; - gsize size; + GstMapInfo map; if (GST_BUFFER_IS_DISCONT (buf)) zap_dtmf_detect_init (&self->dtmf_state); if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)) return GST_FLOW_OK; - data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); + gst_buffer_map (buf, &map, GST_MAP_READ); - zap_dtmf_detect (&self->dtmf_state, (gint16 *) data, size / 2, FALSE); + zap_dtmf_detect (&self->dtmf_state, (gint16 *) map.data, map.size / 2, FALSE); dtmf_count = zap_dtmf_get (&self->dtmf_state, dtmfbuf, MAX_DTMF_DIGITS); @@ -180,7 +179,7 @@ gst_dtmf_detect_transform_ip (GstBaseTransform * trans, GstBuffer * buf) else GST_LOG_OBJECT (self, "Got no DTMF events"); - gst_buffer_unmap (buf, data, size); + gst_buffer_unmap (buf, &map); for (i = 0; i < dtmf_count; i++) { GstMessage *dtmf_message = NULL; diff --git a/gst/dtmf/gstdtmfsrc.c b/gst/dtmf/gstdtmfsrc.c index 80583fbc8..d59fa1c9b 100644 --- a/gst/dtmf/gstdtmfsrc.c +++ b/gst/dtmf/gstdtmfsrc.c @@ -541,6 +541,7 @@ gst_dtmf_src_generate_tone (GstDTMFSrcEvent * event, DTMF_KEY key, float duration, gint sample_rate) { GstBuffer *buffer; + GstMapInfo map; gint16 *p; gint tone_size; double i = 0; @@ -552,7 +553,8 @@ gst_dtmf_src_generate_tone (GstDTMFSrcEvent * event, DTMF_KEY key, buffer = gst_buffer_new_allocate (NULL, tone_size, 1); - p = (gint16 *) gst_buffer_map (buffer, NULL, NULL, GST_MAP_READWRITE); + gst_buffer_map (buffer, &map, GST_MAP_READWRITE); + p = (gint16 *) map.data; volume_factor = pow (10, (-event->volume) / 20); @@ -581,7 +583,7 @@ gst_dtmf_src_generate_tone (GstDTMFSrcEvent * event, DTMF_KEY key, (event->sample)++; } - gst_buffer_unmap (buffer, p, tone_size); + gst_buffer_unmap (buffer, &map); return buffer; } diff --git a/gst/dtmf/gstrtpdtmfdepay.c b/gst/dtmf/gstrtpdtmfdepay.c index 9d470f5f9..01a1698f2 100644 --- a/gst/dtmf/gstrtpdtmfdepay.c +++ b/gst/dtmf/gstrtpdtmfdepay.c @@ -333,6 +333,7 @@ gst_dtmf_src_generate_tone (GstRtpDTMFDepay * rtpdtmfdepay, GstRTPDTMFPayload payload) { GstBuffer *buf; + GstMapInfo map; gint16 *p; gint tone_size; double i = 0; @@ -351,7 +352,8 @@ gst_dtmf_src_generate_tone (GstRtpDTMFDepay * rtpdtmfdepay, GST_BUFFER_DURATION (buf) = payload.duration * GST_SECOND / clock_rate; volume = payload.volume; - p = (gint16 *) gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE); + gst_buffer_map (buf, &map, GST_MAP_WRITE); + p = (gint16 *) map.data; volume_factor = pow (10, (-volume) / 20); @@ -382,7 +384,7 @@ gst_dtmf_src_generate_tone (GstRtpDTMFDepay * rtpdtmfdepay, (rtpdtmfdepay->sample)++; } - gst_buffer_unmap (buf, p, tone_size); + gst_buffer_unmap (buf, &map); return buf; } diff --git a/gst/dvbsuboverlay/gstdvbsuboverlay.c b/gst/dvbsuboverlay/gstdvbsuboverlay.c index 53f4f9092..aa26cdaad 100644 --- a/gst/dvbsuboverlay/gstdvbsuboverlay.c +++ b/gst/dvbsuboverlay/gstdvbsuboverlay.c @@ -702,23 +702,23 @@ static void gst_dvbsub_overlay_process_text (GstDVBSubOverlay * overlay, GstBuffer * buffer, guint64 pts) { - guint8 *data; - gsize size; + GstMapInfo map; GST_DEBUG_OBJECT (overlay, "Processing subtitles with fake PTS=%" G_GUINT64_FORMAT " which is a running time of %" GST_TIME_FORMAT, pts, GST_TIME_ARGS (pts)); - GST_DEBUG_OBJECT (overlay, "Feeding %" G_GSIZE_FORMAT " bytes to libdvbsub", - size); - data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); + gst_buffer_map (buffer, &map, GST_MAP_READ); + + GST_DEBUG_OBJECT (overlay, "Feeding %" G_GSIZE_FORMAT " bytes to libdvbsub", + map.size); g_mutex_lock (&overlay->dvbsub_mutex); - dvb_sub_feed_with_pts (overlay->dvb_sub, pts, data, size); + dvb_sub_feed_with_pts (overlay->dvb_sub, pts, map.data, map.size); g_mutex_unlock (&overlay->dvbsub_mutex); - gst_buffer_unmap (buffer, data, size); + gst_buffer_unmap (buffer, &map); gst_buffer_unref (buffer); } diff --git a/gst/dvdspu/gstdvdspu.c b/gst/dvdspu/gstdvdspu.c index 8e60c29e9..488b46625 100644 --- a/gst/dvdspu/gstdvdspu.c +++ b/gst/dvdspu/gstdvdspu.c @@ -951,14 +951,14 @@ gst_dvd_spu_subpic_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) * we've collected */ guint8 packet_type; guint16 packet_size; - guint8 *data, *ptr, *end; - gsize size; + GstMapInfo map; + guint8 *ptr, *end; gboolean invalid = FALSE; - data = gst_buffer_map (dvdspu->partial_spu, &size, NULL, GST_MAP_READ); + gst_buffer_map (dvdspu->partial_spu, &map, GST_MAP_READ); - ptr = data; - end = ptr + size; + ptr = map.data; + end = ptr + map.size; /* FIXME: There's no need to walk the command set each time. We can set a * marker and resume where we left off next time */ @@ -979,7 +979,7 @@ gst_dvd_spu_subpic_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) break; } } - gst_buffer_unmap (dvdspu->partial_spu, data, size); + gst_buffer_unmap (dvdspu->partial_spu, &map); if (invalid) { gst_buffer_unref (dvdspu->partial_spu); @@ -987,7 +987,7 @@ gst_dvd_spu_subpic_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) } else if (ptr == end) { GST_DEBUG_OBJECT (dvdspu, "Have complete PGS packet of size %" G_GSIZE_FORMAT ". Enqueueing.", - size); + map.size); submit_new_spu_packet (dvdspu, dvdspu->partial_spu); dvdspu->partial_spu = NULL; } diff --git a/gst/dvdspu/gstspu-pgs.c b/gst/dvdspu/gstspu-pgs.c index 955cf1a98..8519d5fdf 100644 --- a/gst/dvdspu/gstspu-pgs.c +++ b/gst/dvdspu/gstspu-pgs.c @@ -679,15 +679,15 @@ parse_pgs_packet (GstDVDSpu * dvdspu, guint8 type, guint8 * payload, gint gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf) { - guint8 *data, *pos, *end; - gsize size; + GstMapInfo map; + guint8 *pos, *end; guint8 type; guint16 packet_len; - data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); + gst_buffer_map (buf, &map, GST_MAP_READ); - pos = data; - end = pos + size; + pos = map.data; + end = pos + map.size; /* Need at least 3 bytes */ if (pos + 3 > end) { @@ -703,7 +703,7 @@ gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf) pos += 2; if (pos + packet_len > end) { - gst_buffer_unmap (buf, data, size); + gst_buffer_unmap (buf, &map); PGS_DUMP ("Invalid packet length %u (only have %u bytes)\n", packet_len, end - pos); goto error; @@ -716,12 +716,12 @@ gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf) } while (pos + 3 <= end); PGS_DUMP ("End dumping command buffer with %u bytes remaining\n", end - pos); - return (pos - data); + return (pos - map.data); /* ERRORS */ error: { - gst_buffer_unmap (buf, data, size); + gst_buffer_unmap (buf, &map); return -1; } } diff --git a/gst/dvdspu/gstspu-vobsub.c b/gst/dvdspu/gstspu-vobsub.c index b1b76bb2e..e442c704b 100644 --- a/gst/dvdspu/gstspu-vobsub.c +++ b/gst/dvdspu/gstspu-vobsub.c @@ -322,8 +322,8 @@ void gstspu_vobsub_handle_new_buf (GstDVDSpu * dvdspu, GstClockTime event_ts, GstBuffer * buf) { + GstMapInfo map; guint8 *start, *end; - gsize size; SpuState *state = &dvdspu->spu_state; #if DUMP_DCSQ @@ -340,8 +340,9 @@ gstspu_vobsub_handle_new_buf (GstDVDSpu * dvdspu, GstClockTime event_ts, state->vobsub.buf = buf; state->vobsub.base_ts = event_ts; - start = gst_buffer_map (state->vobsub.buf, &size, NULL, GST_MAP_READ); - end = start + size; + gst_buffer_map (state->vobsub.buf, &map, GST_MAP_READ); + start = map.data; + end = start + map.size; /* Configure the first command block in this buffer as our initial blk */ state->vobsub.cur_cmd_blk = GST_READ_UINT16_BE (start + 2); @@ -352,7 +353,7 @@ gstspu_vobsub_handle_new_buf (GstDVDSpu * dvdspu, GstClockTime event_ts, g_free (state->vobsub.line_ctrl_i); state->vobsub.line_ctrl_i = NULL; } - gst_buffer_unmap (state->vobsub.buf, start, size); + gst_buffer_unmap (state->vobsub.buf, &map); return; invalid: @@ -363,9 +364,9 @@ invalid: gboolean gstspu_vobsub_execute_event (GstDVDSpu * dvdspu) { + GstMapInfo map; guint8 *start, *cmd_blk, *end; guint16 next_blk; - gsize size; SpuState *state = &dvdspu->spu_state; if (state->vobsub.buf == NULL) @@ -375,13 +376,14 @@ gstspu_vobsub_execute_event (GstDVDSpu * dvdspu) " @ offset %u", GST_TIME_ARGS (state->next_ts), state->vobsub.cur_cmd_blk); - start = gst_buffer_map (state->vobsub.buf, &size, NULL, GST_MAP_READ); - end = start + size; + gst_buffer_map (state->vobsub.buf, &map, GST_MAP_READ); + start = map.data; + end = start + map.size; cmd_blk = start + state->vobsub.cur_cmd_blk; if (G_UNLIKELY (cmd_blk + 5 >= end)) { - gst_buffer_unmap (state->vobsub.buf, start, size); + gst_buffer_unmap (state->vobsub.buf, &map); /* Invalid. Finish the buffer and loop again */ gst_dvd_spu_finish_spu_buf (dvdspu); return FALSE; @@ -396,11 +398,11 @@ gstspu_vobsub_execute_event (GstDVDSpu * dvdspu) } else { /* Next Block points to the current block, so we're finished with this * SPU buffer */ - gst_buffer_unmap (state->vobsub.buf, start, size); + gst_buffer_unmap (state->vobsub.buf, &map); gst_dvd_spu_finish_spu_buf (dvdspu); return FALSE; } - gst_buffer_unmap (state->vobsub.buf, start, size); + gst_buffer_unmap (state->vobsub.buf, &map); return TRUE; } diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c index 34736d7b0..bdf4caddb 100644 --- a/gst/mpegtsdemux/mpegtsbase.c +++ b/gst/mpegtsdemux/mpegtsbase.c @@ -960,16 +960,15 @@ mpegts_base_handle_psi (MpegTSBase * base, MpegTSPacketizerSection * section) /* table ids 0x70 - 0x73 do not have a crc */ if (G_LIKELY (section->table_id < 0x70 || section->table_id > 0x73)) { - gpointer data; - gsize size; + GstMapInfo map; - data = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ); - if (G_UNLIKELY (mpegts_base_calc_crc32 (data, size) != 0)) { - gst_buffer_unmap (section->buffer, data, size); + gst_buffer_map (section->buffer, &map, GST_MAP_READ); + if (G_UNLIKELY (mpegts_base_calc_crc32 (map.data, map.size) != 0)) { + gst_buffer_unmap (section->buffer, &map); GST_WARNING_OBJECT (base, "bad crc in psi pid 0x%x", section->pid); return FALSE; } - gst_buffer_unmap (section->buffer, data, size); + gst_buffer_unmap (section->buffer, &map); } switch (section->table_id) { diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c index afd47aa8e..148e5410a 100644 --- a/gst/mpegtsdemux/mpegtspacketizer.c +++ b/gst/mpegtsdemux/mpegtspacketizer.c @@ -287,7 +287,7 @@ mpegts_packetizer_parse_packet (MpegTSPacketizer2 * packetizer, packet->data = data; - gst_buffer_unmap (packet->buffer, packet->bufdata, packet->bufsize); + gst_buffer_unmap (packet->buffer, &packet->bufmap); if (packet->adaptation_field_control & 0x02) if (!mpegts_packetizer_parse_adaptation_field_control (packetizer, packet)) @@ -305,9 +305,9 @@ static gboolean mpegts_packetizer_parse_section_header (MpegTSPacketizer2 * packetizer, MpegTSPacketizerStream * stream, MpegTSPacketizerSection * section) { + GstMapInfo map; guint8 tmp; - guint8 *bufdata, *data, *crc_data; - gsize size; + guint8 *data, *crc_data; MpegTSPacketizerStreamSubtable *subtable; GSList *subtable_list = NULL; @@ -316,7 +316,8 @@ mpegts_packetizer_parse_section_header (MpegTSPacketizer2 * packetizer, /* get the section buffer, pass the ownership to the caller */ section->buffer = gst_adapter_take_buffer (stream->section_adapter, 3 + stream->section_length); - bufdata = data = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ); + gst_buffer_map (section->buffer, &map, GST_MAP_READ); + data = map.data; GST_BUFFER_OFFSET (section->buffer) = stream->offset; section->table_id = *data++; @@ -352,7 +353,7 @@ mpegts_packetizer_parse_section_header (MpegTSPacketizer2 * packetizer, goto not_applicable; /* CRC is at the end of the section */ - crc_data = bufdata + size - 4; + crc_data = map.data + map.size - 4; section->crc = GST_READ_UINT32_BE (crc_data); if (section->version_number == subtable->version_number && @@ -363,7 +364,7 @@ mpegts_packetizer_parse_section_header (MpegTSPacketizer2 * packetizer, subtable->crc = section->crc; stream->section_table_id = section->table_id; - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); return TRUE; @@ -373,7 +374,7 @@ not_applicable: section->pid, section->table_id, section->subtable_extension, section->current_next_indicator, section->version_number, section->crc); section->complete = FALSE; - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); gst_buffer_unref (section->buffer); return TRUE; } @@ -427,8 +428,8 @@ mpegts_packetizer_parse_pat (MpegTSPacketizer2 * packetizer, MpegTSPacketizerSection * section) { GstStructure *pat_info = NULL; - guint8 *bufdata, *data, *end; - gsize size; + GstMapInfo map; + guint8 *data, *end; guint transport_stream_id; guint8 tmp; guint program_number; @@ -438,7 +439,8 @@ mpegts_packetizer_parse_pat (MpegTSPacketizer2 * packetizer, GstStructure *entry = NULL; gchar *struct_name; - bufdata = data = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ); + gst_buffer_map (section->buffer, &map, GST_MAP_READ); + data = map.data; section->table_id = *data++; section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF; @@ -459,7 +461,7 @@ mpegts_packetizer_parse_pat (MpegTSPacketizer2 * packetizer, g_value_init (&entries, GST_TYPE_LIST); /* stop at the CRC */ - end = bufdata + size; + end = map.data + map.size; while (data < end - 4) { program_number = GST_READ_UINT16_BE (data); @@ -483,7 +485,7 @@ mpegts_packetizer_parse_pat (MpegTSPacketizer2 * packetizer, gst_structure_id_set_value (pat_info, QUARK_PROGRAMS, &entries); g_value_unset (&entries); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); if (data != end - 4) { /* FIXME: check the CRC before parsing the packet */ @@ -501,8 +503,8 @@ mpegts_packetizer_parse_pmt (MpegTSPacketizer2 * packetizer, MpegTSPacketizerSection * section) { GstStructure *pmt = NULL; - guint8 *bufdata, *data, *end; - gsize size; + GstMapInfo map; + guint8 *data, *end; guint16 program_number; guint8 tmp; guint pcr_pid; @@ -516,16 +518,17 @@ mpegts_packetizer_parse_pmt (MpegTSPacketizer2 * packetizer, GstStructure *stream_info = NULL; gchar *struct_name; - data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ); + gst_buffer_map (section->buffer, &map, GST_MAP_READ); + data = map.data; /* fixed header + CRC == 16 */ - if (size < 16) { + if (map.size < 16) { GST_WARNING ("PID %d invalid PMT size %d", section->pid, section->section_length); goto error; } - end = data + size; + end = map.data + map.size; section->table_id = *data++; section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF; @@ -695,7 +698,7 @@ mpegts_packetizer_parse_pmt (MpegTSPacketizer2 * packetizer, gst_structure_id_set_value (pmt, QUARK_STREAMS, &programs); g_value_unset (&programs); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); g_assert (data == end - 4); @@ -704,7 +707,7 @@ mpegts_packetizer_parse_pmt (MpegTSPacketizer2 * packetizer, error: if (pmt) gst_structure_free (pmt); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); return NULL; } @@ -714,8 +717,8 @@ mpegts_packetizer_parse_nit (MpegTSPacketizer2 * packetizer, MpegTSPacketizerSection * section) { GstStructure *nit = NULL, *transport = NULL, *delivery_structure = NULL; - guint8 *bufdata, *data, *end, *entry_begin; - gsize size; + GstMapInfo map; + guint8 *data, *end, *entry_begin; guint16 network_id, transport_stream_id, original_network_id; guint tmp; guint16 descriptors_loop_length, transport_stream_loop_length; @@ -725,16 +728,17 @@ mpegts_packetizer_parse_nit (MpegTSPacketizer2 * packetizer, GST_DEBUG ("NIT"); - data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ); + gst_buffer_map (section->buffer, &map, GST_MAP_READ); + data = map.data; /* fixed header + CRC == 16 */ - if (size < 23) { + if (map.size < 23) { GST_WARNING ("PID %d invalid NIT size %d", section->pid, section->section_length); goto error; } - end = data + size; + end = map.data + map.size; section->table_id = *data++; section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF; @@ -1323,14 +1327,14 @@ mpegts_packetizer_parse_nit (MpegTSPacketizer2 * packetizer, if (data != end - 4) { GST_WARNING ("PID %d invalid NIT parsed %d length %" G_GSIZE_FORMAT, - section->pid, (gint) (data - bufdata), size); + section->pid, (gint) (data - map.data), map.size); goto error; } gst_structure_id_set_value (nit, QUARK_TRANSPORTS, &transports); g_value_unset (&transports); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); GST_DEBUG ("NIT %" GST_PTR_FORMAT, nit); @@ -1340,7 +1344,7 @@ error: if (nit) gst_structure_free (nit); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); if (GST_VALUE_HOLDS_LIST (&transports)) g_value_unset (&transports); @@ -1352,9 +1356,9 @@ GstStructure * mpegts_packetizer_parse_sdt (MpegTSPacketizer2 * packetizer, MpegTSPacketizerSection * section) { + GstMapInfo map; GstStructure *sdt = NULL, *service = NULL; - guint8 *data, *bufdata, *end, *entry_begin; - gsize size; + guint8 *data, *end, *entry_begin; guint16 transport_stream_id, original_network_id, service_id; guint tmp; guint sdt_info_length; @@ -1367,16 +1371,17 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer2 * packetizer, GST_DEBUG ("SDT"); - data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ); + gst_buffer_map (section->buffer, &map, GST_MAP_READ); + data = map.data; /* fixed header + CRC == 16 */ - if (size < 14) { + if (map.size < 14) { GST_WARNING ("PID %d invalid SDT size %d", section->pid, section->section_length); goto error; } - end = data + size; + end = map.data + map.size; section->table_id = *data++; section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF; @@ -1534,14 +1539,14 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer2 * packetizer, if (data != end - 4) { GST_WARNING ("PID %d invalid SDT parsed %d length %" G_GSIZE_FORMAT, - section->pid, (gint) (data - bufdata), size); + section->pid, (gint) (data - map.data), map.size); goto error; } gst_structure_id_set_value (sdt, QUARK_SERVICES, &services); g_value_unset (&services); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); return sdt; @@ -1549,7 +1554,7 @@ error: if (sdt) gst_structure_free (sdt); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); if (GST_VALUE_HOLDS_LIST (&services)) g_value_unset (&services); @@ -1569,8 +1574,8 @@ mpegts_packetizer_parse_eit (MpegTSPacketizer2 * packetizer, guint16 mjd; guint year, month, day, hour, minute, second; guint duration; - guint8 *data, *bufdata, *end, *duration_ptr, *utc_ptr; - gsize size; + GstMapInfo map; + guint8 *data, *end, *duration_ptr, *utc_ptr; guint16 descriptors_loop_length; GValue events = { 0 }; GValue event_value = { 0 }; @@ -1578,16 +1583,17 @@ mpegts_packetizer_parse_eit (MpegTSPacketizer2 * packetizer, gchar *event_name; guint tmp; - data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ); + gst_buffer_map (section->buffer, &map, GST_MAP_READ); + data = map.data; /* fixed header + CRC == 16 */ - if (size < 18) { + if (map.size < 18) { GST_WARNING ("PID %d invalid EIT size %d", section->pid, section->section_length); goto error; } - end = data + size; + end = map.data + map.size; section->table_id = *data++; section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF; @@ -1998,14 +2004,14 @@ mpegts_packetizer_parse_eit (MpegTSPacketizer2 * packetizer, if (data != end - 4) { GST_WARNING ("PID %d invalid EIT parsed %d length %" G_GSIZE_FORMAT, - section->pid, (gint) (data - bufdata), size); + section->pid, (gint) (data - map.data), map.size); goto error; } gst_structure_id_set_value (eit, QUARK_EVENTS, &events); g_value_unset (&events); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); GST_DEBUG ("EIT %" GST_PTR_FORMAT, eit); @@ -2015,7 +2021,7 @@ error: if (eit) gst_structure_free (eit); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); if (GST_VALUE_HOLDS_LIST (&events)) g_value_unset (&events); @@ -2030,21 +2036,22 @@ mpegts_packetizer_parse_tdt (MpegTSPacketizer2 * packetizer, GstStructure *tdt = NULL; guint16 mjd; guint year, month, day, hour, minute, second; - guint8 *data, *bufdata, *end, *utc_ptr; - gsize size; + GstMapInfo map; + guint8 *data, *end, *utc_ptr; GST_DEBUG ("TDT"); - data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ); + gst_buffer_map (section->buffer, &map, GST_MAP_READ); + data = map.data; /* length always 8 */ - if (G_UNLIKELY (size != 8)) { + if (G_UNLIKELY (map.size != 8)) { GST_WARNING ("PID %d invalid TDT size %d", section->pid, section->section_length); goto error; } - end = data + size; + end = map.data + map.size; section->table_id = *data++; section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF; @@ -2085,7 +2092,7 @@ mpegts_packetizer_parse_tdt (MpegTSPacketizer2 * packetizer, "hour", G_TYPE_UINT, hour, "minute", G_TYPE_UINT, minute, "second", G_TYPE_UINT, second, NULL); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); return tdt; @@ -2093,7 +2100,7 @@ error: if (tdt) gst_structure_free (tdt); - gst_buffer_unmap (section->buffer, bufdata, size); + gst_buffer_unmap (section->buffer, &map); return NULL; } @@ -2281,8 +2288,9 @@ mpegts_packetizer_next_packet (MpegTSPacketizer2 * packetizer, packet->buffer = gst_adapter_take_buffer (packetizer->adapter, packetizer->packet_size); - bufdata = packet->bufdata = packet->data_start = - gst_buffer_map (packet->buffer, &packet->bufsize, 0, GST_MAP_READ); + gst_buffer_map (packet->buffer, &packet->bufmap, GST_MAP_READ); + + bufdata = packet->data_start = packet->bufmap.data; /* M2TS packets don't start with the sync byte, all other variants do */ if (packetizer->packet_size == MPEGTS_M2TS_PACKETSIZE) @@ -2312,7 +2320,7 @@ mpegts_packetizer_next_packet (MpegTSPacketizer2 * packetizer, if (G_UNLIKELY (i == packetizer->packet_size)) { GST_ERROR ("REALLY lost the sync"); - gst_buffer_unmap (packet->buffer, bufdata, packet->bufsize); + gst_buffer_unmap (packet->buffer, &packet->bufmap); gst_buffer_unref (packet->buffer); goto done; } @@ -2325,7 +2333,7 @@ mpegts_packetizer_next_packet (MpegTSPacketizer2 * packetizer, } /* Pop out the remaining data... */ - gst_buffer_resize (packet->buffer, i, packet->bufsize - i); + gst_buffer_resize (packet->buffer, i, packet->bufmap.size - i); GST_BUFFER_OFFSET (packet->buffer) += i; tmpbuf = gst_adapter_take_buffer (packetizer->adapter, @@ -2384,7 +2392,7 @@ mpegts_packetizer_push_section (MpegTSPacketizer2 * packetizer, section->section_length = GST_READ_UINT24_BE (data) & 0x000FFF; section->buffer = gst_buffer_copy_region (packet->buffer, GST_BUFFER_COPY_ALL, - data - packet->bufdata, section->section_length + 3); + data - packet->bufmap.data, section->section_length + 3); section->table_id = table_id; section->complete = TRUE; res = TRUE; @@ -2396,7 +2404,7 @@ mpegts_packetizer_push_section (MpegTSPacketizer2 * packetizer, /* create a sub buffer from the start of the section (table_id and * section_length included) to the end */ sub_buf = gst_buffer_copy_region (packet->buffer, GST_BUFFER_COPY_ALL, - data - packet->bufdata, packet->data_end - data); + data - packet->bufmap.data, packet->data_end - data); stream = packetizer->streams[packet->pid]; diff --git a/gst/mpegtsdemux/mpegtspacketizer.h b/gst/mpegtsdemux/mpegtspacketizer.h index d70a10104..ab6db621a 100644 --- a/gst/mpegtsdemux/mpegtspacketizer.h +++ b/gst/mpegtsdemux/mpegtspacketizer.h @@ -94,9 +94,8 @@ typedef struct guint8 continuity_counter; guint8 *payload; - /* temporary copies of gst_buffer_map */ - guint8 *bufdata; - gsize bufsize; + /* gst_buffer_map */ + GstMapInfo bufmap; guint8 *data_start; /* Location of 0x47 marker byte */ guint8 *data_end; diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index 2ed04c516..6261ff908 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -1726,8 +1726,8 @@ process_pcr (MpegTSBase * base, guint64 initoff, TSPcrOffset * pcroffset, for (i = 0; (i < 20) && (nbpcr < numpcr); i++) { guint offset; - gsize size, bufsize; - gpointer data; + GstMapInfo map; + gsize size; ret = gst_pad_pull_range (base->sinkpad, @@ -1736,10 +1736,10 @@ process_pcr (MpegTSBase * base, guint64 initoff, TSPcrOffset * pcroffset, if (G_UNLIKELY (ret != GST_FLOW_OK)) goto beach; - data = gst_buffer_map (buf, &bufsize, 0, GST_MAP_READ); - size = bufsize; + gst_buffer_map (buf, &map, GST_MAP_READ); + size = map.size; - gst_byte_reader_init (&br, data, size); + gst_byte_reader_init (&br, map.data, map.size); offset = 0; @@ -1748,7 +1748,7 @@ process_pcr (MpegTSBase * base, guint64 initoff, TSPcrOffset * pcroffset, 0, base->packetsize); if (offset == -1) { - gst_buffer_unmap (buf, data, bufsize); + gst_buffer_unmap (buf, &map); continue; } @@ -1799,7 +1799,7 @@ process_pcr (MpegTSBase * base, guint64 initoff, TSPcrOffset * pcroffset, size -= base->packetsize; offset += base->packetsize; } - gst_buffer_unmap (buf, data, bufsize); + gst_buffer_unmap (buf, &map); } beach: @@ -2013,19 +2013,18 @@ gst_ts_demux_parse_pes_header (GstTSDemux * demux, TSDemuxStream * stream) GstBuffer *buf = stream->pendingbuffers[0]; GstFlowReturn res = GST_FLOW_OK; gint offset = 0; - guint8 *data; - gsize length; + GstMapInfo map; guint64 bufferoffset; PESParsingResult parseres; GstClockTime origts; - data = gst_buffer_map (buf, &length, 0, GST_MAP_READ); + gst_buffer_map (buf, &map, GST_MAP_READ); bufferoffset = GST_BUFFER_OFFSET (buf); origts = GST_BUFFER_TIMESTAMP (buf); - GST_MEMDUMP ("Header buffer", data, MIN (length, 32)); + GST_MEMDUMP ("Header buffer", map.data, MIN (map.size, 32)); - parseres = mpegts_parse_pes_header (data, length, &header, &offset); + parseres = mpegts_parse_pes_header (map.data, map.size, &header, &offset); if (G_UNLIKELY (parseres == PES_PARSING_NEED_MORE)) goto discont; @@ -2123,11 +2122,11 @@ gst_ts_demux_parse_pes_header (GstTSDemux * demux, TSDemuxStream * stream) if (header.DTS != -1) gst_ts_demux_record_dts (demux, stream, header.DTS, bufferoffset); - gst_buffer_unmap (buf, data, length); + gst_buffer_unmap (buf, &map); /* Remove PES headers */ GST_DEBUG ("Moving data forward by %d bytes", header.header_size); - gst_buffer_resize (buf, header.header_size, length - header.header_size); + gst_buffer_resize (buf, header.header_size, map.size - header.header_size); /* FIXME : responsible for switching to PENDING_PACKET_BUFFER and * creating the bufferlist */ @@ -2162,21 +2161,19 @@ gst_ts_demux_queue_data (GstTSDemux * demux, TSDemuxStream * stream, MpegTSPacketizerPacket * packet) { GstBuffer *buf; - guint8 *data; - gsize size; + GstMapInfo map; GST_DEBUG ("state:%d", stream->state); buf = packet->buffer; - data = gst_buffer_map (buf, &size, 0, GST_MAP_READ); + gst_buffer_map (buf, &map, GST_MAP_READ); GST_DEBUG ("Resizing buffer to %d (size:%d) (Was %" G_GSIZE_FORMAT - " bytes long)", (int) (packet->payload - data), - (int) (packet->data_end - packet->payload), size); - gst_buffer_unmap (buf, data, size); - - gst_buffer_resize (buf, packet->payload - data, + " bytes long)", (int) (packet->payload - map.data), + (int) (packet->data_end - packet->payload), map.size); + gst_buffer_resize (buf, packet->payload - map.data, packet->data_end - packet->payload); + gst_buffer_unmap (buf, &map); if (stream->state == PENDING_PACKET_EMPTY) { if (G_UNLIKELY (!packet->payload_unit_start_indicator)) { |