static gboolean gst_x265_enc_flush (GstVideoEncoder * encoder) { GstX265Enc *x265enc = GST_X265_ENC (encoder); GST_DEBUG_OBJECT (encoder, "flushing encoder"); gst_x265_enc_flush_frames (x265enc, FALSE); gst_x265_enc_close_encoder (x265enc); gst_x265_enc_dequeue_all_frames (x265enc); gst_x265_enc_init_encoder (x265enc); return TRUE; }
static gboolean gst_x265_enc_stop (GstVideoEncoder * encoder) { GstX265Enc *x265enc = GST_X265_ENC (encoder); GST_DEBUG_OBJECT (encoder, "stop encoder"); gst_x265_enc_flush_frames (x265enc, FALSE); gst_x265_enc_close_encoder (x265enc); gst_x265_enc_dequeue_all_frames (x265enc); if (x265enc->input_state) gst_video_codec_state_unref (x265enc->input_state); x265enc->input_state = NULL; return TRUE; }
static gboolean gst_x265_enc_set_format (GstVideoEncoder * video_enc, GstVideoCodecState * state) { GstX265Enc *encoder = GST_X265_ENC (video_enc); GstVideoInfo *info = &state->info; gboolean level_ok = TRUE; /* If the encoder is initialized, do not reinitialize it again if not * necessary */ if (encoder->x265enc) { GstVideoInfo *old = &encoder->input_state->info; if (info->finfo->format == old->finfo->format && info->width == old->width && info->height == old->height && info->fps_n == old->fps_n && info->fps_d == old->fps_d && info->par_n == old->par_n && info->par_d == old->par_d) { gst_video_codec_state_unref (encoder->input_state); encoder->input_state = gst_video_codec_state_ref (state); return TRUE; } /* clear out pending frames */ gst_x265_enc_flush_frames (encoder, TRUE); } if (encoder->input_state) gst_video_codec_state_unref (encoder->input_state); encoder->input_state = gst_video_codec_state_ref (state); if (!level_ok) return FALSE; if (!gst_x265_enc_init_encoder (encoder)) return FALSE; if (!gst_x265_enc_set_src_caps (encoder, state->caps)) { gst_x265_enc_close_encoder (encoder); return FALSE; } gst_x265_enc_set_latency (encoder); return TRUE; }