1
/*****************************************************************
2
* gmerlin-encoders - encoder plugins for gmerlin
4
* Copyright (c) 2001 - 2011 Members of the Gmerlin project
5
* gmerlin-general@lists.sourceforge.net
6
* http://gmerlin.sourceforge.net
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
* *****************************************************************/
25
#include <gmerlin_encoders.h>
27
#include <gmerlin/plugin.h>
28
#include <gmerlin/utils.h>
29
#include <gmerlin/translation.h>
31
#include <theora/theora.h>
33
#include "ogg_common.h"
35
extern const bg_ogg_codec_t bg_theora_codec;
36
extern const bg_ogg_codec_t bg_vorbis_codec;
39
extern const bg_ogg_codec_t bg_speex_codec;
43
extern const bg_ogg_codec_t bg_flacogg_codec;
46
static bg_ogg_codec_t const * const audio_codecs[] =
59
static const bg_parameter_info_t * get_audio_parameters_theora(void * data)
61
return bg_ogg_encoder_get_audio_parameters(data, audio_codecs);
64
static const bg_parameter_info_t * get_video_parameters_theora(void * data)
66
return bg_theora_codec.get_parameters();
69
static int add_audio_stream_theora(void * data,
70
const char * language,
71
const gavl_audio_format_t * format)
74
ret = bg_ogg_encoder_add_audio_stream(data, format);
78
static int add_audio_stream_compressed_theora(void * data,
79
const char * language,
80
const gavl_audio_format_t * format,
81
const gavl_compression_info_t * ci)
84
ret = bg_ogg_encoder_add_audio_stream_compressed(data, format, ci);
85
if(ci->id == GAVL_CODEC_ID_VORBIS)
86
bg_ogg_encoder_init_audio_stream(data, ret, &bg_vorbis_codec);
90
static int add_video_stream_theora(void * data, const gavl_video_format_t * format)
93
ret = bg_ogg_encoder_add_video_stream(data, format);
94
bg_ogg_encoder_init_video_stream(data, ret, &bg_theora_codec);
98
static int add_video_stream_compressed_theora(void * data,
99
const gavl_video_format_t * format,
100
const gavl_compression_info_t * ci)
103
ret = bg_ogg_encoder_add_video_stream_compressed(data, format, ci);
104
bg_ogg_encoder_init_video_stream(data, ret, &bg_theora_codec);
109
static void set_audio_parameter_theora(void * data, int stream,
110
const char * name, const bg_parameter_value_t * val)
115
if(!strcmp(name, "codec"))
119
while(audio_codecs[i])
121
if(!strcmp(audio_codecs[i]->name, val->val_str))
123
bg_ogg_encoder_init_audio_stream(data, stream, audio_codecs[i]);
130
bg_ogg_encoder_set_audio_parameter(data, stream, name, val);
134
open_theora(void * data, const char * file,
135
const bg_metadata_t * metadata, const bg_chapter_list_t * chapter_list)
137
return bg_ogg_encoder_open(data, file, metadata, chapter_list,
141
static int writes_compressed_audio_theora(void* data,
142
const gavl_audio_format_t * format,
143
const gavl_compression_info_t * ci)
145
if(ci->id == GAVL_CODEC_ID_VORBIS)
151
static int writes_compressed_video_theora(void * data,
152
const gavl_video_format_t * format,
153
const gavl_compression_info_t * ci)
155
if(ci->id == GAVL_CODEC_ID_THEORA)
161
const bg_encoder_plugin_t the_plugin =
166
.name = "e_theora", /* Unique short name */
167
.long_name = TRS("Theora encoder"),
168
.description = TRS("Encoder for Theora files. Audio can be Vorbis, Flac or Speex."),
169
.type = BG_PLUGIN_ENCODER,
170
.flags = BG_PLUGIN_FILE,
172
.create = bg_ogg_encoder_create,
173
.destroy = bg_ogg_encoder_destroy,
175
.get_parameters = get_parameters_theora,
176
.set_parameter = set_parameter_theora,
179
.max_audio_streams = -1,
180
.max_video_streams = -1,
182
.set_callbacks = bg_ogg_encoder_set_callbacks,
183
.writes_compressed_audio = writes_compressed_audio_theora,
184
.writes_compressed_video = writes_compressed_video_theora,
188
.get_audio_parameters = get_audio_parameters_theora,
189
.get_video_parameters = get_video_parameters_theora,
191
.add_audio_stream = add_audio_stream_theora,
192
.add_video_stream = add_video_stream_theora,
194
.add_audio_stream_compressed = add_audio_stream_compressed_theora,
195
.add_video_stream_compressed = add_video_stream_compressed_theora,
197
.set_audio_parameter = set_audio_parameter_theora,
198
.set_video_parameter = bg_ogg_encoder_set_video_parameter,
199
.set_video_pass = bg_ogg_encoder_set_video_pass,
201
.start = bg_ogg_encoder_start,
203
.get_audio_format = bg_ogg_encoder_get_audio_format,
204
.get_video_format = bg_ogg_encoder_get_video_format,
206
.write_audio_frame = bg_ogg_encoder_write_audio_frame,
207
.write_video_frame = bg_ogg_encoder_write_video_frame,
209
.write_audio_packet = bg_ogg_encoder_write_audio_packet,
210
.write_video_packet = bg_ogg_encoder_write_video_packet,
212
.close = bg_ogg_encoder_close,
215
/* Include this into all plugin modules exactly once
216
to let the plugin loader obtain the API version */
217
BG_GET_PLUGIN_API_VERSION;