[SCM] libav/experimental: Introduce palette with dynamic size.

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 17:16:59 UTC 2013


The following commit has been merged in the experimental branch:
commit a4d269030976e04d9db0ae9e9c0ed21865048936
Author: Tobias Bindhammer <tobias.bindhammer at uni-ulm.de>
Date:   Tue Oct 5 12:14:14 2010 +0000

    Introduce palette with dynamic size.
    
    Originally committed as revision 25344 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/a64enc.h b/libavcodec/a64enc.h
index caa4891..fb559ba 100644
--- a/libavcodec/a64enc.h
+++ b/libavcodec/a64enc.h
@@ -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 */
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index 5e127e1..6b3d797 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -86,16 +86,16 @@ static void render_charset(AVCodecContext *avctx, uint8_t *charset,
     /* 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(AVCodecContext *avctx)
 
     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)))  ||

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list