port some more to new memory API
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 25 Jan 2012 15:20:41 +0000 (16:20 +0100)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 25 Jan 2012 15:22:09 +0000 (16:22 +0100)
gst/multifdsink/gstmultifdsink.c
gst/pcapparse/gstirtspparse.c
gst/pcapparse/gstpcapparse.c
gst/rtpvp8/gstrtpvp8pay.c
gst/videoparsers/gstdiracparse.c
gst/videoparsers/gsth263parse.c
gst/videoparsers/gsth264parse.c
gst/videoparsers/gstmpeg4videoparse.c
gst/videoparsers/gstmpegvideoparse.c
gst/videoparsers/h263parse.c

index 061fd68..e54fcea 100644 (file)
@@ -1974,14 +1974,13 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
     if (client->sending) {
       ssize_t wrote;
       GstBuffer *head;
-      guint8 *data;
-      gsize size;
+      GstMapInfo map;
 
       /* pick first buffer from list */
       head = GST_BUFFER (client->sending->data);
 
-      data = gst_buffer_map (head, &size, NULL, GST_MAP_READ);
-      maxsize = size - client->bufoffset;
+      gst_buffer_map (head, &map, GST_MAP_READ);
+      maxsize = map.size - client->bufoffset;
 
       /* try to write the complete buffer */
 #ifdef MSG_NOSIGNAL
@@ -1990,11 +1989,11 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
 #define FLAGS 0
 #endif
       if (client->is_socket) {
-        wrote = send (fd, data + client->bufoffset, maxsize, FLAGS);
+        wrote = send (fd, map.data + client->bufoffset, maxsize, FLAGS);
       } else {
-        wrote = write (fd, data + client->bufoffset, maxsize);
+        wrote = write (fd, map.data + client->bufoffset, maxsize);
       }
-      gst_buffer_unmap (head, data, size);
+      gst_buffer_unmap (head, &map);
 
       if (wrote < 0) {
         /* hmm error.. */
index 07ef375..1a47386 100644 (file)
@@ -166,24 +166,23 @@ gst_irtsp_parse_check_valid_frame (GstBaseParse * parse,
   GstBuffer *buf = frame->buffer;
   GstByteReader reader;
   gint off;
-  gsize size;
-  guint8 *data;
+  GstMapInfo map;
   gboolean ret = FALSE;
 
-  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
-  if (G_UNLIKELY (size < 4))
+  gst_buffer_map (buf, &map, GST_MAP_READ);
+  if (G_UNLIKELY (map.size < 4))
     goto exit;
 
-  gst_byte_reader_init (&reader, data, size);
+  gst_byte_reader_init (&reader, map.data, map.size);
 
   off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffff0000,
-      0x24000000 + (IRTSPParse->channel_id << 16), 0, size);
+      0x24000000 + (IRTSPParse->channel_id << 16), 0, map.size);
 
   GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
 
   /* didn't find anything that looks like a sync word, skip */
   if (off < 0) {
-    *skipsize = size - 3;
+    *skipsize = map.size - 3;
     goto exit;
   }
 
@@ -193,12 +192,12 @@ gst_irtsp_parse_check_valid_frame (GstBaseParse * parse,
     goto exit;
   }
 
-  *framesize = GST_READ_UINT16_BE (data + 2) + 4;
+  *framesize = GST_READ_UINT16_BE (map.data + 2) + 4;
   GST_LOG_OBJECT (parse, "got frame size %d", *framesize);
   ret = TRUE;
 
 exit:
-  gst_buffer_unmap (buf, data, -1);
+  gst_buffer_unmap (buf, &map);
 
   return ret;
 }
index 2c9fa6e..01a333f 100644 (file)
@@ -471,7 +471,7 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
           if (gst_pcap_parse_scan_frame (self, data, self->cur_packet_size,
                   &payload_data, &payload_size)) {
             GstBuffer *out_buf;
-            guint8 *data;
+            GstMapInfo map;
 
             out_buf = gst_buffer_new_and_alloc (payload_size);
             if (out_buf) {
@@ -485,9 +485,9 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
                 }
               }
 
