base_video_encoder, GstVideoFrame * frame);
static GstCaps *gst_dirac_enc_get_caps (GstBaseVideoEncoder *
base_video_encoder);
-static void gst_dirac_enc_create_codec_data (GstDiracEnc *dirac_enc,
- GstBuffer *seq_header);
+static void gst_dirac_enc_create_codec_data (GstDiracEnc * dirac_enc,
+ GstBuffer * seq_header);
static GstFlowReturn
gst_dirac_enc_process (GstDiracEnc * dirac_enc, gboolean end_sequence);
);
static GstStaticPadTemplate gst_dirac_enc_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-dirac;video/x-qt-part;video/x-mp4-part")
GstVideoState * state)
{
GstDiracEnc *dirac_enc = GST_DIRAC_ENC (base_video_encoder);
+ GstCaps *caps;
+ GstStructure *structure;
+
+ GST_DEBUG ("set_output_caps");
+ caps =
+ gst_pad_get_allowed_caps (GST_BASE_VIDEO_CODEC_SRC_PAD
+ (base_video_encoder));
+
+ if (caps == NULL) {
+ caps =
+ gst_caps_copy (gst_pad_get_pad_template_caps
+ (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder)));
+ }
+
+ if (gst_caps_is_empty (caps)) {
+ gst_caps_unref (caps);
+ return FALSE;
+ }
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ if (gst_structure_has_name (structure, "video/x-dirac")) {
+ dirac_enc->output_format = GST_DIRAC_ENC_OUTPUT_OGG;
+ } else if (gst_structure_has_name (structure, "video/x-qt-part")) {
+ dirac_enc->output_format = GST_DIRAC_ENC_OUTPUT_QUICKTIME;
+ } else if (gst_structure_has_name (structure, "video/x-avi-part")) {
+ dirac_enc->output_format = GST_DIRAC_ENC_OUTPUT_AVI;
+ } else if (gst_structure_has_name (structure, "video/x-mp4-part")) {
+ dirac_enc->output_format = GST_DIRAC_ENC_OUTPUT_MP4;
+ } else {
+ return FALSE;
+ }
+
+ gst_caps_unref (caps);
+
+ gst_base_video_encoder_set_latency_fields (base_video_encoder, 2 * 2);
switch (state->format) {
case GST_VIDEO_FORMAT_I420:
gst_dirac_enc_start (GstBaseVideoEncoder * base_video_encoder)
{
GstDiracEnc *dirac_enc = GST_DIRAC_ENC (base_video_encoder);
- GstCaps *caps;
- GstStructure *structure;
-
- GST_DEBUG ("set_output_caps");
- caps =
- gst_pad_get_allowed_caps (GST_BASE_VIDEO_CODEC_SRC_PAD
- (base_video_encoder));
-
- if (gst_caps_is_empty (caps)) {
- gst_caps_unref (caps);
- return FALSE;
- }
-
- structure = gst_caps_get_structure (caps, 0);
-
- if (gst_structure_has_name (structure, "video/x-dirac")) {
- dirac_enc->output_format = GST_DIRAC_ENC_OUTPUT_OGG;
- } else if (gst_structure_has_name (structure, "video/x-qt-part")) {
- dirac_enc->output_format = GST_DIRAC_ENC_OUTPUT_QUICKTIME;
- } else if (gst_structure_has_name (structure, "video/x-avi-part")) {
- dirac_enc->output_format = GST_DIRAC_ENC_OUTPUT_AVI;
- } else if (gst_structure_has_name (structure, "video/x-mp4-part")) {
- dirac_enc->output_format = GST_DIRAC_ENC_OUTPUT_MP4;
- } else {
- return FALSE;
- }
-
- gst_base_video_encoder_set_latency_fields (base_video_encoder, 2 * 2);
dirac_enc->granule_offset = ~0;
dirac_enc->encoder = dirac_encoder_init (&dirac_enc->enc_ctx, FALSE);
- gst_caps_unref (caps);
return TRUE;
}
data = (uint8_t *) g_malloc (GST_BUFFER_SIZE (frame->sink_buffer));
for (j = 0; j < state->height; j++) {
for (i = 0; i < state->width; i++) {
- data[j * state->width + i] =
- bufdata[j * state->width * 2 + i * 2];
+ data[j * state->width + i] = bufdata[j * state->width * 2 + i * 2];
}
for (i = 0; i < state->width / 2; i++) {
data[state->height * state->width +
bufdata[j * state->width * 2 + i * 4 + 3];
}
}
- dirac_encoder_load (dirac_enc->encoder, data, GST_BUFFER_SIZE (frame->sink_buffer));
+ dirac_encoder_load (dirac_enc->encoder, data,
+ GST_BUFFER_SIZE (frame->sink_buffer));
g_free (data);
}
break;
bufdata[j * state->width * 2 + i * 4 + 2];
}
}
- dirac_encoder_load (dirac_enc->encoder, data, GST_BUFFER_SIZE (frame->sink_buffer));
+ dirac_encoder_load (dirac_enc->encoder, data,
+ GST_BUFFER_SIZE (frame->sink_buffer));
g_free (data);
}
break;
bufdata[j * state->width * 4 + i * 4 + 3];
}
}
- dirac_encoder_load (dirac_enc->encoder, data, GST_BUFFER_SIZE (frame->sink_buffer));
+ dirac_encoder_load (dirac_enc->encoder, data,
+ GST_BUFFER_SIZE (frame->sink_buffer));
g_free (data);
}
break;
g_assert_not_reached ();
}
- GST_DEBUG("handle frame");
+ GST_DEBUG ("handle frame");
gst_buffer_unref (frame->sink_buffer);
frame->sink_buffer = NULL;
switch (state) {
case ENC_STATE_BUFFER:
- GST_DEBUG("BUFFER");
+ GST_DEBUG ("BUFFER");
gst_buffer_unref (outbuf);
break;
case ENC_STATE_INVALID:
frame->src_buffer = outbuf;
GST_BUFFER_SIZE (outbuf) = dirac_enc->encoder->enc_buf.size;
- ret = gst_base_video_encoder_finish_frame (
- GST_BASE_VIDEO_ENCODER(dirac_enc), frame);
+ ret =
+ gst_base_video_encoder_finish_frame (GST_BASE_VIDEO_ENCODER
+ (dirac_enc), frame);
if (ret != GST_FLOW_OK) {
GST_DEBUG ("pad_push returned %d", ret);
}
break;
case ENC_STATE_AVAIL:
- GST_DEBUG("AVAIL");
+ GST_DEBUG ("AVAIL");
/* FIXME this doesn't reorder frames */
- frame = gst_base_video_encoder_get_frame (
- GST_BASE_VIDEO_ENCODER(dirac_enc),
- dirac_enc->pull_frame_num);
+ frame =
+ gst_base_video_encoder_get_frame (GST_BASE_VIDEO_ENCODER
+ (dirac_enc), dirac_enc->pull_frame_num);
if (frame == NULL) {
- GST_ERROR("didn't get frame %d", dirac_enc->pull_frame_num);
+ GST_ERROR ("didn't get frame %d", dirac_enc->pull_frame_num);
}
dirac_enc->pull_frame_num++;
frame->src_buffer = outbuf;
GST_BUFFER_SIZE (outbuf) = dirac_enc->encoder->enc_buf.size;
- ret = gst_base_video_encoder_finish_frame (
- GST_BASE_VIDEO_ENCODER(dirac_enc), frame);
+ ret =
+ gst_base_video_encoder_finish_frame (GST_BASE_VIDEO_ENCODER
+ (dirac_enc), frame);
if (ret != GST_FLOW_OK) {
GST_DEBUG ("pad_push returned %d", ret);
}
static void
-gst_dirac_enc_create_codec_data (GstDiracEnc *dirac_enc,
- GstBuffer *seq_header)
+gst_dirac_enc_create_codec_data (GstDiracEnc * dirac_enc,
+ GstBuffer * seq_header)
{
GstBuffer *buf;
int size;
- size = GST_READ_UINT32_BE (GST_BUFFER_DATA(seq_header) + 9);
+ size = GST_READ_UINT32_BE (GST_BUFFER_DATA (seq_header) + 9);
#define DIRAC_PARSE_HEADER_SIZE 13
buf = gst_buffer_new_and_alloc (size + DIRAC_PARSE_HEADER_SIZE);
state->fps_d,
"pixel-aspect-ratio", GST_TYPE_FRACTION, state->par_n,
state->par_d,
- "streamheader", GST_TYPE_BUFFER, dirac_enc->codec_data,
- NULL);
+ "streamheader", GST_TYPE_BUFFER, dirac_enc->codec_data, NULL);
} else if (dirac_enc->output_format == GST_DIRAC_ENC_OUTPUT_QUICKTIME) {
caps = gst_caps_new_simple ("video/x-qt-part",
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('d', 'r', 'a', 'c'),
return caps;
}
-