summaryrefslogtreecommitdiff
path: root/vp8/vp8_cx_iface.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/vp8_cx_iface.c')
-rw-r--r--vp8/vp8_cx_iface.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c
index a6cb27b93..ed830cca0 100644
--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -14,6 +14,7 @@
#include "vpx_version.h"
#include "onyx_int.h"
#include "vpx/vp8e.h"
+#include "vp8/encoder/firstpass.h"
#include "onyx.h"
#include <stdlib.h>
#include <string.h>
@@ -103,6 +104,7 @@ update_error_state(vpx_codec_alg_priv_t *ctx,
}
+#undef ERROR
#define ERROR(str) do {\
ctx->base.err_detail = str;\
return VPX_CODEC_INVALID_PARAM;\
@@ -131,8 +133,8 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
const vpx_codec_enc_cfg_t *cfg,
const struct vp8_extracfg *vp8_cfg)
{
- RANGE_CHECK(cfg, g_w, 2, 16384);
- RANGE_CHECK(cfg, g_h, 2, 16384);
+ RANGE_CHECK(cfg, g_w, 1, 16384);
+ RANGE_CHECK(cfg, g_h, 1, 16384);
RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000);
RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den);
RANGE_CHECK_HI(cfg, g_profile, 3);
@@ -184,27 +186,30 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
RANGE_CHECK(vp8_cfg, token_partitions, VP8_ONE_TOKENPARTITION, VP8_EIGHT_TOKENPARTITION);
RANGE_CHECK_HI(vp8_cfg, Sharpness, 7);
RANGE_CHECK(vp8_cfg, arnr_max_frames, 0, 15);
- RANGE_CHECK(vp8_cfg, arnr_strength, 1, 6);
+ RANGE_CHECK_HI(vp8_cfg, arnr_strength, 6);
RANGE_CHECK(vp8_cfg, arnr_type, 1, 3);
if (cfg->g_pass == VPX_RC_LAST_PASS)
{
- int n_doubles = cfg->rc_twopass_stats_in.sz / sizeof(double);
- int n_packets = cfg->rc_twopass_stats_in.sz / sizeof(FIRSTPASS_STATS);
- double frames;
+ int mb_r = (cfg->g_h + 15) / 16;
+ int mb_c = (cfg->g_w + 15) / 16;
+ size_t packet_sz = vp8_firstpass_stats_sz(mb_r * mb_c);
+ int n_packets = cfg->rc_twopass_stats_in.sz / packet_sz;
+ FIRSTPASS_STATS *stats;
if (!cfg->rc_twopass_stats_in.buf)
ERROR("rc_twopass_stats_in.buf not set.");
- if (cfg->rc_twopass_stats_in.sz % sizeof(FIRSTPASS_STATS))
+ if (cfg->rc_twopass_stats_in.sz % packet_sz)
ERROR("rc_twopass_stats_in.sz indicates truncated packet.");
- if (cfg->rc_twopass_stats_in.sz < 2 * sizeof(FIRSTPASS_STATS))
+ if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz)
ERROR("rc_twopass_stats_in requires at least two packets.");
- frames = ((double *)cfg->rc_twopass_stats_in.buf)[n_doubles - 1];
+ stats = (void*)((char *)cfg->rc_twopass_stats_in.buf
+ + (n_packets - 1) * packet_sz);
- if ((int)(frames + 0.5) != n_packets - 1)
+ if ((int)(stats->count + 0.5) != n_packets - 1)
ERROR("rc_twopass_stats_in missing EOS stats packet");
}
@@ -759,12 +764,13 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx,
{
pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE;
- // TODO: ideally this timestamp should be as close as
- // possible to the prior PTS so that if a decoder uses
- // pts to schedule when to do this, we start right after
- // last frame was decoded. Maybe should be set to
- // last time stamp. Invisible frames have no duration..
- pkt.data.frame.pts --;
+ // This timestamp should be as close as possible to the
+ // prior PTS so that if a decoder uses pts to schedule when
+ // to do this, we start right after last frame was decoded.
+ // Invisible frames have no duration.
+ pkt.data.frame.pts = ((cpi->last_time_stamp_seen
+ * ctx->cfg.g_timebase.den + round)
+ / ctx->cfg.g_timebase.num / 10000000) + 1;
pkt.data.frame.duration = 0;
}
@@ -855,8 +861,16 @@ static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx)
{
YV12_BUFFER_CONFIG sd;
+ vp8_ppflags_t flags = {0};
- if (0 == vp8_get_preview_raw_frame(ctx->cpi, &sd, ctx->preview_ppcfg.deblocking_level, ctx->preview_ppcfg.noise_level, ctx->preview_ppcfg.post_proc_flag))
+ if (ctx->preview_ppcfg.post_proc_flag)
+ {
+ flags.post_proc_flag = ctx->preview_ppcfg.post_proc_flag;
+ flags.deblocking_level = ctx->preview_ppcfg.deblocking_level;
+ flags.noise_level = ctx->preview_ppcfg.noise_level;
+ }
+
+ if (0 == vp8_get_preview_raw_frame(ctx->cpi, &sd, &flags))
{
/*