jpegenc copy GstMeta twice

neil yannian89 at 163.com
Wed Apr 22 08:42:48 UTC 2020


I registered a new GstMeta representing video processing information without
any tag. I found two such metas after the jpegenc element.

jpegenc copy all the metadata in gst_jpegenc_term_destination and then calls
gst_video_encoder_finish_frame.

static void
gst_jpegenc_term_destination (j_compress_ptr cinfo)
{
  ...
  outbuf = gst_buffer_new ();
  gst_buffer_copy_into (outbuf, jpegenc->current_frame->input_buffer,
      GST_BUFFER_COPY_METADATA, 0, -1);
  gst_buffer_append_memory (outbuf, jpegenc->output_mem);
  jpegenc->output_mem = NULL;

  jpegenc->current_frame->output_buffer = outbuf;
  ...
  jpegenc->res = gst_video_encoder_finish_frame (GST_VIDEO_ENCODER
(jpegenc),
      jpegenc->current_frame);
  ...
}

and in gst_video_encoder_finish_frame, video_encoder will call
transform_meta and copy GstMeta again.
GstFlowReturn
gst_video_encoder_finish_frame (GstVideoEncoder * encoder,
    GstVideoCodecFrame * frame)
{
  ...
  if (encoder_class->transform_meta) {
    if (G_LIKELY (frame->input_buffer)) {
      CopyMetaData data;

      data.encoder = encoder;
      data.frame = frame;
      gst_buffer_foreach_meta (frame->input_buffer, foreach_metadata,
&data);
    } else {
      GST_WARNING_OBJECT (encoder,
          "Can't copy metadata because input frame disappeared");
    }
  }
  ...
}

So what is the story behind the design? and how could I define my custom
GstMeta.

looking forward to your reply



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list