Merge remote-tracking branch 'qatar/master'

* qatar/master:
  libx264: only use ABR mode when the user explicitly set bitrate.
  libx264: use medium preset by default.
  mp2 encoder: make 128k the default bitrate.
  movenc: use libx264 by default when possible for mov, mp4 and psp
  avienc: saner default audio codec.
  matroskaenc: saner default codecs.
  avplay: add examples of how to specify size/pixel format through private options
  lavc: add A|E|D flags to "ac" and "ar" options

Conflicts:
	doc/ffplay.texi
	libavcodec/libx264.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/2/head
Michael Niedermayer 13 years ago
commit 124deea1a0
  1. 19
      libavcodec/libx264.c
  2. 7
      libavcodec/mpegaudioenc.c
  3. 4
      libavcodec/options.c
  4. 6
      libavformat/avienc.c
  5. 16
      libavformat/matroskaenc.c
  6. 12
      libavformat/movenc.c
  7. 16
      tests/lavf-regression.sh

@ -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,
};

@ -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,
};

@ -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},

@ -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,

@ -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,

@ -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,

@ -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

Loading…
Cancel
Save