ca6ee910dc712e5ffc7fb7b9eafea475b66c93ec
[mesa.git] / src / gallium / state_trackers / omx / vid_enc.h
1 /**************************************************************************
2 *
3 * Copyright 2013 Advanced Micro Devices, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Christian König <christian.koenig@amd.com>
31 *
32 */
33
34 #ifndef OMX_VID_ENC_H
35 #define OMX_VID_ENC_H
36
37 #include <OMX_Types.h>
38 #include <OMX_Component.h>
39 #include <OMX_Core.h>
40
41 #include <bellagio/st_static_component_loader.h>
42 #include <bellagio/omx_base_filter.h>
43
44 #include "util/u_double_list.h"
45
46 #include "vl/vl_defines.h"
47 #include "vl/vl_compositor.h"
48
49 #define OMX_VID_ENC_BASE_NAME "OMX.mesa.video_encoder"
50 #define OMX_VID_ENC_AVC_NAME "OMX.mesa.video_encoder.avc"
51 #define OMX_VID_ENC_AVC_ROLE "video_encoder.avc"
52
53 #define OMX_VID_ENC_BITRATE_MIN 64000
54 #define OMX_VID_ENC_BITRATE_MEDIAN 2000000
55 #define OMX_VID_ENC_BITRATE_MAX 240000000
56 #define OMX_VID_ENC_CONTROL_FRAME_RATE_DEN_DEFAULT 1001
57 #define OMX_VID_ENC_QUANT_I_FRAMES_DEFAULT 0x1c
58 #define OMX_VID_ENC_QUANT_P_FRAMES_DEFAULT 0x1c
59 #define OMX_VID_ENC_QUANT_B_FRAMES_DEFAULT 0x1c
60 #define OMX_VID_ENC_SCALING_WIDTH_DEFAULT 0xffffffff
61 #define OMX_VID_ENC_SCALING_HEIGHT_DEFAULT 0xffffffff
62 #define OMX_VID_ENC_IDR_PERIOD_DEFAULT 1000
63 #define OMX_VID_ENC_P_PERIOD_DEFAULT 3
64
65 #define OMX_VID_ENC_NUM_SCALING_BUFFERS 4
66
67 DERIVEDCLASS(vid_enc_PrivateType, omx_base_filter_PrivateType)
68 #define vid_enc_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \
69 struct vl_screen *screen; \
70 struct pipe_context *s_pipe; \
71 struct pipe_context *t_pipe; \
72 struct pipe_video_codec *codec; \
73 struct list_head free_tasks; \
74 struct list_head used_tasks; \
75 struct list_head b_frames; \
76 OMX_U32 frame_rate; \
77 OMX_U32 frame_num; \
78 OMX_U32 pic_order_cnt; \
79 OMX_U32 ref_idx_l0, ref_idx_l1; \
80 OMX_BOOL restricted_b_frames; \
81 OMX_VIDEO_PARAM_BITRATETYPE bitrate; \
82 OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant; \
83 OMX_VIDEO_PARAM_PROFILELEVELTYPE profile_level; \
84 OMX_CONFIG_INTRAREFRESHVOPTYPE force_pic_type; \
85 struct vl_compositor compositor; \
86 struct vl_compositor_state cstate; \
87 struct pipe_video_buffer *scale_buffer[OMX_VID_ENC_NUM_SCALING_BUFFERS]; \
88 OMX_CONFIG_SCALEFACTORTYPE scale; \
89 OMX_U32 current_scale_buffer;
90 ENDCLASS(vid_enc_PrivateType)
91
92 OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp);
93
94 #endif