[FFmpeg-devel] [PATCH 2/4] lavc/audiotoolboxenc: fix a number of config issues

Michael Niedermayer michael at niedermayer.cc
Thu Mar 24 12:25:53 CET 2016


On Thu, Mar 24, 2016 at 12:54:07AM -0500, Rodger Combs wrote:
> - size variables were used in a confusing way
> - incorrect size var use led to channel layouts not being set properly
> - channel layouts were incorrectly mapped for >2-channel AAC
> - bitrates not accepted by the encoder were discarded instead of being clamped
> - some minor style/indentation fixes
> ---
>  libavcodec/audiotoolboxenc.c | 194 ++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 172 insertions(+), 22 deletions(-)
[...]
> @@ -220,16 +321,49 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx)
>          }
>          q = 127 - q * 9;
>          AudioConverterSetProperty(at->converter, kAudioCodecPropertySoundQualityForVBR,
> -                                  size, &q);
> +                                  sizeof(q), &q);
>      } else if (avctx->bit_rate > 0) {
>          UInt32 rate = avctx->bit_rate;
> +        UInt32 size;
> +        status = AudioConverterGetPropertyInfo(at->converter,
> +                                               kAudioConverterApplicableEncodeBitRates,
> +                                               &size, NULL);

> +        if (!status && size) {
> +            UInt32 new_rate = rate;
> +            int count;
> +            int i;
> +            AudioValueRange *ranges = malloc(size);
> +            if (!ranges)
> +                return AVERROR(ENOMEM);
> +            AudioConverterGetProperty(at->converter,
> +                                      kAudioConverterApplicableEncodeBitRates,
> +                                      &size, ranges);
> +            count = size / sizeof(AudioValueRange);
> +            for (i = 0; i < count; i++) {
> +                AudioValueRange *range = &ranges[i];
> +                if (rate >= range->mMinimum && rate <= range->mMaximum) {
> +                    new_rate = rate;
> +                    break;
> +                } else if (rate > range->mMaximum) {
> +                    new_rate = range->mMaximum;
> +                } else {
> +                    new_rate = range->mMinimum;
> +                    break;
> +                }
> +            }
> +            if (new_rate != rate) {
> +                av_log(avctx, AV_LOG_WARNING,
> +                       "Bitrate %u not allowed; changing to %u\n", rate, new_rate);
> +                rate = new_rate;
> +            }
> +        }

is it intended to use malloc() instead of av_malloc() here ?
and not free it ? or maybe i miss where its freed ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160324/de23196b/attachment.sig>


More information about the ffmpeg-devel mailing list