summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/libx264.c19
-rw-r--r--libavcodec/mpegaudioenc.c7
-rw-r--r--libavcodec/options.c4
-rw-r--r--libavformat/avienc.c6
-rw-r--r--libavformat/matroskaenc.c16
-rw-r--r--libavformat/movenc.c12
-rwxr-xr-xtests/lavf-regression.sh16
7 files changed, 60 insertions, 20 deletions
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 2804598464..33372f3c26 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -21,6 +21,7 @@
#include "libavutil/opt.h"
#include "avcodec.h"
+#include "internal.h"
#include <x264.h>
#include <math.h>
#include <stdio.h>
@@ -318,7 +319,10 @@ static av_cold int X264_init(AVCodecContext *avctx)
OPT_STR("weightp", x4->weightp);
x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH;
- x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
+ if (avctx->bit_rate) {
+ x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
+ x4->params.rc.i_rc_method = X264_RC_ABR;
+ }
x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
@@ -337,11 +341,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
OPT_STR("stats", x4->stats);
- // if neither crf nor cqp modes are selected we have to enable the RC
- // we do it this way because we cannot check if the bitrate has been set
- if (!(avctx->crf || (avctx->cqp > -1)))
- x4->params.rc.i_rc_method = X264_RC_ABR;
-
if (avctx->rc_buffer_size && avctx->rc_initial_buffer_occupancy &&
(avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
x4->params.rc.f_vbv_buffer_init =
@@ -428,7 +427,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
+ { "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), FF_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE},
{ "tune", "Tune the encoding params (cf. x264 --fullhelp)", OFFSET(tune), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
{ "profile", "Set profile restrictions (cf. x264 --fullhelp) ", OFFSET(profile), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
{ "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, { 1 }, 0, 1, VE},
@@ -446,6 +445,11 @@ static const AVClass class = {
.version = LIBAVUTIL_VERSION_INT,
};
+static const AVCodecDefault x264_defaults[] = {
+ { "b", "0" },
+ { NULL },
+};
+
AVCodec ff_libx264_encoder = {
.name = "libx264",
.type = AVMEDIA_TYPE_VIDEO,
@@ -458,4 +462,5 @@ AVCodec ff_libx264_encoder = {
.pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, PIX_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
.priv_class = &class,
+ .defaults = x264_defaults,
};
diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c
index 0ca99bac15..cc4dee9636 100644
--- a/libavcodec/mpegaudioenc.c
+++ b/libavcodec/mpegaudioenc.c
@@ -25,6 +25,7 @@
*/
#include "avcodec.h"
+#include "internal.h"
#include "put_bits.h"
#define FRAC_BITS 15 /* fractional bits for sb_samples and dct */
@@ -763,6 +764,11 @@ static av_cold int MPA_encode_close(AVCodecContext *avctx)
return 0;
}
+static const AVCodecDefault mp2_defaults[] = {
+ { "b", "128k" },
+ { NULL },
+};
+
AVCodec ff_mp2_encoder = {
.name = "mp2",
.type = AVMEDIA_TYPE_AUDIO,
@@ -774,4 +780,5 @@ AVCodec ff_mp2_encoder = {
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.supported_samplerates= (const int[]){44100, 48000, 32000, 22050, 24000, 16000, 0},
.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
+ .defaults = mp2_defaults,
};
diff --git a/libavcodec/options.c b/libavcodec/options.c
index cb2cd7decb..99deac2f41 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -126,8 +126,8 @@ static const AVOption options[]={
{"extradata_size", NULL, OFFSET(extradata_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
{"time_base", NULL, OFFSET(time_base), FF_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX},
{"g", "set the group of picture size", OFFSET(gop_size), FF_OPT_TYPE_INT, {.dbl = 12 }, INT_MIN, INT_MAX, V|E},
-{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
-{"ac", "set number of audio channels", OFFSET(channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
+{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|D|E},
+{"ac", "set number of audio channels", OFFSET(channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|D|E},
{"cutoff", "set cutoff bandwidth", OFFSET(cutoff), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|E},
{"frame_size", NULL, OFFSET(frame_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|E},
{"frame_number", NULL, OFFSET(frame_number), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 20bbfc0375..19cabe2aef 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -644,7 +644,11 @@ AVOutputFormat ff_avi_muxer = {
.mime_type = "video/x-msvideo",
.extensions = "avi",
.priv_data_size = sizeof(AVIContext),
- .audio_codec = CODEC_ID_MP2,
+#if CONFIG_LIBMP3LAME_ENCODER
+ .audio_codec = CODEC_ID_MP3,
+#else
+ .audio_codec = CODEC_ID_AC3,
+#endif
.video_codec = CODEC_ID_MPEG4,
.write_header = avi_write_header,
.write_packet = avi_write_packet,
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 8cf781ddcd..0910da529e 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1221,8 +1221,16 @@ AVOutputFormat ff_matroska_muxer = {
.mime_type = "video/x-matroska",
.extensions = "mkv",
.priv_data_size = sizeof(MatroskaMuxContext),
- .audio_codec = CODEC_ID_MP2,
+#if CONFIG_LIBVORBIS_ENCODER
+ .audio_codec = CODEC_ID_VORBIS,
+#else
+ .audio_codec = CODEC_ID_AC3,
+#endif
+#if CONFIG_LIBX264_ENCODER
+ .video_codec = CODEC_ID_H264,
+#else
.video_codec = CODEC_ID_MPEG4,
+#endif
.write_header = mkv_write_header,
.write_packet = mkv_write_packet,
.write_trailer = mkv_write_trailer,
@@ -1256,7 +1264,11 @@ AVOutputFormat ff_matroska_audio_muxer = {
.mime_type = "audio/x-matroska",
.extensions = "mka",
.priv_data_size = sizeof(MatroskaMuxContext),
- .audio_codec = CODEC_ID_MP2,
+#if CONFIG_LIBVORBIS_ENCODER
+ .audio_codec = CODEC_ID_VORBIS,
+#else
+ .audio_codec = CODEC_ID_AC3,
+#endif
.video_codec = CODEC_ID_NONE,
.write_header = mkv_write_header,
.write_packet = mkv_write_packet,
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5d676f7741..c044b070ab 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2356,7 +2356,11 @@ AVOutputFormat ff_mov_muxer = {
.extensions = "mov",
.priv_data_size = sizeof(MOVMuxContext),
.audio_codec = CODEC_ID_AAC,
+#if CONFIG_LIBX264_ENCODER
+ .video_codec = CODEC_ID_H264,
+#else
.video_codec = CODEC_ID_MPEG4,
+#endif
.write_header = mov_write_header,
.write_packet = ff_mov_write_packet,
.write_trailer = mov_write_trailer,
@@ -2389,7 +2393,11 @@ AVOutputFormat ff_mp4_muxer = {
.extensions = "mp4",
.priv_data_size = sizeof(MOVMuxContext),
.audio_codec = CODEC_ID_AAC,
+#if CONFIG_LIBX264_ENCODER
+ .video_codec = CODEC_ID_H264,
+#else
.video_codec = CODEC_ID_MPEG4,
+#endif
.write_header = mov_write_header,
.write_packet = ff_mov_write_packet,
.write_trailer = mov_write_trailer,
@@ -2405,7 +2413,11 @@ AVOutputFormat ff_psp_muxer = {
.extensions = "mp4,psp",
.priv_data_size = sizeof(MOVMuxContext),
.audio_codec = CODEC_ID_AAC,
+#if CONFIG_LIBX264_ENCODER
+ .video_codec = CODEC_ID_H264,
+#else
.video_codec = CODEC_ID_MPEG4,
+#endif
.write_header = mov_write_header,
.write_packet = ff_mov_write_packet,
.write_trailer = mov_write_trailer,
diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
index f1175ef4b5..67dfb4e328 100755
--- a/tests/lavf-regression.sh
+++ b/tests/lavf-regression.sh
@@ -44,11 +44,11 @@ do_audio_only()
}
if [ -n "$do_avi" ] ; then
-do_lavf avi
+do_lavf avi "-acodec mp2 -ab 64k"
fi
if [ -n "$do_asf" ] ; then
-do_lavf asf "-acodec mp2" "-r 25"
+do_lavf asf "-acodec mp2 -ab 64k" "-r 25"
fi
if [ -n "$do_rm" ] ; then
@@ -59,7 +59,7 @@ do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 441
fi
if [ -n "$do_mpg" ] ; then
-do_lavf mpg
+do_lavf mpg "-ab 64k"
fi
if [ -n "$do_mxf" ] ; then
@@ -71,7 +71,7 @@ do_lavf mxf_d10 "-ar 48000 -ac 2 -r 25 -s 720x576 -vf pad=720:608:0:32 -vcodec m
fi
if [ -n "$do_ts" ] ; then
-do_lavf ts
+do_lavf ts "-ab 64k"
fi
if [ -n "$do_swf" ] ; then
@@ -79,7 +79,7 @@ do_lavf swf -an
fi
if [ -n "$do_ffm" ] ; then
-do_lavf ffm
+do_lavf ffm "-ab 64k"
fi
if [ -n "$do_flv_fmt" ] ; then
@@ -87,7 +87,7 @@ do_lavf flv -an
fi
if [ -n "$do_mov" ] ; then
-do_lavf mov "-acodec pcm_alaw"
+do_lavf mov "-acodec pcm_alaw -vcodec mpeg4"
fi
if [ -n "$do_dv_fmt" ] ; then
@@ -99,11 +99,11 @@ do_lavf gxf "-ar 48000 -r 25 -s pal -ac 1"
fi
if [ -n "$do_nut" ] ; then
-do_lavf nut "-acodec mp2"
+do_lavf nut "-acodec mp2 -ab 64k"
fi
if [ -n "$do_mkv" ] ; then
-do_lavf mkv
+do_lavf mkv "-acodec mp2 -ab 64k -vcodec mpeg4"
fi