Statistics
| Branch: | Revision:

ffmpeg / libavutil / samplefmt.h @ 60c68c0a

History | View | Annotate | Download (4.03 KB)

1 262d1c5d Stefano Sabatini
/*
2
 * This file is part of FFmpeg.
3
 *
4
 * FFmpeg is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * FFmpeg is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with FFmpeg; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 */
18
19 7ffe76e5 Reinhard Tartler
#ifndef AVUTIL_SAMPLEFMT_H
20
#define AVUTIL_SAMPLEFMT_H
21 262d1c5d Stefano Sabatini
22 7ffe76e5 Reinhard Tartler
#include "avutil.h"
23 6cce172f Stefano Sabatini
24 262d1c5d Stefano Sabatini
/**
25
 * all in native-endian format
26
 */
27
enum AVSampleFormat {
28
    AV_SAMPLE_FMT_NONE = -1,
29
    AV_SAMPLE_FMT_U8,          ///< unsigned 8 bits
30
    AV_SAMPLE_FMT_S16,         ///< signed 16 bits
31
    AV_SAMPLE_FMT_S32,         ///< signed 32 bits
32
    AV_SAMPLE_FMT_FLT,         ///< float
33
    AV_SAMPLE_FMT_DBL,         ///< double
34 7ffe76e5 Reinhard Tartler
    AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically
35 262d1c5d Stefano Sabatini
};
36
37 d63e456a Stefano Sabatini
/**
38
 * Return the name of sample_fmt, or NULL if sample_fmt is not
39
 * recognized.
40
 */
41
const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
42
43
/**
44
 * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
45
 * on error.
46
 */
47
enum AVSampleFormat av_get_sample_fmt(const char *name);
48
49
/**
50
 * Generate a string corresponding to the sample format with
51
 * sample_fmt, or a header if sample_fmt is negative.
52
 *
53
 * @param buf the buffer where to write the string
54
 * @param buf_size the size of buf
55
 * @param sample_fmt the number of the sample format to print the
56
 * corresponding info string, or a negative value to print the
57
 * corresponding header.
58
 * @return the pointer to the filled buffer or NULL if sample_fmt is
59
 * unknown or in case of other errors
60
 */
61
char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
62
63 6f84cd12 Stefano Sabatini
/**
64
 * Return sample format bits per sample.
65
 *
66
 * @param sample_fmt the sample format
67
 * @return number of bits per sample or zero if unknown for the given
68
 * sample format
69
 */
70
int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
71
72 e98b8e2f Stefano Sabatini
/**
73
 * Fill channel data pointers and linesizes for samples with sample
74
 * format sample_fmt.
75
 *
76
 * The pointers array is filled with the pointers to the samples data:
77
 * data[c] points to the first sample of channel c.
78
 * data[c] + linesize[0] points to the second sample of channel c
79
 *
80
 * @param pointers array to be filled with the pointer for each plane, may be NULL
81
 * @param linesizes array to be filled with the linesize, may be NULL
82
 * @param buf the pointer to a buffer containing the samples
83
 * @param nb_samples the number of samples in a single channel
84
 * @param planar 1 if the samples layout is planar, 0 if it is packed
85
 * @param nb_channels the number of channels
86
 * @return the total size of the buffer, a negative
87
 * error code in case of failure
88
 */
89
int av_samples_fill_arrays(uint8_t *pointers[8], int linesizes[8],
90
                           uint8_t *buf, int nb_channels, int nb_samples,
91
                           enum AVSampleFormat sample_fmt, int planar, int align);
92
93
/**
94
 * Allocate a samples buffer for nb_samples samples, and
95
 * fill pointers and linesizes accordingly.
96
 * The allocated samples buffer has to be freed by using
97
 * av_freep(&pointers[0]).
98
 *
99
 * @param nb_samples number of samples per channel
100
 * @param planar 1 if the samples layout is planar, 0 if packed,
101
 * @param align the value to use for buffer size alignment
102
 * @return the size in bytes required for the samples buffer, a negative
103
 * error code in case of failure
104
 * @see av_samples_fill_arrays()
105
 */
106
int av_samples_alloc(uint8_t *pointers[8], int linesizes[8],
107
                     int nb_samples, int nb_channels,
108
                     enum AVSampleFormat sample_fmt, int planar,
109
                     int align);
110
111 262d1c5d Stefano Sabatini
#endif /* AVCORE_SAMPLEFMT_H */