summaryrefslogtreecommitdiffstats
path: root/libhb/audio_remap.h
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-10-20 23:29:33 +0000
committerRodeo <[email protected]>2012-10-20 23:29:33 +0000
commit305fc5798105e9a16f83868116d0a38a2919a638 (patch)
tree607b57a009cfa57fb6191fec6655df42167675a1 /libhb/audio_remap.h
parent4916c07f34cf97a79ca76f8163a9e7e258491bce (diff)
hb_audio_remap improvements:
- support for additional sample formats - support for variable channel layouts git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5023 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/audio_remap.h')
-rw-r--r--libhb/audio_remap.h68
1 files changed, 45 insertions, 23 deletions
diff --git a/libhb/audio_remap.h b/libhb/audio_remap.h
index ca8d916cf..a776fe57b 100644
--- a/libhb/audio_remap.h
+++ b/libhb/audio_remap.h
@@ -27,58 +27,80 @@
#define AUDIO_REMAP_H
#include <stdint.h>
+#include "libavutil/samplefmt.h"
/* we only need to support the 11 "most common" channels */
#define HB_AUDIO_REMAP_MAX_CHANNELS 11
-typedef float hb_sample_t;
+typedef struct
+{
+ uint64_t channel_order_map[HB_AUDIO_REMAP_MAX_CHANNELS + 1];
+} hb_chan_map_t;
typedef struct
{
int nchannels;
int sample_size;
int remap_needed;
- int *remap_table;
- hb_sample_t tmp[HB_AUDIO_REMAP_MAX_CHANNELS];
-} hb_audio_remap_t;
+ hb_buffer_t *buf;
+ hb_chan_map_t *channel_map_in;
+ hb_chan_map_t *channel_map_out;
+ int table[HB_AUDIO_REMAP_MAX_CHANNELS];
-typedef struct
-{
- uint64_t channel_order_map[HB_AUDIO_REMAP_MAX_CHANNELS+1];
-} hb_chan_map_t;
+ void (*remap)(uint8_t *tmp_buf, uint8_t *samples, int nsamples,
+ int nchannels, int sample_size, int *remap_table);
+} hb_audio_remap_t;
-/* Predefined channel maps for common channel orders. */
+/*
+ * Predefined channel maps for common channel orders.
+ */
extern hb_chan_map_t hb_libav_chan_map;
extern hb_chan_map_t hb_liba52_chan_map;
extern hb_chan_map_t hb_vorbis_chan_map;
extern hb_chan_map_t hb_aac_chan_map;
-/* Initialize an hb_audio_remap_t to remap audio with the specified channel
- * layout, from the input channel order (indicated by map_in) to the output
- * channel order (indicated by map_out).
+/*
+ * Initialize an hb_audio_remap_t to remap audio with the specified sample
+ * format, from the input to the output channel order (indicated by
+ * channel_map_in and channel_map_out, respectively).
*/
-hb_audio_remap_t* hb_audio_remap_init(uint64_t channel_layout,
- hb_chan_map_t *map_out,
- hb_chan_map_t *map_in);
+hb_audio_remap_t* hb_audio_remap_init(enum AVSampleFormat sample_fmt,
+ hb_chan_map_t *channel_map_out,
+ hb_chan_map_t *channel_map_in);
-/* Free an hb_audio_remap_t. */
+/*
+ * Updates an hb_audio_remap_t's number of channels and remap table to work with
+ * the specified channel layout.
+ *
+ * Must be called at least once before remapping.
+ */
+void hb_audio_remap_set_channel_layout(hb_audio_remap_t *remap,
+ uint64_t channel_layout);
+
+/*
+ * Free an hb_audio_remap_t.
+ */
void hb_audio_remap_free(hb_audio_remap_t *remap);
-/* Remap audio between 2 different channel orders, using the settings specified
+/*
+ * Remap audio between 2 different channel orders, using the settings specified
* in the remap paremeter. Remapping is only done when necessary.
*
* The remap parameter can be NULL (no remapping).
*/
-void hb_audio_remap(hb_audio_remap_t *remap,
- hb_sample_t *samples,
+void hb_audio_remap(hb_audio_remap_t *remap, uint8_t *samples,
int nsamples);
-/* Generate a table used to remap audio between 2 different channel orders.
+/*
+ * Generate a table used to remap audio between 2 different channel orders.
*
* Usage: output_sample[channel_idx] = input_sample[remap_table[channel_idx]]
+ *
+ * remap_table is allocated by the caller.
*/
-int* hb_audio_remap_build_table(uint64_t channel_layout,
- hb_chan_map_t *map_out,
- hb_chan_map_t *map_in);
+void hb_audio_remap_build_table(hb_chan_map_t *channel_map_out,
+ hb_chan_map_t *channel_map_in,
+ uint64_t channel_layout,
+ int *remap_table);
#endif /* AUDIO_REMAP_H */