FFmpeg
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavresample
audio_data.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
3
*
4
* This file is part of Libav.
5
*
6
* Libav is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* Libav is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with Libav; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#ifndef AVRESAMPLE_AUDIO_DATA_H
22
#define AVRESAMPLE_AUDIO_DATA_H
23
24
#include <stdint.h>
25
26
#include "
libavutil/audio_fifo.h
"
27
#include "
libavutil/log.h
"
28
#include "
libavutil/samplefmt.h
"
29
#include "
avresample.h
"
30
31
/**
32
* Audio buffer used for intermediate storage between conversion phases.
33
*/
34
typedef
struct
AudioData
{
35
const
AVClass
*
class
;
/**< AVClass for logging */
36
uint8_t
*
data
[
AVRESAMPLE_MAX_CHANNELS
];
/**< data plane pointers */
37
uint8_t
*
buffer
;
/**< data buffer */
38
unsigned
int
buffer_size
;
/**< allocated buffer size */
39
int
allocated_samples
;
/**< number of samples the buffer can hold */
40
int
nb_samples
;
/**< current number of samples */
41
enum
AVSampleFormat
sample_fmt
;
/**< sample format */
42
int
channels
;
/**< channel count */
43
int
allocated_channels
;
/**< allocated channel count */
44
int
is_planar
;
/**< sample format is planar */
45
int
planes
;
/**< number of data planes */
46
int
sample_size
;
/**< bytes per sample */
47
int
stride
;
/**< sample byte offset within a plane */
48
int
read_only
;
/**< data is read-only */
49
int
allow_realloc
;
/**< realloc is allowed */
50
int
ptr_align
;
/**< minimum data pointer alignment */
51
int
samples_align
;
/**< allocated samples alignment */
52
const
char
*
name
;
/**< name for debug logging */
53
}
AudioData
;
54
55
int
ff_audio_data_set_channels
(
AudioData
*
a
,
int
channels);
56
57
/**
58
* Initialize AudioData using a given source.
59
*
60
* This does not allocate an internal buffer. It only sets the data pointers
61
* and audio parameters.
62
*
63
* @param a AudioData struct
64
* @param src source data pointers
65
* @param plane_size plane size, in bytes.
66
* This can be 0 if unknown, but that will lead to
67
* optimized functions not being used in many cases,
68
* which could slow down some conversions.
69
* @param channels channel count
70
* @param nb_samples number of samples in the source data
71
* @param sample_fmt sample format
72
* @param read_only indicates if buffer is read only or read/write
73
* @param name name for debug logging (can be NULL)
74
* @return 0 on success, negative AVERROR value on error
75
*/
76
int
ff_audio_data_init
(
AudioData
*
a
,
uint8_t
**src,
int
plane_size,
int
channels,
77
int
nb_samples
,
enum
AVSampleFormat
sample_fmt,
78
int
read_only,
const
char
*
name
);
79
80
/**
81
* Allocate AudioData.
82
*
83
* This allocates an internal buffer and sets audio parameters.
84
*
85
* @param channels channel count
86
* @param nb_samples number of samples to allocate space for
87
* @param sample_fmt sample format
88
* @param name name for debug logging (can be NULL)
89
* @return newly allocated AudioData struct, or NULL on error
90
*/
91
AudioData
*
ff_audio_data_alloc
(
int
channels,
int
nb_samples
,
92
enum
AVSampleFormat
sample_fmt,
93
const
char
*
name
);
94
95
/**
96
* Reallocate AudioData.
97
*
98
* The AudioData must have been previously allocated with ff_audio_data_alloc().
99
*
100
* @param a AudioData struct
101
* @param nb_samples number of samples to allocate space for
102
* @return 0 on success, negative AVERROR value on error
103
*/
104
int
ff_audio_data_realloc
(
AudioData
*
a
,
int
nb_samples
);
105
106
/**
107
* Free AudioData.
108
*
109
* The AudioData must have been previously allocated with ff_audio_data_alloc().
110
*
111
* @param a AudioData struct
112
*/
113
void
ff_audio_data_free
(
AudioData
**
a
);
114
115
/**
116
* Copy data from one AudioData to another.
117
*
118
* @param out output AudioData
119
* @param in input AudioData
120
* @return 0 on success, negative AVERROR value on error
121
*/
122
int
ff_audio_data_copy
(
AudioData
*out,
AudioData
*in);
123
124
/**
125
* Append data from one AudioData to the end of another.
126
*
127
* @param dst destination AudioData
128
* @param dst_offset offset, in samples, to start writing, relative to the
129
* start of dst
130
* @param src source AudioData
131
* @param src_offset offset, in samples, to start copying, relative to the
132
* start of the src
133
* @param nb_samples number of samples to copy
134
* @return 0 on success, negative AVERROR value on error
135
*/
136
int
ff_audio_data_combine
(
AudioData
*
dst
,
int
dst_offset,
AudioData
*src,
137
int
src_offset,
int
nb_samples
);
138
139
/**
140
* Drain samples from the start of the AudioData.
141
*
142
* Remaining samples are shifted to the start of the AudioData.
143
*
144
* @param a AudioData struct
145
* @param nb_samples number of samples to drain
146
*/
147
void
ff_audio_data_drain
(
AudioData
*
a
,
int
nb_samples
);
148
149
/**
150
* Add samples in AudioData to an AVAudioFifo.
151
*
152
* @param af Audio FIFO Buffer
153
* @param a AudioData struct
154
* @param offset number of samples to skip from the start of the data
155
* @param nb_samples number of samples to add to the FIFO
156
* @return number of samples actually added to the FIFO, or
157
* negative AVERROR code on error
158
*/
159
int
ff_audio_data_add_to_fifo
(
AVAudioFifo
*af,
AudioData
*
a
,
int
offset
,
160
int
nb_samples
);
161
162
/**
163
* Read samples from an AVAudioFifo to AudioData.
164
*
165
* @param af Audio FIFO Buffer
166
* @param a AudioData struct
167
* @param nb_samples number of samples to read from the FIFO
168
* @return number of samples actually read from the FIFO, or
169
* negative AVERROR code on error
170
*/
171
int
ff_audio_data_read_from_fifo
(
AVAudioFifo
*af,
AudioData
*
a
,
int
nb_samples
);
172
173
#endif
/* AVRESAMPLE_AUDIO_DATA_H */
Generated on Sat May 25 2013 03:58:49 for FFmpeg by
1.8.2