GST_DEBUG_OBJECT (base_video_decoder, "sink query fps=%d/%d",
base_video_decoder->state.fps_n, base_video_decoder->state.fps_d);
switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_CONVERT:
- {
- GstFormat src_fmt, dest_fmt;
- 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);
- if (!res)
- goto error;
- gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
- break;
- }
default:
res = gst_pad_query_default (pad, query);
break;
#define GST_CAT_DEFAULT basevideocodec_debug
-#if 0
-guint64
-gst_base_video_convert_bytes_to_frames (GstVideoState * state, guint64 bytes)
-{
- return gst_util_uint64_scale_int (bytes, 1, state->bytes_per_picture);
-}
-
-guint64
-gst_base_video_convert_frames_to_bytes (GstVideoState * state, guint64 frames)
-{
- return frames * state->bytes_per_picture;
-}
-#endif
-
-
-gboolean
-gst_base_video_rawvideo_convert (GstVideoState * state,
- GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 * dest_value)
-{
- gboolean res = FALSE;
-
- if (src_format == *dest_format) {
- *dest_value = src_value;
- return TRUE;
- }
-
- if (src_format == GST_FORMAT_BYTES &&
- *dest_format == GST_FORMAT_DEFAULT && state->bytes_per_picture != 0) {
- /* convert bytes to frames */
- *dest_value = gst_util_uint64_scale_int (src_value, 1,
- state->bytes_per_picture);
- res = TRUE;
- } else if (src_format == GST_FORMAT_DEFAULT &&
- *dest_format == GST_FORMAT_BYTES && state->bytes_per_picture != 0) {
- /* convert bytes to frames */
- *dest_value = src_value * state->bytes_per_picture;
- res = TRUE;
- } else if (src_format == GST_FORMAT_DEFAULT &&
- *dest_format == GST_FORMAT_TIME && state->fps_n != 0) {
- /* convert frames to time */
- /* FIXME add segment time? */
- *dest_value = gst_util_uint64_scale (src_value,
- GST_SECOND * state->fps_d, state->fps_n);
- res = TRUE;
- } else if (src_format == GST_FORMAT_TIME &&
- *dest_format == GST_FORMAT_DEFAULT && state->fps_d != 0) {
- /* convert time to frames */
- /* FIXME subtract segment time? */
- *dest_value = gst_util_uint64_scale (src_value, state->fps_n,
- GST_SECOND * state->fps_d);
- res = TRUE;
- }
-
- /* FIXME add bytes <--> time */
-
- return res;
-}
-
-gboolean
-gst_base_video_encoded_video_convert (GstVideoState * state,
- GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 * dest_value)
-{
- gboolean res = FALSE;
-
- if (src_format == *dest_format) {
- *dest_value = src_value;
- return TRUE;
- }
-
- GST_DEBUG ("src convert");
-
-#if 0
- if (src_format == GST_FORMAT_DEFAULT && *dest_format == GST_FORMAT_TIME) {
- if (dec->fps_d != 0) {
- *dest_value = gst_util_uint64_scale (granulepos_to_frame (src_value),
- dec->fps_d * GST_SECOND, dec->fps_n);
- res = TRUE;
- } else {
- res = FALSE;
- }
- } else {
- GST_WARNING ("unhandled conversion from %d to %d", src_format,
- *dest_format);
- res = FALSE;
- }
-#endif
-
- return res;
-}
-
GstClockTime
gst_video_state_get_timestamp (const GstVideoState * state,
GstSegment * segment, int frame_number)
struct _GstVideoState
{
- GstVideoFormat format;
int width, height;
int fps_n, fps_d;
int par_n, par_d;
void *coder_hook;
};
-gboolean gst_base_video_rawvideo_convert (GstVideoState *state,
- GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 *dest_value);
-gboolean gst_base_video_encoded_video_convert (GstVideoState *state,
- GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 *dest_value);
-
GstClockTime gst_video_state_get_timestamp (const GstVideoState *state,
GstSegment *segment, int frame_number);
-int gst_adapter_masked_scan_uint32_compat (GstAdapter *adapter,
- guint32 pattern, guint32 mask, guint offset, guint n);
-GstBuffer *gst_adapter_get_buffer (GstAdapter *adapter);
-
G_END_DECLS
#endif