• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012, Collabora Ltd.
3  *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation
8  * version 2.1 of the License.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
18  *
19  */
20 
21 #ifndef __GST_AMC_H__
22 #define __GST_AMC_H__
23 
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26 #include <gst/audio/audio.h>
27 #include "gstamc-codec.h"
28 #include "gstamc-codeclist.h"
29 #include "gstamc-format.h"
30 
31 G_BEGIN_DECLS
32 
33 typedef struct _GstAmcCodecType GstAmcCodecType;
34 typedef struct _GstAmcCodecInfo GstAmcCodecInfo;
35 
36 struct _GstAmcCodecType {
37   gchar *mime;
38 
39   gint *color_formats;
40   gsize n_color_formats;
41 
42   GstAmcCodecProfileLevel * profile_levels;
43   gsize n_profile_levels;
44 };
45 
46 struct _GstAmcCodecInfo {
47   gchar *name;
48   gboolean is_encoder;
49   gboolean gl_output_only;
50   GstAmcCodecType *supported_types;
51   gint n_supported_types;
52 };
53 
54 extern GQuark gst_amc_codec_info_quark;
55 
56 GstVideoFormat gst_amc_color_format_to_video_format (const GstAmcCodecInfo * codec_info, const gchar * mime, gint color_format);
57 gint gst_amc_video_format_to_color_format (const GstAmcCodecInfo * codec_info, const gchar * mime, GstVideoFormat video_format);
58 
59 struct _GstAmcColorFormatInfo {
60   gint color_format;
61   gint width, height, stride, slice_height;
62   gint crop_left, crop_right;
63   gint crop_top, crop_bottom;
64   gint frame_size;
65 };
66 
67 gboolean gst_amc_color_format_info_set (GstAmcColorFormatInfo * color_format_info,
68     const GstAmcCodecInfo * codec_info, const gchar * mime,
69     gint color_format, gint width, gint height, gint stride, gint slice_height,
70     gint crop_left, gint crop_right, gint crop_top, gint crop_bottom);
71 
72 typedef enum
73 {
74   COLOR_FORMAT_COPY_OUT,
75   COLOR_FORMAT_COPY_IN
76 } GstAmcColorFormatCopyDirection;
77 
78 gboolean gst_amc_color_format_copy (
79     GstAmcColorFormatInfo * cinfo, GstAmcBuffer * cbuffer, const GstAmcBufferInfo * cbuffer_info,
80     GstVideoInfo * vinfo, GstBuffer * vbuffer, GstAmcColorFormatCopyDirection direction);
81 
82 const gchar * gst_amc_avc_profile_to_string (gint profile, const gchar **alternative);
83 gint gst_amc_avc_profile_from_string (const gchar *profile);
84 const gchar * gst_amc_avc_level_to_string (gint level);
85 gint gst_amc_avc_level_from_string (const gchar *level);
86 const gchar * gst_amc_hevc_profile_to_string (gint profile);
87 gint gst_amc_hevc_profile_from_string (const gchar *profile);
88 const gchar * gst_amc_hevc_tier_level_to_string (gint tier_level, const gchar ** tier);
89 gint gst_amc_hevc_tier_level_from_string (const gchar * tier, const gchar *level);
90 gint gst_amc_h263_profile_to_gst_id (gint profile);
91 gint gst_amc_h263_profile_from_gst_id (gint profile);
92 gint gst_amc_h263_level_to_gst_id (gint level);
93 gint gst_amc_h263_level_from_gst_id (gint level);
94 const gchar * gst_amc_mpeg4_profile_to_string (gint profile);
95 gint gst_amc_mpeg4_profile_from_string (const gchar *profile);
96 const gchar * gst_amc_mpeg4_level_to_string (gint level);
97 gint gst_amc_mpeg4_level_from_string (const gchar *level);
98 const gchar * gst_amc_aac_profile_to_string (gint profile);
99 gint gst_amc_aac_profile_from_string (const gchar *profile);
100 
101 gboolean gst_amc_audio_channel_mask_to_positions (guint32 channel_mask, gint channels, GstAudioChannelPosition *pos);
102 guint32 gst_amc_audio_channel_mask_from_positions (GstAudioChannelPosition *positions, gint channels);
103 void gst_amc_codec_info_to_caps (const GstAmcCodecInfo * codec_info, GstCaps **sink_caps, GstCaps **src_caps);
104 
105 #define GST_ELEMENT_ERROR_FROM_ERROR(el, err) G_STMT_START {            \
106   gchar *__dbg;                                                         \
107   g_assert (err != NULL);                                               \
108   __dbg = g_strdup (err->message);                                      \
109   GST_WARNING_OBJECT (el, "error: %s", __dbg);                          \
110   gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR,         \
111     err->domain, err->code,                                             \
112     NULL, __dbg, __FILE__, GST_FUNCTION, __LINE__);                     \
113   g_clear_error (&err); \
114 } G_STMT_END
115 
116 #define GST_ELEMENT_WARNING_FROM_ERROR(el, err) G_STMT_START {          \
117   gchar *__dbg;                                                         \
118   g_assert (err != NULL);                                               \
119   __dbg = g_strdup (err->message);                                      \
120   GST_WARNING_OBJECT (el, "error: %s", __dbg);                          \
121   gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING,       \
122     err->domain, err->code,                                             \
123     NULL, __dbg, __FILE__, GST_FUNCTION, __LINE__);                     \
124   g_clear_error (&err); \
125 } G_STMT_END
126 
127 GST_DEBUG_CATEGORY_EXTERN (gst_amc_debug);
128 
129 G_END_DECLS
130 
131 #endif /* __GST_AMC_H__ */
132