Guest User

Untitled

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