mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Merge remote-tracking branch 'qatar/master'
* qatar/master: lavc: add a libwavpack encoder wrapper Conflicts: Changelog doc/encoders.texi libavcodec/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
73d5cf8f43
@ -65,6 +65,7 @@ version <next>:
|
|||||||
- mcdeint filter ported from libmpcodecs
|
- mcdeint filter ported from libmpcodecs
|
||||||
- sab filter ported from libmpcodecs
|
- sab filter ported from libmpcodecs
|
||||||
- ffprobe -show_chapters option
|
- ffprobe -show_chapters option
|
||||||
|
- WavPack encoding through libwavpack
|
||||||
|
|
||||||
|
|
||||||
version 1.2:
|
version 1.2:
|
||||||
|
4
configure
vendored
4
configure
vendored
@ -232,6 +232,7 @@ External library support:
|
|||||||
--enable-libvorbis enable Vorbis en/decoding via libvorbis,
|
--enable-libvorbis enable Vorbis en/decoding via libvorbis,
|
||||||
native implementation exists [no]
|
native implementation exists [no]
|
||||||
--enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]
|
--enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]
|
||||||
|
--enable-libwavpack enable wavpack encoding via libwavpack [no]
|
||||||
--enable-libx264 enable H.264 encoding via x264 [no]
|
--enable-libx264 enable H.264 encoding via x264 [no]
|
||||||
--enable-libxavs enable AVS encoding via xavs [no]
|
--enable-libxavs enable AVS encoding via xavs [no]
|
||||||
--enable-libxvid enable Xvid encoding via xvidcore,
|
--enable-libxvid enable Xvid encoding via xvidcore,
|
||||||
@ -1194,6 +1195,7 @@ EXTERNAL_LIBRARY_LIST="
|
|||||||
libvo_amrwbenc
|
libvo_amrwbenc
|
||||||
libvorbis
|
libvorbis
|
||||||
libvpx
|
libvpx
|
||||||
|
libwavpack
|
||||||
libx264
|
libx264
|
||||||
libxavs
|
libxavs
|
||||||
libxvid
|
libxvid
|
||||||
@ -2011,6 +2013,7 @@ libvpx_vp8_decoder_deps="libvpx"
|
|||||||
libvpx_vp8_encoder_deps="libvpx"
|
libvpx_vp8_encoder_deps="libvpx"
|
||||||
libvpx_vp9_decoder_deps="libvpx"
|
libvpx_vp9_decoder_deps="libvpx"
|
||||||
libvpx_vp9_encoder_deps="libvpx"
|
libvpx_vp9_encoder_deps="libvpx"
|
||||||
|
libwavpack_encoder_deps="libwavpack"
|
||||||
libx264_encoder_deps="libx264"
|
libx264_encoder_deps="libx264"
|
||||||
libx264rgb_encoder_deps="libx264"
|
libx264rgb_encoder_deps="libx264"
|
||||||
libxavs_encoder_deps="libxavs"
|
libxavs_encoder_deps="libxavs"
|
||||||
@ -4156,6 +4159,7 @@ enabled libvpx && {
|
|||||||
die "ERROR: libvpx encoder version must be >=0.9.7"; }
|
die "ERROR: libvpx encoder version must be >=0.9.7"; }
|
||||||
enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
|
enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
|
||||||
enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
|
enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
|
||||||
|
enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput -lwavpack
|
||||||
enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
|
enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
|
||||||
{ check_cpp_condition x264.h "X264_BUILD >= 118" ||
|
{ check_cpp_condition x264.h "X264_BUILD >= 118" ||
|
||||||
die "ERROR: libx264 must be installed and version must be >= 0.118."; }
|
die "ERROR: libx264 must be installed and version must be >= 0.118."; }
|
||||||
|
@ -525,6 +525,35 @@ Bitrate.
|
|||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@section libwavpack
|
||||||
|
|
||||||
|
A wrapper providing WavPack encoding through libwavpack.
|
||||||
|
|
||||||
|
Only lossless mode using 32-bit integer samples is supported currently.
|
||||||
|
The @option{compression_level} option can be used to control speed vs.
|
||||||
|
compression tradeoff, with the values mapped to libwavpack as follows:
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
|
||||||
|
@item 0
|
||||||
|
Fast mode - corresponding to the wavpack @option{-f} option.
|
||||||
|
|
||||||
|
@item 1
|
||||||
|
Normal (default) settings.
|
||||||
|
|
||||||
|
@item 2
|
||||||
|
High quality - corresponding to the wavpack @option{-h} option.
|
||||||
|
|
||||||
|
@item 3
|
||||||
|
Very high quality - corresponding to the wavpack @option{-hh} option.
|
||||||
|
|
||||||
|
@item 4-8
|
||||||
|
Same as 3, but with extra processing enabled - corresponding to the wavpack
|
||||||
|
@option{-x} option. I.e. 4 is the same as @option{-x2} and 8 is the same as
|
||||||
|
@option{-x6}.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
@c man end AUDIO ENCODERS
|
@c man end AUDIO ENCODERS
|
||||||
|
|
||||||
@chapter Video Encoders
|
@chapter Video Encoders
|
||||||
|
@ -95,6 +95,14 @@ Go to @url{http://www.webmproject.org/} and follow the instructions for
|
|||||||
installing the library. Then pass @code{--enable-libvpx} to configure to
|
installing the library. Then pass @code{--enable-libvpx} to configure to
|
||||||
enable it.
|
enable it.
|
||||||
|
|
||||||
|
@section libwavpack
|
||||||
|
|
||||||
|
Libav can make use of the libwavpack library for WavPack encoding.
|
||||||
|
|
||||||
|
Go to @url{http://www.wavpack.com/} and follow the instructions for
|
||||||
|
installing the library. Then pass @code{--enable-libwavpack} to configure to
|
||||||
|
enable it.
|
||||||
|
|
||||||
@section x264
|
@section x264
|
||||||
|
|
||||||
FFmpeg can make use of the x264 library for H.264 encoding.
|
FFmpeg can make use of the x264 library for H.264 encoding.
|
||||||
@ -909,7 +917,8 @@ following image formats are supported:
|
|||||||
@tab Used in LucasArts SMUSH animations.
|
@tab Used in LucasArts SMUSH animations.
|
||||||
@item Vorbis @tab E @tab X
|
@item Vorbis @tab E @tab X
|
||||||
@tab A native but very primitive encoder exists.
|
@tab A native but very primitive encoder exists.
|
||||||
@item WavPack @tab @tab X
|
@item WavPack @tab E @tab X
|
||||||
|
@tab supported through external library libwavpack
|
||||||
@item Westwood Audio (SND1) @tab @tab X
|
@item Westwood Audio (SND1) @tab @tab X
|
||||||
@item Windows Media Audio 1 @tab X @tab X
|
@item Windows Media Audio 1 @tab X @tab X
|
||||||
@item Windows Media Audio 2 @tab X @tab X
|
@item Windows Media Audio 2 @tab X @tab X
|
||||||
|
@ -715,6 +715,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
|
|||||||
OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
|
OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
|
||||||
OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o
|
OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o
|
||||||
OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o
|
OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o
|
||||||
|
OBJS-$(CONFIG_LIBWAVPACK_ENCODER) += libwavpackenc.o
|
||||||
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
|
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
|
||||||
OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o
|
OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o
|
||||||
OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o
|
OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o
|
||||||
|
@ -499,6 +499,7 @@ void avcodec_register_all(void)
|
|||||||
REGISTER_ENCDEC (LIBVORBIS, libvorbis);
|
REGISTER_ENCDEC (LIBVORBIS, libvorbis);
|
||||||
REGISTER_ENCDEC (LIBVPX_VP8, libvpx_vp8);
|
REGISTER_ENCDEC (LIBVPX_VP8, libvpx_vp8);
|
||||||
REGISTER_ENCDEC (LIBVPX_VP9, libvpx_vp9);
|
REGISTER_ENCDEC (LIBVPX_VP9, libvpx_vp9);
|
||||||
|
REGISTER_ENCODER(LIBWAVPACK, libwavpack);
|
||||||
REGISTER_ENCODER(LIBX264, libx264);
|
REGISTER_ENCODER(LIBX264, libx264);
|
||||||
REGISTER_ENCODER(LIBX264RGB, libx264rgb);
|
REGISTER_ENCODER(LIBX264RGB, libx264rgb);
|
||||||
REGISTER_ENCODER(LIBXAVS, libxavs);
|
REGISTER_ENCODER(LIBXAVS, libxavs);
|
||||||
|
194
libavcodec/libwavpackenc.c
Normal file
194
libavcodec/libwavpackenc.c
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of FFmpeg.
|
||||||
|
*
|
||||||
|
* FFmpeg is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* FFmpeg is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with FFmpeg; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wavpack/wavpack.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "libavutil/attributes.h"
|
||||||
|
#include "libavutil/opt.h"
|
||||||
|
#include "libavutil/samplefmt.h"
|
||||||
|
|
||||||
|
#include "audio_frame_queue.h"
|
||||||
|
#include "avcodec.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#define WV_DEFAULT_BLOCK_SIZE 32768
|
||||||
|
|
||||||
|
typedef struct LibWavpackContext {
|
||||||
|
const AVClass *class;
|
||||||
|
WavpackContext *wv;
|
||||||
|
AudioFrameQueue afq;
|
||||||
|
|
||||||
|
AVPacket *pkt;
|
||||||
|
int user_size;
|
||||||
|
|
||||||
|
int got_output;
|
||||||
|
} LibWavpackContext;
|
||||||
|
|
||||||
|
static int wavpack_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
|
const AVFrame *frame, int *got_output)
|
||||||
|
{
|
||||||
|
LibWavpackContext *s = avctx->priv_data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
s->got_output = 0;
|
||||||
|
s->pkt = pkt;
|
||||||
|
s->user_size = pkt->size;
|
||||||
|
|
||||||
|
if (frame) {
|
||||||
|
ret = ff_af_queue_add(&s->afq, frame);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = WavpackPackSamples(s->wv, (int32_t*)frame->data[0], frame->nb_samples);
|
||||||
|
if (!ret) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Error encoding a frame: %s\n",
|
||||||
|
WavpackGetErrorMessage(s->wv));
|
||||||
|
return AVERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!s->got_output &&
|
||||||
|
(!frame || frame->nb_samples < avctx->frame_size)) {
|
||||||
|
ret = WavpackFlushSamples(s->wv);
|
||||||
|
if (!ret) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Error flushing the encoder: %s\n",
|
||||||
|
WavpackGetErrorMessage(s->wv));
|
||||||
|
return AVERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s->got_output) {
|
||||||
|
ff_af_queue_remove(&s->afq, avctx->frame_size, &pkt->pts, &pkt->duration);
|
||||||
|
*got_output = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int encode_callback(void *id, void *data, int32_t count)
|
||||||
|
{
|
||||||
|
AVCodecContext *avctx = id;
|
||||||
|
LibWavpackContext *s = avctx->priv_data;
|
||||||
|
int ret, offset = s->pkt->size;
|
||||||
|
|
||||||
|
if (s->user_size) {
|
||||||
|
if (s->user_size - count < s->pkt->size) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Provided packet too small.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
s->pkt->size += count;
|
||||||
|
} else {
|
||||||
|
ret = av_grow_packet(s->pkt, count);
|
||||||
|
if (ret < 0) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Error allocating output packet.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(s->pkt->data + offset, data, count);
|
||||||
|
|
||||||
|
s->got_output = 1;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static av_cold int wavpack_encode_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
LibWavpackContext *s = avctx->priv_data;
|
||||||
|
WavpackConfig config = { 0 };
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
s->wv = WavpackOpenFileOutput(encode_callback, avctx, NULL);
|
||||||
|
if (!s->wv) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Error allocating the encoder.\n");
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!avctx->frame_size)
|
||||||
|
avctx->frame_size = WV_DEFAULT_BLOCK_SIZE;
|
||||||
|
|
||||||
|
config.bytes_per_sample = 4;
|
||||||
|
config.bits_per_sample = 32;
|
||||||
|
config.block_samples = avctx->frame_size;
|
||||||
|
config.channel_mask = avctx->channel_layout;
|
||||||
|
config.num_channels = avctx->channels;
|
||||||
|
config.sample_rate = avctx->sample_rate;
|
||||||
|
|
||||||
|
if (avctx->compression_level != FF_COMPRESSION_DEFAULT) {
|
||||||
|
if (avctx->compression_level >= 3) {
|
||||||
|
config.flags |= CONFIG_VERY_HIGH_FLAG;
|
||||||
|
|
||||||
|
if (avctx->compression_level >= 8)
|
||||||
|
config.xmode = 6;
|
||||||
|
else if (avctx->compression_level >= 7)
|
||||||
|
config.xmode = 5;
|
||||||
|
else if (avctx->compression_level >= 6)
|
||||||
|
config.xmode = 4;
|
||||||
|
else if (avctx->compression_level >= 5)
|
||||||
|
config.xmode = 3;
|
||||||
|
else if (avctx->compression_level >= 4)
|
||||||
|
config.xmode = 2;
|
||||||
|
} else if (avctx->compression_level >= 2)
|
||||||
|
config.flags |= CONFIG_HIGH_FLAG;
|
||||||
|
else if (avctx->compression_level < 1)
|
||||||
|
config.flags |= CONFIG_FAST_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = WavpackSetConfiguration(s->wv, &config, -1);
|
||||||
|
if (!ret)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
ret = WavpackPackInit(s->wv);
|
||||||
|
if (!ret)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
ff_af_queue_init(avctx, &s->afq);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Error configuring the encoder: %s.\n",
|
||||||
|
WavpackGetErrorMessage(s->wv));
|
||||||
|
WavpackCloseFile(s->wv);
|
||||||
|
return AVERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static av_cold int wavpack_encode_close(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
LibWavpackContext *s = avctx->priv_data;
|
||||||
|
|
||||||
|
WavpackCloseFile(s->wv);
|
||||||
|
|
||||||
|
ff_af_queue_close(&s->afq);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVCodec ff_libwavpack_encoder = {
|
||||||
|
.name = "libwavpack",
|
||||||
|
.type = AVMEDIA_TYPE_AUDIO,
|
||||||
|
.id = AV_CODEC_ID_WAVPACK,
|
||||||
|
.priv_data_size = sizeof(LibWavpackContext),
|
||||||
|
.init = wavpack_encode_init,
|
||||||
|
.encode2 = wavpack_encode_frame,
|
||||||
|
.close = wavpack_encode_close,
|
||||||
|
.capabilities = CODEC_CAP_DELAY | CODEC_CAP_SMALL_LAST_FRAME,
|
||||||
|
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32,
|
||||||
|
AV_SAMPLE_FMT_NONE },
|
||||||
|
};
|
@ -29,7 +29,7 @@
|
|||||||
#include "libavutil/avutil.h"
|
#include "libavutil/avutil.h"
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MAJOR 55
|
#define LIBAVCODEC_VERSION_MAJOR 55
|
||||||
#define LIBAVCODEC_VERSION_MINOR 15
|
#define LIBAVCODEC_VERSION_MINOR 16
|
||||||
#define LIBAVCODEC_VERSION_MICRO 100
|
#define LIBAVCODEC_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
|
Loading…
Reference in New Issue
Block a user