WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / libhb / audio_remap.h
blobb778f1f06fab56adcb466d9e3f49fde56db2629c
1 /* audio_remap.h
3 * Copyright (c) 2003-2015 HandBrake Team
4 * This file is part of the HandBrake source code
5 * Homepage: <http://handbrake.fr/>
6 * It may be used under the terms of the GNU General Public License v2.
7 * For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
8 */
10 /* This file handles the following two scenarios:
12 * 1) remapping audio from decoder order to libav order (for downmixing)
14 * 2) remapping audio from libav order to encoder order (for encoding)
16 * We only need to support:
18 * a) channels found in our non-libavcodec audio decoders' layouts
19 * b) channels found in HB_AMIXDOWN_* layouts
21 * We consider that:
23 * Left/Right Surround == Side Left/Right
24 * Left/Right Rear Surround == Back Left/Right */
26 #ifndef AUDIO_REMAP_H
27 #define AUDIO_REMAP_H
29 #include <stdint.h>
30 #include "libavutil/samplefmt.h"
32 /* we only need to support the 11 "most common" channels */
33 #define HB_AUDIO_REMAP_MAX_CHANNELS 11
35 typedef struct
37 uint64_t channel_order_map[HB_AUDIO_REMAP_MAX_CHANNELS + 1];
38 } hb_chan_map_t;
40 typedef struct
42 int nchannels;
43 int remap_needed;
44 hb_chan_map_t *channel_map_in;
45 hb_chan_map_t *channel_map_out;
46 int table[HB_AUDIO_REMAP_MAX_CHANNELS];
48 void (*remap)(uint8_t **samples, int nsamples,
49 int nchannels, int *remap_table);
50 } hb_audio_remap_t;
53 * Predefined channel maps for common channel orders.
55 extern hb_chan_map_t hb_libav_chan_map;
56 extern hb_chan_map_t hb_liba52_chan_map;
57 extern hb_chan_map_t hb_vorbis_chan_map;
58 extern hb_chan_map_t hb_aac_chan_map;
61 * Initialize an hb_audio_remap_t to remap audio with the specified sample
62 * format, from the input to the output channel order (indicated by
63 * channel_map_in and channel_map_out, respectively).
65 hb_audio_remap_t* hb_audio_remap_init(enum AVSampleFormat sample_fmt,
66 hb_chan_map_t *channel_map_out,
67 hb_chan_map_t *channel_map_in);
70 * Updates an hb_audio_remap_t's number of channels and remap table to work with
71 * the specified channel layout.
73 * Must be called at least once before remapping.
75 void hb_audio_remap_set_channel_layout(hb_audio_remap_t *remap,
76 uint64_t channel_layout);
79 * Free an hb_audio_remap_t.
81 void hb_audio_remap_free(hb_audio_remap_t *remap);
84 * Remap audio between 2 different channel orders, using the settings specified
85 * in the remap paremeter. Remapping is only done when necessary.
87 * The remap parameter can be NULL (no remapping).
89 void hb_audio_remap(hb_audio_remap_t *remap, uint8_t **samples,
90 int nsamples);
93 * Generate a table used to remap audio between 2 different channel orders.
95 * Usage: output_sample[channel_idx] = input_sample[remap_table[channel_idx]]
97 * remap_table is allocated by the caller.
99 void hb_audio_remap_build_table(hb_chan_map_t *channel_map_out,
100 hb_chan_map_t *channel_map_in,
101 uint64_t channel_layout,
102 int *remap_table);
104 #endif /* AUDIO_REMAP_H */