Browse code

scale: fix slice rendering with conversion between pal/non-pal.

We can't use whether the input format is paletted to decide that
the output format has a palette in data[1], too, that makes no sense.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>

Reimar Döffinger authored on 2012/04/08 21:59:53
Showing 1 changed files
... ...
@@ -72,6 +72,7 @@ typedef struct {
72 72
     int hsub, vsub;             ///< chroma subsampling
73 73
     int slice_y;                ///< top of current output slice
74 74
     int input_is_pal;           ///< set to 1 if the input format is paletted
75
+    int output_is_pal;          ///< set to 1 if the output format is paletted
75 76
     int interlaced;
76 77
 
77 78
     char w_expr[256];           ///< width  expression string
... ...
@@ -211,6 +212,8 @@ static int config_props(AVFilterLink *outlink)
211 211
     scale->input_is_pal = av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL ||
212 212
                           av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PSEUDOPAL;
213 213
     if (outfmt == PIX_FMT_PAL8) outfmt = PIX_FMT_BGR8;
214
+    scale->output_is_pal = av_pix_fmt_descriptors[outfmt].flags & PIX_FMT_PAL ||
215
+                           av_pix_fmt_descriptors[outfmt].flags & PIX_FMT_PSEUDOPAL;
214 216
 
215 217
     if (scale->sws)
216 218
         sws_freeContext(scale->sws);
... ...
@@ -303,10 +306,10 @@ static int scale_slice(AVFilterLink *link, struct SwsContext *sws, int y, int h,
303 303
          in[i] = cur_pic->data[i] + ((y>>vsub)+field) * cur_pic->linesize[i];
304 304
         out[i] = out_buf->data[i] +            field  * out_buf->linesize[i];
305 305
     }
306
-    if(scale->input_is_pal){
306
+    if(scale->input_is_pal)
307 307
          in[1] = cur_pic->data[1];
308
+    if(scale->output_is_pal)
308 309
         out[1] = out_buf->data[1];
309
-    }
310 310
 
311 311
     return sws_scale(sws, in, in_stride, y/mul, h,
312 312
                          out,out_stride);