Commit 583d39dd authored by Wim Taymans's avatar Wim Taymans

update for new memory API

parent 77d6229a
......@@ -328,24 +328,23 @@ static gboolean
gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer,
gboolean start_tag, guint * tag_size)
{
guint8 *data;
gsize size;
GstMapInfo map;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
if (memcmp (data, "APETAGEX", 8) != 0) {
if (memcmp (map.data, "APETAGEX", 8) != 0) {
GST_DEBUG_OBJECT (demux, "No APETAGEX marker at %s - not an APE file",
(start_tag) ? "start" : "end");
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
return FALSE;
}
*tag_size = GST_READ_UINT32_LE (data + 12);
*tag_size = GST_READ_UINT32_LE (map.data + 12);
/* size is without header, so add 32 to account for that */
*tag_size += 32;
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
return TRUE;
}
......@@ -354,15 +353,18 @@ static GstTagDemuxResult
gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
gboolean start_tag, guint * tag_size, GstTagList ** tags)
{
guint8 *data_start, *data;
guint8 *data;
guint8 *footer;
gboolean have_header;
gboolean end_tag = !start_tag;
GstCaps *sink_caps;
guint version, footer_size;
GstMapInfo map;
gsize size;
data_start = data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
data = map.data;
size = map.size;
GST_LOG_OBJECT (demux, "Parsing buffer of size %" G_GSIZE_FORMAT, size);
......@@ -425,7 +427,7 @@ gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
GST_TAG_CONTAINER_FORMAT, sink_caps);
gst_caps_unref (sink_caps);
gst_buffer_unmap (buffer, data_start, size);
gst_buffer_unmap (buffer, &map);
return GST_TAG_DEMUX_RESULT_OK;
}
......
......@@ -448,8 +448,7 @@ gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
guint num_samples;
GstClockTime timestamp, stream_time;
guint8 *data;
gsize size;
GstMapInfo map;
timestamp = GST_BUFFER_TIMESTAMP (buf);
stream_time =
......@@ -465,12 +464,12 @@ gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
return GST_FLOW_OK;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
filter->process (filter, data, num_samples);
filter->process (filter, map.data, num_samples);
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return GST_FLOW_OK;
}
......@@ -691,8 +691,7 @@ gst_audio_dynamic_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GstAudioDynamic *filter = GST_AUDIO_DYNAMIC (base);
guint num_samples;
GstClockTime timestamp, stream_time;
guint8 *data;
gsize size;
GstMapInfo map;
timestamp = GST_BUFFER_TIMESTAMP (buf);
stream_time =
......@@ -708,12 +707,12 @@ gst_audio_dynamic_transform_ip (GstBaseTransform * base, GstBuffer * buf)
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
return GST_FLOW_OK;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
filter->process (filter, data, num_samples);
filter->process (filter, map.data, num_samples);
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return GST_FLOW_OK;
}
......@@ -359,8 +359,7 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GstAudioEcho *self = GST_AUDIO_ECHO (base);
guint num_samples;
GstClockTime timestamp, stream_time;
guint8 *data;
gsize size;
GstMapInfo map;
timestamp = GST_BUFFER_TIMESTAMP (buf);
stream_time =
......@@ -393,12 +392,12 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
}
}
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
num_samples = size / GST_AUDIO_FILTER_BPS (self);
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
num_samples = map.size / GST_AUDIO_FILTER_BPS (self);
self->process (self, data, num_samples);
self->process (self, map.data, num_samples);
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return GST_FLOW_OK;
}
......@@ -626,8 +626,8 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
gint channels = GST_AUDIO_FILTER_CHANNELS (self);
gint bps = GST_AUDIO_FILTER_BPS (self);
gint outsize, outsamples;
guint8 *in, *out, *data;
gsize size;
GstMapInfo map;
guint8 *in, *out;
if (channels == 0 || rate == 0 || self->nsamples_in == 0) {
self->buffer_fill = 0;
......@@ -668,16 +668,16 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
/* Convolve the residue with zeros to get the actual remaining data */
in = g_new0 (guint8, outsize);
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
self->nsamples_out += self->process (self, in, data, outsamples);
gst_buffer_unmap (outbuf, data, size);
gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
self->nsamples_out += self->process (self, in, map.data, outsamples);
gst_buffer_unmap (outbuf, &map);
g_free (in);
} else {
guint gensamples = 0;
outbuf = gst_buffer_new_and_alloc (outsize);
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
while (gensamples < outsamples) {
guint step_insamples = self->block_length - self->buffer_fill;
......@@ -688,7 +688,7 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
step_gensamples = self->process (self, zeroes, out, step_insamples);
g_free (zeroes);
memcpy (data + gensamples * bps, out, MIN (step_gensamples,
memcpy (map.data + gensamples * bps, out, MIN (step_gensamples,
outsamples - gensamples) * bps);
gensamples += MIN (step_gensamples, outsamples - gensamples);
......@@ -696,7 +696,7 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
}
self->nsamples_out += gensamples;
gst_buffer_unmap (outbuf, data, size);
gst_buffer_unmap (outbuf, &map);
}
/* Set timestamp, offset, etc from the values we
......@@ -802,8 +802,7 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
gint channels = GST_AUDIO_FILTER_CHANNELS (self);
gint rate = GST_AUDIO_FILTER_RATE (self);
gint bps = GST_AUDIO_FILTER_BPS (self);
guint8 *indata, *outdata;
gsize insize, outsize;
GstMapInfo inmap, outmap;
guint input_samples;
guint output_samples;
guint generated_samples;
......@@ -858,18 +857,19 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
self->start_off = GST_BUFFER_OFFSET (inbuf);
}
indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
gst_buffer_map (inbuf, &inmap, GST_MAP_READ);
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
input_samples = (insize / bps) / channels;
output_samples = (outsize / bps) / channels;
input_samples = (inmap.size / bps) / channels;
output_samples = (outmap.size / bps) / channels;
self->nsamples_in += input_samples;
generated_samples = self->process (self, indata, outdata, input_samples);
generated_samples =
self->process (self, inmap.data, outmap.data, input_samples);
gst_buffer_unmap (inbuf, indata, insize);
gst_buffer_unmap (outbuf, outdata, outsize);
gst_buffer_unmap (inbuf, &inmap);
gst_buffer_unmap (outbuf, &outmap);
g_assert (generated_samples <= output_samples);
self->nsamples_out += generated_samples;
......
......@@ -354,8 +354,7 @@ gst_audio_fx_base_iir_filter_transform_ip (GstBaseTransform * base,
GstAudioFXBaseIIRFilter *filter = GST_AUDIO_FX_BASE_IIR_FILTER (base);
guint num_samples;
GstClockTime timestamp, stream_time;
guint8 *data;
gsize size;
GstMapInfo map;
timestamp = GST_BUFFER_TIMESTAMP (buf);
stream_time =
......@@ -372,12 +371,12 @@ gst_audio_fx_base_iir_filter_transform_ip (GstBaseTransform * base,
g_return_val_if_fail (filter->a != NULL, GST_FLOW_ERROR);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
filter->process (filter, data, num_samples);
filter->process (filter, map.data, num_samples);
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return GST_FLOW_OK;
}
......
......@@ -228,8 +228,7 @@ gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GstAudioInvert *filter = GST_AUDIO_INVERT (base);
guint num_samples;
GstClockTime timestamp, stream_time;
guint8 *data;
gsize size;
GstMapInfo map;
timestamp = GST_BUFFER_TIMESTAMP (buf);
stream_time =
......@@ -245,12 +244,12 @@ gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
return GST_FLOW_OK;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
filter->process (filter, data, num_samples);
filter->process (filter, map.data, num_samples);
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return GST_FLOW_OK;
}
......@@ -331,8 +331,7 @@ gst_audio_karaoke_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GstAudioKaraoke *filter = GST_AUDIO_KARAOKE (base);
guint num_samples;
GstClockTime timestamp, stream_time;
guint8 *data;
gsize size;
GstMapInfo map;
timestamp = GST_BUFFER_TIMESTAMP (buf);
stream_time =
......@@ -348,12 +347,12 @@ gst_audio_karaoke_transform_ip (GstBaseTransform * base, GstBuffer * buf)
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
return GST_FLOW_OK;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
filter->process (filter, data, num_samples);
filter->process (filter, map.data, num_samples);
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return GST_FLOW_OK;
}
......@@ -626,8 +626,7 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
{
GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
GstClockTime timestamp, stream_time;
guint8 *indata, *outdata;
gsize insize, outsize;
GstMapInfo inmap, outmap;
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
stream_time =
......@@ -639,20 +638,20 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
if (GST_CLOCK_TIME_IS_VALID (stream_time))
gst_object_sync_values (GST_OBJECT (filter), stream_time);
indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
gst_buffer_map (inbuf, &inmap, GST_MAP_READ);
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
memset (outdata, 0, outsize);
memset (outmap.data, 0, outmap.size);
} else {
guint num_samples = outsize / GST_AUDIO_INFO_BPF (&filter->info);
guint num_samples = outmap.size / GST_AUDIO_INFO_BPF (&filter->info);
filter->process (filter, indata, outdata, num_samples);
filter->process (filter, inmap.data, outmap.data, num_samples);
}
gst_buffer_unmap (inbuf, indata, insize);
gst_buffer_unmap (outbuf, outdata, outsize);
gst_buffer_unmap (inbuf, &inmap);
gst_buffer_unmap (outbuf, &outmap);
return GST_FLOW_OK;
}
......@@ -257,20 +257,19 @@ gst_aac_parse_sink_setcaps (GstBaseParse * parse, GstCaps * caps)
GstBuffer *buf = gst_value_get_buffer (value);
if (buf) {
guint8 *data;
gsize size;
GstMapInfo map;
guint sr_idx;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_buffer_map (buf, &map, GST_MAP_READ);
sr_idx = ((data[0] & 0x07) << 1) | ((data[1] & 0x80) >> 7);
aacparse->object_type = (data[0] & 0xf8) >> 3;
sr_idx = ((map.data[0] & 0x07) << 1) | ((map.data[1] & 0x80) >> 7);
aacparse->object_type = (map.data[0] & 0xf8) >> 3;
aacparse->sample_rate = gst_aac_parse_get_sample_rate_from_index (sr_idx);
aacparse->channels = (data[1] & 0x78) >> 3;
aacparse->channels = (map.data[1] & 0x78) >> 3;
aacparse->header_type = DSPAAC_HEADER_NONE;
aacparse->mpegversion = 4;
aacparse->frame_samples = (data[1] & 4) ? 960 : 1024;
gst_buffer_unmap (buf, data, size);
aacparse->frame_samples = (map.data[1] & 4) ? 960 : 1024;
gst_buffer_unmap (buf, &map);
GST_DEBUG ("codec_data: object_type=%d, sample_rate=%d, channels=%d, "
"samples=%d", aacparse->object_type, aacparse->sample_rate,
......@@ -913,8 +912,7 @@ static gboolean
gst_aac_parse_check_valid_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
{
guint8 *data;
gsize size;
GstMapInfo map;
GstAacParse *aacparse;
gboolean ret = FALSE;
gboolean lost_sync;
......@@ -923,25 +921,25 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
aacparse = GST_AAC_PARSE (parse);
buffer = frame->buffer;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
lost_sync = GST_BASE_PARSE_LOST_SYNC (parse);
if (aacparse->header_type == DSPAAC_HEADER_ADIF ||
aacparse->header_type == DSPAAC_HEADER_NONE) {
/* There is nothing to parse */
*framesize = size;
*framesize = map.size;
ret = TRUE;
} else if (aacparse->header_type == DSPAAC_HEADER_NOT_PARSED || lost_sync) {
ret = gst_aac_parse_detect_stream (aacparse, data, size,
ret = gst_aac_parse_detect_stream (aacparse, map.data, map.size,
GST_BASE_PARSE_DRAINING (parse), framesize, skipsize);
} else if (aacparse->header_type == DSPAAC_HEADER_ADTS) {
guint needed_data = 1024;
ret = gst_aac_parse_check_adts_frame (aacparse, data, size,
ret = gst_aac_parse_check_adts_frame (aacparse, map.data, map.size,
GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
if (!ret) {
......@@ -953,8 +951,8 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
} else if (aacparse->header_type == DSPAAC_HEADER_LOAS) {
guint needed_data = 1024;
ret = gst_aac_parse_check_loas_frame (aacparse, data,
size, GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
ret = gst_aac_parse_check_loas_frame (aacparse, map.data,
map.size, GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
if (!ret) {
GST_DEBUG ("buffer didn't contain valid frame");
......@@ -967,7 +965,7 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),
ADTS_MAX_SIZE);
}
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
return ret;
}
......@@ -1003,8 +1001,7 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
GstBuffer *buffer;
GstFlowReturn ret = GST_FLOW_OK;
gint rate, channels;
guint8 *data;
gsize size;
GstMapInfo map;
aacparse = GST_AAC_PARSE (parse);
buffer = frame->buffer;
......@@ -1013,10 +1010,10 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
/* see above */
frame->overhead = 7;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_aac_parse_parse_adts_header (aacparse, data,
gst_buffer_map (buffer, &map, GST_MAP_READ);
gst_aac_parse_parse_adts_header (aacparse, map.data,
&rate, &channels, NULL, NULL);
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
GST_LOG_OBJECT (aacparse, "rate: %d, chans: %d", rate, channels);
......@@ -1043,9 +1040,9 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
/* see above */
frame->overhead = 3;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
if (!gst_aac_parse_read_loas_config (aacparse, data, size, &rate, &channels,
NULL)) {
gst_buffer_map (buffer, &map, GST_MAP_READ);
if (!gst_aac_parse_read_loas_config (aacparse, map.data, map.size, &rate,
&channels, NULL)) {
GST_WARNING_OBJECT (aacparse, "Error reading LOAS config");
} else if (G_UNLIKELY (rate != aacparse->sample_rate
|| channels != aacparse->channels)) {
......@@ -1055,7 +1052,7 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
GST_INFO_OBJECT (aacparse, "New LOAS config: %d Hz, %d channels", rate,
channels);
}
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
/* We want to set caps both at start, and when rate/channels change.
Since only some LOAS frames have that info, we may receive frames
......
......@@ -298,15 +298,14 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
guint * sid)
{
GstBitReader bits;
gpointer data;
gsize size;
GstMapInfo map;
guint8 fscod, frmsizcod, bsid, acmod, lfe_on, rate_scale;
gboolean ret = FALSE;
GST_LOG_OBJECT (ac3parse, "parsing ac3");
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_bit_reader_init (&bits, data, size);
gst_buffer_map (buf, &map, GST_MAP_READ);
gst_bit_reader_init (&bits, map.data, map.size);
gst_bit_reader_skip_unchecked (&bits, skip * 8);
gst_bit_reader_skip_unchecked (&bits, 16 + 16);
......@@ -360,7 +359,7 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
ret = TRUE;
cleanup:
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return ret;
}
......@@ -371,16 +370,15 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
guint * sid)
{
GstBitReader bits;
gpointer data;
gsize size;
GstMapInfo map;
guint16 frmsiz, sample_rate, blocks;
guint8 strmtyp, fscod, fscod2, acmod, lfe_on, strmid, numblkscod;
gboolean ret = FALSE;
GST_LOG_OBJECT (ac3parse, "parsing e-ac3");
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_bit_reader_init (&bits, data, size);
gst_buffer_map (buf, &map, GST_MAP_READ);
gst_bit_reader_init (&bits, map.data, map.size);
gst_bit_reader_skip_unchecked (&bits, skip * 8);
gst_bit_reader_skip_unchecked (&bits, 16);
......@@ -426,7 +424,7 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
ret = TRUE;
cleanup:
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return ret;
}
......@@ -439,14 +437,13 @@ gst_ac3_parse_frame_header (GstAc3Parse * parse, GstBuffer * buf, gint skip,
GstBitReader bits;
guint16 sync;
guint8 bsid;
gpointer data;
gsize size;
GstMapInfo map;
gboolean ret = FALSE;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_bit_reader_init (&bits, data, size);
gst_buffer_map (buf, &map, GST_MAP_READ);
gst_bit_reader_init (&bits, map.data, map.size);
GST_MEMDUMP_OBJECT (parse, "AC3 frame sync", data, MIN (size, 16));
GST_MEMDUMP_OBJECT (parse, "AC3 frame sync", map.data, MIN (map.size, 16));
gst_bit_reader_skip_unchecked (&bits, skip * 8);
......@@ -479,7 +476,7 @@ gst_ac3_parse_frame_header (GstAc3Parse * parse, GstBuffer * buf, gint skip,
GST_DEBUG_OBJECT (parse, "unexpected bsid %d", bsid);
cleanup:
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return ret;
}
......@@ -495,24 +492,23 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
gboolean lost_sync, draining, eac, more = FALSE;
guint frmsiz, blocks, sid;
gint have_blocks = 0;
gpointer data;
gsize size;
GstMapInfo map;
gboolean ret = FALSE;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_buffer_map (buf, &map, GST_MAP_READ);
if (G_UNLIKELY (size < 6))
if (G_UNLIKELY (map.size < 6))
goto cleanup;
gst_byte_reader_init (&reader, data, size);
gst_byte_reader_init (&reader, map.data, map.size);
off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffff0000, 0x0b770000,
0, size);
0, map.size);
GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
/* didn't find anything that looks like a sync word, skip */
if (off < 0) {
*skipsize = size - 3;
*skipsize = map.size - 3;
goto cleanup;
}
......@@ -562,7 +558,8 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
do {
*framesize += frmsiz;
if (!gst_byte_reader_skip (&reader, frmsiz) || size < (*framesize + 6)) {
if (!gst_byte_reader_skip (&reader, frmsiz)
|| map.size < (*framesize + 6)) {
more = TRUE;
break;
}
......@@ -605,7 +602,7 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
ret = TRUE;
cleanup:
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return ret;
}
......
......@@ -259,8 +259,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
{
GstBuffer *buffer;
guint8 *data;
gsize size;
GstMapInfo map;
gint fsize, mode, dsize;
GstAmrParse *amrparse;
gboolean ret = FALSE;
......@@ -268,14 +267,14 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
amrparse = GST_AMR_PARSE (parse);
buffer = frame->buffer;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
dsize = size;
gst_buffer_map (buffer, &map, GST_MAP_READ);
dsize = map.size;
GST_LOG ("buffer: %d bytes", dsize);
if (amrparse->need_header) {
if (dsize >= AMR_MIME_HEADER_SIZE &&
gst_amr_parse_parse_header (amrparse, data, skipsize)) {
gst_amr_parse_parse_header (amrparse, map.data, skipsize)) {
amrparse->need_header = FALSE;
gst_base_parse_set_frame_rate (GST_BASE_PARSE (amrparse), 50, 1, 2, 2);
} else {
......@@ -287,9 +286,9 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
}
/* Does this look like a possible frame header candidate? */
if ((data[0] & 0x83) == 0) {
if ((map.data[0] & 0x83) == 0) {
/* Yep. Retrieve the frame size */
mode = (data[0] >> 3) & 0x0F;
mode = (map.data[0] >> 3) & 0x0F;
fsize = amrparse->block_size[mode] + 1; /* +1 for the header byte */
/* We recognize this data as a valid frame when:
......@@ -307,7 +306,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
found = TRUE;
} else if (dsize > fsize) {
/* enough data, check for next sync */
if ((data[fsize] & 0x83) == 0)
if ((map.data[fsize] & 0x83) == 0)
found = TRUE;
} else if (GST_BASE_PARSE_DRAINING (parse)) {
/* not enough, but draining, so ok */
......@@ -326,7 +325,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
GST_LOG ("sync lost");
done:
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
return ret;
}
......
......@@ -318,31 +318,30 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
guint32 sync = 0;
guint size, rate, chans, num_blocks, samples_per_block;
gint off = -1;
gpointer data;
gsize bufsize;
GstMapInfo map;
gboolean ret = FALSE;
data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
gst_buffer_map (buf, &map, GST_MAP_READ);