mån 2021-10-18 klockan 17:06 +0200 skrev Marc-Antoine Arnaud: > > +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 = av_malloc(sample_offset);
You could avoid this allocation using uint8_t tmp[FF_SANE_NB_CHANNELS*4]; since mxfdec only handles up to 32-bit PCM. Maybe *8 if someone down the line decides to add support for 64-bit PCM. Not that I understand why anyone would ever use that.. Don't think SMPTE defines a UL for it. > + uint8_t* data_ptr = data; you can just use 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]; > + } why not memcpy()? Should get inlined by any decent compiler I think /Tomas _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".