mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-08-20 16:25:04 +02:00
Add support for new x264 API.
Originally committed as revision 19977 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
98f7bcb119
commit
2d3beedee2
4
configure
vendored
4
configure
vendored
@ -2292,8 +2292,8 @@ 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_encode -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 >= 76" ||
|
||||||
die "ERROR: libx264 version must be >= 0.65."; }
|
die "ERROR: libx264 version must be >= 0.76."; }
|
||||||
enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
|
enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
|
||||||
enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
|
enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
|
||||||
|
|
||||||
|
@ -52,16 +52,14 @@ X264_log(void *p, int level, const char *fmt, va_list args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, x264_nal_t *nals, int nnal, int skip_sei)
|
||||||
encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, x264_nal_t *nals, int nnal, int skip_sei)
|
|
||||||
{
|
{
|
||||||
X264Context *x4 = ctx->priv_data;
|
X264Context *x4 = ctx->priv_data;
|
||||||
uint8_t *p = buf;
|
uint8_t *p = buf;
|
||||||
int i, s;
|
int i;
|
||||||
|
|
||||||
/* Write the SEI as part of the first frame. */
|
/* Write the SEI as part of the first frame. */
|
||||||
if(x4->sei_size > 0 && nnal > 0)
|
if(x4->sei_size > 0 && nnal > 0){
|
||||||
{
|
|
||||||
memcpy(p, x4->sei, x4->sei_size);
|
memcpy(p, x4->sei, x4->sei_size);
|
||||||
p += x4->sei_size;
|
p += x4->sei_size;
|
||||||
x4->sei_size = 0;
|
x4->sei_size = 0;
|
||||||
@ -69,17 +67,14 @@ encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, x264_nal_t *nals, int n
|
|||||||
|
|
||||||
for(i = 0; i < nnal; i++){
|
for(i = 0; i < nnal; i++){
|
||||||
/* Don't put the SEI in extradata. */
|
/* Don't put the SEI in extradata. */
|
||||||
if(skip_sei && nals[i].i_type == NAL_SEI)
|
if(skip_sei && nals[i].i_type == NAL_SEI){
|
||||||
{
|
x4->sei_size = nals[i].i_payload;
|
||||||
x4->sei = av_malloc( 5 + nals[i].i_payload * 4 / 3 );
|
x4->sei = av_malloc(x4->sei_size);
|
||||||
if(x264_nal_encode(x4->sei, &x4->sei_size, 1, nals + i) < 0)
|
memcpy(x4->sei, nals[i].p_payload, nals[i].i_payload);
|
||||||
return -1;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
s = x264_nal_encode(p, &size, 1, nals + i);
|
memcpy(p, nals[i].p_payload, nals[i].i_payload);
|
||||||
if(s < 0)
|
p += nals[i].i_payload;
|
||||||
return -1;
|
|
||||||
p += s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return p - buf;
|
return p - buf;
|
||||||
@ -97,7 +92,7 @@ X264_frame(AVCodecContext *ctx, uint8_t *buf, int bufsize, void *data)
|
|||||||
x4->pic.img.i_csp = X264_CSP_I420;
|
x4->pic.img.i_csp = X264_CSP_I420;
|
||||||
x4->pic.img.i_plane = 3;
|
x4->pic.img.i_plane = 3;
|
||||||
|
|
||||||
if (frame) {
|
if(frame){
|
||||||
for(i = 0; i < 3; i++){
|
for(i = 0; i < 3; i++){
|
||||||
x4->pic.img.plane[i] = frame->data[i];
|
x4->pic.img.plane[i] = frame->data[i];
|
||||||
x4->pic.img.i_stride[i] = frame->linesize[i];
|
x4->pic.img.i_stride[i] = frame->linesize[i];
|
||||||
@ -107,8 +102,7 @@ X264_frame(AVCodecContext *ctx, uint8_t *buf, int bufsize, void *data)
|
|||||||
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(ctx, buf, bufsize, nal, nnal, 0);
|
bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
|
||||||
@ -296,13 +290,9 @@ X264_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
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, s;
|
||||||
|
|
||||||
x264_encoder_headers(x4->enc, &nal, &nnal);
|
s = x264_encoder_headers(x4->enc, &nal, &nnal);
|
||||||
|
|
||||||
/* 5 bytes NAL header + worst case escaping */
|
|
||||||
for(i = 0; i < nnal; i++)
|
|
||||||
s += 5 + nal[i].i_payload * 4 / 3;
|
|
||||||
|
|
||||||
avctx->extradata = av_malloc(s);
|
avctx->extradata = av_malloc(s);
|
||||||
avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
|
avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user