summaryrefslogtreecommitdiffstats
path: root/tinyMEDIA/include/tinymedia/tmedia_converter_video.h
blob: 133dfab7f9f68b4395d5191b4de3652836fc0da0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
*
* This file is part of Open Source Doubango Framework.
* 
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/

/**@file tmedia_converter_video.h
 * @brief Video converter plugin (chroma, rotation, scaling, ...)
 *
 * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
 *
 */
#ifndef TINYMEDIA_CONVERTER_VIDEO_H
#define TINYMEDIA_CONVERTER_VIDEO_H

#include "tinymedia_config.h"
#include "tmedia_common.h"

TMEDIA_BEGIN_DECLS

/** cast any pointer to @ref tmedia_converter_video_t* object */
#define TMEDIA_CONVERTER_VIDEO(self)		((tmedia_converter_video_t*)(self))

/**Max number of plugins (consumer types) we can create */
#if !defined(TMED_CONVERTER_VIDEO_MAX_PLUGINS)
#	define TMED_CONVERTER_VIDEO_MAX_PLUGINS			0x0F
#endif

typedef struct tmedia_converter_video_s
{
	TSK_DECLARE_OBJECT;
	
	tsk_size_t srcWidth;
	tsk_size_t srcHeight;

	tsk_size_t dstWidth;
	tsk_size_t dstHeight;

	tmedia_chroma_t srcChroma;
	tmedia_chroma_t dstChroma;

	// one shot parameters
	int rotation;
	tsk_bool_t flip;
	tsk_bool_t mirror;
	tsk_bool_t scale_rotated_frames;

	const struct tmedia_converter_video_plugin_def_s* plugin;
}
tmedia_converter_video_t;

#define TMEDIA_DECLARE_CONVERTER_VIDEO tmedia_converter_video_t __converter__

#define tmedia_converter_video_set(self, _rotation, _flip, _mirror, _scale_rotated_frames) \
	if((self)){ \
		(self)->rotation  = (_rotation); \
		(self)->flip  = (_flip); \
		(self)->mirror  = (_mirror); \
		(self)->scale_rotated_frames  = (_scale_rotated_frames); \
	}
#define tmedia_converter_video_set_rotation(self, _rotation) \
	if((self)){ \
		(self)->rotation  = (_rotation); \
	}
#define tmedia_converter_video_set_flip(self, _flip) \
	if((self)){ \
		(self)->flip  = (_flip); \
	}
#define tmedia_converter_video_set_mirror(self, _mirror) \
	if((self)){ \
		(self)->mirror  = (_mirror); \
	}
#define tmedia_converter_video_set_scale_rotated_frames(self, _scale_rotated_frames) \
	if((self)){ \
		(self)->scale_rotated_frames  = (_scale_rotated_frames); \
	}

#define tmedia_converter_video_process(_self, _buffer, _size, _output, _output_max_size) \
	(_self)->plugin->process((_self), (_buffer), (_size), (_output), (_output_max_size))

/** Virtual table used to define a consumer plugin */
typedef struct tmedia_converter_video_plugin_def_s
{
	//! object definition used to create an instance of the converter
	const tsk_object_def_t* objdef;

	int (* init) ( struct tmedia_converter_video_s* self, tsk_size_t srcWidth, tsk_size_t srcHeight, tmedia_chroma_t srcChroma, tsk_size_t dstWidth, tsk_size_t dstHeight, tmedia_chroma_t dstChroma );
	tsk_size_t (* process) ( struct tmedia_converter_video_s* self, const void* buffer, tsk_size_t buffer_size, void** output, tsk_size_t* output_max_size );
}
tmedia_converter_video_plugin_def_t;

TINYMEDIA_API tmedia_converter_video_t* tmedia_converter_video_create(tsk_size_t srcWidth, tsk_size_t srcHeight, tmedia_chroma_t srcChroma, tsk_size_t dstWidth, tsk_size_t dstHeight, tmedia_chroma_t dstChroma);

TINYMEDIA_API int tmedia_converter_video_plugin_register(const tmedia_converter_video_plugin_def_t* plugin);
TINYMEDIA_API tsk_size_t tmedia_converter_video_plugin_registry_count();
TINYMEDIA_API int tmedia_converter_video_plugin_unregister(const tmedia_converter_video_plugin_def_t* plugin);

TMEDIA_END_DECLS

#endif /* TINYMEDIA_CONVERTER_VIDEO_H */
OpenPOWER on IntegriCloud