xine-lib-1.2.13-ffmpeg6-compatibility.patch 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. # HG changeset patch
  2. # User Torsten Jager <t.jager@gmx.de>
  3. # Date 1674929040 -3600
  4. # Sat Jan 28 19:04:00 2023 +0100
  5. # Node ID 771f4ae27e582123ff3500444718fc8f96186d74
  6. # Parent 250f1c09f4244c3e7ca7d414410c57bd387792c3
  7. ffmpeg compatibility update.
  8. diff -r 250f1c09f424 -r 771f4ae27e58 src/combined/ffmpeg/demux_avformat.c
  9. --- a/src/combined/ffmpeg/demux_avformat.c Wed Jan 25 17:03:55 2023 +0100
  10. +++ b/src/combined/ffmpeg/demux_avformat.c Sat Jan 28 19:04:00 2023 +0100
  11. @@ -1,5 +1,5 @@
  12. /*
  13. - * Copyright (C) 2013-2022 the xine project
  14. + * Copyright (C) 2013-2023 the xine project
  15. * Copyright (C) 2013-2020 Petri Hintukainen <phintuka@users.sourceforge.net>
  16. *
  17. * This file is part of xine, a free video player.
  18. @@ -423,8 +423,13 @@
  19. }
  20. #ifdef XFF_CODECPAR
  21. +# if XFF_AUDIO_CHANNEL_LAYOUT < 2
  22. if (st->codecpar && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
  23. st->codecpar->sample_rate != 0 && st->codecpar->channels != 0)
  24. +# else
  25. + if (st->codecpar && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
  26. + st->codecpar->sample_rate != 0 && st->codecpar->ch_layout.nb_channels != 0)
  27. +# endif
  28. #else
  29. if (st->codec && st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
  30. st->codec->sample_rate != 0 && st->codec->channels != 0)
  31. @@ -501,7 +506,11 @@
  32. buf->size = extradata_size + sizeof(xine_waveformatex);
  33. buf->decoder_info[1] = ctx->sample_rate;
  34. buf->decoder_info[2] = ctx->bits_per_coded_sample;
  35. +#if XFF_AUDIO_CHANNEL_LAYOUT < 2
  36. buf->decoder_info[3] = ctx->channels;
  37. +#else
  38. + buf->decoder_info[3] = ctx->ch_layout.nb_channels;
  39. +#endif
  40. buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_STDHEADER | BUF_FLAG_FRAME_END;
  41. this->stream->audio_fifo->put (this->stream->audio_fifo, buf);
  42. diff -r 250f1c09f424 -r 771f4ae27e58 src/combined/ffmpeg/ff_audio_decoder.c
  43. --- a/src/combined/ffmpeg/ff_audio_decoder.c Wed Jan 25 17:03:55 2023 +0100
  44. +++ b/src/combined/ffmpeg/ff_audio_decoder.c Sat Jan 28 19:04:00 2023 +0100
  45. @@ -1,5 +1,5 @@
  46. /*
  47. - * Copyright (C) 2001-2022 the xine project
  48. + * Copyright (C) 2001-2023 the xine project
  49. *
  50. * This file is part of xine, a free video player.
  51. *
  52. @@ -303,7 +303,11 @@
  53. this->context->bits_per_sample = this->ff_bits;
  54. this->context->sample_rate = this->ff_sample_rate;
  55. +#if XFF_AUDIO_CHANNEL_LAYOUT < 2
  56. this->context->channels = this->ff_channels;
  57. +#else
  58. + this->context->ch_layout.nb_channels = this->ff_channels;
  59. +#endif
  60. this->context->codec_id = this->codec->id;
  61. this->context->codec_type = this->codec->type;
  62. this->context->codec_tag = _x_stream_info_get(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC);
  63. @@ -527,16 +531,75 @@
  64. this->ao_mode = 0;
  65. }
  66. +static unsigned int ff_list_channels (uint8_t *list, uint64_t map) {
  67. + unsigned int n, bit;
  68. +
  69. + for (n = bit = 0; map; map >>= 1, bit++) {
  70. + uint32_t b = map & 1;
  71. +
  72. + list[n] = bit;
  73. + n += b;
  74. + }
  75. + return n;
  76. +}
  77. +
  78. static void ff_map_channels (ff_audio_decoder_t *this) {
  79. uint64_t ff_map;
  80. + uint8_t ff_list[64];
  81. + unsigned int ff_num;
  82. + const char *type = "native";
  83. int caps = this->stream->audio_out->get_capabilities (this->stream->audio_out);
  84. +#if XFF_AUDIO_CHANNEL_LAYOUT < 2
  85. +
  86. /* safety kludge for very old libavcodec */
  87. -#ifdef AV_CH_FRONT_LEFT
  88. +# ifdef AV_CH_FRONT_LEFT
  89. ff_map = this->context->channel_layout;
  90. if (!ff_map) /* wma2 bug */
  91. +# endif
  92. + ff_map = ((uint64_t)1 << this->context->channels) - 1;
  93. + ff_num = ff_list_channels (ff_list, ff_map);
  94. +
  95. +#else /* XFF_AUDIO_CHANNEL_LAYOUT == 2 */
  96. +
  97. + ff_num = this->context->ch_layout.nb_channels;
  98. + if (ff_num > (int)(sizeof (ff_list) / sizeof (ff_list[0])))
  99. + ff_num = sizeof (ff_list) / sizeof (ff_list[0]);
  100. + switch (this->context->ch_layout.order) {
  101. + const AVChannelCustom *cmap;
  102. + unsigned int i;
  103. +
  104. + case AV_CHANNEL_ORDER_UNSPEC:
  105. + type = "unknown";
  106. + goto _fallback;
  107. +
  108. + case AV_CHANNEL_ORDER_NATIVE:
  109. + ff_map = this->context->ch_layout.u.mask;
  110. + if (!ff_map) /* wma2 bug */
  111. + ff_map = ((uint64_t)1 << ff_num) - 1;
  112. + ff_num = ff_list_channels (ff_list, ff_map);
  113. + break;
  114. +
  115. + case AV_CHANNEL_ORDER_CUSTOM:
  116. + type = "custom";
  117. + if (!(cmap = this->context->ch_layout.u.map))
  118. + goto _fallback;
  119. + ff_map = 0;
  120. + for (i = 0; i < ff_num; i++) {
  121. + ff_list[i] = cmap[i].id;
  122. + ff_map |= (uint64_t)1 << ff_list[i];
  123. + }
  124. + break;
  125. +
  126. + default:
  127. + type = "unsupported";
  128. + /* fall through */
  129. + _fallback:
  130. + ff_map = ((uint64_t)1 << ff_num) - 1;
  131. + ff_num = ff_list_channels (ff_list, ff_map);
  132. + }
  133. +
  134. #endif
  135. - ff_map = ((uint64_t)1 << this->context->channels) - 1;
  136. if ((caps != this->ao_caps) || (ff_map != this->ff_map)) {
  137. unsigned int i, j;
  138. @@ -562,7 +625,7 @@
  139. this->ao_caps = caps;
  140. this->ff_map = ff_map;
  141. - this->ff_channels = this->context->channels;
  142. + this->ff_channels = ff_num;
  143. /* silence out */
  144. for (i = 0; i < MAX_CHANNELS; i++)
  145. @@ -576,20 +639,23 @@
  146. this->left[0] = this->right[0] = 0;
  147. tries = wishlist + 0 * num_modes;
  148. } else if (this->ff_channels == 2) { /* stereo */
  149. + /* FIXME: libxine does not yet support audio selection _after_ decoding.
  150. + * For now, treat the most common "dual mono" case as stereo. */
  151. name_map[0] = 0;
  152. name_map[1] = 1;
  153. this->left[0] = 0;
  154. this->right[0] = 1;
  155. tries = wishlist + 1 * num_modes;
  156. } else {
  157. - for (i = j = 0; i < sizeof (base_map) / sizeof (base_map[0]); i++) {
  158. - if ((ff_map >> i) & 1) {
  159. - int8_t target = base_map[i];
  160. - if ((target >= 0) && (this->map[target] < 0))
  161. - this->map[target] = j;
  162. - name_map[j] = i; /* for debug output below */
  163. - j++;
  164. - }
  165. + for (i = 0; i < ff_num; i++) {
  166. + int8_t target;
  167. + uint32_t num = ff_list[i];
  168. + if (num >= sizeof (base_map) / sizeof (base_map[0]))
  169. + continue;
  170. + target = base_map[num];
  171. + if ((target >= 0) && (this->map[target] < 0))
  172. + this->map[target] = i;
  173. + name_map[i] = num; /* for debug output below */
  174. }
  175. this->left[0] = this->map[0] < 0 ? 0 : this->map[0];
  176. this->map[0] = -1;
  177. @@ -641,8 +707,8 @@
  178. "rear center",
  179. "side left", "side right"
  180. };
  181. - int8_t buf[200];
  182. - int p = sprintf (buf, "ff_audio_dec: channel layout: ");
  183. + int8_t buf[256];
  184. + int p = sprintf (buf, "ff_audio_dec: %s channel layout: ", type);
  185. int8_t *indx = this->left;
  186. for (i = 0; i < 2; i++) {
  187. buf[p++] = '[';