[haiku-bugs] Re: [Haiku] #12720: Garbled audio due to incorrect parameters on some codecs

  • From: "korli" <trac@xxxxxxxxxxxx>
  • Date: Sat, 16 Jul 2016 07:56:12 -0000

#12720: Garbled audio due to incorrect parameters on some codecs
-----------------------------+----------------------------
   Reporter:  anevilyak      |      Owner:  pulkomandy
       Type:  bug            |     Status:  assigned
   Priority:  normal         |  Milestone:  Unscheduled
  Component:  Add-Ons/Media  |    Version:  R1/Development
 Resolution:                 |   Keywords:  ffmpeg
 Blocked By:                 |   Blocking:
Has a Patch:  0              |   Platform:  All
-----------------------------+----------------------------
Changes (by korli):

 * cc: pulkomandy (removed)
 * owner:  korli => pulkomandy


Comment:

 on x86_64, I tested with success this patch: it simply skips libswr, and
 interleaves samples.

 {{{
 diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp b/src
 /add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp
 index 27ec813..a18f4d9 100644
 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp
 +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp
 @@ -927,6 +927,7 @@
 AVCodecDecoder::_MoveAudioFramesToRawDecodedAudioAndUpdateStartTimes()
         // Some decoders do not support format conversion on themselves,
 or use
         // "planar" audio (each channel separated instead of interleaved
 samples).
         // In that case, we use swresample to convert the data
 +#if 0
         if (av_sample_fmt_is_planar(fContext->sample_fmt)) {
                 const uint8_t* ptr[8];
                 for (int i = 0; i < 8; i++) {
 @@ -950,6 +951,21 @@
 AVCodecDecoder::_MoveAudioFramesToRawDecodedAudioAndUpdateStartTimes()

                 if (frames < 0)
                         debugger("resampling failed");
 +#endif
 +       if (fOutputFrameSize != fInputFrameSize) {
 +               // planar audio
 +               uintptr_t out = (uintptr_t)fRawDecodedAudio->data[0];
 +               int32 offset = fDecodedDataBufferOffset;
 +               for (int i = 0; i < frames; i++) {
 +                       for (int j = 0; j < fContext->channels; j++) {
 +                               memcpy((void*)out,
 fDecodedDataBuffer->data[j]
 +                                       + offset, fInputFrameSize);
 +                               out += fInputFrameSize;
 +                       }
 +                       offset += fInputFrameSize;
 +               }
 +               outFrames = frames;
 +               inFrames = frames;
         } else {
                 memcpy(fRawDecodedAudio->data[0],
 fDecodedDataBuffer->data[0]
                                 + fDecodedDataBufferOffset, frames *
 fOutputFrameSize);

--
Ticket URL: <https://dev.haiku-os.org/ticket/12720#comment:4>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: