mpeg2: don't create sub-buffer for slice data.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 2 Jan 2013 16:23:53 +0000 (17:23 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 3 Jan 2013 08:08:19 +0000 (09:08 +0100)
Avoid creating a GstBuffer for slice data. Rather, directly use the codec
frame input buffer data. This is possible because the codec frame is valid
until end_frame() where we submit the VA buffers for decoding. Anyway, the
slice data buffer is copied into the VA buffer when it is created.

gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c

index c12e497..541e012 100644 (file)
@@ -1039,22 +1039,14 @@ decode_slice(GstVaapiDecoderMpeg2 *decoder, GstVaapiDecoderUnitMpeg2 *unit)
     GstVaapiPicture * const picture = priv->current_picture;
     GstVaapiSlice *slice;
     VASliceParameterBufferMPEG2 *slice_param;
-    GstMpegVideoPacket * const packet = &unit->packet;
     GstMpegVideoSliceHdr * const slice_hdr = &unit->data.slice_hdr;
 
     GST_DEBUG("slice %d (%u bytes)", slice_hdr->slice_vertical_position,
-              packet->size);
-
-    unit->base.buffer = gst_buffer_create_sub(
-        GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer,
-        unit->base.offset, unit->base.size);
-    if (!unit->base.buffer) {
-        GST_ERROR("failed to allocate slice data");
-        return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
-    }
+              unit->base.size);
 
     slice = GST_VAAPI_SLICE_NEW(MPEG2, decoder,
-        GST_BUFFER_DATA(unit->base.buffer), packet->size);
+        (GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) +
+         unit->base.offset), unit->base.size);
     if (!slice) {
         GST_ERROR("failed to allocate slice");
         return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;