1 /*
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 #include <wavpack/wavpack.h>
20 #include <string.h>
21
25
29
30 #define WV_DEFAULT_BLOCK_SIZE 32768
31
36
39
42
45 {
47 int ret;
48
52
53 if (frame) {
55 if (ret < 0)
56 return ret;
57
59 if (!ret) {
61 WavpackGetErrorMessage(s->
wv));
63 }
64 }
65
68 ret = WavpackFlushSamples(s->
wv);
69 if (!ret) {
71 WavpackGetErrorMessage(s->
wv));
73 }
74 }
75
78 *got_output = 1;
79 }
80
81 return 0;
82 }
83
85 {
89
93 return 0;
94 }
96 } else {
98 if (ret < 0) {
100 return 0;
101 }
102 }
103
104 memcpy(s->
pkt->
data + offset, data, count);
105
107
108 return 1;
109 }
110
112 {
114 WavpackConfig config = { 0 };
115 int ret;
116
121 }
122
125
126 config.bytes_per_sample = 4;
127 config.bits_per_sample = 32;
130 config.num_channels = avctx->
channels;
132
135 config.flags |= CONFIG_VERY_HIGH_FLAG;
136
138 config.xmode = 6;
140 config.xmode = 5;
142 config.xmode = 4;
144 config.xmode = 3;
146 config.xmode = 2;
148 config.flags |= CONFIG_HIGH_FLAG;
150 config.flags |= CONFIG_FAST_FLAG;
151 }
152
153 ret = WavpackSetConfiguration(s->
wv, &config, -1);
154 if (!ret)
156
157 ret = WavpackPackInit(s->
wv);
158 if (!ret)
160
162
163 return 0;
164
167 WavpackGetErrorMessage(s->
wv));
168 WavpackCloseFile(s->
wv);
170 }
171
173 {
175
176 WavpackCloseFile(s->
wv);
177
179
180 return 0;
181 }
182
184 .
name =
"libwavpack",
194 .wrapper_name = "libwavpack",
195 };
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, int64_t *duration)
Remove frame(s) from the queue.
#define FF_COMPRESSION_DEFAULT
This structure describes decoded (raw) audio or video data.
static av_cold int wavpack_encode_init(AVCodecContext *avctx)
ptrdiff_t const GLvoid * data
static av_cold int init(AVCodecContext *avctx)
Macro definitions for various function/variable attributes.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
Initialize AudioFrameQueue.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int wavpack_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_output)
static av_cold int wavpack_encode_close(AVCodecContext *avctx)
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
uint64_t channel_layout
Audio channel layout.
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
#define WV_DEFAULT_BLOCK_SIZE
int frame_size
Number of samples per channel in an audio frame.
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
main external API structure.
Describe the class of an AVClass context structure.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int encode_callback(void *id, void *data, int32_t count)
common internal api header.
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
AVCodec ff_libwavpack_encoder
int channels
number of audio channels
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
static enum AVSampleFormat sample_fmts[]
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...