Change-Id: Ifa3c1cc2317c1bc21d1042b9662b35056d1e9ed0
This commit is contained in:
Dmitry Kovalev 2014-09-04 14:51:29 -07:00
Родитель 27db51c602
Коммит 7897059e8b
1 изменённых файлов: 8 добавлений и 9 удалений

Просмотреть файл

@ -837,18 +837,19 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
vpx_enc_frame_flags_t flags, vpx_enc_frame_flags_t flags,
unsigned long deadline) { unsigned long deadline) {
vpx_codec_err_t res = VPX_CODEC_OK; vpx_codec_err_t res = VPX_CODEC_OK;
VP9_COMP *const cpi = ctx->cpi;
const vpx_rational_t *const timebase = &ctx->cfg.g_timebase; const vpx_rational_t *const timebase = &ctx->cfg.g_timebase;
if (img != NULL) { if (img != NULL) {
res = validate_img(ctx, img); res = validate_img(ctx, img);
// TODO(jzern) the checks related to cpi's validity should be treated as a // TODO(jzern) the checks related to cpi's validity should be treated as a
// failure condition, encoder setup is done fully in init() currently. // failure condition, encoder setup is done fully in init() currently.
if (res == VPX_CODEC_OK && ctx->cpi != NULL && ctx->cx_data == NULL) { if (res == VPX_CODEC_OK && cpi != NULL && ctx->cx_data == NULL) {
// There's no codec control for multiple alt-refs so check the encoder // There's no codec control for multiple alt-refs so check the encoder
// instance for its status to determine the compressed data size. // instance for its status to determine the compressed data size.
ctx->cx_data_sz = ctx->cfg.g_w * ctx->cfg.g_h * ctx->cx_data_sz = ctx->cfg.g_w * ctx->cfg.g_h *
get_image_bps(img) / 8 * get_image_bps(img) / 8 *
(ctx->cpi->multi_arf_allowed ? 8 : 2); (cpi->multi_arf_allowed ? 8 : 2);
if (ctx->cx_data_sz < 4096) ctx->cx_data_sz = 4096; if (ctx->cx_data_sz < 4096) ctx->cx_data_sz = 4096;
ctx->cx_data = (unsigned char *)malloc(ctx->cx_data_sz); ctx->cx_data = (unsigned char *)malloc(ctx->cx_data_sz);
@ -868,7 +869,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
return VPX_CODEC_INVALID_PARAM; return VPX_CODEC_INVALID_PARAM;
} }
vp9_apply_encoding_flags(ctx->cpi, flags); vp9_apply_encoding_flags(cpi, flags);
// Handle fixed keyframe intervals // Handle fixed keyframe intervals
if (ctx->cfg.kf_mode == VPX_KF_AUTO && if (ctx->cfg.kf_mode == VPX_KF_AUTO &&
@ -880,7 +881,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
} }
// Initialize the encoder instance on the first frame. // Initialize the encoder instance on the first frame.
if (res == VPX_CODEC_OK && ctx->cpi != NULL) { if (res == VPX_CODEC_OK && cpi != NULL) {
unsigned int lib_flags = 0; unsigned int lib_flags = 0;
YV12_BUFFER_CONFIG sd; YV12_BUFFER_CONFIG sd;
int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts); int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts);
@ -891,16 +892,15 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
// Set up internal flags // Set up internal flags
if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) if (ctx->base.init_flags & VPX_CODEC_USE_PSNR)
((VP9_COMP *)ctx->cpi)->b_calculate_psnr = 1; cpi->b_calculate_psnr = 1;
if (img != NULL) { if (img != NULL) {
res = image2yuvconfig(img, &sd); res = image2yuvconfig(img, &sd);
// Store the original flags in to the frame buffer. Will extract the // Store the original flags in to the frame buffer. Will extract the
// key frame flag when we actually encode this frame. // key frame flag when we actually encode this frame.
if (vp9_receive_raw_frame(ctx->cpi, flags, if (vp9_receive_raw_frame(cpi, flags,
&sd, dst_time_stamp, dst_end_time_stamp)) { &sd, dst_time_stamp, dst_end_time_stamp)) {
VP9_COMP *cpi = (VP9_COMP *)ctx->cpi;
res = update_error_state(ctx, &cpi->common.error); res = update_error_state(ctx, &cpi->common.error);
} }
} }
@ -925,11 +925,10 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
} }
while (cx_data_sz >= ctx->cx_data_sz / 2 && while (cx_data_sz >= ctx->cx_data_sz / 2 &&
-1 != vp9_get_compressed_data(ctx->cpi, &lib_flags, &size, -1 != vp9_get_compressed_data(cpi, &lib_flags, &size,
cx_data, &dst_time_stamp, cx_data, &dst_time_stamp,
&dst_end_time_stamp, !img)) { &dst_end_time_stamp, !img)) {
if (size) { if (size) {
VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi;
vpx_codec_cx_pkt_t pkt; vpx_codec_cx_pkt_t pkt;
#if CONFIG_SPATIAL_SVC #if CONFIG_SPATIAL_SVC