change encoder log output format, support GST log
authorWind Yuan <feng.yuan@intel.com>
Tue, 29 Nov 2011 02:31:44 +0000 (10:31 +0800)
committerZhong Cong <congx.zhong@intel.com>
Tue, 5 Feb 2013 07:37:11 +0000 (15:37 +0800)
gst/vaapiencode/gstvaapih264encoder.c

index c49d40a..a358aad 100644 (file)
@@ -679,7 +679,6 @@ gst_h264_encoder_prepare_next_buffer(GstVaapiBaseEncoder* encoder,
   GstH264Encoder *h264_encoder = GST_H264_ENCODER(encoder);
   GstH264EncoderPrivate *h264_prv = GST_H264_ENCODER_GET_PRIVATE(h264_encoder);
   GstVaapiVideoBuffer  *return_buf = NULL;
-  GstVaapiVideoBuffer  *tmp_next_buf = NULL;
   //guint64 pts = 0;
 
   if (NULL == display_buf && g_queue_is_empty(h264_prv->queued_buffers)) {
@@ -802,19 +801,23 @@ gst_h264_encoder_rendering(GstVaapiBaseEncoder *encoder, GstVaapiDisplay *displa
     va_status = vaCreateBuffer(va_dpy, context_id,
                                VAEncSequenceParameterBufferType,
                                sizeof(seq_h264), 1, &seq_h264, &h264_prv->seq_parameter);
-    ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS == va_status, ENCODER_ENC_RES_ERR, "alloc seq-buffer failed.\n");
+    ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS == va_status,
+                         ENCODER_ENC_RES_ERR, "alloc seq-buffer failed.");
     va_status = vaRenderPicture(va_dpy, context_id, &h264_prv->seq_parameter, 1);
-    ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS == va_status, ENCODER_PICTURE_ERR, "vaRenderPicture seq-parameters failed.\n");
+    ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS == va_status,
+                         ENCODER_PICTURE_ERR, "vaRenderPicture seq-parameters failed.");
   }
 
   /* set pic_parameters*/
   if (!h264_prv->ref_surface1) {
     h264_prv->ref_surface1 = gst_vaapi_context_get_surface(context);
-    ENCODER_CHECK_STATUS(h264_prv->ref_surface1, ENCODER_SURFACE_ERR, "reference surface, h264_pop_free_surface failed.\n");
+    ENCODER_CHECK_STATUS(h264_prv->ref_surface1, ENCODER_SURFACE_ERR,
+                         "reference surface, h264_pop_free_surface failed.");
   }
   if (!h264_prv->recon_surface) {
     h264_prv->recon_surface = gst_vaapi_context_get_surface(context);
-    ENCODER_CHECK_STATUS(h264_prv->recon_surface, ENCODER_SURFACE_ERR, "reconstructed surface, h264_pop_free_surface failed.\n");
+    ENCODER_CHECK_STATUS(h264_prv->recon_surface, ENCODER_SURFACE_ERR,
+                         "reconstructed surface, h264_pop_free_surface failed.");
   }
 
   pic_h264.reference_picture = GST_VAAPI_OBJECT_ID(h264_prv->ref_surface1);
@@ -831,10 +834,12 @@ gst_h264_encoder_rendering(GstVaapiBaseEncoder *encoder, GstVaapiDisplay *displa
   va_status = vaCreateBuffer(va_dpy, context_id, VAEncPictureParameterBufferType,
                                sizeof(pic_h264), 1, &pic_h264, &h264_prv->pic_parameter);
 
-  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status, ENCODER_PICTURE_ERR, "creating pic-param buffer failed.\n");
+  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status,
+                       ENCODER_PICTURE_ERR, "creating pic-param buffer failed.");
 
   va_status = vaRenderPicture(va_dpy, context_id, &h264_prv->pic_parameter, 1);
-  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status, ENCODER_PICTURE_ERR, "rendering pic-param buffer failed.\n");
+  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status,
+                       ENCODER_PICTURE_ERR, "rendering pic-param buffer failed.");
 
   /* set slice parameters, support multiple slices */
   int i = 0;
@@ -868,10 +873,12 @@ gst_h264_encoder_rendering(GstVaapiBaseEncoder *encoder, GstVaapiDisplay *displa
                              h264_encoder->slice_num,
                              h264_prv->slice_param_buffers,
                              &h264_prv->slice_parameter);
