From 57ed7e3f8b803f9aa50da72586260d381258e1d0 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Thu, 21 Mar 2013 13:28:05 +0100 Subject: [PATCH] decoder: sanitize uses of codec frame input buffer (cosmetics). Alias GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer to a simple "buffer" variable. --- gst-libs/gst/vaapi/gstvaapidecoder_h264.c | 6 ++++-- gst-libs/gst/vaapi/gstvaapidecoder_jpeg.c | 6 +++--- gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c | 11 ++++++----- gst-libs/gst/vaapi/gstvaapidecoder_mpeg4.c | 6 +++--- gst-libs/gst/vaapi/gstvaapidecoder_vc1.c | 5 +++-- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index bd318d7684..1ff9193428 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -2698,6 +2698,8 @@ decode_slice(GstVaapiDecoderH264 *decoder, GstVaapiDecoderUnit *unit) GstVaapiPictureH264 * const picture = priv->current_picture; GstH264SliceHdr * const slice_hdr = &pi->data.slice_hdr; GstVaapiSlice *slice; + GstBuffer * const buffer = + GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer; GST_DEBUG("slice (%u bytes)", pi->nalu.size); @@ -2707,8 +2709,8 @@ decode_slice(GstVaapiDecoderH264 *decoder, GstVaapiDecoderUnit *unit) } slice = GST_VAAPI_SLICE_NEW(H264, decoder, - (GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) + - unit->offset + pi->nalu.offset), pi->nalu.size); + (GST_BUFFER_DATA(buffer) + unit->offset + pi->nalu.offset), + pi->nalu.size); if (!slice) { GST_ERROR("failed to allocate slice"); return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_jpeg.c b/gst-libs/gst/vaapi/gstvaapidecoder_jpeg.c index f3221b992a..65e648059d 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_jpeg.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_jpeg.c @@ -681,14 +681,14 @@ gst_vaapi_decoder_jpeg_decode(GstVaapiDecoder *base_decoder, { GstVaapiDecoderJpeg * const decoder = GST_VAAPI_DECODER_JPEG(base_decoder); GstVaapiDecoderStatus status; + GstBuffer * const buffer = + GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer; status = ensure_decoder(decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; - unit->buffer = gst_buffer_create_sub( - GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer, - unit->offset, unit->size); + unit->buffer = gst_buffer_create_sub(buffer, unit->offset, unit->size); if (!unit->buffer) return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c index c889e9a497..074d65e8e0 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c @@ -1194,6 +1194,8 @@ decode_slice(GstVaapiDecoderMpeg2 *decoder, GstVaapiDecoderUnit *unit) GstVaapiSlice *slice; VASliceParameterBufferMPEG2 *slice_param; GstMpegVideoSliceHdr * const slice_hdr = unit->parsed_info; + GstBuffer * const buffer = + GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer; GST_DEBUG("slice %d (%u bytes)", slice_hdr->slice_vertical_position, unit->size); @@ -1202,8 +1204,7 @@ decode_slice(GstVaapiDecoderMpeg2 *decoder, GstVaapiDecoderUnit *unit) return GST_VAAPI_DECODER_STATUS_SUCCESS; slice = GST_VAAPI_SLICE_NEW(MPEG2, decoder, - (GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) + - unit->offset), unit->size); + (GST_BUFFER_DATA(buffer) + unit->offset), unit->size); if (!slice) { GST_ERROR("failed to allocate slice"); return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; @@ -1473,14 +1474,14 @@ gst_vaapi_decoder_mpeg2_decode(GstVaapiDecoder *base_decoder, GST_VAAPI_DECODER_MPEG2_CAST(base_decoder); GstVaapiDecoderStatus status; GstMpegVideoPacket packet; + GstBuffer * const buffer = + GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer; status = ensure_decoder(decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; - packet.data = - (GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) + - unit->offset); + packet.data = GST_BUFFER_DATA(buffer) + unit->offset; packet.size = unit->size; packet.type = packet.data[3]; packet.offset = 4; diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg4.c b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg4.c index 0dd3425570..8d800b4104 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg4.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg4.c @@ -1086,14 +1086,14 @@ gst_vaapi_decoder_mpeg4_decode(GstVaapiDecoder *base_decoder, GstVaapiDecoderMpeg4 * const decoder = GST_VAAPI_DECODER_MPEG4(base_decoder); GstVaapiDecoderStatus status; + GstBuffer * const buffer = + GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer; status = ensure_decoder(decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; - unit->buffer = gst_buffer_create_sub( - GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer, - unit->offset, unit->size); + unit->buffer = gst_buffer_create_sub(buffer, unit->offset, unit->size); if (!unit->buffer) return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c b/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c index d42f72e151..754729076b 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c @@ -1253,14 +1253,15 @@ gst_vaapi_decoder_vc1_decode(GstVaapiDecoder *base_decoder, { GstVaapiDecoderVC1 * const decoder = GST_VAAPI_DECODER_VC1(base_decoder); GstVaapiDecoderStatus status; + GstBuffer * const buffer = + GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer; status = ensure_decoder(decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; status = decode_buffer(decoder, - (GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) + - unit->offset), unit->size); + (GST_BUFFER_DATA(buffer) + unit->offset), unit->size); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; return GST_VAAPI_DECODER_STATUS_SUCCESS;