-              data = gst_buffer_map (out_buf, NULL, NULL, GST_MAP_WRITE);
-              memcpy (data, payload_data, payload_size);
-              gst_buffer_unmap (out_buf, data, -1);
+              gst_buffer_map (out_buf, &map, GST_MAP_WRITE);
+              memcpy (map.data, payload_data, payload_size);
+              gst_buffer_unmap (out_buf, &map);
               GST_BUFFER_TIMESTAMP (out_buf) = self->cur_ts;
 
               if (!self->newsegment_sent &&
index b3342db..e96a044 100644 (file)
@@ -100,6 +100,7 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
   GstBitReader *reader = NULL;
   guint8 *data;
   gsize size;
+  GstMapInfo map;
   int i;
   gboolean keyframe;
   guint32 partition0_size;
@@ -113,10 +114,11 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
   if (G_UNLIKELY (gst_buffer_get_size (buffer) < 3))
     goto error;
 
-  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
-  if (data == NULL)
+  if (!gst_buffer_map (buffer, &map, GST_MAP_READ) || !map.data)
     goto error;
 
+  data = map.data;
+  size = map.size;
   reader = gst_bit_reader_new (data, size);
 
   self->is_keyframe = keyframe = ((data[0] & 0x1) == 0);
@@ -255,14 +257,14 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
   self->partition_offset[i + 1] = size;
 
   gst_bit_reader_free (reader);
-  gst_buffer_unmap (buffer, data, size);
+  gst_buffer_unmap (buffer, &map);
   return TRUE;
 
 error:
   GST_DEBUG ("Failed to parse frame");
   if (reader) {
     gst_bit_reader_free (reader);
-    gst_buffer_unmap (buffer, data, size);
+    gst_buffer_unmap (buffer, &map);
   }
   return FALSE;
 }
index c6fa692..7725c97 100644 (file)
@@ -219,12 +219,15 @@ gst_dirac_parse_check_valid_frame (GstBaseParse * parse,
 {
   int off;
   guint32 next_header;
+  GstMapInfo map;
   guint8 *data;
   gsize size;
   gboolean have_picture = FALSE;
   int offset;
 
-  data = gst_buffer_map (frame->buffer, &size, NULL, GST_MAP_READ);
+  gst_buffer_map (frame->buffer, &map, GST_MAP_READ);
+  data = map.data;
+  size = map.size;
 
   if (G_UNLIKELY (size < 13))
     goto out;
@@ -286,7 +289,7 @@ gst_dirac_parse_check_valid_frame (GstBaseParse * parse,
     }
   }
 
-  gst_buffer_unmap (frame->buffer, data, size);
+  gst_buffer_unmap (frame->buffer, &map);
 
   *framesize = offset;
   GST_DEBUG ("framesize %d", *framesize);
@@ -294,7 +297,7 @@ gst_dirac_parse_check_valid_frame (GstBaseParse * parse,
   return TRUE;
 
 out:
-  gst_buffer_unmap (frame->buffer, data, size);
+  gst_buffer_unmap (frame->buffer, &map);
   return FALSE;
 }
 
@@ -302,6 +305,7 @@ static GstFlowReturn
 gst_dirac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
 {
   GstDiracParse *diracparse = GST_DIRAC_PARSE (parse);
+  GstMapInfo map;
   guint8 *data;
   gsize size;
 
@@ -309,7 +313,9 @@ gst_dirac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
      a checked frame. */
   /* MUST implement */
 
-  data = gst_buffer_map (frame->buffer, &size, NULL, GST_MAP_READ);
+  gst_buffer_map (frame->buffer, &map, GST_MAP_READ);
+  data = map.data;
+  size = map.size;
 
   //GST_ERROR("got here %d", size);
 
@@ -343,7 +349,7 @@ gst_dirac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
     }
   }
 
