st/omx/enc: implement restricted b frames pattern
authorLeo Liu <leo.liu@amd.com>
Tue, 27 May 2014 14:12:02 +0000 (10:12 -0400)
committerChristian König <christian.koenig@amd.com>
Tue, 27 May 2014 14:56:55 +0000 (16:56 +0200)
Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/state_trackers/omx/vid_enc.c
src/gallium/state_trackers/omx/vid_enc.h

index ee31452a3e8daff6e195152ec796243747623baa..e64928bd6d757e595dc9812ace3a771a174a5a8f 100644 (file)
@@ -259,6 +259,7 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam
    priv->force_pic_type.IntraRefreshVOP = OMX_FALSE; 
    priv->frame_num = 0;
    priv->pic_order_cnt = 0;
+   priv->restricted_b_frames = debug_get_bool_option("OMX_USE_RESTRICTED_B_FRAMES", FALSE);
 
    priv->scale.xWidth = OMX_VID_ENC_SCALING_WIDTH_DEFAULT;
    priv->scale.xHeight = OMX_VID_ENC_SCALING_WIDTH_DEFAULT;
@@ -994,6 +995,8 @@ static void enc_HandleTask(omx_base_PortType *port, struct encode_task *task,
 
    picture.picture_type = picture_type;
    picture.pic_order_cnt = task->pic_order_cnt;
+   if (priv->restricted_b_frames && picture_type == PIPE_H264_ENC_PICTURE_TYPE_B)
+      picture.not_referenced = true;
    enc_ControlPicture(port, &picture);
 
    /* -------------- encode frame --------- */
@@ -1023,7 +1026,9 @@ static void enc_ClearBframes(omx_base_PortType *port, struct input_buf_private *
    /* handle B frames */
    LIST_FOR_EACH_ENTRY(task, &priv->b_frames, list) {
       enc_HandleTask(port, task, PIPE_H264_ENC_PICTURE_TYPE_B);
-      priv->ref_idx_l0 = priv->frame_num++;
+      if (!priv->restricted_b_frames)
+         priv->ref_idx_l0 = priv->frame_num;
+      priv->frame_num++;
    }
 
    enc_MoveTasks(&priv->b_frames, &inp->tasks);
@@ -1091,7 +1096,9 @@ static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEAD
       /* handle B frames */
       LIST_FOR_EACH_ENTRY(task, &priv->b_frames, list) {
          enc_HandleTask(port, task, PIPE_H264_ENC_PICTURE_TYPE_B);
-         priv->ref_idx_l0 = priv->frame_num++;
+         if (!priv->restricted_b_frames)
+            priv->ref_idx_l0 = priv->frame_num;
+         priv->frame_num++;
       }
 
       enc_MoveTasks(&priv->b_frames, &inp->tasks);
index 22f276faa6d5b166fdbcde3810b55a8a1e9a16a1..d0350d6b495f52a9fb2e0127c8c5af42be7c3db5 100644 (file)
@@ -77,6 +77,7 @@ DERIVEDCLASS(vid_enc_PrivateType, omx_base_filter_PrivateType)
        OMX_U32 frame_num; \
        OMX_U32 pic_order_cnt; \
        OMX_U32 ref_idx_l0, ref_idx_l1; \
+       OMX_BOOL restricted_b_frames; \
        OMX_VIDEO_PARAM_BITRATETYPE bitrate; \
        OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant; \
        OMX_CONFIG_INTRAREFRESHVOPTYPE force_pic_type; \