]> git.sesse.net Git - casparcg/commitdiff
2.0. bluefish_consumer: 24 bit audio.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 2 Sep 2011 18:05:13 +0000 (18:05 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 2 Sep 2011 18:05:13 +0000 (18:05 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1325 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/mixer/audio/audio_util.h
modules/bluefish/consumer/bluefish_consumer.cpp

index 4f45efa42d9a11fc38e7d5b72e1bdc0832e7c432..0cbebc3d1dbfc27158b33c3ce63eb9e00e9f427e 100644 (file)
@@ -19,4 +19,16 @@ static std::vector<int16_t> audio_32_to_16(const boost::iterator_range<int32_t*>
        return audio16;\r
 }\r
 \r
+static std::vector<int8_t> audio_32_to_24(const boost::iterator_range<int32_t*>& input)\r
+{      \r
+       std::vector<int8_t> audio24(input.size()*3+16);\r
+       auto audio32_ptr = reinterpret_cast<const uint32_t*>(input.begin());\r
+       auto audio24_ptr = reinterpret_cast<uint8_t*>(audio24.data());\r
+       auto size                = input.size();\r
+       for(int n = 0; n < size; ++n)           \r
+               *reinterpret_cast<uint32_t*>(audio24_ptr + n*3) = *(audio32_ptr + n) >> 8;      \r
+       audio24.resize(input.size());\r
+       return audio24;\r
+}\r
+\r
 }}
\ No newline at end of file
index 4f5c9baf77dbdd97a1f54f187fe87b807e9cfe60..c52a0b50ffa606cd80e14b5e15036a89d44e4247 100644 (file)
@@ -208,7 +208,7 @@ public:
        \r
        void schedule_next_video(const safe_ptr<core::read_frame>& frame)\r
        {\r
-               static std::vector<int16_t> silence(MAX_HANC_BUFFER_SIZE, 0);\r
+               static std::vector<int8_t> silence(MAX_HANC_BUFFER_SIZE, 0);\r
                \r
                executor_.begin_invoke([=]\r
                {\r
@@ -242,7 +242,7 @@ public:
 \r
                                if(embedded_audio_)\r
                                {               \r
-                                       auto frame_audio          = core::audio_32_to_16(frame->audio_data());\r
+                                       auto frame_audio          = core::audio_32_to_24(frame->audio_data());\r
                                        auto frame_audio_data = frame_audio.size() != audio_samples ? silence.data() : frame_audio.data();      \r
 \r
                                        encode_hanc(reinterpret_cast<BLUE_UINT32*>(reserved_frames_.front()->hanc_data()), frame_audio_data, audio_samples, audio_nchannels);\r
@@ -289,7 +289,7 @@ public:
 \r
        void encode_hanc(BLUE_UINT32* hanc_data, void* audio_data, size_t audio_samples, size_t audio_nchannels)\r
        {       \r
-               const auto sample_type = AUDIO_CHANNEL_16BIT | AUDIO_CHANNEL_LITTLEENDIAN;\r
+               const auto sample_type = AUDIO_CHANNEL_24BIT | AUDIO_CHANNEL_LITTLEENDIAN;\r
                const auto emb_audio_flag = blue_emb_audio_enable | blue_emb_audio_group1_enable;\r
                \r
                hanc_stream_info_struct hanc_stream_info;\r