[Ffmpeg-devel] [RFC, Request for testing, PATCH] snow wavelet fliping
Michael Niedermayer
michaelni
Tue Jan 2 18:26:00 CET 2007
Hi
the attached patch rotates the residual by 180? for every 2nd frame
before performing the wavelet transform (!only encoding is implemented!)
i tested it with a single file and it gave +0.10 PSNR
more testing is welcome
decoding support is welcome too
and comments about this are even more welcome
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
Index: libavcodec/snow.c
===================================================================
--- libavcodec/snow.c (revision 7401)
+++ libavcodec/snow.c (working copy)
@@ -471,6 +471,7 @@
#define ME_CACHE_SIZE 1024
int me_cache[ME_CACHE_SIZE];
int me_cache_generation;
+ int flip;
slice_buffer sb;
MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independant of MpegEncContext, so this will be removed then (FIXME/XXX)
@@ -2166,7 +2167,7 @@
// assert(score==256*256*256*64-1);
assert(iscore < 255*255*256 + s->lambda2*10);
- assert(iscore >= 0);
+// assert(iscore >= 0);
assert(l>=0 && l<=255);
assert(pl>=0 && pl<=255);
@@ -4058,6 +4059,19 @@
return 0;
}
+static void flip(int *buf, int w, int h){
+ int x,y;
+ for(y=0; y<h; y++){
+ for(x=0; x<w; x++){
+ int idx0= x + y*w;
+ int idx1= w-x-1 + (h-y-1)*w;
+ if(idx0>=idx1)
+ break;
+ FFSWAP(int, buf[idx0], buf[idx1]);
+ }
+ }
+}
+
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
SnowContext *s = avctx->priv_data;
RangeCoder * const c= &s->c;
@@ -4204,6 +4218,9 @@
}
}
+ if(++s->flip & 1)
+ flip(s->spatial_dwt_buffer, w, h);
+
ff_spatial_dwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
if(s->pass1_rc && plane_index==0){
@@ -4244,6 +4261,8 @@
}
ff_spatial_idwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
+ if(s->flip & 1)
+ flip(s->spatial_dwt_buffer, w, h);
if(s->qlog == LOSSLESS_QLOG){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070102/22003877/attachment.pgp>
More information about the ffmpeg-devel
mailing list