libs: humongous code style fix

As part of the upstreaming process of gstreamer-vaapi into the GStreamer
umbrella, we need to comply with the project's code style. This meant to
change a lot of code.

It was decided to use a single massive patch to update the code style.

I would like to apologize with the original developers of this code because of
the history breakage.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-02-03 11:50:13 +01:00
parent 4b5be5973e
commit ac730d0a62
13 changed files with 8565 additions and 8730 deletions

View File

@ -37,7 +37,8 @@
* *
* A decoded picture buffer (DPB) object. * A decoded picture buffer (DPB) object.
*/ */
struct _GstVaapiDpb { struct _GstVaapiDpb
{
/*< private > */ /*< private > */
GstVaapiMiniObject parent_instance; GstVaapiMiniObject parent_instance;
@ -52,7 +53,8 @@ struct _GstVaapiDpb {
* *
* The #GstVaapiDpb base class. * The #GstVaapiDpb base class.
*/ */
struct _GstVaapiDpbClass { struct _GstVaapiDpbClass
{
/*< private > */ /*< private > */
GstVaapiMiniObjectClass parent_class; GstVaapiMiniObjectClass parent_class;
@ -63,11 +65,9 @@ struct _GstVaapiDpbClass {
GstVaapiPicture ** prev_picture_ptr, GstVaapiPicture ** next_picture_ptr); GstVaapiPicture ** prev_picture_ptr, GstVaapiPicture ** next_picture_ptr);
}; };
static const GstVaapiMiniObjectClass * static const GstVaapiMiniObjectClass *gst_vaapi_dpb_class (void);
gst_vaapi_dpb_class(void);
static const GstVaapiMiniObjectClass * static const GstVaapiMiniObjectClass *gst_vaapi_dpb2_class (void);
gst_vaapi_dpb2_class(void);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* --- Common utilities --- */ /* --- Common utilities --- */
@ -80,8 +80,9 @@ dpb_new(guint max_pictures)
g_return_val_if_fail (max_pictures > 0, NULL); g_return_val_if_fail (max_pictures > 0, NULL);
dpb = (GstVaapiDpb *)gst_vaapi_mini_object_new( dpb =
max_pictures == 2 ? gst_vaapi_dpb2_class() : gst_vaapi_dpb_class()); (GstVaapiDpb *) gst_vaapi_mini_object_new (max_pictures ==
2 ? gst_vaapi_dpb2_class () : gst_vaapi_dpb_class ());
if (!dpb) if (!dpb)
return NULL; return NULL;
@ -167,8 +168,7 @@ dpb_clear(GstVaapiDpb *dpb)
static void static void
dpb_flush (GstVaapiDpb * dpb) dpb_flush (GstVaapiDpb * dpb)
{ {
while (dpb_bump(dpb)) while (dpb_bump (dpb));
;
dpb_clear (dpb); dpb_clear (dpb);
} }
@ -199,7 +199,6 @@ dpb_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
return FALSE; return FALSE;
} }
} }
// Store non-reference decoded picture into the DPB // Store non-reference decoded picture into the DPB
else { else {
if (GST_VAAPI_PICTURE_IS_SKIPPED (picture)) if (GST_VAAPI_PICTURE_IS_SKIPPED (picture))
@ -237,8 +236,7 @@ dpb_get_neighbours(GstVaapiDpb *dpb, GstVaapiPicture *picture,
if (i + 1 < dpb->num_pictures) if (i + 1 < dpb->num_pictures)
next_picture = dpb->pictures[i + 1]; next_picture = dpb->pictures[i + 1];
break; break;
} } else if (ref_picture->poc > picture->poc) {
else if (ref_picture->poc > picture->poc) {
next_picture = ref_picture; next_picture = ref_picture;
if (i > 0) if (i > 0)
prev_picture = dpb->pictures[i - 1]; prev_picture = dpb->pictures[i - 1];
@ -338,7 +336,8 @@ gst_vaapi_dpb_class(void)
{ {
static const GstVaapiDpbClass GstVaapiDpbClass = { static const GstVaapiDpbClass GstVaapiDpbClass = {
{sizeof (GstVaapiDpb), {sizeof (GstVaapiDpb),
(GDestroyNotify)gst_vaapi_dpb_finalize }, (GDestroyNotify) gst_vaapi_dpb_finalize}
,
dpb_flush, dpb_flush,
dpb_add, dpb_add,
@ -352,7 +351,8 @@ gst_vaapi_dpb2_class(void)
{ {
static const GstVaapiDpbClass GstVaapiDpb2Class = { static const GstVaapiDpbClass GstVaapiDpb2Class = {
{sizeof (GstVaapiDpb), {sizeof (GstVaapiDpb),
(GDestroyNotify)gst_vaapi_dpb_finalize }, (GDestroyNotify) gst_vaapi_dpb_finalize}
,
dpb_flush, dpb_flush,
dpb2_add, dpb2_add,

File diff suppressed because it is too large Load Diff

View File

@ -49,20 +49,20 @@
typedef struct _GstVaapiDecoderJpegPrivate GstVaapiDecoderJpegPrivate; typedef struct _GstVaapiDecoderJpegPrivate GstVaapiDecoderJpegPrivate;
typedef struct _GstVaapiDecoderJpegClass GstVaapiDecoderJpegClass; typedef struct _GstVaapiDecoderJpegClass GstVaapiDecoderJpegClass;
typedef enum { typedef enum
{
GST_JPEG_VIDEO_STATE_GOT_SOI = 1 << 0, GST_JPEG_VIDEO_STATE_GOT_SOI = 1 << 0,
GST_JPEG_VIDEO_STATE_GOT_SOF = 1 << 1, GST_JPEG_VIDEO_STATE_GOT_SOF = 1 << 1,
GST_JPEG_VIDEO_STATE_GOT_SOS = 1 << 2, GST_JPEG_VIDEO_STATE_GOT_SOS = 1 << 2,
GST_JPEG_VIDEO_STATE_GOT_HUF_TABLE = 1 << 3, GST_JPEG_VIDEO_STATE_GOT_HUF_TABLE = 1 << 3,
GST_JPEG_VIDEO_STATE_GOT_IQ_TABLE = 1 << 4, GST_JPEG_VIDEO_STATE_GOT_IQ_TABLE = 1 << 4,
GST_JPEG_VIDEO_STATE_VALID_PICTURE = ( GST_JPEG_VIDEO_STATE_VALID_PICTURE = (GST_JPEG_VIDEO_STATE_GOT_SOI |
GST_JPEG_VIDEO_STATE_GOT_SOI | GST_JPEG_VIDEO_STATE_GOT_SOF | GST_JPEG_VIDEO_STATE_GOT_SOS),
GST_JPEG_VIDEO_STATE_GOT_SOF |
GST_JPEG_VIDEO_STATE_GOT_SOS),
} GstJpegVideoState; } GstJpegVideoState;
struct _GstVaapiDecoderJpegPrivate { struct _GstVaapiDecoderJpegPrivate
{
GstVaapiProfile profile; GstVaapiProfile profile;
guint width; guint width;
guint height; guint height;
@ -82,7 +82,8 @@ struct _GstVaapiDecoderJpegPrivate {
* *
* A decoder based on Jpeg. * A decoder based on Jpeg.
*/ */
struct _GstVaapiDecoderJpeg { struct _GstVaapiDecoderJpeg
{
/*< private > */ /*< private > */
GstVaapiDecoder parent_instance; GstVaapiDecoder parent_instance;
GstVaapiDecoderJpegPrivate priv; GstVaapiDecoderJpegPrivate priv;
@ -93,7 +94,8 @@ struct _GstVaapiDecoderJpeg {
* *
* A decoder class based on Jpeg. * A decoder class based on Jpeg.
*/ */
struct _GstVaapiDecoderJpegClass { struct _GstVaapiDecoderJpegClass
{
/*< private > */ /*< private > */
GstVaapiDecoderClass parent_class; GstVaapiDecoderClass parent_class;
}; };
@ -195,10 +197,8 @@ ensure_context(GstVaapiDecoderJpeg *decoder)
info.width = priv->width; info.width = priv->width;
info.height = priv->height; info.height = priv->height;
info.ref_frames = 2; info.ref_frames = 2;
reset_context = gst_vaapi_decoder_ensure_context( reset_context =
GST_VAAPI_DECODER(decoder), gst_vaapi_decoder_ensure_context (GST_VAAPI_DECODER (decoder), &info);
&info
);
if (!reset_context) if (!reset_context)
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN; return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
} }
@ -245,11 +245,8 @@ drop_frame:
} }
static gboolean static gboolean
fill_picture( fill_picture (GstVaapiDecoderJpeg * decoder,
GstVaapiDecoderJpeg *decoder, GstVaapiPicture * picture, GstJpegFrameHdr * frame_hdr)
GstVaapiPicture *picture,
GstJpegFrameHdr *frame_hdr
)
{ {
VAPictureParameterBufferJPEGBaseline *const pic_param = picture->param; VAPictureParameterBufferJPEGBaseline *const pic_param = picture->param;
guint i; guint i;
@ -262,8 +259,7 @@ fill_picture(
if (frame_hdr->num_components > 4) if (frame_hdr->num_components > 4)
return FALSE; return FALSE;
for (i = 0; i < pic_param->num_components; i++) { for (i = 0; i < pic_param->num_components; i++) {
pic_param->components[i].component_id = pic_param->components[i].component_id = frame_hdr->components[i].identifier;
frame_hdr->components[i].identifier;
pic_param->components[i].h_sampling_factor = pic_param->components[i].h_sampling_factor =
frame_hdr->components[i].horizontal_factor; frame_hdr->components[i].horizontal_factor;
pic_param->components[i].v_sampling_factor = pic_param->components[i].v_sampling_factor =
@ -275,7 +271,8 @@ fill_picture(
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
fill_quantization_table(GstVaapiDecoderJpeg *decoder, GstVaapiPicture *picture) fill_quantization_table (GstVaapiDecoderJpeg * decoder,
GstVaapiPicture * picture)
{ {
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv; GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
VAIQMatrixBufferJPEGBaseline *iq_matrix; VAIQMatrixBufferJPEGBaseline *iq_matrix;
@ -295,8 +292,7 @@ fill_quantization_table(GstVaapiDecoderJpeg *decoder, GstVaapiPicture *picture)
GST_JPEG_MAX_QUANT_ELEMENTS); GST_JPEG_MAX_QUANT_ELEMENTS);
for (i = 0; i < num_tables; i++) { for (i = 0; i < num_tables; i++) {
GstJpegQuantTable * const quant_table = GstJpegQuantTable *const quant_table = &priv->quant_tables.quant_tables[i];
&priv->quant_tables.quant_tables[i];
iq_matrix->load_quantiser_table[i] = quant_table->valid; iq_matrix->load_quantiser_table[i] = quant_table->valid;
if (!iq_matrix->load_quantiser_table[i]) if (!iq_matrix->load_quantiser_table[i])
@ -370,8 +366,7 @@ fill_huffman_table(GstVaapiHuffmanTable *huf_table,
huf_tables->ac_tables[i].huf_values, huf_tables->ac_tables[i].huf_values,
sizeof (huffman_table->huffman_table[i].ac_values)); sizeof (huffman_table->huffman_table[i].ac_values));
memset (huffman_table->huffman_table[i].pad, memset (huffman_table->huffman_table[i].pad,
0, 0, sizeof (huffman_table->huffman_table[i].pad));
sizeof(huffman_table->huffman_table[i].pad));
} }
} }
@ -441,10 +436,7 @@ decode_picture(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_huffman_table( decode_huffman_table (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
GstVaapiDecoderJpeg *decoder,
GstJpegSegment *seg
)
{ {
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv; GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
@ -461,10 +453,7 @@ decode_huffman_table(
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_quant_table( decode_quant_table (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
GstVaapiDecoderJpeg *decoder,
GstJpegSegment *seg
)
{ {
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv; GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
@ -481,10 +470,7 @@ decode_quant_table(
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_restart_interval( decode_restart_interval (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
GstVaapiDecoderJpeg *decoder,
GstJpegSegment *seg
)
{ {
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv; GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
@ -707,8 +693,7 @@ gst_vaapi_decoder_jpeg_parse(GstVaapiDecoder *base_decoder,
ofs2 = seg.offset + seg.size; ofs2 = seg.offset + seg.size;
} }
ofs2 = seg.offset - 2; ofs2 = seg.offset - 2;
} } else {
else {
// Check that the whole segment is actually available (in buffer) // Check that the whole segment is actually available (in buffer)
ofs2 = ofs1 + seg.size; ofs2 = ofs1 + seg.size;
if (ofs2 > buf_size) { if (ofs2 > buf_size) {

View File

@ -44,7 +44,8 @@
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
typedef struct _PTSGenerator PTSGenerator; typedef struct _PTSGenerator PTSGenerator;
struct _PTSGenerator { struct _PTSGenerator
{
GstClockTime gop_pts; // Current GOP PTS GstClockTime gop_pts; // Current GOP PTS
GstClockTime max_pts; // Max picture PTS GstClockTime max_pts; // Max picture PTS
guint gop_tsn; // Absolute GOP TSN guint gop_tsn; // Absolute GOP TSN
@ -99,18 +100,16 @@ pts_sync(PTSGenerator *tsg, GstClockTime gop_pts)
if (GST_CLOCK_TIME_IS_VALID (tsg->max_pts)) { if (GST_CLOCK_TIME_IS_VALID (tsg->max_pts)) {
gop_pts = tsg->max_pts + pts_get_duration (tsg, 1); gop_pts = tsg->max_pts + pts_get_duration (tsg, 1);
gop_tsn = tsg->gop_tsn + tsg->ovl_tsn * 1024 + tsg->max_tsn + 1; gop_tsn = tsg->gop_tsn + tsg->ovl_tsn * 1024 + tsg->max_tsn + 1;
} } else {
else {
gop_pts = 0; gop_pts = 0;
gop_tsn = 0; gop_tsn = 0;
} }
} } else {
else {
/* Interpolate GOP TSN from this valid PTS */ /* Interpolate GOP TSN from this valid PTS */
if (GST_CLOCK_TIME_IS_VALID (tsg->gop_pts)) if (GST_CLOCK_TIME_IS_VALID (tsg->gop_pts))
gop_tsn = tsg->gop_tsn + gst_util_uint64_scale( gop_tsn =
gop_pts - tsg->gop_pts + pts_get_duration(tsg, 1) - 1, tsg->gop_tsn + gst_util_uint64_scale (gop_pts - tsg->gop_pts +
tsg->fps_n, GST_SECOND * tsg->fps_d); pts_get_duration (tsg, 1) - 1, tsg->fps_n, GST_SECOND * tsg->fps_d);
else else
gop_tsn = 0; gop_tsn = 0;
} }
@ -158,11 +157,13 @@ pts_eval(PTSGenerator *tsg, GstClockTime pic_pts, guint pic_tsn)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
typedef struct _GstVaapiParserInfoMpeg2 GstVaapiParserInfoMpeg2; typedef struct _GstVaapiParserInfoMpeg2 GstVaapiParserInfoMpeg2;
struct _GstVaapiParserInfoMpeg2 { struct _GstVaapiParserInfoMpeg2
{
GstVaapiMiniObject parent_instance; GstVaapiMiniObject parent_instance;
GstMpegVideoPacket packet; GstMpegVideoPacket packet;
guint8 extension_type; /* for Extension packets */ guint8 extension_type; /* for Extension packets */
union { union
{
GstMpegVideoSequenceHdr seq_hdr; GstMpegVideoSequenceHdr seq_hdr;
GstMpegVideoSequenceExt seq_ext; GstMpegVideoSequenceExt seq_ext;
GstMpegVideoSequenceDisplayExt seq_display_ext; GstMpegVideoSequenceDisplayExt seq_display_ext;
@ -224,26 +225,24 @@ gst_vaapi_parser_info_mpeg2_ensure(GstVaapiParserInfoMpeg2 **pi_ptr)
typedef struct _GstVaapiDecoderMpeg2Private GstVaapiDecoderMpeg2Private; typedef struct _GstVaapiDecoderMpeg2Private GstVaapiDecoderMpeg2Private;
typedef struct _GstVaapiDecoderMpeg2Class GstVaapiDecoderMpeg2Class; typedef struct _GstVaapiDecoderMpeg2Class GstVaapiDecoderMpeg2Class;
typedef enum { typedef enum
{
GST_MPEG_VIDEO_STATE_GOT_SEQ_HDR = 1 << 0, GST_MPEG_VIDEO_STATE_GOT_SEQ_HDR = 1 << 0,
GST_MPEG_VIDEO_STATE_GOT_SEQ_EXT = 1 << 1, GST_MPEG_VIDEO_STATE_GOT_SEQ_EXT = 1 << 1,
GST_MPEG_VIDEO_STATE_GOT_PIC_HDR = 1 << 2, GST_MPEG_VIDEO_STATE_GOT_PIC_HDR = 1 << 2,
GST_MPEG_VIDEO_STATE_GOT_PIC_EXT = 1 << 3, GST_MPEG_VIDEO_STATE_GOT_PIC_EXT = 1 << 3,
GST_MPEG_VIDEO_STATE_GOT_SLICE = 1 << 4, GST_MPEG_VIDEO_STATE_GOT_SLICE = 1 << 4,
GST_MPEG_VIDEO_STATE_VALID_SEQ_HEADERS = ( GST_MPEG_VIDEO_STATE_VALID_SEQ_HEADERS = (GST_MPEG_VIDEO_STATE_GOT_SEQ_HDR |
GST_MPEG_VIDEO_STATE_GOT_SEQ_HDR|
GST_MPEG_VIDEO_STATE_GOT_SEQ_EXT), GST_MPEG_VIDEO_STATE_GOT_SEQ_EXT),
GST_MPEG_VIDEO_STATE_VALID_PIC_HEADERS = ( GST_MPEG_VIDEO_STATE_VALID_PIC_HEADERS = (GST_MPEG_VIDEO_STATE_GOT_PIC_HDR |
GST_MPEG_VIDEO_STATE_GOT_PIC_HDR|
GST_MPEG_VIDEO_STATE_GOT_PIC_EXT), GST_MPEG_VIDEO_STATE_GOT_PIC_EXT),
GST_MPEG_VIDEO_STATE_VALID_PICTURE = ( GST_MPEG_VIDEO_STATE_VALID_PICTURE = (GST_MPEG_VIDEO_STATE_VALID_SEQ_HEADERS |
GST_MPEG_VIDEO_STATE_VALID_SEQ_HEADERS| GST_MPEG_VIDEO_STATE_VALID_PIC_HEADERS | GST_MPEG_VIDEO_STATE_GOT_SLICE)
GST_MPEG_VIDEO_STATE_VALID_PIC_HEADERS|
GST_MPEG_VIDEO_STATE_GOT_SLICE)
} GstMpegVideoState; } GstMpegVideoState;
struct _GstVaapiDecoderMpeg2Private { struct _GstVaapiDecoderMpeg2Private
{
GstVaapiProfile profile; GstVaapiProfile profile;
GstVaapiProfile hw_profile; GstVaapiProfile hw_profile;
guint width; guint width;
@ -279,7 +278,8 @@ struct _GstVaapiDecoderMpeg2Private {
* *
* A decoder based on Mpeg2. * A decoder based on Mpeg2.
*/ */
struct _GstVaapiDecoderMpeg2 { struct _GstVaapiDecoderMpeg2
{
/*< private > */ /*< private > */
GstVaapiDecoder parent_instance; GstVaapiDecoder parent_instance;
GstVaapiDecoderMpeg2Private priv; GstVaapiDecoderMpeg2Private priv;
@ -290,7 +290,8 @@ struct _GstVaapiDecoderMpeg2 {
* *
* A decoder class based on Mpeg2. * A decoder class based on Mpeg2.
*/ */
struct _GstVaapiDecoderMpeg2Class { struct _GstVaapiDecoderMpeg2Class
{
/*< private > */ /*< private > */
GstVaapiDecoderClass parent_class; GstVaapiDecoderClass parent_class;
}; };
@ -367,10 +368,18 @@ get_profile_str(GstVaapiProfile profile)
char *str; char *str;
switch (profile) { switch (profile) {
case GST_VAAPI_PROFILE_MPEG2_SIMPLE: str = "simple"; break; case GST_VAAPI_PROFILE_MPEG2_SIMPLE:
case GST_VAAPI_PROFILE_MPEG2_MAIN: str = "main"; break; str = "simple";
case GST_VAAPI_PROFILE_MPEG2_HIGH: str = "high"; break; break;
default: str = "<unknown>"; break; case GST_VAAPI_PROFILE_MPEG2_MAIN:
str = "main";
break;
case GST_VAAPI_PROFILE_MPEG2_HIGH:
str = "high";
break;
default:
str = "<unknown>";
break;
} }
return str; return str;
} }
@ -399,8 +408,7 @@ get_profile(GstVaapiDecoderMpeg2 *decoder, GstVaapiEntrypoint entrypoint)
// Try to map to main profile if no high profile specific bits used // Try to map to main profile if no high profile specific bits used
if (priv->profile == profile && if (priv->profile == profile &&
!priv->seq_scalable_ext && !priv->seq_scalable_ext &&
(priv->seq_ext && (priv->seq_ext && priv->seq_ext->data.seq_ext.chroma_format == 1)) {
priv->seq_ext->data.seq_ext.chroma_format == 1)) {
profile = GST_VAAPI_PROFILE_MPEG2_MAIN; profile = GST_VAAPI_PROFILE_MPEG2_MAIN;
break; break;
} }
@ -449,10 +457,9 @@ ensure_context(GstVaapiDecoderMpeg2 *decoder)
info.width = priv->width; info.width = priv->width;
info.height = priv->height; info.height = priv->height;
info.ref_frames = 2; info.ref_frames = 2;
reset_context = gst_vaapi_decoder_ensure_context( reset_context =
GST_VAAPI_DECODER_CAST(decoder), gst_vaapi_decoder_ensure_context (GST_VAAPI_DECODER_CAST (decoder),
&info &info);
);
if (!reset_context) if (!reset_context)
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN; return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
} }
@ -495,25 +502,27 @@ ensure_quant_matrix(GstVaapiDecoderMpeg2 *decoder, GstVaapiPicture *picture)
if (quant_matrix->load_chroma_intra_quantiser_matrix) if (quant_matrix->load_chroma_intra_quantiser_matrix)
chroma_intra_quant_matrix = quant_matrix->chroma_intra_quantiser_matrix; chroma_intra_quant_matrix = quant_matrix->chroma_intra_quantiser_matrix;
if (quant_matrix->load_chroma_non_intra_quantiser_matrix) if (quant_matrix->load_chroma_non_intra_quantiser_matrix)
chroma_non_intra_quant_matrix = quant_matrix->chroma_non_intra_quantiser_matrix; chroma_non_intra_quant_matrix =
quant_matrix->chroma_non_intra_quantiser_matrix;
} }
iq_matrix->load_intra_quantiser_matrix = intra_quant_matrix != NULL; iq_matrix->load_intra_quantiser_matrix = intra_quant_matrix != NULL;
if (intra_quant_matrix) if (intra_quant_matrix)
copy_quant_matrix(iq_matrix->intra_quantiser_matrix, copy_quant_matrix (iq_matrix->intra_quantiser_matrix, intra_quant_matrix);
intra_quant_matrix);
iq_matrix->load_non_intra_quantiser_matrix = non_intra_quant_matrix != NULL; iq_matrix->load_non_intra_quantiser_matrix = non_intra_quant_matrix != NULL;
if (non_intra_quant_matrix) if (non_intra_quant_matrix)
copy_quant_matrix (iq_matrix->non_intra_quantiser_matrix, copy_quant_matrix (iq_matrix->non_intra_quantiser_matrix,
non_intra_quant_matrix); non_intra_quant_matrix);
iq_matrix->load_chroma_intra_quantiser_matrix = chroma_intra_quant_matrix != NULL; iq_matrix->load_chroma_intra_quantiser_matrix =
chroma_intra_quant_matrix != NULL;
if (chroma_intra_quant_matrix) if (chroma_intra_quant_matrix)
copy_quant_matrix (iq_matrix->chroma_intra_quantiser_matrix, copy_quant_matrix (iq_matrix->chroma_intra_quantiser_matrix,
chroma_intra_quant_matrix); chroma_intra_quant_matrix);
iq_matrix->load_chroma_non_intra_quantiser_matrix = chroma_non_intra_quant_matrix != NULL; iq_matrix->load_chroma_non_intra_quantiser_matrix =
chroma_non_intra_quant_matrix != NULL;
if (chroma_non_intra_quant_matrix) if (chroma_non_intra_quant_matrix)
copy_quant_matrix (iq_matrix->chroma_non_intra_quantiser_matrix, copy_quant_matrix (iq_matrix->chroma_non_intra_quantiser_matrix,
chroma_non_intra_quant_matrix); chroma_non_intra_quant_matrix);
@ -752,7 +761,8 @@ parse_sequence_scalable_ext(GstVaapiDecoderMpeg2 *decoder,
GstMpegVideoSequenceScalableExt *seq_scalable_ext; GstMpegVideoSequenceScalableExt *seq_scalable_ext;
if (!gst_vaapi_parser_info_mpeg2_ensure (&priv->seq_scalable_ext)) { if (!gst_vaapi_parser_info_mpeg2_ensure (&priv->seq_scalable_ext)) {
GST_ERROR("failed to allocate parser info for sequence scalable extension"); GST_ERROR
("failed to allocate parser info for sequence scalable extension");
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
} }
@ -908,8 +918,7 @@ parse_picture_ext(GstVaapiDecoderMpeg2 *decoder,
GstMpegVideoPictureExt *pic_ext; GstMpegVideoPictureExt *pic_ext;
priv->state &= (GST_MPEG_VIDEO_STATE_GOT_SEQ_HDR | priv->state &= (GST_MPEG_VIDEO_STATE_GOT_SEQ_HDR |
GST_MPEG_VIDEO_STATE_GOT_SEQ_EXT| GST_MPEG_VIDEO_STATE_GOT_SEQ_EXT | GST_MPEG_VIDEO_STATE_GOT_PIC_HDR);
GST_MPEG_VIDEO_STATE_GOT_PIC_HDR);
if (!gst_vaapi_parser_info_mpeg2_ensure (&priv->pic_ext)) { if (!gst_vaapi_parser_info_mpeg2_ensure (&priv->pic_ext)) {
GST_ERROR ("failed to allocate parser info for picture extension"); GST_ERROR ("failed to allocate parser info for picture extension");
@ -943,7 +952,8 @@ decode_picture_ext(GstVaapiDecoderMpeg2 *decoder, GstVaapiDecoderUnit *unit)
if (pic_ext->picture_structure == 0 || if (pic_ext->picture_structure == 0 ||
(pic_ext->progressive_frame && (pic_ext->progressive_frame &&
pic_ext->picture_structure != GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME)) { pic_ext->picture_structure !=
GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME)) {
GST_WARNING ("invalid picture_structure %d, replacing with \"frame\"", GST_WARNING ("invalid picture_structure %d, replacing with \"frame\"",
pic_ext->picture_structure); pic_ext->picture_structure);
pic_ext->picture_structure = GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME; pic_ext->picture_structure = GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME;
@ -958,8 +968,7 @@ pack_f_code(guint8 f_code[2][2])
{ {
return (((guint32) f_code[0][0] << 12) | return (((guint32) f_code[0][0] << 12) |
((guint32) f_code[0][1] << 8) | ((guint32) f_code[0][1] << 8) |
((guint32)f_code[1][0] << 4) | ((guint32) f_code[1][0] << 4) | (f_code[1][1]));
( f_code[1][1] ));
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
@ -1022,11 +1031,9 @@ init_picture(GstVaapiDecoderMpeg2 *decoder, GstVaapiPicture *picture)
dummy_picture->poc = -1; dummy_picture->poc = -1;
dummy_picture->structure = GST_VAAPI_PICTURE_STRUCTURE_FRAME; dummy_picture->structure = GST_VAAPI_PICTURE_STRUCTURE_FRAME;
GST_VAAPI_PICTURE_FLAG_SET( GST_VAAPI_PICTURE_FLAG_SET (dummy_picture,
dummy_picture,
(GST_VAAPI_PICTURE_FLAG_SKIPPED | (GST_VAAPI_PICTURE_FLAG_SKIPPED |
GST_VAAPI_PICTURE_FLAG_OUTPUT | GST_VAAPI_PICTURE_FLAG_OUTPUT | GST_VAAPI_PICTURE_FLAG_REFERENCE)
GST_VAAPI_PICTURE_FLAG_REFERENCE)
); );
success = gst_vaapi_dpb_add (priv->dpb, dummy_picture); success = gst_vaapi_dpb_add (priv->dpb, dummy_picture);
@ -1108,8 +1115,7 @@ parse_slice(GstVaapiDecoderMpeg2 *decoder,
priv->state &= (GST_MPEG_VIDEO_STATE_GOT_SEQ_HDR | priv->state &= (GST_MPEG_VIDEO_STATE_GOT_SEQ_HDR |
GST_MPEG_VIDEO_STATE_GOT_SEQ_EXT | GST_MPEG_VIDEO_STATE_GOT_SEQ_EXT |
GST_MPEG_VIDEO_STATE_GOT_PIC_HDR| GST_MPEG_VIDEO_STATE_GOT_PIC_HDR | GST_MPEG_VIDEO_STATE_GOT_PIC_EXT);
GST_MPEG_VIDEO_STATE_GOT_PIC_EXT);
if (!is_valid_state (decoder, GST_MPEG_VIDEO_STATE_VALID_PIC_HEADERS)) if (!is_valid_state (decoder, GST_MPEG_VIDEO_STATE_VALID_PIC_HEADERS))
return GST_VAAPI_DECODER_STATUS_SUCCESS; return GST_VAAPI_DECODER_STATUS_SUCCESS;
@ -1413,7 +1419,6 @@ gst_vaapi_decoder_mpeg2_parse(GstVaapiDecoder *base_decoder,
break; break;
} }
} }
// Ignore system start codes (PES headers) // Ignore system start codes (PES headers)
else if (type >= 0xb9 && type <= 0xff) else if (type >= 0xb9 && type <= 0xff)
flags |= GST_VAAPI_DECODER_UNIT_FLAG_SKIP; flags |= GST_VAAPI_DECODER_UNIT_FLAG_SKIP;
@ -1495,8 +1500,7 @@ gst_vaapi_decoder_mpeg2_start_frame(GstVaapiDecoder *base_decoder,
GST_ERROR ("failed to allocate field picture"); GST_ERROR ("failed to allocate field picture");
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
} }
} } else {
else {
/* Create new picture */ /* Create new picture */
picture = GST_VAAPI_PICTURE_NEW (MPEG2, decoder); picture = GST_VAAPI_PICTURE_NEW (MPEG2, decoder);
if (!picture) { if (!picture) {

View File

@ -44,7 +44,8 @@
typedef struct _GstVaapiDecoderMpeg4Private GstVaapiDecoderMpeg4Private; typedef struct _GstVaapiDecoderMpeg4Private GstVaapiDecoderMpeg4Private;
typedef struct _GstVaapiDecoderMpeg4Class GstVaapiDecoderMpeg4Class; typedef struct _GstVaapiDecoderMpeg4Class GstVaapiDecoderMpeg4Class;
struct _GstVaapiDecoderMpeg4Private { struct _GstVaapiDecoderMpeg4Private
{
GstVaapiProfile profile; GstVaapiProfile profile;
guint level; guint level;
guint width; guint width;
@ -100,7 +101,8 @@ struct _GstVaapiDecoderMpeg4Private {
* *
* A decoder based on Mpeg4. * A decoder based on Mpeg4.
*/ */
struct _GstVaapiDecoderMpeg4 { struct _GstVaapiDecoderMpeg4
{
/*< private > */ /*< private > */
GstVaapiDecoder parent_instance; GstVaapiDecoder parent_instance;
GstVaapiDecoderMpeg4Private priv; GstVaapiDecoderMpeg4Private priv;
@ -111,7 +113,8 @@ struct _GstVaapiDecoderMpeg4 {
* *
* A decoder class based on Mpeg4. * A decoder class based on Mpeg4.
*/ */
struct _GstVaapiDecoderMpeg4Class { struct _GstVaapiDecoderMpeg4Class
{
/*< private > */ /*< private > */
GstVaapiDecoderClass parent_class; GstVaapiDecoderClass parent_class;
}; };
@ -226,10 +229,8 @@ ensure_context(GstVaapiDecoderMpeg4 *decoder)
info.width = priv->width; info.width = priv->width;
info.height = priv->height; info.height = priv->height;
info.ref_frames = 2; info.ref_frames = 2;
reset_context = gst_vaapi_decoder_ensure_context( reset_context =
GST_VAAPI_DECODER(decoder), gst_vaapi_decoder_ensure_context (GST_VAAPI_DECODER (decoder), &info);
&info
);
if (!reset_context) if (!reset_context)
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN; return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
} }
@ -242,7 +243,8 @@ ensure_quant_matrix(GstVaapiDecoderMpeg4 *decoder, GstVaapiPicture *picture)
GstVaapiDecoderMpeg4Private *const priv = &decoder->priv; GstVaapiDecoderMpeg4Private *const priv = &decoder->priv;
VAIQMatrixBufferMPEG4 *iq_matrix; VAIQMatrixBufferMPEG4 *iq_matrix;
if (!priv->vol_hdr.load_intra_quant_mat && !priv->vol_hdr.load_non_intra_quant_mat) { if (!priv->vol_hdr.load_intra_quant_mat
&& !priv->vol_hdr.load_non_intra_quant_mat) {
return GST_VAAPI_DECODER_STATUS_SUCCESS; return GST_VAAPI_DECODER_STATUS_SUCCESS;
} }
@ -257,16 +259,14 @@ ensure_quant_matrix(GstVaapiDecoderMpeg4 *decoder, GstVaapiPicture *picture)
iq_matrix->load_intra_quant_mat = 1; iq_matrix->load_intra_quant_mat = 1;
copy_quant_matrix (iq_matrix->intra_quant_mat, copy_quant_matrix (iq_matrix->intra_quant_mat,
priv->vol_hdr.intra_quant_mat); priv->vol_hdr.intra_quant_mat);
} } else
else
iq_matrix->load_intra_quant_mat = 0; iq_matrix->load_intra_quant_mat = 0;
if (priv->vol_hdr.load_non_intra_quant_mat) { if (priv->vol_hdr.load_non_intra_quant_mat) {
iq_matrix->load_non_intra_quant_mat = 1; iq_matrix->load_non_intra_quant_mat = 1;
copy_quant_matrix (iq_matrix->non_intra_quant_mat, copy_quant_matrix (iq_matrix->non_intra_quant_mat,
priv->vol_hdr.non_intra_quant_mat); priv->vol_hdr.non_intra_quant_mat);
} } else
else
iq_matrix->load_non_intra_quant_mat = 0; iq_matrix->load_non_intra_quant_mat = 0;
@ -306,13 +306,15 @@ decode_current_picture(GstVaapiDecoderMpeg4 *decoder)
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_sequence(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size) decode_sequence (GstVaapiDecoderMpeg4 * decoder, const guint8 * buf,
guint buf_size)
{ {
GstVaapiDecoderMpeg4Private *const priv = &decoder->priv; GstVaapiDecoderMpeg4Private *const priv = &decoder->priv;
GstMpeg4VisualObjectSequence *const vos_hdr = &priv->vos_hdr; GstMpeg4VisualObjectSequence *const vos_hdr = &priv->vos_hdr;
GstVaapiProfile profile; GstVaapiProfile profile;
if (gst_mpeg4_parse_visual_object_sequence(vos_hdr, buf, buf_size) != GST_MPEG4_PARSER_OK) { if (gst_mpeg4_parse_visual_object_sequence (vos_hdr, buf,
buf_size) != GST_MPEG4_PARSER_OK) {
GST_DEBUG ("failed to parse sequence header"); GST_DEBUG ("failed to parse sequence header");
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER; return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
} }
@ -364,13 +366,15 @@ decode_sequence_end(GstVaapiDecoderMpeg4 *decoder)
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_visual_object(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size) decode_visual_object (GstVaapiDecoderMpeg4 * decoder, const guint8 * buf,
guint buf_size)
{ {
GstVaapiDecoderMpeg4Private *const priv = &decoder->priv; GstVaapiDecoderMpeg4Private *const priv = &decoder->priv;
GstMpeg4VisualObject *vo_hdr = &priv->vo_hdr; GstMpeg4VisualObject *vo_hdr = &priv->vo_hdr;
GstMpeg4VideoSignalType *signal_type = &priv->signal_type; GstMpeg4VideoSignalType *signal_type = &priv->signal_type;
if (gst_mpeg4_parse_visual_object (vo_hdr, signal_type, buf, buf_size) != GST_MPEG4_PARSER_OK) { if (gst_mpeg4_parse_visual_object (vo_hdr, signal_type, buf,
buf_size) != GST_MPEG4_PARSER_OK) {
GST_DEBUG ("failed to parse visual object"); GST_DEBUG ("failed to parse visual object");
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER; return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
} }
@ -380,14 +384,16 @@ decode_visual_object(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_video_object_layer(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size) decode_video_object_layer (GstVaapiDecoderMpeg4 * decoder, const guint8 * buf,
guint buf_size)
{ {
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (decoder); GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (decoder);
GstVaapiDecoderMpeg4Private *const priv = &decoder->priv; GstVaapiDecoderMpeg4Private *const priv = &decoder->priv;
GstMpeg4VisualObject *vo_hdr = &priv->vo_hdr; GstMpeg4VisualObject *vo_hdr = &priv->vo_hdr;
GstMpeg4VideoObjectLayer *vol_hdr = &priv->vol_hdr; GstMpeg4VideoObjectLayer *vol_hdr = &priv->vol_hdr;
if (gst_mpeg4_parse_video_object_layer (vol_hdr, vo_hdr, buf, buf_size) != GST_MPEG4_PARSER_OK) { if (gst_mpeg4_parse_video_object_layer (vol_hdr, vo_hdr, buf,
buf_size) != GST_MPEG4_PARSER_OK) {
GST_DEBUG ("failed to parse video object layer"); GST_DEBUG ("failed to parse video object layer");
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER; return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
} }
@ -403,7 +409,8 @@ decode_video_object_layer(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guin
gst_vaapi_decoder_set_framerate (base_decoder, priv->fps_n, priv->fps_d); gst_vaapi_decoder_set_framerate (base_decoder, priv->fps_n, priv->fps_d);
} }
gst_vaapi_decoder_set_pixel_aspect_ratio(base_decoder, priv->vol_hdr.par_width, priv->vol_hdr.par_height); gst_vaapi_decoder_set_pixel_aspect_ratio (base_decoder,
priv->vol_hdr.par_width, priv->vol_hdr.par_height);
gst_vaapi_decoder_set_picture_size (base_decoder, priv->width, priv->height); gst_vaapi_decoder_set_picture_size (base_decoder, priv->width, priv->height);
return GST_VAAPI_DECODER_STATUS_SUCCESS; return GST_VAAPI_DECODER_STATUS_SUCCESS;
@ -417,12 +424,12 @@ decode_gop(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size)
GstClockTime gop_time; GstClockTime gop_time;
if (buf_size > 4) { if (buf_size > 4) {
if (gst_mpeg4_parse_group_of_vop(&gop, buf, buf_size) != GST_MPEG4_PARSER_OK) { if (gst_mpeg4_parse_group_of_vop (&gop, buf,
buf_size) != GST_MPEG4_PARSER_OK) {
GST_DEBUG ("failed to parse GOP"); GST_DEBUG ("failed to parse GOP");
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER; return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
} }
} } else {
else {
gop.closed = 1; gop.closed = 1;
gop.broken_link = 0; gop.broken_link = 0;
gop.hours = 0; gop.hours = 0;
@ -434,8 +441,7 @@ decode_gop(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size)
priv->broken_link = gop.broken_link; priv->broken_link = gop.broken_link;
GST_DEBUG ("GOP %02u:%02u:%02u (closed_gop %d, broken_link %d)", GST_DEBUG ("GOP %02u:%02u:%02u (closed_gop %d, broken_link %d)",
gop.hours, gop.minutes, gop.seconds, gop.hours, gop.minutes, gop.seconds, priv->closed_gop, priv->broken_link);
priv->closed_gop, priv->broken_link);
gop_time = gop.hours * 3600 + gop.minutes * 60 + gop.seconds; gop_time = gop.hours * 3600 + gop.minutes * 60 + gop.seconds;
priv->last_sync_time = gop_time; priv->last_sync_time = gop_time;
@ -452,8 +458,7 @@ decode_gop(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size)
void void
calculate_pts_diff (GstVaapiDecoderMpeg4 * decoder, calculate_pts_diff (GstVaapiDecoderMpeg4 * decoder,
GstMpeg4VideoObjectLayer *vol_hdr, GstMpeg4VideoObjectLayer * vol_hdr, GstMpeg4VideoObjectPlane * vop_hdr)
GstMpeg4VideoObjectPlane *vop_hdr)
{ {
GstVaapiDecoderMpeg4Private *const priv = &decoder->priv; GstVaapiDecoderMpeg4Private *const priv = &decoder->priv;
GstClockTime frame_timestamp; GstClockTime frame_timestamp;
@ -461,13 +466,11 @@ calculate_pts_diff(GstVaapiDecoderMpeg4 *decoder,
frame_timestamp = GST_VAAPI_DECODER_CODEC_FRAME (decoder)->pts; frame_timestamp = GST_VAAPI_DECODER_CODEC_FRAME (decoder)->pts;
if (frame_timestamp && frame_timestamp != GST_CLOCK_TIME_NONE) { if (frame_timestamp && frame_timestamp != GST_CLOCK_TIME_NONE) {
/* Buffer with timestamp */ /* Buffer with timestamp */
if (priv->max_pts != GST_CLOCK_TIME_NONE && if (priv->max_pts != GST_CLOCK_TIME_NONE && frame_timestamp < priv->max_pts) {
frame_timestamp < priv->max_pts) {
frame_timestamp = priv->max_pts + frame_timestamp = priv->max_pts +
gst_util_uint64_scale ((vol_hdr->fixed_vop_rate ? gst_util_uint64_scale ((vol_hdr->fixed_vop_rate ?
vol_hdr->fixed_vop_time_increment : 1), vol_hdr->fixed_vop_time_increment : 1),
GST_SECOND, GST_SECOND, vol_hdr->vop_time_increment_resolution);
vol_hdr->vop_time_increment_resolution);
} }
} else { } else {
/* Buffer without timestamp set */ /* Buffer without timestamp set */
@ -478,16 +481,14 @@ calculate_pts_diff(GstVaapiDecoderMpeg4 *decoder,
tmp_pts = priv->pts_diff + priv->gop_pts + tmp_pts = priv->pts_diff + priv->gop_pts +
vop_hdr->modulo_time_base * GST_SECOND + vop_hdr->modulo_time_base * GST_SECOND +
gst_util_uint64_scale (vop_hdr->time_increment, gst_util_uint64_scale (vop_hdr->time_increment,
GST_SECOND, GST_SECOND, vol_hdr->vop_time_increment_resolution);
vol_hdr->vop_time_increment_resolution);
if (tmp_pts > priv->max_pts) if (tmp_pts > priv->max_pts)
frame_timestamp = tmp_pts; frame_timestamp = tmp_pts;
else else
frame_timestamp = priv->max_pts + frame_timestamp = priv->max_pts +
gst_util_uint64_scale ((vol_hdr->fixed_vop_rate ? gst_util_uint64_scale ((vol_hdr->fixed_vop_rate ?
vol_hdr->fixed_vop_time_increment : 1), vol_hdr->fixed_vop_time_increment : 1),
GST_SECOND, GST_SECOND, vol_hdr->vop_time_increment_resolution);
vol_hdr->vop_time_increment_resolution);
} }
} }
@ -498,7 +499,8 @@ calculate_pts_diff(GstVaapiDecoderMpeg4 *decoder,
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_picture(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size) decode_picture (GstVaapiDecoderMpeg4 * decoder, const guint8 * buf,
guint buf_size)
{ {
GstMpeg4ParseResult parser_result = GST_MPEG4_PARSER_OK; GstMpeg4ParseResult parser_result = GST_MPEG4_PARSER_OK;
GstVaapiDecoderMpeg4Private *const priv = &decoder->priv; GstVaapiDecoderMpeg4Private *const priv = &decoder->priv;
@ -511,11 +513,14 @@ decode_picture(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size)
// context depends on priv->width and priv->height, so we move parse_vop a little earlier // context depends on priv->width and priv->height, so we move parse_vop a little earlier
if (priv->is_svh) { if (priv->is_svh) {
parser_result = gst_mpeg4_parse_video_plane_short_header(&priv->svh_hdr, buf, buf_size); parser_result =
gst_mpeg4_parse_video_plane_short_header (&priv->svh_hdr, buf,
buf_size);
} } else {
else { parser_result =
parser_result = gst_mpeg4_parse_video_object_plane(vop_hdr, sprite_trajectory, vol_hdr, buf, buf_size); gst_mpeg4_parse_video_object_plane (vop_hdr, sprite_trajectory, vol_hdr,
buf, buf_size);
/* Need to skip this frame if VOP was not coded */ /* Need to skip this frame if VOP was not coded */
if (GST_MPEG4_PARSER_OK == parser_result && !vop_hdr->coded) if (GST_MPEG4_PARSER_OK == parser_result && !vop_hdr->coded)
return (GstVaapiDecoderStatus) GST_VAAPI_DECODER_STATUS_DROP_FRAME; return (GstVaapiDecoderStatus) GST_VAAPI_DECODER_STATUS_DROP_FRAME;
@ -529,8 +534,7 @@ decode_picture(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size)
if (priv->is_svh) { if (priv->is_svh) {
priv->width = priv->svh_hdr.vop_width; priv->width = priv->svh_hdr.vop_width;
priv->height = priv->svh_hdr.vop_height; priv->height = priv->svh_hdr.vop_height;
} } else {
else {
if (!vop_hdr->width && !vop_hdr->height) { if (!vop_hdr->width && !vop_hdr->height) {
vop_hdr->width = vol_hdr->width; vop_hdr->width = vol_hdr->width;
vop_hdr->height = vol_hdr->height; vop_hdr->height = vol_hdr->height;
@ -574,8 +578,7 @@ decode_picture(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size)
*/ */
if (priv->is_svh) { if (priv->is_svh) {
priv->coding_type = priv->svh_hdr.picture_coding_type; priv->coding_type = priv->svh_hdr.picture_coding_type;
} } else {
else {
priv->coding_type = priv->vop_hdr.coding_type; priv->coding_type = priv->vop_hdr.coding_type;
} }
switch (priv->coding_type) { switch (priv->coding_type) {
@ -622,8 +625,7 @@ decode_picture(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size)
pts += gst_util_uint64_scale (delta_ref, GST_SECOND * 1001, 30000); pts += gst_util_uint64_scale (delta_ref, GST_SECOND * 1001, 30000);
priv->sync_time = pts; priv->sync_time = pts;
priv->prev_t_ref = priv->svh_hdr.temporal_reference; priv->prev_t_ref = priv->svh_hdr.temporal_reference;
} } else {
else {
/* Update priv->pts_diff */ /* Update priv->pts_diff */
if (priv->calculate_pts_diff) { if (priv->calculate_pts_diff) {
calculate_pts_diff (decoder, vol_hdr, vop_hdr); calculate_pts_diff (decoder, vol_hdr, vop_hdr);
@ -636,16 +638,23 @@ decode_picture(GstVaapiDecoderMpeg4 *decoder, const guint8 *buf, guint buf_size)
priv->last_sync_time = priv->sync_time; priv->last_sync_time = priv->sync_time;
priv->sync_time = priv->last_sync_time + vop_hdr->modulo_time_base; priv->sync_time = priv->last_sync_time + vop_hdr->modulo_time_base;
pts = priv->sync_time * GST_SECOND; pts = priv->sync_time * GST_SECOND;
pts += gst_util_uint64_scale(vop_hdr->time_increment, GST_SECOND, vol_hdr->vop_time_increment_resolution); pts +=
gst_util_uint64_scale (vop_hdr->time_increment, GST_SECOND,
vol_hdr->vop_time_increment_resolution);
priv->last_non_b_scale_time = priv->non_b_scale_time; priv->last_non_b_scale_time = priv->non_b_scale_time;
priv->non_b_scale_time = priv->sync_time * vol_hdr->vop_time_increment_resolution + vop_hdr->time_increment; priv->non_b_scale_time =
priv->sync_time * vol_hdr->vop_time_increment_resolution +
vop_hdr->time_increment;
priv->trd = priv->non_b_scale_time - priv->last_non_b_scale_time; priv->trd = priv->non_b_scale_time - priv->last_non_b_scale_time;
} } else {
else {
// increment basing on display oder // increment basing on display oder
pts = (priv->last_sync_time + vop_hdr->modulo_time_base) * GST_SECOND; pts = (priv->last_sync_time + vop_hdr->modulo_time_base) * GST_SECOND;
pts += gst_util_uint64_scale(vop_hdr->time_increment, GST_SECOND, vol_hdr->vop_time_increment_resolution); pts +=
priv->trb = (priv->last_sync_time + vop_hdr->modulo_time_base) * vol_hdr->vop_time_increment_resolution + gst_util_uint64_scale (vop_hdr->time_increment, GST_SECOND,
vol_hdr->vop_time_increment_resolution);
priv->trb =
(priv->last_sync_time +
vop_hdr->modulo_time_base) * vol_hdr->vop_time_increment_resolution +
vop_hdr->time_increment - priv->last_non_b_scale_time; vop_hdr->time_increment - priv->last_non_b_scale_time;
} }
} }
@ -702,13 +711,14 @@ fill_picture(GstVaapiDecoderMpeg4 *decoder, GstVaapiPicture *picture)
// VOP parameters // VOP parameters
pic_param->vop_width = priv->svh_hdr.vop_width; pic_param->vop_width = priv->svh_hdr.vop_width;
pic_param->vop_height = priv->svh_hdr.vop_height; pic_param->vop_height = priv->svh_hdr.vop_height;
pic_param->vop_fields.bits.vop_coding_type = priv->svh_hdr.picture_coding_type; pic_param->vop_fields.bits.vop_coding_type =
pic_param->vop_time_increment_resolution = priv->vol_hdr.vop_time_increment_resolution; priv->svh_hdr.picture_coding_type;
pic_param->vop_time_increment_resolution =
priv->vol_hdr.vop_time_increment_resolution;
pic_param->num_gobs_in_vop = priv->svh_hdr.num_gobs_in_vop; pic_param->num_gobs_in_vop = priv->svh_hdr.num_gobs_in_vop;
pic_param->num_macroblocks_in_gob = priv->svh_hdr.num_macroblocks_in_gob; pic_param->num_macroblocks_in_gob = priv->svh_hdr.num_macroblocks_in_gob;
} } else {
else {
int i; int i;
// VOL parameters // VOL parameters
@ -717,17 +727,23 @@ fill_picture(GstVaapiDecoderMpeg4 *decoder, GstVaapiPicture *picture)
pic_param->vol_fields.bits.interlaced = priv->vol_hdr.interlaced; pic_param->vol_fields.bits.interlaced = priv->vol_hdr.interlaced;
pic_param->vol_fields.bits.obmc_disable = priv->vol_hdr.obmc_disable; pic_param->vol_fields.bits.obmc_disable = priv->vol_hdr.obmc_disable;
pic_param->vol_fields.bits.sprite_enable = priv->vol_hdr.sprite_enable; pic_param->vol_fields.bits.sprite_enable = priv->vol_hdr.sprite_enable;
pic_param->vol_fields.bits.sprite_warping_accuracy = priv->vol_hdr.sprite_warping_accuracy; pic_param->vol_fields.bits.sprite_warping_accuracy =
priv->vol_hdr.sprite_warping_accuracy;
pic_param->vol_fields.bits.quant_type = priv->vol_hdr.quant_type; pic_param->vol_fields.bits.quant_type = priv->vol_hdr.quant_type;
pic_param->vol_fields.bits.quarter_sample = priv->vol_hdr.quarter_sample; pic_param->vol_fields.bits.quarter_sample = priv->vol_hdr.quarter_sample;
pic_param->vol_fields.bits.data_partitioned = priv->vol_hdr.data_partitioned; pic_param->vol_fields.bits.data_partitioned =
priv->vol_hdr.data_partitioned;
pic_param->vol_fields.bits.reversible_vlc = priv->vol_hdr.reversible_vlc; pic_param->vol_fields.bits.reversible_vlc = priv->vol_hdr.reversible_vlc;
pic_param->vol_fields.bits.resync_marker_disable = priv->vol_hdr.resync_marker_disable; pic_param->vol_fields.bits.resync_marker_disable =
pic_param->no_of_sprite_warping_points = priv->vol_hdr.no_of_sprite_warping_points; priv->vol_hdr.resync_marker_disable;
pic_param->no_of_sprite_warping_points =
priv->vol_hdr.no_of_sprite_warping_points;
for (i = 0; i < 3 && i < priv->vol_hdr.no_of_sprite_warping_points; i++) { for (i = 0; i < 3 && i < priv->vol_hdr.no_of_sprite_warping_points; i++) {
pic_param->sprite_trajectory_du[i] = priv->sprite_trajectory.vop_ref_points[i]; pic_param->sprite_trajectory_du[i] =
pic_param->sprite_trajectory_dv[i] = priv->sprite_trajectory.sprite_ref_points[i]; priv->sprite_trajectory.vop_ref_points[i];
pic_param->sprite_trajectory_dv[i] =
priv->sprite_trajectory.sprite_ref_points[i];
} }
pic_param->quant_precision = priv->vol_hdr.quant_precision; pic_param->quant_precision = priv->vol_hdr.quant_precision;
@ -738,11 +754,13 @@ fill_picture(GstVaapiDecoderMpeg4 *decoder, GstVaapiPicture *picture)
pic_param->vop_fields.bits.vop_rounding_type = vop_hdr->rounding_type; pic_param->vop_fields.bits.vop_rounding_type = vop_hdr->rounding_type;
pic_param->vop_fields.bits.intra_dc_vlc_thr = vop_hdr->intra_dc_vlc_thr; pic_param->vop_fields.bits.intra_dc_vlc_thr = vop_hdr->intra_dc_vlc_thr;
pic_param->vop_fields.bits.top_field_first = vop_hdr->top_field_first; pic_param->vop_fields.bits.top_field_first = vop_hdr->top_field_first;
pic_param->vop_fields.bits.alternate_vertical_scan_flag = vop_hdr->alternate_vertical_scan_flag; pic_param->vop_fields.bits.alternate_vertical_scan_flag =
vop_hdr->alternate_vertical_scan_flag;
pic_param->vop_fcode_forward = vop_hdr->fcode_forward; pic_param->vop_fcode_forward = vop_hdr->fcode_forward;
pic_param->vop_fcode_backward = vop_hdr->fcode_backward; pic_param->vop_fcode_backward = vop_hdr->fcode_backward;
pic_param->vop_time_increment_resolution = priv->vol_hdr.vop_time_increment_resolution; pic_param->vop_time_increment_resolution =
priv->vol_hdr.vop_time_increment_resolution;
} }
pic_param->TRB = 0; pic_param->TRB = 0;
@ -751,7 +769,8 @@ fill_picture(GstVaapiDecoderMpeg4 *decoder, GstVaapiPicture *picture)
case GST_MPEG4_B_VOP: case GST_MPEG4_B_VOP:
pic_param->TRB = priv->trb; pic_param->TRB = priv->trb;
pic_param->backward_reference_picture = priv->next_picture->surface_id; pic_param->backward_reference_picture = priv->next_picture->surface_id;
pic_param->vop_fields.bits.backward_reference_vop_coding_type = get_vop_coding_type(priv->next_picture); pic_param->vop_fields.bits.backward_reference_vop_coding_type =
get_vop_coding_type (priv->next_picture);
// fall-through // fall-through
case GST_MPEG4_P_VOP: case GST_MPEG4_P_VOP:
pic_param->TRD = priv->trd; pic_param->TRD = priv->trd;
@ -767,12 +786,8 @@ fill_picture(GstVaapiDecoderMpeg4 *decoder, GstVaapiPicture *picture)
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_slice( decode_slice (GstVaapiDecoderMpeg4 * decoder,
GstVaapiDecoderMpeg4 *decoder, const guint8 * buf, guint buf_size, gboolean has_packet_header)
const guint8 *buf,
guint buf_size,
gboolean has_packet_header
)
{ {
GstVaapiDecoderMpeg4Private *const priv = &decoder->priv; GstVaapiDecoderMpeg4Private *const priv = &decoder->priv;
GstVaapiPicture *const picture = priv->curr_picture; GstVaapiPicture *const picture = priv->curr_picture;
@ -799,14 +814,12 @@ decode_slice(
slice_param->macroblock_number = 0; slice_param->macroblock_number = 0;
// the header of first gob_layer is empty (gob_header_empty=1), use vop_quant // the header of first gob_layer is empty (gob_header_empty=1), use vop_quant
slice_param->quant_scale = priv->svh_hdr.vop_quant; slice_param->quant_scale = priv->svh_hdr.vop_quant;
} } else {
else {
if (has_packet_header) { if (has_packet_header) {
slice_param->macroblock_offset = priv->packet_hdr.size % 8; slice_param->macroblock_offset = priv->packet_hdr.size % 8;
slice_param->macroblock_number = priv->packet_hdr.macroblock_number; slice_param->macroblock_number = priv->packet_hdr.macroblock_number;
slice_param->quant_scale = priv->packet_hdr.quant_scale; slice_param->quant_scale = priv->packet_hdr.quant_scale;
} } else {
else {
slice_param->macroblock_offset = priv->vop_hdr.size % 8; slice_param->macroblock_offset = priv->vop_hdr.size % 8;
slice_param->macroblock_number = 0; slice_param->macroblock_number = 0;
slice_param->quant_scale = priv->vop_hdr.quant; slice_param->quant_scale = priv->vop_hdr.quant;
@ -824,25 +837,27 @@ decode_packet(GstVaapiDecoderMpeg4 *decoder, GstMpeg4Packet packet)
// packet.size is the size from current marker to the next. // packet.size is the size from current marker to the next.
if (tos->type == GST_MPEG4_VISUAL_OBJ_SEQ_START) { if (tos->type == GST_MPEG4_VISUAL_OBJ_SEQ_START) {
status = decode_sequence(decoder, packet.data + packet.offset, packet.size); status =
} decode_sequence (decoder, packet.data + packet.offset, packet.size);
else if (tos->type == GST_MPEG4_VISUAL_OBJ_SEQ_END) { } else if (tos->type == GST_MPEG4_VISUAL_OBJ_SEQ_END) {
status = decode_sequence_end (decoder); status = decode_sequence_end (decoder);
} } else if (tos->type == GST_MPEG4_VISUAL_OBJ) {
else if (tos->type == GST_MPEG4_VISUAL_OBJ) { status =
status = decode_visual_object(decoder, packet.data + packet.offset, packet.size); decode_visual_object (decoder, packet.data + packet.offset,
} packet.size);
else if (tos->type >= GST_MPEG4_VIDEO_OBJ_FIRST && tos->type <= GST_MPEG4_VIDEO_OBJ_LAST) { } else if (tos->type >= GST_MPEG4_VIDEO_OBJ_FIRST
GST_WARNING("unexpected marker: (GST_MPEG4_VIDEO_OBJ_FIRST, GST_MPEG4_VIDEO_OBJ_LAST)"); && tos->type <= GST_MPEG4_VIDEO_OBJ_LAST) {
GST_WARNING
("unexpected marker: (GST_MPEG4_VIDEO_OBJ_FIRST, GST_MPEG4_VIDEO_OBJ_LAST)");
status = GST_VAAPI_DECODER_STATUS_SUCCESS; status = GST_VAAPI_DECODER_STATUS_SUCCESS;
} } else if (tos->type >= GST_MPEG4_VIDEO_LAYER_FIRST
else if (tos->type >= GST_MPEG4_VIDEO_LAYER_FIRST && tos->type <= GST_MPEG4_VIDEO_LAYER_LAST) { && tos->type <= GST_MPEG4_VIDEO_LAYER_LAST) {
status = decode_video_object_layer(decoder, packet.data + packet.offset, packet.size); status =
} decode_video_object_layer (decoder, packet.data + packet.offset,
else if (tos->type == GST_MPEG4_GROUP_OF_VOP) { packet.size);
} else if (tos->type == GST_MPEG4_GROUP_OF_VOP) {
status = decode_gop (decoder, packet.data + packet.offset, packet.size); status = decode_gop (decoder, packet.data + packet.offset, packet.size);
} } else if (tos->type == GST_MPEG4_VIDEO_OBJ_PLANE) {
else if (tos->type == GST_MPEG4_VIDEO_OBJ_PLANE) {
GstMpeg4Packet video_packet; GstMpeg4Packet video_packet;
const guint8 *_data; const guint8 *_data;
gint _data_size; gint _data_size;
@ -867,8 +882,7 @@ decode_packet(GstVaapiDecoderMpeg4 *decoder, GstMpeg4Packet packet)
status = decode_slice (decoder, _data, _data_size, FALSE); status = decode_slice (decoder, _data, _data_size, FALSE);
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
return status; return status;
} } else {
else {
GstMpeg4ParseResult ret = GST_MPEG4_PARSER_OK; GstMpeg4ParseResult ret = GST_MPEG4_PARSER_OK;
gboolean first_slice = TRUE; gboolean first_slice = TRUE;
@ -877,7 +891,9 @@ decode_packet(GstVaapiDecoderMpeg4 *decoder, GstMpeg4Packet packet)
while (_data_size > 0) { while (_data_size > 0) {
// we can skip user data here // we can skip user data here
ret = gst_mpeg4_parse(&video_packet, TRUE, &priv->vop_hdr, _data, 0, _data_size); ret =
gst_mpeg4_parse (&video_packet, TRUE, &priv->vop_hdr, _data, 0,
_data_size);
if (ret != GST_MPEG4_PARSER_OK) { if (ret != GST_MPEG4_PARSER_OK) {
break; break;
} }
@ -885,13 +901,17 @@ decode_packet(GstVaapiDecoderMpeg4 *decoder, GstMpeg4Packet packet)
if (first_slice) { if (first_slice) {
status = decode_slice (decoder, _data, video_packet.size, FALSE); status = decode_slice (decoder, _data, video_packet.size, FALSE);
first_slice = FALSE; first_slice = FALSE;
} } else {
else {
_data += video_packet.offset; _data += video_packet.offset;
_data_size -= video_packet.offset; _data_size -= video_packet.offset;
ret = gst_mpeg4_parse_video_packet_header (&priv->packet_hdr, &priv->vol_hdr, &priv->vop_hdr, &priv->sprite_trajectory, _data, _data_size); ret =
status = decode_slice(decoder,_data + priv->packet_hdr.size/8, video_packet.size - priv->packet_hdr.size/8, TRUE); gst_mpeg4_parse_video_packet_header (&priv->packet_hdr,
&priv->vol_hdr, &priv->vop_hdr, &priv->sprite_trajectory, _data,
_data_size);
status =
decode_slice (decoder, _data + priv->packet_hdr.size / 8,
video_packet.size - priv->packet_hdr.size / 8, TRUE);
} }
_data += video_packet.size; _data += video_packet.size;
@ -899,8 +919,7 @@ decode_packet(GstVaapiDecoderMpeg4 *decoder, GstMpeg4Packet packet)
} }
} }
status = decode_current_picture (decoder); status = decode_current_picture (decoder);
} } else if (tos->type == GST_MPEG4_USER_DATA
else if (tos->type == GST_MPEG4_USER_DATA
|| tos->type == GST_MPEG4_VIDEO_SESSION_ERR || tos->type == GST_MPEG4_VIDEO_SESSION_ERR
|| tos->type == GST_MPEG4_FBA || tos->type == GST_MPEG4_FBA
|| tos->type == GST_MPEG4_FBA_PLAN || tos->type == GST_MPEG4_FBA_PLAN
@ -916,8 +935,7 @@ decode_packet(GstVaapiDecoderMpeg4 *decoder, GstMpeg4Packet packet)
|| tos->type == GST_MPEG4_SYSTEM_LAST) { || tos->type == GST_MPEG4_SYSTEM_LAST) {
GST_WARNING ("Ignore marker: %x\n", tos->type); GST_WARNING ("Ignore marker: %x\n", tos->type);
status = GST_VAAPI_DECODER_STATUS_SUCCESS; status = GST_VAAPI_DECODER_STATUS_SUCCESS;
} } else {
else {
GST_ERROR ("unsupported start code %x\n", tos->type); GST_ERROR ("unsupported start code %x\n", tos->type);
status = GST_VAAPI_DECODER_STATUS_SUCCESS; status = GST_VAAPI_DECODER_STATUS_SUCCESS;
} }
@ -926,7 +944,8 @@ decode_packet(GstVaapiDecoderMpeg4 *decoder, GstMpeg4Packet packet)
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_buffer(GstVaapiDecoderMpeg4 *decoder, const guchar *buf, guint buf_size) decode_buffer (GstVaapiDecoderMpeg4 * decoder, const guchar * buf,
guint buf_size)
{ {
GstVaapiDecoderMpeg4Private *const priv = &decoder->priv; GstVaapiDecoderMpeg4Private *const priv = &decoder->priv;
GstVaapiDecoderStatus status; GstVaapiDecoderStatus status;
@ -942,8 +961,7 @@ decode_buffer(GstVaapiDecoderMpeg4 *decoder, const guchar *buf, guint buf_size)
status = decode_slice (decoder, buf + ofs, buf_size - ofs, FALSE); status = decode_slice (decoder, buf + ofs, buf_size - ofs, FALSE);
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
return status; return status;
} } else {
else {
packet.data = buf; packet.data = buf;
packet.offset = 0; packet.offset = 0;
packet.size = buf_size; packet.size = buf_size;
@ -987,8 +1005,7 @@ gst_vaapi_decoder_mpeg4_decode_codec_data(GstVaapiDecoder *base_decoder,
status = decode_packet (decoder, packet); status = decode_packet (decoder, packet);
if (GST_VAAPI_DECODER_STATUS_SUCCESS == status) { if (GST_VAAPI_DECODER_STATUS_SUCCESS == status) {
pos = packet.offset + packet.size; pos = packet.offset + packet.size;
} } else {
else {
GST_WARNING ("decode mp4 packet failed when decoding codec data\n"); GST_WARNING ("decode mp4 packet failed when decoding codec data\n");
break; break;
} }
@ -1008,8 +1025,8 @@ ensure_decoder(GstVaapiDecoderMpeg4 *decoder)
if (!priv->is_opened) if (!priv->is_opened)
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC; return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC;
status = gst_vaapi_decoder_decode_codec_data( status =
GST_VAAPI_DECODER_CAST(decoder)); gst_vaapi_decoder_decode_codec_data (GST_VAAPI_DECODER_CAST (decoder));
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
return status; return status;
} }
@ -1149,8 +1166,7 @@ gst_vaapi_decoder_mpeg4_class_init(GstVaapiDecoderMpeg4Class *klass)
decoder_class->parse = gst_vaapi_decoder_mpeg4_parse; decoder_class->parse = gst_vaapi_decoder_mpeg4_parse;
decoder_class->decode = gst_vaapi_decoder_mpeg4_decode; decoder_class->decode = gst_vaapi_decoder_mpeg4_decode;
decoder_class->decode_codec_data = decoder_class->decode_codec_data = gst_vaapi_decoder_mpeg4_decode_codec_data;
gst_vaapi_decoder_mpeg4_decode_codec_data;
} }
static inline const GstVaapiDecoderClass * static inline const GstVaapiDecoderClass *

View File

@ -50,7 +50,8 @@ typedef struct _GstVaapiDecoderVC1Class GstVaapiDecoderVC1Class;
* *
* A decoder based on VC1. * A decoder based on VC1.
*/ */
struct _GstVaapiDecoderVC1Private { struct _GstVaapiDecoderVC1Private
{
GstVaapiProfile profile; GstVaapiProfile profile;
guint width; guint width;
guint height; guint height;
@ -80,7 +81,8 @@ struct _GstVaapiDecoderVC1Private {
* *
* A decoder based on VC1. * A decoder based on VC1.
*/ */
struct _GstVaapiDecoderVC1 { struct _GstVaapiDecoderVC1
{
/*< private > */ /*< private > */
GstVaapiDecoder parent_instance; GstVaapiDecoder parent_instance;
GstVaapiDecoderVC1Private priv; GstVaapiDecoderVC1Private priv;
@ -91,7 +93,8 @@ struct _GstVaapiDecoderVC1 {
* *
* A decoder class based on VC1. * A decoder class based on VC1.
*/ */
struct _GstVaapiDecoderVC1Class { struct _GstVaapiDecoderVC1Class
{
/*< private > */ /*< private > */
GstVaapiDecoderClass parent_class; GstVaapiDecoderClass parent_class;
}; };
@ -153,8 +156,7 @@ gst_vaapi_decoder_vc1_open(GstVaapiDecoderVC1 *decoder)
static void static void
gst_vaapi_decoder_vc1_destroy (GstVaapiDecoder * base_decoder) gst_vaapi_decoder_vc1_destroy (GstVaapiDecoder * base_decoder)
{ {
GstVaapiDecoderVC1 * const decoder = GstVaapiDecoderVC1 *const decoder = GST_VAAPI_DECODER_VC1_CAST (base_decoder);
GST_VAAPI_DECODER_VC1_CAST(base_decoder);
GstVaapiDecoderVC1Private *const priv = &decoder->priv; GstVaapiDecoderVC1Private *const priv = &decoder->priv;
gst_vaapi_decoder_vc1_close (decoder); gst_vaapi_decoder_vc1_close (decoder);
@ -169,8 +171,7 @@ gst_vaapi_decoder_vc1_destroy(GstVaapiDecoder *base_decoder)
static gboolean static gboolean
gst_vaapi_decoder_vc1_create (GstVaapiDecoder * base_decoder) gst_vaapi_decoder_vc1_create (GstVaapiDecoder * base_decoder)
{ {
GstVaapiDecoderVC1 * const decoder = GstVaapiDecoderVC1 *const decoder = GST_VAAPI_DECODER_VC1_CAST (base_decoder);
GST_VAAPI_DECODER_VC1_CAST(base_decoder);
GstVaapiDecoderVC1Private *const priv = &decoder->priv; GstVaapiDecoderVC1Private *const priv = &decoder->priv;
priv->profile = (GstVaapiProfile) 0; priv->profile = (GstVaapiProfile) 0;
@ -221,10 +222,8 @@ ensure_context(GstVaapiDecoderVC1 *decoder)
info.width = priv->width; info.width = priv->width;
info.height = priv->height; info.height = priv->height;
info.ref_frames = 2; info.ref_frames = 2;
reset_context = gst_vaapi_decoder_ensure_context( reset_context =
GST_VAAPI_DECODER(decoder), gst_vaapi_decoder_ensure_context (GST_VAAPI_DECODER (decoder), &info);
&info
);
if (!reset_context) if (!reset_context)
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN; return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
} }
@ -256,7 +255,8 @@ error:
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_sequence(GstVaapiDecoderVC1 *decoder, GstVC1BDU *rbdu, GstVC1BDU *ebdu) decode_sequence (GstVaapiDecoderVC1 * decoder, GstVC1BDU * rbdu,
GstVC1BDU * ebdu)
{ {
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (decoder); GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (decoder);
GstVaapiDecoderVC1Private *const priv = &decoder->priv; GstVaapiDecoderVC1Private *const priv = &decoder->priv;
@ -267,11 +267,8 @@ decode_sequence(GstVaapiDecoderVC1 *decoder, GstVC1BDU *rbdu, GstVC1BDU *ebdu)
GstVaapiProfile profile; GstVaapiProfile profile;
guint width, height, fps_n, fps_d, par_n, par_d; guint width, height, fps_n, fps_d, par_n, par_d;
result = gst_vc1_parse_sequence_header( result = gst_vc1_parse_sequence_header (rbdu->data + rbdu->offset,
rbdu->data + rbdu->offset, rbdu->size, seq_hdr);
rbdu->size,
seq_hdr
);
if (result != GST_VC1_PARSER_OK) { if (result != GST_VC1_PARSER_OK) {
GST_ERROR ("failed to parse sequence layer"); GST_ERROR ("failed to parse sequence layer");
return get_status (result); return get_status (result);
@ -387,19 +384,16 @@ decode_sequence_end(GstVaapiDecoderVC1 *decoder)
} }
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_entry_point(GstVaapiDecoderVC1 *decoder, GstVC1BDU *rbdu, GstVC1BDU *ebdu) decode_entry_point (GstVaapiDecoderVC1 * decoder, GstVC1BDU * rbdu,
GstVC1BDU * ebdu)
{ {
GstVaapiDecoderVC1Private *const priv = &decoder->priv; GstVaapiDecoderVC1Private *const priv = &decoder->priv;
GstVC1SeqHdr *const seq_hdr = &priv->seq_hdr; GstVC1SeqHdr *const seq_hdr = &priv->seq_hdr;
GstVC1EntryPointHdr *const entrypoint_hdr = &priv->entrypoint_hdr; GstVC1EntryPointHdr *const entrypoint_hdr = &priv->entrypoint_hdr;
GstVC1ParserResult result; GstVC1ParserResult result;
result = gst_vc1_parse_entry_point_header( result = gst_vc1_parse_entry_point_header (rbdu->data + rbdu->offset,
rbdu->data + rbdu->offset, rbdu->size, entrypoint_hdr, seq_hdr);
rbdu->size,
entrypoint_hdr,
seq_hdr
);
if (result != GST_VC1_PARSER_OK) { if (result != GST_VC1_PARSER_OK) {
GST_ERROR ("failed to parse entrypoint layer"); GST_ERROR ("failed to parse entrypoint layer");
return get_status (result); return get_status (result);
@ -422,10 +416,14 @@ static guint
get_PTYPE (guint ptype) get_PTYPE (guint ptype)
{ {
switch (ptype) { switch (ptype) {
case GST_VC1_PICTURE_TYPE_I: return 0; case GST_VC1_PICTURE_TYPE_I:
case GST_VC1_PICTURE_TYPE_P: return 1; return 0;
case GST_VC1_PICTURE_TYPE_B: return 2; case GST_VC1_PICTURE_TYPE_P:
case GST_VC1_PICTURE_TYPE_BI: return 3; return 1;
case GST_VC1_PICTURE_TYPE_B:
return 2;
case GST_VC1_PICTURE_TYPE_BI:
return 3;
} }
return 4; /* skipped P-frame */ return 4; /* skipped P-frame */
} }
@ -436,34 +434,36 @@ get_BFRACTION(guint bfraction)
{ {
guint i; guint i;
static const struct { static const struct
{
guint16 index; guint16 index;
guint16 value; guint16 value;
} }
bfraction_map[] = { bfraction_map[] = {
{ 0, GST_VC1_BFRACTION_BASIS / 2 }, {
{ 1, GST_VC1_BFRACTION_BASIS / 3 }, 0, GST_VC1_BFRACTION_BASIS / 2}, {
{ 2, (GST_VC1_BFRACTION_BASIS * 2) / 3 }, 1, GST_VC1_BFRACTION_BASIS / 3}, {
{ 3, GST_VC1_BFRACTION_BASIS / 4 }, 2, (GST_VC1_BFRACTION_BASIS * 2) / 3}, {
{ 4, (GST_VC1_BFRACTION_BASIS * 3) / 4 }, 3, GST_VC1_BFRACTION_BASIS / 4}, {
{ 5, GST_VC1_BFRACTION_BASIS / 5 }, 4, (GST_VC1_BFRACTION_BASIS * 3) / 4}, {
{ 6, (GST_VC1_BFRACTION_BASIS * 2) / 5 }, 5, GST_VC1_BFRACTION_BASIS / 5}, {
{ 7, (GST_VC1_BFRACTION_BASIS * 3) / 5 }, 6, (GST_VC1_BFRACTION_BASIS * 2) / 5}, {
{ 8, (GST_VC1_BFRACTION_BASIS * 4) / 5 }, 7, (GST_VC1_BFRACTION_BASIS * 3) / 5}, {
{ 9, GST_VC1_BFRACTION_BASIS / 6 }, 8, (GST_VC1_BFRACTION_BASIS * 4) / 5}, {
{ 10, (GST_VC1_BFRACTION_BASIS * 5) / 6 }, 9, GST_VC1_BFRACTION_BASIS / 6}, {
{ 11, GST_VC1_BFRACTION_BASIS / 7 }, 10, (GST_VC1_BFRACTION_BASIS * 5) / 6}, {
{ 12, (GST_VC1_BFRACTION_BASIS * 2) / 7 }, 11, GST_VC1_BFRACTION_BASIS / 7}, {
{ 13, (GST_VC1_BFRACTION_BASIS * 3) / 7 }, 12, (GST_VC1_BFRACTION_BASIS * 2) / 7}, {
{ 14, (GST_VC1_BFRACTION_BASIS * 4) / 7 }, 13, (GST_VC1_BFRACTION_BASIS * 3) / 7}, {
{ 15, (GST_VC1_BFRACTION_BASIS * 5) / 7 }, 14, (GST_VC1_BFRACTION_BASIS * 4) / 7}, {
{ 16, (GST_VC1_BFRACTION_BASIS * 6) / 7 }, 15, (GST_VC1_BFRACTION_BASIS * 5) / 7}, {
{ 17, GST_VC1_BFRACTION_BASIS / 8 }, 16, (GST_VC1_BFRACTION_BASIS * 6) / 7}, {
{ 18, (GST_VC1_BFRACTION_BASIS * 3) / 8 }, 17, GST_VC1_BFRACTION_BASIS / 8}, {
{ 19, (GST_VC1_BFRACTION_BASIS * 5) / 8 }, 18, (GST_VC1_BFRACTION_BASIS * 3) / 8}, {
{ 20, (GST_VC1_BFRACTION_BASIS * 7) / 8 }, 19, (GST_VC1_BFRACTION_BASIS * 5) / 8}, {
{ 21, GST_VC1_BFRACTION_RESERVED }, 20, (GST_VC1_BFRACTION_BASIS * 7) / 8}, {
{ 22, GST_VC1_BFRACTION_PTYPE_BI } 21, GST_VC1_BFRACTION_RESERVED}, {
22, GST_VC1_BFRACTION_PTYPE_BI}
}; };
if (!bfraction) if (!bfraction)
@ -481,11 +481,16 @@ static guint
get_VAMvModeVC1 (guint mvmode) get_VAMvModeVC1 (guint mvmode)
{ {
switch (mvmode) { switch (mvmode) {
case GST_VC1_MVMODE_1MV_HPEL_BILINEAR: return VAMvMode1MvHalfPelBilinear; case GST_VC1_MVMODE_1MV_HPEL_BILINEAR:
case GST_VC1_MVMODE_1MV: return VAMvMode1Mv; return VAMvMode1MvHalfPelBilinear;
case GST_VC1_MVMODE_1MV_HPEL: return VAMvMode1MvHalfPel; case GST_VC1_MVMODE_1MV:
case GST_VC1_MVMODE_MIXED_MV: return VAMvModeMixedMv; return VAMvMode1Mv;
case GST_VC1_MVMODE_INTENSITY_COMP: return VAMvModeIntensityCompensation; case GST_VC1_MVMODE_1MV_HPEL:
return VAMvMode1MvHalfPel;
case GST_VC1_MVMODE_MIXED_MV:
return VAMvModeMixedMv;
case GST_VC1_MVMODE_INTENSITY_COMP:
return VAMvModeIntensityCompensation;
} }
return 0; return 0;
} }
@ -516,8 +521,7 @@ get_MVMODE2(GstVC1FrameHdr *frame_hdr)
if (frame_hdr->profile == GST_VC1_PROFILE_ADVANCED) { if (frame_hdr->profile == GST_VC1_PROFILE_ADVANCED) {
mvmode = frame_hdr->pic.advanced.mvmode; mvmode = frame_hdr->pic.advanced.mvmode;
mvmode2 = frame_hdr->pic.advanced.mvmode2; mvmode2 = frame_hdr->pic.advanced.mvmode2;
} } else {
else {
mvmode = frame_hdr->pic.simple.mvmode; mvmode = frame_hdr->pic.simple.mvmode;
mvmode2 = frame_hdr->pic.simple.mvmode2; mvmode2 = frame_hdr->pic.simple.mvmode2;
} }
@ -542,8 +546,7 @@ has_MVTYPEMB_bitplane(GstVaapiDecoderVC1 *decoder)
return 0; return 0;
mvmode = pic->mvmode; mvmode = pic->mvmode;
mvmode2 = pic->mvmode2; mvmode2 = pic->mvmode2;
} } else {
else {
GstVC1PicSimpleMain *const pic = &frame_hdr->pic.simple; GstVC1PicSimpleMain *const pic = &frame_hdr->pic.simple;
if (pic->mvtypemb) if (pic->mvtypemb)
return 0; return 0;
@ -567,8 +570,7 @@ has_SKIPMB_bitplane(GstVaapiDecoderVC1 *decoder)
GstVC1PicAdvanced *const pic = &frame_hdr->pic.advanced; GstVC1PicAdvanced *const pic = &frame_hdr->pic.advanced;
if (pic->skipmb) if (pic->skipmb)
return 0; return 0;
} } else {
else {
GstVC1PicSimpleMain *const pic = &frame_hdr->pic.simple; GstVC1PicSimpleMain *const pic = &frame_hdr->pic.simple;
if (pic->skipmb) if (pic->skipmb)
return 0; return 0;
@ -588,8 +590,7 @@ has_DIRECTMB_bitplane(GstVaapiDecoderVC1 *decoder)
GstVC1PicAdvanced *const pic = &frame_hdr->pic.advanced; GstVC1PicAdvanced *const pic = &frame_hdr->pic.advanced;
if (pic->directmb) if (pic->directmb)
return 0; return 0;
} } else {
else {
GstVC1PicSimpleMain *const pic = &frame_hdr->pic.simple; GstVC1PicSimpleMain *const pic = &frame_hdr->pic.simple;
if (pic->directmb) if (pic->directmb)
return 0; return 0;
@ -633,7 +634,8 @@ has_OVERFLAGS_bitplane(GstVaapiDecoderVC1 *decoder)
} }
static inline void static inline void
pack_bitplanes(GstVaapiBitPlane *bitplane, guint n, const guint8 *bitplanes[3], guint x, guint y, guint stride) pack_bitplanes (GstVaapiBitPlane * bitplane, guint n,
const guint8 * bitplanes[3], guint x, guint y, guint stride)
{ {
const guint dst_index = n / 2; const guint dst_index = n / 2;
const guint src_index = y * stride + x; const guint src_index = y * stride + x;
@ -677,16 +679,20 @@ fill_picture_structc(GstVaapiDecoderVC1 *decoder, GstVaapiPicture *picture)
pic_param->raw_coding.flags.mv_type_mb = pic->mvtypemb; pic_param->raw_coding.flags.mv_type_mb = pic->mvtypemb;
pic_param->raw_coding.flags.direct_mb = pic->directmb; pic_param->raw_coding.flags.direct_mb = pic->directmb;
pic_param->raw_coding.flags.skip_mb = pic->skipmb; pic_param->raw_coding.flags.skip_mb = pic->skipmb;
pic_param->bitplane_present.flags.bp_mv_type_mb = has_MVTYPEMB_bitplane(decoder); pic_param->bitplane_present.flags.bp_mv_type_mb =
pic_param->bitplane_present.flags.bp_direct_mb = has_DIRECTMB_bitplane(decoder); has_MVTYPEMB_bitplane (decoder);
pic_param->bitplane_present.flags.bp_direct_mb =
has_DIRECTMB_bitplane (decoder);
pic_param->bitplane_present.flags.bp_skip_mb = has_SKIPMB_bitplane (decoder); pic_param->bitplane_present.flags.bp_skip_mb = has_SKIPMB_bitplane (decoder);
pic_param->mv_fields.bits.mv_table = pic->mvtab; pic_param->mv_fields.bits.mv_table = pic->mvtab;
pic_param->mv_fields.bits.extended_mv_flag = structc->extended_mv; pic_param->mv_fields.bits.extended_mv_flag = structc->extended_mv;
pic_param->mv_fields.bits.extended_mv_range = pic->mvrange; pic_param->mv_fields.bits.extended_mv_range = pic->mvrange;
pic_param->transform_fields.bits.variable_sized_transform_flag = structc->vstransform; pic_param->transform_fields.bits.variable_sized_transform_flag =
structc->vstransform;
pic_param->transform_fields.bits.mb_level_transform_type_flag = pic->ttmbf; pic_param->transform_fields.bits.mb_level_transform_type_flag = pic->ttmbf;
pic_param->transform_fields.bits.frame_level_transform_type = pic->ttfrm; pic_param->transform_fields.bits.frame_level_transform_type = pic->ttfrm;
pic_param->transform_fields.bits.transform_ac_codingset_idx2 = pic->transacfrm2; pic_param->transform_fields.bits.transform_ac_codingset_idx2 =
pic->transacfrm2;
/* Refer to 8.3.7 Rounding control for Simple and Main Profile */ /* Refer to 8.3.7 Rounding control for Simple and Main Profile */
if (frame_hdr->ptype == GST_VC1_PICTURE_TYPE_I || if (frame_hdr->ptype == GST_VC1_PICTURE_TYPE_I ||
@ -726,9 +732,11 @@ fill_picture_advanced(GstVaapiDecoderVC1 *decoder, GstVaapiPicture *picture)
pic_param->entrypoint_fields.bits.loopfilter = entrypoint_hdr->loopfilter; pic_param->entrypoint_fields.bits.loopfilter = entrypoint_hdr->loopfilter;
pic_param->conditional_overlap_flag = pic->condover; pic_param->conditional_overlap_flag = pic->condover;
pic_param->fast_uvmc_flag = entrypoint_hdr->fastuvmc; pic_param->fast_uvmc_flag = entrypoint_hdr->fastuvmc;
pic_param->range_mapping_fields.bits.luma_flag = entrypoint_hdr->range_mapy_flag; pic_param->range_mapping_fields.bits.luma_flag =
entrypoint_hdr->range_mapy_flag;
pic_param->range_mapping_fields.bits.luma = entrypoint_hdr->range_mapy; pic_param->range_mapping_fields.bits.luma = entrypoint_hdr->range_mapy;
pic_param->range_mapping_fields.bits.chroma_flag = entrypoint_hdr->range_mapuv_flag; pic_param->range_mapping_fields.bits.chroma_flag =
entrypoint_hdr->range_mapuv_flag;
pic_param->range_mapping_fields.bits.chroma = entrypoint_hdr->range_mapuv; pic_param->range_mapping_fields.bits.chroma = entrypoint_hdr->range_mapuv;
pic_param->b_picture_fraction = get_BFRACTION (pic->bfraction); pic_param->b_picture_fraction = get_BFRACTION (pic->bfraction);
pic_param->cbp_table = pic->cbptab; pic_param->cbp_table = pic->cbptab;
@ -742,28 +750,35 @@ fill_picture_advanced(GstVaapiDecoderVC1 *decoder, GstVaapiPicture *picture)
pic_param->picture_fields.bits.frame_coding_mode = pic->fcm; pic_param->picture_fields.bits.frame_coding_mode = pic->fcm;
pic_param->picture_fields.bits.top_field_first = pic->tff; pic_param->picture_fields.bits.top_field_first = pic->tff;
pic_param->picture_fields.bits.is_first_field = pic->fcm == 0; /* XXX: interlaced frame */ pic_param->picture_fields.bits.is_first_field = pic->fcm == 0; /* XXX: interlaced frame */
pic_param->picture_fields.bits.intensity_compensation = pic->mvmode == GST_VC1_MVMODE_INTENSITY_COMP; pic_param->picture_fields.bits.intensity_compensation =
pic->mvmode == GST_VC1_MVMODE_INTENSITY_COMP;
pic_param->raw_coding.flags.mv_type_mb = pic->mvtypemb; pic_param->raw_coding.flags.mv_type_mb = pic->mvtypemb;
pic_param->raw_coding.flags.direct_mb = pic->directmb; pic_param->raw_coding.flags.direct_mb = pic->directmb;
pic_param->raw_coding.flags.skip_mb = pic->skipmb; pic_param->raw_coding.flags.skip_mb = pic->skipmb;
pic_param->raw_coding.flags.ac_pred = pic->acpred; pic_param->raw_coding.flags.ac_pred = pic->acpred;
pic_param->raw_coding.flags.overflags = pic->overflags; pic_param->raw_coding.flags.overflags = pic->overflags;
pic_param->bitplane_present.flags.bp_mv_type_mb = has_MVTYPEMB_bitplane(decoder); pic_param->bitplane_present.flags.bp_mv_type_mb =
pic_param->bitplane_present.flags.bp_direct_mb = has_DIRECTMB_bitplane(decoder); has_MVTYPEMB_bitplane (decoder);
pic_param->bitplane_present.flags.bp_direct_mb =
has_DIRECTMB_bitplane (decoder);
pic_param->bitplane_present.flags.bp_skip_mb = has_SKIPMB_bitplane (decoder); pic_param->bitplane_present.flags.bp_skip_mb = has_SKIPMB_bitplane (decoder);
pic_param->bitplane_present.flags.bp_ac_pred = has_ACPRED_bitplane (decoder); pic_param->bitplane_present.flags.bp_ac_pred = has_ACPRED_bitplane (decoder);
pic_param->bitplane_present.flags.bp_overflags = has_OVERFLAGS_bitplane(decoder); pic_param->bitplane_present.flags.bp_overflags =
pic_param->reference_fields.bits.reference_distance_flag = entrypoint_hdr->refdist_flag; has_OVERFLAGS_bitplane (decoder);
pic_param->reference_fields.bits.reference_distance_flag =
entrypoint_hdr->refdist_flag;
pic_param->mv_fields.bits.mv_table = pic->mvtab; pic_param->mv_fields.bits.mv_table = pic->mvtab;
pic_param->mv_fields.bits.extended_mv_flag = entrypoint_hdr->extended_mv; pic_param->mv_fields.bits.extended_mv_flag = entrypoint_hdr->extended_mv;
pic_param->mv_fields.bits.extended_mv_range = pic->mvrange; pic_param->mv_fields.bits.extended_mv_range = pic->mvrange;
pic_param->mv_fields.bits.extended_dmv_flag = entrypoint_hdr->extended_dmv; pic_param->mv_fields.bits.extended_dmv_flag = entrypoint_hdr->extended_dmv;
pic_param->pic_quantizer_fields.bits.dquant = entrypoint_hdr->dquant; pic_param->pic_quantizer_fields.bits.dquant = entrypoint_hdr->dquant;
pic_param->pic_quantizer_fields.bits.quantizer = entrypoint_hdr->quantizer; pic_param->pic_quantizer_fields.bits.quantizer = entrypoint_hdr->quantizer;
pic_param->transform_fields.bits.variable_sized_transform_flag = entrypoint_hdr->vstransform; pic_param->transform_fields.bits.variable_sized_transform_flag =
entrypoint_hdr->vstransform;
pic_param->transform_fields.bits.mb_level_transform_type_flag = pic->ttmbf; pic_param->transform_fields.bits.mb_level_transform_type_flag = pic->ttmbf;
pic_param->transform_fields.bits.frame_level_transform_type = pic->ttfrm; pic_param->transform_fields.bits.frame_level_transform_type = pic->ttfrm;
pic_param->transform_fields.bits.transform_ac_codingset_idx2 = pic->transacfrm2; pic_param->transform_fields.bits.transform_ac_codingset_idx2 =
pic->transacfrm2;
return TRUE; return TRUE;
} }
@ -800,22 +815,28 @@ fill_picture(GstVaapiDecoderVC1 *decoder, GstVaapiPicture *picture)
pic_param->pic_quantizer_fields.value = 0; pic_param->pic_quantizer_fields.value = 0;
pic_param->pic_quantizer_fields.bits.half_qp = frame_hdr->halfqp; pic_param->pic_quantizer_fields.bits.half_qp = frame_hdr->halfqp;
pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = frame_hdr->pquant; pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = frame_hdr->pquant;
pic_param->pic_quantizer_fields.bits.pic_quantizer_type = frame_hdr->pquantizer; pic_param->pic_quantizer_fields.bits.pic_quantizer_type =
frame_hdr->pquantizer;
pic_param->pic_quantizer_fields.bits.dq_frame = vopdquant->dquantfrm; pic_param->pic_quantizer_fields.bits.dq_frame = vopdquant->dquantfrm;
pic_param->pic_quantizer_fields.bits.dq_profile = vopdquant->dqprofile; pic_param->pic_quantizer_fields.bits.dq_profile = vopdquant->dqprofile;
pic_param->pic_quantizer_fields.bits.dq_sb_edge = vopdquant->dqprofile == GST_VC1_DQPROFILE_SINGLE_EDGE ? vopdquant->dqbedge : 0; pic_param->pic_quantizer_fields.bits.dq_sb_edge =
pic_param->pic_quantizer_fields.bits.dq_db_edge = vopdquant->dqprofile == GST_VC1_DQPROFILE_DOUBLE_EDGES ? vopdquant->dqbedge : 0; vopdquant->dqprofile ==
GST_VC1_DQPROFILE_SINGLE_EDGE ? vopdquant->dqbedge : 0;
pic_param->pic_quantizer_fields.bits.dq_db_edge =
vopdquant->dqprofile ==
GST_VC1_DQPROFILE_DOUBLE_EDGES ? vopdquant->dqbedge : 0;
pic_param->pic_quantizer_fields.bits.dq_binary_level = vopdquant->dqbilevel; pic_param->pic_quantizer_fields.bits.dq_binary_level = vopdquant->dqbilevel;
pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = vopdquant->altpquant; pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = vopdquant->altpquant;
pic_param->transform_fields.value = 0; pic_param->transform_fields.value = 0;
pic_param->transform_fields.bits.transform_ac_codingset_idx1 = frame_hdr->transacfrm; pic_param->transform_fields.bits.transform_ac_codingset_idx1 =
pic_param->transform_fields.bits.intra_transform_dc_table = frame_hdr->transdctab; frame_hdr->transacfrm;
pic_param->transform_fields.bits.intra_transform_dc_table =
frame_hdr->transdctab;
if (seq_hdr->profile == GST_VC1_PROFILE_ADVANCED) { if (seq_hdr->profile == GST_VC1_PROFILE_ADVANCED) {
if (!fill_picture_advanced (decoder, picture)) if (!fill_picture_advanced (decoder, picture))
return FALSE; return FALSE;
} } else {
else {
if (!fill_picture_structc (decoder, picture)) if (!fill_picture_structc (decoder, picture))
return FALSE; return FALSE;
} }
@ -846,20 +867,27 @@ fill_picture(GstVaapiDecoderVC1 *decoder, GstVaapiPicture *picture)
switch (picture->type) { switch (picture->type) {
case GST_VAAPI_PICTURE_TYPE_P: case GST_VAAPI_PICTURE_TYPE_P:
bitplanes[0] = pic_param->bitplane_present.flags.bp_direct_mb ? priv->bitplanes->directmb : NULL; bitplanes[0] = pic_param->bitplane_present.flags.bp_direct_mb ?
bitplanes[1] = pic_param->bitplane_present.flags.bp_skip_mb ? priv->bitplanes->skipmb : NULL; priv->bitplanes->directmb : NULL;
bitplanes[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? priv->bitplanes->mvtypemb : NULL; bitplanes[1] = pic_param->bitplane_present.flags.bp_skip_mb ?
priv->bitplanes->skipmb : NULL;
bitplanes[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ?
priv->bitplanes->mvtypemb : NULL;
break; break;
case GST_VAAPI_PICTURE_TYPE_B: case GST_VAAPI_PICTURE_TYPE_B:
bitplanes[0] = pic_param->bitplane_present.flags.bp_direct_mb ? priv->bitplanes->directmb : NULL; bitplanes[0] = pic_param->bitplane_present.flags.bp_direct_mb ?
bitplanes[1] = pic_param->bitplane_present.flags.bp_skip_mb ? priv->bitplanes->skipmb : NULL; priv->bitplanes->directmb : NULL;
bitplanes[1] = pic_param->bitplane_present.flags.bp_skip_mb ?
priv->bitplanes->skipmb : NULL;
bitplanes[2] = NULL; /* XXX: interlaced frame (FORWARD plane) */ bitplanes[2] = NULL; /* XXX: interlaced frame (FORWARD plane) */
break; break;
case GST_VAAPI_PICTURE_TYPE_BI: case GST_VAAPI_PICTURE_TYPE_BI:
case GST_VAAPI_PICTURE_TYPE_I: case GST_VAAPI_PICTURE_TYPE_I:
bitplanes[0] = NULL; /* XXX: interlaced frame (FIELDTX plane) */ bitplanes[0] = NULL; /* XXX: interlaced frame (FIELDTX plane) */
bitplanes[1] = pic_param->bitplane_present.flags.bp_ac_pred ? priv->bitplanes->acpred : NULL; bitplanes[1] = pic_param->bitplane_present.flags.bp_ac_pred ?
bitplanes[2] = pic_param->bitplane_present.flags.bp_overflags ? priv->bitplanes->overflags : NULL; priv->bitplanes->acpred : NULL;
bitplanes[2] = pic_param->bitplane_present.flags.bp_overflags ?
priv->bitplanes->overflags : NULL;
break; break;
default: default:
bitplanes[0] = NULL; bitplanes[0] = NULL;
@ -868,17 +896,16 @@ fill_picture(GstVaapiDecoderVC1 *decoder, GstVaapiPicture *picture)
break; break;
} }
picture->bitplane = GST_VAAPI_BITPLANE_NEW( picture->bitplane = GST_VAAPI_BITPLANE_NEW (decoder,
decoder, (seq_hdr->mb_width * seq_hdr->mb_height + 1) / 2);
(seq_hdr->mb_width * seq_hdr->mb_height + 1) / 2
);
if (!picture->bitplane) if (!picture->bitplane)
return FALSE; return FALSE;
n = 0; n = 0;
for (y = 0; y < seq_hdr->mb_height; y++) for (y = 0; y < seq_hdr->mb_height; y++)
for (x = 0; x < seq_hdr->mb_width; x++, n++) for (x = 0; x < seq_hdr->mb_width; x++, n++)
pack_bitplanes(picture->bitplane, n, bitplanes, x, y, seq_hdr->mb_stride); pack_bitplanes (picture->bitplane, n, bitplanes, x, y,
seq_hdr->mb_stride);
if (n & 1) /* move last nibble to the high order */ if (n & 1) /* move last nibble to the high order */
picture->bitplane->data[n / 2] <<= 4; picture->bitplane->data[n / 2] <<= 4;
} }
@ -920,13 +947,8 @@ decode_frame(GstVaapiDecoderVC1 *decoder, GstVC1BDU *rbdu, GstVC1BDU *ebdu)
GstVaapiPicture *const picture = priv->current_picture; GstVaapiPicture *const picture = priv->current_picture;
memset (frame_hdr, 0, sizeof (*frame_hdr)); memset (frame_hdr, 0, sizeof (*frame_hdr));
result = gst_vc1_parse_frame_header( result = gst_vc1_parse_frame_header (rbdu->data + rbdu->offset,
rbdu->data + rbdu->offset, rbdu->size, frame_hdr, &priv->seq_hdr, priv->bitplanes);
rbdu->size,
frame_hdr,
&priv->seq_hdr,
priv->bitplanes
);
if (result != GST_VC1_PARSER_OK) { if (result != GST_VC1_PARSER_OK) {
GST_ERROR ("failed to parse frame layer"); GST_ERROR ("failed to parse frame layer");
return get_status (result); return get_status (result);
@ -959,8 +981,7 @@ decode_frame(GstVaapiDecoderVC1 *decoder, GstVC1BDU *rbdu, GstVC1BDU *ebdu)
(priv->last_non_b_picture->poc + 1) : priv->next_poc; (priv->last_non_b_picture->poc + 1) : priv->next_poc;
priv->next_poc = picture->poc + 1; priv->next_poc = picture->poc + 1;
gst_vaapi_picture_replace (&priv->last_non_b_picture, picture); gst_vaapi_picture_replace (&priv->last_non_b_picture, picture);
} } else if (!priv->last_non_b_picture)
else if (!priv->last_non_b_picture)
picture->poc = priv->next_poc++; picture->poc = priv->next_poc++;
else { /* B or BI */ else { /* B or BI */
picture->poc = priv->last_non_b_picture->poc++; picture->poc = priv->last_non_b_picture->poc++;
@ -981,12 +1002,8 @@ decode_slice(GstVaapiDecoderVC1 *decoder, GstVC1BDU *rbdu, GstVC1BDU *ebdu)
GstVC1ParserResult result; GstVC1ParserResult result;
memset (&slice_hdr, 0, sizeof (slice_hdr)); memset (&slice_hdr, 0, sizeof (slice_hdr));
result = gst_vc1_parse_slice_header( result = gst_vc1_parse_slice_header (rbdu->data + rbdu->offset,
rbdu->data + rbdu->offset, rbdu->size, &slice_hdr, &priv->seq_hdr);
rbdu->size,
&slice_hdr,
&priv->seq_hdr
);
if (result != GST_VC1_PARSER_OK) { if (result != GST_VC1_PARSER_OK) {
GST_ERROR ("failed to parse slice layer"); GST_ERROR ("failed to parse slice layer");
return get_status (result); return get_status (result);
@ -1022,15 +1039,13 @@ decode_rbdu(GstVaapiDecoderVC1 *decoder, GstVC1BDU *rbdu, GstVC1BDU *ebdu)
if (ebdu->size < 4) { if (ebdu->size < 4) {
memcpy (rbdu_buffer, ebdu->data + ebdu->offset, ebdu->size); memcpy (rbdu_buffer, ebdu->data + ebdu->offset, ebdu->size);
rbdu_buffer_size = ebdu->size; rbdu_buffer_size = ebdu->size;
} } else {
else {
guint8 *const bdu_buffer = ebdu->data + ebdu->offset; guint8 *const bdu_buffer = ebdu->data + ebdu->offset;
for (i = 0, j = 0; i < ebdu->size; i++) { for (i = 0, j = 0; i < ebdu->size; i++) {
if (i >= 2 && i < ebdu->size - 1 && if (i >= 2 && i < ebdu->size - 1 &&
bdu_buffer[i - 1] == 0x00 && bdu_buffer[i - 1] == 0x00 &&
bdu_buffer[i - 2] == 0x00 && bdu_buffer[i - 2] == 0x00 &&
bdu_buffer[i ] == 0x03 && bdu_buffer[i] == 0x03 && bdu_buffer[i + 1] <= 0x03)
bdu_buffer[i + 1] <= 0x03)
i++; i++;
rbdu_buffer[j++] = bdu_buffer[i]; rbdu_buffer[j++] = bdu_buffer[i];
} }
@ -1096,8 +1111,7 @@ decode_buffer(GstVaapiDecoderVC1 *decoder, guchar *buf, guint buf_size)
ebdu.type = GST_VC1_FRAME; ebdu.type = GST_VC1_FRAME;
ebdu.sc_offset = 0; ebdu.sc_offset = 0;
ebdu.offset = 0; ebdu.offset = 0;
} } else {
else {
ebdu.type = buf[3]; ebdu.type = buf[3];
ebdu.sc_offset = 0; ebdu.sc_offset = 0;
ebdu.offset = 4; ebdu.offset = 4;
@ -1111,8 +1125,7 @@ static GstVaapiDecoderStatus
gst_vaapi_decoder_vc1_decode_codec_data (GstVaapiDecoder * base_decoder, gst_vaapi_decoder_vc1_decode_codec_data (GstVaapiDecoder * base_decoder,
const guchar * buf, guint buf_size) const guchar * buf, guint buf_size)
{ {
GstVaapiDecoderVC1 * const decoder = GstVaapiDecoderVC1 *const decoder = GST_VAAPI_DECODER_VC1_CAST (base_decoder);
GST_VAAPI_DECODER_VC1_CAST(base_decoder);
GstVaapiDecoderVC1Private *const priv = &decoder->priv; GstVaapiDecoderVC1Private *const priv = &decoder->priv;
GstVC1SeqHdr *const seq_hdr = &priv->seq_hdr; GstVC1SeqHdr *const seq_hdr = &priv->seq_hdr;
GstVaapiDecoderStatus status; GstVaapiDecoderStatus status;
@ -1173,11 +1186,7 @@ gst_vaapi_decoder_vc1_decode_codec_data(GstVaapiDecoder *base_decoder,
ofs = 0; ofs = 0;
do { do {
result = gst_vc1_identify_next_bdu( result = gst_vc1_identify_next_bdu (buf + ofs, buf_size - ofs, &ebdu);
buf + ofs,
buf_size - ofs,
&ebdu
);
switch (result) { switch (result) {
case GST_VC1_PARSER_NO_BDU_END: case GST_VC1_PARSER_NO_BDU_END:
@ -1207,8 +1216,8 @@ ensure_decoder(GstVaapiDecoderVC1 *decoder)
if (!priv->is_opened) if (!priv->is_opened)
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC; return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC;
status = gst_vaapi_decoder_decode_codec_data( status =
GST_VAAPI_DECODER_CAST(decoder)); gst_vaapi_decoder_decode_codec_data (GST_VAAPI_DECODER_CAST (decoder));
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
return status; return status;
} }
@ -1226,8 +1235,7 @@ static GstVaapiDecoderStatus
gst_vaapi_decoder_vc1_parse (GstVaapiDecoder * base_decoder, gst_vaapi_decoder_vc1_parse (GstVaapiDecoder * base_decoder,
GstAdapter * adapter, gboolean at_eos, GstVaapiDecoderUnit * unit) GstAdapter * adapter, gboolean at_eos, GstVaapiDecoderUnit * unit)
{ {
GstVaapiDecoderVC1 * const decoder = GstVaapiDecoderVC1 *const decoder = GST_VAAPI_DECODER_VC1_CAST (base_decoder);
GST_VAAPI_DECODER_VC1_CAST(base_decoder);
GstVaapiDecoderVC1Private *const priv = &decoder->priv; GstVaapiDecoderVC1Private *const priv = &decoder->priv;
GstVaapiDecoderStatus status; GstVaapiDecoderStatus status;
guint8 bdu_type; guint8 bdu_type;
@ -1246,8 +1254,7 @@ gst_vaapi_decoder_vc1_parse(GstVaapiDecoder *base_decoder,
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA; return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
buf_size = size; buf_size = size;
bdu_type = GST_VC1_FRAME; bdu_type = GST_VC1_FRAME;
} } else {
else {
if (size < 4) if (size < 4)
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA; return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
@ -1297,8 +1304,7 @@ static GstVaapiDecoderStatus
gst_vaapi_decoder_vc1_decode (GstVaapiDecoder * base_decoder, gst_vaapi_decoder_vc1_decode (GstVaapiDecoder * base_decoder,
GstVaapiDecoderUnit * unit) GstVaapiDecoderUnit * unit)
{ {
GstVaapiDecoderVC1 * const decoder = GstVaapiDecoderVC1 *const decoder = GST_VAAPI_DECODER_VC1_CAST (base_decoder);
GST_VAAPI_DECODER_VC1_CAST(base_decoder);
GstVaapiDecoderStatus status; GstVaapiDecoderStatus status;
GstBuffer *const buffer = GstBuffer *const buffer =
GST_VAAPI_DECODER_CODEC_FRAME (decoder)->input_buffer; GST_VAAPI_DECODER_CODEC_FRAME (decoder)->input_buffer;
@ -1324,8 +1330,7 @@ static GstVaapiDecoderStatus
gst_vaapi_decoder_vc1_start_frame (GstVaapiDecoder * base_decoder, gst_vaapi_decoder_vc1_start_frame (GstVaapiDecoder * base_decoder,
GstVaapiDecoderUnit * unit) GstVaapiDecoderUnit * unit)
{ {
GstVaapiDecoderVC1 * const decoder = GstVaapiDecoderVC1 *const decoder = GST_VAAPI_DECODER_VC1_CAST (base_decoder);
GST_VAAPI_DECODER_VC1_CAST(base_decoder);
GstVaapiDecoderVC1Private *const priv = &decoder->priv; GstVaapiDecoderVC1Private *const priv = &decoder->priv;
GstVaapiDecoderStatus status; GstVaapiDecoderStatus status;
GstVaapiPicture *picture; GstVaapiPicture *picture;
@ -1374,8 +1379,7 @@ gst_vaapi_decoder_vc1_start_frame(GstVaapiDecoder *base_decoder,
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
gst_vaapi_decoder_vc1_end_frame (GstVaapiDecoder * base_decoder) gst_vaapi_decoder_vc1_end_frame (GstVaapiDecoder * base_decoder)
{ {
GstVaapiDecoderVC1 * const decoder = GstVaapiDecoderVC1 *const decoder = GST_VAAPI_DECODER_VC1_CAST (base_decoder);
GST_VAAPI_DECODER_VC1_CAST(base_decoder);
return decode_current_picture (decoder); return decode_current_picture (decoder);
} }
@ -1383,8 +1387,7 @@ gst_vaapi_decoder_vc1_end_frame(GstVaapiDecoder *base_decoder)
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
gst_vaapi_decoder_vc1_flush (GstVaapiDecoder * base_decoder) gst_vaapi_decoder_vc1_flush (GstVaapiDecoder * base_decoder)
{ {
GstVaapiDecoderVC1 * const decoder = GstVaapiDecoderVC1 *const decoder = GST_VAAPI_DECODER_VC1_CAST (base_decoder);
GST_VAAPI_DECODER_VC1_CAST(base_decoder);
GstVaapiDecoderVC1Private *const priv = &decoder->priv; GstVaapiDecoderVC1Private *const priv = &decoder->priv;
gst_vaapi_dpb_flush (priv->dpb); gst_vaapi_dpb_flush (priv->dpb);
@ -1409,8 +1412,7 @@ gst_vaapi_decoder_vc1_class_init(GstVaapiDecoderVC1Class *klass)
decoder_class->end_frame = gst_vaapi_decoder_vc1_end_frame; decoder_class->end_frame = gst_vaapi_decoder_vc1_end_frame;
decoder_class->flush = gst_vaapi_decoder_vc1_flush; decoder_class->flush = gst_vaapi_decoder_vc1_flush;
decoder_class->decode_codec_data = decoder_class->decode_codec_data = gst_vaapi_decoder_vc1_decode_codec_data;
gst_vaapi_decoder_vc1_decode_codec_data;
} }
static inline const GstVaapiDecoderClass * static inline const GstVaapiDecoderClass *

View File

@ -47,8 +47,7 @@
static gboolean static gboolean
_gst_vaapi_image_map (GstVaapiImage * image, GstVaapiImageRaw * raw_image); _gst_vaapi_image_map (GstVaapiImage * image, GstVaapiImageRaw * raw_image);
static gboolean static gboolean _gst_vaapi_image_unmap (GstVaapiImage * image);
_gst_vaapi_image_unmap(GstVaapiImage *image);
static gboolean static gboolean
_gst_vaapi_image_set_image (GstVaapiImage * image, const VAImage * va_image); _gst_vaapi_image_set_image (GstVaapiImage * image, const VAImage * va_image);
@ -141,13 +140,9 @@ _gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format)
return FALSE; return FALSE;
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaCreateImage( status = vaCreateImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_DISPLAY_VADISPLAY(display),
(VAImageFormat *) va_format, (VAImageFormat *) va_format,
image->width, image->width, image->height, &image->internal_image);
image->height,
&image->internal_image
);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (status != VA_STATUS_SUCCESS || if (status != VA_STATUS_SUCCESS ||
image->internal_image.format.fourcc != va_format->fourcc) image->internal_image.format.fourcc != va_format->fourcc)
@ -220,17 +215,14 @@ gst_vaapi_image_init(GstVaapiImage *image)
static void static void
gst_vaapi_image_class_init (GstVaapiImageClass * klass) gst_vaapi_image_class_init (GstVaapiImageClass * klass)
{ {
GstVaapiObjectClass * const object_class = GstVaapiObjectClass *const object_class = GST_VAAPI_OBJECT_CLASS (klass);
GST_VAAPI_OBJECT_CLASS(klass);
object_class->init = (GstVaapiObjectInitFunc) gst_vaapi_image_init; object_class->init = (GstVaapiObjectInitFunc) gst_vaapi_image_init;
} }
#define gst_vaapi_image_finalize gst_vaapi_image_destroy #define gst_vaapi_image_finalize gst_vaapi_image_destroy
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE( GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiImage,
GstVaapiImage, gst_vaapi_image, gst_vaapi_image_class_init (&g_class))
gst_vaapi_image,
gst_vaapi_image_class_init(&g_class))
/** /**
* gst_vaapi_image_new: * gst_vaapi_image_new:
@ -244,13 +236,8 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
* *
* Return value: the newly allocated #GstVaapiImage object * Return value: the newly allocated #GstVaapiImage object
*/ */
GstVaapiImage * GstVaapiImage *gst_vaapi_image_new (GstVaapiDisplay * display,
gst_vaapi_image_new( GstVideoFormat format, guint width, guint height)
GstVaapiDisplay *display,
GstVideoFormat format,
guint width,
guint height
)
{ {
GstVaapiImage *image; GstVaapiImage *image;
@ -471,7 +458,8 @@ gst_vaapi_image_get_height(GstVaapiImage *image)
* Retrieves the dimensions of a #GstVaapiImage. * Retrieves the dimensions of a #GstVaapiImage.
*/ */
void void
gst_vaapi_image_get_size(GstVaapiImage *image, guint *pwidth, guint *pheight) gst_vaapi_image_get_size (GstVaapiImage * image, guint * pwidth,
guint * pheight)
{ {
g_return_if_fail (image != NULL); g_return_if_fail (image != NULL);
@ -554,11 +542,8 @@ _gst_vaapi_image_map(GstVaapiImage *image, GstVaapiImageRaw *raw_image)
return FALSE; return FALSE;
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaMapBuffer( status = vaMapBuffer (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_DISPLAY_VADISPLAY(display), image->image.buf, (void **) &image->image_data);
image->image.buf,
(void **)&image->image_data
);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaMapBuffer()")) if (!vaapi_check_status (status, "vaMapBuffer()"))
return FALSE; return FALSE;
@ -610,10 +595,8 @@ _gst_vaapi_image_unmap(GstVaapiImage *image)
return FALSE; return FALSE;
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaUnmapBuffer( status = vaUnmapBuffer (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_DISPLAY_VADISPLAY(display), image->image.buf);
image->image.buf
);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaUnmapBuffer()")) if (!vaapi_check_status (status, "vaUnmapBuffer()"))
return FALSE; return FALSE;
@ -717,14 +700,9 @@ init_image_from_buffer(GstVaapiImageRaw *raw_image, GstBuffer *buffer)
/* Copy N lines of an image */ /* Copy N lines of an image */
static inline void static inline void
memcpy_pic( memcpy_pic (guchar * dst,
guchar *dst,
guint dst_stride, guint dst_stride,
const guchar *src, const guchar * src, guint src_stride, guint len, guint height)
guint src_stride,
guint len,
guint height
)
{ {
guint i; guint i;
@ -737,11 +715,8 @@ memcpy_pic(
/* Copy NV12 images */ /* Copy NV12 images */
static void static void
copy_image_NV12( copy_image_NV12 (GstVaapiImageRaw * dst_image,
GstVaapiImageRaw *dst_image, GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
GstVaapiImageRaw *src_image,
const GstVaapiRectangle *rect
)
{ {
guchar *dst, *src; guchar *dst, *src;
guint dst_stride, src_stride; guint dst_stride, src_stride;
@ -763,11 +738,8 @@ copy_image_NV12(
/* Copy YV12 images */ /* Copy YV12 images */
static void static void
copy_image_YV12( copy_image_YV12 (GstVaapiImageRaw * dst_image,
GstVaapiImageRaw *dst_image, GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
GstVaapiImageRaw *src_image,
const GstVaapiRectangle *rect
)
{ {
guchar *dst, *src; guchar *dst, *src;
guint dst_stride, src_stride; guint dst_stride, src_stride;
@ -796,11 +768,8 @@ copy_image_YV12(
/* Copy YUY2 images */ /* Copy YUY2 images */
static void static void
copy_image_YUY2( copy_image_YUY2 (GstVaapiImageRaw * dst_image,
GstVaapiImageRaw *dst_image, GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
GstVaapiImageRaw *src_image,
const GstVaapiRectangle *rect
)
{ {
guchar *dst, *src; guchar *dst, *src;
guint dst_stride, src_stride; guint dst_stride, src_stride;
@ -815,11 +784,8 @@ copy_image_YUY2(
/* Copy RGBA images */ /* Copy RGBA images */
static void static void
copy_image_RGBA( copy_image_RGBA (GstVaapiImageRaw * dst_image,
GstVaapiImageRaw *dst_image, GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
GstVaapiImageRaw *src_image,
const GstVaapiRectangle *rect
)
{ {
guchar *dst, *src; guchar *dst, *src;
guint dst_stride, src_stride; guint dst_stride, src_stride;
@ -832,11 +798,8 @@ copy_image_RGBA(
} }
static gboolean static gboolean
copy_image( copy_image (GstVaapiImageRaw * dst_image,
GstVaapiImageRaw *dst_image, GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
GstVaapiImageRaw *src_image,
const GstVaapiRectangle *rect
)
{ {
GstVaapiRectangle default_rect; GstVaapiRectangle default_rect;
@ -851,8 +814,7 @@ copy_image(
rect->y >= src_image->height || rect->y >= src_image->height ||
rect->y + rect->height > src_image->height) rect->y + rect->height > src_image->height)
return FALSE; return FALSE;
} } else {
else {
default_rect.x = 0; default_rect.x = 0;
default_rect.y = 0; default_rect.y = 0;
default_rect.width = src_image->width; default_rect.width = src_image->width;
@ -898,11 +860,8 @@ copy_image(
* Return value: %TRUE on success * Return value: %TRUE on success
*/ */
gboolean gboolean
gst_vaapi_image_get_buffer( gst_vaapi_image_get_buffer (GstVaapiImage * image,
GstVaapiImage *image, GstBuffer * buffer, GstVaapiRectangle * rect)
GstBuffer *buffer,
GstVaapiRectangle *rect
)
{ {
GstVaapiImageRaw dst_image, src_image; GstVaapiImageRaw dst_image, src_image;
gboolean success; gboolean success;
@ -941,11 +900,8 @@ gst_vaapi_image_get_buffer(
* Return value: %TRUE on success * Return value: %TRUE on success
*/ */
gboolean gboolean
gst_vaapi_image_get_raw( gst_vaapi_image_get_raw (GstVaapiImage * image,
GstVaapiImage *image, GstVaapiImageRaw * dst_image, GstVaapiRectangle * rect)
GstVaapiImageRaw *dst_image,
GstVaapiRectangle *rect
)
{ {
GstVaapiImageRaw src_image; GstVaapiImageRaw src_image;
gboolean success; gboolean success;
@ -976,11 +932,8 @@ gst_vaapi_image_get_raw(
* Return value: %TRUE on success * Return value: %TRUE on success
*/ */
gboolean gboolean
gst_vaapi_image_update_from_buffer( gst_vaapi_image_update_from_buffer (GstVaapiImage * image,
GstVaapiImage *image, GstBuffer * buffer, GstVaapiRectangle * rect)
GstBuffer *buffer,
GstVaapiRectangle *rect
)
{ {
GstVaapiImageRaw dst_image, src_image; GstVaapiImageRaw dst_image, src_image;
gboolean success; gboolean success;
@ -1020,11 +973,8 @@ gst_vaapi_image_update_from_buffer(
* Return value: %TRUE on success * Return value: %TRUE on success
*/ */
gboolean gboolean
gst_vaapi_image_update_from_raw( gst_vaapi_image_update_from_raw (GstVaapiImage * image,
GstVaapiImage *image, GstVaapiImageRaw * src_image, GstVaapiRectangle * rect)
GstVaapiImageRaw *src_image,
GstVaapiRectangle *rect
)
{ {
GstVaapiImageRaw dst_image; GstVaapiImageRaw dst_image;
gboolean success; gboolean success;

View File

@ -212,7 +212,8 @@ gst_vaapi_pixmap_get_height(GstVaapiPixmap *pixmap)
* Retrieves the dimensions of a #GstVaapiPixmap. * Retrieves the dimensions of a #GstVaapiPixmap.
*/ */
void void
gst_vaapi_pixmap_get_size(GstVaapiPixmap *pixmap, guint *width, guint *height) gst_vaapi_pixmap_get_size (GstVaapiPixmap * pixmap, guint * width,
guint * height)
{ {
g_return_if_fail (pixmap != NULL); g_return_if_fail (pixmap != NULL);
@ -240,8 +241,8 @@ gst_vaapi_pixmap_get_size(GstVaapiPixmap *pixmap, guint *width, guint *height)
* Return value: %TRUE on success * Return value: %TRUE on success
*/ */
gboolean gboolean
gst_vaapi_pixmap_put_surface(GstVaapiPixmap *pixmap, GstVaapiSurface *surface, gst_vaapi_pixmap_put_surface (GstVaapiPixmap * pixmap,
const GstVaapiRectangle *crop_rect, guint flags) GstVaapiSurface * surface, const GstVaapiRectangle * crop_rect, guint flags)
{ {
GstVaapiRectangle src_rect; GstVaapiRectangle src_rect;

View File

@ -40,11 +40,13 @@
typedef struct _GstVaapiPixmapX11Class GstVaapiPixmapX11Class; typedef struct _GstVaapiPixmapX11Class GstVaapiPixmapX11Class;
struct _GstVaapiPixmapX11 { struct _GstVaapiPixmapX11
{
GstVaapiPixmap parent_instance; GstVaapiPixmap parent_instance;
}; };
struct _GstVaapiPixmapX11Class { struct _GstVaapiPixmapX11Class
{
GstVaapiPixmapClass parent_class; GstVaapiPixmapClass parent_class;
}; };
@ -64,8 +66,9 @@ gst_vaapi_pixmap_x11_create_from_xid(GstVaapiPixmap *pixmap, Pixmap xid)
if (!success) if (!success)
return FALSE; return FALSE;
pixmap->format = gst_vaapi_display_x11_get_pixmap_format( pixmap->format =
GST_VAAPI_OBJECT_DISPLAY_X11(pixmap), depth); gst_vaapi_display_x11_get_pixmap_format (GST_VAAPI_OBJECT_DISPLAY_X11
(pixmap), depth);
if (pixmap->format == GST_VIDEO_FORMAT_UNKNOWN) if (pixmap->format == GST_VIDEO_FORMAT_UNKNOWN)
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -126,8 +129,7 @@ gst_vaapi_pixmap_x11_render(GstVaapiPixmap *pixmap, GstVaapiSurface *surface,
return FALSE; return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap); GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
status = vaPutSurface( status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (pixmap),
GST_VAAPI_OBJECT_VADISPLAY(pixmap),
surface_id, surface_id,
GST_VAAPI_OBJECT_ID (pixmap), GST_VAAPI_OBJECT_ID (pixmap),
crop_rect->x, crop_rect->y, crop_rect->x, crop_rect->y,
@ -135,8 +137,7 @@ gst_vaapi_pixmap_x11_render(GstVaapiPixmap *pixmap, GstVaapiSurface *surface,
0, 0, 0, 0,
GST_VAAPI_PIXMAP_WIDTH (pixmap), GST_VAAPI_PIXMAP_WIDTH (pixmap),
GST_VAAPI_PIXMAP_HEIGHT (pixmap), GST_VAAPI_PIXMAP_HEIGHT (pixmap),
NULL, 0, NULL, 0, from_GstVaapiSurfaceRenderFlags (flags)
from_GstVaapiSurfaceRenderFlags(flags)
); );
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap); GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
if (!vaapi_check_status (status, "vaPutSurface() [pixmap]")) if (!vaapi_check_status (status, "vaPutSurface() [pixmap]"))
@ -147,10 +148,8 @@ gst_vaapi_pixmap_x11_render(GstVaapiPixmap *pixmap, GstVaapiSurface *surface,
void void
gst_vaapi_pixmap_x11_class_init (GstVaapiPixmapX11Class * klass) gst_vaapi_pixmap_x11_class_init (GstVaapiPixmapX11Class * klass)
{ {
GstVaapiObjectClass * const object_class = GstVaapiObjectClass *const object_class = GST_VAAPI_OBJECT_CLASS (klass);
GST_VAAPI_OBJECT_CLASS(klass); GstVaapiPixmapClass *const pixmap_class = GST_VAAPI_PIXMAP_CLASS (klass);
GstVaapiPixmapClass * const pixmap_class =
GST_VAAPI_PIXMAP_CLASS(klass);
object_class->finalize = (GstVaapiObjectFinalizeFunc) object_class->finalize = (GstVaapiObjectFinalizeFunc)
gst_vaapi_pixmap_x11_destroy; gst_vaapi_pixmap_x11_destroy;
@ -162,10 +161,8 @@ gst_vaapi_pixmap_x11_class_init(GstVaapiPixmapX11Class *klass)
#define gst_vaapi_pixmap_x11_finalize \ #define gst_vaapi_pixmap_x11_finalize \
gst_vaapi_pixmap_x11_destroy gst_vaapi_pixmap_x11_destroy
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE( GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiPixmapX11,
GstVaapiPixmapX11, gst_vaapi_pixmap_x11, gst_vaapi_pixmap_x11_class_init (&g_class))
gst_vaapi_pixmap_x11,
gst_vaapi_pixmap_x11_class_init(&g_class))
/** /**
* gst_vaapi_pixmap_x11_new: * gst_vaapi_pixmap_x11_new:
@ -179,17 +176,17 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
* *
* Return value: the newly allocated #GstVaapiPixmap object * Return value: the newly allocated #GstVaapiPixmap object
*/ */
GstVaapiPixmap * GstVaapiPixmap *gst_vaapi_pixmap_x11_new (GstVaapiDisplay * display,
gst_vaapi_pixmap_x11_new(GstVaapiDisplay *display, GstVideoFormat format, GstVideoFormat format, guint width, guint height)
guint width, guint height)
{ {
GST_DEBUG ("new pixmap, format %s, size %ux%u", GST_DEBUG ("new pixmap, format %s, size %ux%u",
gst_vaapi_video_format_to_string (format), width, height); gst_vaapi_video_format_to_string (format), width, height);
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL); g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
return gst_vaapi_pixmap_new(GST_VAAPI_PIXMAP_CLASS( return
gst_vaapi_pixmap_x11_class()), display, format, width, height); gst_vaapi_pixmap_new (GST_VAAPI_PIXMAP_CLASS (gst_vaapi_pixmap_x11_class
()), display, format, width, height);
} }
/** /**
@ -212,8 +209,9 @@ gst_vaapi_pixmap_x11_new_with_xid(GstVaapiDisplay *display, Pixmap xid)
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL); g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
g_return_val_if_fail (xid != None, NULL); g_return_val_if_fail (xid != None, NULL);
return gst_vaapi_pixmap_new_from_native(GST_VAAPI_PIXMAP_CLASS( return
gst_vaapi_pixmap_x11_class()), display, GSIZE_TO_POINTER(xid)); gst_vaapi_pixmap_new_from_native (GST_VAAPI_PIXMAP_CLASS
(gst_vaapi_pixmap_x11_class ()), display, GSIZE_TO_POINTER (xid));
} }
/** /**

View File

@ -38,19 +38,22 @@ typedef struct _GstVaapiCodecMap GstVaapiCodecMap;
typedef struct _GstVaapiProfileMap GstVaapiProfileMap; typedef struct _GstVaapiProfileMap GstVaapiProfileMap;
typedef struct _GstVaapiEntrypointMap GstVaapiEntrypointMap; typedef struct _GstVaapiEntrypointMap GstVaapiEntrypointMap;
struct _GstVaapiCodecMap { struct _GstVaapiCodecMap
{
GstVaapiCodec codec; GstVaapiCodec codec;
const gchar *name; const gchar *name;
}; };
struct _GstVaapiProfileMap { struct _GstVaapiProfileMap
{
GstVaapiProfile profile; GstVaapiProfile profile;
VAProfile va_profile; VAProfile va_profile;
const char *media_str; const char *media_str;
const gchar *profile_str; const gchar *profile_str;
}; };
struct _GstVaapiEntrypointMap { struct _GstVaapiEntrypointMap
{
GstVaapiEntrypoint entrypoint; GstVaapiEntrypoint entrypoint;
VAEntrypoint va_entrypoint; VAEntrypoint va_entrypoint;
}; };
@ -74,85 +77,63 @@ static const GstVaapiCodecMap gst_vaapi_codecs[] = {
/* Profiles */ /* Profiles */
static const GstVaapiProfileMap gst_vaapi_profiles[] = { static const GstVaapiProfileMap gst_vaapi_profiles[] = {
{GST_VAAPI_PROFILE_MPEG2_SIMPLE, VAProfileMPEG2Simple, {GST_VAAPI_PROFILE_MPEG2_SIMPLE, VAProfileMPEG2Simple,
"video/mpeg, mpegversion=2", "simple" "video/mpeg, mpegversion=2", "simple"},
},
{GST_VAAPI_PROFILE_MPEG2_MAIN, VAProfileMPEG2Main, {GST_VAAPI_PROFILE_MPEG2_MAIN, VAProfileMPEG2Main,
"video/mpeg, mpegversion=2", "main" "video/mpeg, mpegversion=2", "main"},
},
{GST_VAAPI_PROFILE_MPEG4_SIMPLE, VAProfileMPEG4Simple, {GST_VAAPI_PROFILE_MPEG4_SIMPLE, VAProfileMPEG4Simple,
"video/mpeg, mpegversion=4", "simple" "video/mpeg, mpegversion=4", "simple"},
},
{GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple, {GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/mpeg, mpegversion=4", "advanced-simple" "video/mpeg, mpegversion=4", "advanced-simple"},
},
{GST_VAAPI_PROFILE_MPEG4_MAIN, VAProfileMPEG4Main, {GST_VAAPI_PROFILE_MPEG4_MAIN, VAProfileMPEG4Main,
"video/mpeg, mpegversion=4", "main" "video/mpeg, mpegversion=4", "main"},
},
{GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple, {GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/x-divx, divxversion=5", "advanced-simple" "video/x-divx, divxversion=5", "advanced-simple"},
},
{GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple, {GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/x-xvid", "advanced-simple" "video/x-xvid", "advanced-simple"},
},
#if VA_CHECK_VERSION(0,30,0) #if VA_CHECK_VERSION(0,30,0)
{GST_VAAPI_PROFILE_H263_BASELINE, VAProfileH263Baseline, {GST_VAAPI_PROFILE_H263_BASELINE, VAProfileH263Baseline,
"video/x-h263, variant=itu, h263version=h263", "baseline" "video/x-h263, variant=itu, h263version=h263", "baseline"},
},
#endif #endif
{GST_VAAPI_PROFILE_H264_BASELINE, VAProfileH264Baseline, {GST_VAAPI_PROFILE_H264_BASELINE, VAProfileH264Baseline,
"video/x-h264", "baseline" "video/x-h264", "baseline"},
},
#if VA_CHECK_VERSION(0,31,1) #if VA_CHECK_VERSION(0,31,1)
{GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE, {GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE,
VAProfileH264ConstrainedBaseline, VAProfileH264ConstrainedBaseline,
"video/x-h264", "constrained-baseline" "video/x-h264", "constrained-baseline"},
},
#endif #endif
{GST_VAAPI_PROFILE_H264_MAIN, VAProfileH264Main, {GST_VAAPI_PROFILE_H264_MAIN, VAProfileH264Main,
"video/x-h264", "main" "video/x-h264", "main"},
},
{GST_VAAPI_PROFILE_H264_HIGH, VAProfileH264High, {GST_VAAPI_PROFILE_H264_HIGH, VAProfileH264High,
"video/x-h264", "high" "video/x-h264", "high"},
},
#if VA_CHECK_VERSION(0,35,2) #if VA_CHECK_VERSION(0,35,2)
{GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH, VAProfileH264MultiviewHigh, {GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH, VAProfileH264MultiviewHigh,
"video/x-h264", "multiview-high" "video/x-h264", "multiview-high"},
},
{GST_VAAPI_PROFILE_H264_STEREO_HIGH, VAProfileH264StereoHigh, {GST_VAAPI_PROFILE_H264_STEREO_HIGH, VAProfileH264StereoHigh,
"video/x-h264", "stereo-high" "video/x-h264", "stereo-high"},
},
#endif #endif
{GST_VAAPI_PROFILE_VC1_SIMPLE, VAProfileVC1Simple, {GST_VAAPI_PROFILE_VC1_SIMPLE, VAProfileVC1Simple,
"video/x-wmv, wmvversion=3", "simple" "video/x-wmv, wmvversion=3", "simple"},
},
{GST_VAAPI_PROFILE_VC1_MAIN, VAProfileVC1Main, {GST_VAAPI_PROFILE_VC1_MAIN, VAProfileVC1Main,
"video/x-wmv, wmvversion=3", "main" "video/x-wmv, wmvversion=3", "main"},
},
{GST_VAAPI_PROFILE_VC1_ADVANCED, VAProfileVC1Advanced, {GST_VAAPI_PROFILE_VC1_ADVANCED, VAProfileVC1Advanced,
"video/x-wmv, wmvversion=3, format=(string)WVC1", "advanced" "video/x-wmv, wmvversion=3, format=(string)WVC1", "advanced"},
},
#if VA_CHECK_VERSION(0,32,0) #if VA_CHECK_VERSION(0,32,0)
{GST_VAAPI_PROFILE_JPEG_BASELINE, VAProfileJPEGBaseline, {GST_VAAPI_PROFILE_JPEG_BASELINE, VAProfileJPEGBaseline,
"image/jpeg", NULL "image/jpeg", NULL},
},
#endif #endif
#if VA_CHECK_VERSION(0,35,0) #if VA_CHECK_VERSION(0,35,0)
{GST_VAAPI_PROFILE_VP8, VAProfileVP8Version0_3, {GST_VAAPI_PROFILE_VP8, VAProfileVP8Version0_3,
"video/x-vp8", NULL "video/x-vp8", NULL},
},
#endif #endif
#if VA_CHECK_VERSION(0,37,0) #if VA_CHECK_VERSION(0,37,0)
{GST_VAAPI_PROFILE_H265_MAIN, VAProfileHEVCMain, {GST_VAAPI_PROFILE_H265_MAIN, VAProfileHEVCMain,
"video/x-h265", "main" "video/x-h265", "main"},
},
{GST_VAAPI_PROFILE_H265_MAIN10, VAProfileHEVCMain10, {GST_VAAPI_PROFILE_H265_MAIN10, VAProfileHEVCMain10,
"video/x-h265", "main-10" "video/x-h265", "main-10"},
},
#endif #endif
#if VA_CHECK_VERSION(0,38,0) #if VA_CHECK_VERSION(0,38,0)
{GST_VAAPI_PROFILE_VP9, VAProfileVP9Profile0, {GST_VAAPI_PROFILE_VP9, VAProfileVP9Profile0,
"video/x-vp9", NULL "video/x-vp9", NULL},
},
#endif #endif
{0,} {0,}
}; };
@ -295,13 +276,18 @@ gst_vaapi_profile_from_codec_data_h264(GstBuffer *buffer)
return 0; return 0;
switch (buf[1]) { /* AVCProfileIndication */ switch (buf[1]) { /* AVCProfileIndication */
case 66: return ((buf[2] & 0x40) ? case 66:
return ((buf[2] & 0x40) ?
GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE : GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE :
GST_VAAPI_PROFILE_H264_BASELINE); GST_VAAPI_PROFILE_H264_BASELINE);
case 77: return GST_VAAPI_PROFILE_H264_MAIN; case 77:
case 100: return GST_VAAPI_PROFILE_H264_HIGH; return GST_VAAPI_PROFILE_H264_MAIN;
case 118: return GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH; case 100:
case 128: return GST_VAAPI_PROFILE_H264_STEREO_HIGH; return GST_VAAPI_PROFILE_H264_HIGH;
case 118:
return GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH;
case 128:
return GST_VAAPI_PROFILE_H264_STEREO_HIGH;
} }
return 0; return 0;
@ -323,9 +309,12 @@ gst_vaapi_profile_from_codec_data_h265(GstBuffer *buffer)
return 0; return 0;
switch (buf[1] & 0x1f) { /* HEVCProfileIndication */ switch (buf[1] & 0x1f) { /* HEVCProfileIndication */
case 1: return GST_VAAPI_PROFILE_H265_MAIN; case 1:
case 2: return GST_VAAPI_PROFILE_H265_MAIN10; return GST_VAAPI_PROFILE_H265_MAIN;
case 3: return GST_VAAPI_PROFILE_H265_MAIN_STILL_PICTURE; case 2:
return GST_VAAPI_PROFILE_H265_MAIN10;
case 3:
return GST_VAAPI_PROFILE_H265_MAIN_STILL_PICTURE;
} }
return 0; return 0;
} }
@ -405,13 +394,11 @@ gst_vaapi_profile_from_caps(const GstCaps *caps)
profile = best_profile; profile = best_profile;
} }
if (!profile) { if (!profile) {
profile = gst_vaapi_profile_from_codec_data( profile =
gst_vaapi_profile_get_codec(m->profile), gst_vaapi_profile_from_codec_data (gst_vaapi_profile_get_codec
codec_data (m->profile), codec_data);
); if (!profile && WORKAROUND_QTDEMUX_NO_H263_PROFILES
if (!profile && && strncmp (name, "video/x-h263", namelen) == 0) {
WORKAROUND_QTDEMUX_NO_H263_PROFILES &&
strncmp(name, "video/x-h263", namelen) == 0) {
/* HACK: qtdemux does not report profiles for h263 */ /* HACK: qtdemux does not report profiles for h263 */
profile = m->profile; profile = m->profile;
} }
@ -464,11 +451,7 @@ gst_vaapi_profile_get_caps(GstVaapiProfile profile)
caps = gst_caps_from_string (m->media_str); caps = gst_caps_from_string (m->media_str);
if (!caps) if (!caps)
continue; continue;
gst_caps_set_simple( gst_caps_set_simple (caps, "profile", G_TYPE_STRING, m->profile_str, NULL);
caps,
"profile", G_TYPE_STRING, m->profile_str,
NULL
);
out_caps = gst_caps_merge (out_caps, caps); out_caps = gst_caps_merge (out_caps, caps);
} }
return out_caps; return out_caps;

View File

@ -45,7 +45,8 @@ typedef struct _GstVaapiSubpictureClass GstVaapiSubpictureClass;
* *
* A VA subpicture wrapper * A VA subpicture wrapper
*/ */
struct _GstVaapiSubpicture { struct _GstVaapiSubpicture
{
/*< private > */ /*< private > */
GstVaapiObject parent_instance; GstVaapiObject parent_instance;
@ -59,7 +60,8 @@ struct _GstVaapiSubpicture {
* *
* A VA subpicture wrapper class * A VA subpicture wrapper class
*/ */
struct _GstVaapiSubpictureClass { struct _GstVaapiSubpictureClass
{
/*< private > */ /*< private > */
GstVaapiObjectClass parent_class; GstVaapiObjectClass parent_class;
}; };
@ -78,10 +80,8 @@ gst_vaapi_subpicture_destroy(GstVaapiSubpicture *subpicture)
if (subpicture_id != VA_INVALID_ID) { if (subpicture_id != VA_INVALID_ID) {
if (display) { if (display) {
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaDestroySubpicture( status = vaDestroySubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_DISPLAY_VADISPLAY(display), subpicture_id);
subpicture_id
);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaDestroySubpicture()")) if (!vaapi_check_status (status, "vaDestroySubpicture()"))
g_warning ("failed to destroy subpicture %" GST_VAAPI_ID_FORMAT, g_warning ("failed to destroy subpicture %" GST_VAAPI_ID_FORMAT,
@ -101,11 +101,8 @@ gst_vaapi_subpicture_create(GstVaapiSubpicture *subpicture,
VAStatus status; VAStatus status;
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaCreateSubpicture( status = vaCreateSubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_DISPLAY_VADISPLAY(display), GST_VAAPI_OBJECT_ID (image), &subpicture_id);
GST_VAAPI_OBJECT_ID(image),
&subpicture_id
);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaCreateSubpicture()")) if (!vaapi_check_status (status, "vaCreateSubpicture()"))
return FALSE; return FALSE;
@ -130,8 +127,8 @@ GST_VAAPI_OBJECT_DEFINE_CLASS(GstVaapiSubpicture, gst_vaapi_subpicture)
* *
* Return value: the newly allocated #GstVaapiSubpicture object * Return value: the newly allocated #GstVaapiSubpicture object
*/ */
GstVaapiSubpicture * GstVaapiSubpicture *gst_vaapi_subpicture_new (GstVaapiImage * image,
gst_vaapi_subpicture_new(GstVaapiImage *image, guint flags) guint flags)
{ {
GstVaapiSubpicture *subpicture; GstVaapiSubpicture *subpicture;
GstVaapiDisplay *display; GstVaapiDisplay *display;
@ -177,10 +174,8 @@ error:
* Return value: the newly allocated #GstVaapiSubpicture object * Return value: the newly allocated #GstVaapiSubpicture object
*/ */
GstVaapiSubpicture * GstVaapiSubpicture *
gst_vaapi_subpicture_new_from_overlay_rectangle( gst_vaapi_subpicture_new_from_overlay_rectangle (GstVaapiDisplay * display,
GstVaapiDisplay *display, GstVideoOverlayRectangle * rect)
GstVideoOverlayRectangle *rect
)
{ {
GstVaapiSubpicture *subpicture; GstVaapiSubpicture *subpicture;
GstVideoFormat format; GstVideoFormat format;
@ -205,8 +200,10 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
if (!gst_vaapi_display_has_subpicture_format (display, format, &hw_flags)) if (!gst_vaapi_display_has_subpicture_format (display, format, &hw_flags))
return NULL; return NULL;
flags = hw_flags & from_GstVideoOverlayFormatFlags( flags =
gst_video_overlay_rectangle_get_flags(rect)); hw_flags &
from_GstVideoOverlayFormatFlags (gst_video_overlay_rectangle_get_flags
(rect));
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_argb (rect, buffer = gst_video_overlay_rectangle_get_pixels_unscaled_argb (rect,
to_GstVideoOverlayFormatFlags (flags)); to_GstVideoOverlayFormatFlags (flags));
@ -367,11 +364,8 @@ gst_vaapi_subpicture_set_global_alpha(GstVaapiSubpicture *subpicture,
display = GST_VAAPI_OBJECT_DISPLAY (subpicture); display = GST_VAAPI_OBJECT_DISPLAY (subpicture);
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaSetSubpictureGlobalAlpha( status = vaSetSubpictureGlobalAlpha (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_DISPLAY_VADISPLAY(display), GST_VAAPI_OBJECT_ID (subpicture), global_alpha);
GST_VAAPI_OBJECT_ID(subpicture),
global_alpha
);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaSetSubpictureGlobalAlpha()")) if (!vaapi_check_status (status, "vaSetSubpictureGlobalAlpha()"))
return FALSE; return FALSE;