decoder: add first-field flag to picture.

Add first-field (FF) flag to GstVaapiPicture, thus not requiring is_first_field
member in each decoder. Rather, when a GstVaapiPicture is created, it is considered
as the first field. Any subsequent allocated field will become the second field.
This commit is contained in:
Gwenole Beauchesne 2012-03-28 17:50:28 +02:00
parent 195a61fa02
commit b56ac16224
3 changed files with 9 additions and 7 deletions

View file

@ -80,7 +80,6 @@ struct _GstVaapiDecoderMpeg2Private {
GstClockTime pts_diff;
guint is_constructed : 1;
guint is_opened : 1;
guint is_first_field : 1;
guint has_seq_ext : 1;
guint has_seq_scalable_ext : 1;
guint has_pic_ext : 1;
@ -499,8 +498,6 @@ decode_gop(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
priv->gop_pts = pts;
if (!priv->pts_diff)
priv->pts_diff = priv->seq_pts - priv->gop_pts;
priv->is_first_field = FALSE;
return GST_VAAPI_DECODER_STATUS_SUCCESS;
}
@ -596,7 +593,6 @@ decode_picture_ext(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
pic_ext->picture_structure = GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME;
}
priv->is_first_field ^= 1;
switch (pic_ext->picture_structure) {
case GST_MPEG_VIDEO_PICTURE_STRUCTURE_TOP_FIELD:
picture->structure = GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD;
@ -606,7 +602,6 @@ decode_picture_ext(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
break;
case GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME:
picture->structure = GST_VAAPI_PICTURE_STRUCTURE_FRAME;
priv->is_first_field = TRUE;
break;
}
return GST_VAAPI_DECODER_STATUS_SUCCESS;
@ -643,7 +638,7 @@ fill_picture(GstVaapiDecoderMpeg2 *decoder, GstVaapiPicture *picture)
#define COPY_FIELD(a, b, f) \
pic_param->a.b.f = pic_ext->f
pic_param->picture_coding_extension.value = 0;
pic_param->picture_coding_extension.bits.is_first_field = priv->is_first_field;
pic_param->picture_coding_extension.bits.is_first_field = GST_VAAPI_PICTURE_IS_FIRST_FIELD(picture);
COPY_FIELD(picture_coding_extension, bits, intra_dc_precision);
COPY_FIELD(picture_coding_extension, bits, picture_structure);
COPY_FIELD(picture_coding_extension, bits, top_field_first);
@ -945,7 +940,6 @@ gst_vaapi_decoder_mpeg2_init(GstVaapiDecoderMpeg2 *decoder)
priv->pts_diff = 0;
priv->is_constructed = FALSE;
priv->is_opened = FALSE;
priv->is_first_field = FALSE;
priv->has_seq_ext = FALSE;
priv->has_seq_scalable_ext = FALSE;
priv->has_pic_ext = FALSE;

View file

@ -114,6 +114,7 @@ gst_vaapi_picture_create(
(GST_VAAPI_PICTURE_FLAG_SKIPPED |
GST_VAAPI_PICTURE_FLAG_REFERENCE |
GST_VAAPI_PICTURE_FLAG_INTERLACED |
GST_VAAPI_PICTURE_FLAG_FF |
GST_VAAPI_PICTURE_FLAG_TFF)
);
@ -128,6 +129,7 @@ gst_vaapi_picture_create(
picture->structure = GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD;
break;
}
GST_VAAPI_PICTURE_FLAG_UNSET(picture, GST_VAAPI_PICTURE_FLAG_FF);
}
}
else {
@ -141,6 +143,7 @@ gst_vaapi_picture_create(
return FALSE;
picture->structure = GST_VAAPI_PICTURE_STRUCTURE_FRAME;
GST_VAAPI_PICTURE_FLAG_SET(picture, GST_VAAPI_PICTURE_FLAG_FF);
}
picture->surface_id = gst_vaapi_surface_get_id(picture->surface);

View file

@ -81,6 +81,7 @@ enum _GstVaapiPictureType {
* @GST_VAAPI_PICTURE_FLAG_REFERENCE: reference frame
* @GST_VAAPI_PICTURE_FLAG_OUTPUT: frame was output
* @GST_VAAPI_PICTURE_FLAG_INTERLACED: interlaced frame
* @GST_VAAPI_PICTURE_FLAG_FF: first-field
* @GST_VAAPI_PICTURE_FLAG_TFF: top-field-first
* @GST_VAAPI_PICTURE_FLAG_LAST: first flag that can be used by subclasses
*
@ -91,6 +92,7 @@ enum {
GST_VAAPI_PICTURE_FLAG_REFERENCE = (GST_VAAPI_CODEC_OBJECT_FLAG_LAST << 1),
GST_VAAPI_PICTURE_FLAG_OUTPUT = (GST_VAAPI_CODEC_OBJECT_FLAG_LAST << 2),
GST_VAAPI_PICTURE_FLAG_INTERLACED = (GST_VAAPI_CODEC_OBJECT_FLAG_LAST << 3),
GST_VAAPI_PICTURE_FLAG_FF = (GST_VAAPI_CODEC_OBJECT_FLAG_LAST << 4),
GST_VAAPI_PICTURE_FLAG_TFF = (GST_VAAPI_CODEC_OBJECT_FLAG_LAST << 5),
GST_VAAPI_PICTURE_FLAG_LAST = (GST_VAAPI_CODEC_OBJECT_FLAG_LAST << 6),
};
@ -112,6 +114,9 @@ enum {
#define GST_VAAPI_PICTURE_IS_INTERLACED(picture) \
GST_VAAPI_PICTURE_FLAG_IS_SET(picture, GST_VAAPI_PICTURE_FLAG_INTERLACED)
#define GST_VAAPI_PICTURE_IS_FIRST_FIELD(picture) \
GST_VAAPI_PICTURE_FLAG_IS_SET(picture, GST_VAAPI_PICTURE_FLAG_FF)
#define GST_VAAPI_PICTURE_IS_TFF(picture) \
GST_VAAPI_PICTURE_FLAG_IS_SET(picture, GST_VAAPI_PICTURE_FLAG_TFF)