1 /*
2 * encode_copy.c -- passthrough A/V frames through deep copy.
3 * (C) 2005-2010 Francesco Romani <fromani at gmail dot com>
4 *
5 * This file is part of transcode, a video stream processing tool.
6 *
7 * transcode is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * transcode is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22 #include "transcode.h"
23 #include "framebuffer.h"
24 #include "libtc/optstr.h"
25
26 #include "libtc/tcmodule-plugin.h"
27
28 #define MOD_NAME "encode_copy.so"
29 #define MOD_VERSION "v0.0.4 (2007-11-18)"
30 #define MOD_CAP "copy (passthrough) A/V frames"
31
32 #define MOD_FEATURES \
33 TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_VIDEO|TC_MODULE_FEATURE_AUDIO
34
35 #define MOD_FLAGS \
36 TC_MODULE_FLAG_RECONFIGURABLE
37
38 static const char copy_help[] = ""
39 "Overview:\n"
40 " this module passthrough A/V frames copying them from input\n"
41 " to output.\n"
42 " For a faster passthrough consider usage of 'null' module.\n"
43 "Options:\n"
44 " help produce module overview and options explanations\n";
45
46
copy_init(TCModuleInstance * self,uint32_t features)47 static int copy_init(TCModuleInstance *self, uint32_t features)
48 {
49 TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
50
51 if (self == NULL) {
52 tc_log_error(MOD_NAME, "init: bad instance data reference");
53 return TC_ERROR;
54 }
55
56 if (verbose) {
57 tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
58 }
59 self->userdata = NULL;
60
61 return TC_OK;
62 }
63
copy_fini(TCModuleInstance * self)64 static int copy_fini(TCModuleInstance *self)
65 {
66 TC_MODULE_SELF_CHECK(self, "fini");
67
68 return TC_OK;
69 }
70
copy_inspect(TCModuleInstance * self,const char * param,const char ** value)71 static int copy_inspect(TCModuleInstance *self,
72 const char *param, const char **value)
73 {
74 TC_MODULE_SELF_CHECK(self, "inspect");
75
76 if (optstr_lookup(param, "help")) {
77 *value = copy_help;
78 }
79
80 return TC_OK;
81 }
82
copy_configure(TCModuleInstance * self,const char * options,vob_t * vob)83 static int copy_configure(TCModuleInstance *self,
84 const char *options, vob_t *vob)
85 {
86 TC_MODULE_SELF_CHECK(self, "configure");
87
88 return TC_OK;
89 }
90
copy_stop(TCModuleInstance * self)91 static int copy_stop(TCModuleInstance *self)
92 {
93 TC_MODULE_SELF_CHECK(self, "stop");
94
95 return TC_OK;
96 }
97
copy_encode_video(TCModuleInstance * self,vframe_list_t * inframe,vframe_list_t * outframe)98 static int copy_encode_video(TCModuleInstance *self,
99 vframe_list_t *inframe, vframe_list_t *outframe)
100 {
101 TC_MODULE_SELF_CHECK(self, "encode_video");
102
103 if (inframe == NULL) {
104 outframe->video_len = 0;
105 } else {
106 vframe_copy(outframe, inframe, 1);
107 outframe->video_len = outframe->video_size;
108 }
109 return TC_OK;
110 }
111
copy_encode_audio(TCModuleInstance * self,aframe_list_t * inframe,aframe_list_t * outframe)112 static int copy_encode_audio(TCModuleInstance *self,
113 aframe_list_t *inframe, aframe_list_t *outframe)
114 {
115 TC_MODULE_SELF_CHECK(self, "encode_audio");
116
117 if (inframe == NULL) {
118 outframe->audio_len = 0;
119 } else {
120 aframe_copy(outframe, inframe, 1);
121 outframe->audio_len = outframe->audio_size;
122 }
123 return TC_OK;
124 }
125
126
127 /*************************************************************************/
128
129 static const uint32_t copy_codecs_in[] = { TC_CODEC_ANY, TC_CODEC_ERROR };
130 static const uint32_t copy_codecs_out[] = { TC_CODEC_ANY, TC_CODEC_ERROR };
131 TC_MODULE_CODEC_FORMATS(copy);
132
133 TC_MODULE_INFO(copy);
134
135 static const TCModuleClass copy_class = {
136 TC_MODULE_CLASS_HEAD(copy),
137
138 .init = copy_init,
139 .fini = copy_fini,
140 .configure = copy_configure,
141 .stop = copy_stop,
142 .inspect = copy_inspect,
143
144 .encode_video = copy_encode_video,
145 .encode_audio = copy_encode_audio,
146 };
147
148 TC_MODULE_ENTRY_POINT(copy);
149
150 /*************************************************************************/
151
152 /*
153 * Local variables:
154 * c-file-style: "stroustrup"
155 * c-file-offsets: ((case-label . *) (statement-case-intro . *))
156 * indent-tabs-mode: nil
157 * End:
158 *
159 * vim: expandtab shiftwidth=4:
160 */
161