diff options
author | wm4 <wm4@nowhere> | 2013-11-12 22:27:44 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-12 23:39:09 +0100 |
commit | 22b3f522cacfbdba76d311c86efd6091512eb089 (patch) | |
tree | 1105af44a9403bde554cd4b6041d05ceea4fb39a /audio/reorder_ch.c | |
parent | 5388a0cd4062ba24f5382f025552422fb6430906 (diff) | |
download | mpv-22b3f522cacfbdba76d311c86efd6091512eb089.tar.bz2 mpv-22b3f522cacfbdba76d311c86efd6091512eb089.tar.xz |
audio: add support for using non-interleaved audio from decoders directly
Most libavcodec decoders output non-interleaved audio. Add direct
support for this, and remove the hack that repacked non-interleaved
audio back to packed audio.
Remove the minlen argument from the decoder callback. Instead of
forcing every decoder to have its own decode loop to fill the buffer
until minlen is reached, leave this to the caller. So if a decoder
doesn't return enough data, it's simply called again. (In future, I
even want to change it so that decoders don't read packets directly,
but instead the caller has to pass packets to the decoders. This fits
well with this change, because now the decoder callback typically
decodes at most one packet.)
ad_mpg123.c receives some heavy refactoring. The main problem is that
it wanted to handle format changes when there was no data in the decode
output buffer yet. This sounds reasonable, but actually it would write
data into a buffer prepared for old data, since the caller doesn't know
about the format change yet. (I.e. the best place for a format change
would be _after_ writing the last sample to the output buffer.) It's
possible that this code was not perfectly sane before this commit,
and perhaps lost one frame of data after a format change, but I didn't
confirm this. Trying to fix this, I ended up rewriting the decoding
and also the probing.
Diffstat (limited to 'audio/reorder_ch.c')
-rw-r--r-- | audio/reorder_ch.c | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/audio/reorder_ch.c b/audio/reorder_ch.c index 57cb664a6f..b99731e6bf 100644 --- a/audio/reorder_ch.c +++ b/audio/reorder_ch.c @@ -63,38 +63,6 @@ void reorder_to_planar(void *restrict out, const void *restrict in, reorder_to_planar_(out, in, size, nchan, nmemb); } -static inline void reorder_to_packed_(uint8_t *out, uint8_t **in, - size_t size, size_t nchan, size_t nmemb) -{ - size_t outstep = nchan * size; - - for (size_t c = 0; c < nchan; ++c) { - char *outptr = out + c * size; - char *inptr = in[c]; - for (size_t i = 0; i < nmemb; ++i, outptr += outstep, inptr += size) { - memcpy(outptr, inptr, size); - } - } -} - -// out = destination array of packed samples of given size, nmemb frames -// in[channel] = source array of samples for the given channel -void reorder_to_packed(uint8_t *out, uint8_t **in, - size_t size, size_t nchan, size_t nmemb) -{ - if (nchan == 1) - memcpy(out, in, size * nchan * nmemb); - // See reorder_to_planar() why this is done this way - else if (size == 1) - reorder_to_packed_(out, in, 1, nchan, nmemb); - else if (size == 2) - reorder_to_packed_(out, in, 2, nchan, nmemb); - else if (size == 4) - reorder_to_packed_(out, in, 4, nchan, nmemb); - else - reorder_to_packed_(out, in, size, nchan, nmemb); -} - #define MAX_SAMPLESIZE 8 static void reorder_channels_(uint8_t *restrict data, int *restrict ch_order, |