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