-  gst_buffer_unmap (frame->buffer, data, size);
+  gst_buffer_unmap (frame->buffer, &map);
 
   gst_base_parse_set_min_frame_size (parse, 13);
 
index 5b369ac..bff6866 100644 (file)
@@ -151,13 +151,12 @@ gst_h263_parse_sink_event (GstBaseParse * parse, GstEvent * event)
 static guint
 find_psc (GstBuffer * buffer, guint skip)
 {
-  guint8 *buf_data;
-  gsize buf_size;
+  GstMapInfo map;
   GstByteReader br;
   guint psc_pos = -1, psc;
 
-  buf_data = gst_buffer_map (buffer, &buf_size, NULL, GST_MAP_READ);
-  gst_byte_reader_init (&br, buf_data, buf_size);
+  gst_buffer_map (buffer, &map, GST_MAP_READ);
+  gst_byte_reader_init (&br, map.data, map.size);
 
   if (!gst_byte_reader_set_pos (&br, skip))
     goto out;
@@ -175,7 +174,7 @@ find_psc (GstBuffer * buffer, guint skip)
   }
 
 out:
-  gst_buffer_unmap (buffer, buf_data, buf_size);
+  gst_buffer_unmap (buffer, &map);
   return psc_pos;
 }
 
index 98ebc3d..3113094 100644 (file)
@@ -627,6 +627,7 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse,
 {
   GstH264Parse *h264parse = GST_H264_PARSE (parse);
   GstBuffer *buffer = frame->buffer;
+  GstMapInfo map;
   guint8 *data;
   gsize size;
   guint current_off = 0;
@@ -634,11 +635,13 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse,
   GstH264NalParser *nalparser = h264parse->nalparser;
   GstH264NalUnit nalu;
 
-  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  gst_buffer_map (buffer, &map, GST_MAP_READ);
+  data = map.data;
+  size = map.size;
 
   /* expect at least 3 bytes startcode == sc, and 2 bytes NALU payload */
   if (G_UNLIKELY (size < 5)) {
-    gst_buffer_unmap (buffer, data, size);
+    gst_buffer_unmap (buffer, &map);
     return FALSE;
   }
 
@@ -770,7 +773,7 @@ end:
   *framesize = nalu.offset + nalu.size - h264parse->nalu.sc_offset;
   h264parse->current_off = current_off;
 
-  gst_buffer_unmap (buffer, data, size);
+  gst_buffer_unmap (buffer, &map);
   return TRUE;
 
 parsing_error:
@@ -795,7 +798,7 @@ more:
 
   /* Fall-through. */
 out:
-  gst_buffer_unmap (buffer, data, size);
+  gst_buffer_unmap (buffer, &map);
   return FALSE;
 
 invalid:
@@ -811,7 +814,8 @@ gst_h264_parse_make_codec_data (GstH264Parse * h264parse)
   gint i, sps_size = 0, pps_size = 0, num_sps = 0, num_pps = 0;
   guint8 profile_idc = 0, profile_comp = 0, level_idc = 0;
   gboolean found = FALSE;
-  guint8 *buf_data, *data;
+  GstMapInfo map;
+  guint8 *data;
 
   /* only nal payload in stored nals */
 
@@ -846,8 +850,8 @@ gst_h264_parse_make_codec_data (GstH264Parse * h264parse)
     return NULL;
 
   buf = gst_buffer_new_allocate (NULL, 5 + 1 + sps_size + 1 + pps_size, 0);
-  buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
-  data = buf_data;
+  gst_buffer_map (buf, &map, GST_MAP_WRITE);
+  data = map.data;
 
   data[0] = 1;                  /* AVC Decoder Configuration Record ver. 1 */
   data[1] = profile_idc;        /* profile_idc                             */
@@ -877,7 +881,7 @@ gst_h264_parse_make_codec_data (GstH264Parse * h264parse)
     }
   }
 
-  gst_buffer_unmap (buf, buf_data, -1);
+  gst_buffer_unmap (buf, &map);
 
   return buf;
 }
