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

Showing the changes to libavcodec (3 of 4 files). Show all

Unified · Split

3 files
  1. libavcodec/avcodec.h +11 −1
  2. libavcodec/libx264.c +2 −0
  3. libavcodec/options.c +2 −0
libavcodec/avcodec.h+11−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/avutil.h"
3131
3232 #define LIBAVCODEC_VERSION_MAJOR 52
33−#define LIBAVCODEC_VERSION_MINOR 66
33+#define LIBAVCODEC_VERSION_MINOR 67
3434 #define LIBAVCODEC_VERSION_MICRO 0
3535
3636 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -597,6 +597,7 @@ typedef struct RcOverride{ · 560 unmodified lines
597597 #define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
598598 #define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations.
599599 #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.
600601
601602 /* Unsupported options :
602603 * Syntax Arithmetic coding (SAC)
@@ -2646,6 +2647,15 @@ typedef struct AVCodecContext { · 2043 unmodified lines
26462647 * - decoding: unused
26472648 */
26482649 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;
26492659 } AVCodecContext;
26502660
26512661 /**
libavcodec/libx264.c+2−0
@@ -156,6 +156,7 @@ static av_cold int X264_init(AVCodecContext *avctx) · 155 unmodified lines
156156 x4->params.p_log_private = avctx;
157157
158158 x4->params.i_keyint_max = avctx->gop_size;
159+ x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH;
159160 x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
160161 x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
161162 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
166167 if (avctx->crf) {
167168 x4->params.rc.i_rc_method = X264_RC_CRF;
168169 x4->params.rc.f_rf_constant = avctx->crf;
170+ x4->params.rc.f_rf_constant_max = avctx->crf_max;
169171 } else if (avctx->cqp > -1) {
170172 x4->params.rc.i_rc_method = X264_RC_CQP;
171173 x4->params.rc.i_qp_constant = avctx->cqp;
libavcodec/options.c+2−0
@@ -411,6 +411,8 @@ static const AVOption options[]={ · 410 unmodified lines
411411 {"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, 1.0, 0, FLT_MAX, V|E},
412412 {"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, 40, 0, INT_MAX, V|E},
413413 {"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},
414416 {NULL},
415417 };
416418

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