summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Massiot <cmassiot@openheadend.tv>2015-05-12 15:53:23 +0200
committerChristophe Massiot <cmassiot@openheadend.tv>2015-05-12 15:53:23 +0200
commitf9ef55eec9789e99ae3159112dfc9750081e3a98 (patch)
tree388d7b660ccbc61107052a895623cd353e840a30
parent73f18859425c24ce28cba5a61d780ded6516a9f0 (diff)
x264: take into account input overscan
-rw-r--r--lib/upipe-x264/upipe_x264.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/upipe-x264/upipe_x264.c b/lib/upipe-x264/upipe_x264.c
index 348f084..7e0331e 100644
--- a/lib/upipe-x264/upipe_x264.c
+++ b/lib/upipe-x264/upipe_x264.c
@@ -346,9 +346,10 @@ static struct upipe *upipe_x264_alloc(struct upipe_mgr *mgr,
* @param width image width
* @param height image height
* @param sar SAR
+ * @param overscan overscan
*/
static bool upipe_x264_open(struct upipe *upipe, int width, int height,
- struct urational *sar)
+ struct urational *sar, bool overscan)
{
struct upipe_x264 *upipe_x264 = upipe_x264_from_upipe(upipe);
struct urational fps = {0, 0};
@@ -368,6 +369,7 @@ static bool upipe_x264_open(struct upipe *upipe, int width, int height,
params->vui.i_sar_width = sar->num;
params->vui.i_sar_height = sar->den;
+ params->vui.i_overscan = overscan ? 2 : 1;
params->i_width = width;
params->i_height = height;
if (!ubase_check(uref_pic_get_progressive(upipe_x264->flow_def_input)))
@@ -573,17 +575,19 @@ static void upipe_x264_close(struct upipe *upipe)
* @param width image width
* @param height image height
* @param sar SAR
+ * @param overscan overscan
* @return true if parameters update needed
*/
static inline bool upipe_x264_need_update(struct upipe *upipe,
int width, int height,
- struct urational *sar)
+ struct urational *sar, bool overscan)
{
x264_param_t *params = &upipe_x264_from_upipe(upipe)->params;
return (params->i_width != width ||
params->i_height != height ||
params->vui.i_sar_width != sar->num ||
- params->vui.i_sar_height != sar->den);
+ params->vui.i_sar_height != sar->den ||
+ params->vui.i_overscan != (overscan ? 2 : 1));
}
/** @internal @This processes pictures.
@@ -632,17 +636,20 @@ static void upipe_x264_input(struct upipe *upipe, struct uref *uref,
uref_pic_flow_get_sar(upipe_x264->flow_def_input, &sar);
urational_simplify(&sar);
uref_pic_size(uref, &width, &height, NULL);
+ bool overscan =
+ ubase_check(uref_pic_flow_get_overscan(upipe_x264->flow_def_input));
/* open encoder if not already opened or if update needed */
if (unlikely(!upipe_x264->encoder)) {
needopen = true;
} else if (unlikely(upipe_x264_need_update(upipe, width, height,
- &sar))) {
+ &sar, overscan))) {
needopen = true;
upipe_notice(upipe, "Flow parameters changed, reconfiguring encoder");
}
if (unlikely(needopen)) {
- if (unlikely(!upipe_x264_open(upipe, width, height, &sar))) {
+ if (unlikely(!upipe_x264_open(upipe, width, height,
+ &sar, overscan))) {
upipe_err(upipe, "Could not open encoder");
uref_free(uref);
return;