[FFmpeg-devel] [PATCH] avformat/mxf: support MCA audio information

Tomas Härdin tjoppen at acc.umu.se
Thu Oct 28 16:57:41 EEST 2021


ons 2021-10-27 klockan 15:50 +0200 skrev Marc-Antoine Arnaud:

> +                            if(channel_ordering_ptr->service_type !=
> AV_AUDIO_SERVICE_TYPE_NB) {
> +                                ast = (enum
> AVAudioServiceType*)av_stream_new_side_data(st,
> AV_PKT_DATA_AUDIO_SERVICE_TYPE, sizeof(*ast));

This needs a check for ast == NULL

> +static int mxf_audio_remapping(int* channel_ordering, uint8_t* data,
> int size, int sample_size, int channels)
> +{
> +    int sample_offset = channels * sample_size;
> +    int number_of_samples = size / sample_offset;
> +    uint8_t tmp[FF_SANE_NB_CHANNELS * 4];
> +    uint8_t* data_ptr = data;
> +
> +    if (!tmp)
> +        return AVERROR(ENOMEM);
> +
> +    for (int sample = 0; sample < number_of_samples; ++sample) {
> +        memcpy(tmp, data_ptr, sample_offset);
> +
> +        for (int channel = 0; channel < channels; ++channel) {
> +            for (int sample_index = 0; sample_index < sample_size;
> ++sample_index) {
> +                data_ptr[sample_size * channel_ordering[channel] +
> sample_index] = tmp[sample_size * channel + sample_index];
> +            }

What I meant with my previous comment on this is that the innermost
loop can be replaced with memcpy(), making the code simpler.

/Tomas



More information about the ffmpeg-devel mailing list