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
eeea3f27ea
commit
56a07a14b5
21 changed files with 287 additions and 286 deletions
|
@ -498,8 +498,7 @@ gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
|
|||
gboolean need_reneg = FALSE;
|
||||
gint chans;
|
||||
gint length = 0, flags, sample_rate, bit_rate;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
GstBuffer *outbuf;
|
||||
const gint num_blocks = 6;
|
||||
|
@ -511,8 +510,8 @@ gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
|
|||
return GST_FLOW_OK;
|
||||
|
||||
/* parsed stuff already, so this should work out fine */
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
g_assert (size >= 7);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
g_assert (map.size >= 7);
|
||||
|
||||
/* re-obtain some sync header info,
|
||||
* should be same as during _parse and could also be cached there,
|
||||
|
@ -520,8 +519,8 @@ gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
|
|||
bit_rate = a52dec->bit_rate;
|
||||
sample_rate = a52dec->sample_rate;
|
||||
flags = 0;
|
||||
length = a52_syncinfo (data, &flags, &sample_rate, &bit_rate);
|
||||
g_assert (length == size);
|
||||
length = a52_syncinfo (map.data, &flags, &sample_rate, &bit_rate);
|
||||
g_assert (length == map.size);
|
||||
|
||||
/* update stream information, renegotiate or re-streaminfo if needed */
|
||||
need_reneg = FALSE;
|
||||
|
@ -591,13 +590,13 @@ gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
|
|||
/* process */
|
||||
flags |= A52_ADJUST_LEVEL;
|
||||
a52dec->level = 1;
|
||||
if (a52_frame (a52dec->state, data, &flags, &a52dec->level, a52dec->bias)) {
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
if (a52_frame (a52dec->state, map.data, &flags, &a52dec->level, a52dec->bias)) {
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
GST_AUDIO_DECODER_ERROR (a52dec, 1, STREAM, DECODE, (NULL),
|
||||
("a52_frame error"), result);
|
||||
goto exit;
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
channels = flags & (A52_CHANNEL_MASK | A52_LFE);
|
||||
if (a52dec->using_channels != channels) {
|
||||
|
@ -628,16 +627,16 @@ gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
|
|||
outbuf =
|
||||
gst_buffer_new_and_alloc (256 * chans * (SAMPLE_WIDTH / 8) * num_blocks);
|
||||
|
||||
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
{
|
||||
guint8 *ptr = data;
|
||||
guint8 *ptr = map.data;
|
||||
for (i = 0; i < num_blocks; i++) {
|
||||
if (a52_block (a52dec->state)) {
|
||||
/* also marks discont */
|
||||
GST_AUDIO_DECODER_ERROR (a52dec, 1, STREAM, DECODE, (NULL),
|
||||
("error decoding block %d", i), result);
|
||||
if (result != GST_FLOW_OK) {
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
goto exit;
|
||||
}
|
||||
} else {
|
||||
|
@ -654,7 +653,7 @@ gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
|
|||
ptr += 256 * chans * (SAMPLE_WIDTH / 8);
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
result = gst_audio_decoder_finish_frame (bdec, outbuf, 1);
|
||||
|
||||
|
|
|
@ -282,8 +282,7 @@ static GstFlowReturn
|
|||
gst_amrnbdec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
|
||||
{
|
||||
GstAmrnbDec *amrnbdec;
|
||||
guint8 *data;
|
||||
short *out_data;
|
||||
GstMapInfo inmap, outmap;
|
||||
GstBuffer *out;
|
||||
|
||||
amrnbdec = GST_AMRNBDEC (dec);
|
||||
|
@ -295,16 +294,17 @@ gst_amrnbdec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
|
|||
if (amrnbdec->rate == 0 || amrnbdec->channels == 0)
|
||||
goto not_negotiated;
|
||||
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &inmap, GST_MAP_READ);
|
||||
|
||||
/* get output */
|
||||
out = gst_buffer_new_and_alloc (160 * 2);
|
||||
/* decode */
|
||||
out_data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
|
||||
Decoder_Interface_Decode (amrnbdec->handle, data, out_data, 0);
|
||||
gst_buffer_unmap (out, out_data, 160 * 2);
|
||||
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
|
||||
Decoder_Interface_Decode (amrnbdec->handle, inmap.data,
|
||||
(gint16 *) outmap.data, 0);
|
||||
gst_buffer_unmap (out, &outmap);
|
||||
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &inmap);
|
||||
|
||||
return gst_audio_decoder_finish_frame (dec, out, 1);
|
||||
|
||||
|
|
|
@ -241,9 +241,8 @@ gst_amrnbenc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
|||
GstAmrnbEnc *amrnbenc;
|
||||
GstFlowReturn ret;
|
||||
GstBuffer *out;
|
||||
short *in_data;
|
||||
guint8 *out_data;
|
||||
gsize in_size, out_size;
|
||||
GstMapInfo in_map, out_map;
|
||||
gsize out_size;
|
||||
|
||||
amrnbenc = GST_AMRNBENC (enc);
|
||||
|
||||
|
@ -255,12 +254,12 @@ gst_amrnbenc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
|||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
in_data = gst_buffer_map (buffer, &in_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &in_map, GST_MAP_READ);
|
||||
|
||||
if (G_UNLIKELY (in_size < 320)) {
|
||||
gst_buffer_unmap (buffer, in_data, -1);
|
||||
if (G_UNLIKELY (in_map.size < 320)) {
|
||||
gst_buffer_unmap (buffer, &in_map);
|
||||
GST_DEBUG_OBJECT (amrnbenc, "discarding trailing data of %" G_GSIZE_FORMAT
|
||||
" bytes", in_size);
|
||||
" bytes", in_map.size);
|
||||
return gst_audio_encoder_finish_frame (enc, NULL, -1);
|
||||
}
|
||||
|
||||
|
@ -269,13 +268,14 @@ gst_amrnbenc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
|||
/* AMR encoder actually writes into the source data buffers it gets */
|
||||
/* should be able to handle that with what we are given */
|
||||
|
||||
out_data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (out, &out_map, GST_MAP_WRITE);
|
||||
/* encode */
|
||||
out_size =
|
||||
Encoder_Interface_Encode (amrnbenc->handle, amrnbenc->bandmode,
|
||||
in_data, out_data, 0);
|
||||
gst_buffer_unmap (out, out_data, out_size);
|
||||
gst_buffer_unmap (buffer, in_data, -1);
|
||||
(short *) in_map.data, out_map.data, 0);
|
||||
gst_buffer_unmap (out, &out_map);
|
||||
gst_buffer_resize (out, 0, out_size);
|
||||
gst_buffer_unmap (buffer, &in_map);
|
||||
|
||||
GST_LOG_OBJECT (amrnbenc, "output data size %" G_GSIZE_FORMAT, out_size);
|
||||
|
||||
|
|
|
@ -205,8 +205,7 @@ gst_amrwbdec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
|
|||
{
|
||||
GstAmrwbDec *amrwbdec;
|
||||
GstBuffer *out;
|
||||
guint8 *data;
|
||||
Word16 *outdata;
|
||||
GstMapInfo inmap, outmap;
|
||||
|
||||
amrwbdec = GST_AMRWBDEC (dec);
|
||||
|
||||
|
@ -219,17 +218,18 @@ gst_amrwbdec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
|
|||
|
||||
/* the library seems to write into the source data, hence the copy. */
|
||||
/* should be no problem */
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &inmap, GST_MAP_READ);
|
||||
|
||||
/* get output */
|
||||
out = gst_buffer_new_and_alloc (sizeof (gint16) * L_FRAME16k);
|
||||
outdata = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
|
||||
|
||||
/* decode */
|
||||
D_IF_decode (amrwbdec->handle, (unsigned char *) data, outdata, _good_frame);
|
||||
D_IF_decode (amrwbdec->handle, (unsigned char *) inmap.data,
|
||||
(short int *) outmap.data, _good_frame);
|
||||
|
||||
gst_buffer_unmap (out, outdata, sizeof (gint16) * L_FRAME16k);
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (out, &outmap);
|
||||
gst_buffer_unmap (buffer, &inmap);
|
||||
|
||||
/* send out */
|
||||
return gst_audio_decoder_finish_frame (dec, out, 1);
|
||||
|
|
|
@ -738,7 +738,7 @@ gst_dvd_read_src_read (GstDvdReadSrc * src, gint angle, gint new_seek,
|
|||
gint len;
|
||||
gint retries;
|
||||
gint64 next_time;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
seg = &(GST_BASE_SRC (src)->segment);
|
||||
|
||||
|
@ -846,14 +846,16 @@ nav_retry:
|
|||
GST_LOG_OBJECT (src, "Going to read %u sectors @ pack %d", cur_output_size,
|
||||
src->cur_pack);
|
||||
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
/* read in and output cursize packs */
|
||||
len = DVDReadBlocks (src->dvd_title, src->cur_pack, cur_output_size, data);
|
||||
len =
|
||||
DVDReadBlocks (src->dvd_title, src->cur_pack, cur_output_size, map.data);
|
||||
|
||||
if (len != cur_output_size)
|
||||
goto block_read_error;
|
||||
|
||||
gst_buffer_unmap (buf, data, cur_output_size * DVD_VIDEO_LB_LEN);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_resize (buf, 0, cur_output_size * DVD_VIDEO_LB_LEN);
|
||||
/* GST_BUFFER_OFFSET (buf) = priv->cur_pack * DVD_VIDEO_LB_LEN; */
|
||||
GST_BUFFER_TIMESTAMP (buf) =
|
||||
gst_dvd_read_src_get_time_for_sector (src, src->cur_pack);
|
||||
|
@ -889,7 +891,7 @@ block_read_error:
|
|||
{
|
||||
GST_ERROR_OBJECT (src, "Read failed for %d blocks at %d",
|
||||
cur_output_size, src->cur_pack);
|
||||
gst_buffer_unmap (buf, data, 0);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return GST_DVD_READ_ERROR;
|
||||
}
|
||||
|
|
|
@ -701,8 +701,8 @@ static GstFlowReturn
|
|||
gst_lamemp3enc_flush_full (GstLameMP3Enc * lame, gboolean push)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
GstMapInfo map;
|
||||
gint size;
|
||||
guint8 *data;
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
gint av;
|
||||
|
||||
|
@ -710,15 +710,16 @@ gst_lamemp3enc_flush_full (GstLameMP3Enc * lame, gboolean push)
|
|||
return GST_FLOW_OK;
|
||||
|
||||
buf = gst_buffer_new_and_alloc (7200);
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
size = lame_encode_flush (lame->lgf, data, 7200);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
size = lame_encode_flush (lame->lgf, map.data, 7200);
|
||||
|
||||
if (size > 0) {
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_resize (buf, 0, size);
|
||||
GST_DEBUG_OBJECT (lame, "collecting final %d bytes", size);
|
||||
gst_adapter_push (lame->adapter, buf);
|
||||
} else {
|
||||
gst_buffer_unmap (buf, data, 0);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
GST_DEBUG_OBJECT (lame, "no final packet (size=%d, push=%d)", size, push);
|
||||
gst_buffer_unref (buf);
|
||||
result = GST_FLOW_OK;
|
||||
|
@ -752,13 +753,11 @@ static GstFlowReturn
|
|||
gst_lamemp3enc_handle_frame (GstAudioEncoder * enc, GstBuffer * in_buf)
|
||||
{
|
||||
GstLameMP3Enc *lame;
|
||||
guchar *mp3_data;
|
||||
gint mp3_buffer_size, mp3_size;
|
||||
GstBuffer *mp3_buf;
|
||||
GstFlowReturn result;
|
||||
gint num_samples;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo in_map, mp3_map;
|
||||
|
||||
lame = GST_LAMEMP3ENC (enc);
|
||||
|
||||
|
@ -766,38 +765,39 @@ gst_lamemp3enc_handle_frame (GstAudioEncoder * enc, GstBuffer * in_buf)
|
|||
if (G_UNLIKELY (in_buf == NULL))
|
||||
return gst_lamemp3enc_flush_full (lame, TRUE);
|
||||
|
||||
data = gst_buffer_map (in_buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (in_buf, &in_map, GST_MAP_READ);
|
||||
|
||||
num_samples = size / 2;
|
||||
num_samples = in_map.size / 2;
|
||||
|
||||
/* allocate space for output */
|
||||
mp3_buffer_size = 1.25 * num_samples + 7200;
|
||||
mp3_buf = gst_buffer_new_allocate (NULL, mp3_buffer_size, 0);
|
||||
mp3_data = gst_buffer_map (mp3_buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (mp3_buf, &mp3_map, GST_MAP_WRITE);
|
||||
|
||||
/* lame seems to be too stupid to get mono interleaved going */
|
||||
if (lame->num_channels == 1) {
|
||||
mp3_size = lame_encode_buffer (lame->lgf,
|
||||
(short int *) data,
|
||||
(short int *) data, num_samples, mp3_data, mp3_buffer_size);
|
||||
(short int *) in_map.data,
|
||||
(short int *) in_map.data, num_samples, mp3_map.data, mp3_buffer_size);
|
||||
} else {
|
||||
mp3_size = lame_encode_buffer_interleaved (lame->lgf,
|
||||
(short int *) data,
|
||||
num_samples / lame->num_channels, mp3_data, mp3_buffer_size);
|
||||
(short int *) in_map.data,
|
||||
num_samples / lame->num_channels, mp3_map.data, mp3_buffer_size);
|
||||
}
|
||||
gst_buffer_unmap (in_buf, data, size);
|
||||
gst_buffer_unmap (in_buf, &in_map);
|
||||
|
||||
GST_LOG_OBJECT (lame, "encoded %" G_GSIZE_FORMAT " bytes of audio "
|
||||
"to %d bytes of mp3", size, mp3_size);
|
||||
"to %d bytes of mp3", in_map.size, mp3_size);
|
||||
|
||||
if (G_LIKELY (mp3_size > 0)) {
|
||||
/* unfortunately lame does not provide frame delineated output,
|
||||
* so collect output and parse into frames ... */
|
||||
gst_buffer_unmap (mp3_buf, mp3_data, mp3_size);
|
||||
gst_buffer_unmap (mp3_buf, &mp3_map);
|
||||
gst_buffer_resize (mp3_buf, 0, mp3_size);
|
||||
gst_adapter_push (lame->adapter, mp3_buf);
|
||||
result = gst_lamemp3enc_finish_frames (lame);
|
||||
} else {
|
||||
gst_buffer_unmap (mp3_buf, mp3_data, 0);
|
||||
gst_buffer_unmap (mp3_buf, &mp3_map);
|
||||
if (mp3_size < 0) {
|
||||
/* eat error ? */
|
||||
g_warning ("error %d", mp3_size);
|
||||
|
|
|
@ -433,7 +433,8 @@ gst_mad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
|
|||
GstFlowReturn ret = GST_FLOW_EOS;
|
||||
GstBuffer *outbuffer;
|
||||
guint nsamples;
|
||||
gint32 *data, *outdata;
|
||||
GstMapInfo outmap;
|
||||
gint32 *outdata;
|
||||
mad_fixed_t const *left_ch, *right_ch;
|
||||
|
||||
mad = GST_MAD (dec);
|
||||
|
@ -457,7 +458,8 @@ gst_mad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
|
|||
|
||||
outbuffer = gst_buffer_new_and_alloc (nsamples * mad->channels * 4);
|
||||
|
||||
data = outdata = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuffer, &outmap, GST_MAP_WRITE);
|
||||
outdata = (gint32 *) outmap.data;
|
||||
|
||||
/* output sample(s) in 16-bit signed native-endian PCM */
|
||||
if (mad->channels == 1) {
|
||||
|
@ -475,7 +477,7 @@ gst_mad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
|
|||
}
|
||||
}
|
||||
|
||||
gst_buffer_unmap (outbuffer, data, -1);
|
||||
gst_buffer_unmap (outbuffer, &outmap);
|
||||
|
||||
ret = gst_audio_decoder_finish_frame (dec, outbuffer, 1);
|
||||
|
||||
|
|
|
@ -1004,8 +1004,7 @@ static GstFlowReturn
|
|||
gst_mpeg2dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||
{
|
||||
GstMpeg2dec *mpeg2dec;
|
||||
gsize size;
|
||||
guint8 *data, *end;
|
||||
GstMapInfo map;
|
||||
GstClockTime pts;
|
||||
const mpeg2_info_t *info;
|
||||
mpeg2_state_t state;
|
||||
|
@ -1014,7 +1013,7 @@ gst_mpeg2dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
|
||||
mpeg2dec = GST_MPEG2DEC (parent);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
pts = GST_BUFFER_TIMESTAMP (buf);
|
||||
|
||||
if (GST_BUFFER_IS_DISCONT (buf)) {
|
||||
|
@ -1032,7 +1031,6 @@ gst_mpeg2dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
||||
|
||||
info = mpeg2dec->info;
|
||||
end = data + size;
|
||||
|
||||
mpeg2dec->offset = GST_BUFFER_OFFSET (buf);
|
||||
|
||||
|
@ -1054,7 +1052,7 @@ gst_mpeg2dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
}
|
||||
|
||||
GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer");
|
||||
mpeg2_buffer (mpeg2dec->decoder, data, end);
|
||||
mpeg2_buffer (mpeg2dec->decoder, map.data, map.data + map.size);
|
||||
GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer done");
|
||||
|
||||
while (!done) {
|
||||
|
@ -1159,7 +1157,7 @@ gst_mpeg2dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
}
|
||||
}
|
||||
done:
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ play_loop (GstPad * pad)
|
|||
GstFlowReturn ret;
|
||||
GstSidDec *siddec;
|
||||
GstBuffer *out;
|
||||
guint8 *data;
|
||||
GstMapInfo outmap;
|
||||
gint64 value, offset, time;
|
||||
GstFormat format;
|
||||
|
||||
|
@ -363,10 +363,10 @@ play_loop (GstPad * pad)
|
|||
|
||||
out = gst_buffer_new_and_alloc (siddec->blocksize);
|
||||
|
||||
data = (guint8 *) gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
|
||||
sidEmuFillBuffer (*siddec->engine, *siddec->tune,
|
||||
data, siddec->blocksize);
|
||||
gst_buffer_unmap (out, data, siddec->blocksize);
|
||||
outmap.data, siddec->blocksize);
|
||||
gst_buffer_unmap (out, &outmap);
|
||||
|
||||
/* get offset in samples */
|
||||
format = GST_FORMAT_DEFAULT;
|
||||
|
|
|
@ -613,7 +613,7 @@ static GstFlowReturn
|
|||
gst_two_lame_flush_full (GstTwoLame * lame, gboolean push)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
gint size;
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
|
||||
|
@ -621,9 +621,9 @@ gst_two_lame_flush_full (GstTwoLame * lame, gboolean push)
|
|||
return GST_FLOW_OK;
|
||||
|
||||
buf = gst_buffer_new_and_alloc (16384);
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
size = twolame_encode_flush (lame->glopts, data, 16384);
|
||||
gst_buffer_unmap (buf, data, 16384);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
size = twolame_encode_flush (lame->glopts, map.data, 16384);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
if (size > 0 && push) {
|
||||
gst_buffer_set_size (buf, size);
|
||||
|
@ -647,13 +647,11 @@ static GstFlowReturn
|
|||
gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf)
|
||||
{
|
||||
GstTwoLame *twolame;
|
||||
guchar *mp3_data;
|
||||
gint mp3_buffer_size, mp3_size;
|
||||
GstBuffer *mp3_buf;
|
||||
GstFlowReturn result;
|
||||
gint num_samples;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map, mp3_map;
|
||||
|
||||
twolame = GST_TWO_LAME (enc);
|
||||
|
||||
|
@ -661,43 +659,43 @@ gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf)
|
|||
if (G_UNLIKELY (buf == NULL))
|
||||
return gst_two_lame_flush_full (twolame, TRUE);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
if (twolame->float_input)
|
||||
num_samples = size / 4;
|
||||
num_samples = map.size / 4;
|
||||
else
|
||||
num_samples = size / 2;
|
||||
num_samples = map.size / 2;
|
||||
|
||||
/* allocate space for output */
|
||||
mp3_buffer_size = 1.25 * num_samples + 16384;
|
||||
mp3_buf = gst_buffer_new_and_alloc (mp3_buffer_size);
|
||||
mp3_data = gst_buffer_map (mp3_buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (mp3_buf, &mp3_map, GST_MAP_WRITE);
|
||||
|
||||
if (twolame->num_channels == 1) {
|
||||
if (twolame->float_input)
|
||||
mp3_size = twolame_encode_buffer_float32 (twolame->glopts,
|
||||
(float *) data,
|
||||
(float *) data, num_samples, mp3_data, mp3_buffer_size);
|
||||
(float *) map.data,
|
||||
(float *) map.data, num_samples, mp3_map.data, mp3_buffer_size);
|
||||
else
|
||||
mp3_size = twolame_encode_buffer (twolame->glopts,
|
||||
(short int *) data,
|
||||
(short int *) data, num_samples, mp3_data, mp3_buffer_size);
|
||||
(short int *) map.data,
|
||||
(short int *) map.data, num_samples, mp3_map.data, mp3_buffer_size);
|
||||
} else {
|
||||
if (twolame->float_input)
|
||||
mp3_size = twolame_encode_buffer_float32_interleaved (twolame->glopts,
|
||||
(float *) data,
|
||||
num_samples / twolame->num_channels, mp3_data, mp3_buffer_size);
|
||||
(float *) map.data,
|
||||
num_samples / twolame->num_channels, mp3_map.data, mp3_buffer_size);
|
||||
else
|
||||
mp3_size = twolame_encode_buffer_interleaved (twolame->glopts,
|
||||
(short int *) data,
|
||||
num_samples / twolame->num_channels, mp3_data, mp3_buffer_size);
|
||||
(short int *) map.data,
|
||||
num_samples / twolame->num_channels, mp3_map.data, mp3_buffer_size);
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (twolame, "encoded %" G_GSIZE_FORMAT " bytes of audio "
|
||||
"to %d bytes of mp3", size, mp3_size);
|
||||
"to %d bytes of mp3", map.size, mp3_size);
|
||||
|
||||
gst_buffer_unmap (buf, data, -1);
|
||||
gst_buffer_unmap (mp3_buf, mp3_data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unmap (mp3_buf, &mp3_map);
|
||||
|
||||
if (mp3_size > 0) {
|
||||
gst_buffer_set_size (mp3_buf, mp3_size);
|
||||
|
|
|
@ -467,17 +467,16 @@ gboolean
|
|||
gst_asf_demux_parse_packet (GstASFDemux * demux, GstBuffer * buf)
|
||||
{
|
||||
AsfPacket packet = { 0, };
|
||||
gpointer bufdata;
|
||||
GstMapInfo map;
|
||||
const guint8 *data;
|
||||
gboolean has_multiple_payloads;
|
||||
gboolean ret = TRUE;
|
||||
guint8 ec_flags, flags1;
|
||||
gsize bufsize;
|
||||
guint size;
|
||||
|
||||
bufdata = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
||||
data = bufdata;
|
||||
size = bufsize;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
GST_LOG_OBJECT (demux, "Buffer size: %u", size);
|
||||
|
||||
/* need at least two payload flag bytes, send time, and duration */
|
||||
|
@ -596,13 +595,13 @@ gst_asf_demux_parse_packet (GstASFDemux * demux, GstBuffer * buf)
|
|||
ret = gst_asf_demux_parse_payload (demux, &packet, -1, &data, &size);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf, bufdata, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return ret;
|
||||
|
||||
/* ERRORS */
|
||||
short_packet:
|
||||
{
|
||||
gst_buffer_unmap (buf, bufdata, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
GST_WARNING_OBJECT (demux, "Short packet!");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -988,14 +988,13 @@ gst_asf_demux_pull_indices (GstASFDemux * demux)
|
|||
while (gst_asf_demux_pull_data (demux, offset, 16 + 8, &buf, NULL)) {
|
||||
GstFlowReturn flow;
|
||||
AsfObject obj;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 *bufdata;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
g_assert (size >= 16 + 8);
|
||||
asf_demux_peek_object (demux, data, 16 + 8, &obj, TRUE);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
g_assert (map.size >= 16 + 8);
|
||||
asf_demux_peek_object (demux, map.data, 16 + 8, &obj, TRUE);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_replace (&buf, NULL);
|
||||
|
||||
/* check for sanity */
|
||||
|
@ -1013,11 +1012,11 @@ gst_asf_demux_pull_indices (GstASFDemux * demux)
|
|||
|
||||
offset += obj.size; /* increase before _process_object changes it */
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
g_assert (size >= obj.size);
|
||||
bufdata = (guint8 *) data;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
g_assert (map.size >= obj.size);
|
||||
bufdata = (guint8 *) map.data;
|
||||
flow = gst_asf_demux_process_object (demux, &bufdata, &obj.size);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_replace (&buf, NULL);
|
||||
|
||||
if (G_UNLIKELY (flow != GST_FLOW_OK))
|
||||
|
@ -1086,9 +1085,8 @@ gst_asf_demux_pull_headers (GstASFDemux * demux)
|
|||
AsfObject obj;
|
||||
GstBuffer *buf = NULL;
|
||||
guint64 size;
|
||||
GstMapInfo map;
|
||||
guint8 *bufdata;
|
||||
gpointer data = NULL;
|
||||
gsize data_size;
|
||||
|
||||
GST_LOG_OBJECT (demux, "reading headers");
|
||||
|
||||
|
@ -1096,12 +1094,11 @@ gst_asf_demux_pull_headers (GstASFDemux * demux)
|
|||
if (!gst_asf_demux_pull_data (demux, demux->base_offset, 16 + 8, &buf, NULL))
|
||||
goto read_failed;
|
||||
|
||||
data = gst_buffer_map (buf, &data_size, NULL, GST_MAP_READ);
|
||||
g_assert (data_size >= 16 + 8);
|
||||
asf_demux_peek_object (demux, data, 16 + 8, &obj, TRUE);
|
||||
gst_buffer_unmap (buf, data, data_size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
g_assert (map.size >= 16 + 8);
|
||||
asf_demux_peek_object (demux, map.data, 16 + 8, &obj, TRUE);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_replace (&buf, NULL);
|
||||
data = NULL;
|
||||
|
||||
if (obj.id != ASF_OBJ_HEADER)
|
||||
goto wrong_type;
|
||||
|
@ -1114,13 +1111,12 @@ gst_asf_demux_pull_headers (GstASFDemux * demux)
|
|||
goto read_failed;
|
||||
|
||||
size = obj.size; /* don't want obj.size changed */
|
||||
data = gst_buffer_map (buf, &data_size, NULL, GST_MAP_READ);
|
||||
g_assert (data_size >= size);
|
||||
bufdata = (guint8 *) data;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
g_assert (map.size >= size);
|
||||
bufdata = (guint8 *) map.data;
|
||||
flow = gst_asf_demux_process_object (demux, &bufdata, &size);
|
||||
gst_buffer_unmap (buf, data, data_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_replace (&buf, NULL);
|
||||
data = NULL;
|
||||
|
||||
if (flow != GST_FLOW_OK) {
|
||||
GST_WARNING_OBJECT (demux, "process_object: %s", gst_flow_get_name (flow));
|
||||
|
@ -1135,25 +1131,25 @@ gst_asf_demux_pull_headers (GstASFDemux * demux)
|
|||
NULL))
|
||||
goto read_failed;
|
||||
|
||||
|
||||
data = gst_buffer_map (buf, &data_size, NULL, GST_MAP_READ);
|
||||
g_assert (data_size >= size);
|
||||
bufdata = (guint8 *) data;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
g_assert (map.size >= size);
|
||||
bufdata = (guint8 *) map.data;
|
||||
if (!gst_asf_demux_parse_data_object_start (demux, bufdata))
|
||||
goto wrong_type;
|
||||
|
||||
if (demux->num_streams == 0)
|
||||
goto no_streams;
|
||||
|
||||
gst_buffer_unmap (buf, data, data_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_replace (&buf, NULL);
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
wrong_type:
|
||||
{
|
||||
if (data != NULL) {
|
||||
gst_buffer_unmap (buf, data, data_size);
|
||||
if (buf != NULL) {
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_replace (&buf, NULL);
|
||||
}
|
||||
GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL),
|
||||
|
@ -1166,7 +1162,7 @@ read_failed:
|
|||
parse_failed:
|
||||
{
|
||||
if (buf)
|
||||
gst_buffer_unmap (buf, data, data_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_replace (&buf, NULL);
|
||||
GST_ELEMENT_ERROR (demux, STREAM, DEMUX, (NULL), (NULL));
|
||||
return FALSE;
|
||||
|
@ -1502,23 +1498,22 @@ static gboolean
|
|||
gst_asf_demux_check_buffer_is_header (GstASFDemux * demux, GstBuffer * buf)
|
||||
{
|
||||
AsfObject obj;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
g_assert (buf != NULL);
|
||||
|
||||
GST_LOG_OBJECT (demux, "Checking if buffer is a header");
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
/* we return false on buffer too small */
|
||||
if (size < ASF_OBJECT_HEADER_SIZE) {
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
if (map.size < ASF_OBJECT_HEADER_SIZE) {
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* check if it is a header */
|
||||
asf_demux_peek_object (demux, data, ASF_OBJECT_HEADER_SIZE, &obj, TRUE);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
asf_demux_peek_object (demux, map.data, ASF_OBJECT_HEADER_SIZE, &obj, TRUE);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
if (obj.id == ASF_OBJ_HEADER) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1971,21 +1966,17 @@ static gboolean
|
|||
gst_asf_demux_get_buffer (GstBuffer ** p_buf, guint num_bytes_to_read,
|
||||
guint8 ** p_data, guint64 * p_size)
|
||||
{
|
||||
gpointer data;
|
||||
gsize size;
|
||||
|
||||
*p_buf = NULL;
|
||||
|
||||
if (*p_size < num_bytes_to_read)
|
||||
return FALSE;
|
||||
|
||||
|
||||
*p_buf = gst_buffer_new_and_alloc (num_bytes_to_read);
|
||||
data = gst_buffer_map (*p_buf, &size, NULL, GST_MAP_WRITE);
|
||||
memcpy (data, *p_data, num_bytes_to_read);
|
||||
gst_buffer_fill (*p_buf, 0, *p_data, num_bytes_to_read);
|
||||
|
||||
*p_data += num_bytes_to_read;
|
||||
*p_size -= num_bytes_to_read;
|
||||
gst_buffer_unmap (*p_buf, data, size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -3565,14 +3556,13 @@ gst_asf_demux_process_queued_extended_stream_objects (GstASFDemux * demux)
|
|||
|
||||
for (l = demux->ext_stream_props, i = 0; l != NULL; l = l->next, ++i) {
|
||||
GstBuffer *buf = GST_BUFFER (l->data);
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
GST_LOG_OBJECT (demux, "parsing ext. stream properties object #%u", i);
|
||||
gst_asf_demux_process_ext_stream_props (demux, data, size);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_asf_demux_process_ext_stream_props (demux, map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
g_slist_free (demux->ext_stream_props);
|
||||
|
@ -3692,15 +3682,12 @@ gst_asf_demux_process_object (GstASFDemux * demux, guint8 ** p_data,
|
|||
break;
|
||||
case ASF_OBJ_EXTENDED_STREAM_PROPS:{
|
||||
GstBuffer *buf;
|
||||
gpointer data;
|
||||
|
||||
/* process these later, we might not have parsed the corresponding
|
||||
* stream object yet */
|
||||
GST_LOG ("%s: queued for later parsing", demux->objpath);
|
||||
buf = gst_buffer_new_and_alloc (obj_data_size);
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (data, *p_data, obj_data_size);
|
||||
gst_buffer_unmap (buf, data, -1);
|
||||
gst_buffer_fill (buf, 0, *p_data, obj_data_size);
|
||||
demux->ext_stream_props = g_slist_append (demux->ext_stream_props, buf);
|
||||
ret = GST_FLOW_OK;
|
||||
break;
|
||||
|
|
|
@ -248,8 +248,7 @@ static void
|
|||
gst_rtp_asf_depay_set_padding (GstRtpAsfDepay * depayload,
|
||||
GstBuffer * buf, guint32 padding)
|
||||
{
|
||||
gpointer bufdata;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gint offset = 0;
|
||||
guint8 aux;
|
||||
|
@ -257,8 +256,8 @@ gst_rtp_asf_depay_set_padding (GstRtpAsfDepay * depayload,
|
|||
guint8 pad_type;
|
||||
guint8 pkt_type;
|
||||
|
||||
bufdata = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
||||
data = bufdata;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
|
||||
aux = data[offset++];
|
||||
if (aux & 0x80) {
|
||||
|
@ -267,7 +266,7 @@ gst_rtp_asf_depay_set_padding (GstRtpAsfDepay * depayload,
|
|||
GST_WARNING_OBJECT (depayload, "Error correction length type should be "
|
||||
"set to 0");
|
||||
/* this packet doesn't follow the spec */
|
||||
gst_buffer_unmap (buf, bufdata, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return;
|
||||
}
|
||||
err_len = aux & 0x0F;
|
||||
|
@ -305,7 +304,7 @@ gst_rtp_asf_depay_set_padding (GstRtpAsfDepay * depayload,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
gst_buffer_unmap (buf, bufdata, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
/* Docs: 'RTSP Protocol PDF' document from http://sdp.ppona.com/ (page 8) */
|
||||
|
|
|
@ -425,6 +425,7 @@ static GstFlowReturn
|
|||
gst_dvdlpcmdec_chain_dvd (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||
{
|
||||
GstDvdLpcmDec *dvdlpcmdec;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
guint first_access;
|
||||
|
@ -436,7 +437,9 @@ gst_dvdlpcmdec_chain_dvd (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
|
||||
dvdlpcmdec = GST_DVDLPCMDEC (parent);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
if (size < 5)
|
||||
goto too_small;
|
||||
|
@ -551,7 +554,7 @@ gst_dvdlpcmdec_chain_dvd (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
}
|
||||
|
||||
done:
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
return ret;
|
||||
|
@ -637,8 +640,9 @@ gst_dvdlpcmdec_chain_raw (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
gint64 samples = size * 8 / 20;
|
||||
gint64 count = size / 10;
|
||||
gint64 i;
|
||||
guint8 *src, *osrc;
|
||||
guint8 *dest, *odest;
|
||||
GstMapInfo srcmap, destmap;
|
||||
guint8 *src;
|
||||
guint8 *dest;
|
||||
GstBuffer *outbuf;
|
||||
|
||||
if (samples < 1)
|
||||
|
@ -650,8 +654,10 @@ gst_dvdlpcmdec_chain_raw (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
/* adjust samples so we can calc the new timestamp */
|
||||
samples = samples / channels;
|
||||
|
||||
src = osrc = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
|
||||
dest = odest = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &srcmap, GST_MAP_READ);
|
||||
gst_buffer_map (outbuf, &destmap, GST_MAP_WRITE);
|
||||
src = srcmap.data;
|
||||
dest = destmap.data;
|
||||
|
||||
/* Copy 20-bit LPCM format to 24-bit buffers, with 0x00 in the lowest
|
||||
* nibble. Note that the first 2 bytes are already correct */
|
||||
|
@ -672,8 +678,8 @@ gst_dvdlpcmdec_chain_raw (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
src += 10;
|
||||
dest += 12;
|
||||
}
|
||||
gst_buffer_unmap (outbuf, odest, -1);
|
||||
gst_buffer_unmap (buf, osrc, -1);
|
||||
gst_buffer_unmap (outbuf, &destmap);
|
||||
gst_buffer_unmap (buf, &srcmap);
|
||||
gst_buffer_unref (buf);
|
||||
buf = outbuf;
|
||||
break;
|
||||
|
@ -684,7 +690,8 @@ gst_dvdlpcmdec_chain_raw (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
* and last byte are already correct */
|
||||
guint count = size / 12;
|
||||
gint i;
|
||||
guint8 *src, *osrc;
|
||||
GstMapInfo map;
|
||||
guint8 *ptr;
|
||||
|
||||
samples = size / channels / 3;
|
||||
|
||||
|
@ -694,25 +701,26 @@ gst_dvdlpcmdec_chain_raw (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
/* Ensure our output buffer is writable */
|
||||
buf = gst_buffer_make_writable (buf);
|
||||
|
||||
src = osrc = gst_buffer_map (buf, NULL, NULL, GST_MAP_READWRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
ptr = map.data;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
guint8 tmp;
|
||||
|
||||
tmp = src[10];
|
||||
src[10] = src[7];
|
||||
src[7] = src[5];
|
||||
src[5] = src[9];
|
||||
src[9] = src[6];
|
||||
src[6] = src[4];
|
||||
src[4] = src[3];
|
||||
src[3] = src[2];
|
||||
src[2] = src[8];
|
||||
src[8] = tmp;
|
||||
tmp = ptr[10];
|
||||
ptr[10] = ptr[7];
|
||||
ptr[7] = ptr[5];
|
||||
ptr[5] = ptr[9];
|
||||
ptr[9] = ptr[6];
|
||||
ptr[6] = ptr[4];
|
||||
ptr[4] = ptr[3];
|
||||
ptr[3] = ptr[2];
|
||||
ptr[2] = ptr[8];
|
||||
ptr[8] = tmp;
|
||||
|
||||
src += 12;
|
||||
ptr += 12;
|
||||
}
|
||||
gst_buffer_unmap (buf, osrc, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -148,7 +148,6 @@ gst_dvd_sub_dec_init (GstDvdSubDec * dec)
|
|||
dec->in_height = 576;
|
||||
|
||||
dec->partialbuf = NULL;
|
||||
dec->partialdata = NULL;
|
||||
dec->have_title = FALSE;
|
||||
dec->parse_pos = NULL;
|
||||
dec->forced_display = FALSE;
|
||||
|
@ -171,7 +170,7 @@ gst_dvd_sub_dec_finalize (GObject * gobject)
|
|||
GstDvdSubDec *dec = GST_DVD_SUB_DEC (gobject);
|
||||
|
||||
if (dec->partialbuf) {
|
||||
gst_buffer_unmap (dec->partialbuf, dec->partialdata, dec->partialsize);
|
||||
gst_buffer_unmap (dec->partialbuf, &dec->partialmap);
|
||||
gst_buffer_unref (dec->partialbuf);
|
||||
dec->partialbuf = NULL;
|
||||
}
|
||||
|
@ -201,7 +200,7 @@ gst_dvd_sub_dec_get_event_delay (GstDvdSubDec * dec)
|
|||
GstClockTime event_delay;
|
||||
|
||||
/* If starting a new buffer, follow the first DCSQ ptr */
|
||||
if (dec->parse_pos == dec->partialdata) {
|
||||
if (dec->parse_pos == dec->partialmap.data) {
|
||||
buf = dec->parse_pos + dec->data_size;
|
||||
} else {
|
||||
buf = dec->parse_pos;
|
||||
|
@ -227,7 +226,7 @@ gst_dvd_sub_dec_parse_subpic (GstDvdSubDec * dec)
|
|||
{ GST_WARNING("Subtitle stream broken parsing %c", *buf); \
|
||||
broken = TRUE; break; }
|
||||
|
||||
guchar *start = dec->partialdata;
|
||||
guchar *start = dec->partialmap.data;
|
||||
guchar *buf;
|
||||
guchar *end;
|
||||
gboolean broken = FALSE;
|
||||
|
@ -567,7 +566,7 @@ gst_dvd_sub_dec_merge_title (GstDvdSubDec * dec, GstVideoFrame * frame)
|
|||
{
|
||||
gint y;
|
||||
gint Y_stride;
|
||||
guchar *buffer = dec->partialdata;
|
||||
guchar *buffer = dec->partialmap.data;
|
||||
gint hl_top, hl_bottom;
|
||||
gint last_y;
|
||||
RLE_state state;
|
||||
|
@ -821,7 +820,7 @@ gst_dvd_sub_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
}
|
||||
|
||||
if (dec->have_title) {
|
||||
gst_buffer_unmap (dec->partialbuf, dec->partialdata, dec->partialsize);
|
||||
gst_buffer_unmap (dec->partialbuf, &dec->partialmap);
|
||||
gst_buffer_unref (dec->partialbuf);
|
||||
dec->partialbuf = NULL;
|
||||
dec->have_title = FALSE;
|
||||
|
@ -834,18 +833,17 @@ gst_dvd_sub_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
if (dec->partialbuf) {
|
||||
GstBuffer *merge;
|
||||
|
||||
gst_buffer_unmap (dec->partialbuf, dec->partialdata, dec->partialsize);
|
||||
gst_buffer_unmap (dec->partialbuf, &dec->partialmap);
|
||||
merge = gst_buffer_join (dec->partialbuf, buf);
|
||||
dec->partialbuf = merge;
|
||||
} else {
|
||||
dec->partialbuf = buf;
|
||||
}
|
||||
|
||||
dec->partialdata =
|
||||
gst_buffer_map (dec->partialbuf, &dec->partialsize, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (dec->partialbuf, &dec->partialmap, GST_MAP_READ);
|
||||
|
||||
data = dec->partialdata;
|
||||
size = dec->partialsize;
|
||||
data = dec->partialmap.data;
|
||||
size = dec->partialmap.size;
|
||||
|
||||
if (size > 4) {
|
||||
dec->packet_size = GST_READ_UINT16_BE (data);
|
||||
|
@ -1003,8 +1001,7 @@ gst_dvd_sub_dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
// dec->forced_display = 0;
|
||||
// dec->current_button = 0;
|
||||
if (dec->partialbuf) {
|
||||
gst_buffer_unmap (dec->partialbuf, dec->partialdata,
|
||||
dec->partialsize);
|
||||
gst_buffer_unmap (dec->partialbuf, &dec->partialmap);
|
||||
gst_buffer_unref (dec->partialbuf);
|
||||
dec->partialbuf = NULL;
|
||||
dec->have_title = FALSE;
|
||||
|
@ -1028,7 +1025,7 @@ gst_dvd_sub_dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
dec->current_button = 0;
|
||||
|
||||
if (dec->partialbuf) {
|
||||
gst_buffer_unmap (dec->partialbuf, dec->partialdata, dec->partialsize);
|
||||
gst_buffer_unmap (dec->partialbuf, &dec->partialmap);
|
||||
gst_buffer_unref (dec->partialbuf);
|
||||
dec->partialbuf = NULL;
|
||||
dec->have_title = FALSE;
|
||||
|
|
|
@ -51,8 +51,7 @@ struct _GstDvdSubDec
|
|||
|
||||
/* Collect together subtitle buffers until we have a full control sequence */
|
||||
GstBuffer *partialbuf;
|
||||
guint8 *partialdata;
|
||||
gsize partialsize;
|
||||
GstMapInfo partialmap;
|
||||
gboolean have_title;
|
||||
|
||||
guchar subtitle_index[4];
|
||||
|
|
|
@ -51,6 +51,7 @@ gst_rdt_buffer_get_packet_count (GstBuffer * buffer)
|
|||
static gboolean
|
||||
read_packet_header (GstRDTPacket * packet)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
guint offset;
|
||||
|
@ -60,7 +61,9 @@ read_packet_header (GstRDTPacket * packet)
|
|||
g_return_val_if_fail (packet != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
|
||||
|
||||
data = gst_buffer_map (packet->buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (packet->buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
offset = packet->offset;
|
||||
|
||||
|
@ -164,7 +167,7 @@ read_packet_header (GstRDTPacket * packet)
|
|||
/* length is remainder of packet */
|
||||
packet->length = size - offset;
|
||||
}
|
||||
gst_buffer_unmap (packet->buffer, data, size);
|
||||
gst_buffer_unmap (packet->buffer, &map);
|
||||
|
||||
/* the length should be smaller than the remaining size */
|
||||
if (packet->length + offset > size)
|
||||
|
@ -175,13 +178,13 @@ read_packet_header (GstRDTPacket * packet)
|
|||
/* ERRORS */
|
||||
packet_end:
|
||||
{
|
||||
gst_buffer_unmap (packet->buffer, data, size);
|
||||
gst_buffer_unmap (packet->buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
unknown_packet:
|
||||
{
|
||||
packet->type = GST_RDT_TYPE_INVALID;
|
||||
gst_buffer_unmap (packet->buffer, data, size);
|
||||
gst_buffer_unmap (packet->buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
invalid_length:
|
||||
|
@ -283,22 +286,22 @@ gst_rdt_buffer_compare_seqnum (guint16 seqnum1, guint16 seqnum2)
|
|||
guint16
|
||||
gst_rdt_packet_data_get_seq (GstRDTPacket * packet)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint header;
|
||||
guint8 *bufdata;
|
||||
guint16 result;
|
||||
|
||||
g_return_val_if_fail (packet != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_RDT_IS_DATA_TYPE (packet->type), FALSE);
|
||||
|
||||
bufdata = gst_buffer_map (packet->buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (packet->buffer, &map, GST_MAP_READ);
|
||||
|
||||
/* skip header bits */
|
||||
header = packet->offset + 1;
|
||||
|
||||
/* read seq_no */
|
||||
result = GST_READ_UINT16_BE (&bufdata[header]);
|
||||
result = GST_READ_UINT16_BE (&map.data[header]);
|
||||
|
||||
gst_buffer_unmap (packet->buffer, bufdata, -1);
|
||||
gst_buffer_unmap (packet->buffer, &map);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -306,24 +309,24 @@ gst_rdt_packet_data_get_seq (GstRDTPacket * packet)
|
|||
guint8 *
|
||||
gst_rdt_packet_data_map (GstRDTPacket * packet, guint * size)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint header;
|
||||
guint8 *bufdata;
|
||||
gboolean length_included_flag;
|
||||
gboolean need_reliable_flag;
|
||||
guint8 stream_id;
|
||||
guint8 asm_rule_number;
|
||||
|
||||
g_return_val_if_fail (packet != NULL, NULL);
|
||||
g_return_val_if_fail (packet->data == NULL, NULL);
|
||||
g_return_val_if_fail (packet->map.data == NULL, NULL);
|
||||
g_return_val_if_fail (GST_RDT_IS_DATA_TYPE (packet->type), NULL);
|
||||
|
||||
bufdata = gst_buffer_map (packet->buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (packet->buffer, &map, GST_MAP_READ);
|
||||
|
||||
header = packet->offset;
|
||||
|
||||
length_included_flag = (bufdata[header] & 0x80) == 0x80;
|
||||
need_reliable_flag = (bufdata[header] & 0x40) == 0x40;
|
||||
stream_id = (bufdata[header] & 0x3e) >> 1;
|
||||
length_included_flag = (map.data[header] & 0x80) == 0x80;
|
||||
need_reliable_flag = (map.data[header] & 0x40) == 0x40;
|
||||
stream_id = (map.data[header] & 0x3e) >> 1;
|
||||
|
||||
/* skip seq_no and header bits */
|
||||
header += 3;
|
||||
|
@ -332,7 +335,7 @@ gst_rdt_packet_data_map (GstRDTPacket * packet, guint * size)
|
|||
/* skip length */
|
||||
header += 2;
|
||||
}
|
||||
asm_rule_number = (bufdata[header] & 0x3f);
|
||||
asm_rule_number = (map.data[header] & 0x3f);
|
||||
|
||||
/* skip timestamp and asm_rule_number */
|
||||
header += 5;
|
||||
|
@ -353,19 +356,19 @@ gst_rdt_packet_data_map (GstRDTPacket * packet, guint * size)
|
|||
if (size)
|
||||
*size = packet->length - (header - packet->offset);
|
||||
|
||||
packet->data = bufdata;
|
||||
packet->map = map;
|
||||
|
||||
return &bufdata[header];
|
||||
return &map.data[header];
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_rdt_packet_data_unmap (GstRDTPacket * packet)
|
||||
{
|
||||
g_return_val_if_fail (packet != NULL, FALSE);
|
||||
g_return_val_if_fail (packet->data != NULL, FALSE);
|
||||
g_return_val_if_fail (packet->map.data != NULL, FALSE);
|
||||
|
||||
gst_buffer_unmap (packet->buffer, packet->data, -1);
|
||||
packet->data = NULL;
|
||||
gst_buffer_unmap (packet->buffer, &packet->map);
|
||||
packet->map.data = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -373,20 +376,20 @@ gst_rdt_packet_data_unmap (GstRDTPacket * packet)
|
|||
guint16
|
||||
gst_rdt_packet_data_get_stream_id (GstRDTPacket * packet)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint16 result;
|
||||
guint header;
|
||||
gboolean length_included_flag;
|
||||
guint8 *bufdata;
|
||||
|
||||
g_return_val_if_fail (packet != NULL, 0);
|
||||
g_return_val_if_fail (GST_RDT_IS_DATA_TYPE (packet->type), 0);
|
||||
|
||||
bufdata = gst_buffer_map (packet->buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (packet->buffer, &map, GST_MAP_READ);
|
||||
|
||||
header = packet->offset;
|
||||
|
||||
length_included_flag = (bufdata[header] & 0x80) == 0x80;
|
||||
result = (bufdata[header] & 0x3e) >> 1;
|
||||
length_included_flag = (map.data[header] & 0x80) == 0x80;
|
||||
result = (map.data[header] & 0x3e) >> 1;
|
||||
if (result == 31) {
|
||||
/* skip seq_no and header bits */
|
||||
header += 3;
|
||||
|
@ -399,9 +402,9 @@ gst_rdt_packet_data_get_stream_id (GstRDTPacket * packet)
|
|||
header += 5;
|
||||
|
||||
/* stream_id_expansion */
|
||||
result = GST_READ_UINT16_BE (&bufdata[header]);
|
||||
result = GST_READ_UINT16_BE (&map.data[header]);
|
||||
}
|
||||
gst_buffer_unmap (packet->buffer, bufdata, -1);
|
||||
gst_buffer_unmap (packet->buffer, &map);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -409,19 +412,19 @@ gst_rdt_packet_data_get_stream_id (GstRDTPacket * packet)
|
|||
guint32
|
||||
gst_rdt_packet_data_get_timestamp (GstRDTPacket * packet)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint header;
|
||||
gboolean length_included_flag;
|
||||
guint8 *bufdata;
|
||||
guint32 result;
|
||||
|
||||
g_return_val_if_fail (packet != NULL, 0);
|
||||
g_return_val_if_fail (GST_RDT_IS_DATA_TYPE (packet->type), 0);
|
||||
|
||||
bufdata = gst_buffer_map (packet->buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (packet->buffer, &map, GST_MAP_READ);
|
||||
|
||||
header = packet->offset;
|
||||
|
||||
length_included_flag = (bufdata[header] & 0x80) == 0x80;
|
||||
length_included_flag = (map.data[header] & 0x80) == 0x80;
|
||||
|
||||
/* skip seq_no and header bits */
|
||||
header += 3;
|
||||
|
@ -434,8 +437,8 @@ gst_rdt_packet_data_get_timestamp (GstRDTPacket * packet)
|
|||
header += 1;
|
||||
|
||||
/* get timestamp */
|
||||
result = GST_READ_UINT32_BE (&bufdata[header]);
|
||||
gst_buffer_unmap (packet->buffer, bufdata, -1);
|
||||
result = GST_READ_UINT32_BE (&map.data[header]);
|
||||
gst_buffer_unmap (packet->buffer, &map);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -443,19 +446,19 @@ gst_rdt_packet_data_get_timestamp (GstRDTPacket * packet)
|
|||
guint8
|
||||
gst_rdt_packet_data_get_flags (GstRDTPacket * packet)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint8 result;
|
||||
guint header;
|
||||
gboolean length_included_flag;
|
||||
guint8 *bufdata;
|
||||
|
||||
g_return_val_if_fail (packet != NULL, 0);
|
||||
g_return_val_if_fail (GST_RDT_IS_DATA_TYPE (packet->type), 0);
|
||||
|
||||
bufdata = gst_buffer_map (packet->buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (packet->buffer, &map, GST_MAP_READ);
|
||||
|
||||
header = packet->offset;
|
||||
|
||||
length_included_flag = (bufdata[header] & 0x80) == 0x80;
|
||||
length_included_flag = (map.data[header] & 0x80) == 0x80;
|
||||
|
||||
/* skip seq_no and header bits */
|
||||
header += 3;
|
||||
|
@ -465,8 +468,8 @@ gst_rdt_packet_data_get_flags (GstRDTPacket * packet)
|
|||
header += 2;
|
||||
}
|
||||
/* get flags */
|
||||
result = bufdata[header];
|
||||
gst_buffer_unmap (packet->buffer, bufdata, -1);
|
||||
result = map.data[header];
|
||||
gst_buffer_unmap (packet->buffer, &map);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ struct _GstRDTPacket
|
|||
/*< private >*/
|
||||
GstRDTType type; /* type of current packet */
|
||||
guint16 length; /* length of current packet in bytes */
|
||||
guint8 *data; /* last mapped data */
|
||||
GstMapInfo map; /* last mapped data */
|
||||
};
|
||||
|
||||
/* validate buffers */
|
||||
|
|
|
@ -303,6 +303,7 @@ gst_rdt_depay_handle_data (GstRDTDepay * rdtdepay, GstClockTime outtime,
|
|||
{
|
||||
GstFlowReturn ret;
|
||||
GstBuffer *outbuf;
|
||||
GstMapInfo outmap;
|
||||
guint8 *data, *outdata;
|
||||
guint size;
|
||||
guint16 stream_id;
|
||||
|
@ -365,14 +366,16 @@ gst_rdt_depay_handle_data (GstRDTDepay * rdtdepay, GstClockTime outtime,
|
|||
else
|
||||
outflags = 0;
|
||||
|
||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
outdata = outmap.data;
|
||||
GST_WRITE_UINT16_BE (outdata + 0, 0); /* version */
|
||||
GST_WRITE_UINT16_BE (outdata + 2, size + 12); /* length */
|
||||
GST_WRITE_UINT16_BE (outdata + 4, stream_id); /* stream */
|
||||
GST_WRITE_UINT32_BE (outdata + 6, timestamp); /* timestamp */
|
||||
GST_WRITE_UINT16_BE (outdata + 10, outflags); /* flags */
|
||||
memcpy (outdata + 12, data, size);
|
||||
gst_buffer_unmap (outbuf, outdata, 12 + size);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
gst_buffer_resize (outbuf, 0, 12 + size);
|
||||
|
||||
gst_rdt_packet_data_unmap (packet);
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ gst_rmdemux_validate_offset (GstRMDemux * rmdemux)
|
|||
GstFlowReturn flowret;
|
||||
guint16 version, length;
|
||||
gboolean ret = TRUE;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
flowret = gst_pad_pull_range (rmdemux->sinkpad, rmdemux->offset, 4, &buffer);
|
||||
|
||||
|
@ -361,21 +361,21 @@ gst_rmdemux_validate_offset (GstRMDemux * rmdemux)
|
|||
* 4 bytes, and we can check that it won't take us past our known total size
|
||||
*/
|
||||
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
version = RMDEMUX_GUINT16_GET (data);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
version = RMDEMUX_GUINT16_GET (map.data);
|
||||
if (version != 0 && version != 1) {
|
||||
GST_DEBUG_OBJECT (rmdemux, "Expected version 0 or 1, got %d",
|
||||
(int) version);
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
length = RMDEMUX_GUINT16_GET (data + 2);
|
||||
length = RMDEMUX_GUINT16_GET (map.data + 2);
|
||||
/* TODO: Also check against total stream length */
|
||||
if (length < 4) {
|
||||
GST_DEBUG_OBJECT (rmdemux, "Expected length >= 4, got %d", (int) length);
|
||||
ret = FALSE;
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
if (ret) {
|
||||
rmdemux->offset += 4;
|
||||
|
@ -1914,7 +1914,7 @@ gst_rmdemux_descramble_audio (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
|
|||
{
|
||||
GstFlowReturn ret = GST_FLOW_ERROR;
|
||||
GstBuffer *outbuf;
|
||||
guint8 *outdata;
|
||||
GstMapInfo outmap;
|
||||
guint packet_size = stream->packet_size;
|
||||
guint height = stream->subpackets->len;
|
||||
guint leaf_size = stream->leaf_size;
|
||||
|
@ -1926,11 +1926,13 @@ gst_rmdemux_descramble_audio (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
|
|||
leaf_size, height);
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (height * packet_size);
|
||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
|
||||
for (p = 0; p < height; ++p) {
|
||||
GstBuffer *b = g_ptr_array_index (stream->subpackets, p);
|
||||
guint8 *b_data = gst_buffer_map (b, NULL, NULL, GST_MAP_READ);
|
||||
GstMapInfo map;
|
||||
|
||||
gst_buffer_map (b, &map, GST_MAP_READ);
|
||||
|
||||
if (p == 0)
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (b);
|
||||
|
@ -1941,11 +1943,12 @@ gst_rmdemux_descramble_audio (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
|
|||
idx = height * x + ((height + 1) / 2) * (p % 2) + (p / 2);
|
||||
|
||||
/* GST_LOG ("%3u => %3u", (height * p) + x, idx); */
|
||||
memcpy (outdata + leaf_size * idx, b_data + leaf_size * x, leaf_size);
|
||||
memcpy (outmap.data + leaf_size * idx, map.data + leaf_size * x,
|
||||
leaf_size);
|
||||
}
|
||||
gst_buffer_unmap (b, b_data, -1);
|
||||
gst_buffer_unmap (b, &map);
|
||||
}
|
||||
gst_buffer_unmap (outbuf, outdata, -1);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
|
||||
/* some decoders, such as realaudiodec, need to be fed in packet units */
|
||||
for (p = 0; p < height; ++p) {
|
||||
|
@ -2001,7 +2004,7 @@ gst_rmdemux_descramble_mp4a_audio (GstRMDemux * rmdemux,
|
|||
GstFlowReturn res;
|
||||
GstBuffer *buf, *outbuf;
|
||||
guint frames, index, i;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
GstClockTime timestamp;
|
||||
|
||||
res = GST_FLOW_OK;
|
||||
|
@ -2010,14 +2013,14 @@ gst_rmdemux_descramble_mp4a_audio (GstRMDemux * rmdemux,
|
|||
g_ptr_array_index (stream->subpackets, 0) = NULL;
|
||||
g_ptr_array_set_size (stream->subpackets, 0);
|
||||
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
|
||||
frames = (data[1] & 0xf0) >> 4;
|
||||
frames = (map.data[1] & 0xf0) >> 4;
|
||||
index = 2 * frames + 2;
|
||||
|
||||
for (i = 0; i < frames; i++) {
|
||||
guint len = (data[i * 2 + 2] << 8) | data[i * 2 + 3];
|
||||
guint len = (map.data[i * 2 + 2] << 8) | map.data[i * 2 + 3];
|
||||
|
||||
outbuf = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, index, len);
|
||||
if (i == 0)
|
||||
|
@ -2033,7 +2036,7 @@ gst_rmdemux_descramble_mp4a_audio (GstRMDemux * rmdemux,
|
|||
if (res != GST_FLOW_OK)
|
||||
break;
|
||||
}
|
||||
gst_buffer_unmap (buf, data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return res;
|
||||
}
|
||||
|
@ -2044,7 +2047,7 @@ gst_rmdemux_descramble_sipr_audio (GstRMDemux * rmdemux,
|
|||
{
|
||||
GstFlowReturn ret;
|
||||
GstBuffer *outbuf;
|
||||
guint8 *outdata;
|
||||
GstMapInfo outmap;
|
||||
guint packet_size = stream->packet_size;
|
||||
guint height = stream->subpackets->len;
|
||||
guint p;
|
||||
|
@ -2055,7 +2058,7 @@ gst_rmdemux_descramble_sipr_audio (GstRMDemux * rmdemux,
|
|||
stream->leaf_size, height);
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (height * packet_size);
|
||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
|
||||
for (p = 0; p < height; ++p) {
|
||||
GstBuffer *b = g_ptr_array_index (stream->subpackets, p);
|
||||
|
@ -2063,9 +2066,9 @@ gst_rmdemux_descramble_sipr_audio (GstRMDemux * rmdemux,
|
|||
if (p == 0)
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (b);
|
||||
|
||||
gst_buffer_extract (b, 0, outdata + packet_size * p, packet_size);
|
||||
gst_buffer_extract (b, 0, outmap.data + packet_size * p, packet_size);
|
||||
}
|
||||
gst_buffer_unmap (outbuf, outdata, -1);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
|
||||
GST_LOG_OBJECT (rmdemux, "pushing buffer timestamp %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
|
||||
|
@ -2284,14 +2287,14 @@ gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
|
|||
GstClockTime timestamp, gboolean key)
|
||||
{
|
||||
GstFlowReturn ret;
|
||||
GstMapInfo map;
|
||||
const guint8 *data;
|
||||
guint8 *base;
|
||||
gsize size;
|
||||
|
||||
base = gst_buffer_map (in, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (in, &map, GST_MAP_READ);
|
||||
|
||||
data = base + offset;
|
||||
size -= offset;
|
||||
data = map.data + offset;
|
||||
size = map.size - offset;
|
||||
|
||||
/* if size <= 2, we want this method to return the same GstFlowReturn as it
|
||||
* was previously for that given stream. */
|
||||
|
@ -2358,7 +2361,7 @@ gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
|
|||
|
||||
/* get the fragment */
|
||||
fragment =
|
||||
gst_buffer_copy_region (in, GST_BUFFER_COPY_ALL, data - base,
|
||||
gst_buffer_copy_region (in, GST_BUFFER_COPY_ALL, data - map.data,
|
||||
fragment_size);
|
||||
|
||||
if (pkg_subseq == 1) {
|
||||
|
@ -2389,7 +2392,8 @@ gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
|
|||
/* flush fragment when complete */
|
||||
if (stream->frag_current >= stream->frag_length) {
|
||||
GstBuffer *out;
|
||||
guint8 *outdata, *outbase;
|
||||
GstMapInfo outmap;
|
||||
guint8 *outdata;
|
||||
guint header_size;
|
||||
gint i, avail;
|
||||
|
||||
|
@ -2412,8 +2416,8 @@ gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
|
|||
avail = gst_adapter_available (stream->adapter);
|
||||
|
||||
out = gst_buffer_new_and_alloc (header_size + avail);
|
||||
outbase = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
|
||||
outdata = outbase;
|
||||
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
|
||||
outdata = outmap.data;
|
||||
|
||||
/* create header */
|
||||
*outdata++ = stream->frag_count - 1;
|
||||
|
@ -2444,7 +2448,7 @@ gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
|
|||
timestamp =
|
||||
gst_rmdemux_fix_timestamp (rmdemux, stream, outdata, timestamp);
|
||||
|
||||
gst_buffer_unmap (out, outbase, -1);
|
||||
gst_buffer_unmap (out, &outmap);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (out) = timestamp;
|
||||
|
||||
|
@ -2473,7 +2477,7 @@ gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
|
|||
GST_DEBUG_OBJECT (rmdemux, "%" G_GSIZE_FORMAT " bytes left", size);
|
||||
|
||||
done:
|
||||
gst_buffer_unmap (in, base, -1);
|
||||
gst_buffer_unmap (in, &map);
|
||||
gst_buffer_unref (in);
|
||||
|
||||
return ret;
|
||||
|
@ -2547,11 +2551,14 @@ gst_rmdemux_parse_packet (GstRMDemux * rmdemux, GstBuffer * in, guint16 version)
|
|||
GstFlowReturn cret, ret;
|
||||
GstClockTime timestamp;
|
||||
gboolean key;
|
||||
guint8 *data, *base;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
guint8 flags;
|
||||
guint32 ts;
|
||||
|
||||
base = data = gst_buffer_map (in, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (in, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
/* stream number */
|
||||
id = RMDEMUX_GUINT16_GET (data);
|
||||
|
@ -2591,8 +2598,8 @@ gst_rmdemux_parse_packet (GstRMDemux * rmdemux, GstBuffer * in, guint16 version)
|
|||
data += 1;
|
||||
size -= 1;
|
||||
}
|
||||
offset = data - base;
|
||||
gst_buffer_unmap (in, base, -1);
|
||||
offset = data - map.data;
|
||||
gst_buffer_unmap (in, &map);
|
||||
|
||||
key = (flags & 0x02) != 0;
|
||||
GST_DEBUG_OBJECT (rmdemux, "flags %d, Keyframe %d", flags, key);
|
||||
|
@ -2654,7 +2661,7 @@ unknown_stream:
|
|||
{
|
||||
GST_WARNING_OBJECT (rmdemux, "No stream for stream id %d in parsing "
|
||||
"data packet", id);
|
||||
gst_buffer_unmap (in, base, -1);
|
||||
gst_buffer_unmap (in, &map);
|
||||
gst_buffer_unref (in);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -125,15 +125,15 @@ gst_rm_utils_read_tags (const guint8 * data, guint datalen,
|
|||
GstBuffer *
|
||||
gst_rm_utils_descramble_dnet_buffer (GstBuffer * buf)
|
||||
{
|
||||
guint8 *base, *data, *end, tmp;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 *data, *end, tmp;
|
||||
|
||||
buf = gst_buffer_make_writable (buf);
|
||||
|
||||
/* dnet = byte-order swapped AC3 */
|
||||
base = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
data = base;
|
||||
end = data + size;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
data = map.data;
|
||||
end = data + map.size;
|
||||
while ((data + 1) < end) {
|
||||
/* byte-swap */
|
||||
tmp = data[0];
|
||||
|
@ -141,7 +141,7 @@ gst_rm_utils_descramble_dnet_buffer (GstBuffer * buf)
|
|||
data[1] = tmp;
|
||||
data += sizeof (guint16);
|
||||
}
|
||||
gst_buffer_unmap (buf, base, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -223,9 +223,9 @@ static const gint sipr_swap_index[38][2] = {
|
|||
GstBuffer *
|
||||
gst_rm_utils_descramble_sipr_buffer (GstBuffer * buf)
|
||||
{
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gint n, bs;
|
||||
gsize size;
|
||||
|
||||
size = gst_buffer_get_size (buf);
|
||||
|
||||
|
@ -236,7 +236,7 @@ gst_rm_utils_descramble_sipr_buffer (GstBuffer * buf)
|
|||
|
||||
buf = gst_buffer_make_writable (buf);
|
||||
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
|
||||
/* we need to perform 38 swaps on the blocks */
|
||||
for (n = 0; n < 38; n++) {
|
||||
|
@ -247,9 +247,9 @@ gst_rm_utils_descramble_sipr_buffer (GstBuffer * buf)
|
|||
idx2 = bs * sipr_swap_index[n][1];
|
||||
|
||||
/* swap the blocks */
|
||||
gst_rm_utils_swap_nibbles (data, idx1, idx2, bs);
|
||||
gst_rm_utils_swap_nibbles (map.data, idx1, idx2, bs);
|
||||
}
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue