GST_BUFFER_OFFSET_END (buf) = dirac_enc->last_granulepos;
}
- gst_buffer_set_caps (buf, base_video_encoder->caps);
+ gst_buffer_set_caps (buf, GST_BASE_VIDEO_CODEC(base_video_encoder)->caps);
return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
}
state = gst_base_video_encoder_get_state (base_video_encoder);
GST_BUFFER_TIMESTAMP (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->presentation_frame_number);
+ &GST_BASE_VIDEO_CODEC(base_video_encoder)->segment, frame->presentation_frame_number);
GST_BUFFER_DURATION (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment,
+ &GST_BASE_VIDEO_CODEC(base_video_encoder)->segment,
frame->presentation_frame_number + 1) - GST_BUFFER_TIMESTAMP (buf);
- GST_BUFFER_OFFSET_END (buf) =
- gst_video_state_get_timestamp (state, &base_video_encoder->segment,
+ GST_BUFFER_OFFSET_END (buf) = gst_video_state_get_timestamp (state,
+ &GST_BASE_VIDEO_CODEC(base_video_encoder)->segment,
frame->system_frame_number);
GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
}
- gst_buffer_set_caps (buf, base_video_encoder->caps);
+ gst_buffer_set_caps (buf, GST_BASE_VIDEO_CODEC(base_video_encoder)->caps);
return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
}
state = gst_base_video_encoder_get_state (base_video_encoder);
GST_BUFFER_TIMESTAMP (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->presentation_frame_number);
+ &GST_BASE_VIDEO_CODEC(base_video_encoder)->segment,
+ frame->presentation_frame_number);
GST_BUFFER_DURATION (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment,
+ &GST_BASE_VIDEO_CODEC(base_video_encoder)->segment,
frame->presentation_frame_number + 1) - GST_BUFFER_TIMESTAMP (buf);
- GST_BUFFER_OFFSET_END (buf) =
- gst_video_state_get_timestamp (state, &base_video_encoder->segment,
+ GST_BUFFER_OFFSET_END (buf) = gst_video_state_get_timestamp (state,
+ &GST_BASE_VIDEO_CODEC(base_video_encoder)->segment,
frame->decode_frame_number);
GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;
GST_BUFFER_OFFSET_END (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->system_frame_number);
+ &GST_BASE_VIDEO_CODEC(base_video_encoder)->segment,
+ frame->system_frame_number);
if (frame->is_sync_point &&
frame->presentation_frame_number == frame->system_frame_number) {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
}
- gst_buffer_set_caps (buf, base_video_encoder->caps);
+ gst_buffer_set_caps (buf, GST_BASE_VIDEO_CODEC(base_video_encoder)->caps);
return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
}
GST_BUFFER_OFFSET_END (buf) = schro_enc->last_granulepos;
}
- gst_buffer_set_caps (buf, base_video_encoder->caps);
+ gst_buffer_set_caps (buf, GST_BASE_VIDEO_CODEC (base_video_encoder)->caps);
return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
}
state = gst_base_video_encoder_get_state (base_video_encoder);
GST_BUFFER_TIMESTAMP (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->presentation_frame_number);
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
+ frame->presentation_frame_number);
GST_BUFFER_DURATION (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment,
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
frame->presentation_frame_number + 1) - GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_OFFSET_END (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->system_frame_number);
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
+ frame->system_frame_number);
GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;
if (frame->is_sync_point &&
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
}
- gst_buffer_set_caps (buf, base_video_encoder->caps);
+ gst_buffer_set_caps (buf, GST_BASE_VIDEO_CODEC (base_video_encoder)->caps);
return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
}
state = gst_base_video_encoder_get_state (base_video_encoder);
GST_BUFFER_TIMESTAMP (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->presentation_frame_number);
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
+ frame->presentation_frame_number);
GST_BUFFER_DURATION (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment,
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
frame->presentation_frame_number + 1) - GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_OFFSET_END (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->decode_frame_number);
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
+ frame->decode_frame_number);
GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;
GST_BUFFER_OFFSET_END (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->system_frame_number);
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
+ frame->system_frame_number);
if (frame->is_sync_point &&
frame->presentation_frame_number == frame->system_frame_number) {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
}
- gst_buffer_set_caps (buf, base_video_encoder->caps);
+ gst_buffer_set_caps (buf, GST_BASE_VIDEO_CODEC (base_video_encoder)->caps);
return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
}
gst_vp8_dec_image_to_buffer (GstVP8Dec * dec, const vpx_image_t * img,
GstBuffer * buffer)
{
- GstBaseVideoDecoder *decoder = (GstBaseVideoDecoder *) dec;
int stride, w, h, i;
guint8 *d;
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (dec)->state;
d = GST_BUFFER_DATA (buffer) +
- gst_video_format_get_component_offset (decoder->state.format, 0,
- decoder->state.width, decoder->state.height);
- stride =
- gst_video_format_get_row_stride (decoder->state.format, 0,
- decoder->state.width);
- h = gst_video_format_get_component_height (decoder->state.format, 0,
- decoder->state.height);
+ gst_video_format_get_component_offset (state->format, 0,
+ state->width, state->height);
+ stride = gst_video_format_get_row_stride (state->format, 0, state->width);
+ h = gst_video_format_get_component_height (state->format, 0, state->height);
h = MIN (h, img->h);
- w = gst_video_format_get_component_width (decoder->state.format, 0,
- decoder->state.width);
+ w = gst_video_format_get_component_width (state->format, 0, state->width);
w = MIN (w, img->w);
for (i = 0; i < h; i++)
img->planes[VPX_PLANE_Y] + i * img->stride[VPX_PLANE_Y], w);
d = GST_BUFFER_DATA (buffer) +
- gst_video_format_get_component_offset (decoder->state.format, 1,
- decoder->state.width, decoder->state.height);
- stride =
- gst_video_format_get_row_stride (decoder->state.format, 1,
- decoder->state.width);
- h = gst_video_format_get_component_height (decoder->state.format, 1,
- decoder->state.height);
+ gst_video_format_get_component_offset (state->format, 1,
+ state->width, state->height);
+ stride = gst_video_format_get_row_stride (state->format, 1, state->width);
+ h = gst_video_format_get_component_height (state->format, 1, state->height);
h = MIN (h, img->h >> img->y_chroma_shift);
- w = gst_video_format_get_component_width (decoder->state.format, 1,
- decoder->state.width);
+ w = gst_video_format_get_component_width (state->format, 1, state->width);
w = MIN (w, img->w >> img->x_chroma_shift);
for (i = 0; i < h; i++)
memcpy (d + i * stride,
img->planes[VPX_PLANE_U] + i * img->stride[VPX_PLANE_U], w);
d = GST_BUFFER_DATA (buffer) +
- gst_video_format_get_component_offset (decoder->state.format, 2,
- decoder->state.width, decoder->state.height);
+ gst_video_format_get_component_offset (state->format, 2,
+ state->width, state->height);
/* Same stride, height, width as above */
for (i = 0; i < h; i++)
memcpy (d + i * stride,
int flags = 0;
vpx_codec_stream_info_t stream_info;
vpx_codec_caps_t caps;
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (dec)->state;
memset (&stream_info, 0, sizeof (stream_info));
stream_info.sz = sizeof (stream_info);
}
/* should set size here */
- decoder->state.width = stream_info.w;
- decoder->state.height = stream_info.h;
- decoder->state.format = GST_VIDEO_FORMAT_I420;
+ state->width = stream_info.w;
+ state->height = stream_info.h;
+ state->format = GST_VIDEO_FORMAT_I420;
gst_vp8_dec_send_tags (dec);
caps = vpx_codec_get_caps (&vpx_codec_vp8_dx_algo);
gst_vp8_enc_buffer_to_image (GstVP8Enc * enc, GstBuffer * buffer)
{
vpx_image_t *image = g_slice_new0 (vpx_image_t);
- GstBaseVideoEncoder *encoder = (GstBaseVideoEncoder *) enc;
guint8 *data = GST_BUFFER_DATA (buffer);
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (enc)->state;
image->fmt = VPX_IMG_FMT_I420;
image->bps = 12;
image->x_chroma_shift = image->y_chroma_shift = 1;
image->img_data = data;
- image->w = image->d_w = encoder->state.width;
- image->h = image->d_h = encoder->state.height;
+ image->w = image->d_w = state->width;
+ image->h = image->d_h = state->height;
image->stride[VPX_PLANE_Y] =
- gst_video_format_get_row_stride (encoder->state.format, 0,
- encoder->state.width);
+ gst_video_format_get_row_stride (state->format, 0, state->width);
image->stride[VPX_PLANE_U] =
- gst_video_format_get_row_stride (encoder->state.format, 1,
- encoder->state.width);
+ gst_video_format_get_row_stride (state->format, 1, state->width);
image->stride[VPX_PLANE_V] =
- gst_video_format_get_row_stride (encoder->state.format, 2,
- encoder->state.width);
+ gst_video_format_get_row_stride (state->format, 2, state->width);
image->planes[VPX_PLANE_Y] =
- data + gst_video_format_get_component_offset (encoder->state.format, 0,
- encoder->state.width, encoder->state.height);
+ data + gst_video_format_get_component_offset (state->format, 0,
+ state->width, state->height);
image->planes[VPX_PLANE_U] =
- data + gst_video_format_get_component_offset (encoder->state.format, 1,
- encoder->state.width, encoder->state.height);
+ data + gst_video_format_get_component_offset (state->format, 1,
+ state->width, state->height);
image->planes[VPX_PLANE_V] =
- data + gst_video_format_get_component_offset (encoder->state.format, 2,
- encoder->state.width, encoder->state.height);
+ data + gst_video_format_get_component_offset (state->format, 2,
+ state->width, state->height);
return image;
}
return FALSE;
}
- cfg.g_w = base_video_encoder->state.width;
- cfg.g_h = base_video_encoder->state.height;
- cfg.g_timebase.num = base_video_encoder->state.fps_d;
- cfg.g_timebase.den = base_video_encoder->state.fps_n;
+ cfg.g_w = state->width;
+ cfg.g_h = state->height;
+ cfg.g_timebase.num = state->fps_d;
+ cfg.g_timebase.den = state->fps_n;
cfg.g_error_resilient = encoder->error_resilient;
cfg.g_lag_in_frames = encoder->max_latency;
gst_base_video_encoder_set_latency (base_video_encoder, 0,
gst_util_uint64_scale (encoder->max_latency,
- base_video_encoder->state.fps_d * GST_SECOND,
- base_video_encoder->state.fps_n));
+ state->fps_d * GST_SECOND, state->fps_n));
encoder->inited = TRUE;
}
}
GST_BUFFER_TIMESTAMP (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->presentation_frame_number);
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
+ frame->presentation_frame_number);
GST_BUFFER_DURATION (buf) = 0;
GST_BUFFER_OFFSET_END (buf) =
_to_granulepos (frame->presentation_frame_number + 1,
gst_util_uint64_scale (frame->presentation_frame_number + 1,
GST_SECOND * state->fps_d, state->fps_n);
- gst_buffer_set_caps (buf, base_video_encoder->caps);
+ gst_buffer_set_caps (buf, GST_BASE_VIDEO_CODEC (base_video_encoder)->caps);
ret = gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
if (ret != GST_FLOW_OK) {
}
GST_BUFFER_TIMESTAMP (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment, frame->presentation_frame_number);
- GST_BUFFER_DURATION (buf) = gst_video_state_get_timestamp (state,
- &base_video_encoder->segment,
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
+ frame->presentation_frame_number);
+ GST_BUFFER_DURATION (buf) =
+ gst_video_state_get_timestamp (state,
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
frame->presentation_frame_number + 1) - GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_OFFSET_END (buf) =
- _to_granulepos (frame->presentation_frame_number + 1,
- 0, encoder->keyframe_distance);
+ _to_granulepos (frame->presentation_frame_number + 1, 0,
+ encoder->keyframe_distance);
GST_BUFFER_OFFSET (buf) =
gst_util_uint64_scale (frame->presentation_frame_number + 1,
GST_SECOND * state->fps_d, state->fps_n);
- gst_buffer_set_caps (buf, base_video_encoder->caps);
+ gst_buffer_set_caps (buf, GST_BASE_VIDEO_CODEC (base_video_encoder)->caps);
ret = gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf);
if (ret != GST_FLOW_OK) {
gst_element_add_pad (GST_ELEMENT (base_video_codec),
base_video_codec->srcpad);
+ gst_segment_init (&base_video_codec->segment, GST_FORMAT_TIME);
+
}
static void
gst_base_video_codec_reset (GstBaseVideoCodec * base_video_codec)
{
+ GList *g;
+
GST_DEBUG ("reset");
+ for (g = base_video_codec->frames; g; g = g_list_next (g)) {
+ gst_base_video_codec_free_frame ((GstVideoFrame *) g->data);
+ }
+ g_list_free (base_video_codec->frames);
+
+ if (base_video_codec->caps) {
+ gst_caps_unref (base_video_codec->caps);
+ base_video_codec->caps = NULL;
+ }
+
}
static void
g_return_if_fail (GST_IS_BASE_VIDEO_CODEC (object));
base_video_codec = GST_BASE_VIDEO_CODEC (object);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
GstPad *srcpad;
guint64 system_frame_number;
+
+ GList *frames;
+ GstVideoState state;
+ GstSegment segment;
+
+ GstCaps *caps;
+
+ gdouble proportion;
+ GstClockTime earliest_time;
+
+ /* FIXME before moving to base */
+ void *padding[GST_PADDING_LARGE];
};
struct _GstBaseVideoCodecClass
GstFlowReturn (*shape_output) (GstBaseVideoCodec *codec, GstVideoFrame *frame);
GstCaps *(*get_caps) (GstBaseVideoCodec *codec);
+ /* FIXME before moving to base */
+ void *padding[GST_PADDING_LARGE];
};
GType gst_base_video_codec_get_type (void);
base_video_decoder->input_adapter = gst_adapter_new ();
base_video_decoder->output_adapter = gst_adapter_new ();
- gst_segment_init (&base_video_decoder->segment, GST_FORMAT_TIME);
gst_base_video_decoder_reset (base_video_decoder);
base_video_decoder->current_frame =
GST_DEBUG ("setcaps %" GST_PTR_FORMAT, caps);
- state = &base_video_decoder->state;
+ state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
if (state->codec_data) {
gst_buffer_unref (state->codec_data);
gint64 start;
gint64 stop;
gint64 position;
- GstSegment *segment = &base_video_decoder->segment;
+ GstSegment *segment = &GST_BASE_VIDEO_CODEC (base_video_decoder)->segment;
gst_event_parse_new_segment_full (event, &update, &rate,
&applied_rate, &format, &start, &stop, &position);
break;
case GST_EVENT_FLUSH_STOP:{
GST_OBJECT_LOCK (base_video_decoder);
- base_video_decoder->earliest_time = GST_CLOCK_TIME_NONE;
- base_video_decoder->proportion = 0.5;
- gst_segment_init (&base_video_decoder->segment, GST_FORMAT_TIME);
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->earliest_time =
+ GST_CLOCK_TIME_NONE;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->proportion = 0.5;
+ gst_segment_init (&GST_BASE_VIDEO_CODEC (base_video_decoder)->segment,
+ GST_FORMAT_TIME);
GST_OBJECT_UNLOCK (base_video_decoder);
}
default:
gst_event_parse_qos (event, &proportion, &diff, ×tamp);
GST_OBJECT_LOCK (base_video_decoder);
- base_video_decoder->proportion = proportion;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->proportion = proportion;
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (timestamp))) {
if (G_UNLIKELY (diff > 0)) {
- if (base_video_decoder->state.fps_n > 0)
+ if (GST_BASE_VIDEO_CODEC (base_video_decoder)->state.fps_n > 0)
duration =
gst_util_uint64_scale (GST_SECOND,
- base_video_decoder->state.fps_d,
- base_video_decoder->state.fps_n);
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->state.fps_d,
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->state.fps_n);
else
duration = 0;
- base_video_decoder->earliest_time = timestamp + 2 * diff + duration;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->earliest_time =
+ timestamp + 2 * diff + duration;
} else {
- base_video_decoder->earliest_time = timestamp + diff;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->earliest_time =
+ timestamp + diff;
}
} else {
- base_video_decoder->earliest_time = GST_CLOCK_TIME_NONE;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->earliest_time =
+ GST_CLOCK_TIME_NONE;
}
GST_OBJECT_UNLOCK (base_video_decoder);
}
time = enc->last_timestamp;
- time = gst_segment_to_stream_time (&enc->segment, GST_FORMAT_TIME, time);
+ time =
+ gst_segment_to_stream_time (&GST_BASE_VIDEO_CODEC (enc)->segment,
+ GST_FORMAT_TIME, time);
gst_query_set_position (query, format, time);
base_video_decoder = GST_BASE_VIDEO_DECODER (gst_pad_get_parent (pad));
GST_DEBUG_OBJECT (base_video_decoder, "sink query fps=%d/%d",
- base_video_decoder->state.fps_n, base_video_decoder->state.fps_d);
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->state.fps_n,
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->state.fps_d);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONVERT:
{
gint64 src_val, dest_val;
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
- res = gst_base_video_rawvideo_convert (&base_video_decoder->state,
- src_fmt, src_val, &dest_fmt, &dest_val);
+ res =
+ gst_base_video_rawvideo_convert (&GST_BASE_VIDEO_CODEC
+ (base_video_decoder)->state, src_fmt, src_val, &dest_fmt, &dest_val);
if (!res)
goto error;
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
gst_base_video_decoder_reset (GstBaseVideoDecoder * base_video_decoder)
{
GstBaseVideoDecoderClass *base_video_decoder_class;
- GList *g;
base_video_decoder_class =
GST_BASE_VIDEO_DECODER_GET_CLASS (base_video_decoder);
base_video_decoder->have_sync = FALSE;
base_video_decoder->timestamp_offset = GST_CLOCK_TIME_NONE;
- base_video_decoder->system_frame_number = 0;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->system_frame_number = 0;
base_video_decoder->presentation_frame_number = 0;
base_video_decoder->base_picture_number = 0;
base_video_decoder->last_timestamp = GST_CLOCK_TIME_NONE;
if (base_video_decoder->output_adapter) {
gst_adapter_clear (base_video_decoder->output_adapter);
}
-
- if (base_video_decoder->caps) {
- gst_caps_unref (base_video_decoder->caps);
- base_video_decoder->caps = NULL;
- }
//gst_segment_init (&base_video_decoder->segment, GST_FORMAT_TIME);
if (base_video_decoder->current_frame) {
base_video_decoder->have_src_caps = FALSE;
- for (g = g_list_first (base_video_decoder->frames); g; g = g_list_next (g)) {
- GstVideoFrame *frame = g->data;
- gst_base_video_decoder_free_frame (frame);
- }
- g_list_free (base_video_decoder->frames);
- base_video_decoder->frames = NULL;
-
GST_OBJECT_LOCK (base_video_decoder);
- base_video_decoder->earliest_time = GST_CLOCK_TIME_NONE;
- base_video_decoder->proportion = 0.5;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->earliest_time =
+ GST_CLOCK_TIME_NONE;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->proportion = 0.5;
GST_OBJECT_UNLOCK (base_video_decoder);
if (base_video_decoder_class->reset) {
GST_WARNING
("Received buffer without a new-segment. Assuming timestamps start from 0.");
- gst_segment_set_newsegment_full (&base_video_decoder->segment,
- FALSE, 1.0, 1.0, GST_FORMAT_TIME, 0, GST_CLOCK_TIME_NONE, 0);
+ gst_segment_set_newsegment_full (&GST_BASE_VIDEO_CODEC
+ (base_video_decoder)->segment, FALSE, 1.0, 1.0, GST_FORMAT_TIME, 0,
+ GST_CLOCK_TIME_NONE, 0);
base_video_decoder->have_segment = TRUE;
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0,
if (base_video_decoder_class->stop) {
base_video_decoder_class->stop (base_video_decoder);
}
- gst_segment_init (&base_video_decoder->segment, GST_FORMAT_TIME);
+ gst_segment_init (&GST_BASE_VIDEO_CODEC (base_video_decoder)->segment,
+ GST_FORMAT_TIME);
g_list_foreach (base_video_decoder->timestamps, (GFunc) g_free, NULL);
g_list_free (base_video_decoder->timestamps);
base_video_decoder->timestamps = NULL;
frame = g_malloc0 (sizeof (GstVideoFrame));
- frame->system_frame_number = base_video_decoder->system_frame_number;
- base_video_decoder->system_frame_number++;
+ frame->system_frame_number =
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->system_frame_number;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->system_frame_number++;
frame->decode_frame_number = frame->system_frame_number -
base_video_decoder->reorder_depth;
GstVideoFrame * frame)
{
GstBaseVideoDecoderClass *base_video_decoder_class;
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
GstBuffer *src_buffer;
GST_DEBUG ("finish frame");
+ GST_DEBUG ("n %d in %d out %d",
+ g_list_length (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames),
+ gst_adapter_available (base_video_decoder->input_adapter),
+ gst_adapter_available (base_video_decoder->output_adapter));
base_video_decoder_class =
GST_BASE_VIDEO_DECODER_GET_CLASS (base_video_decoder);
GST_DEBUG ("sync timestamp %" GST_TIME_FORMAT " diff %" GST_TIME_FORMAT,
GST_TIME_ARGS (frame->presentation_timestamp),
GST_TIME_ARGS (frame->presentation_timestamp -
- base_video_decoder->segment.start));
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->segment.start));
base_video_decoder->timestamp_offset = frame->presentation_timestamp;
base_video_decoder->field_index &= 1;
} else {
GST_WARNING
("No base timestamp. Assuming frames start at segment start");
base_video_decoder->timestamp_offset =
- base_video_decoder->segment.start;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->segment.start;
base_video_decoder->field_index &= 1;
}
}
base_video_decoder->last_timestamp = frame->presentation_timestamp;
GST_BUFFER_FLAG_UNSET (frame->src_buffer, GST_BUFFER_FLAG_DELTA_UNIT);
- if (base_video_decoder->state.interlaced) {
- int tff = base_video_decoder->state.top_field_first;
+ if (state->interlaced) {
+ int tff = state->top_field_first;
if (frame->field_index & 1) {
tff ^= 1;
GST_DEBUG ("pushing frame %" GST_TIME_FORMAT,
GST_TIME_ARGS (frame->presentation_timestamp));
- base_video_decoder->frames =
- g_list_remove (base_video_decoder->frames, frame);
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->frames =
+ g_list_remove (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames, frame);
gst_base_video_decoder_set_src_caps (base_video_decoder);
gint64 start = GST_BUFFER_TIMESTAMP (src_buffer);
gint64 stop = GST_BUFFER_TIMESTAMP (src_buffer) +
GST_BUFFER_DURATION (src_buffer);
+ GstSegment *segment = &GST_BASE_VIDEO_CODEC (base_video_decoder)->segment;
- if (gst_segment_clip (&base_video_decoder->segment, GST_FORMAT_TIME,
- start, stop, &start, &stop)) {
+ if (gst_segment_clip (segment, GST_FORMAT_TIME, start, stop, &start, &stop)) {
GST_BUFFER_TIMESTAMP (src_buffer) = start;
GST_BUFFER_DURATION (src_buffer) = stop - start;
GST_DEBUG ("accepting buffer inside segment: %" GST_TIME_FORMAT
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (src_buffer)),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (src_buffer) +
GST_BUFFER_DURATION (src_buffer)),
- GST_TIME_ARGS (base_video_decoder->segment.start),
- GST_TIME_ARGS (base_video_decoder->segment.stop),
- GST_TIME_ARGS (base_video_decoder->segment.time));
+ GST_TIME_ARGS (segment->start),
+ GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time));
} else {
GST_DEBUG ("dropping buffer outside segment: %" GST_TIME_FORMAT
" %" GST_TIME_FORMAT
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (src_buffer)),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (src_buffer) +
GST_BUFFER_DURATION (src_buffer)),
- GST_TIME_ARGS (base_video_decoder->segment.start),
- GST_TIME_ARGS (base_video_decoder->segment.stop),
- GST_TIME_ARGS (base_video_decoder->segment.time));
+ GST_TIME_ARGS (segment->start),
+ GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time));
gst_buffer_unref (src_buffer);
return GST_FLOW_OK;
}
GST_DEBUG ("sync timestamp %" GST_TIME_FORMAT " diff %" GST_TIME_FORMAT,
GST_TIME_ARGS (frame->presentation_timestamp),
GST_TIME_ARGS (frame->presentation_timestamp -
- base_video_decoder->segment.start));
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->segment.start));
base_video_decoder->timestamp_offset = frame->presentation_timestamp;
base_video_decoder->field_index = 0;
} else {
GST_WARNING
("No base timestamp. Assuming frames start at segment start");
base_video_decoder->timestamp_offset =
- base_video_decoder->segment.start;
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->segment.start;
base_video_decoder->field_index = 0;
}
}
GST_DEBUG ("skipping frame %" GST_TIME_FORMAT,
GST_TIME_ARGS (frame->presentation_timestamp));
- base_video_decoder->frames =
- g_list_remove (base_video_decoder->frames, frame);
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->frames =
+ g_list_remove (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames, frame);
gst_base_video_decoder_free_frame (frame);
int
gst_base_video_decoder_get_height (GstBaseVideoDecoder * base_video_decoder)
{
- return base_video_decoder->state.height;
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
+
+ return state->height;
}
int
gst_base_video_decoder_get_width (GstBaseVideoDecoder * base_video_decoder)
{
- return base_video_decoder->state.width;
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
+
+ return state->width;
}
GstFlowReturn
GstBuffer * buffer)
{
- if (base_video_decoder->frames) {
+ if (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames) {
GST_DEBUG ("EOS with frames left over");
}
gst_base_video_decoder_get_timestamp (GstBaseVideoDecoder * base_video_decoder,
int picture_number)
{
- if (base_video_decoder->state.fps_d == 0) {
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
+
+ if (state->fps_d == 0) {
return -1;
}
if (picture_number < base_video_decoder->base_picture_number) {
return base_video_decoder->timestamp_offset -
(gint64) gst_util_uint64_scale (base_video_decoder->base_picture_number
- - picture_number, base_video_decoder->state.fps_d * GST_SECOND,
- base_video_decoder->state.fps_n);
+ - picture_number, state->fps_d * GST_SECOND, state->fps_n);
} else {
return base_video_decoder->timestamp_offset +
gst_util_uint64_scale (picture_number -
base_video_decoder->base_picture_number,
- base_video_decoder->state.fps_d * GST_SECOND,
- base_video_decoder->state.fps_n);
+ state->fps_d * GST_SECOND, state->fps_n);
}
}
gst_base_video_decoder_get_field_timestamp (GstBaseVideoDecoder *
base_video_decoder, int field_offset)
{
- if (base_video_decoder->state.fps_d == 0) {
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
+
+ if (state->fps_d == 0) {
return GST_CLOCK_TIME_NONE;
}
if (field_offset < 0) {
return GST_CLOCK_TIME_NONE;
}
return base_video_decoder->timestamp_offset +
- gst_util_uint64_scale (field_offset,
- base_video_decoder->state.fps_d * GST_SECOND,
- base_video_decoder->state.fps_n * 2);
+ gst_util_uint64_scale (field_offset, state->fps_d * GST_SECOND,
+ state->fps_n * 2);
}
static guint64
gst_base_video_decoder_get_field_duration (GstBaseVideoDecoder *
base_video_decoder, int n_fields)
{
- if (base_video_decoder->state.fps_d == 0) {
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
+
+ if (state->fps_d == 0) {
return GST_CLOCK_TIME_NONE;
}
if (n_fields < 0) {
GST_WARNING ("n_fields < 0");
return GST_CLOCK_TIME_NONE;
}
- return gst_util_uint64_scale (n_fields,
- base_video_decoder->state.fps_d * GST_SECOND,
- base_video_decoder->state.fps_n * 2);
+ return gst_util_uint64_scale (n_fields, state->fps_d * GST_SECOND,
+ state->fps_n * 2);
}
GST_DEBUG ("dts %" GST_TIME_FORMAT, GST_TIME_ARGS (frame->decode_timestamp));
GST_DEBUG ("dist %d", frame->distance_from_sync);
- base_video_decoder->frames = g_list_append (base_video_decoder->frames,
- frame);
+ GST_BASE_VIDEO_CODEC (base_video_decoder)->frames =
+ g_list_append (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames, frame);
- frame->deadline = gst_segment_to_running_time (&base_video_decoder->segment,
- GST_FORMAT_TIME, frame->presentation_timestamp);
+ frame->deadline =
+ gst_segment_to_running_time (&GST_BASE_VIDEO_CODEC
+ (base_video_decoder)->segment, GST_FORMAT_TIME,
+ frame->presentation_timestamp);
/* do something with frame */
ret = base_video_decoder_class->handle_frame (base_video_decoder, frame);
GstVideoState *
gst_base_video_decoder_get_state (GstBaseVideoDecoder * base_video_decoder)
{
- return &base_video_decoder->state;
+ return &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
}
gst_base_video_decoder_set_state (GstBaseVideoDecoder * base_video_decoder,
GstVideoState * state)
{
- memcpy (&base_video_decoder->state, state, sizeof (*state));
+ memcpy (&GST_BASE_VIDEO_CODEC (base_video_decoder)->state,
+ state, sizeof (*state));
}
{
GList *g;
- g = g_list_first (base_video_decoder->frames);
+ g = g_list_first (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames);
if (g == NULL)
return NULL;
{
GList *g;
- for (g = g_list_first (base_video_decoder->frames); g; g = g_list_next (g)) {
+ for (g = g_list_first (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames);
+ g; g = g_list_next (g)) {
GstVideoFrame *frame = g->data;
if (frame->system_frame_number == frame_number) {
gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder * base_video_decoder)
{
GstCaps *caps;
- GstVideoState *state = &base_video_decoder->state;
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
if (base_video_decoder->have_src_caps)
return;
{
GstFlowReturn flow_ret;
int num_bytes;
+ GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
gst_base_video_decoder_set_src_caps (base_video_decoder);
- num_bytes = gst_video_format_get_size (base_video_decoder->state.format,
- base_video_decoder->state.width, base_video_decoder->state.height);
+ num_bytes = gst_video_format_get_size (state->format, state->width,
+ state->height);
flow_ret =
gst_pad_alloc_buffer_and_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD
(base_video_decoder), GST_BUFFER_OFFSET_NONE, num_bytes,
base_video_decoder, GstVideoFrame * frame)
{
GstClockTimeDiff deadline;
+ GstClockTime earliest_time;
- if (GST_CLOCK_TIME_IS_VALID (base_video_decoder->earliest_time))
- deadline = GST_CLOCK_DIFF (base_video_decoder->earliest_time,
- frame->deadline);
+ earliest_time = GST_BASE_VIDEO_CODEC (base_video_decoder)->earliest_time;
+ if (GST_CLOCK_TIME_IS_VALID (earliest_time))
+ deadline = GST_CLOCK_DIFF (earliest_time, frame->deadline);
else
deadline = G_MAXINT64;
GstAdapter *input_adapter;
GstAdapter *output_adapter;
- GList *frames;
-
gboolean have_sync;
gboolean discont;
gboolean started;
- GstVideoState state;
- GstSegment segment;
-
gboolean sink_clipping;
guint64 presentation_frame_number;
- guint64 system_frame_number;
- GstCaps *caps;
gboolean have_src_caps;
GstVideoFrame *current_frame;
GstClockTime timestamp_offset;
- gdouble proportion;
- GstClockTime earliest_time;
-
//GstBuffer *codec_data;
guint64 input_offset;
GList *timestamps;
gboolean have_segment;
+
+ /* FIXME before moving to base */
+ void *padding[GST_PADDING_LARGE];
};
struct _GstBaseVideoDecoderClass
guint32 capture_mask;
guint32 capture_pattern;
+
+ /* FIXME before moving to base */
+ void *padding[GST_PADDING_LARGE];
};
GType gst_base_video_decoder_get_type (void);
GST_DEBUG ("setcaps");
- state = &base_video_encoder->state;
+ state = &GST_BASE_VIDEO_CODEC (base_video_encoder)->state;
structure = gst_caps_get_structure (caps, 0);
gst_video_format_parse_caps (caps, &state->format,
state->clean_offset_top = 0;
ret = base_video_encoder_class->set_format (base_video_encoder,
- &base_video_encoder->state);
+ &GST_BASE_VIDEO_CODEC (base_video_encoder)->state);
if (ret) {
ret = base_video_encoder_class->start (base_video_encoder);
}
{
GstBaseVideoEncoder *base_video_encoder;
GstBaseVideoEncoderClass *base_video_encoder_class;
- GList *g;
g_return_if_fail (GST_IS_BASE_VIDEO_ENCODER (object));
base_video_encoder = GST_BASE_VIDEO_ENCODER (object);
GST_DEBUG ("finalize");
- for (g = base_video_encoder->frames; g; g = g_list_next (g)) {
- gst_base_video_codec_free_frame ((GstVideoFrame *) g->data);
- }
- g_list_free (base_video_encoder->frames);
-
- if (base_video_encoder->caps) {
- gst_caps_unref (base_video_encoder->caps);
- base_video_encoder->caps = NULL;
- }
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
GST_DEBUG ("new segment %" GST_TIME_FORMAT " %" GST_TIME_FORMAT,
GST_TIME_ARGS (start), GST_TIME_ARGS (position));
- gst_segment_set_newsegment_full (&base_video_encoder->segment,
- update, rate, applied_rate, format, start, stop, position);
+ gst_segment_set_newsegment_full (&GST_BASE_VIDEO_CODEC
+ (base_video_encoder)->segment, update, rate, applied_rate, format,
+ start, stop, position);
ret =
gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder),
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
res =
- gst_base_video_encoded_video_convert (&enc->state, src_fmt, src_val,
- &dest_fmt, &dest_val);
+ gst_base_video_encoded_video_convert (&GST_BASE_VIDEO_CODEC
+ (enc)->state, src_fmt, src_val, &dest_fmt, &dest_val);
if (!res)
goto error;
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
gint64 clip_start;
gint64 clip_stop;
- if (!gst_segment_clip (&base_video_encoder->segment,
+ if (!gst_segment_clip (&GST_BASE_VIDEO_CODEC (base_video_encoder)->segment,
GST_FORMAT_TIME, start, stop, &clip_start, &clip_stop)) {
GST_DEBUG ("clipping to segment dropped frame");
goto done;
base_video_encoder->presentation_frame_number;
base_video_encoder->presentation_frame_number++;
- base_video_encoder->frames =
- g_list_append (base_video_encoder->frames, frame);
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->frames =
+ g_list_append (GST_BASE_VIDEO_CODEC (base_video_encoder)->frames, frame);
klass->handle_frame (base_video_encoder, frame);
base_video_encoder_class =
GST_BASE_VIDEO_ENCODER_GET_CLASS (base_video_encoder);
- frame->system_frame_number = base_video_encoder->system_frame_number;
- base_video_encoder->system_frame_number++;
+ frame->system_frame_number =
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->system_frame_number;
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->system_frame_number++;
if (frame->is_sync_point) {
base_video_encoder->distance_from_sync = 0;
frame->decode_timestamp = 0;
} else {
frame->decode_timestamp = gst_util_uint64_scale (frame->decode_frame_number,
- GST_SECOND * base_video_encoder->state.fps_d,
- base_video_encoder->state.fps_n);
+ GST_SECOND * GST_BASE_VIDEO_CODEC (base_video_encoder)->state.fps_d,
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->state.fps_n);
}
GST_BUFFER_TIMESTAMP (frame->src_buffer) = frame->presentation_timestamp;
GST_BUFFER_DURATION (frame->src_buffer) = frame->presentation_duration;
GST_BUFFER_OFFSET (frame->src_buffer) = frame->decode_timestamp;
- base_video_encoder->frames =
- g_list_remove (base_video_encoder->frames, frame);
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->frames =
+ g_list_remove (GST_BASE_VIDEO_CODEC (base_video_encoder)->frames, frame);
if (!base_video_encoder->set_output_caps) {
if (base_video_encoder_class->get_caps) {
- base_video_encoder->caps =
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->caps =
base_video_encoder_class->get_caps (base_video_encoder);
} else {
- base_video_encoder->caps = gst_caps_new_simple ("video/unknown", NULL);
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->caps =
+ gst_caps_new_simple ("video/unknown", NULL);
}
gst_pad_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder),
- base_video_encoder->caps);
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->caps);
base_video_encoder->set_output_caps = TRUE;
}
gst_buffer_set_caps (GST_BUFFER (frame->src_buffer),
- base_video_encoder->caps);
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->caps);
if (frame->force_keyframe) {
GstClockTime stream_time;
GstClockTime running_time;
GstStructure *s;
- running_time = gst_segment_to_running_time (&base_video_encoder->segment,
- GST_FORMAT_TIME, frame->presentation_timestamp);
- stream_time = gst_segment_to_stream_time (&base_video_encoder->segment,
- GST_FORMAT_TIME, frame->presentation_timestamp);
+ running_time =
+ gst_segment_to_running_time (&GST_BASE_VIDEO_CODEC
+ (base_video_encoder)->segment, GST_FORMAT_TIME,
+ frame->presentation_timestamp);
+ stream_time =
+ gst_segment_to_stream_time (&GST_BASE_VIDEO_CODEC
+ (base_video_encoder)->segment, GST_FORMAT_TIME,
+ frame->presentation_timestamp);
/* FIXME this should send the event that we got on the sink pad
instead of creating a new one */
int
gst_base_video_encoder_get_height (GstBaseVideoEncoder * base_video_encoder)
{
- return base_video_encoder->state.height;
+ return GST_BASE_VIDEO_CODEC (base_video_encoder)->state.height;
}
int
gst_base_video_encoder_get_width (GstBaseVideoEncoder * base_video_encoder)
{
- return base_video_encoder->state.width;
+ return GST_BASE_VIDEO_CODEC (base_video_encoder)->state.width;
}
const GstVideoState *
gst_base_video_encoder_get_state (GstBaseVideoEncoder * base_video_encoder)
{
- return &base_video_encoder->state;
+ return &GST_BASE_VIDEO_CODEC (base_video_encoder)->state;
}
GstFlowReturn
GstBuffer * buffer)
{
- if (base_video_encoder->frames) {
+ if (GST_BASE_VIDEO_CODEC (base_video_encoder)->frames) {
GST_WARNING ("EOS with frames left over");
}
gint64 latency;
latency = gst_util_uint64_scale (n_fields,
- base_video_encoder->state.fps_d * GST_SECOND,
- 2 * base_video_encoder->state.fps_n);
+ GST_BASE_VIDEO_CODEC (base_video_encoder)->state.fps_d * GST_SECOND,
+ 2 * GST_BASE_VIDEO_CODEC (base_video_encoder)->state.fps_n);
gst_base_video_encoder_set_latency (base_video_encoder, latency, latency);
{
GList *g;
- g = g_list_first (base_video_encoder->frames);
+ g = g_list_first (GST_BASE_VIDEO_CODEC (base_video_encoder)->frames);
if (g == NULL)
return NULL;
GstBaseVideoCodec base_video_codec;
/*< private >*/
- GList *frames;
-
- GstVideoState state;
- GstSegment segment;
-
gboolean sink_clipping;
guint64 presentation_frame_number;
- guint64 system_frame_number;
int distance_from_sync;
- GstCaps *caps;
gboolean set_output_caps;
gint64 min_latency;
gint64 max_latency;
gboolean force_keyframe;
+
+ /* FIXME before moving to base */
+ void *padding[GST_PADDING_LARGE];
};
struct _GstBaseVideoEncoderClass
GstFlowReturn (*shape_output) (GstBaseVideoEncoder *coder, GstVideoFrame *frame);
GstCaps *(*get_caps) (GstBaseVideoEncoder *coder);
+ /* FIXME before moving to base */
+ void *padding[GST_PADDING_LARGE];
};
GType gst_base_video_encoder_get_type (void);