History

Add intra refresh and crf-max support to the libavcodec libx264 wrapper. Minor version bump.

Originally committed as revision 23038 to svn://svn.ffmpeg.org/ffmpeg/trunk

Jason Garrett-Glaser committed 16 years ago

Commit e8c7fca1 parent 46174074 files · +17 −3Browse files

Unified · Split

4 files
  1. configure +2 −2
  2. libavcodec/avcodec.h +11 −1
  3. libavcodec/libx264.c +2 −0
  4. libavcodec/options.c +2 −0
configure+2−2
@@ -2618,8 +2618,8 @@ enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex · 2617 unmodified lines
2618enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg2618enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
2619enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg2619enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2620enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&2620enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
2621 { check_cpp_condition x264.h "X264_BUILD >= 83" ||2621 { check_cpp_condition x264.h "X264_BUILD >= 90" ||
2622 die "ERROR: libx264 version must be >= 0.83."; }2622 die "ERROR: libx264 version must be >= 0.90."; }
2623enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore2623enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
2624enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib2624enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2625 2625
libavcodec/avcodec.h+11−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
30#include "libavutil/avutil.h"30#include "libavutil/avutil.h"
31 31
32#define LIBAVCODEC_VERSION_MAJOR 5232#define LIBAVCODEC_VERSION_MAJOR 52
33#define LIBAVCODEC_VERSION_MINOR 6633#define LIBAVCODEC_VERSION_MINOR 67
34#define LIBAVCODEC_VERSION_MICRO 034#define LIBAVCODEC_VERSION_MICRO 0
35 35
36#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \36#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -597,6 +597,7 @@ typedef struct RcOverride{ · 560 unmodified lines
597#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)597#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
598#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations.598#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations.
599#define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.599#define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.
600#define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes.
600 601
601/* Unsupported options :602/* Unsupported options :
602 * Syntax Arithmetic coding (SAC)603 * Syntax Arithmetic coding (SAC)
@@ -2646,6 +2647,15 @@ typedef struct AVCodecContext { · 2043 unmodified lines
2646 * - decoding: unused2647 * - decoding: unused
2647 */2648 */
2648 int rc_lookahead;2649 int rc_lookahead;
2650
2651 /**
2652 * Constant rate factor maximum
2653 * With CRF encoding mode and VBV restrictions enabled, prevents quality from being worse
2654 * than crf_max, even if doing so would violate VBV restrictions.
2655 * - encoding: Set by user.
2656 * - decoding: unused
2657 */
2658 float crf_max;
2649} AVCodecContext;2659} AVCodecContext;
2650 2660
2651/**2661/**
libavcodec/libx264.c+2−0
@@ -156,6 +156,7 @@ static av_cold int X264_init(AVCodecContext *avctx) · 155 unmodified lines
156 x4->params.p_log_private = avctx;156 x4->params.p_log_private = avctx;
157 157
158 x4->params.i_keyint_max = avctx->gop_size;158 x4->params.i_keyint_max = avctx->gop_size;
159 x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH;
159 x4->params.rc.i_bitrate = avctx->bit_rate / 1000;160 x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
160 x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;161 x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
161 x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;162 x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
@@ -166,6 +167,7 @@ static av_cold int X264_init(AVCodecContext *avctx) · 4 unmodified lines
166 if (avctx->crf) {167 if (avctx->crf) {
167 x4->params.rc.i_rc_method = X264_RC_CRF;168 x4->params.rc.i_rc_method = X264_RC_CRF;
168 x4->params.rc.f_rf_constant = avctx->crf;169 x4->params.rc.f_rf_constant = avctx->crf;
170 x4->params.rc.f_rf_constant_max = avctx->crf_max;
169 } else if (avctx->cqp > -1) {171 } else if (avctx->cqp > -1) {
170 x4->params.rc.i_rc_method = X264_RC_CQP;172 x4->params.rc.i_rc_method = X264_RC_CQP;
171 x4->params.rc.i_qp_constant = avctx->cqp;173 x4->params.rc.i_qp_constant = avctx->cqp;
libavcodec/options.c+2−0
@@ -411,6 +411,8 @@ static const AVOption options[]={ · 410 unmodified lines
411{"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, 1.0, 0, FLT_MAX, V|E},411{"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, 1.0, 0, FLT_MAX, V|E},
412{"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, 40, 0, INT_MAX, V|E},412{"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, 40, 0, INT_MAX, V|E},
413{"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_SSIM, INT_MIN, INT_MAX, V|E, "flags2"},413{"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_SSIM, INT_MIN, INT_MAX, V|E, "flags2"},
414{"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_REFRESH, INT_MIN, INT_MAX, V|E, "flags2"},
415{"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 51, V|E},
414{NULL},416{NULL},
415};417};
416 418

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t