Browse code

Move internal function ff_set_systematic_pal() to libavcore, and rename it ff_set_systematic_pal2().

Originally committed as revision 25712 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini authored on 2010/11/10 07:22:36
Showing 8 changed files
... ...
@@ -33,7 +33,7 @@
33 33
 
34 34
 #define LIBAVCODEC_VERSION_MAJOR 52
35 35
 #define LIBAVCODEC_VERSION_MINOR 94
36
-#define LIBAVCODEC_VERSION_MICRO  3
36
+#define LIBAVCODEC_VERSION_MICRO  4
37 37
 
38 38
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
39 39
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -37,6 +37,7 @@
37 37
 #include "libavutil/colorspace.h"
38 38
 #include "libavutil/pixdesc.h"
39 39
 #include "libavcore/imgutils.h"
40
+#include "libavcore/internal.h"
40 41
 
41 42
 #if HAVE_MMX && HAVE_YASM
42 43
 #include "x86/dsputil_mmx.h"
... ...
@@ -456,46 +457,11 @@ int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt)
456 456
     return av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL;
457 457
 }
458 458
 
459
+#if LIBAVCODEC_VERSION_MAJOR < 53
459 460
 int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt){
460
-    int i;
461
-
462
-    for(i=0; i<256; i++){
463
-        int r,g,b;
464
-
465
-        switch(pix_fmt) {
466
-        case PIX_FMT_RGB8:
467
-            r= (i>>5    )*36;
468
-            g= ((i>>2)&7)*36;
469
-            b= (i&3     )*85;
470
-            break;
471
-        case PIX_FMT_BGR8:
472
-            b= (i>>6    )*85;
473
-            g= ((i>>3)&7)*36;
474
-            r= (i&7     )*36;
475
-            break;
476
-        case PIX_FMT_RGB4_BYTE:
477
-            r= (i>>3    )*255;
478
-            g= ((i>>1)&3)*85;
479
-            b= (i&1     )*255;
480
-            break;
481
-        case PIX_FMT_BGR4_BYTE:
482
-            b= (i>>3    )*255;
483
-            g= ((i>>1)&3)*85;
484
-            r= (i&1     )*255;
485
-            break;
486
-        case PIX_FMT_GRAY8:
487
-            r=b=g= i;
488
-            break;
489
-        default:
490
-            return -1;
491
-        }
492
-        pal[i] =  b + (g<<8) + (r<<16);
493
-    }
494
-
495
-    return 0;
461
+    return ff_set_systematic_pal2(pal, pix_fmt);
496 462
 }
497 463
 
498
-#if LIBAVCODEC_VERSION_MAJOR < 53
499 464
 int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width)
500 465
 {
501 466
     return av_image_fill_linesizes(picture->linesize, pix_fmt, width);
... ...
@@ -909,7 +875,7 @@ int avpicture_alloc(AVPicture *picture,
909 909
         goto fail;
910 910
     avpicture_fill(picture, ptr, pix_fmt, width, height);
911 911
     if(picture->data[1] && !picture->data[2])
912
-        ff_set_systematic_pal((uint32_t*)picture->data[1], pix_fmt);
912
+        ff_set_systematic_pal2((uint32_t*)picture->data[1], pix_fmt);
913 913
 
914 914
     return 0;
915 915
  fail:
... ...
@@ -36,8 +36,9 @@ int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt,
36 36
 
37 37
 attribute_deprecated
38 38
 int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane);
39
-#endif
40 39
 
40
+attribute_deprecated
41 41
 int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt);
42
+#endif
42 43
 
43 44
 #endif /* AVCODEC_IMGCONVERT_H */
... ...
@@ -29,6 +29,7 @@
29 29
 #include "raw.h"
30 30
 #include "libavutil/intreadwrite.h"
31 31
 #include "libavcore/imgutils.h"
32
+#include "libavcore/internal.h"
32 33
 
