annotate audioconvert.h @ 10874:bcfe2acbf190 libavcodec

AAC: Compress codebook tables and optimise sign bit handling The codebooks each consist of small number of values repeated in groups of 2 or 4. Storing the codebooks as a packed list of 2- or 4-bit indexes into a table reduces their size substantially (from 7.5k to 1.5k), resulting in less cache pressure. For the band types with sign bits in the bitstream, storing the number and position of non-zero codebook values using a few bits avoids multiple get_bits() calls and floating-point comparisons which gcc handles miserably. Some float/int type punning also avoids gcc brain damage. Overall speedup 20-35% on Cortex-A8, 20% on Core i7.
author mru
date Wed, 13 Jan 2010 16:46:28 +0000
parents c2dba7ed94dc
children 7dd2a45249a9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7453
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
1 /*
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
2 * audio conversion
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
3 * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
4 * Copyright (c) 2008 Peter Ross
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
5 *
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
6 * This file is part of FFmpeg.
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
7 *
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
12 *
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
16 * Lesser General Public License for more details.
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
17 *
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
21 */
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
22
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7459
diff changeset
23 #ifndef AVCODEC_AUDIOCONVERT_H
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7459
diff changeset
24 #define AVCODEC_AUDIOCONVERT_H
7453
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
25
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
26 /**
8718
e9d9d946f213 Use full internal pathname in doxygen @file directives.
diego
parents: 8098
diff changeset
27 * @file libavcodec/audioconvert.h
7453
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
28 * Audio format conversion routines
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
29 */
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
30
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
31
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
32 #include "avcodec.h"
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
33
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
34
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
35 /**
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
36 * Generate string corresponding to the sample format with
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
37 * number sample_fmt, or a header if sample_fmt is negative.
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
38 *
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
39 * @param[in] buf the buffer where to write the string
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
40 * @param[in] buf_size the size of buf
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
41 * @param[in] sample_fmt the number of the sample format to print the corresponding info string, or
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
42 * a negative value to print the corresponding header.
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
43 * Meaningful values for obtaining a sample format info vary from 0 to SAMPLE_FMT_NB -1.
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
44 */
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
45 void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
46
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
47 /**
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
48 * @return NULL on error
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
49 */
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
50 const char *avcodec_get_sample_fmt_name(int sample_fmt);
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
51
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
52 /**
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
53 * @return SAMPLE_FMT_NONE on error
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
54 */
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
55 enum SampleFormat avcodec_get_sample_fmt(const char* name);
d1d15f2dca4c Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
diff changeset
56
8098
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
57 /**
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
58 * @return NULL on error
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
59 */
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
60 const char *avcodec_get_channel_name(int channel_id);
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
61
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
62 /**
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
63 * Return description of channel layout
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
64 */
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
65 void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
66
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
67 /**
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
68 * Guess the channel layout
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
69 * @param nb_channels
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
70 * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
71 * @param fmt_name Format name, or NULL if unknown
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
72 * @return Channel layout mask
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
73 */
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
74 int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
75
9511
c2dba7ed94dc Check that channel layout is compatible with number of channels for
jbr
parents: 8718
diff changeset
76 /**
c2dba7ed94dc Check that channel layout is compatible with number of channels for
jbr
parents: 8718
diff changeset
77 * @return the number of channels in the channel layout.
c2dba7ed94dc Check that channel layout is compatible with number of channels for
jbr
parents: 8718
diff changeset
78 */
c2dba7ed94dc Check that channel layout is compatible with number of channels for
jbr
parents: 8718
diff changeset
79 int avcodec_channel_layout_num_channels(int64_t channel_layout);
8098
c2ab7a8958ed Add audio channel layout API to libavcodec.
pross
parents: 7760
diff changeset
80
7459
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
81 struct AVAudioConvert;
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
82 typedef struct AVAudioConvert AVAudioConvert;
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
83
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
84 /**
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
85 * Create an audio sample format converter context
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
86 * @param out_fmt Output sample format
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
87 * @param out_channels Number of output channels
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
88 * @param in_fmt Input sample format
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
89 * @param in_channels Number of input channels
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
90 * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
91 * @param flags See FF_MM_xx
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
92 * @return NULL on error
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
93 */
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
94 AVAudioConvert *av_audio_convert_alloc(enum SampleFormat out_fmt, int out_channels,
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
95 enum SampleFormat in_fmt, int in_channels,
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
96 const float *matrix, int flags);
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
97
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
98 /**
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
99 * Free audio sample format converter context
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
100 */
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
101 void av_audio_convert_free(AVAudioConvert *ctx);
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
102
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
103 /**
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
104 * Convert between audio sample formats
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
105 * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
106 * @param[in] out_stride distance between consecutive input samples (measured in bytes)
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
107 * @param[in] in array of input buffers for each channel
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
108 * @param[in] in_stride distance between consecutive output samples (measured in bytes)
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
109 * @param len length of audio frame size (measured in samples)
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
110 */
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
111 int av_audio_convert(AVAudioConvert *ctx,
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
112 void * const out[6], const int out_stride[6],
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
113 const void * const in[6], const int in_stride[6], int len);
283eeda62184 Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents: 7453
diff changeset
114
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7459
diff changeset
115 #endif /* AVCODEC_AUDIOCONVERT_H */