[XviD-devel] [PATCH proposal] Feedback required
Edouard Gomez
ed.gomez at free.fr
Sun May 30 19:20:24 CEST 2004
I propose this patch. As it touches to time code, i'd prefer
everyone test it before it goes to CVS.
What does it fix:
* Code in bitstream.c did assume like reference frames could
not be distant from each other more than from 1s (all maths
were done modulo the 1s time increments).
* bframe direct mode was a bit strange, mvs weren't
interpolated right, formulas fixed, all seems to work as it
should have been.
Please test.
NB: the code for time in bitstream was enclosed in #if 0
#endif blocks, so i guess it's not the first time someone
plays with this part of the code.
--
Edouard Gomez
-------------- next part --------------
* looking for ed.gomez at free.fr--2004-1/xvidcore--stable--1.0--patch-36 to compare with
* comparing to ed.gomez at free.fr--2004-1/xvidcore--stable--1.0--patch-36
M src/decoder.c
M src/decoder.h
M src/bitstream/bitstream.c
* modified files
--- orig/src/bitstream/bitstream.c
+++ mod/src/bitstream/bitstream.c
@@ -814,23 +814,12 @@
if (coding_type != B_VOP) {
dec->last_time_base = dec->time_base;
dec->time_base += time_incr;
- dec->time = time_increment;
-
-#if 0
- dec->time_base * dec->time_inc_resolution +
- time_increment;
-#endif
- dec->time_pp = (uint32_t)
- (dec->time_inc_resolution + dec->time - dec->last_non_b_time)%dec->time_inc_resolution;
+ dec->time = dec->time_base*dec->time_inc_resolution + time_increment;
+ dec->time_pp = (int32_t)(dec->time - dec->last_non_b_time);
dec->last_non_b_time = dec->time;
} else {
- dec->time = time_increment;
-#if 0
- (dec->last_time_base +
- time_incr) * dec->time_inc_resolution + time_increment;
-#endif
- dec->time_bp = (uint32_t)
- (dec->time_inc_resolution + dec->last_non_b_time - dec->time)%dec->time_inc_resolution;
+ dec->time = (dec->last_time_base + time_incr)*dec->time_inc_resolution + time_increment;
+ dec->time_bp = dec->time_pp - (int32_t)(dec->last_non_b_time - dec->time);
}
DPRINTF(XVID_DEBUG_HEADER,"time_pp=%i\n", dec->time_pp);
DPRINTF(XVID_DEBUG_HEADER,"time_bp=%i\n", dec->time_bp);
@@ -1023,7 +1012,7 @@
else
sscanf(tmp, "XviD%d", &dec->bs_version);
- DPRINTF(XVID_DEBUG_HEADER, "xvid bitstream version=%i", dec->bs_version);
+ DPRINTF(XVID_DEBUG_HEADER, "xvid bitstream version=%i\n", dec->bs_version);
}
/* divx detection */
--- orig/src/decoder.c
+++ mod/src/decoder.c
@@ -1215,7 +1215,6 @@
uint32_t x, y;
VECTOR mv;
const VECTOR zeromv = {0,0};
- const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp;
int i;
start_timer();
@@ -1310,14 +1309,15 @@
case MODE_DIRECT_NONE_MV:
for (i = 0; i < 4; i++) {
- mb->mvs[i].x = (int32_t) ((TRB * last_mb->mvs[i].x) / TRD + mv.x);
- mb->b_mvs[i].x = (int32_t) ((mv.x == 0)
- ? ((TRB - TRD) * last_mb->mvs[i].x) / TRD
- : mb->mvs[i].x - last_mb->mvs[i].x);
- mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y);
- mb->b_mvs[i].y = (int32_t) ((mv.y == 0)
- ? ((TRB - TRD) * last_mb->mvs[i].y) / TRD
- : mb->mvs[i].y - last_mb->mvs[i].y);
+ mb->mvs[i].x = last_mb->mvs[i].x*dec->time_bp/dec->time_pp + mv.x;
+ mb->mvs[i].y = last_mb->mvs[i].y*dec->time_bp/dec->time_pp + mv.y;
+
+ mb->b_mvs[i].x = (mv.x)
+ ? mb->mvs[i].x - last_mb->mvs[i].x
+ : last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp;
+ mb->b_mvs[i].y = (mv.y)
+ ? mb->mvs[i].y - last_mb->mvs[i].y
+ : last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp;
}
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],
--- orig/src/decoder.h
+++ mod/src/decoder.h
@@ -145,8 +145,8 @@
int64_t time_base;
int64_t last_time_base;
int64_t last_non_b_time;
- uint32_t time_pp;
- uint32_t time_bp;
+ int32_t time_pp;
+ int32_t time_bp;
uint32_t low_delay; /* low_delay flage (1 means no B_VOP) */
uint32_t low_delay_default; /* default value for low_delay flag */
More information about the XviD-devel
mailing list