Guest User

Untitled

a guest
Jan 26th, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 11.11 KB | None | 0 0
  1. From 92d9746c8a8a002e3db7447c7706669a127fe8db Mon Sep 17 00:00:00 2001
  2. From: Michael Niedermayer <michaelni@gmx.at>
  3. Date: Fri, 23 Sep 2011 02:43:57 +0200
  4. Subject: [PATCH 1/7] aacdec: Disable locking code for parse_adts_frame_header() non zero chan config
  5.  
  6. This fixes changing channels.
  7. It possibly might cause regressions but i cant avoid this without having a test
  8. case that needs the locking code.
  9.  
  10. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  11. ---
  12. libavcodec/aacdec.c |    2 +-
  13.  1 files changed, 1 insertions(+), 1 deletions(-)
  14.  
  15. diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
  16. index a3a6b42..0be45b7 100644
  17. --- a/libavcodec/aacdec.c
  18. +++ b/libavcodec/aacdec.c
  19. @@ -2077,7 +2077,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
  20.  
  21.      size = avpriv_aac_parse_header(gb, &hdr_info);
  22.      if (size > 0) {
  23. -        if (ac->output_configured != OC_LOCKED && hdr_info.chan_config) {
  24. +        if (hdr_info.chan_config) {
  25.              enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
  26.              memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
  27.              ac->m4ac.chan_config = hdr_info.chan_config;
  28. --
  29. 1.7.0.2.msysgit.0
  30.  
  31.  
  32. From 5ac19e941ed9174ee0b931501377fc1e20bdad08 Mon Sep 17 00:00:00 2001
  33. From: Michael Niedermayer <michaelni@gmx.at>
  34. Date: Fri, 23 Sep 2011 22:30:27 +0200
  35. Subject: [PATCH 2/7] aacsbr: Add an assert checking for an inconsistency
  36.  
  37. This inconsistency was noticed during debug.
  38. I dont know if this can happen normally, but if sit can,
  39. it would be quite bad.
  40.  
  41. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  42. ---
  43. libavcodec/aacsbr.c |    2 ++
  44.  1 files changed, 2 insertions(+), 0 deletions(-)
  45.  
  46. diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
  47. index 81b0b4c..2910395 100644
  48. --- a/libavcodec/aacsbr.c
  49. +++ b/libavcodec/aacsbr.c
  50. @@ -33,6 +33,7 @@
  51.  #include "fft.h"
  52.  #include "aacps.h"
  53.  #include "libavutil/libm.h"
  54. +#include "libavutil/avassert.h"
  55.  
  56.  #include <stdint.h>
  57.  #include <float.h>
  58. @@ -1456,6 +1457,7 @@ static void sbr_mapping(AACContext *ac, SpectralBandReplication *sbr,
  59.          uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow;
  60.          int k;
  61.  
  62. +        av_assert0(sbr->kx[1] <= table[0]);
  63.          for (i = 0; i < ilim; i++)
  64.              for (m = table[i]; m < table[i + 1]; m++)
  65.                  sbr->e_origmapped[e][m - sbr->kx[1]] = ch_data->env_facs[e+1][i];
  66. --
  67. 1.7.0.2.msysgit.0
  68.  
  69.  
  70. From d429e4e8d5be640df559458a276ede09fd7de81f Mon Sep 17 00:00:00 2001
  71. From: Michael Niedermayer <michaelni@gmx.at>
  72. Date: Fri, 23 Sep 2011 22:31:57 +0200
  73. Subject: [PATCH 3/7] aacsbr: prevent multiple ff_aac_sbr_ctx_init()
  74.  
  75. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  76. ---
  77. libavcodec/aacsbr.c |    2 ++
  78.  1 files changed, 2 insertions(+), 0 deletions(-)
  79.  
  80. diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
  81. index 2910395..60fa701 100644
  82. --- a/libavcodec/aacsbr.c
  83. +++ b/libavcodec/aacsbr.c
  84. @@ -130,6 +130,8 @@ av_cold void ff_aac_sbr_init(void)
  85.  av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr)
  86.  {
  87.      float mdct_scale;
  88. +    if(sbr->mdct.mdct_bits)
  89. +        return;
  90.      sbr->kx[0] = sbr->kx[1] = 32; //Typo in spec, kx' inits to 32
  91.      sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1;
  92.      sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128);
  93. --
  94. 1.7.0.2.msysgit.0
  95.  
  96.  
  97. From 1f8eb2de1571be8187f7360c45aec0da6242142e Mon Sep 17 00:00:00 2001
  98. From: Michael Niedermayer <michaelni@gmx.at>
  99. Date: Fri, 23 Sep 2011 22:34:26 +0200
  100. Subject: [PATCH 4/7] aacdec: Make aac-latm closer to the spec
  101.  
  102. Make it not read random data leading to random false configurations.
  103.  
  104. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  105.  
  106. Conflicts:
  107.  
  108.     libavcodec/aacdec.c
  109. ---
  110. libavcodec/aacdec.c |   14 +++++++-------
  111.  1 files changed, 7 insertions(+), 7 deletions(-)
  112.  
  113. diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
  114. index 0be45b7..8338e25 100644
  115. --- a/libavcodec/aacdec.c
  116. +++ b/libavcodec/aacdec.c
  117. @@ -458,7 +458,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
  118.  static int decode_audio_specific_config(AACContext *ac,
  119.                                          AVCodecContext *avctx,
  120.                                          MPEG4AudioConfig *m4ac,
  121. -                                        const uint8_t *data, int data_size)
  122. +                                        const uint8_t *data, int data_size, int asclen)
  123.  {
  124.      GetBitContext gb;
  125.      int i;
  126. @@ -470,7 +470,7 @@ static int decode_audio_specific_config(AACContext *ac,
  127.  
  128.      init_get_bits(&gb, data, data_size * 8);
  129.  
  130. -    if ((i = avpriv_mpeg4audio_get_config(m4ac, data, data_size)) < 0)
  131. +    if ((i = avpriv_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0)
  132.          return -1;
  133.      if (m4ac->sampling_index > 12) {
  134.          av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);
  135. @@ -570,7 +570,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
  136.      if (avctx->extradata_size > 0) {
  137.          if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
  138.                                           avctx->extradata,
  139. -                                         avctx->extradata_size) < 0)
  140. +                                         avctx->extradata_size, 8*avctx->extradata_size) < 0)
  141.              return -1;
  142.      } else {
  143.          int sr, i;
  144. @@ -2307,7 +2307,7 @@ static inline uint32_t latm_get_value(GetBitContext *b)
  145.  }
  146.  
  147.  static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
  148. -                                             GetBitContext *gb)
  149. +                                             GetBitContext *gb, int asclen)
  150.  {
  151.      AVCodecContext *avctx = latmctx->aac_ctx.avctx;
  152.      MPEG4AudioConfig m4ac;
  153. @@ -2322,7 +2322,7 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
  154.          bits_consumed =
  155.              decode_audio_specific_config(NULL, avctx, &m4ac,
  156.                                           gb->buffer + (config_start_bit / 8),
  157. -                                         get_bits_left(gb) / 8);
  158. +                                         get_bits_left(gb) / 8, asclen);
  159.  
  160.          if (bits_consumed < 0)
  161.              return AVERROR_INVALIDDATA;
  162. @@ -2380,11 +2380,11 @@ static int read_stream_mux_config(struct LATMContext *latmctx,
  163.  
  164.          // for all but first stream: use_same_config = get_bits(gb, 1);
  165.          if (!audio_mux_version) {
  166. -            if ((ret = latm_decode_audio_specific_config(latmctx, gb)) < 0)
  167. +            if ((ret = latm_decode_audio_specific_config(latmctx, gb, 0)) < 0)
  168.                  return ret;
  169.          } else {
  170.              int ascLen = latm_get_value(gb);
  171. -            if ((ret = latm_decode_audio_specific_config(latmctx, gb)) < 0)
  172. +            if ((ret = latm_decode_audio_specific_config(latmctx, gb, ascLen)) < 0)
  173.                  return ret;
  174.              ascLen -= ret;
  175.              skip_bits_long(gb, ascLen);
  176. --
  177. 1.7.0.2.msysgit.0
  178.  
  179.  
  180. From bd021c274a3ac1c415f224231de7d1d62336f6a0 Mon Sep 17 00:00:00 2001
  181. From: Michael Niedermayer <michaelni@gmx.at>
  182. Date: Fri, 23 Sep 2011 22:41:10 +0200
  183. Subject: [PATCH 5/7] aacdec: fix channel reconfigs on LATM
  184.  
  185. Fixes FFmpeg ticket 200.
  186.  
  187. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  188. ---
  189. libavcodec/aacdec.c |    4 +++-
  190.  1 files changed, 3 insertions(+), 1 deletions(-)
  191.  
  192. diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
  193. index 8338e25..41d1aaa 100644
  194. --- a/libavcodec/aacdec.c
  195. +++ b/libavcodec/aacdec.c
  196. @@ -2311,6 +2311,7 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
  197.  {
  198.      AVCodecContext *avctx = latmctx->aac_ctx.avctx;
  199.      MPEG4AudioConfig m4ac;
  200. +    AACContext *ac= &latmctx->aac_ctx;
  201.      int  config_start_bit = get_bits_count(gb);
  202.      int     bits_consumed, esize;
  203.  
  204. @@ -2320,12 +2321,13 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
  205.          return AVERROR_INVALIDDATA;
  206.      } else {
  207.          bits_consumed =
  208. -            decode_audio_specific_config(NULL, avctx, &m4ac,
  209. +            decode_audio_specific_config(ac, avctx, &m4ac,
  210.                                           gb->buffer + (config_start_bit / 8),
  211.                                           get_bits_left(gb) / 8, asclen);
  212.  
  213.          if (bits_consumed < 0)
  214.              return AVERROR_INVALIDDATA;
  215. +        ac->m4ac= m4ac;
  216.  
  217.          esize = (bits_consumed+7) / 8;
  218.  
  219. --
  220. 1.7.0.2.msysgit.0
  221.  
  222.  
  223. From a7f4fa723b1101c0c5146043f8aac0b27ab10f22 Mon Sep 17 00:00:00 2001
  224. From: Michael Niedermayer <michaelni@gmx.at>
  225. Date: Thu, 20 Oct 2011 13:54:54 +0200
  226. Subject: [PATCH 6/7] aacdec: support chan config =1 stereo files
  227.  
  228. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  229. ---
  230. libavcodec/aacdec.c |    9 +++++++++
  231.  1 files changed, 9 insertions(+), 0 deletions(-)
  232.  
  233. diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
  234. index 41d1aaa..7dfa070 100644
  235. --- a/libavcodec/aacdec.c
  236. +++ b/libavcodec/aacdec.c
  237. @@ -2135,6 +2135,15 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
  238.          elem_id = get_bits(gb, 4);
  239.  
  240.          if (elem_type < TYPE_DSE) {
  241. +            if (!ac->tags_mapped && elem_type == TYPE_CPE && ac->m4ac.chan_config==1) {
  242. +                enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]= {0};
  243. +                ac->m4ac.chan_config=2;
  244. +
  245. +                if (set_default_channel_config(ac->avctx, new_che_pos, 2)<0)
  246. +                    return -1;
  247. +                if (output_configure(ac, ac->che_pos, new_che_pos, 2, OC_TRIAL_FRAME)<0)
  248. +                    return -1;
  249. +            }
  250.              if (!(che=get_che(ac, elem_type, elem_id))) {
  251.                  av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
  252.                         elem_type, elem_id);
  253. --
  254. 1.7.0.2.msysgit.0
  255.  
  256.  
  257. From a07baa99b7dbc361796000238b3e88864049c464 Mon Sep 17 00:00:00 2001
  258. From: Michael Niedermayer <michaelni@gmx.at>
  259. Date: Thu, 20 Oct 2011 21:57:52 +0200
  260. Subject: [PATCH 7/7] aacdec: only overwrite configuration if theres a actual change
  261.  
  262. Fixes FFmpeg ticket 574.
  263.  
  264. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  265. ---
  266. libavcodec/aacdec.c |    5 +++--
  267.  1 files changed, 3 insertions(+), 2 deletions(-)
  268.  
  269. diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
  270. index 7dfa070..1dc19d5 100644
  271. --- a/libavcodec/aacdec.c
  272. +++ b/libavcodec/aacdec.c
  273. @@ -2319,8 +2319,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
  274.                                               GetBitContext *gb, int asclen)
  275.  {
  276.      AVCodecContext *avctx = latmctx->aac_ctx.avctx;
  277. -    MPEG4AudioConfig m4ac;
  278.      AACContext *ac= &latmctx->aac_ctx;
  279. +    MPEG4AudioConfig m4ac=ac->m4ac;
  280.      int  config_start_bit = get_bits_count(gb);
  281.      int     bits_consumed, esize;
  282.  
  283. @@ -2336,7 +2336,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
  284.  
  285.          if (bits_consumed < 0)
  286.              return AVERROR_INVALIDDATA;
  287. -        ac->m4ac= m4ac;
  288. +        if(ac->m4ac.sample_rate != m4ac.sample_rate || m4ac.chan_config != ac->m4ac.chan_config)
  289. +            ac->m4ac= m4ac;
  290.  
  291.          esize = (bits_consumed+7) / 8;
  292.  
  293. --
  294. 1.7.0.2.msysgit.0
Add Comment
Please, Sign In to add comment