[FFmpeg-cvslog] r25344 - in trunk/libavcodec: a64enc.h a64multienc.c

bindhammer subversion
Tue Oct 5 14:14:14 CEST 2010


Author: bindhammer
Date: Tue Oct  5 14:14:14 2010
New Revision: 25344

Log:
Introduce palette with dynamic size.

Modified:
   trunk/libavcodec/a64enc.h
   trunk/libavcodec/a64multienc.c

Modified: trunk/libavcodec/a64enc.h
==============================================================================
--- trunk/libavcodec/a64enc.h	Tue Oct  5 13:06:32 2010	(r25343)
+++ trunk/libavcodec/a64enc.h	Tue Oct  5 14:14:14 2010	(r25344)
@@ -48,6 +48,8 @@ typedef struct A64Context {
     int mc_luma_vals[5];
     uint8_t *mc_charset;
     uint8_t *mc_colram;
+    uint8_t *mc_palette;
+    int mc_pal_size;
 } A64Context;
 
 #endif /* AVCODEC_A64ENC_H */

Modified: trunk/libavcodec/a64multienc.c
==============================================================================
--- trunk/libavcodec/a64multienc.c	Tue Oct  5 13:06:32 2010	(r25343)
+++ trunk/libavcodec/a64multienc.c	Tue Oct  5 14:14:14 2010	(r25344)
@@ -86,16 +86,16 @@ static void render_charset(AVCodecContex
     /* generate lookup-tables for dither and index before looping */
     i = 0;
     for (a=0; a < 256; a++) {
-        if(i < 4 && a == c->mc_luma_vals[i+1]) {
+        if(i < c->mc_pal_size -1 && a == c->mc_luma_vals[i+1]) {
             distance = c->mc_luma_vals[i+1] - c->mc_luma_vals[i];
             for(b = 0; b <= distance; b++) {
                   dither[c->mc_luma_vals[i]+b] = b * (DITHERSTEPS - 1) / distance;
             }
             i++;
         }
-        if(i >=4 ) dither[a] = 0;
+        if(i >= c->mc_pal_size - 1) dither[a] = 0;
         index1[a] = i;
-        index2[a] = FFMIN(i+1, 4);
+        index2[a] = FFMIN(i+1, c->mc_pal_size - 1);
     }
     /* and render charset */
     for (charpos = 0; charpos < CHARSET_CHARS; charpos++) {
@@ -183,16 +183,17 @@ static av_cold int a64multi_init_encoder
 
     av_log(avctx, AV_LOG_INFO, "charset lifetime set to %d frame(s)\n", c->mc_lifetime);
 
+    c->mc_frame_counter = 0;
+    c->mc_use_5col      = avctx->codec->id == CODEC_ID_A64_MULTI5;
+    c->mc_pal_size      = 4 + c->mc_use_5col;
+
     /* precalc luma values for later use */
-    for (a = 0; a < 5; a++) {
+    for (a = 0; a < c->mc_pal_size; a++) {
         c->mc_luma_vals[a]=a64_palette[mc_colors[a]][0] * 0.30 +
                            a64_palette[mc_colors[a]][1] * 0.59 +
                            a64_palette[mc_colors[a]][2] * 0.11;
     }
 
-    c->mc_frame_counter = 0;
-    c->mc_use_5col      = avctx->codec->id == CODEC_ID_A64_MULTI5;
-
     if(!(c->mc_meta_charset  = av_malloc (32000 * c->mc_lifetime * sizeof(int))) ||
        !(c->mc_best_cb       = av_malloc (CHARSET_CHARS * 32 * sizeof(int)))     ||
        !(c->mc_charmap       = av_mallocz(1000 * c->mc_lifetime * sizeof(int)))  ||



More information about the ffmpeg-cvslog mailing list