@@ -1007,15 +1011,14 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps)
       h264parse->align == GST_H264_PARSE_ALIGN_AU) {
     buf = gst_h264_parse_make_codec_data (h264parse);
     if (buf && h264parse->codec_data) {
-      gsize size;
-      gpointer data;
+      GstMapInfo map;
 
-      data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
-      if (size != gst_buffer_get_size (h264parse->codec_data) ||
-          gst_buffer_memcmp (h264parse->codec_data, 0, data, size))
+      gst_buffer_map (buf, &map, GST_MAP_READ);
+      if (map.size != gst_buffer_get_size (h264parse->codec_data) ||
+          gst_buffer_memcmp (h264parse->codec_data, 0, map.data, map.size))
         modified = TRUE;
 
-      gst_buffer_unmap (buf, data, size);
+      gst_buffer_unmap (buf, &map);
     } else {
       if (h264parse->codec_data)
         buf = gst_buffer_ref (h264parse->codec_data);
@@ -1292,12 +1295,12 @@ static GstFlowReturn
 gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse, GstBuffer * nal,
     GstClockTime ts)
 {
-  gpointer data;
-  gsize size;
+  GstMapInfo map;
 
-  data = gst_buffer_map (nal, &size, NULL, GST_MAP_READ);
-  nal = gst_h264_parse_wrap_nal (h264parse, h264parse->format, data, size);
-  gst_buffer_unmap (nal, data, size);
+  gst_buffer_map (nal, &map, GST_MAP_READ);
+  nal = gst_h264_parse_wrap_nal (h264parse, h264parse->format,
+      map.data, map.size);
+  gst_buffer_unmap (nal, &map);
 
   GST_BUFFER_TIMESTAMP (nal) = ts;
   GST_BUFFER_DURATION (nal) = 0;
@@ -1548,6 +1551,7 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
   /* packetized video has a codec_data */
   if (format != GST_H264_PARSE_FORMAT_BYTE &&
       (value = gst_structure_get_value (str, "codec_data"))) {
+    GstMapInfo map;
     guint8 *data;
     guint num_sps, num_pps, profile;
     gint i;
@@ -1559,16 +1563,18 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
     codec_data = gst_value_get_buffer (value);
     if (!codec_data)
       goto wrong_type;
-    data = gst_buffer_map (codec_data, &size, NULL, GST_MAP_READ);
+    gst_buffer_map (codec_data, &map, GST_MAP_READ);
+    data = map.data;
+    size = map.size;
 
     /* parse the avcC data */
     if (size < 8) {
-      gst_buffer_unmap (codec_data, data, size);
+      gst_buffer_unmap (codec_data, &map);
       goto avcc_too_small;
     }
     /* parse the version, this must be 1 */
     if (data[0] != 1) {
-      gst_buffer_unmap (codec_data, data, size);
+      gst_buffer_unmap (codec_data, &map);
       goto wrong_version;
     }
 
@@ -1591,7 +1597,7 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
       parseres = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
           data, off, size, 2, &nalu);
       if (parseres != GST_H264_PARSER_OK) {
-        gst_buffer_unmap (codec_data, data, size);
+        gst_buffer_unmap (codec_data, &map);
         goto avcc_too_small;
       }
 
@@ -1606,7 +1612,7 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
       parseres = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
           data, off, size, 2, &nalu);
       if (parseres != GST_H264_PARSER_OK) {
-        gst_buffer_unmap (codec_data, data, size);
+        gst_buffer_unmap (codec_data, &map);
         goto avcc_too_small;
       }
 
@@ -1614,7 +1620,7 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
       off = nalu.offset + nalu.size;
     }
 
-    gst_buffer_unmap (codec_data, data, size);
+    gst_buffer_unmap (codec_data, &map);
 
     h264parse->codec_data = gst_buffer_ref (codec_data);
 
@@ -1840,8 +1846,7 @@ gst_h264_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
     GstH264ParserResult parse_res;
     GstH264NalUnit nalu;
     const guint nl = h264parse->nal_length_size;
