xine-lib: xine-lib-1.2.12/src/video_out/vaapi/vaapi_frame.h Source File

xine-lib 1.2.12

vaapi_frame.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 Edgar Hucek <gimli|@dark-green.com>
3 * Copyright (C) 2012-2022 xine developers
4 *
5 * This file is part of xine, a free video player.
6 *
7 * xine is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * xine is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 *
21 * vaapi_frame.c, VAAPI video extension interface for xine
22 *
23 */
24
25#ifndef XINE_VAAPI_FRAME_H
26#define XINE_VAAPI_FRAME_H
27
28#include <xine/video_out.h>
29#include "accel_vaapi.h"
30
31#include "vaapi_util.h"
32#include "../mem_frame.h"
33
34 typedef struct {
35 mem_frame_t mem_frame;
36 vaapi_accel_t vaapi_accel_data;
37 vaapi_context_impl_t *ctx_impl;
38} vaapi_frame_t;
39
40
41 vaapi_frame_t *_x_va_frame_alloc_frame (vaapi_context_impl_t *va, vo_driver_t *driver,
42 int guarded_render);
43void _x_va_frame_update_frame_format (vo_driver_t *this_gen,
44 vo_frame_t *frame_gen,
45 uint32_t width, uint32_t height,
46 double ratio, int format, int flags);
47
48void _x_va_frame_provide_standard_frame_data (vo_frame_t *vo_frame, xine_current_frame_data_t *data);
49void _x_va_frame_duplicate_frame_data (vo_frame_t *this_gen, vo_frame_t *original);
50
51/*
52 *
53 */
54
55static inline
56 vaapi_context_impl_t *_ctx_from_frame(vo_frame_t *vo_frame)
57{
58 vaapi_frame_t *frame = xine_container_of(vo_frame, vaapi_frame_t, mem_frame.vo_frame);
59 return frame->ctx_impl;
60}
61
62/*
63 * accel
64 */
65
66static inline
67 int _x_va_accel_profile_from_imgfmt(vo_frame_t *vo_frame, unsigned format)
68{
69 vaapi_context_impl_t *va = _ctx_from_frame(vo_frame);
70 return _x_va_profile_from_imgfmt(va, format);
71}
72
73static inline
74 ff_vaapi_context_t *_x_va_accel_get_context(vo_frame_t *vo_frame)
75{
76 vaapi_context_impl_t *va = _ctx_from_frame(vo_frame);
77 return &va->c;
78}
79
80static inline
81 int _x_va_accel_vaapi_init(vo_frame_t *vo_frame, int va_profile, int width, int height)
82{
83 vaapi_context_impl_t *va = _ctx_from_frame(vo_frame);
84 return _x_va_init(va, va_profile, width, height);
85}
86
87static inline
88 int _x_va_accel_guarded_render(vo_frame_t *vo_frame)
89{
90 vaapi_accel_t *accel = vo_frame->accel_data;
91 return accel->f->render_vaapi_surface != NULL;
92}
93
94/*
95 * non-guarded mode
96 */
97
98static inline
99 int _x_va_accel_lock_decode_dummy(vo_frame_t *vo_frame)
100{
101 (void)vo_frame;
102 return 0;
103}
104
105static inline
106 ff_vaapi_surface_t *_x_va_accel_get_vaapi_surface(vo_frame_t *vo_frame)
107{
108 vaapi_context_impl_t *va = _ctx_from_frame(vo_frame);
109 vaapi_accel_t *accel = vo_frame->accel_data;
110 _x_assert(accel->index < RENDER_SURFACES); /* index is constant in this mode */
111 return &va->c.va_render_surfaces[accel->index];
112}
113
114/*
115 * guarded mode
116 */
117
118static inline
119 ff_vaapi_surface_t *_x_va_accel_alloc_vaapi_surface(vo_frame_t *vo_frame)
120{
121 vaapi_context_impl_t *va = _ctx_from_frame(vo_frame);
122 return _x_va_alloc_surface(va);
123}
124
125static inline
126 void _x_va_accel_render_vaapi_surface(vo_frame_t *vo_frame, ff_vaapi_surface_t *va_surface)
127{
128 vaapi_context_impl_t *va = _ctx_from_frame(vo_frame);
129 vaapi_accel_t *accel = vo_frame->accel_data;
130
131 accel->index = va_surface->index;
132 _x_va_render_surface(va, va_surface);
133}
134
135static inline
136 void _x_va_accel_release_vaapi_surface(vo_frame_t *vo_frame, ff_vaapi_surface_t *va_surface)
137{
138 /* surface was not binded to this vo_frame */
139 vaapi_context_impl_t *va = _ctx_from_frame(vo_frame);
140 _x_va_release_surface(va, va_surface);
141}
142
143/*
144 * video out
145 */
146
147static inline
148 void _x_va_frame_displayed(vo_frame_t *vo_frame)
149{
150 vaapi_context_impl_t *va_context = _ctx_from_frame(vo_frame);
151 vaapi_accel_t *accel = vo_frame->accel_data;
152
153 if (accel->index < RENDER_SURFACES) {
154 ff_vaapi_surface_t *va_surface = &va_context->c.va_render_surfaces[accel->index];
155 _x_va_surface_displayed(va_context, va_surface);
156 accel->index = RENDER_SURFACES; /* invalid */
157 }
158}
159
160#endif /* XINE_VAAPI_UTIL_H */
accel_vaapi.h
height
unsigned int height
Definition: gfontrle.c:5
width
unsigned int width
Definition: gfontrle.c:4
video_out.h
ff_vaapi_context_s
Definition: accel_vaapi.h:52
ff_vaapi_context_s::va_render_surfaces
ff_vaapi_surface_t * va_render_surfaces
Definition: accel_vaapi.h:62
ff_vaapi_surface_s
Definition: accel_vaapi.h:72
ff_vaapi_surface_s::index
unsigned int index
Definition: accel_vaapi.h:73
mem_frame_t
Definition: mem_frame.h:32
vaapi_accel_funcs_s::render_vaapi_surface
void(* render_vaapi_surface)(vo_frame_t *frame_gen, ff_vaapi_surface_t *va_surface)
Definition: accel_vaapi.h:111
vaapi_accel_s
Definition: accel_vaapi.h:115
vaapi_accel_s::f
const struct vaapi_accel_funcs_s * f
Definition: accel_vaapi.h:118
vaapi_accel_s::index
unsigned int index
Definition: accel_vaapi.h:116
vaapi_context_impl
Definition: vaapi_util.h:54
vaapi_context_impl::c
ff_vaapi_context_t c
Definition: vaapi_util.h:55
vaapi_frame_t
Definition: vaapi_frame.h:34
vaapi_frame_t::ctx_impl
vaapi_context_impl_t * ctx_impl
Definition: vaapi_frame.h:37
vaapi_frame_t::vaapi_accel_data
vaapi_accel_t vaapi_accel_data
Definition: vaapi_frame.h:36
vaapi_frame_t::mem_frame
mem_frame_t mem_frame
Definition: vaapi_frame.h:35
vo_driver_t
Definition: video_out.h:50
vo_frame_s
Definition: video_out.h:70
vo_frame_s::accel_data
void * accel_data
Definition: video_out.h:158
xine_current_frame_data_s
Definition: xine.h:477
_x_va_accel_profile_from_imgfmt
static int _x_va_accel_profile_from_imgfmt(vo_frame_t *vo_frame, unsigned format)
Definition: vaapi_frame.h:67
_x_va_accel_get_context
static ff_vaapi_context_t * _x_va_accel_get_context(vo_frame_t *vo_frame)
Definition: vaapi_frame.h:74
_ctx_from_frame
static vaapi_context_impl_t * _ctx_from_frame(vo_frame_t *vo_frame)
Definition: vaapi_frame.h:56
_x_va_accel_render_vaapi_surface
static void _x_va_accel_render_vaapi_surface(vo_frame_t *vo_frame, ff_vaapi_surface_t *va_surface)
Definition: vaapi_frame.h:126
_x_va_frame_provide_standard_frame_data
void _x_va_frame_provide_standard_frame_data(vo_frame_t *vo_frame, xine_current_frame_data_t *data)
Definition: vaapi_frame.c:51
_x_va_accel_alloc_vaapi_surface
static ff_vaapi_surface_t * _x_va_accel_alloc_vaapi_surface(vo_frame_t *vo_frame)
Definition: vaapi_frame.h:119
_x_va_accel_guarded_render
static int _x_va_accel_guarded_render(vo_frame_t *vo_frame)
Definition: vaapi_frame.h:88
_x_va_accel_release_vaapi_surface
static void _x_va_accel_release_vaapi_surface(vo_frame_t *vo_frame, ff_vaapi_surface_t *va_surface)
Definition: vaapi_frame.h:136
_x_va_frame_duplicate_frame_data
void _x_va_frame_duplicate_frame_data(vo_frame_t *this_gen, vo_frame_t *original)
Definition: vaapi_frame.c:191
_x_va_accel_vaapi_init
static int _x_va_accel_vaapi_init(vo_frame_t *vo_frame, int va_profile, int width, int height)
Definition: vaapi_frame.h:81
_x_va_frame_update_frame_format
void _x_va_frame_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_gen, uint32_t width, uint32_t height, double ratio, int format, int flags)
Definition: vaapi_frame.c:333
_x_va_frame_alloc_frame
vaapi_frame_t * _x_va_frame_alloc_frame(vaapi_context_impl_t *va, vo_driver_t *driver, int guarded_render)
Definition: vaapi_frame.c:374
_x_va_accel_lock_decode_dummy
static int _x_va_accel_lock_decode_dummy(vo_frame_t *vo_frame)
Definition: vaapi_frame.h:99
_x_va_accel_get_vaapi_surface
static ff_vaapi_surface_t * _x_va_accel_get_vaapi_surface(vo_frame_t *vo_frame)
Definition: vaapi_frame.h:106
_x_va_frame_displayed
static void _x_va_frame_displayed(vo_frame_t *vo_frame)
Definition: vaapi_frame.h:148
_x_va_init
VAStatus _x_va_init(vaapi_context_impl_t *va_context, int va_profile, int width, int height)
Definition: vaapi_util.c:338
_x_va_alloc_surface
ff_vaapi_surface_t * _x_va_alloc_surface(vaapi_context_impl_t *va_context)
Definition: vaapi_util.c:543
_x_va_profile_from_imgfmt
int _x_va_profile_from_imgfmt(vaapi_context_impl_t *va_context, unsigned format)
Definition: vaapi_util.c:444
_x_va_release_surface
void _x_va_release_surface(vaapi_context_impl_t *va_context, ff_vaapi_surface_t *va_surface)
Definition: vaapi_util.c:593
_x_va_surface_displayed
void _x_va_surface_displayed(vaapi_context_impl_t *va_context, ff_vaapi_surface_t *va_surface)
Definition: vaapi_util.c:612
_x_va_render_surface
void _x_va_render_surface(vaapi_context_impl_t *va_context, ff_vaapi_surface_t *va_surface)
Definition: vaapi_util.c:583
vaapi_util.h
RENDER_SURFACES
#define RENDER_SURFACES
Definition: vaapi_util.h:52
NULL
NULL
Definition: xine_plugin.c:78
xine_container_of
#define xine_container_of(ptr, type, member)
Definition: xineutils.h:256
_x_assert
#define _x_assert(exp)
Definition: xineutils.h:570