vl: add interface for H264 B-frame encoding
authorChristian König <christian.koenig@amd.com>
Fri, 4 Apr 2014 12:22:16 +0000 (14:22 +0200)
committerChristian König <christian.koenig@amd.com>
Fri, 11 Apr 2014 09:35:03 +0000 (11:35 +0200)
Signed-off-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/radeon/radeon_vce_40_2_2.c
src/gallium/include/pipe/p_video_state.h
src/gallium/state_trackers/omx/vid_enc.c

index c41b2d03ab860ea4de55a684549756dc93372bd6..33a58f3e8e90ba38c97e78c6c6538beb6726aa4f 100644 (file)
@@ -156,8 +156,8 @@ static void pic_control(struct rvce_encoder *enc)
        RVCE_CS(0x00000040); // encConstraintSetFlags
        RVCE_CS(0x00000000); // encBPicPattern
        RVCE_CS(0x00000000); // weightPredModeBPicture
-       RVCE_CS(0x00000001); // encNumberOfReferenceFrames
-       RVCE_CS(0x00000001); // encMaxNumRefFrames
+       RVCE_CS(MIN2(enc->base.max_references, 2)); // encNumberOfReferenceFrames
+       RVCE_CS(enc->base.max_references + 1); // encMaxNumRefFrames
        RVCE_CS(0x00000000); // encNumDefaultActiveRefL0
        RVCE_CS(0x00000000); // encNumDefaultActiveRefL1
        RVCE_CS(0x00000000); // encSliceMode
@@ -297,8 +297,9 @@ static void encode(struct rvce_encoder *enc)
                RVCE_CS(0xffffffff); // chromaOffset
        }
        else if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P) {
-               frame_offset(enc, enc->pic.frame_num - 1, &luma_offset, &chroma_offset);
+               frame_offset(enc, enc->pic.ref_idx_l0, &luma_offset, &chroma_offset);
                RVCE_CS(0x00000000); // encPicType
+               // TODO: Stores these in the CPB backtrack
                RVCE_CS(enc->pic.frame_num - 1); // frameNumber
                RVCE_CS(enc->pic.frame_num - 1); // pictureOrderCount
                RVCE_CS(luma_offset); // lumaOffset
@@ -322,8 +323,8 @@ static void encode(struct rvce_encoder *enc)
        RVCE_CS(0x00000000); // encReferenceRefBasePictureLumaOffset
        RVCE_CS(0x00000000); // encReferenceRefBasePictureChromaOffset
        RVCE_CS(0x00000000); // pictureCount
-       RVCE_CS(0x00000000); // frameNumber
-       RVCE_CS(0x00000000); // pictureOrderCount
+       RVCE_CS(enc->pic.frame_num); // frameNumber
+       RVCE_CS(enc->pic.pic_order_cnt); // pictureOrderCount
        RVCE_CS(0x00000000); // numIPicRemainInRCGOP
        RVCE_CS(0x00000000); // numPPicRemainInRCGOP
        RVCE_CS(0x00000000); // numBPicRemainInRCGOP
index f9721dca05b1ef3d005e23ffe982dedef36319f6..0256a8fa194901e2fcdf78b6ceb901ef6452994b 100644 (file)
@@ -368,6 +368,9 @@ struct pipe_h264_enc_picture_desc
 
    enum pipe_h264_enc_picture_type picture_type;
    unsigned frame_num;
+   unsigned pic_order_cnt;
+   unsigned ref_idx_l0;
+   unsigned ref_idx_l1;
 };
 
 #ifdef __cplusplus
index 8ec04390628d017a8655fa84f81675770262b642..080730bd29477eb13f74da1f610721f001036a96 100644 (file)
@@ -769,11 +769,17 @@ static void enc_ControlPicture(omx_base_PortType *port,
 
    if (!(priv->frame_num % OMX_VID_ENC_IDR_PERIOD_DEFAULT) || priv->force_pic_type.IntraRefreshVOP) {
       picture->picture_type = PIPE_H264_ENC_PICTURE_TYPE_IDR;
+      picture->ref_idx_l0 = 0;
+      picture->ref_idx_l1 = 0;
       priv->frame_num = 0;
-   } else
+   } else {
       picture->picture_type = PIPE_H264_ENC_PICTURE_TYPE_P;
+      picture->ref_idx_l0 = priv->frame_num - 1;
+      picture->ref_idx_l1 = 0;
+   }
    
    picture->frame_num = priv->frame_num++;
+   picture->pic_order_cnt = picture->frame_num;
    priv->force_pic_type.IntraRefreshVOP = OMX_FALSE; 
 }