summaryrefslogtreecommitdiff
path: root/src/libffmpeg/libavcodec/motion_est.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libffmpeg/libavcodec/motion_est.c')
-rw-r--r--src/libffmpeg/libavcodec/motion_est.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/libffmpeg/libavcodec/motion_est.c b/src/libffmpeg/libavcodec/motion_est.c
index d3e31fc42..084eb6038 100644
--- a/src/libffmpeg/libavcodec/motion_est.c
+++ b/src/libffmpeg/libavcodec/motion_est.c
@@ -17,6 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include "config.h"
+#include "xine-utils/xineutils.h"
#include <stdlib.h>
#include <stdio.h>
#include "avcodec.h"
@@ -400,7 +402,7 @@ int estimate_motion(MpegEncContext * s,
UINT8 *pix, *ppix;
int sum, varc, vard, mx, my, range, dmin, xx, yy;
int xmin, ymin, xmax, ymax;
-
+
range = 8 * (1 << (s->f_code - 1));
/* XXX: temporary kludge to avoid overflow for msmpeg4 */
if (s->out_format == FMT_H263 && !s->h263_msmpeg4)
@@ -409,13 +411,20 @@ int estimate_motion(MpegEncContext * s,
if (s->unrestricted_mv) {
xmin = -16;
ymin = -16;
- xmax = s->width;
- ymax = s->height;
+ if(s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MPEG4){
+ xmax = s->mb_width*16;
+ ymax = s->mb_height*16;
+ }else {
+ /* XXX: dunno if this is correct but ffmpeg4 decoder wont like it otherwise
+ (cuz the drawn edge isnt large enough))*/
+ xmax = s->width;
+ ymax = s->height;
+ }
} else {
xmin = 0;
ymin = 0;
- xmax = s->width - 16;
- ymax = s->height - 16;
+ xmax = s->mb_width*16 - 16;
+ ymax = s->mb_height*16 - 16;
}
switch(s->full_search) {
@@ -451,9 +460,12 @@ int estimate_motion(MpegEncContext * s,
vard = vard >> 8;
sum = sum >> 8;
varc = (varc >> 8) - (sum * sum);
+ s->mb_var[s->mb_width * mb_y + mb_x] = varc;
+ s->avg_mb_var += varc;
+
#if 0
- printf("varc=%d (sum=%d) vard=%d mx=%d my=%d\n",
- varc, sum, vard, mx - xx, my - yy);
+ printf("varc=%4d avg_var=%4d (sum=%4d) vard=%4d mx=%2d my=%2d\n",
+ varc, s->avg_mb_var, sum, vard, mx - xx, my - yy);
#endif
if (vard <= 64 || vard < varc) {
if (s->full_search != ME_ZERO) {