h264: add decode_nalu() helper function.

Split decode_buffer() into the core infrastructure that determines
the NAL units contained in the adapter and the actual function that
decodes the NAL unit.
This commit is contained in:
Gwenole Beauchesne 2012-10-10 10:35:20 +02:00
parent 6f2e885f11
commit 3f430b32a4

View file

@ -2213,6 +2213,45 @@ scan_for_start_code(GstAdapter *adapter, guint ofs, guint size, guint32 *scp)
scp); scp);
} }
static GstVaapiDecoderStatus
decode_nalu(GstVaapiDecoderH264 *decoder, GstH264NalUnit *nalu)
{
GstVaapiDecoderStatus status;
switch (nalu->type) {
case GST_H264_NAL_SLICE_IDR:
/* fall-through. IDR specifics are handled in init_picture() */
case GST_H264_NAL_SLICE:
status = decode_slice(decoder, nalu);
break;
case GST_H264_NAL_SPS:
status = decode_sps(decoder, nalu);
break;
case GST_H264_NAL_PPS:
status = decode_pps(decoder, nalu);
break;
case GST_H264_NAL_SEI:
status = decode_sei(decoder, nalu);
break;
case GST_H264_NAL_SEQ_END:
status = decode_sequence_end(decoder);
break;
case GST_H264_NAL_AU_DELIMITER:
/* skip all Access Unit NALs */
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
break;
case GST_H264_NAL_FILLER_DATA:
/* skip all Filler Data NALs */
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
break;
default:
GST_WARNING("unsupported NAL unit type %d", nalu->type);
status = GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
break;
}
return status;
}
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_buffer(GstVaapiDecoderH264 *decoder, GstBuffer *buffer) decode_buffer(GstVaapiDecoderH264 *decoder, GstBuffer *buffer)
{ {
@ -2298,42 +2337,8 @@ decode_buffer(GstVaapiDecoderH264 *decoder, GstBuffer *buffer)
); );
} }
status = get_status(result); status = get_status(result);
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) { if (status == GST_VAAPI_DECODER_STATUS_SUCCESS)
gst_buffer_unref(buffer); status = decode_nalu(decoder, &nalu);
break;
}
switch (nalu.type) {
case GST_H264_NAL_SLICE_IDR:
/* fall-through. IDR specifics are handled in init_picture() */
case GST_H264_NAL_SLICE:
status = decode_slice(decoder, &nalu);
break;
case GST_H264_NAL_SPS:
status = decode_sps(decoder, &nalu);
break;
case GST_H264_NAL_PPS:
status = decode_pps(decoder, &nalu);
break;
case GST_H264_NAL_SEI:
status = decode_sei(decoder, &nalu);
break;
case GST_H264_NAL_SEQ_END:
status = decode_sequence_end(decoder);
break;
case GST_H264_NAL_AU_DELIMITER:
/* skip all Access Unit NALs */
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
break;
case GST_H264_NAL_FILLER_DATA:
/* skip all Filler Data NALs */
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
break;
default:
GST_WARNING("unsupported NAL unit type %d", nalu.type);
status = GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
break;
}
gst_buffer_unref(buffer); gst_buffer_unref(buffer);
} while (status == GST_VAAPI_DECODER_STATUS_SUCCESS); } while (status == GST_VAAPI_DECODER_STATUS_SUCCESS);