summaryrefslogtreecommitdiffstats
path: root/libhb/audio_remap.h
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-07-12 20:13:23 +0000
committerRodeo <[email protected]>2012-07-12 20:13:23 +0000
commit252b183a32348050bbf9c23f3d70e9723db9271a (patch)
treec7a204fbdfd3c3413c788445cfad05c7a7344fc6 /libhb/audio_remap.h
parentf0c657025d394b1224abc6184bfea1540c9b9b16 (diff)
hb_audio_remap improvements.
This moves some logic outside of the decoders/encoders and into a single place. Encoders that do their own remapping (faac, vorbis) can still generate a remap table with hb_audio_remap_build_table(), without having to use hb_audio_remap(). git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4827 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/audio_remap.h')
-rw-r--r--libhb/audio_remap.h60
1 files changed, 46 insertions, 14 deletions
diff --git a/libhb/audio_remap.h b/libhb/audio_remap.h
index 32ee3e9cb..d74bb725c 100644
--- a/libhb/audio_remap.h
+++ b/libhb/audio_remap.h
@@ -9,45 +9,77 @@
/* This file handles the following two scenarios:
*
- * 1) remapping from liba52/libdca order to libav order
- * - this allows downmixing liba52/libdca sources with libavresample
+ * 1) remapping audio from decoder order to libav order (for downmixing)
*
- * 2) remapping from libav order to aac/vorbis order
- * - this allows encoding audio without libavcodec (faac, ca_aac, libvorbis)
+ * 2) remapping audio from libav order to encoder order (for encoding)
*
- * Thus we only need to support:
+ * We only need to support:
*
- * a) channels found in liba52/libdca layouts
+ * a) channels found in our non-libavcodec audio decoders' layouts
* b) channels found in HB_AMIXDOWN_* layouts
*
- * Notes:
+ * We consider that:
*
- * Left/Right Surround -> Side Left/Right
- * Left/Right Rear Surround -> Back Left/Right */
+ * Left/Right Surround == Side Left/Right
+ * Left/Right Rear Surround == Back Left/Right */
#ifndef AUDIO_REMAP_H
#define AUDIO_REMAP_H
#include <stdint.h>
-// we only need to support the 11 "most common" channels
+/* 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[HB_AUDIO_REMAP_MAX_CHANNELS+1];
+ int nchannels;
+ int sample_size;
+ int remap_needed;
+ int *remap_table;
+ hb_sample_t tmp[HB_AUDIO_REMAP_MAX_CHANNELS];
+} hb_audio_remap_t;
+
+typedef struct
+{
+ uint64_t channel_order_map[HB_AUDIO_REMAP_MAX_CHANNELS+1];
} hb_chan_map_t;
-// used to convert between various 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_libdca_chan_map;
extern hb_chan_map_t hb_vorbis_chan_map;
extern hb_chan_map_t hb_aac_chan_map;
-int* hb_audio_remap_build_table(uint64_t layout, hb_chan_map_t *map_in, hb_chan_map_t *map_out);
-void hb_audio_remap(int nchannels, int nsamples, hb_sample_t *samples, int *remap_table);
+/* 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).
+ */
+hb_audio_remap_t* hb_audio_remap_init(uint64_t channel_layout,
+ hb_chan_map_t *map_out,
+ hb_chan_map_t *map_in);
+
+/* 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
+ * 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,
+ int nsamples);
+
+/* Generate a table used to remap audio between 2 different channel orders.
+ *
+ * Usage: output_sample[channel_idx] = input_sample[remap_table[channel_idx]]
+ */
+int* hb_audio_remap_build_table(uint64_t channel_layout,
+ hb_chan_map_t *map_out,
+ hb_chan_map_t *map_in);
#endif /* AUDIO_REMAP_H */