Revision: 52438
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52438
Author:   nazgul
Date:     2012-11-21 11:57:35 +0000 (Wed, 21 Nov 2012)
Log Message:
-----------
Patch #33242: ffmpeg AAC/AC3 encoding

Patch by David M (erwin94), thanks!

Also made Vorbis codec using float sample_fmt, otherwise it didn't work
with new FFmpeg.

Perhaps we can make it more clear by explicitly separating audio_input_buffer
for float and integer buffers, but as far as it works i'm not so fussed about
this atm.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/writeffmpeg.c

Modified: trunk/blender/source/blender/blenkernel/intern/writeffmpeg.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/writeffmpeg.c        
2012-11-21 11:10:37 UTC (rev 52437)
+++ trunk/blender/source/blender/blenkernel/intern/writeffmpeg.c        
2012-11-21 11:57:35 UTC (rev 52438)
@@ -111,6 +111,11 @@
        }
 }
 
+static int use_float_audio_buffer(int codec_id)
+{
+       return codec_id == CODEC_ID_AAC || codec_id == CODEC_ID_AC3 || codec_id 
== CODEC_ID_VORBIS;
+}
+
 #ifdef WITH_AUDASPACE
 static int write_audio_frame(void) 
 {
@@ -618,6 +623,10 @@
        c->bit_rate = ffmpeg_audio_bitrate * 1000;
        c->sample_fmt = AV_SAMPLE_FMT_S16;
        c->channels = rd->ffcodecdata.audio_channels;
+       if (use_float_audio_buffer(codec_id)) {
+               c->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
+               c->sample_fmt = AV_SAMPLE_FMT_FLT;
+       }
        codec = avcodec_find_encoder(c->codec_id);
        if (!codec) {
                //XXX error("Couldn't find a valid audio codec");
@@ -649,7 +658,12 @@
 
        audio_output_buffer = (uint8_t *) av_malloc(audio_outbuf_size);
 
-       audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * 
c->channels * sizeof(int16_t));
+       if (use_float_audio_buffer(codec_id)) {
+               audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples 
* c->channels * sizeof(float));
+       }
+       else {
+               audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples 
* c->channels * sizeof(int16_t));
+       }
 
        audio_time = 0.0f;
 
@@ -949,7 +963,12 @@
                AVCodecContext *c = audio_stream->codec;
                AUD_DeviceSpecs specs;
                specs.channels = c->channels;
-               specs.format = AUD_FORMAT_S16;
+               if (use_float_audio_buffer(c->codec_id)) {
+                       specs.format = AUD_FORMAT_FLOAT32;
+               }
+               else {
+                       specs.format = AUD_FORMAT_S16;
+               }
                specs.rate = rd->ffcodecdata.audio_mixrate;
                audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, 
rd->ffcodecdata.audio_volume);
 #ifdef FFMPEG_CODEC_TIME_BASE

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to