vl: add H264 encoding interface
authorChristian König <christian.koenig@amd.com>
Mon, 15 Jul 2013 15:16:22 +0000 (09:16 -0600)
committerChristian König <christian.koenig@amd.com>
Tue, 11 Feb 2014 12:26:13 +0000 (13:26 +0100)
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Leo Liu <leo.liu@amd.com>
src/gallium/auxiliary/vl/vl_decoder.c
src/gallium/drivers/radeon/radeon_video.c
src/gallium/include/pipe/p_video_codec.h
src/gallium/include/pipe/p_video_enums.h
src/gallium/include/pipe/p_video_state.h

index fc0106705680ef82acb69fbf36b00547608a8fc1..97e549d6a50d498e01670d4dd6c7c2a61b76cde8 100644 (file)
@@ -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;
    }
index 455b147144e2afdc39be73426fe4d10cb7853812..173fd6874ecadb9ba071458afb401cbd870b85be 100644 (file)
@@ -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;
                }
index 0e3827a0eac999d330dca214cba547dd4b45983e..d4cdacb9cef74e71e29124c6752712b00d217dc4 100644 (file)
@@ -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);
 };
 
 /**
index 7ec29c033f4e1ac39b9f7050e1df306a23f9eca9..10205ac4411694ab589b3316ca9f0a819baf5c59 100644 (file)
@@ -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 */
index 79e588fa2a0ddfdae76a9f12b991a5098408fe84..f9721dca05b1ef3d005e23ffe982dedef36319f6 100644 (file)
@@ -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