diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2011-08-10 11:26:24 +0200 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-08-11 16:07:23 -0700 |
commit | e5ec68699e418b5c6044195fb998ee5287f2bb6f (patch) | |
tree | 89e36e1cfbe0bf98456474a59448f1979d42f3b8 /libavcodec/rv34.c | |
parent | d241f51e0f7c08060d2fa72117e2a1f273ab0c72 (diff) | |
download | ffmpeg-e5ec68699e418b5c6044195fb998ee5287f2bb6f.tar.gz |
RV3/4: calculate B-frame motion weights once per frame
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/rv34.c')
-rw-r--r-- | libavcodec/rv34.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index f8192a8f8f..58e4552bd8 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -568,12 +568,8 @@ static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int */ static int calc_add_mv(RV34DecContext *r, int dir, int val) { - int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts); - int dist = dir ? -GET_PTS_DIFF(r->next_pts, r->cur_pts) : GET_PTS_DIFF(r->cur_pts, r->last_pts); - int mul; + int mul = dir ? -r->weight2 : r->weight1; - if(!refdist) return 0; - mul = (dist << 14) / refdist; return (val * mul + 0x2000) >> 14; } @@ -1273,6 +1269,17 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int if(s->pict_type != AV_PICTURE_TYPE_B){ r->last_pts = r->next_pts; r->next_pts = r->cur_pts; + }else{ + int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts); + int dist0 = GET_PTS_DIFF(r->cur_pts, r->last_pts); + int dist1 = GET_PTS_DIFF(r->next_pts, r->cur_pts); + + if(!refdist){ + r->weight1 = r->weight2 = 8192; + }else{ + r->weight1 = (dist0 << 14) / refdist; + r->weight2 = (dist1 << 14) / refdist; + } } s->mb_x = s->mb_y = 0; } |