[Ffmpeg-devel] mjpeg.c cosmetics/cleanup
Arpi
arpi
Fri Mar 24 23:39:30 CET 2006
Hi,
While working on mjpeg.c improvement (encoding without chroma subsampling)
i've found that encode_block() is quite messy (compared to decode_block),
it assumes 4:2:0 format, and its 'n' parameter is an 0..5 block index.
Although it should not be handled there, instead at mjpeg_encode_mb().
This patch fixes only this.
A'rpi
--- mjpeg.c.orig 2006-03-24 18:52:16.000000000 +0100
+++ mjpeg.c 2006-03-24 23:26:25.000000000 +0100
@@ -604,19 +604,18 @@
}
}
-static void encode_block(MpegEncContext *s, DCTELEM *block, int n)
+static void encode_block(MpegEncContext *s, DCTELEM *block, int component)
{
int mant, nbits, code, i, j;
- int component, dc, run, last_index, val;
+ int dc, run, last_index, val;
MJpegContext *m = s->mjpeg_ctx;
uint8_t *huff_size_ac;
uint16_t *huff_code_ac;
/* DC coef */
- component = (n <= 3 ? 0 : n - 4 + 1);
dc = block[0]; /* overflow is impossible */
val = dc - s->last_dc[component];
- if (n < 4) {
+ if (component == 0) {
mjpeg_encode_dc(s, val, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
huff_size_ac = m->huff_size_ac_luminance;
huff_code_ac = m->huff_code_ac_luminance;
@@ -667,7 +666,7 @@
{
int i;
for(i=0;i<6;i++) {
- encode_block(s, block[i], i);
+ encode_block(s, block[i], (i <= 3 ? 0 : i - 4 + 1) );
}
}
More information about the ffmpeg-devel
mailing list