decoder: h264: fix slice data bit offset with MVC NAL units.

When MVC slice NAL units (coded slice extension and prefix NAL) are
present, the number of NAL header bytes is 3, not 1 as usual.

Signed-off-by: Li Xiaowei <xiaowei.a.li@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
Li Xiaowei 2013-03-07 11:32:20 +08:00 committed by Gwenole Beauchesne
parent 5a3e51472d
commit 3f14745d61

View file

@ -2672,12 +2672,12 @@ decode_picture(GstVaapiDecoderH264 *decoder, GstVaapiDecoderUnit *unit)
}
static inline guint
get_slice_data_bit_offset(GstH264SliceHdr *slice_hdr)
get_slice_data_bit_offset(GstH264SliceHdr *slice_hdr, guint nal_header_bytes)
{
guint epb_count;
epb_count = slice_hdr->n_emulation_prevention_bytes;
return 8 /* nal_unit_type */ + slice_hdr->header_size - epb_count * 8;
return 8 * nal_header_bytes + slice_hdr->header_size - epb_count * 8;
}
static gboolean
@ -2793,12 +2793,14 @@ fill_RefPicList(GstVaapiDecoderH264 *decoder,
static gboolean
fill_slice(GstVaapiDecoderH264 *decoder,
GstVaapiSlice *slice, GstH264SliceHdr *slice_hdr)
GstVaapiSlice *slice, GstVaapiParserInfoH264 *pi)
{
VASliceParameterBufferH264 * const slice_param = slice->param;
GstH264SliceHdr * const slice_hdr = &pi->data.slice_hdr;
/* Fill in VASliceParameterBufferH264 */
slice_param->slice_data_bit_offset = get_slice_data_bit_offset(slice_hdr);
slice_param->slice_data_bit_offset =
get_slice_data_bit_offset(slice_hdr, pi->nalu.header_bytes);
slice_param->first_mb_in_slice = slice_hdr->first_mb_in_slice;
slice_param->slice_type = slice_hdr->type % 5;
slice_param->direct_spatial_mv_pred_flag = slice_hdr->direct_spatial_mv_pred_flag;
@ -2858,7 +2860,7 @@ decode_slice(GstVaapiDecoderH264 *decoder, GstVaapiDecoderUnit *unit)
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
}
if (!fill_slice(decoder, slice, slice_hdr)) {
if (!fill_slice(decoder, slice, pi)) {
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(slice));
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
}