diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-01-25 16:20:41 +0100 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-01-25 16:22:09 +0100 |
commit | 9dc7571c75b9e1a7233e3db4e7147c30752e7513 (patch) | |
tree | a263f6d89766f28a5ddd14a78514a0bdebcd37e7 /gst/videoparsers | |
parent | 21073e98cf0c939318d90cc1b07eecd308e70732 (diff) | |
download | gstreamer-plugins-bad-9dc7571c75b9e1a7233e3db4e7147c30752e7513.tar.gz |
port some more to new memory API
Diffstat (limited to 'gst/videoparsers')
-rw-r--r-- | gst/videoparsers/gstdiracparse.c | 16 | ||||
-rw-r--r-- | gst/videoparsers/gsth263parse.c | 9 | ||||
-rw-r--r-- | gst/videoparsers/gsth264parse.c | 69 | ||||
-rw-r--r-- | gst/videoparsers/gstmpeg4videoparse.c | 25 | ||||
-rw-r--r-- | gst/videoparsers/gstmpegvideoparse.c | 44 | ||||
-rw-r--r-- | gst/videoparsers/h263parse.c | 11 |
6 files changed, 95 insertions, 79 deletions
diff --git a/gst/videoparsers/gstdiracparse.c b/gst/videoparsers/gstdiracparse.c index c6fa69204..7725c9713 100644 --- a/gst/videoparsers/gstdiracparse.c +++ b/gst/videoparsers/gstdiracparse.c @@ -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); diff --git a/gst/videoparsers/gsth263parse.c b/gst/videoparsers/gsth263parse.c index 5b369accb..bff68661b 100644 --- a/gst/videoparsers/gsth263parse.c +++ b/gst/videoparsers/gsth263parse.c @@ -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; } diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 98ebc3d21..311309434 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -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); diff --git a/gst/videoparsers/gstmpeg4videoparse.c b/gst/videoparsers/gstmpeg4videoparse.c index c13eb6fca..f04351662 100644 --- a/gst/videoparsers/gstmpeg4videoparse.c +++ b/gst/videoparsers/gstmpeg4videoparse.c @@ -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 */ diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c index 6f7cb7cb0..974fecc56 100644 --- a/gst/videoparsers/gstmpegvideoparse.c +++ b/gst/videoparsers/gstmpegvideoparse.c @@ -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) diff --git a/gst/videoparsers/h263parse.c b/gst/videoparsers/h263parse.c index 71f3661c9..96c4a1dba 100644 --- a/gst/videoparsers/h263parse.c +++ b/gst/videoparsers/h263parse.c @@ -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; } |