Path: blob/21.2-virgl/src/gallium/frontends/omx/vid_enc_common.h
4561 views
/**************************************************************************1*2* Copyright 2013 Advanced Micro Devices, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef VID_ENC_COMMON_H28#define VID_ENC_COMMON_H2930#include "util/list.h"31#include "util/u_memory.h"3233#include "vl/vl_defines.h"34#include "vl/vl_compositor.h"35#include "vl/vl_winsys.h"3637#include <OMX_Core.h>3839#define OMX_VID_ENC_BITRATE_MIN 6400040#define OMX_VID_ENC_BITRATE_MEDIAN 200000041#define OMX_VID_ENC_BITRATE_MAX 24000000042#define OMX_VID_ENC_CONTROL_FRAME_RATE_DEN_DEFAULT 100143#define OMX_VID_ENC_QUANT_I_FRAMES_DEFAULT 0x1c44#define OMX_VID_ENC_QUANT_P_FRAMES_DEFAULT 0x1c45#define OMX_VID_ENC_QUANT_B_FRAMES_DEFAULT 0x1c46#define OMX_VID_ENC_SCALING_WIDTH_DEFAULT 0xffffffff47#define OMX_VID_ENC_SCALING_HEIGHT_DEFAULT 0xffffffff48#define OMX_VID_ENC_IDR_PERIOD_DEFAULT 100049#define OMX_VID_ENC_P_PERIOD_DEFAULT 35051#define OMX_VID_ENC_NUM_SCALING_BUFFERS 45253struct encode_task {54struct list_head list;5556struct pipe_video_buffer *buf;57unsigned pic_order_cnt;58struct pipe_resource *bitstream;59void *feedback;60};6162struct input_buf_private {63struct list_head tasks;6465struct pipe_resource *resource;66struct pipe_transfer *transfer;67};6869struct output_buf_private {70struct pipe_resource *bitstream;71struct pipe_transfer *transfer;72};7374#if ENABLE_ST_OMX_BELLAGIO7576#include <bellagio/omx_base_filter.h>7778DERIVEDCLASS(vid_enc_PrivateType, omx_base_filter_PrivateType)79#define vid_enc_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \80struct vl_screen *screen; \81struct pipe_context *s_pipe; \82struct pipe_context *t_pipe; \83struct pipe_video_codec *codec; \84struct list_head free_tasks; \85struct list_head used_tasks; \86struct list_head b_frames; \87struct list_head stacked_tasks; \88OMX_U32 frame_rate; \89OMX_U32 frame_num; \90OMX_U32 pic_order_cnt; \91OMX_U32 ref_idx_l0, ref_idx_l1; \92OMX_BOOL restricted_b_frames; \93OMX_VIDEO_PARAM_BITRATETYPE bitrate; \94OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant; \95OMX_VIDEO_PARAM_PROFILELEVELTYPE profile_level; \96OMX_CONFIG_INTRAREFRESHVOPTYPE force_pic_type; \97struct vl_compositor compositor; \98struct vl_compositor_state cstate; \99struct pipe_video_buffer *scale_buffer[OMX_VID_ENC_NUM_SCALING_BUFFERS]; \100OMX_CONFIG_SCALEFACTORTYPE scale; \101OMX_U32 current_scale_buffer; \102OMX_U32 stacked_frames_num; \103void *copy_y_shader; \104void *copy_uv_shader;105ENDCLASS(vid_enc_PrivateType)106107#else108109#include <tizprc_decls.h>110#include <tizport_decls.h>111112typedef struct h264e_prc_class h264e_prc_class_t;113struct h264e_prc_class114{115/* Class */116const tiz_prc_class_t _;117/* NOTE: Class methods might be added in the future */118};119120typedef struct h264e_prc vid_enc_PrivateType;121struct h264e_prc122{123/* Object */124const tiz_prc_t _;125OMX_BUFFERHEADERTYPE *p_inhdr_;126OMX_BUFFERHEADERTYPE *p_outhdr_;127OMX_PARAM_PORTDEFINITIONTYPE in_port_def_;128OMX_PARAM_PORTDEFINITIONTYPE out_port_def_;129struct vl_screen *screen;130struct pipe_context *s_pipe;131struct pipe_context *t_pipe;132struct pipe_video_codec *codec;133struct list_head free_tasks;134struct list_head used_tasks;135struct list_head b_frames;136struct list_head stacked_tasks;137OMX_U32 frame_rate;138OMX_U32 frame_num;139OMX_U32 pic_order_cnt;140OMX_U32 ref_idx_l0, ref_idx_l1;141OMX_BOOL restricted_b_frames;142OMX_VIDEO_PARAM_BITRATETYPE bitrate;143OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant;144OMX_VIDEO_PARAM_PROFILELEVELTYPE profile_level;145OMX_CONFIG_INTRAREFRESHVOPTYPE force_pic_type;146struct vl_compositor compositor;147struct vl_compositor_state cstate;148struct pipe_video_buffer *scale_buffer[OMX_VID_ENC_NUM_SCALING_BUFFERS];149OMX_CONFIG_SCALEFACTORTYPE scale;150OMX_U32 current_scale_buffer;151OMX_U32 stacked_frames_num;152bool eos_;153bool in_port_disabled_;154bool out_port_disabled_;155void *copy_y_shader;156void *copy_uv_shader;157};158#endif159160void enc_ReleaseTasks(struct list_head *head);161void enc_MoveTasks(struct list_head *from, struct list_head *to);162enum pipe_video_profile enc_TranslateOMXProfileToPipe(unsigned omx_profile);163unsigned enc_TranslateOMXLevelToPipe(unsigned omx_level);164void vid_enc_BufferEncoded_common(vid_enc_PrivateType * priv, OMX_BUFFERHEADERTYPE* input,165OMX_BUFFERHEADERTYPE* output);166struct encode_task *enc_NeedTask_common(vid_enc_PrivateType * priv,167OMX_VIDEO_PORTDEFINITIONTYPE *def);168void enc_ScaleInput_common(vid_enc_PrivateType * priv,169OMX_VIDEO_PORTDEFINITIONTYPE *def,170struct pipe_video_buffer **vbuf, unsigned *size);171void enc_ControlPicture_common(vid_enc_PrivateType * priv,172struct pipe_h264_enc_picture_desc *picture);173void enc_InitCompute_common(vid_enc_PrivateType *priv);174void enc_ReleaseCompute_common(vid_enc_PrivateType *priv);175OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def,176OMX_BUFFERHEADERTYPE *buf,177struct pipe_video_buffer *vbuf);178#endif179180181