mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-20 06:20:40 +00:00
x264: Factor out the reconfiguration code
This commit is contained in:
parent
24ad3ac6a3
commit
03ca6d70df
@ -128,33 +128,12 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
|
||||
int *got_packet)
|
||||
static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame)
|
||||
{
|
||||
X264Context *x4 = ctx->priv_data;
|
||||
x264_nal_t *nal;
|
||||
int nnal, i, ret;
|
||||
x264_picture_t pic_out;
|
||||
AVFrameSideData *side_data;
|
||||
|
||||
x264_picture_init( &x4->pic );
|
||||
x4->pic.img.i_csp = x4->params.i_csp;
|
||||
if (x264_bit_depth > 8)
|
||||
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
|
||||
x4->pic.img.i_plane = 3;
|
||||
|
||||
if (frame) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
x4->pic.img.plane[i] = frame->data[i];
|
||||
x4->pic.img.i_stride[i] = frame->linesize[i];
|
||||
}
|
||||
|
||||
x4->pic.i_pts = frame->pts;
|
||||
x4->pic.i_type =
|
||||
frame->pict_type == AV_PICTURE_TYPE_I ? X264_TYPE_KEYFRAME :
|
||||
frame->pict_type == AV_PICTURE_TYPE_P ? X264_TYPE_P :
|
||||
frame->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B :
|
||||
X264_TYPE_AUTO;
|
||||
if (x4->params.b_tff != frame->top_field_first) {
|
||||
x4->params.b_tff = frame->top_field_first;
|
||||
x264_encoder_reconfig(x4->enc, &x4->params);
|
||||
@ -233,6 +212,35 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
|
||||
int *got_packet)
|
||||
{
|
||||
X264Context *x4 = ctx->priv_data;
|
||||
x264_nal_t *nal;
|
||||
int nnal, i, ret;
|
||||
x264_picture_t pic_out;
|
||||
|
||||
x264_picture_init( &x4->pic );
|
||||
x4->pic.img.i_csp = x4->params.i_csp;
|
||||
if (x264_bit_depth > 8)
|
||||
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
|
||||
x4->pic.img.i_plane = 3;
|
||||
|
||||
if (frame) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
x4->pic.img.plane[i] = frame->data[i];
|
||||
x4->pic.img.i_stride[i] = frame->linesize[i];
|
||||
}
|
||||
|
||||
x4->pic.i_pts = frame->pts;
|
||||
x4->pic.i_type =
|
||||
frame->pict_type == AV_PICTURE_TYPE_I ? X264_TYPE_KEYFRAME :
|
||||
frame->pict_type == AV_PICTURE_TYPE_P ? X264_TYPE_P :
|
||||
frame->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B :
|
||||
X264_TYPE_AUTO;
|
||||
reconfig_encoder(ctx, frame);
|
||||
}
|
||||
do {
|
||||
if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
|
||||
return AVERROR_UNKNOWN;
|
||||
|
Loading…
Reference in New Issue
Block a user