0011-Fix-ogg123-speex-stereo-Initialize-stereo-info-data-.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. From: =?utf-8?q?Martin_Stegh=C3=B6fer?= <martin@steghoefer.eu>
  2. Date: Tue, 9 Dec 2014 23:14:08 +0100
  3. Subject: Fix ogg123 speex stereo: Initialize stereo info data structure
  4. The ogg123 executable wasn't able to correctly play stereo speex
  5. files that don't contain any inband intensity stereo signals at
  6. all or whose first inband intensity stereo signal arrives after
  7. the stream has already started. This was due to the stereo
  8. information data structure not being initialized properly before
  9. the first inband intensity stereo signal arrived. So in the
  10. mentioned cases the speex decoder used uninitialized float
  11. values for the stereo decoding. This patch fixes the problem by
  12. using the proper initialization and deallocation functions from
  13. libspeex.
  14. Bug-Debian: https://bugs.debian.org/312185
  15. Forwarded: https://trac.xiph.org/ticket/1676#comment:1
  16. ---
  17. ogg123/speex_format.c | 8 +++++---
  18. 1 file changed, 5 insertions(+), 3 deletions(-)
  19. diff --git a/ogg123/speex_format.c b/ogg123/speex_format.c
  20. index 9aad365..c5a453d 100644
  21. --- a/ogg123/speex_format.c
  22. +++ b/ogg123/speex_format.c
  23. @@ -47,7 +47,7 @@ typedef struct speex_private_t {
  24. ogg_packet op;
  25. ogg_stream_state os;
  26. SpeexBits bits;
  27. - SpeexStereoState stereo;
  28. + SpeexStereoState *stereo;
  29. SpeexHeader *header;
  30. void *st;
  31. @@ -142,6 +142,7 @@ decoder_t* speex_init (data_source_t *source, ogg123_options_t *ogg123_opts,
  32. private->comment_packet = NULL;
  33. private->comment_packet_len = 0;
  34. private->header = NULL;
  35. + private->stereo = speex_stereo_state_init();
  36. private->stats.total_time = 0.0;
  37. private->stats.current_time = 0.0;
  38. @@ -234,7 +235,7 @@ int speex_read (decoder_t *decoder, void *ptr, int nbytes, int *eos,
  39. speex_decode(priv->st, &priv->bits, temp_output);
  40. if (audio_fmt->channels==2)
  41. - speex_decode_stereo(temp_output, priv->frame_size, &priv->stereo);
  42. + speex_decode_stereo(temp_output, priv->frame_size, priv->stereo);
  43. priv->samples_decoded += priv->frame_size;
  44. @@ -328,6 +329,7 @@ void speex_cleanup (decoder_t *decoder)
  45. {
  46. speex_private_t *priv = decoder->private;
  47. + speex_stereo_state_destroy(priv->stereo);
  48. free(priv->comment_packet);
  49. free(priv->output);
  50. free(decoder->private);
  51. @@ -544,7 +546,7 @@ int read_speex_header (decoder_t *decoder)
  52. priv->st = process_header(&priv->op,
  53. &priv->frame_size,
  54. &priv->header,
  55. - &priv->stereo,
  56. + priv->stereo,
  57. decoder->callbacks,
  58. decoder->callback_arg);