mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
port to new memory API
This commit is contained in:
parent
f5cf0caf9f
commit
21073e98cf
20 changed files with 219 additions and 211 deletions
|
@ -135,6 +135,7 @@ struct _GstSignalProcessorPad
|
|||
GstPad parent;
|
||||
|
||||
GstBuffer *pen;
|
||||
GstMapInfo map; /* mapped data to read from / write to */
|
||||
|
||||
/* index for the pad per direction (starting from 0) */
|
||||
guint index;
|
||||
|
@ -144,7 +145,6 @@ struct _GstSignalProcessorPad
|
|||
|
||||
/* these are only used for sink pads */
|
||||
guint samples_avail; /* available mono sample frames */
|
||||
gfloat *data; /* data pointer to read from / write to */
|
||||
};
|
||||
|
||||
static GType
|
||||
|
@ -291,10 +291,8 @@ gst_signal_processor_init (GstSignalProcessor * self,
|
|||
|
||||
self->group_in = g_new0 (GstSignalProcessorGroup, klass->num_group_in);
|
||||
self->group_out = g_new0 (GstSignalProcessorGroup, klass->num_group_out);
|
||||
self->audio_in = g_new0 (gfloat *, klass->num_audio_in);
|
||||
self->audio_out = g_new0 (gfloat *, klass->num_audio_out);
|
||||
self->control_in = g_new0 (gfloat, klass->num_control_in);
|
||||
self->control_out = g_new0 (gfloat, klass->num_control_out);
|
||||
self->audio_in = g_new0 (GstMapInfo, klass->num_audio_in);
|
||||
self->audio_out = g_new0 (GstMapInfo, klass->num_audio_out);
|
||||
|
||||
/* init */
|
||||
self->pending_in = klass->num_group_in + klass->num_audio_in;
|
||||
|
@ -314,10 +312,6 @@ gst_signal_processor_finalize (GObject * object)
|
|||
self->audio_in = NULL;
|
||||
g_free (self->audio_out);
|
||||
self->audio_out = NULL;
|
||||
g_free (self->control_in);
|
||||
self->control_in = NULL;
|
||||
g_free (self->control_out);
|
||||
self->control_out = NULL;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -424,12 +418,12 @@ gst_signal_processor_cleanup (GstSignalProcessor * self)
|
|||
|
||||
for (i = 0; i < klass->num_group_in; ++i) {
|
||||
g_free (self->group_in[i].buffer);
|
||||
memset (&self->group_in[i], '\0', sizeof (GstSignalProcessorGroup));
|
||||
memset (&self->group_in[i], 0, sizeof (GstSignalProcessorGroup));
|
||||
}
|
||||
|
||||
for (i = 0; i < klass->num_group_out; ++i) {
|
||||
g_free (self->group_out[i].buffer);
|
||||
memset (&self->group_in[i], '\0', sizeof (GstSignalProcessorGroup));
|
||||
memset (&self->group_out[i], 0, sizeof (GstSignalProcessorGroup));
|
||||
}
|
||||
|
||||
self->state = GST_SIGNAL_PROCESSOR_STATE_NULL;
|
||||
|
@ -559,12 +553,12 @@ gst_signal_processor_deinterleave_group (GstSignalProcessorGroup * group,
|
|||
{
|
||||
guint i, j;
|
||||
g_assert (group->nframes == nframes);
|
||||
g_assert (group->interleaved_buffer);
|
||||
g_assert (group->interleaved_map.data);
|
||||
g_assert (group->buffer);
|
||||
for (i = 0; i < nframes; ++i)
|
||||
for (j = 0; j < group->channels; ++j)
|
||||
group->buffer[(j * nframes) + i]
|
||||
= group->interleaved_buffer[(i * group->channels) + j];
|
||||
= group->interleaved_map.data[(i * group->channels) + j];
|
||||
}
|
||||
|
||||
/* Interleave a pad (plugin => gstreamer) */
|
||||
|
@ -574,11 +568,11 @@ gst_signal_processor_interleave_group (GstSignalProcessorGroup * group,
|
|||
{
|
||||
guint i, j;
|
||||
g_assert (group->nframes == nframes);
|
||||
g_assert (group->interleaved_buffer);
|
||||
g_assert (group->interleaved_map.data);
|
||||
g_assert (group->buffer);
|
||||
for (i = 0; i < nframes; ++i)
|
||||
for (j = 0; j < group->channels; ++j)
|
||||
group->interleaved_buffer[(i * group->channels) + j]
|
||||
group->interleaved_map.data[(i * group->channels) + j]
|
||||
= group->buffer[(j * nframes) + i];
|
||||
}
|
||||
|
||||
|
@ -659,7 +653,7 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
|
|||
samples_avail = MIN (samples_avail, sinkpad->samples_avail);
|
||||
if (sinkpad->channels > 1) {
|
||||
GstSignalProcessorGroup *group = &self->group_in[in_group_index++];
|
||||
group->interleaved_buffer = sinkpad->data;
|
||||
group->interleaved_map.data = sinkpad->map.data;
|
||||
/* allocate buffer for de-interleaving */
|
||||
if (!group->buffer || group->channels < sinkpad->channels
|
||||
|| group->nframes < samples_avail) {
|
||||
|
@ -674,7 +668,7 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
|
|||
group->nframes = samples_avail;
|
||||
gst_signal_processor_deinterleave_group (group, samples_avail);
|
||||
} else {
|
||||
self->audio_in[sinkpad->index] = sinkpad->data;
|
||||
self->audio_in[sinkpad->index] = sinkpad->map;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -726,7 +720,7 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
|
|||
g_assert (sinkpad->samples_avail == samples_avail);
|
||||
srcpad->pen = sinkpad->pen;
|
||||
sinkpad->pen = NULL;
|
||||
self->audio_out[srcpad->index] = sinkpad->data;
|
||||
self->audio_out[srcpad->index] = sinkpad->map;
|
||||
self->pending_out++;
|
||||
|
||||
srcs = srcs->next;
|
||||
|
@ -750,9 +744,7 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
|
|||
|
||||
if (srcpad->channels > 1) {
|
||||
GstSignalProcessorGroup *group = &self->group_out[out_group_index++];
|
||||
group->interleaved_buffer =
|
||||
(gfloat *) gst_buffer_map (srcpad->pen, NULL, NULL,
|
||||
GST_MAP_READWRITE);
|
||||
gst_buffer_map (srcpad->pen, &group->interleaved_map, GST_MAP_READWRITE);
|
||||
if (!group->buffer || group->channels < srcpad->channels
|
||||
|| group->nframes < samples_avail)
|
||||
group->buffer =
|
||||
|
@ -762,8 +754,7 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
|
|||
group->nframes = samples_avail;
|
||||
self->pending_out++;
|
||||
} else {
|
||||
self->audio_out[srcpad->index] =
|
||||
(gfloat *) gst_buffer_map (srcpad->pen, NULL, NULL,
|
||||
gst_buffer_map (srcpad->pen, &self->audio_out[srcpad->index],
|
||||
GST_MAP_READWRITE);
|
||||
self->pending_out++;
|
||||
}
|
||||
|
@ -804,13 +795,13 @@ gst_signal_processor_update_inputs (GstSignalProcessor * self, guint nprocessed)
|
|||
if (!sinkpad->pen) {
|
||||
/* this buffer was used up */
|
||||
self->pending_in++;
|
||||
sinkpad->data = NULL;
|
||||
sinkpad->map.data = NULL;
|
||||
sinkpad->samples_avail = 0;
|
||||
} else {
|
||||
/* advance ->data pointers and decrement ->samples_avail, unreffing buffer
|
||||
if no samples are left */
|
||||
sinkpad->samples_avail -= nprocessed;
|
||||
sinkpad->data += nprocessed * sinkpad->channels; /* gfloat* arithmetic */
|
||||
sinkpad->map.data += nprocessed * sinkpad->channels; /* gfloat* arithmetic */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -864,16 +855,14 @@ gst_signal_processor_pen_buffer (GstSignalProcessor * self, GstPad * pad,
|
|||
GstBuffer * buffer)
|
||||
{
|
||||
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) pad;
|
||||
gsize size;
|
||||
|
||||
if (spad->pen)
|
||||
goto had_buffer;
|
||||
|
||||
/* keep the reference */
|
||||
spad->pen = buffer;
|
||||
spad->data =
|
||||
(gfloat *) gst_buffer_map (buffer, &size, NULL, GST_MAP_READWRITE);
|
||||
spad->samples_avail = size / sizeof (float) / spad->channels;
|
||||
gst_buffer_map (buffer, &spad->map, GST_MAP_READWRITE);
|
||||
spad->samples_avail = spad->map.size / sizeof (float) / spad->channels;
|
||||
|
||||
g_assert (self->pending_in != 0);
|
||||
|
||||
|
@ -906,10 +895,9 @@ gst_signal_processor_flush (GstSignalProcessor * self)
|
|||
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) pads->data;
|
||||
|
||||
if (spad->pen) {
|
||||
gst_buffer_unmap (spad->pen, spad->data, -1);
|
||||
gst_buffer_unmap (spad->pen, &spad->map);
|
||||
gst_buffer_unref (spad->pen);
|
||||
spad->pen = NULL;
|
||||
spad->data = NULL;
|
||||
spad->samples_avail = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ typedef struct _GstSignalProcessorClass GstSignalProcessorClass;
|
|||
struct _GstSignalProcessorGroup {
|
||||
guint channels; /**< Number of channels in buffers */
|
||||
guint nframes; /**< Number of frames currently allocated per channel */
|
||||
gfloat *interleaved_buffer; /**< Interleaved buffer (c1c2c1c2...)*/
|
||||
GstMapInfo interleaved_map; /**< Interleaved buffer (c1c2c1c2...)*/
|
||||
gfloat *buffer; /**< De-interleaved buffer (c1c1...c2c2...) */
|
||||
};
|
||||
|
||||
|
@ -94,13 +94,9 @@ struct _GstSignalProcessor {
|
|||
GstSignalProcessorGroup *group_out;
|
||||
|
||||
/* single channel signal pads */
|
||||
gfloat **audio_in;
|
||||
gfloat **audio_out;
|
||||
GstMapInfo *audio_in;
|
||||
GstMapInfo *audio_out;
|
||||
|
||||
/* controls */
|
||||
gfloat *control_in;
|
||||
gfloat *control_out;
|
||||
|
||||
/* sampling rate */
|
||||
gint sample_rate;
|
||||
|
||||
|
@ -114,8 +110,6 @@ struct _GstSignalProcessorClass {
|
|||
guint num_group_out;
|
||||
guint num_audio_in;
|
||||
guint num_audio_out;
|
||||
guint num_control_in;
|
||||
guint num_control_out;
|
||||
|
||||
guint flags;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue