diff options
author | Peter Schlaile <peter@schlaile.de> | 2006-03-07 23:01:12 +0300 |
---|---|---|
committer | Peter Schlaile <peter@schlaile.de> | 2006-03-07 23:01:12 +0300 |
commit | 327d413eb3c0c4cf07b71903eaa27e784be172c3 (patch) | |
tree | 9563098700eaa9f038dd476541ba71adf9d50e16 /source/blender/blenkernel | |
parent | 9ce587e2117dcb2340d75c4bfa2b6e3c1135254c (diff) |
this patch features several cleanups and bugfixes for the sequencer:
- blur works again (this was a serious bug in gamwarp...)
- seperates all sequence effects into a seperate file with a clean interface
- thereby fixing some obscure segfaults
- seperates the scope views into a seperate file
- adds float support to all effects and scope views
- removes a bad level call to open_plugin_seq
- FFMPEG seeking improved a lot.
- FFMPEG compiles with debian sarge version cleanly
- Makes hdaudio seek and resample code really work
Diffstat (limited to 'source/blender/blenkernel')
4 files changed, 51 insertions, 36 deletions
diff --git a/source/blender/blenkernel/BKE_bad_level_calls.h b/source/blender/blenkernel/BKE_bad_level_calls.h index 1bc02a02ea6..f261f786dd4 100644 --- a/source/blender/blenkernel/BKE_bad_level_calls.h +++ b/source/blender/blenkernel/BKE_bad_level_calls.h @@ -43,8 +43,6 @@ void free_editText(void); void free_vertexpaint(void); /* readfile.c */ -struct PluginSeq; -void open_plugin_seq(struct PluginSeq *pis, char *seqname); struct SpaceButs; void set_rects_butspace(struct SpaceButs *buts); struct SpaceImaSel; diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c index e200c6a88ad..81b6130c021 100644 --- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c +++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c @@ -63,8 +63,6 @@ void fluidsimSettingsFree(struct FluidsimSettings* sb); /* readfile.c */ - /* struct PluginSeq; */ -void open_plugin_seq(struct PluginSeq *pis, char *seqname){} /* struct SpaceButs; */ void set_rects_butspace(struct SpaceButs *buts){} /* struct SpaceImaSel; */ diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index b5e318f7279..5d67760f54a 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> +#include <ffmpeg/rational.h> #include <ffmpeg/avformat.h> #include <ffmpeg/avcodec.h> @@ -28,6 +29,7 @@ #define FFMPEG_OLD_FRAME_RATE 1 #else #define FFMPEG_CODEC_IS_POINTER 1 +#define FFMPEG_CODEC_TIME_BASE 1 #endif #include "BKE_writeffmpeg.h" @@ -77,8 +79,6 @@ static uint8_t* audio_output_buffer = 0; static int audio_outbuf_size = 0; static RenderData *ffmpeg_renderdata; -static int ffmpeg_rectx; -static int ffmpeg_recty; #define FFMPEG_AUTOSPLIT_SIZE 2000000000 @@ -92,11 +92,23 @@ void delete_picture(AVFrame* f) } } +#ifdef FFMPEG_CODEC_IS_POINTER +static AVCodecContext* get_codec_from_stream(AVStream* stream) +{ + return stream->codec; +} +#else +static AVCodecContext* get_codec_from_stream(AVStream* stream) +{ + return &stream->codec; +} +#endif + int write_audio_frame(void) { AVCodecContext* c = NULL; AVPacket pkt; - c = audio_stream->codec; + c = get_codec_from_stream(audio_stream); audiostream_fill(audio_input_buffer, audio_input_frame_size @@ -108,8 +120,12 @@ int write_audio_frame(void) { audio_outbuf_size, (short*) audio_input_buffer); pkt.data = audio_output_buffer; +#ifdef FFMPEG_CODEC_TIME_BASE pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_stream->time_base); +#else + pkt.pts = c->coded_frame->pts; +#endif pkt.stream_index = audio_stream->index; pkt.flags |= PKT_FLAG_KEY; if (av_write_frame(outfile, &pkt) != 0) { @@ -150,9 +166,11 @@ AVOutputFormat* ffmpeg_get_format(int format) f = guess_format("dv", NULL, NULL); break; case FFMPEG_MPEG1: - case FFMPEG_MPEG2: f = guess_format("mpeg", NULL, NULL); break; + case FFMPEG_MPEG2: + f = guess_format("dvd", NULL, NULL); + break; case FFMPEG_MPEG4: f = guess_format("mp4", NULL, NULL); break; @@ -218,11 +236,7 @@ void makeffmpegstring(char* string) { static void write_video_frame(AVFrame* frame) { int outsize = 0; int ret; -#ifdef FFMPEG_CODEC_IS_POINTER - AVCodecContext* c = video_stream->codec; -#else - AVCodecContext* c = &video_stream->codec; -#endif + AVCodecContext* c = get_codec_from_stream(video_stream); frame->pts = G.scene->r.cfra - G.scene->r.sfra; outsize = avcodec_encode_video(c, video_buffer, video_buffersize, @@ -231,9 +245,13 @@ static void write_video_frame(AVFrame* frame) { AVPacket packet; av_init_packet(&packet); +#ifdef FFMPEG_CODEC_TIME_BASE packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base); +#else + packet.pts = c->coded_frame->pts; +#endif if (c->coded_frame->key_frame) packet.flags |= PKT_FLAG_KEY; packet.stream_index = video_stream->index; @@ -252,11 +270,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels) { uint8_t* rendered_frame; -#ifdef FFMPEG_CODEC_IS_POINTER - AVCodecContext* c = video_stream->codec; -#else - AVCodecContext* c = &video_stream->codec; -#endif + AVCodecContext* c = get_codec_from_stream(video_stream); int width = c->width; int height = c->height; AVFrame* rgb_frame; @@ -334,11 +348,7 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of, /* Set up the codec context */ -#ifdef FFMPEG_CODEC_IS_POINTER - c = st->codec; -#else - c = &st->codec; -#endif + c = get_codec_from_stream(st); c->codec_id = codec_id; c->codec_type = CODEC_TYPE_VIDEO; @@ -348,6 +358,7 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of, c->width = rectx; c->height = recty; +#ifdef FFMPEG_CODEC_TIME_BASE /* FIXME: Really bad hack (tm) for NTSC support */ if (ffmpeg_type == FFMPEG_DV && G.scene->r.frs_sec != 25) { c->time_base.den = 2997; @@ -356,6 +367,16 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of, c->time_base.den = G.scene->r.frs_sec; c->time_base.num = 1; } +#else + /* FIXME: Really bad hack (tm) for NTSC support */ + if (ffmpeg_type == FFMPEG_DV && G.scene->r.frs_sec != 25) { + c->frame_rate = 2997; + c->frame_rate_base = 100; + } else { + c->frame_rate = G.scene->r.frs_sec; + c->frame_rate_base = 1; + } +#endif c->gop_size = ffmpeg_gop_size; c->bit_rate = ffmpeg_video_bitrate*1000; @@ -419,7 +440,7 @@ AVStream* alloc_audio_stream(int codec_id, AVFormatContext* of) st = av_new_stream(of, 1); if (!st) return NULL; - c = st->codec; + c = get_codec_from_stream(st); c->codec_id = codec_id; c->codec_type = CODEC_TYPE_AUDIO; @@ -445,7 +466,7 @@ AVStream* alloc_audio_stream(int codec_id, AVFormatContext* of) if (c->frame_size <= 1) { audio_input_frame_size = audio_outbuf_size / c->channels; - switch(st->codec->codec_id) { + switch(c->codec_id) { case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: @@ -600,14 +621,14 @@ void append_ffmpeg(int frame, int *pixels, int rectx, int recty) )) { write_audio_frame(); } - write_video_frame(generate_video_frame(pixels)); + write_video_frame(generate_video_frame((unsigned char*) pixels)); if (ffmpeg_autosplit) { - if (url_fsize(&outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) { + if (url_ftell(&outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) { end_ffmpeg(); ffmpeg_autosplit_count++; - start_ffmpeg_impl(rectx, recty, - ffmpeg_renderdata); + start_ffmpeg_impl(ffmpeg_renderdata, + rectx, recty); } } } @@ -625,8 +646,8 @@ void end_ffmpeg(void) /* Close the video codec */ - if (video_stream && video_stream->codec) { - avcodec_close(video_stream->codec); + if (video_stream && get_codec_from_stream(video_stream)) { + avcodec_close(get_codec_from_stream(video_stream)); } diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index b82f9581cf3..58d8f82d454 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -165,10 +165,7 @@ static int handle_request(char * req) { char * p; char * path; - - if (strlen(req) < 20) { - return -1; - } + int pathlen; if (memcmp(req, "GET ", 4) != 0) { return -1; @@ -188,8 +185,9 @@ static int handle_request(char * req) } write_ppm = 0; + pathlen = strlen(path); - if (memcmp(path, "/images/ppm/", 12) == 0) { + if (pathlen > 12 && memcmp(path, "/images/ppm/", 12) == 0) { write_ppm = 1; return atoi(path + 12); } |