Initialize Tizen 2.3
[framework/multimedia/gstreamer0.10-ffmpeg.git] / ext / ffmpeg / gstffmpegutils.h
1 /* GStreamer
2  * Copyright (C) <2009> Edward Hervey <bilboed@bilboed.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GST_FFMPEG_UTILS_H__
21 #define __GST_FFMPEG_UTILS_H__
22
23 #ifdef HAVE_FFMPEG_UNINSTALLED
24 #include <avcodec.h>
25 #else
26 #include <libavcodec/avcodec.h>
27 #endif
28 #include <gst/gst.h>
29
30 /*
31  *Get the size of an picture
32  */
33 int
34 gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height);
35
36 /*
37  * Fill in pointers in an AVPicture, aligned by 4 (required by X).
38  */
39
40 int
41 gst_ffmpeg_avpicture_fill (AVPicture * picture,
42                            uint8_t *   ptr,
43                            enum PixelFormat pix_fmt,
44                            int         width,
45                            int         height);
46
47 /*
48  * Convert from/to a GStreamer <-> FFMpeg timestamp.
49  */
50 static inline guint64
51 gst_ffmpeg_time_ff_to_gst (gint64 pts, AVRational base)
52 {
53   guint64 out;
54
55   if (pts == AV_NOPTS_VALUE){
56     out = GST_CLOCK_TIME_NONE;
57   } else {
58     AVRational bq = { 1, GST_SECOND };
59     out = av_rescale_q (pts, base, bq);
60   }
61
62   return out;
63 }
64
65 static inline gint64
66 gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
67 {
68   gint64 out;
69
70   if (!GST_CLOCK_TIME_IS_VALID (time) || base.num == 0) {
71     out = AV_NOPTS_VALUE;
72   } else {
73     AVRational bq = { 1, GST_SECOND };
74     out = av_rescale_q (time, bq, base);
75   }
76
77   return out;
78 }
79
80 void 
81 gst_ffmpeg_init_pix_fmt_info(void);
82
83
84 G_CONST_RETURN gchar *
85 gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
86
87 gint
88 av_smp_format_depth(enum SampleFormat smp_fmt);
89
90 GstBuffer *
91 new_aligned_buffer (gint size, GstCaps * caps);
92
93 #endif /* __GST_FFMPEG_UTILS_H__ */