-  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status, ENCODER_PICTURE_ERR, "creating slice-parameters buffer failed.\n");
+  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status,
+                       ENCODER_PICTURE_ERR, "creating slice-parameters buffer failed.");
 
   va_status = vaRenderPicture(va_dpy, context_id, &h264_prv->slice_parameter, 1);
-  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status, ENCODER_PICTURE_ERR, "rendering slice-parameters buffer failed.\n");
+  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status,
+                       ENCODER_PICTURE_ERR, "rendering slice-parameters buffer failed.");
 
   /*after finished, set ref_surface1_index, recon_surface_index */
   GstVaapiSurface *swap = h264_prv->ref_surface1;
@@ -928,7 +935,7 @@ h264_recreate_seq_param(GstH264Encoder *h264_encoder,
   else if (h264_encoder->init_qp == -2)
       seq_h264.rate_control_method = BR_VBR;
   else {
-      assert(h264_encoder->init_qp >= 0 && h264_encoder->init_qp <= 51);
+      ENCODER_ASSERT(h264_encoder->init_qp >= 0 && h264_encoder->init_qp <= 51);
       seq_h264.rate_control_method = BR_CQP;
   }
 
@@ -965,7 +972,7 @@ h264_recreate_seq_param(GstH264Encoder *h264_encoder,
                              sizeof(seq_h264), 1,
                              &seq_h264, &h264_prv->seq_parameter);
   ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS == va_status,
-                     FALSE, "alloc seq-buffer failed.\n");
+                     FALSE, "alloc seq-buffer failed.");
 
   /*pack sps header buffer/data */
   if (NULL == h264_prv->sps_data) {
@@ -1057,7 +1064,7 @@ h264_recreate_pic_param(GstH264Encoder *h264_encoder,
     frame_type = "P";
   if (h264_prv->cur_slice_type == SLICE_TYPE_B)
     frame_type = "B";
-  ENCODER_LOG_INFO("type:%s, frame_num:%d, display_num:%d\n",
+  ENCODER_LOG_INFO("type:%s, frame_num:%d, display_num:%d",
          frame_type, pic_h264.frame_num, pic_h264.CurrPic.TopFieldOrderCnt);
 
   if (VA_INVALID_ID != h264_prv->pic_parameter) { /* share the same pic_parameter*/
@@ -1067,7 +1074,8 @@ h264_recreate_pic_param(GstH264Encoder *h264_encoder,
   va_status = vaCreateBuffer(va_dpy, context_id, VAEncPictureParameterBufferType,
                                sizeof(pic_h264), 1, &pic_h264, &h264_prv->pic_parameter);
 
-  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status, FALSE, "creating pic-param buffer failed.\n");
+  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status,
+                       FALSE, "creating pic-param buffer failed.");
 
   //if (NULL == h264_prv->pps_data) {
   if (VA_INVALID_ID == h264_prv->packed_pps_data_buf) {
@@ -1178,7 +1186,8 @@ h264_recreate_slice_param(GstH264Encoder *h264_encoder,
                              h264_encoder->slice_num,
                              h264_prv->slice_param_buffers,
                              &h264_prv->slice_parameter);
-  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status, FALSE, "creating slice-parameters buffer failed.\n");
+  ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS ==va_status,
+                       FALSE, "creating slice-parameters buffer failed.");
 
 end:
   return ret;
@@ -1207,15 +1216,21 @@ gst_h264_encoder_rendering(GstVaapiBaseEncoder *encoder, GstVaapiDisplay *displa
 
   if (!h264_prv->ref_surface1) {
     h264_prv->ref_surface1 = gst_vaapi_context_get_surface(context);
-    ENCODER_CHECK_STATUS(h264_prv->ref_surface1, ENCODER_SURFACE_ERR, "reference surface, h264_pop_free_surface failed.\n");
+    ENCODER_CHECK_STATUS(h264_prv->ref_surface1,
+                         ENCODER_SURFACE_ERR,
+                         "reference surface, h264_pop_free_surface failed.");
   }
   if (!h264_prv->ref_surface2) {
     h264_prv->ref_surface2 = gst_vaapi_context_get_surface(context);
-    ENCODER_CHECK_STATUS(h264_prv->ref_surface2, ENCODER_SURFACE_ERR, "reference surface, h264_pop_free_surface failed.\n");
+    ENCODER_CHECK_STATUS(h264_prv->ref_surface2,
+                         ENCODER_SURFACE_ERR,
+                         "reference surface, h264_pop_free_surface failed.");
   }
   if (!h264_prv->recon_surface) {
     h264_prv->recon_surface = gst_vaapi_context_get_surface(context);
-    ENCODER_CHECK_STATUS(h264_prv->recon_surface, ENCODER_SURFACE_ERR, "reconstructed surface, h264_pop_free_surface failed.\n");
+    ENCODER_CHECK_STATUS(h264_prv->recon_surface,
+                         ENCODER_SURFACE_ERR,
+                         "reconstructed surface, h264_pop_free_surface failed.");
   }
 
   if (SLICE_TYPE_P == h264_prv->cur_slice_type) {
@@ -1265,7 +1280,7 @@ gst_h264_encoder_rendering(GstVaapiBaseEncoder *encoder, GstVaapiDisplay *displa
 
   va_status = vaRenderPicture(va_dpy, context_id, va_buffers, va_buffers_count);
   ENCODER_CHECK_STATUS(VA_STATUS_SUCCESS == va_status, ENCODER_PICTURE_ERR,
-                       "vaRenderH264Picture failed.\n");
+                       "vaRenderH264Picture failed.");
 
   /*after finished,  swap  recon and surface2*/
   if (SLICE_TYPE_P == h264_prv->cur_slice_type ||
@@ -1640,7 +1655,9 @@ h264_bitstream_write_uint(H264Bitstream *bitstream, guint32 value, guint32 bit_s
   }
 
   VAAPI_UNUSED_ARG(ret);
-  ENCODER_CHECK_STATUS(TRUE == h264_bitstream_auto_grow(bitstream, bit_size), FALSE, "h264_bitstream_auto_grow failed.\n");
+  ENCODER_CHECK_STATUS(TRUE == h264_bitstream_auto_grow(bitstream, bit_size),
+                       FALSE,
+                       "h264_bitstream_auto_grow failed.");
   byte_pos = (bitstream->bit_size>>3);
   bit_offset = (bitstream->bit_size&0x07);
   cur_byte = bitstream->buffer + byte_pos;
@@ -1684,7 +1701,9 @@ h264_bitstream_write_byte_array(H264Bitstream *bitstream, const guint8 *buf, gui
   }
 
   VAAPI_UNUSED_ARG(ret);
-  ENCODER_CHECK_STATUS(TRUE == h264_bitstream_auto_grow(bitstream, byte_size<<3), FALSE, "h264_bitstream_auto_grow failed.\n");
+  ENCODER_CHECK_STATUS(TRUE == h264_bitstream_auto_grow(bitstream, byte_size<<3),
+                       FALSE,
+                       "h264_bitstream_auto_grow failed.");
   if (0 == (bitstream->bit_size&0x07)) {
     memcpy(&bitstream->buffer[bitstream->bit_size>>3], buf, byte_size);
     bitstream->bit_size += (byte_size<<3);
@@ -1711,8 +1730,12 @@ h264_bitstream_write_ue(H264Bitstream *bitstream, guint32 value)
     ++size_in_bits;
     tmp_value >>= 1;
   }
-  ENCODER_CHECK_STATUS(h264_bitstream_write_uint(bitstream, 0, size_in_bits-1), FALSE, "h264_bitstream_write_ue failed.\n");
-  ENCODER_CHECK_STATUS(h264_bitstream_write_uint(bitstream, value, size_in_bits), FALSE, "h264_bitstream_write_ue failed.\n");
+  ENCODER_CHECK_STATUS(h264_bitstream_write_uint(bitstream, 0, size_in_bits-1),
+                       FALSE,
+                       "h264_bitstream_write_ue failed.");
+  ENCODER_CHECK_STATUS(h264_bitstream_write_uint(bitstream, value, size_in_bits),
+                       FALSE,
+                       "h264_bitstream_write_ue failed.");
 
 end:
   return ret;
@@ -1730,7 +1753,9 @@ h264_bitstream_write_se(H264Bitstream *bitstream, gint32 value)
     new_val = (value<<1) - 1;
   }
 
-  ENCODER_CHECK_STATUS(h264_bitstream_write_ue(bitstream, new_val), FALSE, "h264_bitstream_write_se failed.\n");
+  ENCODER_CHECK_STATUS(h264_bitstream_write_ue(bitstream, new_val),
+                       FALSE,
+                       "h264_bitstream_write_se failed.");
 
 end:
   return ret;