== Sequencer / FFMPEG ==
Updating to latest FFMPEG version.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <ffmpeg/avformat.h>
|
||||
#include <ffmpeg/avcodec.h>
|
||||
#include <ffmpeg/rational.h>
|
||||
#include <ffmpeg/swscale.h>
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT < (49 << 16)
|
||||
#define FFMPEG_OLD_FRAME_RATE 1
|
||||
@@ -81,6 +82,7 @@ static AVFormatContext* outfile = 0;
|
||||
static AVStream* video_stream = 0;
|
||||
static AVStream* audio_stream = 0;
|
||||
static AVFrame* current_frame = 0;
|
||||
static struct SwsContext *img_convert_ctx = 0;
|
||||
|
||||
static uint8_t* video_buffer = 0;
|
||||
static int video_buffersize = 0;
|
||||
@@ -317,8 +319,9 @@ static AVFrame* generate_video_frame(uint8_t* pixels)
|
||||
}
|
||||
|
||||
if (c->pix_fmt != PIX_FMT_RGBA32) {
|
||||
img_convert((AVPicture*)current_frame, c->pix_fmt,
|
||||
(AVPicture*)rgb_frame, PIX_FMT_RGBA32, width, height);
|
||||
sws_scale(img_convert_ctx, rgb_frame->data,
|
||||
rgb_frame->linesize, 0, c->height,
|
||||
current_frame->data, current_frame->linesize);
|
||||
delete_picture(rgb_frame);
|
||||
}
|
||||
return current_frame;
|
||||
@@ -420,6 +423,13 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of,
|
||||
"FFMPEG video buffer");
|
||||
|
||||
current_frame = alloc_picture(c->pix_fmt, c->width, c->height);
|
||||
|
||||
img_convert_ctx = sws_getContext(c->width, c->height,
|
||||
PIX_FMT_RGBA32,
|
||||
c->width, c->height,
|
||||
c->pix_fmt,
|
||||
SWS_BICUBIC,
|
||||
NULL, NULL, NULL);
|
||||
return st;
|
||||
}
|
||||
|
||||
@@ -749,8 +759,10 @@ void end_ffmpeg(void)
|
||||
|
||||
fprintf(stderr, "Closing ffmpeg...\n");
|
||||
|
||||
write_audio_frames();
|
||||
|
||||
if (audio_stream) {
|
||||
write_audio_frames();
|
||||
}
|
||||
|
||||
if (outfile) {
|
||||
av_write_trailer(outfile);
|
||||
}
|
||||
@@ -797,6 +809,11 @@ void end_ffmpeg(void)
|
||||
MEM_freeN(audio_input_buffer);
|
||||
audio_input_buffer = 0;
|
||||
}
|
||||
|
||||
if (img_convert_ctx) {
|
||||
sws_freeContext(img_convert_ctx);
|
||||
img_convert_ctx = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user