33 34
 typedef struct RawVideoContext {
34 35
     uint32_t palette[AVPALETTE_COUNT];
... ...
@@ -83,7 +84,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
83 83
     else if (avctx->pix_fmt == PIX_FMT_NONE && avctx->bits_per_coded_sample)
84 84
         avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample);
85 85
 
86
-    ff_set_systematic_pal(context->palette, avctx->pix_fmt);
86
+    ff_set_systematic_pal2(context->palette, avctx->pix_fmt);
87 87
     context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
88 88
     if((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
89 89
        avctx->pix_fmt==PIX_FMT_PAL8 &&
... ...
@@ -30,6 +30,7 @@
30 30
 #include "libavutil/crc.h"
31 31
 #include "libavutil/pixdesc.h"
32 32
 #include "libavcore/imgutils.h"
33
+#include "libavcore/internal.h"
33 34
 #include "libavcore/samplefmt.h"
34 35
 #include "avcodec.h"
35 36
 #include "dsputil.h"
... ...
@@ -323,7 +324,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
323 323
                 buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]);
324 324
         }
325 325
         if(size[1] && !size[2])
326
-            ff_set_systematic_pal((uint32_t*)buf->data[1], s->pix_fmt);
326
+            ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt);
327 327
         buf->width  = s->width;
328 328
         buf->height = s->height;
329 329
         buf->pix_fmt= s->pix_fmt;
... ...
@@ -28,7 +28,7 @@
28 28
 
29 29
 #define LIBAVCORE_VERSION_MAJOR  0
30 30
 #define LIBAVCORE_VERSION_MINOR 12
31
-#define LIBAVCORE_VERSION_MICRO  0
31
+#define LIBAVCORE_VERSION_MICRO  1
32 32
 
33 33
 #define LIBAVCORE_VERSION_INT   AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \
34 34
                                                LIBAVCORE_VERSION_MINOR, \
... ...
@@ -22,6 +22,7 @@
22 22
  */
23 23
 
24 24
 #include "imgutils.h"
25
+#include "internal.h"
25 26
 #include "libavutil/pixdesc.h"
26 27
 
27 28
 void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
... ...
@@ -120,6 +121,46 @@ int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int heigh
120 120
     return total_size;
121 121
 }
122 122
 
123
+int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt)
124
+{
125
+    int i;
126
+
127
+    for (i = 0; i < 256; i++) {
128
+        int r, g, b;
129
+
130
+        switch (pix_fmt) {
131
+        case PIX_FMT_RGB8:
132
+            r = (i>>5    )*36;
133
+            g = ((i>>2)&7)*36;
134
+            b = (i&3     )*85;
135
+            break;
136
+        case PIX_FMT_BGR8:
137
+            b = (i>>6    )*85;
138
+            g = ((i>>3)&7)*36;
139
+            r = (i&7     )*36;
140
+            break;
141
+        case PIX_FMT_RGB4_BYTE:
142
+            r = (i>>3    )*255;
143
+            g = ((i>>1)&3)*85;
144
+            b = (i&1     )*255;
145
+            break;
146
+        case PIX_FMT_BGR4_BYTE:
147
+            b = (i>>3    )*255;
148
+            g = ((i>>1)&3)*85;
149
+            r = (i&1     )*255;
150
+            break;
151
+        case PIX_FMT_GRAY8:
152
+            r = b = g = i;
153
+            break;
154
+        default:
155
+            return AVERROR(EINVAL);
156
+        }
157
+        pal[i] = b + (g<<8) + (r<<16);
158
+    }
159
+
160
+    return 0;
161
+}
162
+
123 163
 typedef struct ImgUtils {
124 164
     const AVClass *class;
125 165
     int   log_offset;
126 166
new file mode 100644
... ...
@@ -0,0 +1,31 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#ifndef AVCORE_INTERNAL_H
19
+#define AVCORE_INTERNAL_H
20
+
21
+/**
22
+ * @file
23
+ * internal functions
24
+ */
25
+
26
+#include "avcore.h"
27
+
28
+int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt);
29
+
30
+#endif /* AVCORE_INTERNAL_H */