diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-06-22 00:39:41 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-06-22 00:39:41 +0400 |
commit | 2d3d025e8cf8776361e6397502f4e240ae9a5ccc (patch) | |
tree | 52530ba2f7202fdc77a68db0ba973d6d2beafe3a /source | |
parent | 8e6b5598e075932cab09048bff7ef1e54d657bb8 (diff) |
3D Audio GSoC:
- Sequencer dynamics: Now it's possible to change the output channels and the resampling quality also increased (previously maximum quality was 44,1 kHz)
- Changed two buffers to use ffmpeg allocation, not sure if that helps somehow.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeffmpeg.c | 17 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 12 |
6 files changed, 33 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 51eaba3c05b..e045bd0fb82 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -469,6 +469,7 @@ Scene *add_scene(const char *name) sce->r.ffcodecdata.audio_mixrate = 44100; sce->r.ffcodecdata.audio_volume = 1.0f; sce->r.ffcodecdata.audio_bitrate = 192; + sce->r.ffcodecdata.audio_channels = 2; BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine)); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 60a24c2eace..9b86b8752db 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -346,6 +346,7 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, AUD_setDeviceVolume(mixdown, volume); + AUD_setSequencerSpecs(scene->sound_scene, specs.specs); AUD_freeHandle(AUD_playDevice(mixdown, scene->sound_scene, start / FPS)); return mixdown; @@ -405,6 +406,9 @@ static void sound_start_play_scene(struct Scene *scene) { if(scene->sound_scene_handle) AUD_stop(scene->sound_scene_handle); + + AUD_setSequencerDeviceSpecs(scene->sound_scene); + if((scene->sound_scene_handle = AUD_play(scene->sound_scene, 1))) AUD_setLoop(scene->sound_scene_handle, -1); } diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index c729565533f..26de31b2b03 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -549,7 +549,7 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex c->sample_rate = rd->ffcodecdata.audio_mixrate; c->bit_rate = ffmpeg_audio_bitrate*1000; c->sample_fmt = SAMPLE_FMT_S16; - c->channels = 2; + c->channels = rd->ffcodecdata.audio_channels; codec = avcodec_find_encoder(c->codec_id); if (!codec) { //XXX error("Couldn't find a valid audio codec"); @@ -574,12 +574,11 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4; } - audio_output_buffer = (uint8_t*)MEM_mallocN( - audio_outbuf_size, "FFMPEG audio encoder input buffer"); + audio_output_buffer = (uint8_t*)av_malloc( + audio_outbuf_size); - audio_input_buffer = (uint8_t*)MEM_mallocN( - audio_input_samples * c->channels * sizeof(int16_t), - "FFMPEG audio encoder output buffer"); + audio_input_buffer = (uint8_t*)av_malloc( + audio_input_samples * c->channels * sizeof(int16_t)); audio_time = 0.0f; @@ -701,7 +700,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report if (ffmpeg_type == FFMPEG_DV) { fmt->audio_codec = CODEC_ID_PCM_S16LE; - if (ffmpeg_audio_codec != CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000) { + if (ffmpeg_audio_codec != CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000 && rd->ffcodecdata.audio_channels != 2) { BKE_report(reports, RPT_ERROR, "FFMPEG only supports 48khz / stereo audio for DV!"); return 0; } @@ -971,11 +970,11 @@ void end_ffmpeg(void) video_buffer = 0; } if (audio_output_buffer) { - MEM_freeN(audio_output_buffer); + av_free(audio_output_buffer); audio_output_buffer = 0; } if (audio_input_buffer) { - MEM_freeN(audio_input_buffer); + av_free(audio_input_buffer); audio_input_buffer = 0; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b8a72616593..50be7b83484 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11474,6 +11474,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) kb->slidermax = kb->slidermin + 1.0f; } } + + { + Scene *scene; + for (scene=main->scene.first; scene; scene=scene->id.next) + scene->r.ffcodecdata.audio_channels = 2; + } } if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) { diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 100a66d209f..2fc92aa12c4 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -126,6 +126,8 @@ typedef struct FFMpegCodecData { int video_bitrate; int audio_bitrate; int audio_mixrate; + int audio_channels; + int audio_pad; float audio_volume; int gop_size; int flags; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 1322a18421b..a8d8d875ec4 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -98,6 +98,14 @@ EnumPropertyItem snap_element_items[] = { {SCE_SNAP_MODE_VOLUME, "VOLUME", ICON_SNAP_VOLUME, "Volume", "Snap to volume"}, {0, NULL, 0, NULL, NULL}}; +static EnumPropertyItem audio_channel_items[] = { + {1, "MONO", 0, "Mono", "Set audio channels to mono"}, + {2, "STEREO", 0, "Stereo", "Set audio channels to stereo"}, + {4, "SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels"}, + {6, "SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound"}, + {8, "SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound"}, + {0, NULL, 0, NULL, NULL}}; + EnumPropertyItem image_type_items[] = { {0, "", 0, "Image", NULL}, {R_BMP, "BMP", ICON_FILE_IMAGE, "BMP", "Output image in bitmap format"}, @@ -2468,6 +2476,10 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Volume", "Audio volume"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "ffmpeg_audio_channels", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "ffcodecdata.audio_channels"); + RNA_def_property_enum_items(prop, audio_channel_items); + RNA_def_property_ui_text(prop, "Audio Channels", "Sets the audio channel count"); #endif prop= RNA_def_property(srna, "fps", PROP_INT, PROP_NONE); |