Extract audio more correctly and neatly; support 7.1 in DCP naming; fix up lack of...
authorCarl Hetherington <cth@carlh.net>
Sat, 20 Oct 2012 20:29:20 +0000 (21:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 20 Oct 2012 20:29:20 +0000 (21:29 +0100)
src/lib/decoder.cc
src/lib/film_state.cc
src/wx/film_editor.cc

index 14401994fbad7e847881b66cb283a91c68ff0d70..d78089265d65b848709d9870c157123744970a16 100644 (file)
@@ -200,28 +200,37 @@ Decoder::emit_audio (uint8_t* data, int size)
        switch (audio_sample_format()) {
        case AV_SAMPLE_FMT_S16:
        {
-               uint8_t* p = data;
+               int16_t* p = (int16_t *) data;
                int sample = 0;
                int channel = 0;
                for (int i = 0; i < total_samples; ++i) {
-                       /* unsigned sample */
-                       int const ou = p[0] | (p[1] << 8);
-                       /* signed sample */
-                       int const os = ou >= 0x8000 ? (- 0x10000 + ou) : ou;
-                       /* float sample */
-                       audio->data(channel)[sample] = float(os) / 0x8000;
+                       audio->data(channel)[sample] = float(*p++) / (1 << 15);
 
                        ++channel;
                        if (channel == _fs->audio_channels()) {
                                channel = 0;
                                ++sample;
                        }
-
-                       p += 2;
                }
        }
        break;
 
+       case AV_SAMPLE_FMT_S32:
+       {
+               int32_t* p = (int32_t *) data;
+               int sample = 0;
+               int channel = 0;
+               for (int i = 0; i < total_samples; ++i) {
+                       audio->data(channel)[sample] = float(*p++) / (1 << 31);
+
+                       ++channel;
+                       if (channel == _fs->audio_channels()) {
+                               channel = 0;
+                               ++sample;
+                       }
+               }
+       }
+
        case AV_SAMPLE_FMT_FLTP:
        {
                float* p = reinterpret_cast<float*> (data);
index 8dd8309a8f0358a2d35c556623f6e569fe487d55..09c5e3efd19e89b3c8617e97bd57059581879e01 100644 (file)
@@ -431,6 +431,9 @@ FilmState::dci_name () const
        case 6:
                d << "51_";
                break;
+       case 8:
+               d << "71_";
+               break;
        }
 
        d << "2K_";
index 54b810db91b429cc914276c2ebcc521ff9cc0752..15755b9db43b756e0cf7a62ac7f851c7839d0e06 100644 (file)
@@ -900,6 +900,9 @@ FilmEditor::audio_stream_changed (wxCommandEvent &)
        _ignore_changes = Film::AUDIO_STREAM;
        _film->set_audio_stream (_audio_stream->GetSelection ());
        _ignore_changes = Film::NONE;
+
+       _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
+       setup_audio_details ();
 }
 
 void
@@ -925,4 +928,3 @@ FilmEditor::setup_audio_details ()
                _audio->SetLabel (std_to_wx (s.str ()));
        }
 }
-