]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'dc70c19476e76f1118df73b5d97cc76f0e5f6f6c'
authorHendrik Leppkes <h.leppkes@gmail.com>
Sat, 5 Sep 2015 14:42:44 +0000 (16:42 +0200)
committerHendrik Leppkes <h.leppkes@gmail.com>
Sat, 5 Sep 2015 14:42:44 +0000 (16:42 +0200)
* commit 'dc70c19476e76f1118df73b5d97cc76f0e5f6f6c':
  lavc: Drop deprecated request_channels related functions

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
1  2 
libavcodec/aac_ac3_parser.c
libavcodec/ac3dec.c
libavcodec/avcodec.h
libavcodec/dcadec.c
libavcodec/mlp_parser.c
libavcodec/mlpdec.c
libavcodec/options_table.h
libavcodec/version.h

Simple merge
index 398224753f99e28a3eeb8fcc89c95fa3a649206f,97ce2878a8740308b6dd0af0475dbff4c205fcbb..6df697e855b8195d629239149129136b24b6b34b
@@@ -189,33 -180,16 +189,25 @@@ static av_cold int ac3_decode_init(AVCo
      ac3_tables_init();
      ff_mdct_init(&s->imdct_256, 8, 1, 1.0);
      ff_mdct_init(&s->imdct_512, 9, 1, 1.0);
 -    ff_kbd_window_init(s->window, 5.0, 256);
 +    AC3_RENAME(ff_kbd_window_init)(s->window, 5.0, 256);
      ff_bswapdsp_init(&s->bdsp);
 -    avpriv_float_dsp_init(&s->fdsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
 -    ff_ac3dsp_init(&s->ac3dsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
 +
 +#if (USE_FIXED)
 +    s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
 +#else
 +    s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
      ff_fmt_convert_init(&s->fmt_conv, avctx);
 +#endif
 +
 +    ff_ac3dsp_init(&s->ac3dsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
      av_lfg_init(&s->dith_state, 0);
  
 -    avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
 +    if (USE_FIXED)
 +        avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
 +    else
 +        avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
  
      /* allow downmixing to stereo or mono */
- #if FF_API_REQUEST_CHANNELS
- FF_DISABLE_DEPRECATION_WARNINGS
-     if (avctx->request_channels == 1)
-         avctx->request_channel_layout = AV_CH_LAYOUT_MONO;
-     else if (avctx->request_channels == 2)
-         avctx->request_channel_layout = AV_CH_LAYOUT_STEREO;
- FF_ENABLE_DEPRECATION_WARNINGS
- #endif
      if (avctx->channels > 1 &&
          avctx->request_channel_layout == AV_CH_LAYOUT_MONO)
          avctx->channels = 1;
Simple merge
index eae6c44844f099d958338b63621c71b66e7fe82a,abf762d906a863459ec0c529ec754c02e3499aea..741f2f766dd176b9172a36e4a6e56802db711468
@@@ -1667,159 -1294,92 +1667,128 @@@ static int dca_decode_frame(AVCodecCont
  
      full_channels = channels = s->prim_channels + !!s->lfe;
  
 -    if (s->amode < 16) {
 -        avctx->channel_layout = dca_core_channel_layout[s->amode];
 -
 -        if (s->prim_channels + !!s->lfe > 2 &&
 -            avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
 -            /*
 -             * Neither the core's auxiliary data nor our default tables contain
 -             * downmix coefficients for the additional channel coded in the XCh
 -             * extension, so when we're doing a Stereo downmix, don't decode it.
 -             */
 -            s->xch_disable = 1;
 -        }
 +    /* If we have XXCH then the channel layout is managed differently */
 +    /* note that XLL will also have another way to do things */
- #if FF_API_REQUEST_CHANNELS
- FF_DISABLE_DEPRECATION_WARNINGS
-     if (!(s->core_ext_mask & DCA_EXT_XXCH)
-         || (s->core_ext_mask & DCA_EXT_XXCH && avctx->request_channels > 0
-             && avctx->request_channels
-             < num_core_channels + !!s->lfe + s->xxch_chset_nch[0]))
-     {
- FF_ENABLE_DEPRECATION_WARNINGS
- #else
 +    if (!(s->core_ext_mask & DCA_EXT_XXCH)) {
- #endif
 +        /* xxx should also do MA extensions */
 +        if (s->amode < 16) {
 +            avctx->channel_layout = ff_dca_core_channel_layout[s->amode];
 +
 +            if (s->prim_channels + !!s->lfe > 2 &&
 +                avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
 +                /*
 +                 * Neither the core's auxiliary data nor our default tables contain
 +                 * downmix coefficients for the additional channel coded in the XCh
 +                 * extension, so when we're doing a Stereo downmix, don't decode it.
 +                 */
 +                s->xch_disable = 1;
 +            }
  
- #if FF_API_REQUEST_CHANNELS
- FF_DISABLE_DEPRECATION_WARNINGS
-             if (s->xch_present && !s->xch_disable &&
-                 (!avctx->request_channels ||
-                  avctx->request_channels > num_core_channels + !!s->lfe)) {
- FF_ENABLE_DEPRECATION_WARNINGS
- #else
 -        if (s->xch_present && !s->xch_disable) {
 -            avctx->channel_layout |= AV_CH_BACK_CENTER;
 -            if (s->lfe) {
 -                avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
 -                s->channel_order_tab = ff_dca_channel_reorder_lfe_xch[s->amode];
 +            if (s->xch_present && !s->xch_disable) {
- #endif
 +                if (avctx->channel_layout & AV_CH_BACK_CENTER) {
 +                    avpriv_request_sample(avctx, "XCh with Back center channel");
 +                    return AVERROR_INVALIDDATA;
 +                }
 +                avctx->channel_layout |= AV_CH_BACK_CENTER;
 +                if (s->lfe) {
 +                    avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
 +                    s->channel_order_tab = ff_dca_channel_reorder_lfe_xch[s->amode];
 +                } else {
 +                    s->channel_order_tab = ff_dca_channel_reorder_nolfe_xch[s->amode];
 +                }
 +                if (s->channel_order_tab[s->xch_base_channel] < 0)
 +                    return AVERROR_INVALIDDATA;
              } else {
 -                s->channel_order_tab = ff_dca_channel_reorder_nolfe_xch[s->amode];
 +                channels       = num_core_channels + !!s->lfe;
 +                s->xch_present = 0; /* disable further xch processing */
 +                if (s->lfe) {
 +                    avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
 +                    s->channel_order_tab = ff_dca_channel_reorder_lfe[s->amode];
 +                } else
 +                    s->channel_order_tab = ff_dca_channel_reorder_nolfe[s->amode];
              }
 +
 +            if (channels > !!s->lfe &&
 +                s->channel_order_tab[channels - 1 - !!s->lfe] < 0)
 +                return AVERROR_INVALIDDATA;
 +
 +            if (av_get_channel_layout_nb_channels(avctx->channel_layout) != channels) {
 +                av_log(avctx, AV_LOG_ERROR, "Number of channels %d mismatches layout %d\n", channels, av_get_channel_layout_nb_channels(avctx->channel_layout));
 +                return AVERROR_INVALIDDATA;
 +            }
 +
 +            if (num_core_channels + !!s->lfe > 2 &&
 +                avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
 +                channels              = 2;
 +                s->output             = s->prim_channels == 2 ? s->amode : DCA_STEREO;
 +                avctx->channel_layout = AV_CH_LAYOUT_STEREO;
 +            }
 +            else if (avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE) {
 +                static const int8_t dca_channel_order_native[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
 +                s->channel_order_tab = dca_channel_order_native;
 +            }
 +            s->lfe_index = ff_dca_lfe_index[s->amode];
          } else {
 -            channels       = num_core_channels + !!s->lfe;
 -            s->xch_present = 0; /* disable further xch processing */
 -            if (s->lfe) {
 -                avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
 -                s->channel_order_tab = ff_dca_channel_reorder_lfe[s->amode];
 -            } else
 -                s->channel_order_tab = ff_dca_channel_reorder_nolfe[s->amode];
 +            av_log(avctx, AV_LOG_ERROR,
 +                   "Non standard configuration %d !\n", s->amode);
 +            return AVERROR_INVALIDDATA;
          }
  
 -        if (channels > !!s->lfe &&
 -            s->channel_order_tab[channels - 1 - !!s->lfe] < 0)
 -            return AVERROR_INVALIDDATA;
 +        s->xxch_dmix_embedded = 0;
 +    } else {
 +        /* we only get here if an XXCH channel set can be added to the mix */
 +        channel_mask = s->xxch_core_spkmask;
  
- #if FF_API_REQUEST_CHANNELS
- FF_DISABLE_DEPRECATION_WARNINGS
-         if (avctx->request_channels > 0
-             && avctx->request_channels < s->prim_channels) {
-             channels = num_core_channels + !!s->lfe;
-             for (i = 0; i < s->xxch_chset && channels + s->xxch_chset_nch[i]
-                                               <= avctx->request_channels; i++) {
-                 channels += s->xxch_chset_nch[i];
-                 channel_mask |= s->xxch_spk_masks[i];
-             }
- FF_ENABLE_DEPRECATION_WARNINGS
-         } else
- #endif
 -        if (num_core_channels + !!s->lfe > 2 &&
 -            avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
 -            channels              = 2;
 -            s->output             = s->prim_channels == 2 ? s->amode : DCA_STEREO;
 -            avctx->channel_layout = AV_CH_LAYOUT_STEREO;
 +        {
 +            channels = s->prim_channels + !!s->lfe;
 +            for (i = 0; i < s->xxch_chset; i++) {
 +                channel_mask |= s->xxch_spk_masks[i];
 +            }
 +        }
  
 -            /* Stereo downmix coefficients
 -             *
 -             * The decoder can only downmix to 2-channel, so we need to ensure
 -             * embedded downmix coefficients are actually targeting 2-channel.
 -             */
 -            if (s->core_downmix && (s->core_downmix_amode == DCA_STEREO ||
 -                                    s->core_downmix_amode == DCA_STEREO_TOTAL)) {
 -                for (i = 0; i < num_core_channels + !!s->lfe; i++) {
 -                    /* Range checked earlier */
 -                    s->downmix_coef[i][0] = dca_dmix_code(s->core_downmix_codes[i][0]);
 -                    s->downmix_coef[i][1] = dca_dmix_code(s->core_downmix_codes[i][1]);
 -                }
 -                s->output = s->core_downmix_amode;
 -            } else {
 -                int am = s->amode & DCA_CHANNEL_MASK;
 -                if (am >= FF_ARRAY_ELEMS(ff_dca_default_coeffs)) {
 -                    av_log(s->avctx, AV_LOG_ERROR,
 -                           "Invalid channel mode %d\n", am);
 -                    return AVERROR_INVALIDDATA;
 -                }
 -                if (num_core_channels + !!s->lfe >
 -                    FF_ARRAY_ELEMS(ff_dca_default_coeffs[0])) {
 -                    avpriv_request_sample(s->avctx, "Downmixing %d channels",
 -                                          s->prim_channels + !!s->lfe);
 -                    return AVERROR_PATCHWELCOME;
 -                }
 -                for (i = 0; i < num_core_channels + !!s->lfe; i++) {
 -                    s->downmix_coef[i][0] = ff_dca_default_coeffs[am][i][0];
 -                    s->downmix_coef[i][1] = ff_dca_default_coeffs[am][i][1];
 -                }
 +        /* Given the DTS spec'ed channel mask, generate an avcodec version */
 +        channel_layout = 0;
 +        for (i = 0; i < s->xxch_nbits_spk_mask; ++i) {
 +            if (channel_mask & (1 << i)) {
 +                channel_layout |= ff_dca_map_xxch_to_native[i];
              }
 -            ff_dlog(s->avctx, "Stereo downmix coeffs:\n");
 -            for (i = 0; i < num_core_channels + !!s->lfe; i++) {
 -                ff_dlog(s->avctx, "L, input channel %d = %f\n", i,
 -                        s->downmix_coef[i][0]);
 -                ff_dlog(s->avctx, "R, input channel %d = %f\n", i,
 -                        s->downmix_coef[i][1]);
 +        }
 +
 +        /* make sure that we have managed to get equivalent dts/avcodec channel
 +         * masks in some sense -- unfortunately some channels could overlap */
 +        if (av_popcount(channel_mask) != av_popcount(channel_layout)) {
 +            av_log(avctx, AV_LOG_DEBUG,
 +                   "DTS-XXCH: Inconsistent avcodec/dts channel layouts\n");
 +            return AVERROR_INVALIDDATA;
 +        }
 +
 +        avctx->channel_layout = channel_layout;
 +
 +        if (!(avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE)) {
 +            /* Estimate DTS --> avcodec ordering table */
 +            for (chset = -1, j = 0; chset < s->xxch_chset; ++chset) {
 +                mask = chset >= 0 ? s->xxch_spk_masks[chset]
 +                                  : s->xxch_core_spkmask;
 +                for (i = 0; i < s->xxch_nbits_spk_mask; i++) {
 +                    if (mask & ~(DCA_XXCH_LFE1 | DCA_XXCH_LFE2) & (1 << i)) {
 +                        lavc = ff_dca_map_xxch_to_native[i];
 +                        posn = av_popcount(channel_layout & (lavc - 1));
 +                        s->xxch_order_tab[j++] = posn;
 +                    }
 +                }
 +
              }
 -            ff_dlog(s->avctx, "\n");
 +
 +            s->lfe_index = av_popcount(channel_layout & (AV_CH_LOW_FREQUENCY-1));
 +        } else { /* native ordering */
 +            for (i = 0; i < channels; i++)
 +                s->xxch_order_tab[i] = i;
 +
 +            s->lfe_index = channels - 1;
          }
 -    } else {
 -        av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n", s->amode);
 -        return AVERROR_INVALIDDATA;
 +
 +        s->channel_order_tab = s->xxch_order_tab;
      }
 -    avctx->channels = channels;
  
      /* get output buffer */
      frame->nb_samples = 256 * (s->sample_blocks / 8);
index deaa844fc03727a21dd97fabd947e0cee0599480,e8fb4f5f4d95a0ebb7dd0c07ee825fbffee966b0..23601c86331680ddd74ec36c88fb3dc2f86e9a89
@@@ -354,18 -343,8 +354,9 @@@ static int mlp_parse(AVCodecParserConte
          avctx->sample_rate = mh.group1_samplerate;
          s->duration = mh.access_unit_size;
  
 +        if(!avctx->channels || !avctx->channel_layout) {
          if (mh.stream_type == 0xbb) {
              /* MLP stream */
- #if FF_API_REQUEST_CHANNELS
- FF_DISABLE_DEPRECATION_WARNINGS
-             if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
-                 mh.num_substreams > 1) {
-                 avctx->channels       = 2;
-                 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
- FF_ENABLE_DEPRECATION_WARNINGS
-             } else
- #endif
              if (avctx->request_channel_layout &&
                  (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) ==
                  avctx->request_channel_layout &&
              }
          } else { /* mh.stream_type == 0xba */
              /* TrueHD stream */
- #if FF_API_REQUEST_CHANNELS
- FF_DISABLE_DEPRECATION_WARNINGS
-             if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
-                 mh.num_substreams > 1) {
-                 avctx->channels       = 2;
-                 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
-             } else if (avctx->request_channels > 0 &&
-                        avctx->request_channels <= mh.channels_thd_stream1) {
-                 avctx->channels       = mh.channels_thd_stream1;
-                 avctx->channel_layout = mh.channel_layout_thd_stream1;
- FF_ENABLE_DEPRECATION_WARNINGS
-             } else
- #endif
--                if (avctx->request_channel_layout &&
++            if (avctx->request_channel_layout &&
                      (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) ==
                      avctx->request_channel_layout &&
                      mh.num_substreams > 1) {
Simple merge
index 93d4f779a4667857be209a7a8b36153b91771ef5,9fec8e48f4b04f1da2df06ea2177d2151bf0e0cf..c18bd85b94cfcc5f0a0b891b1b4a5749c9868125
@@@ -410,10 -392,7 +410,7 @@@ static const AVOption avcodec_options[
  {"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
  {"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
  {"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
 -{"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, V|E},
 +{"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = -1 }, -1, INT64_MAX, V|E},
- #if FF_API_REQUEST_CHANNELS
- {"request_channels", "set desired number of audio channels", OFFSET(request_channels), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D},
- #endif
  {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
  {"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"},
  {"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT64_MAX, A|D, "request_channel_layout"},
index 6dbeeff083e4dec785dcafbc22c4d2507937c256,0fbb8362171d5a3f566080d3fb7e3e4d494c1327..00347c958e1b061c289354fc375ed77edf0a49a9
   * FF_API_* defines may be placed below to indicate public API that will be
   * dropped at a future version bump. The defines themselves are not part of
   * the public API and may change, break or disappear at any time.
 + *
 + * @note, when bumping the major version it is recommended to manually
 + * disable each FF_API_* in its own commit instead of disabling them all
 + * at once through the bump. This improves the git bisect-ability of the change.
   */
  
- #endif
- #ifndef FF_API_REQUEST_CHANNELS
- #define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 57)
 +#ifndef FF_API_VIMA_DECODER
 +#define FF_API_VIMA_DECODER     (LIBAVCODEC_VERSION_MAJOR < 57)
 +#endif
 +#ifndef FF_API_OLD_DECODE_AUDIO
 +#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 57)
 +#endif
 +#ifndef FF_API_OLD_ENCODE_AUDIO
 +#define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 57)
 +#endif
 +#ifndef FF_API_OLD_ENCODE_VIDEO
 +#define FF_API_OLD_ENCODE_VIDEO (LIBAVCODEC_VERSION_MAJOR < 57)
 +#endif
 +#ifndef FF_API_CODEC_ID
 +#define FF_API_CODEC_ID          (LIBAVCODEC_VERSION_MAJOR < 57)
 +#endif
 +#ifndef FF_API_AUDIO_CONVERT
 +#define FF_API_AUDIO_CONVERT     (LIBAVCODEC_VERSION_MAJOR < 57)
 +#endif
 +#ifndef FF_API_AVCODEC_RESAMPLE
 +#define FF_API_AVCODEC_RESAMPLE  FF_API_AUDIO_CONVERT
 +#endif
  #ifndef FF_API_DEINTERLACE
  #define FF_API_DEINTERLACE       (LIBAVCODEC_VERSION_MAJOR < 57)
  #endif