author | Vittorio Giovara <vittorio.giovara@gmail.com> |
Tue, 10 Nov 2015 13:53:14 +0100 | |
branch | 0.9.22 |
changeset 11601 | ba7e67586fcd |
parent 11600 | 9a17a39eccdc |
child 11602 | 4575b6990348 |
permissions | -rw-r--r-- |
7542
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
1 |
/* |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
7542
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
4 |
* |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
8 |
* |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
12 |
* GNU General Public License for more details. |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
13 |
* |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
7542
37ef1891efe2
Insert license in avwrapper.c
Stepan777 <stepik-777@mail.ru>
parents:
7376
diff
changeset
|
17 |
*/ |
7180 | 18 |
|
19 |
#include <stdlib.h> |
|
20 |
#include <stdio.h> |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
21 |
#include <stdint.h> |
7180 | 22 |
#include <string.h> |
23 |
#include <stdarg.h> |
|
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
24 |
|
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
25 |
#include "libavcodec/avcodec.h" |
7180 | 26 |
#include "libavformat/avformat.h" |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
27 |
#include "libavutil/avutil.h" |
8065 | 28 |
#include "libavutil/mathematics.h" |
7180 | 29 |
|
9203
bcc25cb9b122
and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents:
9080
diff
changeset
|
30 |
#if (defined _MSC_VER) |
bcc25cb9b122
and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents:
9080
diff
changeset
|
31 |
#define AVWRAP_DECL __declspec(dllexport) |
bcc25cb9b122
and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents:
9080
diff
changeset
|
32 |
#elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun)) |
bcc25cb9b122
and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents:
9080
diff
changeset
|
33 |
#define AVWRAP_DECL __attribute__((visibility("default"))) |
bcc25cb9b122
and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents:
9080
diff
changeset
|
34 |
#else |
bcc25cb9b122
and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents:
9080
diff
changeset
|
35 |
#define AVWRAP_DECL |
bcc25cb9b122
and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents:
9080
diff
changeset
|
36 |
#endif |
bcc25cb9b122
and now also avwrapper can be shared/static, add visibility to its exported functions, drop (needed only when static)
koda
parents:
9080
diff
changeset
|
37 |
|
7180 | 38 |
static AVFormatContext* g_pContainer; |
39 |
static AVOutputFormat* g_pFormat; |
|
40 |
static AVStream* g_pAStream; |
|
41 |
static AVStream* g_pVStream; |
|
42 |
static AVFrame* g_pAFrame; |
|
43 |
static AVFrame* g_pVFrame; |
|
44 |
static AVCodec* g_pACodec; |
|
45 |
static AVCodec* g_pVCodec; |
|
46 |
static AVCodecContext* g_pAudio; |
|
47 |
static AVCodecContext* g_pVideo; |
|
48 |
||
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
49 |
static int g_Width, g_Height; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
50 |
static uint32_t g_Frequency, g_Channels; |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
51 |
static int g_VQuality; |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
52 |
static AVRational g_Framerate; |
7180 | 53 |
|
54 |
static FILE* g_pSoundFile; |
|
55 |
static int16_t* g_pSamples; |
|
56 |
static int g_NumSamples; |
|
57 |
||
58 |
||
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
59 |
// compatibility section |
7180 | 60 |
#if LIBAVCODEC_VERSION_MAJOR < 54 |
61 |
#define OUTBUFFER_SIZE 200000 |
|
62 |
static uint8_t g_OutBuffer[OUTBUFFER_SIZE]; |
|
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
63 |
#define avcodec_open2(x, y, z) avcodec_open(x, y) |
7180 | 64 |
#endif |
65 |
||
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
66 |
#if LIBAVCODEC_VERSION_MAJOR < 56 |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
67 |
#define av_frame_alloc avcodec_alloc_frame |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
68 |
#define av_frame_free av_freep |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
69 |
#endif |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
70 |
|
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
71 |
#if LIBAVCODEC_VERSION_MAJOR < 57 |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
72 |
#define AV_CODEC_CAP_DELAY CODEC_CAP_DELAY |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
73 |
#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE CODEC_CAP_VARIABLE_FRAME_SIZE |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
74 |
#define AV_CODEC_FLAG_GLOBAL_HEADER CODEC_FLAG_GLOBAL_HEADER |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
75 |
#define AV_CODEC_FLAG_QSCALE CODEC_FLAG_QSCALE |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
76 |
#endif |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
77 |
|
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
78 |
#if LIBAVFORMAT_VERSION_MAJOR < 53 |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
79 |
#define AVIO_FLAG_WRITE AVIO_WRONLY |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
80 |
#endif |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
81 |
|
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
82 |
#if LIBAVFORMAT_VERSION_MAJOR < 54 |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
83 |
#define avformat_new_stream(x, y) av_new_stream(x, y->type == AVMEDIA_TYPE_AUDIO) |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
84 |
#endif |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
85 |
|
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
86 |
#if LIBAVUTIL_VERSION_MAJOR < 54 |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
87 |
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
88 |
#endif |
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
89 |
|
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
90 |
|
7180 | 91 |
// pointer to function from hwengine (uUtils.pas) |
92 |
static void (*AddFileLogRaw)(const char* pString); |
|
93 |
||
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
94 |
static int FatalError(const char* pFmt, ...) |
7180 | 95 |
{ |
8065 | 96 |
char Buffer[1024]; |
7180 | 97 |
va_list VaArgs; |
98 |
||
99 |
va_start(VaArgs, pFmt); |
|
100 |
vsnprintf(Buffer, 1024, pFmt, VaArgs); |
|
101 |
va_end(VaArgs); |
|
102 |
||
103 |
AddFileLogRaw("Error in av-wrapper: "); |
|
104 |
AddFileLogRaw(Buffer); |
|
105 |
AddFileLogRaw("\n"); |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
106 |
return(-1); |
7180 | 107 |
} |
108 |
||
109 |
// Function to be called from libav for logging. |
|
110 |
// Note: libav can call LogCallback from different threads |
|
111 |
// (there is mutex in AddFileLogRaw). |
|
112 |
static void LogCallback(void* p, int Level, const char* pFmt, va_list VaArgs) |
|
113 |
{ |
|
8065 | 114 |
char Buffer[1024]; |
7180 | 115 |
|
116 |
vsnprintf(Buffer, 1024, pFmt, VaArgs); |
|
117 |
AddFileLogRaw(Buffer); |
|
118 |
} |
|
119 |
||
120 |
static void Log(const char* pFmt, ...) |
|
121 |
{ |
|
8065 | 122 |
char Buffer[1024]; |
7180 | 123 |
va_list VaArgs; |
124 |
||
125 |
va_start(VaArgs, pFmt); |
|
126 |
vsnprintf(Buffer, 1024, pFmt, VaArgs); |
|
127 |
va_end(VaArgs); |
|
128 |
||
129 |
AddFileLogRaw(Buffer); |
|
130 |
} |
|
131 |
||
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
132 |
static void AddAudioStream() |
7180 | 133 |
{ |
134 |
g_pAStream = avformat_new_stream(g_pContainer, g_pACodec); |
|
135 |
if(!g_pAStream) |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
136 |
{ |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7282
diff
changeset
|
137 |
Log("Could not allocate audio stream\n"); |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
138 |
return; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
139 |
} |
7180 | 140 |
g_pAStream->id = 1; |
141 |
||
142 |
g_pAudio = g_pAStream->codec; |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
143 |
|
7180 | 144 |
avcodec_get_context_defaults3(g_pAudio, g_pACodec); |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
145 |
g_pAudio->codec_id = g_pACodec->id; |
7180 | 146 |
|
147 |
// put parameters |
|
148 |
g_pAudio->sample_fmt = AV_SAMPLE_FMT_S16; |
|
149 |
g_pAudio->sample_rate = g_Frequency; |
|
150 |
g_pAudio->channels = g_Channels; |
|
151 |
||
11601
ba7e67586fcd
videorec: Always initialize audio and video time bases
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11600
diff
changeset
|
152 |
// set time base as invers of sample rate |
ba7e67586fcd
videorec: Always initialize audio and video time bases
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11600
diff
changeset
|
153 |
g_pAudio->time_base.den = g_pAStream->time_base.den = g_Frequency; |
ba7e67586fcd
videorec: Always initialize audio and video time bases
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11600
diff
changeset
|
154 |
g_pAudio->time_base.num = g_pAStream->time_base.num = 1; |
ba7e67586fcd
videorec: Always initialize audio and video time bases
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11600
diff
changeset
|
155 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
156 |
// set quality |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
157 |
g_pAudio->bit_rate = 160000; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
158 |
|
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
159 |
// for codecs that support variable bitrate use it, it should be better |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
160 |
g_pAudio->flags |= AV_CODEC_FLAG_QSCALE; |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
161 |
g_pAudio->global_quality = 1*FF_QP2LAMBDA; |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
162 |
|
7180 | 163 |
// some formats want stream headers to be separate |
164 |
if (g_pFormat->flags & AVFMT_GLOBALHEADER) |
|
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
165 |
g_pAudio->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; |
7180 | 166 |
|
167 |
// open it |
|
168 |
if (avcodec_open2(g_pAudio, g_pACodec, NULL) < 0) |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
169 |
{ |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7282
diff
changeset
|
170 |
Log("Could not open audio codec %s\n", g_pACodec->long_name); |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
171 |
return; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
172 |
} |
7180 | 173 |
|
174 |
#if LIBAVCODEC_VERSION_MAJOR >= 54 |
|
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
175 |
if (g_pACodec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) |
7180 | 176 |
#else |
177 |
if (g_pAudio->frame_size == 0) |
|
178 |
#endif |
|
179 |
g_NumSamples = 4096; |
|
180 |
else |
|
181 |
g_NumSamples = g_pAudio->frame_size; |
|
182 |
g_pSamples = (int16_t*)av_malloc(g_NumSamples*g_Channels*sizeof(int16_t)); |
|
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
183 |
g_pAFrame = av_frame_alloc(); |
7180 | 184 |
if (!g_pAFrame) |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
185 |
{ |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7282
diff
changeset
|
186 |
Log("Could not allocate frame\n"); |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
187 |
return; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
188 |
} |
7180 | 189 |
} |
190 |
||
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
191 |
// returns non-zero if there is more sound, -1 in case of error |
7180 | 192 |
static int WriteAudioFrame() |
193 |
{ |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
194 |
if (!g_pAStream) |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
195 |
return 0; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
196 |
|
11349
bf5cfd830f7d
Let initialization happen in the appropriate function
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11347
diff
changeset
|
197 |
AVPacket Packet; |
7180 | 198 |
av_init_packet(&Packet); |
11598
72be390795db
videorec: Make sure the audio packet is considered empty
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11349
diff
changeset
|
199 |
Packet.data = NULL; |
72be390795db
videorec: Make sure the audio packet is considered empty
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11349
diff
changeset
|
200 |
Packet.size = 0; |
7180 | 201 |
|
202 |
int NumSamples = fread(g_pSamples, 2*g_Channels, g_NumSamples, g_pSoundFile); |
|
203 |
||
8065 | 204 |
#if LIBAVCODEC_VERSION_MAJOR >= 53 |
7180 | 205 |
AVFrame* pFrame = NULL; |
206 |
if (NumSamples > 0) |
|
207 |
{ |
|
208 |
g_pAFrame->nb_samples = NumSamples; |
|
209 |
avcodec_fill_audio_frame(g_pAFrame, g_Channels, AV_SAMPLE_FMT_S16, |
|
210 |
(uint8_t*)g_pSamples, NumSamples*2*g_Channels, 1); |
|
211 |
pFrame = g_pAFrame; |
|
212 |
} |
|
213 |
// when NumSamples == 0 we still need to call encode_audio2 to flush |
|
214 |
int got_packet; |
|
215 |
if (avcodec_encode_audio2(g_pAudio, &Packet, pFrame, &got_packet) != 0) |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
216 |
return FatalError("avcodec_encode_audio2 failed"); |
7180 | 217 |
if (!got_packet) |
218 |
return 0; |
|
219 |
#else |
|
220 |
if (NumSamples == 0) |
|
221 |
return 0; |
|
222 |
int BufferSize = OUTBUFFER_SIZE; |
|
223 |
if (g_pAudio->frame_size == 0) |
|
224 |
BufferSize = NumSamples*g_Channels*2; |
|
225 |
Packet.size = avcodec_encode_audio(g_pAudio, g_OutBuffer, BufferSize, g_pSamples); |
|
226 |
if (Packet.size == 0) |
|
227 |
return 1; |
|
228 |
if (g_pAudio->coded_frame && g_pAudio->coded_frame->pts != AV_NOPTS_VALUE) |
|
229 |
Packet.pts = av_rescale_q(g_pAudio->coded_frame->pts, g_pAudio->time_base, g_pAStream->time_base); |
|
230 |
Packet.flags |= AV_PKT_FLAG_KEY; |
|
231 |
Packet.data = g_OutBuffer; |
|
232 |
#endif |
|
233 |
||
234 |
// Write the compressed frame to the media file. |
|
235 |
Packet.stream_index = g_pAStream->index; |
|
8811 | 236 |
if (av_interleaved_write_frame(g_pContainer, &Packet) != 0) |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
237 |
return FatalError("Error while writing audio frame"); |
7180 | 238 |
return 1; |
239 |
} |
|
240 |
||
241 |
// add a video output stream |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
242 |
static int AddVideoStream() |
7180 | 243 |
{ |
244 |
g_pVStream = avformat_new_stream(g_pContainer, g_pVCodec); |
|
245 |
if (!g_pVStream) |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
246 |
return FatalError("Could not allocate video stream"); |
7180 | 247 |
|
248 |
g_pVideo = g_pVStream->codec; |
|
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
249 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
250 |
avcodec_get_context_defaults3(g_pVideo, g_pVCodec); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
251 |
g_pVideo->codec_id = g_pVCodec->id; |
7180 | 252 |
|
253 |
// put parameters |
|
254 |
// resolution must be a multiple of two |
|
7282
c65992e2d794
correctly fix odd dimensions (it was incorrectly fixed in previous commit)
Stepan777 <stepik-777@mail.ru>
parents:
7280
diff
changeset
|
255 |
g_pVideo->width = g_Width & ~1; // make even (dimensions should be even) |
c65992e2d794
correctly fix odd dimensions (it was incorrectly fixed in previous commit)
Stepan777 <stepik-777@mail.ru>
parents:
7280
diff
changeset
|
256 |
g_pVideo->height = g_Height & ~1; // make even |
7180 | 257 |
/* time base: this is the fundamental unit of time (in seconds) in terms |
258 |
of which frame timestamps are represented. for fixed-fps content, |
|
259 |
timebase should be 1/framerate and timestamp increments should be |
|
260 |
identically 1. */ |
|
11601
ba7e67586fcd
videorec: Always initialize audio and video time bases
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11600
diff
changeset
|
261 |
g_pVideo->time_base.den = g_pVStream->time_base.den = g_Framerate.num; |
ba7e67586fcd
videorec: Always initialize audio and video time bases
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11600
diff
changeset
|
262 |
g_pVideo->time_base.num = g_pVStream->time_base.num = g_Framerate.den; |
7180 | 263 |
//g_pVideo->gop_size = 12; /* emit one intra frame every twelve frames at most */ |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
264 |
g_pVideo->pix_fmt = AV_PIX_FMT_YUV420P; |
7180 | 265 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
266 |
// set quality |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
267 |
if (g_VQuality > 100) |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
268 |
g_pVideo->bit_rate = g_VQuality; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
269 |
else |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
270 |
{ |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
271 |
g_pVideo->flags |= AV_CODEC_FLAG_QSCALE; |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
272 |
g_pVideo->global_quality = g_VQuality*FF_QP2LAMBDA; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
273 |
} |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
274 |
|
7180 | 275 |
// some formats want stream headers to be separate |
276 |
if (g_pFormat->flags & AVFMT_GLOBALHEADER) |
|
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
277 |
g_pVideo->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; |
7180 | 278 |
|
8065 | 279 |
#if LIBAVCODEC_VERSION_MAJOR < 53 |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
280 |
// for some versions of ffmpeg x264 options must be set explicitly |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
281 |
if (strcmp(g_pVCodec->name, "libx264") == 0) |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
282 |
{ |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
283 |
g_pVideo->coder_type = FF_CODER_TYPE_AC; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
284 |
g_pVideo->flags |= CODEC_FLAG_LOOP_FILTER; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
285 |
g_pVideo->crf = 23; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
286 |
g_pVideo->thread_count = 3; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
287 |
g_pVideo->me_cmp = FF_CMP_CHROMA; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
288 |
g_pVideo->partitions = X264_PART_I8X8 | X264_PART_I4X4 | X264_PART_P8X8 | X264_PART_B8X8; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
289 |
g_pVideo->me_method = ME_HEX; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
290 |
g_pVideo->me_subpel_quality = 7; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
291 |
g_pVideo->me_range = 16; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
292 |
g_pVideo->gop_size = 250; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
293 |
g_pVideo->keyint_min = 25; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
294 |
g_pVideo->scenechange_threshold = 40; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
295 |
g_pVideo->i_quant_factor = 0.71; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
296 |
g_pVideo->b_frame_strategy = 1; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
297 |
g_pVideo->qcompress = 0.6; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
298 |
g_pVideo->qmin = 10; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
299 |
g_pVideo->qmax = 51; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
300 |
g_pVideo->max_qdiff = 4; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
301 |
g_pVideo->max_b_frames = 3; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
302 |
g_pVideo->refs = 3; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
303 |
g_pVideo->directpred = 1; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
304 |
g_pVideo->trellis = 1; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
305 |
g_pVideo->flags2 = CODEC_FLAG2_BPYRAMID | CODEC_FLAG2_MIXED_REFS | CODEC_FLAG2_WPRED | CODEC_FLAG2_8X8DCT | CODEC_FLAG2_FASTPSKIP; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
306 |
g_pVideo->weighted_p_pred = 2; |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
307 |
} |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
308 |
#endif |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
309 |
|
7180 | 310 |
// open the codec |
7359
8bb4da06b065
Fix compilation of hwengine on ffmpeg 0.7.13.
Stepan777 <stepik-777@mail.ru>
parents:
7356
diff
changeset
|
311 |
#if LIBAVCODEC_VERSION_MAJOR >= 53 |
8bb4da06b065
Fix compilation of hwengine on ffmpeg 0.7.13.
Stepan777 <stepik-777@mail.ru>
parents:
7356
diff
changeset
|
312 |
AVDictionary* pDict = NULL; |
8bb4da06b065
Fix compilation of hwengine on ffmpeg 0.7.13.
Stepan777 <stepik-777@mail.ru>
parents:
7356
diff
changeset
|
313 |
if (strcmp(g_pVCodec->name, "libx264") == 0) |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
314 |
av_dict_set(&pDict, "preset", "medium", 0); |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
315 |
#endif |
7359
8bb4da06b065
Fix compilation of hwengine on ffmpeg 0.7.13.
Stepan777 <stepik-777@mail.ru>
parents:
7356
diff
changeset
|
316 |
|
7180 | 317 |
if (avcodec_open2(g_pVideo, g_pVCodec, &pDict) < 0) |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
318 |
return FatalError("Could not open video codec %s", g_pVCodec->long_name); |
7180 | 319 |
|
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
320 |
g_pVFrame = av_frame_alloc(); |
7180 | 321 |
if (!g_pVFrame) |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
322 |
return FatalError("Could not allocate frame"); |
7180 | 323 |
|
11600
9a17a39eccdc
videorec: Fully set frame properties
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11599
diff
changeset
|
324 |
g_pVFrame->width = g_Width; |
9a17a39eccdc
videorec: Fully set frame properties
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11599
diff
changeset
|
325 |
g_pVFrame->height = g_Height; |
9a17a39eccdc
videorec: Fully set frame properties
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11599
diff
changeset
|
326 |
g_pVFrame->format = AV_PIX_FMT_YUV420P; |
7180 | 327 |
g_pVFrame->linesize[0] = g_Width; |
328 |
g_pVFrame->linesize[1] = g_Width/2; |
|
329 |
g_pVFrame->linesize[2] = g_Width/2; |
|
330 |
g_pVFrame->linesize[3] = 0; |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
331 |
return 0; |
7180 | 332 |
} |
333 |
||
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
334 |
static int WriteFrame(AVFrame* pFrame) |
7180 | 335 |
{ |
336 |
double AudioTime, VideoTime; |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
337 |
int ret; |
7180 | 338 |
// write interleaved audio frame |
339 |
if (g_pAStream) |
|
340 |
{ |
|
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
341 |
VideoTime = (double)g_pVFrame->pts * g_pVStream->time_base.num/g_pVStream->time_base.den; |
7180 | 342 |
do |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
343 |
{ |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
344 |
AudioTime = (double)g_pAFrame->pts * g_pAStream->time_base.num/g_pAStream->time_base.den; |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
345 |
ret = WriteAudioFrame(); |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
346 |
} |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
347 |
while (AudioTime < VideoTime && ret); |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
348 |
if (ret < 0) |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
349 |
return ret; |
7180 | 350 |
} |
8811 | 351 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
352 |
if (!g_pVStream) |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
353 |
return 0; |
7180 | 354 |
|
355 |
AVPacket Packet; |
|
356 |
av_init_packet(&Packet); |
|
357 |
Packet.data = NULL; |
|
358 |
Packet.size = 0; |
|
359 |
||
360 |
g_pVFrame->pts++; |
|
361 |
if (g_pFormat->flags & AVFMT_RAWPICTURE) |
|
362 |
{ |
|
363 |
/* raw video case. The API will change slightly in the near |
|
364 |
future for that. */ |
|
365 |
Packet.flags |= AV_PKT_FLAG_KEY; |
|
366 |
Packet.stream_index = g_pVStream->index; |
|
367 |
Packet.data = (uint8_t*)pFrame; |
|
368 |
Packet.size = sizeof(AVPicture); |
|
369 |
||
370 |
if (av_interleaved_write_frame(g_pContainer, &Packet) != 0) |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
371 |
return FatalError("Error while writing video frame"); |
7180 | 372 |
return 0; |
373 |
} |
|
374 |
else |
|
375 |
{ |
|
376 |
#if LIBAVCODEC_VERSION_MAJOR >= 54 |
|
377 |
int got_packet; |
|
378 |
if (avcodec_encode_video2(g_pVideo, &Packet, pFrame, &got_packet) < 0) |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
379 |
return FatalError("avcodec_encode_video2 failed"); |
7180 | 380 |
if (!got_packet) |
381 |
return 0; |
|
382 |
||
383 |
if (Packet.pts != AV_NOPTS_VALUE) |
|
384 |
Packet.pts = av_rescale_q(Packet.pts, g_pVideo->time_base, g_pVStream->time_base); |
|
385 |
if (Packet.dts != AV_NOPTS_VALUE) |
|
386 |
Packet.dts = av_rescale_q(Packet.dts, g_pVideo->time_base, g_pVStream->time_base); |
|
8811 | 387 |
#else |
7180 | 388 |
Packet.size = avcodec_encode_video(g_pVideo, g_OutBuffer, OUTBUFFER_SIZE, pFrame); |
389 |
if (Packet.size < 0) |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
390 |
return FatalError("avcodec_encode_video failed"); |
7180 | 391 |
if (Packet.size == 0) |
392 |
return 0; |
|
393 |
||
394 |
if( g_pVideo->coded_frame->pts != AV_NOPTS_VALUE) |
|
395 |
Packet.pts = av_rescale_q(g_pVideo->coded_frame->pts, g_pVideo->time_base, g_pVStream->time_base); |
|
396 |
if( g_pVideo->coded_frame->key_frame ) |
|
397 |
Packet.flags |= AV_PKT_FLAG_KEY; |
|
398 |
Packet.data = g_OutBuffer; |
|
399 |
#endif |
|
400 |
// write the compressed frame in the media file |
|
401 |
Packet.stream_index = g_pVStream->index; |
|
402 |
if (av_interleaved_write_frame(g_pContainer, &Packet) != 0) |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
403 |
return FatalError("Error while writing video frame"); |
8811 | 404 |
|
7180 | 405 |
return 1; |
406 |
} |
|
407 |
} |
|
408 |
||
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
409 |
AVWRAP_DECL int AVWrapper_WriteFrame(uint8_t* pY, uint8_t* pCb, uint8_t* pCr) |
7180 | 410 |
{ |
411 |
g_pVFrame->data[0] = pY; |
|
412 |
g_pVFrame->data[1] = pCb; |
|
413 |
g_pVFrame->data[2] = pCr; |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
414 |
return WriteFrame(g_pVFrame); |
7180 | 415 |
} |
416 |
||
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
417 |
AVWRAP_DECL int AVWrapper_Init( |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
418 |
void (*pAddFileLogRaw)(const char*), |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
419 |
const char* pFilename, |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
420 |
const char* pDesc, |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
421 |
const char* pSoundFile, |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
422 |
const char* pFormatName, |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
423 |
const char* pVCodecName, |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
424 |
const char* pACodecName, |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
425 |
int Width, int Height, |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
426 |
int FramerateNum, int FramerateDen, |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7359
diff
changeset
|
427 |
int VQuality) |
8811 | 428 |
{ |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
429 |
int ret; |
7180 | 430 |
AddFileLogRaw = pAddFileLogRaw; |
431 |
av_log_set_callback( &LogCallback ); |
|
432 |
||
7282
c65992e2d794
correctly fix odd dimensions (it was incorrectly fixed in previous commit)
Stepan777 <stepik-777@mail.ru>
parents:
7280
diff
changeset
|
433 |
g_Width = Width; |
c65992e2d794
correctly fix odd dimensions (it was incorrectly fixed in previous commit)
Stepan777 <stepik-777@mail.ru>
parents:
7280
diff
changeset
|
434 |
g_Height = Height; |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
435 |
g_Framerate.num = FramerateNum; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
436 |
g_Framerate.den = FramerateDen; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
437 |
g_VQuality = VQuality; |
7180 | 438 |
|
439 |
// initialize libav and register all codecs and formats |
|
440 |
av_register_all(); |
|
441 |
||
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
442 |
// find format |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
443 |
g_pFormat = av_guess_format(pFormatName, NULL, NULL); |
7180 | 444 |
if (!g_pFormat) |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
445 |
return FatalError("Format \"%s\" was not found", pFormatName); |
7180 | 446 |
|
447 |
// allocate the output media context |
|
448 |
g_pContainer = avformat_alloc_context(); |
|
449 |
if (!g_pContainer) |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
450 |
return FatalError("Could not allocate output context"); |
7180 | 451 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
452 |
g_pContainer->oformat = g_pFormat; |
7180 | 453 |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
454 |
// store description of file |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
455 |
av_dict_set(&g_pContainer->metadata, "comment", pDesc, 0); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
456 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
457 |
// append extesnion to filename |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
458 |
char ext[16]; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
459 |
strncpy(ext, g_pFormat->extensions, 16); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
460 |
ext[15] = 0; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
461 |
ext[strcspn(ext,",")] = 0; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
462 |
snprintf(g_pContainer->filename, sizeof(g_pContainer->filename), "%s.%s", pFilename, ext); |
7180 | 463 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
464 |
// find codecs |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
465 |
g_pVCodec = avcodec_find_encoder_by_name(pVCodecName); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
466 |
g_pACodec = avcodec_find_encoder_by_name(pACodecName); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
467 |
|
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
468 |
// add audio and video stream to container |
7180 | 469 |
g_pVStream = NULL; |
470 |
g_pAStream = NULL; |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
471 |
|
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
472 |
if (g_pVCodec) |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
473 |
{ |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
474 |
ret = AddVideoStream(); |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
475 |
if (ret < 0) |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
476 |
return ret; |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
477 |
} |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
478 |
else |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
479 |
Log("Video codec \"%s\" was not found; video will be ignored.\n", pVCodecName); |
7180 | 480 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
481 |
if (g_pACodec) |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
482 |
{ |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
483 |
g_pSoundFile = fopen(pSoundFile, "rb"); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
484 |
if (g_pSoundFile) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
485 |
{ |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
486 |
fread(&g_Frequency, 4, 1, g_pSoundFile); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
487 |
fread(&g_Channels, 4, 1, g_pSoundFile); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
488 |
AddAudioStream(); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
489 |
} |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
490 |
else |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7282
diff
changeset
|
491 |
Log("Could not open %s\n", pSoundFile); |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
492 |
} |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
493 |
else |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
494 |
Log("Audio codec \"%s\" was not found; audio will be ignored.\n", pACodecName); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
495 |
|
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
496 |
if (!g_pAStream && !g_pVStream) |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
497 |
return FatalError("No video, no audio, aborting..."); |
7180 | 498 |
|
499 |
// write format info to log |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
500 |
av_dump_format(g_pContainer, 0, g_pContainer->filename, 1); |
7180 | 501 |
|
502 |
// open the output file, if needed |
|
503 |
if (!(g_pFormat->flags & AVFMT_NOFILE)) |
|
504 |
{ |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
505 |
if (avio_open(&g_pContainer->pb, g_pContainer->filename, AVIO_FLAG_WRITE) < 0) |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
506 |
return FatalError("Could not open output file (%s)", g_pContainer->filename); |
7180 | 507 |
} |
508 |
||
509 |
// write the stream header, if any |
|
510 |
avformat_write_header(g_pContainer, NULL); |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
511 |
|
7180 | 512 |
g_pVFrame->pts = -1; |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
513 |
return 0; |
7180 | 514 |
} |
515 |
||
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
516 |
AVWRAP_DECL int AVWrapper_Close() |
7180 | 517 |
{ |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
518 |
int ret; |
7180 | 519 |
// output buffered frames |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
520 |
if (g_pVCodec->capabilities & AV_CODEC_CAP_DELAY) |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
521 |
{ |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
522 |
do |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
523 |
ret = WriteFrame(NULL); |
11599
91d31e15f8f2
videorec: Fix flushing encoders
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11598
diff
changeset
|
524 |
while (ret > 0); |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
525 |
if (ret < 0) |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
526 |
return ret; |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
527 |
} |
7180 | 528 |
// output any remaining audio |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
529 |
do |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
530 |
{ |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
531 |
ret = WriteAudioFrame(); |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
532 |
} |
11599
91d31e15f8f2
videorec: Fix flushing encoders
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11598
diff
changeset
|
533 |
while(ret > 0); |
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
534 |
if (ret < 0) |
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
535 |
return ret; |
7180 | 536 |
|
537 |
// write the trailer, if any. |
|
538 |
av_write_trailer(g_pContainer); |
|
539 |
||
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
540 |
// close the output file |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
541 |
if (!(g_pFormat->flags & AVFMT_NOFILE)) |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
542 |
avio_close(g_pContainer->pb); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
543 |
|
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
544 |
// free everything |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
545 |
if (g_pVStream) |
7180 | 546 |
{ |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
547 |
avcodec_close(g_pVideo); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
548 |
av_free(g_pVideo); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
549 |
av_free(g_pVStream); |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
550 |
av_frame_free(&g_pVFrame); |
7180 | 551 |
} |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
552 |
if (g_pAStream) |
7180 | 553 |
{ |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
554 |
avcodec_close(g_pAudio); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
555 |
av_free(g_pAudio); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
556 |
av_free(g_pAStream); |
11347
210650fc7182
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
557 |
av_frame_free(&g_pAFrame); |
7180 | 558 |
av_free(g_pSamples); |
559 |
fclose(g_pSoundFile); |
|
560 |
} |
|
561 |
||
562 |
av_free(g_pContainer); |
|
9925
113e61a8cadc
Fixed avwrapper exit calls, fixing issue 752
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9224
diff
changeset
|
563 |
return 0; |
7180 | 564 |
} |