Hi Here is old cyuv encoder resurrected from [Ffmpeg-devel] Trellis Quantization Applied To (A)DPCM http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-June/011688.html by Loren. I added some #ifdef DEBUG around printf code, renamed some macros. Can it be applied ? -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
On Thu, Mar 01, 2007 at 01:45:26AM +0100, Baptiste Coudurier wrote:
Here is old cyuv encoder resurrected from
[Ffmpeg-devel] Trellis Quantization Applied To (A)DPCM http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-June/011688.html
by Loren.
--- libavcodec/cyuvenc.c (revision 0) +++ libavcodec/cyuvenc.c (revision 0) @@ -0,0 +1,569 @@ +/* + * CYUV encoder + * Copyright (C) 2006 Lorent Meritt.
Loren Diego
Hi On Thu, Mar 01, 2007 at 01:45:26AM +0100, Baptiste Coudurier wrote:
Hi
Here is old cyuv encoder resurrected from
[Ffmpeg-devel] Trellis Quantization Applied To (A)DPCM http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-June/011688.html
by Loren.
I added some #ifdef DEBUG around printf code, renamed some macros. Can it be applied ?
[...]
+ u = nodes; + nodes = nodes_next; + nodes_next = u;
FFSWAP [...]
+ for(i=0; i<16; i++){ + int score = abs(d - table[i]);
FFABS [...]
+static int tables_tried = 0;
non constant static [...]
+ { + static int fn = 0; + dprintf("fn %d tables_tried %d \n", fn, tables_tried); + fn++; + }
ugly [...]
+ uint8_t y_buf[s->avctx->width]; + uint8_t u_buf[s->avctx->width>>2]; + uint8_t v_buf[s->avctx->width>>2]; + pict->error[0] += quantize_row_trellis(avctx, y_ptr, y_buf, y_table, y_itable, s->avctx->width); + pict->error[1] += quantize_row_trellis(avctx, u_ptr, u_buf, u_table, u_itable, s->avctx->width>>2); + pict->error[2] += quantize_row_trellis(avctx, v_ptr, v_buf, v_table, v_itable, s->avctx->width>>2);
could be put into a loop maybe, the same applies to other similar YUV cases of course only if the resulting code is simpler [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you really think that XML is the answer, then you definitly missunderstood the question -- Attila Kinali
Hi Michael Niedermayer wrote:
Hi
On Thu, Mar 01, 2007 at 01:45:26AM +0100, Baptiste Coudurier wrote:
Hi
Here is old cyuv encoder resurrected from
[Ffmpeg-devel] Trellis Quantization Applied To (A)DPCM http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-June/011688.html
by Loren.
I added some #ifdef DEBUG around printf code, renamed some macros. Can it be applied ?
[...]
+ u = nodes; + nodes = nodes_next; + nodes_next = u;
FFSWAP
Done
[...]
+ for(i=0; i<16; i++){ + int score = abs(d - table[i]);
FFABS
Done
[...]
+static int tables_tried = 0;
non constant static
Removed
[...]
+ { + static int fn = 0; + dprintf("fn %d tables_tried %d \n", fn, tables_tried); + fn++; + }
Removed.
[...]
+ uint8_t y_buf[s->avctx->width]; + uint8_t u_buf[s->avctx->width>>2]; + uint8_t v_buf[s->avctx->width>>2]; + pict->error[0] += quantize_row_trellis(avctx, y_ptr, y_buf, y_table, y_itable, s->avctx->width); + pict->error[1] += quantize_row_trellis(avctx, u_ptr, u_buf, u_table, u_itable, s->avctx->width>>2); + pict->error[2] += quantize_row_trellis(avctx, v_ptr, v_buf, v_table, v_itable, s->avctx->width>>2);
could be put into a loop maybe, the same applies to other similar YUV cases of course only if the resulting code is simpler
I'll let Loren do it if he feels like it. Updated patch attached. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Baptiste Coudurier wrote:
Hi
Michael Niedermayer wrote:
Hi
On Thu, Mar 01, 2007 at 01:45:26AM +0100, Baptiste Coudurier wrote:
Hi
Here is old cyuv encoder resurrected from
[Ffmpeg-devel] Trellis Quantization Applied To (A)DPCM http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-June/011688.html
by Loren.
I added some #ifdef DEBUG around printf code, renamed some macros. Can it be applied ? [...] + u = nodes; + nodes = nodes_next; + nodes_next = u; FFSWAP
Done
[...]
+ for(i=0; i<16; i++){ + int score = abs(d - table[i]); FFABS
Done
[...]
+static int tables_tried = 0; non constant static
Removed
[...]
+ { + static int fn = 0; + dprintf("fn %d tables_tried %d \n", fn, tables_tried); + fn++; + }
Removed.
[...]
+ uint8_t y_buf[s->avctx->width]; + uint8_t u_buf[s->avctx->width>>2]; + uint8_t v_buf[s->avctx->width>>2]; + pict->error[0] += quantize_row_trellis(avctx, y_ptr, y_buf, y_table, y_itable, s->avctx->width); + pict->error[1] += quantize_row_trellis(avctx, u_ptr, u_buf, u_table, u_itable, s->avctx->width>>2); + pict->error[2] += quantize_row_trellis(avctx, v_ptr, v_buf, v_table, v_itable, s->avctx->width>>2); could be put into a loop maybe, the same applies to other similar YUV cases of course only if the resulting code is simpler
I'll let Loren do it if he feels like it. Updated patch attached.
[...] + +static int quantize_sample(int sample, int *pred, const int8_t *table, const uint8_t *itable) +{ + int p = *pred; + int bi = itable[(sample - p) & 0xff]; + *pred = p + table[bi]; + if(*pred & ~0xff){ + int i, bscore=INT_MAX; + for(i=0; i<16; i++){ + int score = abs(sample - ((p + table[i]) & 0xff));
Rah, that is changed to FFABS in my tree. [...] -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Baptiste Coudurier wrote:
Baptiste Coudurier wrote:
Michael Niedermayer wrote:
Baptiste Coudurier wrote:
+ uint8_t y_buf[s->avctx->width]; + uint8_t u_buf[s->avctx->width>>2]; + uint8_t v_buf[s->avctx->width>>2]; + pict->error[0] += quantize_row_trellis(avctx, y_ptr, y_buf, y_table, y_itable, s->avctx->width); + pict->error[1] += quantize_row_trellis(avctx, u_ptr, u_buf, u_table, u_itable, s->avctx->width>>2); + pict->error[2] += quantize_row_trellis(avctx, v_ptr, v_buf, v_table, v_itable, s->avctx->width>>2); could be put into a loop maybe, the same applies to other similar YUV cases of course only if the resulting code is simpler
Yes, it's simpler.
+static int quantize_sample(int sample, int *pred, const int8_t *table, const uint8_t *itable) +{ + int p = *pred; + int bi = itable[(sample - p) & 0xff]; + *pred = p + table[bi]; + if(*pred & ~0xff){ + int i, bscore=INT_MAX; + for(i=0; i<16; i++){ + int score = abs(sample - ((p + table[i]) & 0xff));
Rah, that is changed to FFABS in my tree.
Better yet, don't compute abs at all. The whole codec (without trellis) is 13% faster this way. --Loren Merritt
Hi On Fri, Mar 02, 2007 at 08:10:12PM -0700, Loren Merritt wrote:
Baptiste Coudurier wrote:
Baptiste Coudurier wrote:
Michael Niedermayer wrote:
Baptiste Coudurier wrote:
+ uint8_t y_buf[s->avctx->width]; + uint8_t u_buf[s->avctx->width>>2]; + uint8_t v_buf[s->avctx->width>>2]; + pict->error[0] += quantize_row_trellis(avctx, y_ptr, y_buf, y_table, y_itable, s->avctx->width); + pict->error[1] += quantize_row_trellis(avctx, u_ptr, u_buf, u_table, u_itable, s->avctx->width>>2); + pict->error[2] += quantize_row_trellis(avctx, v_ptr, v_buf, v_table, v_itable, s->avctx->width>>2); could be put into a loop maybe, the same applies to other similar YUV cases of course only if the resulting code is simpler
Yes, it's simpler.
+static int quantize_sample(int sample, int *pred, const int8_t *table, const uint8_t *itable) +{ + int p = *pred; + int bi = itable[(sample - p) & 0xff]; + *pred = p + table[bi]; + if(*pred & ~0xff){ + int i, bscore=INT_MAX; + for(i=0; i<16; i++){ + int score = abs(sample - ((p + table[i]) & 0xff));
Rah, that is changed to FFABS in my tree.
Better yet, don't compute abs at all. The whole codec (without trellis) is 13% faster this way.
hmm, if this code matters so much speedwise then i think it could be changed to int p = *pred; int bi = itable[(sample - p) & 0xff]; *pred = p + table[bi]; if(*pred & ~0xff){ bi = itable2[(sample - p) & 0xff]; *pred = p + table[bi]; } where itable2 rounds in the oposite direction than itable [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Observe your enemies, for they first find out your faults. -- Antisthenes
On Sat, 3 Mar 2007, Michael Niedermayer wrote:
On Fri, Mar 02, 2007 at 08:10:12PM -0700, Loren Merritt wrote:
Better yet, don't compute abs at all. The whole codec (without trellis) is 13% faster this way.
hmm, if this code matters so much speedwise then i think it could be changed to int p = *pred; int bi = itable[(sample - p) & 0xff]; *pred = p + table[bi]; if(*pred & ~0xff){ bi = itable2[(sample - p) & 0xff]; *pred = p + table[bi]; }
where itable2 rounds in the oposite direction than itable
Old code was wrong. It only triggered the correction when the quantized delta overflows and the input doesn't, but it should also trigger when the input delta overflows and the quantized one doesn't. After fixing that I don't see how to implement the correction as a table, but I can avoid the search. --Loren Merritt
Hi On Sat, Mar 03, 2007 at 11:23:22PM -0700, Loren Merritt wrote:
On Sat, 3 Mar 2007, Michael Niedermayer wrote:
On Fri, Mar 02, 2007 at 08:10:12PM -0700, Loren Merritt wrote:
Better yet, don't compute abs at all. The whole codec (without trellis) is 13% faster this way.
hmm, if this code matters so much speedwise then i think it could be changed to int p = *pred; int bi = itable[(sample - p) & 0xff]; *pred = p + table[bi]; if(*pred & ~0xff){ bi = itable2[(sample - p) & 0xff]; *pred = p + table[bi]; }
where itable2 rounds in the oposite direction than itable
Old code was wrong. It only triggered the correction when the quantized delta overflows and the input doesn't, but it should also trigger when the input delta overflows and the quantized one doesn't. After fixing that I don't see how to implement the correction as a table, but I can avoid the search.
new code seems wrong too, ive attached some test code, with your new code, my 2 table variant and bruteforce quantization [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The misfortune of the wise is better than the prosperity of the fool. -- Epicurus
Hi guys, Michael Niedermayer wrote:
Hi
On Sat, Mar 03, 2007 at 11:23:22PM -0700, Loren Merritt wrote:
On Sat, 3 Mar 2007, Michael Niedermayer wrote:
On Fri, Mar 02, 2007 at 08:10:12PM -0700, Loren Merritt wrote:
Better yet, don't compute abs at all. The whole codec (without trellis) is 13% faster this way. hmm, if this code matters so much speedwise then i think it could be changed to int p = *pred; int bi = itable[(sample - p) & 0xff]; *pred = p + table[bi]; if(*pred & ~0xff){ bi = itable2[(sample - p) & 0xff]; *pred = p + table[bi]; }
where itable2 rounds in the oposite direction than itable Old code was wrong. It only triggered the correction when the quantized delta overflows and the input doesn't, but it should also trigger when the input delta overflows and the quantized one doesn't. After fixing that I don't see how to implement the correction as a table, but I can avoid the search.
new code seems wrong too, ive attached some test code, with your new code, my 2 table variant and bruteforce quantization
[...]
How hard is it to resurrect this and commit ? For the sake of completeness :> -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Smartjog USA Inc. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
participants (4)
-
baptiste.coudurier@smartjog.com -
diego@biurrun.de -
lorenm@u.washington.edu -
michaelni@gmx.at