backport libx264.c from trunk
now compiles with x264 API versions 65 up to 85 patch prepared by darkshikari Originally committed as revision 22042 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5
This commit is contained in:
parent
a0244ae347
commit
53b90bb25e
2
configure
vendored
2
configure
vendored
@ -2017,7 +2017,7 @@ enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
|
|||||||
enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
|
enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
|
||||||
enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
|
enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
|
||||||
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
|
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
|
||||||
enabled libx264 && require libx264 x264.h x264_encoder_open -lx264 -lm &&
|
enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
|
||||||
{ check_cpp_condition x264.h "X264_BUILD >= 65" ||
|
{ check_cpp_condition x264.h "X264_BUILD >= 65" ||
|
||||||
die "ERROR: libx264 version must be >= 0.65."; }
|
die "ERROR: libx264 version must be >= 0.65."; }
|
||||||
enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
|
enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
coder=0
|
coder=0
|
||||||
bf=0
|
bf=0
|
||||||
flags2=-wpred-dct8x8
|
flags2=-wpred-dct8x8+mbtree
|
||||||
|
wpredp=0
|
||||||
|
@ -3,7 +3,7 @@ flags=+loop
|
|||||||
cmp=+chroma
|
cmp=+chroma
|
||||||
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
|
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
|
||||||
me_method=hex
|
me_method=hex
|
||||||
subq=6
|
subq=7
|
||||||
me_range=16
|
me_range=16
|
||||||
g=250
|
g=250
|
||||||
keyint_min=25
|
keyint_min=25
|
||||||
@ -14,5 +14,9 @@ qcomp=0.6
|
|||||||
qmin=10
|
qmin=10
|
||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
|
bf=3
|
||||||
|
refs=3
|
||||||
directpred=1
|
directpred=1
|
||||||
flags2=+fastpskip
|
trellis=1
|
||||||
|
flags2=+mixed_refs+wpred+dct8x8+fastpskip+mbtree
|
||||||
|
wpredp=2
|
||||||
|
@ -3,7 +3,7 @@ flags=+loop
|
|||||||
cmp=+chroma
|
cmp=+chroma
|
||||||
partitions=-parti8x8-parti4x4-partp8x8-partp4x4-partb8x8
|
partitions=-parti8x8-parti4x4-partp8x8-partp4x4-partb8x8
|
||||||
me_method=dia
|
me_method=dia
|
||||||
subq=1
|
subq=2
|
||||||
me_range=16
|
me_range=16
|
||||||
g=250
|
g=250
|
||||||
keyint_min=25
|
keyint_min=25
|
||||||
@ -14,8 +14,9 @@ qcomp=0.6
|
|||||||
qmin=10
|
qmin=10
|
||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
bf=4
|
bf=3
|
||||||
refs=1
|
refs=1
|
||||||
directpred=3
|
directpred=3
|
||||||
trellis=0
|
trellis=0
|
||||||
flags2=-bpyramid-wpred-mixed_refs-dct8x8+fastpskip
|
flags2=-bpyramid-wpred-mixed_refs-dct8x8+fastpskip+mbtree
|
||||||
|
wpredp=2
|
||||||
|
@ -14,8 +14,9 @@ qcomp=0.6
|
|||||||
qmin=10
|
qmin=10
|
||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
bf=4
|
bf=3
|
||||||
refs=4
|
refs=4
|
||||||
directpred=3
|
directpred=3
|
||||||
trellis=1
|
trellis=1
|
||||||
flags2=+bpyramid+wpred+mixed_refs+dct8x8+fastpskip
|
flags2=+wpred+mixed_refs+dct8x8+fastpskip+mbtree
|
||||||
|
wpredp=2
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
coder=0
|
coder=0
|
||||||
bf=0
|
bf=0
|
||||||
flags2=-wpred-dct8x8
|
flags2=-wpred-dct8x8+mbtree
|
||||||
level=13
|
level=13
|
||||||
maxrate=768000
|
maxrate=768000
|
||||||
bufsize=3000000
|
bufsize=3000000
|
||||||
|
wpredp=0
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
coder=0
|
coder=0
|
||||||
bf=0
|
bf=0
|
||||||
refs=1
|
refs=1
|
||||||
flags2=-wpred-dct8x8
|
flags2=-wpred-dct8x8+mbtree
|
||||||
level=30
|
level=30
|
||||||
maxrate=10000000
|
maxrate=10000000
|
||||||
bufsize=10000000
|
bufsize=10000000
|
||||||
|
wpredp=0
|
||||||
|
@ -15,5 +15,6 @@ qmin=10
|
|||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
directpred=1
|
directpred=1
|
||||||
flags2=+fastpskip
|
flags2=+fastpskip+mbtree
|
||||||
cqp=0
|
cqp=0
|
||||||
|
wpredp=0
|
||||||
|
@ -16,5 +16,6 @@ qmax=51
|
|||||||
qdiff=4
|
qdiff=4
|
||||||
refs=16
|
refs=16
|
||||||
directpred=1
|
directpred=1
|
||||||
flags2=+mixed_refs+dct8x8+fastpskip
|
flags2=+mixed_refs+dct8x8+fastpskip+mbtree
|
||||||
cqp=0
|
cqp=0
|
||||||
|
wpredp=2
|
||||||
|
@ -15,5 +15,6 @@ qmin=10
|
|||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
directpred=1
|
directpred=1
|
||||||
flags2=+fastpskip
|
flags2=+fastpskip+mbtree
|
||||||
cqp=0
|
cqp=0
|
||||||
|
wpredp=2
|
||||||
|
@ -16,5 +16,6 @@ qmax=51
|
|||||||
qdiff=4
|
qdiff=4
|
||||||
refs=2
|
refs=2
|
||||||
directpred=1
|
directpred=1
|
||||||
flags2=+dct8x8+fastpskip
|
flags2=+dct8x8+fastpskip+mbtree
|
||||||
cqp=0
|
cqp=0
|
||||||
|
wpredp=2
|
||||||
|
@ -16,5 +16,6 @@ qmax=51
|
|||||||
qdiff=4
|
qdiff=4
|
||||||
refs=4
|
refs=4
|
||||||
directpred=1
|
directpred=1
|
||||||
flags2=+mixed_refs+dct8x8+fastpskip
|
flags2=+mixed_refs+dct8x8+fastpskip+mbtree
|
||||||
cqp=0
|
cqp=0
|
||||||
|
wpredp=2
|
||||||
|
@ -15,5 +15,5 @@ qmin=10
|
|||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
directpred=1
|
directpred=1
|
||||||
flags2=+fastpskip
|
flags2=+fastpskip+mbtree
|
||||||
cqp=0
|
cqp=0
|
||||||
|
@ -1 +1 @@
|
|||||||
flags2=-dct8x8
|
flags2=-dct8x8+mbtree
|
||||||
|
@ -3,8 +3,8 @@ flags=+loop
|
|||||||
cmp=+chroma
|
cmp=+chroma
|
||||||
partitions=+parti8x8+parti4x4+partp8x8+partp4x4+partb8x8
|
partitions=+parti8x8+parti4x4+partp8x8+partp4x4+partb8x8
|
||||||
me_method=tesa
|
me_method=tesa
|
||||||
subq=9
|
subq=10
|
||||||
me_range=32
|
me_range=24
|
||||||
g=250
|
g=250
|
||||||
keyint_min=25
|
keyint_min=25
|
||||||
sc_threshold=40
|
sc_threshold=40
|
||||||
@ -14,8 +14,9 @@ qcomp=0.6
|
|||||||
qmin=10
|
qmin=10
|
||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
bf=4
|
bf=3
|
||||||
refs=16
|
refs=16
|
||||||
directpred=3
|
directpred=3
|
||||||
trellis=2
|
trellis=2
|
||||||
flags2=+bpyramid+wpred+mixed_refs+dct8x8-fastpskip
|
flags2=+wpred+mixed_refs+dct8x8-fastpskip+mbtree
|
||||||
|
wpredp=2
|
||||||
|
@ -14,8 +14,9 @@ qcomp=0.6
|
|||||||
qmin=10
|
qmin=10
|
||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
bf=4
|
bf=3
|
||||||
refs=2
|
refs=2
|
||||||
directpred=3
|
directpred=3
|
||||||
trellis=0
|
trellis=0
|
||||||
flags2=+bpyramid+wpred+dct8x8+fastpskip
|
flags2=+wpred+dct8x8+fastpskip+mbtree
|
||||||
|
wpredp=2
|
||||||
|
@ -14,8 +14,9 @@ qcomp=0.6
|
|||||||
qmin=10
|
qmin=10
|
||||||
qmax=51
|
qmax=51
|
||||||
qdiff=4
|
qdiff=4
|
||||||
bf=4
|
bf=3
|
||||||
refs=1
|
refs=1
|
||||||
directpred=3
|
directpred=3
|
||||||
trellis=0
|
trellis=0
|
||||||
flags2=+bpyramid+wpred+dct8x8+fastpskip
|
flags2=+wpred+dct8x8+fastpskip+mbtree
|
||||||
|
wpredp=2
|
||||||
|
@ -501,6 +501,7 @@ typedef struct RcOverride{
|
|||||||
#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
|
#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
|
||||||
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
|
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
|
||||||
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
|
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
|
||||||
|
#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
|
||||||
|
|
||||||
/* Unsupported options :
|
/* Unsupported options :
|
||||||
* Syntax Arithmetic coding (SAC)
|
* Syntax Arithmetic coding (SAC)
|
||||||
@ -2332,6 +2333,16 @@ typedef struct AVCodecContext {
|
|||||||
* Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
|
* Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
|
||||||
*/
|
*/
|
||||||
int ticks_per_frame;
|
int ticks_per_frame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* explicit P-frame weighted prediction analysis method
|
||||||
|
* 0: off
|
||||||
|
* 1: fast blind weighting (one reference duplicate with -1 offset)
|
||||||
|
* 2: smart weighting (full fade detection analysis)
|
||||||
|
* - encoding: Set by user.
|
||||||
|
* - decoding: unused
|
||||||
|
*/
|
||||||
|
int weighted_p_pred;
|
||||||
} AVCodecContext;
|
} AVCodecContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +30,8 @@ typedef struct X264Context {
|
|||||||
x264_param_t params;
|
x264_param_t params;
|
||||||
x264_t *enc;
|
x264_t *enc;
|
||||||
x264_picture_t pic;
|
x264_picture_t pic;
|
||||||
|
uint8_t *sei;
|
||||||
|
int sei_size;
|
||||||
AVFrame out_pic;
|
AVFrame out_pic;
|
||||||
} X264Context;
|
} X264Context;
|
||||||
|
|
||||||
@ -48,14 +50,58 @@ static void X264_log(void *p, int level, const char *fmt, va_list args)
|
|||||||
av_vlog(p, level_map[level], fmt, args);
|
av_vlog(p, level_map[level], fmt, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if X264_BUILD >= 76
|
||||||
static int encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal)
|
static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size,
|
||||||
|
x264_nal_t *nals, int nnal, int skip_sei)
|
||||||
{
|
{
|
||||||
|
X264Context *x4 = ctx->priv_data;
|
||||||
uint8_t *p = buf;
|
uint8_t *p = buf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* Write the SEI as part of the first frame. */
|
||||||
|
if (x4->sei_size > 0 && nnal > 0) {
|
||||||
|
memcpy(p, x4->sei, x4->sei_size);
|
||||||
|
p += x4->sei_size;
|
||||||
|
x4->sei_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < nnal; i++){
|
for (i = 0; i < nnal; i++){
|
||||||
int s = x264_nal_encode(p, &size, 1, nals + i);
|
/* Don't put the SEI in extradata. */
|
||||||
|
if (skip_sei && nals[i].i_type == NAL_SEI) {
|
||||||
|
x4->sei_size = nals[i].i_payload;
|
||||||
|
x4->sei = av_malloc(x4->sei_size);
|
||||||
|
memcpy(x4->sei, nals[i].p_payload, nals[i].i_payload);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
memcpy(p, nals[i].p_payload, nals[i].i_payload);
|
||||||
|
p += nals[i].i_payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p - buf;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, x264_nal_t *nals, int nnal, int skip_sei)
|
||||||
|
{
|
||||||
|
X264Context *x4 = ctx->priv_data;
|
||||||
|
uint8_t *p = buf;
|
||||||
|
int i, s;
|
||||||
|
|
||||||
|
/* Write the SEI as part of the first frame. */
|
||||||
|
if (x4->sei_size > 0 && nnal > 0) {
|
||||||
|
memcpy(p, x4->sei, x4->sei_size);
|
||||||
|
p += x4->sei_size;
|
||||||
|
x4->sei_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < nnal; i++) {
|
||||||
|
/* Don't put the SEI in extradata. */
|
||||||
|
if (skip_sei && nals[i].i_type == NAL_SEI) {
|
||||||
|
x4->sei = av_malloc( 5 + nals[i].i_payload * 4 / 3 );
|
||||||
|
if(x264_nal_encode(x4->sei, &x4->sei_size, 1, nals + i) < 0)
|
||||||
|
return -1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
s = x264_nal_encode(p, &size, 1, nals + i);
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
return -1;
|
return -1;
|
||||||
p += s;
|
p += s;
|
||||||
@ -63,6 +109,7 @@ static int encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal)
|
|||||||
|
|
||||||
return p - buf;
|
return p - buf;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
|
static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
|
||||||
int bufsize, void *data)
|
int bufsize, void *data)
|
||||||
@ -86,15 +133,14 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
|
|||||||
x4->pic.i_type = X264_TYPE_AUTO;
|
x4->pic.i_type = X264_TYPE_AUTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL,
|
if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
|
||||||
&pic_out))
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
bufsize = encode_nals(buf, bufsize, nal, nnal);
|
bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
|
||||||
if (bufsize < 0)
|
if (bufsize < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* FIXME: dts */
|
/* FIXME: libx264 now provides DTS, but AVFrame doesn't have a field for it. */
|
||||||
x4->out_pic.pts = pic_out.i_pts;
|
x4->out_pic.pts = pic_out.i_pts;
|
||||||
|
|
||||||
switch (pic_out.i_type) {
|
switch (pic_out.i_type) {
|
||||||
@ -111,7 +157,11 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if X264_BUILD < 82
|
||||||
x4->out_pic.key_frame = pic_out.i_type == X264_TYPE_IDR;
|
x4->out_pic.key_frame = pic_out.i_type == X264_TYPE_IDR;
|
||||||
|
#else
|
||||||
|
x4->out_pic.key_frame = pic_out.b_keyframe;
|
||||||
|
#endif
|
||||||
x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
|
x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
|
||||||
|
|
||||||
return bufsize;
|
return bufsize;
|
||||||
@ -122,6 +172,7 @@ static av_cold int X264_close(AVCodecContext *avctx)
|
|||||||
X264Context *x4 = avctx->priv_data;
|
X264Context *x4 = avctx->priv_data;
|
||||||
|
|
||||||
av_freep(&avctx->extradata);
|
av_freep(&avctx->extradata);
|
||||||
|
av_free(x4->sei);
|
||||||
|
|
||||||
if (x4->enc)
|
if (x4->enc)
|
||||||
x264_encoder_close(x4->enc);
|
x264_encoder_close(x4->enc);
|
||||||
@ -133,6 +184,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
X264Context *x4 = avctx->priv_data;
|
X264Context *x4 = avctx->priv_data;
|
||||||
|
|
||||||
|
x4->sei_size = 0;
|
||||||
x264_param_default(&x4->params);
|
x264_param_default(&x4->params);
|
||||||
|
|
||||||
x4->params.pf_log = X264_log;
|
x4->params.pf_log = X264_log;
|
||||||
@ -164,7 +216,11 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
|||||||
x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
|
x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
|
||||||
x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
|
x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
|
||||||
x4->params.i_bframe_bias = avctx->bframebias;
|
x4->params.i_bframe_bias = avctx->bframebias;
|
||||||
|
#if X264_BUILD >= 78
|
||||||
|
x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE;
|
||||||
|
#else
|
||||||
x4->params.b_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID;
|
x4->params.b_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID;
|
||||||
|
#endif
|
||||||
avctx->has_b_frames = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
|
avctx->has_b_frames = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
|
||||||
|
|
||||||
x4->params.i_keyint_min = avctx->keyint_min;
|
x4->params.i_keyint_min = avctx->keyint_min;
|
||||||
@ -191,8 +247,10 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
|||||||
x4->params.i_height = avctx->height;
|
x4->params.i_height = avctx->height;
|
||||||
x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
|
x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
|
||||||
x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
|
x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
|
||||||
x4->params.i_fps_num = avctx->time_base.den;
|
#if X264_BUILD >= 81
|
||||||
x4->params.i_fps_den = avctx->time_base.num;
|
x4->params.i_fps_num = x4->params.i_timebase_den = avctx->time_base.den;
|
||||||
|
x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num;
|
||||||
|
#endif
|
||||||
|
|
||||||
x4->params.analyse.inter = 0;
|
x4->params.analyse.inter = 0;
|
||||||
if (avctx->partitions) {
|
if (avctx->partitions) {
|
||||||
@ -211,6 +269,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
|||||||
x4->params.analyse.i_direct_mv_pred = avctx->directpred;
|
x4->params.analyse.i_direct_mv_pred = avctx->directpred;
|
||||||
|
|
||||||
x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
|
x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
|
||||||
|
#if X264_BUILD >= 79
|
||||||
|
x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (avctx->me_method == ME_EPZS)
|
if (avctx->me_method == ME_EPZS)
|
||||||
x4->params.analyse.i_me_method = X264_ME_DIA;
|
x4->params.analyse.i_me_method = X264_ME_DIA;
|
||||||
@ -248,6 +309,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
|||||||
} else
|
} else
|
||||||
x4->params.rc.f_vbv_buffer_init = 0.9;
|
x4->params.rc.f_vbv_buffer_init = 0.9;
|
||||||
|
|
||||||
|
#if X264_BUILD >= 69
|
||||||
|
x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
|
||||||
|
#endif
|
||||||
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
|
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
|
||||||
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
|
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
|
||||||
x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
|
x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
|
||||||
@ -270,6 +334,17 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
avctx->coded_frame = &x4->out_pic;
|
avctx->coded_frame = &x4->out_pic;
|
||||||
|
|
||||||
|
#if X264_BUILD >= 76
|
||||||
|
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
|
||||||
|
x264_nal_t *nal;
|
||||||
|
int nnal, s;
|
||||||
|
|
||||||
|
s = x264_encoder_headers(x4->enc, &nal, &nnal);
|
||||||
|
|
||||||
|
avctx->extradata = av_malloc(s);
|
||||||
|
avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
|
if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
|
||||||
x264_nal_t *nal;
|
x264_nal_t *nal;
|
||||||
int nnal, i, s = 0;
|
int nnal, i, s = 0;
|
||||||
@ -281,8 +356,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
|||||||
s += 5 + nal[i].i_payload * 4 / 3;
|
s += 5 + nal[i].i_payload * 4 / 3;
|
||||||
|
|
||||||
avctx->extradata = av_malloc(s);
|
avctx->extradata = av_malloc(s);
|
||||||
avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal);
|
avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -296,6 +372,6 @@ AVCodec libx264_encoder = {
|
|||||||
.encode = X264_frame,
|
.encode = X264_frame,
|
||||||
.close = X264_close,
|
.close = X264_close,
|
||||||
.capabilities = CODEC_CAP_DELAY,
|
.capabilities = CODEC_CAP_DELAY,
|
||||||
.pix_fmts = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE },
|
.pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE },
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
|
.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
|
||||||
};
|
};
|
||||||
|
@ -122,6 +122,7 @@ static const AVOption options[]={
|
|||||||
{"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, 1.25, -FLT_MAX, FLT_MAX, V|E},
|
{"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, 1.25, -FLT_MAX, FLT_MAX, V|E},
|
||||||
{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
|
{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
|
||||||
{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
|
{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
|
||||||
|
{"wpredp", "weighted prediction analysis method", OFFSET(weighted_p_pred), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
|
||||||
{"hurry_up", NULL, OFFSET(hurry_up), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
|
{"hurry_up", NULL, OFFSET(hurry_up), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
|
||||||
{"ps", "rtp payload size in bits", OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
|
{"ps", "rtp payload size in bits", OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
|
||||||
{"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
|
{"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
|
||||||
@ -388,6 +389,7 @@ static const AVOption options[]={
|
|||||||
{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D},
|
{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D},
|
||||||
{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, 1.0, 0.0, 1.0, A|D},
|
{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, 1.0, 0.0, 1.0, A|D},
|
||||||
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"},
|
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"},
|
||||||
|
{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MBTREE, INT_MIN, INT_MAX, V|E, "flags2"},
|
||||||
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
|
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
|
||||||
{"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|E|D, "channel_layout"},
|
{"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|E|D, "channel_layout"},
|
||||||
{"request_channel_layout", NULL, OFFSET(request_channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|D, "request_channel_layout"},
|
{"request_channel_layout", NULL, OFFSET(request_channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|D, "request_channel_layout"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user