[FFmpeg-devel] support for audio with sample resolution better than 16bit
Lars Täuber
lars.taeuber
Sun Apr 20 10:44:16 CEST 2008
Hallo!
Recently I added a wish (#425) to the ffmpeg roundup system.
I'd like ffmpeg to be capable to transcode 24bit pcm into 24bit flac.
Therefore the audio handling has to be enhanced. Now I want to make some suggestions how I think this could be done.
At first the decoding needs to be able to handle other resolutions than 16bit.
I'd suggest to add the following function:
int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx,
int16_t *samples,
int *frame_size_ptr,
void *low_samples,
int *low_frame_size_ptr,
uint8_t *sample_res,
const uint8_t *buf, int buf_size)
When there is audio decoded in 24 bit depth the caller can tell that he only wants to receive 16bit depth with setting *sample_res=16.
Then low_frame_size_ptr and low_samples can be uninitialized.
when 16 < *sample_res <=24 low_samples is of type (unint8_t *) and the memory has to be allocated
when 24 < *sample_res <=32 low_samples is of type (uint16_t *) and the memory has to be allocated
when 32 < *sample_res return error
audio samples are always put into the high bits:
26 bit sample:
int32_t real_sample[0] = samples[0]<<16 | ((uint16_t *) low_samples[0] & 0xfffc)
after decoding *sample_res is set to the actual sample resolution
e.g. the caller tells he wants 24bit maximum but the stream only had 20bit resolution then *sample_res is set to 20
When the caller sets *sample_res == 0 he accepts all depth up to 32bit.
Optionaly the samples pointer could also be of type (void *) and then *samples_res could distinguish 16bit samples from 8bit samples.
What do you think?
Lars
More information about the ffmpeg-devel
mailing list