• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __GST_FFMPEG_UTILS_H__
21 #define __GST_FFMPEG_UTILS_H__
22 
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26 
27 #include <libavcodec/avcodec.h>
28 #include <libavutil/mathematics.h>
29 
30 #include <gst/gst.h>
31 
32 /*
33  *Get the size of an picture
34  */
35 int
36 gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height);
37 
38 /*
39  * Fill in pointers in an AVFrame, aligned by 4 (required by X).
40  */
41 
42 int
43 gst_ffmpeg_avpicture_fill (AVFrame * picture,
44                            uint8_t *   ptr,
45                            enum AVPixelFormat pix_fmt,
46                            int         width,
47                            int         height);
48 
49 /*
50  * Convert from/to a GStreamer <-> FFMpeg timestamp.
51  */
52 static inline guint64
gst_ffmpeg_time_ff_to_gst(gint64 pts,AVRational base)53 gst_ffmpeg_time_ff_to_gst (gint64 pts, AVRational base)
54 {
55   guint64 out;
56 
57   if (pts == AV_NOPTS_VALUE){
58     out = GST_CLOCK_TIME_NONE;
59   } else {
60     AVRational bq = { 1, GST_SECOND };
61     out = av_rescale_q (pts, base, bq);
62   }
63 
64   return out;
65 }
66 
67 static inline gint64
gst_ffmpeg_time_gst_to_ff(guint64 time,AVRational base)68 gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
69 {
70   gint64 out;
71 
72   if (!GST_CLOCK_TIME_IS_VALID (time) || base.num == 0) {
73     out = AV_NOPTS_VALUE;
74   } else {
75     AVRational bq = { 1, GST_SECOND };
76     out = av_rescale_q (time, bq, base);
77   }
78 
79   return out;
80 }
81 
82 void
83 gst_ffmpeg_init_pix_fmt_info(void);
84 
85 int
86 gst_ffmpeg_auto_max_threads(void);
87 
88 const gchar *
89 gst_ffmpeg_get_codecid_longname (enum AVCodecID codec_id);
90 
91 gint
92 av_smp_format_depth(enum AVSampleFormat smp_fmt);
93 
94 GstBuffer *
95 new_aligned_buffer (gint size);
96 
97 #endif /* __GST_FFMPEG_UTILS_H__ */
98