From ee978aee94d98fec669002eb5ef7ceb1f46683a9 Mon Sep 17 00:00:00 2001 From: Christian König Date: Mon, 15 Jul 2013 09:16:22 -0600 Subject: vl: add H264 encoding interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König Signed-off-by: Leo Liu --- src/gallium/auxiliary/vl/vl_decoder.c | 2 +- src/gallium/drivers/radeon/radeon_video.c | 5 ++-- src/gallium/include/pipe/p_video_codec.h | 13 +++++++++ src/gallium/include/pipe/p_video_enums.h | 4 +-- src/gallium/include/pipe/p_video_state.h | 45 +++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/vl/vl_decoder.c b/src/gallium/auxiliary/vl/vl_decoder.c index fc010670568..97e549d6a50 100644 --- a/src/gallium/auxiliary/vl/vl_decoder.c +++ b/src/gallium/auxiliary/vl/vl_decoder.c @@ -39,7 +39,7 @@ vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile assert(screen); switch (u_reduce_video_profile(profile)) { case PIPE_VIDEO_FORMAT_MPEG12: - return true; + return entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE; default: return false; } diff --git a/src/gallium/drivers/radeon/radeon_video.c b/src/gallium/drivers/radeon/radeon_video.c index 455b147144e..173fd6874ec 100644 --- a/src/gallium/drivers/radeon/radeon_video.c +++ b/src/gallium/drivers/radeon/radeon_video.c @@ -233,10 +233,11 @@ int rvid_get_video_param(struct pipe_screen *screen, case PIPE_VIDEO_FORMAT_MPEG12: case PIPE_VIDEO_FORMAT_MPEG4: case PIPE_VIDEO_FORMAT_MPEG4_AVC: - return true; + return entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE; case PIPE_VIDEO_FORMAT_VC1: /* FIXME: VC-1 simple/main profile is broken */ - return profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED; + return profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED && + entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE; default: return false; } diff --git a/src/gallium/include/pipe/p_video_codec.h b/src/gallium/include/pipe/p_video_codec.h index 0e3827a0eac..d4cdacb9cef 100644 --- a/src/gallium/include/pipe/p_video_codec.h +++ b/src/gallium/include/pipe/p_video_codec.h @@ -86,6 +86,14 @@ struct pipe_video_codec const void * const *buffers, const unsigned *sizes); + /** + * encode to a bitstream + */ + void (*encode_bitstream)(struct pipe_video_codec *codec, + struct pipe_video_buffer *source, + struct pipe_resource *destination, + void **feedback); + /** * end decoding of the current frame */ @@ -98,6 +106,11 @@ struct pipe_video_codec * should be called before a video_buffer is acessed by the state tracker again */ void (*flush)(struct pipe_video_codec *codec); + + /** + * get encoder feedback + */ + void (*get_feedback)(struct pipe_video_codec *codec, void *feedback, unsigned *size); }; /** diff --git a/src/gallium/include/pipe/p_video_enums.h b/src/gallium/include/pipe/p_video_enums.h index 7ec29c033f4..10205ac4411 100644 --- a/src/gallium/include/pipe/p_video_enums.h +++ b/src/gallium/include/pipe/p_video_enums.h @@ -72,8 +72,8 @@ enum pipe_video_entrypoint PIPE_VIDEO_ENTRYPOINT_UNKNOWN, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_ENTRYPOINT_IDCT, - PIPE_VIDEO_ENTRYPOINT_MC + PIPE_VIDEO_ENTRYPOINT_MC, + PIPE_VIDEO_ENTRYPOINT_ENCODE }; - #endif /* PIPE_VIDEO_ENUMS_H */ diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index 79e588fa2a0..f9721dca05b 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -110,6 +110,24 @@ enum pipe_h264_slice_type PIPE_H264_SLICE_TYPE_SI = 0x4 }; +enum pipe_h264_enc_picture_type +{ + PIPE_H264_ENC_PICTURE_TYPE_P = 0x00, + PIPE_H264_ENC_PICTURE_TYPE_B = 0x01, + PIPE_H264_ENC_PICTURE_TYPE_I = 0x02, + PIPE_H264_ENC_PICTURE_TYPE_IDR = 0x03, + PIPE_H264_ENC_PICTURE_TYPE_SKIP = 0x04 +}; + +enum pipe_h264_enc_rate_control_method +{ + PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE = 0x00, + PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT_SKIP = 0x01, + PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE_SKIP = 0x02, + PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT = 0x03, + PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE = 0x04 +}; + struct pipe_picture_desc { enum pipe_video_profile profile; @@ -325,6 +343,33 @@ struct pipe_h264_picture_desc struct pipe_video_buffer *ref[16]; }; +struct pipe_h264_enc_rate_control +{ + enum pipe_h264_enc_rate_control_method rate_ctrl_method; + unsigned target_bitrate; + unsigned peak_bitrate; + unsigned frame_rate_num; + unsigned frame_rate_den; + unsigned vbv_buffer_size; + unsigned target_bits_picture; + unsigned peak_bits_picture_integer; + unsigned peak_bits_picture_fraction; +}; + +struct pipe_h264_enc_picture_desc +{ + struct pipe_picture_desc base; + + struct pipe_h264_enc_rate_control rate_ctrl; + + unsigned quant_i_frames; + unsigned quant_p_frames; + unsigned quant_b_frames; + + enum pipe_h264_enc_picture_type picture_type; + unsigned frame_num; +}; + #ifdef __cplusplus } #endif -- cgit v1.2.3