#5897: swresample. Incorrect work of swr_set_matrix() if the SwrContext was 
never
initialized
-------------------------------------+-------------------------------------
             Reporter:  v0lt         |                     Type:  defect
               Status:  new          |                 Priority:  important
            Component:  swresample   |                  Version:
             Keywords:               |  unspecified
             Blocking:               |               Blocked By:
Analyzed by developer:  0            |  Reproduced by developer:  0
-------------------------------------+-------------------------------------
 Summary of the bug:

 Function swr_set_matrix() muted front channels when mixing from
 AV_CH_LAYOUT_6POINT1 in AV_CH_LAYOUT_STEREO if the SwrContext was never
 initialized.

 How to reproduce:
 {{{
 SwrContext* m_pSWRCxt = swr_alloc();

 for (int i = 1; i <= 2; i++) {
         int ret = 0;

         swr_close(m_pSWRCxt);

         av_opt_set_int(m_pSWRCxt, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
         av_opt_set_int(m_pSWRCxt, "out_sample_fmt", AV_SAMPLE_FMT_FLT, 0);
         av_opt_set_int(m_pSWRCxt, "in_channel_layout",
 AV_CH_LAYOUT_6POINT1, 0);
         av_opt_set_int(m_pSWRCxt, "out_channel_layout",
 AV_CH_LAYOUT_STEREO, 0);
         av_opt_set_int(m_pSWRCxt, "in_sample_rate", 48000, 0);
         av_opt_set_int(m_pSWRCxt, "out_sample_rate", 48000, 0);

         const int in_ch  = av_popcount(AV_CH_LAYOUT_6POINT1);
         const int out_ch = av_popcount(AV_CH_LAYOUT_STEREO);
         double* m_matrix_dbl = (double*)av_mallocz(in_ch * out_ch *
 sizeof(*m_matrix_dbl));

         const double center_mix_level   = M_SQRT1_2;
         const double surround_mix_level = 1.0;
         const double lfe_mix_level      = 1.0;
         const double rematrix_maxval    = INT_MAX;
         const double rematrix_volume    = 0.0;
         ret = swr_build_matrix(
                 m_in_layout, m_out_layout,
                 center_mix_level, surround_mix_level, lfe_mix_level,
                 rematrix_maxval, rematrix_volume,
                 m_matrix_dbl, in_ch,
                 AV_MATRIX_ENCODING_NONE, NULL);

         ret = swr_set_matrix(m_pSWRCxt, m_matrix_dbl, in_ch);

         ret = swr_init(m_pSWRCxt);

         // working...
         // if i = 1 get the silence.
         // if i = 2 get the sound.
 }

 swr_free(&m_pSWRCxt);
 av_free(m_matrix_dbl);
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/5897>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
_______________________________________________
FFmpeg-trac mailing list
FFmpeg-trac@avcodec.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-trac

Reply via email to