-    gpointer data;
-    gsize size;
+    GstMapInfo map;
 
     if (nl < 1 || nl > 4) {
       GST_DEBUG_OBJECT (h264parse, "insufficient data to split input");
@@ -1850,13 +1855,13 @@ gst_h264_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
       return GST_FLOW_NOT_NEGOTIATED;
     }
 
-    data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+    gst_buffer_map (buffer, &map, GST_MAP_READ);
 
     GST_LOG_OBJECT (h264parse,
-        "processing packet buffer of size %" G_GSIZE_FORMAT, size);
+        "processing packet buffer of size %" G_GSIZE_FORMAT, map.size);
 
     parse_res = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
-        data, 0, size, nl, &nalu);
+        map.data, 0, map.size, nl, &nalu);
 
     while (parse_res == GST_H264_PARSER_OK) {
       GST_DEBUG_OBJECT (h264parse, "AVC nal offset %d",
@@ -1881,10 +1886,10 @@ gst_h264_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
       }
 
       parse_res = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
-          data, nalu.offset + nalu.size, size, nl, &nalu);
+          map.data, nalu.offset + nalu.size, map.size, nl, &nalu);
     }
 
-    gst_buffer_unmap (buffer, data, size);
+    gst_buffer_unmap (buffer, &map);
 
     if (h264parse->split_packetized) {
       gst_buffer_unref (buffer);
index c13eb6f..f043516 100644 (file)
@@ -369,12 +369,15 @@ gst_mpeg4vparse_check_valid_frame (GstBaseParse * parse,
 {
   GstMpeg4VParse *mp4vparse = GST_MPEG4VIDEO_PARSE (parse);
   GstMpeg4Packet packet;
+  GstMapInfo map;
   guint8 *data = NULL;
   gsize size;
   gint off = 0;
   gboolean ret = FALSE;
 
-  data = gst_buffer_map (frame->buffer, &size, NULL, GST_MAP_READ);
+  gst_buffer_map (frame->buffer, &map, GST_MAP_READ);
+  data = map.data;
+  size = map.size;
 
 retry:
   /* at least start code and subsequent byte */
@@ -475,7 +478,7 @@ next:
   }
 
 out:
-  gst_buffer_unmap (frame->buffer, data, size);
+  gst_buffer_unmap (frame->buffer, &map);
   return ret;
 }
 
@@ -671,16 +674,17 @@ gst_mpeg4vparse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
           "interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
 
       if (GST_TIME_AS_SECONDS (diff) >= mp4vparse->interval || push_codec) {
-        guint8 *cdata;
+        GstMapInfo cmap;
         gsize csize;
         gboolean diffconf;
 
         /* we need to send config now first */
         GST_INFO_OBJECT (parse, "inserting config in stream");
-        cdata = gst_buffer_map (mp4vparse->config, &csize, NULL, GST_MAP_READ);
-        diffconf = (gst_buffer_get_size (buffer) < csize)
-            || gst_buffer_memcmp (buffer, 0, cdata, csize);
-        gst_buffer_unmap (mp4vparse->config, cdata, csize);
+        gst_buffer_map (mp4vparse->config, &cmap, GST_MAP_READ);
+        diffconf = (gst_buffer_get_size (buffer) < cmap.size)
+            || gst_buffer_memcmp (buffer, 0, cmap.data, cmap.size);
+        csize = cmap.size;
+        gst_buffer_unmap (mp4vparse->config, &cmap);
 
         /* avoid inserting duplicate config */
         if (diffconf) {
@@ -713,6 +717,7 @@ gst_mpeg4vparse_set_caps (GstBaseParse * parse, GstCaps * caps)
   GstStructure *s;
   const GValue *value;
   GstBuffer *buf;
+  GstMapInfo map;
   guint8 *data;
   gsize size;
 
@@ -728,7 +733,9 @@ gst_mpeg4vparse_set_caps (GstBaseParse * parse, GstCaps * caps)
     /* best possible parse attempt,
      * src caps are based on sink caps so it will end up in there
      * whether sucessful or not */
-    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    gst_buffer_map (buf, &map, GST_MAP_READ);
+    data = map.data;
+    size = map.size;
     res = gst_mpeg4_parse (&packet, TRUE, NULL, data, 0, size);
 
     while (res == GST_MPEG4_PARSER_OK || res == GST_MPEG4_PARSER_NO_PACKET_END) {
@@ -742,7 +749,7 @@ gst_mpeg4vparse_set_caps (GstBaseParse * parse, GstCaps * caps)
 
     /* And take it as config */
     gst_mpeg4vparse_process_config (mp4vparse, data, 3, size);
-    gst_buffer_unmap (buf, data, size);
+    gst_buffer_unmap (buf, &map);
   }
 
   /* let's not interfere and accept regardless of config parsing success */
index 6f7cb7c..974fecc 100644 (file)
@@ -229,21 +229,21 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
     guint size)
 {
   GList *tmp;
-  guint8 *buf_data, *data;
-  gsize buf_size;
+  GstMapInfo map;
+  guint8 *data;
 
-  buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
-  data = buf_data + mpvparse->seq_offset;
+  gst_buffer_map (buf, &map, GST_MAP_READ);
+  data = map.data + mpvparse->seq_offset;
 
   /* only do stuff if something new */
   if (mpvparse->config && size == gst_buffer_get_size (mpvparse->config) &&
       gst_buffer_memcmp (mpvparse->config, 0, data, size) == 0) {
-    gst_buffer_unmap (buf, buf_data, buf_size);
+    gst_buffer_unmap (buf, &map);
     return TRUE;
   }
 
   if (gst_mpeg_video_parse_sequence_header (&mpvparse->sequencehdr, data,
-          buf_size - mpvparse->seq_offset, 0)) {
+          map.size - mpvparse->seq_offset, 0)) {
     if (mpvparse->fps_num == 0 || mpvparse->fps_den == 0) {
       mpvparse->fps_num = mpvparse->sequencehdr.fps_n;
       mpvparse->fps_den = mpvparse->sequencehdr.fps_d;
@@ -252,7 +252,7 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
     GST_DEBUG_OBJECT (mpvparse,
         "failed to parse config data (size %d) at offset %d",
         size, mpvparse->seq_offset);
-    gst_buffer_unmap (buf, buf_data, buf_size);
+    gst_buffer_unmap (buf, &map);
     return FALSE;
   }
 
@@ -270,7 +270,7 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
         mpvparse->mpeg_version = 2;
 
         if (gst_mpeg_video_parse_sequence_extension (&mpvparse->sequenceext,
-                buf_data, buf_size, tpoffsz->offset)) {
+                map.data, map.size, tpoffsz->offset)) {
           mpvparse->fps_num =
               mpvparse->sequencehdr.fps_n * (mpvparse->sequenceext.fps_n_ext +
               1) * 2;
@@ -292,7 +292,7 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
   /* trigger src caps update */
   mpvparse->update_caps = TRUE;
 
-  gst_buffer_unmap (buf, buf_data, buf_size);
+  gst_buffer_unmap (buf, &map);
 
   return TRUE;
 }
@@ -359,12 +359,11 @@ static void
 parse_picture_extension (GstMpegvParse * mpvparse, GstBuffer * buf, guint off)
 {
   GstMpegVideoPictureExt ext;
-  gpointer data;
-  gsize size;
+  GstMapInfo map;
 
-  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  gst_buffer_map (buf, &map, GST_MAP_READ);
 
-  if (gst_mpeg_video_parse_picture_extension (&ext, data, size, off)) {
+  if (gst_mpeg_video_parse_picture_extension (&ext, map.data, map.size, off)) {
     mpvparse->frame_repeat_count = 1;
 
     if (ext.repeat_first_field) {
@@ -379,7 +378,7 @@ parse_picture_extension (GstMpegvParse * mpvparse, GstBuffer * buf, guint off)
     }
   }
 
-  gst_buffer_unmap (buf, data, size);
+  gst_buffer_unmap (buf, &map);
 }
 
 /* caller guarantees at least start code in @buf at @off */
@@ -438,11 +437,11 @@ gst_mpegv_parse_process_sc (GstMpegvParse * mpvparse,
 
   /* extract some picture info if there is any in the frame being terminated */
   if (ret && mpvparse->pic_offset >= 0 && mpvparse->pic_offset < off) {
-    gsize size;
-    gpointer data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    GstMapInfo map;
 
+    gst_buffer_map (buf, &map, GST_MAP_READ);
     if (gst_mpeg_video_parse_picture_header (&mpvparse->pichdr,
-            data, size, mpvparse->pic_offset))
+            map.data, map.size, mpvparse->pic_offset))
       GST_LOG_OBJECT (mpvparse, "picture_coding_type %d (%s), ending"
           "frame of size %d", mpvparse->pichdr.pic_type,
           picture_type_name (mpvparse->pichdr.pic_type), off - 4);
@@ -450,7 +449,7 @@ gst_mpegv_parse_process_sc (GstMpegvParse * mpvparse,
       GST_LOG_OBJECT (mpvparse, "Couldn't parse picture at offset %d",
           mpvparse->pic_offset);
 
-    gst_buffer_unmap (buf, data, size);
+    gst_buffer_unmap (buf, &map);
   }
 
   return ret;
@@ -503,7 +502,7 @@ gst_mpegv_parse_check_valid_frame (GstBaseParse * parse,
   gboolean ret = FALSE;
   GList *tmp;
   gint off = 0, fsize = -1;
-  gpointer buf_data;
+  GstMapInfo map;
   gsize buf_size;
 
   update_frame_parsing_status (mpvparse, frame);
@@ -511,9 +510,10 @@ gst_mpegv_parse_check_valid_frame (GstBaseParse * parse,
   if (mpvparse->last_sc >= 0)
     off = mpvparse->last_sc;
 
-  buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
-  mpvparse->typeoffsize = gst_mpeg_video_parse (buf_data, buf_size, off);
-  gst_buffer_unmap (buf, buf_data, buf_size);
+  gst_buffer_map (buf, &map, GST_MAP_READ);
+  buf_size = map.size;
+  mpvparse->typeoffsize = gst_mpeg_video_parse (map.data, map.size, off);
+  gst_buffer_unmap (buf, &map);
 
   /* No sc found */
   if (mpvparse->typeoffsize == NULL)
index 71f3661..96c4a1d 100644 (file)
@@ -73,18 +73,17 @@ gst_h263_parse_get_params (H263Params * params, GstBuffer * buffer,
   };
 
   GstBitReader br;
-  guint8 *buf_data;
-  gsize buf_size;
+  GstMapInfo map;
   guint8 tr;
   guint32 psc = 0, temp32;
   guint8 temp8, pquant;
   gboolean hasplusptype;
 
-  buf_data = gst_buffer_map (buffer, &buf_size, NULL, GST_MAP_READ);
+  gst_buffer_map (buffer, &map, GST_MAP_READ);
 
   /* FIXME: we can optimise a little by checking the value of available
    * instead of calling using the bit reader's get_bits_* functions. */
-  gst_bit_reader_init (&br, buf_data, buf_size);
+  gst_bit_reader_init (&br, map.data, map.size);
 
   /* Default PCF is CIF PCF = 30000/1001 */
   params->pcfnum = 30000;
@@ -449,12 +448,12 @@ gst_h263_parse_get_params (H263Params * params, GstBuffer * buffer,
 done:
   *state = GOT_HEADER;
 more:
-  gst_buffer_unmap (buffer, buf_data, buf_size);
+  gst_buffer_unmap (buffer, &map);
   return GST_FLOW_OK;
 
 beach:
   *state = PASSTHROUGH;
-  gst_buffer_unmap (buffer, buf_data, buf_size);
+  gst_buffer_unmap (buffer, &map);
   return GST_FLOW_OK;
 }