Use AV_ namespace for all CODEC_ macro
[platform/upstream/gstreamer.git] / ext / libav / gstavcodecmap.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
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_CODECMAP_H__
21 #define __GST_FFMPEG_CODECMAP_H__
22
23 #include <libavcodec/avcodec.h>
24 #include <gst/gst.h>
25 #include <gst/audio/audio.h>
26 #include <gst/video/video.h>
27
28 /**
29  * GstFFMpegCompliance:
30  * @GST_FFMPEG_VERY_STRICT: Strictly conform to an older
31  * more strict version of the spec or reference software
32  * @GST_FFMPEG_STRICT: Strictly conform to all the things
33  * in the spec no matter what consequences.
34  * @GST_FFMPEG_NORMAL:
35  * @GST_FFMPEG_UNOFFICIAL: Allow unofficial extensions
36  * @GST_FFMPEG_EXPERIMENTAL: Allow nonstandardized
37  * experimental things.
38  *
39  * This setting instructs libav on how strictly it should follow the
40  * associated standard.
41  *
42  * From avcodec.h:
43  * Setting this to STRICT or higher means the encoder and decoder will
44  * generally do stupid things, whereas setting it to unofficial or lower
45  * will mean the encoder might produce output that is not supported by all
46  * spec-compliant decoders. Decoders don't differentiate between normal,
47  * unofficial and experimental (that is, they always try to decode things
48  * when they can) unless they are explicitly asked to behave stupidly
49  * (=strictly conform to the specs)
50  */
51 typedef enum {
52   GST_FFMPEG_VERY_STRICT = FF_COMPLIANCE_VERY_STRICT,
53   GST_FFMPEG_STRICT = FF_COMPLIANCE_STRICT,
54   GST_FFMPEG_NORMAL = FF_COMPLIANCE_NORMAL,
55   GST_FFMPEG_UNOFFICIAL = FF_COMPLIANCE_UNOFFICIAL,
56   GST_FFMPEG_EXPERIMENTAL = FF_COMPLIANCE_EXPERIMENTAL,
57 } GstFFMpegCompliance;
58
59 /*
60  * _compliance_get_type () Returns an enum type that can be
61  * used as a property to indicate desired FFMpeg adherence to
62  * an associated specification
63  */
64
65 GType
66 gst_ffmpeg_compliance_get_type (void);
67 #define GST_TYPE_FFMPEG_COMPLIANCE (gst_ffmpeg_compliance_get_type ())
68 #define FFMPEG_DEFAULT_COMPLIANCE GST_FFMPEG_NORMAL
69
70 /*
71  * _codecid_is_image() returns TRUE for image formats
72  */
73 gboolean
74 gst_ffmpeg_codecid_is_image (enum AVCodecID codec_id);
75
76 /*
77  * _codecid_to_caps () gets the GstCaps that belongs to
78  * a certain CodecID for a pad with compressed data.
79  */
80
81 GstCaps *
82 gst_ffmpeg_codecid_to_caps   (enum AVCodecID    codec_id,
83                               AVCodecContext *context,
84                               gboolean        encode);
85
86 /*
87  * _codectype_to_caps () gets the GstCaps that belongs to
88  * a certain AVMediaType for a pad with uncompressed data.
89  */
90
91 GstCaps *
92 gst_ffmpeg_codectype_to_audio_caps (AVCodecContext *context, 
93                               enum AVCodecID codec_id,
94                                     gboolean encode,
95                                     AVCodec *codec);
96 GstCaps *
97 gst_ffmpeg_codectype_to_video_caps (AVCodecContext *context, 
98                               enum AVCodecID codec_id,
99                                     gboolean encode,
100                                     AVCodec *codec);
101
102 /*
103  * caps_to_codecid () transforms a GstCaps that belongs to
104  * a pad for compressed data to (optionally) a filled-in
105  * context and a codecID.
106  */
107
108 enum AVCodecID
109 gst_ffmpeg_caps_to_codecid (const GstCaps  *caps,
110                             AVCodecContext *context);
111
112 /*
113  * caps_with_codecid () transforms a GstCaps for a known codec
114  * ID into a filled-in context.
115  */
116
117 void
118 gst_ffmpeg_caps_with_codecid (enum AVCodecID    codec_id,
119                               enum AVMediaType  codec_type,
120                               const GstCaps  *caps,
121                               AVCodecContext *context);
122
123 /*
124  * caps_with_codectype () transforms a GstCaps that belongs to
125  * a pad for uncompressed data to a filled-in context.
126  */
127
128 void
129 gst_ffmpeg_caps_with_codectype (enum AVMediaType  type,
130                                 const GstCaps  *caps,
131                                 AVCodecContext *context);
132
133 void
134 gst_ffmpeg_videoinfo_to_context (GstVideoInfo *info,
135                                  AVCodecContext *context);
136
137 void
138 gst_ffmpeg_audioinfo_to_context (GstAudioInfo *info,
139                                  AVCodecContext *context);
140
141 GstVideoFormat gst_ffmpeg_pixfmt_to_videoformat (enum AVPixelFormat pixfmt);
142 enum AVPixelFormat gst_ffmpeg_videoformat_to_pixfmt (GstVideoFormat format);
143
144 GstAudioFormat gst_ffmpeg_smpfmt_to_audioformat (enum AVSampleFormat sample_fmt);
145
146 /*
147  * _formatid_to_caps () is meant for muxers/demuxers, it
148  * transforms a name (ffmpeg way of ID'ing these, why don't
149  * they have unique numerical IDs?) to the corresponding
150  * caps belonging to that mux-format
151  */
152
153 GstCaps *
154 gst_ffmpeg_formatid_to_caps (const gchar *format_name);
155
156 /*
157  * _formatid_get_codecids () can be used to get the codecIDs
158  * (AV_CODEC_ID_NONE-terminated list) that fit that specific
159  * output format.
160  */
161
162 gboolean
163 gst_ffmpeg_formatid_get_codecids (const gchar *format_name,
164                                   enum AVCodecID ** video_codec_list,
165                                   enum AVCodecID ** audio_codec_list,
166                                   AVOutputFormat * plugin);
167
168
169 gboolean
170 gst_ffmpeg_channel_layout_to_gst (guint64 channel_layout, gint channels,
171     GstAudioChannelPosition * pos);
172
173 #endif /* __GST_FFMPEG_CODECMAP_H__ */