mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
decoder: sanitize uses of codec frame input buffer (cosmetics).
Alias GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer to a simple "buffer" variable.
This commit is contained in:
parent
9e1da76971
commit
57ed7e3f8b
5 changed files with 19 additions and 15 deletions
|
@ -2698,6 +2698,8 @@ decode_slice(GstVaapiDecoderH264 *decoder, GstVaapiDecoderUnit *unit)
|
||||||
GstVaapiPictureH264 * const picture = priv->current_picture;
|
GstVaapiPictureH264 * const picture = priv->current_picture;
|
||||||
GstH264SliceHdr * const slice_hdr = &pi->data.slice_hdr;
|
GstH264SliceHdr * const slice_hdr = &pi->data.slice_hdr;
|
||||||
GstVaapiSlice *slice;
|
GstVaapiSlice *slice;
|
||||||
|
GstBuffer * const buffer =
|
||||||
|
GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer;
|
||||||
|
|
||||||
GST_DEBUG("slice (%u bytes)", pi->nalu.size);
|
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,
|
slice = GST_VAAPI_SLICE_NEW(H264, decoder,
|
||||||
(GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) +
|
(GST_BUFFER_DATA(buffer) + unit->offset + pi->nalu.offset),
|
||||||
unit->offset + pi->nalu.offset), pi->nalu.size);
|
pi->nalu.size);
|
||||||
if (!slice) {
|
if (!slice) {
|
||||||
GST_ERROR("failed to allocate slice");
|
GST_ERROR("failed to allocate slice");
|
||||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
|
|
@ -681,14 +681,14 @@ gst_vaapi_decoder_jpeg_decode(GstVaapiDecoder *base_decoder,
|
||||||
{
|
{
|
||||||
GstVaapiDecoderJpeg * const decoder = GST_VAAPI_DECODER_JPEG(base_decoder);
|
GstVaapiDecoderJpeg * const decoder = GST_VAAPI_DECODER_JPEG(base_decoder);
|
||||||
GstVaapiDecoderStatus status;
|
GstVaapiDecoderStatus status;
|
||||||
|
GstBuffer * const buffer =
|
||||||
|
GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer;
|
||||||
|
|
||||||
status = ensure_decoder(decoder);
|
status = ensure_decoder(decoder);
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
unit->buffer = gst_buffer_create_sub(
|
unit->buffer = gst_buffer_create_sub(buffer, unit->offset, unit->size);
|
||||||
GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer,
|
|
||||||
unit->offset, unit->size);
|
|
||||||
if (!unit->buffer)
|
if (!unit->buffer)
|
||||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
|
||||||
|
|
|
@ -1194,6 +1194,8 @@ decode_slice(GstVaapiDecoderMpeg2 *decoder, GstVaapiDecoderUnit *unit)
|
||||||
GstVaapiSlice *slice;
|
GstVaapiSlice *slice;
|
||||||
VASliceParameterBufferMPEG2 *slice_param;
|
VASliceParameterBufferMPEG2 *slice_param;
|
||||||
GstMpegVideoSliceHdr * const slice_hdr = unit->parsed_info;
|
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,
|
GST_DEBUG("slice %d (%u bytes)", slice_hdr->slice_vertical_position,
|
||||||
unit->size);
|
unit->size);
|
||||||
|
@ -1202,8 +1204,7 @@ decode_slice(GstVaapiDecoderMpeg2 *decoder, GstVaapiDecoderUnit *unit)
|
||||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||||
|
|
||||||
slice = GST_VAAPI_SLICE_NEW(MPEG2, decoder,
|
slice = GST_VAAPI_SLICE_NEW(MPEG2, decoder,
|
||||||
(GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) +
|
(GST_BUFFER_DATA(buffer) + unit->offset), unit->size);
|
||||||
unit->offset), unit->size);
|
|
||||||
if (!slice) {
|
if (!slice) {
|
||||||
GST_ERROR("failed to allocate slice");
|
GST_ERROR("failed to allocate slice");
|
||||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
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);
|
GST_VAAPI_DECODER_MPEG2_CAST(base_decoder);
|
||||||
GstVaapiDecoderStatus status;
|
GstVaapiDecoderStatus status;
|
||||||
GstMpegVideoPacket packet;
|
GstMpegVideoPacket packet;
|
||||||
|
GstBuffer * const buffer =
|
||||||
|
GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer;
|
||||||
|
|
||||||
status = ensure_decoder(decoder);
|
status = ensure_decoder(decoder);
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
packet.data =
|
packet.data = GST_BUFFER_DATA(buffer) + unit->offset;
|
||||||
(GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) +
|
|
||||||
unit->offset);
|
|
||||||
packet.size = unit->size;
|
packet.size = unit->size;
|
||||||
packet.type = packet.data[3];
|
packet.type = packet.data[3];
|
||||||
packet.offset = 4;
|
packet.offset = 4;
|
||||||
|
|
|
@ -1086,14 +1086,14 @@ gst_vaapi_decoder_mpeg4_decode(GstVaapiDecoder *base_decoder,
|
||||||
GstVaapiDecoderMpeg4 * const decoder =
|
GstVaapiDecoderMpeg4 * const decoder =
|
||||||
GST_VAAPI_DECODER_MPEG4(base_decoder);
|
GST_VAAPI_DECODER_MPEG4(base_decoder);
|
||||||
GstVaapiDecoderStatus status;
|
GstVaapiDecoderStatus status;
|
||||||
|
GstBuffer * const buffer =
|
||||||
|
GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer;
|
||||||
|
|
||||||
status = ensure_decoder(decoder);
|
status = ensure_decoder(decoder);
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
unit->buffer = gst_buffer_create_sub(
|
unit->buffer = gst_buffer_create_sub(buffer, unit->offset, unit->size);
|
||||||
GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer,
|
|
||||||
unit->offset, unit->size);
|
|
||||||
if (!unit->buffer)
|
if (!unit->buffer)
|
||||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
|
||||||
|
|
|
@ -1253,14 +1253,15 @@ gst_vaapi_decoder_vc1_decode(GstVaapiDecoder *base_decoder,
|
||||||
{
|
{
|
||||||
GstVaapiDecoderVC1 * const decoder = GST_VAAPI_DECODER_VC1(base_decoder);
|
GstVaapiDecoderVC1 * const decoder = GST_VAAPI_DECODER_VC1(base_decoder);
|
||||||
GstVaapiDecoderStatus status;
|
GstVaapiDecoderStatus status;
|
||||||
|
GstBuffer * const buffer =
|
||||||
|
GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer;
|
||||||
|
|
||||||
status = ensure_decoder(decoder);
|
status = ensure_decoder(decoder);
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
status = decode_buffer(decoder,
|
status = decode_buffer(decoder,
|
||||||
(GST_BUFFER_DATA(GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer) +
|
(GST_BUFFER_DATA(buffer) + unit->offset), unit->size);
|
||||||
unit->offset), unit->size);
|
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||||
|
|
Loading…
Reference in a new issue