FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vaapi_internal.h
Go to the documentation of this file.
1 /*
2  * Video Acceleration API (video decoding)
3  * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
4  *
5  * Copyright (C) 2008-2009 Splitted-Desktop Systems
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #ifndef AVCODEC_VAAPI_INTERNAL_H
25 #define AVCODEC_VAAPI_INTERNAL_H
26 
27 #include <va/va.h>
28 #include "vaapi.h"
29 #include "avcodec.h"
30 #include "internal.h"
31 
32 /**
33  * @addtogroup VAAPI_Decoding
34  *
35  * @{
36  */
37 
38 typedef struct {
39  VADisplay display; ///< Windowing system dependent handle
40  VAConfigID config_id; ///< Configuration ID
41  VAContextID context_id; ///< Context ID (video decode pipeline)
42  VABufferID pic_param_buf_id; ///< Picture parameter buffer
43  VABufferID iq_matrix_buf_id; ///< Inverse quantiser matrix buffer
44  VABufferID bitplane_buf_id; ///< Bitplane buffer (for VC-1 decoding)
45  VABufferID *slice_buf_ids; ///< Slice parameter/data buffers
46  unsigned int n_slice_buf_ids; ///< Number of effective slice buffers
47  unsigned int slice_buf_ids_alloc; ///< Number of allocated slice buffers
48  void *slice_params; ///< Pointer to slice parameter buffers
49  unsigned int slice_param_size; ///< Size of a slice parameter element
50  unsigned int slice_params_alloc; ///< Number of allocated slice parameters
51  unsigned int slice_count; ///< Number of slices currently filled in
52  const uint8_t *slice_data; ///< Pointer to slice data buffer base
53  unsigned int slice_data_size; ///< Current size of slice data
54 } FFVAContext;
55 
56 /** Extract vaapi_context from an AVCodecContext */
58 {
59  return avctx->internal->hwaccel_priv_data;
60 }
61 
62 /** Extract VASurfaceID from an AVFrame */
63 static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
64 {
65  return (uintptr_t)pic->data[3];
66 }
67 
68 /** Common AVHWAccel.init() implementation */
70 
71 /** Common AVHWAccel.uninit() implementation */
73 
74 /** Common AVHWAccel.end_frame() implementation */
76 
77 /** Allocate a new picture parameter buffer */
78 void *ff_vaapi_alloc_pic_param(FFVAContext *vactx, unsigned int size);
79 
80 /** Allocate a new IQ matrix buffer */
81 void *ff_vaapi_alloc_iq_matrix(FFVAContext *vactx, unsigned int size);
82 
83 /** Allocate a new bit-plane buffer */
85 
86 /**
87  * Allocate a new slice descriptor for the input slice.
88  *
89  * @param vactx the VA API context
90  * @param buffer the slice data buffer base
91  * @param size the size of the slice in bytes
92  * @return the newly allocated slice parameter
93  */
94 VASliceParameterBufferBase *ff_vaapi_alloc_slice(FFVAContext *vactx, const uint8_t *buffer, uint32_t size);
95 
98 int ff_vaapi_render_picture(FFVAContext *vactx, VASurfaceID surface);
99 
100 /* @} */
101 
102 #endif /* AVCODEC_VAAPI_INTERNAL_H */
VASliceParameterBufferBase * ff_vaapi_alloc_slice(FFVAContext *vactx, const uint8_t *buffer, uint32_t size)
Allocate a new slice descriptor for the input slice.
Definition: vaapi.c:178
int ff_vaapi_context_fini(AVCodecContext *avctx)
Common AVHWAccel.uninit() implementation.
Definition: vaapi.c:66
VAContextID context_id
Context ID (video decode pipeline)
const uint8_t * slice_data
Pointer to slice data buffer base.
This structure describes decoded (raw) audio or video data.
Definition: frame.h:181
int ff_vaapi_render_picture(FFVAContext *vactx, VASurfaceID surface)
Definition: vaapi.c:71
VABufferID pic_param_buf_id
Picture parameter buffer.
uint8_t
unsigned int slice_param_size
Size of a slice parameter element.
VADisplay display
Windowing system dependent handle.
void * ff_vaapi_alloc_iq_matrix(FFVAContext *vactx, unsigned int size)
Allocate a new IQ matrix buffer.
Definition: vaapi.c:168
static FFVAContext * ff_vaapi_get_context(AVCodecContext *avctx)
Extract vaapi_context from an AVCodecContext.
ptrdiff_t size
Definition: opengl_enc.c:101
VABufferID iq_matrix_buf_id
Inverse quantiser matrix buffer.
void ff_vaapi_common_end_frame(AVCodecContext *avctx)
Common AVHWAccel.end_frame() implementation.
Definition: vaapi.c:209
int ff_vaapi_context_init(AVCodecContext *avctx)
Common AVHWAccel.init() implementation.
Definition: vaapi.c:45
unsigned int n_slice_buf_ids
Number of effective slice buffers.
unsigned int slice_params_alloc
Number of allocated slice parameters.
static VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
Extract VASurfaceID from an AVFrame.
VABufferID * slice_buf_ids
Slice parameter/data buffers.
void * slice_params
Pointer to slice parameter buffers.
unsigned int slice_buf_ids_alloc
Number of allocated slice buffers.
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1532
int ff_vaapi_commit_slices(FFVAContext *vactx)
Definition: vaapi.c:111
Public libavcodec VA API header.
void * ff_vaapi_alloc_pic_param(FFVAContext *vactx, unsigned int size)
Allocate a new picture parameter buffer.
Definition: vaapi.c:163
unsigned int slice_data_size
Current size of slice data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:192
common internal api header.
unsigned int slice_count
Number of slices currently filled in.
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:162
VABufferID bitplane_buf_id
Bitplane buffer (for VC-1 decoding)
VAConfigID config_id
Configuration ID.
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:1582
int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx)
uint8_t * ff_vaapi_alloc_bitplane(FFVAContext *vactx, uint32_t size)
Allocate a new bit-plane buffer.
Definition: vaapi.c:173
GLuint buffer
Definition: opengl_enc.c:102