context: re-indent all GstVaapiContext related source code.

This commit is contained in:
Gwenole Beauchesne 2014-01-23 09:27:38 +01:00
parent c5bdeb6980
commit 1ffdc010ad
2 changed files with 584 additions and 629 deletions

View file

@ -51,7 +51,8 @@ typedef struct _GstVaapiContextClass GstVaapiContextClass;
*
* A VA context wrapper.
*/
struct _GstVaapiContext {
struct _GstVaapiContext
{
/*< private >*/
GstVaapiObject parent_instance;
@ -68,13 +69,15 @@ struct _GstVaapiContext {
*
* A VA context wrapper class.
*/
struct _GstVaapiContextClass {
struct _GstVaapiContextClass
{
/*< private >*/
GstVaapiObjectClass parent_class;
};
typedef struct _GstVaapiOverlayRectangle GstVaapiOverlayRectangle;
struct _GstVaapiOverlayRectangle {
struct _GstVaapiOverlayRectangle
{
GstVaapiContext *context;
GstVaapiSubpicture *subpicture;
GstVaapiRectangle render_rect;
@ -91,9 +94,15 @@ get_max_ref_frames(GstVaapiProfile profile)
guint ref_frames;
switch (gst_vaapi_profile_get_codec (profile)) {
case GST_VAAPI_CODEC_H264: ref_frames = 16; break;
case GST_VAAPI_CODEC_JPEG: ref_frames = 0; break;
default: ref_frames = 2; break;
case GST_VAAPI_CODEC_H264:
ref_frames = 16;
break;
case GST_VAAPI_CODEC_JPEG:
ref_frames = 0;
break;
default:
ref_frames = 2;
break;
}
return ref_frames;
}
@ -116,8 +125,7 @@ gst_video_overlay_rectangle_replace(GstVideoOverlayRectangle **old_rect_ptr,
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)(old_overlay_ptr), \
(GstVaapiMiniObject *)(new_overlay))
static void
overlay_rectangle_finalize(GstVaapiOverlayRectangle *overlay);
static void overlay_rectangle_finalize (GstVaapiOverlayRectangle * overlay);
static gboolean
overlay_rectangle_associate (GstVaapiOverlayRectangle * overlay);
@ -136,8 +144,8 @@ overlay_rectangle_class(void)
}
static GstVaapiOverlayRectangle *
overlay_rectangle_new(GstVideoOverlayRectangle *rect, GstVaapiContext *context,
guint layer_id)
overlay_rectangle_new (GstVideoOverlayRectangle * rect,
GstVaapiContext * context, guint layer_id)
{
GstVaapiOverlayRectangle *overlay;
GstVaapiRectangle *render_rect;
@ -160,8 +168,9 @@ overlay_rectangle_new(GstVideoOverlayRectangle *rect, GstVaapiContext *context,
if (!overlay->rect_buffer)
goto error;
overlay->subpicture = gst_vaapi_subpicture_new_from_overlay_rectangle(
GST_VAAPI_OBJECT_DISPLAY(context), rect);
overlay->subpicture =
gst_vaapi_subpicture_new_from_overlay_rectangle (GST_VAAPI_OBJECT_DISPLAY
(context), rect);
if (!overlay->subpicture)
goto error;
@ -245,8 +254,9 @@ overlay_rectangle_changed_pixels(GstVaapiOverlayRectangle *overlay,
if (overlay->seq_num == gst_video_overlay_rectangle_get_seqnum (rect))
return FALSE;
flags = to_GstVideoOverlayFormatFlags(
gst_vaapi_subpicture_get_flags(overlay->subpicture));
flags =
to_GstVideoOverlayFormatFlags (gst_vaapi_subpicture_get_flags
(overlay->subpicture));
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_raw (rect, flags);
if (!buffer)
@ -265,8 +275,7 @@ overlay_rectangle_changed_pixels(GstVaapiOverlayRectangle *overlay,
for (i = 0; i < n_blocks; i++) {
GstMemory *const mem1 = gst_buffer_peek_memory (buffer, i);
GstMemory * const mem2 =
gst_buffer_peek_memory(overlay->rect_buffer, i);
GstMemory *const mem2 = gst_buffer_peek_memory (overlay->rect_buffer, i);
if (!gst_memory_is_span (mem1, mem2, &ofs))
return FALSE;
}
@ -291,8 +300,7 @@ overlay_rectangle_changed_render_rect(GstVaapiOverlayRectangle *overlay,
if (x == render_rect->x &&
y == render_rect->y &&
width == render_rect->width &&
height == render_rect->height)
width == render_rect->width && height == render_rect->height)
return FALSE;
render_rect->x = x;
@ -360,8 +368,7 @@ overlay_lookup(GPtrArray *overlays, GstVideoOverlayRectangle *rect)
guint i;
for (i = 0; i < overlays->len; i++) {
GstVaapiOverlayRectangle * const overlay =
g_ptr_array_index(overlays, i);
GstVaapiOverlayRectangle *const overlay = g_ptr_array_index (overlays, i);
if (overlay->rect == rect)
return overlay;
@ -432,10 +439,8 @@ gst_vaapi_context_destroy(GstVaapiContext *context)
if (context_id != VA_INVALID_ID) {
GST_VAAPI_DISPLAY_LOCK (display);
status = vaDestroyContext(
GST_VAAPI_DISPLAY_VADISPLAY(display),
context_id
);
status = vaDestroyContext (GST_VAAPI_DISPLAY_VADISPLAY (display),
context_id);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaDestroyContext()"))
g_warning ("failed to destroy context %" GST_VAAPI_ID_FORMAT,
@ -445,10 +450,8 @@ gst_vaapi_context_destroy(GstVaapiContext *context)
if (context->config_id != VA_INVALID_ID) {
GST_VAAPI_DISPLAY_LOCK (display);
status = vaDestroyConfig(
GST_VAAPI_DISPLAY_VADISPLAY(display),
context->config_id
);
status = vaDestroyConfig (GST_VAAPI_DISPLAY_VADISPLAY (display),
context->config_id);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaDestroyConfig()"))
g_warning ("failed to destroy config %" GST_VAAPI_ID_FORMAT,
@ -490,8 +493,8 @@ gst_vaapi_context_create_surfaces(GstVaapiContext *context)
if (!context->surfaces_pool) {
gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_ENCODED,
cip->width, cip->height);
context->surfaces_pool = gst_vaapi_surface_pool_new(
GST_VAAPI_OBJECT_DISPLAY(context), &vi);
context->surfaces_pool =
gst_vaapi_surface_pool_new (GST_VAAPI_OBJECT_DISPLAY (context), &vi);
if (!context->surfaces_pool)
return FALSE;
}
@ -500,11 +503,8 @@ gst_vaapi_context_create_surfaces(GstVaapiContext *context)
gst_vaapi_video_pool_set_capacity (context->surfaces_pool, num_surfaces);
for (i = context->surfaces->len; i < num_surfaces; i++) {
surface = gst_vaapi_surface_new(
GST_VAAPI_OBJECT_DISPLAY(context),
GST_VAAPI_CHROMA_TYPE_YUV420,
cip->width, cip->height
);
surface = gst_vaapi_surface_new (GST_VAAPI_OBJECT_DISPLAY (context),
GST_VAAPI_CHROMA_TYPE_YUV420, cip->width, cip->height);
if (!surface)
return FALSE;
gst_vaapi_surface_set_parent_context (surface, context);
@ -535,18 +535,13 @@ gst_vaapi_context_create(GstVaapiContext *context)
if (!context->surfaces && !gst_vaapi_context_create_surfaces (context))
goto end;
surfaces = g_array_sized_new(
FALSE,
FALSE,
sizeof(VASurfaceID),
context->surfaces->len
);
surfaces = g_array_sized_new (FALSE,
FALSE, sizeof (VASurfaceID), context->surfaces->len);
if (!surfaces)
goto end;
for (i = 0; i < context->surfaces->len; i++) {
GstVaapiSurface * const surface =
g_ptr_array_index(context->surfaces, i);
GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i);
if (!surface)
goto end;
surface_id = GST_VAAPI_OBJECT_ID (surface);
@ -565,12 +560,8 @@ gst_vaapi_context_create(GstVaapiContext *context)
attribs[num_attribs++].type = VAConfigAttribRateControl;
GST_VAAPI_DISPLAY_LOCK (display);
status = vaGetConfigAttributes(
GST_VAAPI_DISPLAY_VADISPLAY(display),
va_profile,
va_entrypoint,
attribs, num_attribs
);
status = vaGetConfigAttributes (GST_VAAPI_DISPLAY_VADISPLAY (display),
va_profile, va_entrypoint, attribs, num_attribs);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaGetConfigAttributes()"))
goto end;
@ -590,26 +581,18 @@ gst_vaapi_context_create(GstVaapiContext *context)
}
GST_VAAPI_DISPLAY_LOCK (display);
status = vaCreateConfig(
GST_VAAPI_DISPLAY_VADISPLAY(display),
va_profile,
va_entrypoint,
attribs, num_attribs,
&context->config_id
);
status = vaCreateConfig (GST_VAAPI_DISPLAY_VADISPLAY (display),
va_profile, va_entrypoint, attribs, num_attribs, &context->config_id);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaCreateConfig()"))
goto end;
GST_VAAPI_DISPLAY_LOCK (display);
status = vaCreateContext(
GST_VAAPI_DISPLAY_VADISPLAY(display),
status = vaCreateContext (GST_VAAPI_DISPLAY_VADISPLAY (display),
context->config_id,
cip->width, cip->height,
VA_PROGRESSIVE,
(VASurfaceID *)surfaces->data, surfaces->len,
&context_id
);
(VASurfaceID *) surfaces->data, surfaces->len, &context_id);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaCreateContext()"))
goto end;
@ -624,7 +607,8 @@ end:
}
static inline void
gst_vaapi_context_init(GstVaapiContext *context, const GstVaapiContextInfo *cip)
gst_vaapi_context_init (GstVaapiContext * context,
const GstVaapiContextInfo * cip)
{
context->info = *cip;
context->config_id = VA_INVALID_ID;
@ -656,14 +640,9 @@ GST_VAAPI_OBJECT_DEFINE_CLASS(GstVaapiContext, gst_vaapi_context)
*
* Return value: the newly allocated #GstVaapiContext object
*/
GstVaapiContext *
gst_vaapi_context_new(
GstVaapiDisplay *display,
GstVaapiContext *gst_vaapi_context_new (GstVaapiDisplay * display,
GstVaapiProfile profile,
GstVaapiEntrypoint entrypoint,
guint width,
guint height
)
GstVaapiEntrypoint entrypoint, guint width, guint height)
{
GstVaapiContextInfo info;
@ -726,13 +705,9 @@ error:
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_context_reset(
GstVaapiContext *context,
gst_vaapi_context_reset (GstVaapiContext * context,
GstVaapiProfile profile,
GstVaapiEntrypoint entrypoint,
unsigned int width,
unsigned int height
)
GstVaapiEntrypoint entrypoint, unsigned int width, unsigned int height)
{
GstVaapiContextInfo info;
@ -764,8 +739,7 @@ gst_vaapi_context_reset_full(GstVaapiContext *context,
GstVaapiContextInfo *const cip = &context->info;
gboolean size_changed, codec_changed, rc_mode_changed;
size_changed = cip->width != new_cip->width ||
cip->height != new_cip->height;
size_changed = cip->width != new_cip->width || cip->height != new_cip->height;
if (size_changed) {
gst_vaapi_context_destroy_surfaces (context);
cip->width = new_cip->width;
@ -842,16 +816,15 @@ gst_vaapi_context_get_profile(GstVaapiContext *context)
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_context_set_profile(GstVaapiContext *context, GstVaapiProfile profile)
gst_vaapi_context_set_profile (GstVaapiContext * context,
GstVaapiProfile profile)
{
g_return_val_if_fail (context != NULL, FALSE);
g_return_val_if_fail (profile, FALSE);
return gst_vaapi_context_reset (context,
profile,
context->info.entrypoint,
context->info.width,
context->info.height);
context->info.entrypoint, context->info.width, context->info.height);
}
/**
@ -879,11 +852,8 @@ gst_vaapi_context_get_entrypoint(GstVaapiContext *context)
* Retrieves the size of the surfaces attached to @context.
*/
void
gst_vaapi_context_get_size(
GstVaapiContext *context,
guint *pwidth,
guint *pheight
)
gst_vaapi_context_get_size (GstVaapiContext * context,
guint * pwidth, guint * pheight)
{
g_return_if_fail (context != NULL);
@ -914,8 +884,9 @@ gst_vaapi_context_get_surface_proxy(GstVaapiContext *context)
{
g_return_val_if_fail (context != NULL, NULL);
return gst_vaapi_surface_proxy_new_from_pool(
GST_VAAPI_SURFACE_POOL(context->surfaces_pool));
return
gst_vaapi_surface_proxy_new_from_pool (GST_VAAPI_SURFACE_POOL (context->
surfaces_pool));
}
/**
@ -948,10 +919,8 @@ gst_vaapi_context_get_surface_count(GstVaapiContext *context)
* %FALSE otherwise
*/
gboolean
gst_vaapi_context_apply_composition(
GstVaapiContext *context,
GstVideoOverlayComposition *composition
)
gst_vaapi_context_apply_composition (GstVaapiContext * context,
GstVideoOverlayComposition * composition)
{
GPtrArray *curr_overlay, *next_overlay;
guint i, n_rectangles;
@ -982,8 +951,7 @@ gst_vaapi_context_apply_composition(
overlay_rectangle_ref (overlay);
if (overlay->layer_id != i)
reassociate = TRUE;
}
else {
} else {
overlay = overlay_rectangle_new (rect, context, i);
if (!overlay) {
GST_WARNING ("could not create VA overlay rectangle");

View file

@ -49,7 +49,8 @@ typedef struct _GstVaapiContextInfo GstVaapiContextInfo;
* Note: @rc_mode is only valid for VA context used for encoding,
* i.e. if @entrypoint is set to @GST_VAAPI_ENTRYPOINT_SLICE_ENCODE.
*/
struct _GstVaapiContextInfo {
struct _GstVaapiContextInfo
{
GstVaapiProfile profile;
GstVaapiEntrypoint entrypoint;
GstVaapiRateControl rc_mode;
@ -60,13 +61,8 @@ struct _GstVaapiContextInfo {
G_GNUC_INTERNAL
GstVaapiContext *
gst_vaapi_context_new(
GstVaapiDisplay *display,
GstVaapiProfile profile,
GstVaapiEntrypoint entrypoint,
guint width,
guint height
);
gst_vaapi_context_new (GstVaapiDisplay * display, GstVaapiProfile profile,
GstVaapiEntrypoint entrypoint, guint width, guint height);
G_GNUC_INTERNAL
GstVaapiContext *
@ -75,13 +71,8 @@ gst_vaapi_context_new_full(GstVaapiDisplay *display,
G_GNUC_INTERNAL
gboolean
gst_vaapi_context_reset(
GstVaapiContext *context,
GstVaapiProfile profile,
GstVaapiEntrypoint entrypoint,
guint width,
guint height
);
gst_vaapi_context_reset (GstVaapiContext * context, GstVaapiProfile profile,
GstVaapiEntrypoint entrypoint, guint width, guint height);
G_GNUC_INTERNAL
gboolean
@ -98,7 +89,8 @@ gst_vaapi_context_get_profile(GstVaapiContext *context);
G_GNUC_INTERNAL
gboolean
gst_vaapi_context_set_profile(GstVaapiContext *context, GstVaapiProfile profile);
gst_vaapi_context_set_profile (GstVaapiContext * context,
GstVaapiProfile profile);
G_GNUC_INTERNAL
GstVaapiEntrypoint
@ -106,11 +98,8 @@ gst_vaapi_context_get_entrypoint(GstVaapiContext *context);
G_GNUC_INTERNAL
void
gst_vaapi_context_get_size(
GstVaapiContext *context,
guint *pwidth,
guint *pheight
);
gst_vaapi_context_get_size (GstVaapiContext * context,
guint * pwidth, guint * pheight);
G_GNUC_INTERNAL
GstVaapiSurfaceProxy *
@ -122,10 +111,8 @@ gst_vaapi_context_get_surface_count(GstVaapiContext *context);
G_GNUC_INTERNAL
gboolean
gst_vaapi_context_apply_composition(
GstVaapiContext *context,
GstVideoOverlayComposition *composition
);
gst_vaapi_context_apply_composition (GstVaapiContext * context,
GstVideoOverlayComposition * composition);
G_GNUC_INTERNAL
gboolean