lavfi/hflip: copy palette data in start_frame()
authorStefano Sabatini <stefasab@gmail.com>
Sat, 7 Apr 2012 07:57:07 +0000 (09:57 +0200)
committerStefano Sabatini <stefasab@gmail.com>
Fri, 25 May 2012 09:04:24 +0000 (11:04 +0200)
Fix trac ticket #1116.

libavfilter/vf_hflip.c
tests/ref/lavfi/pixfmts_hflip

index af0404c..ba8e100 100644 (file)
@@ -80,6 +80,21 @@ static int config_props(AVFilterLink *inlink)
     return 0;
 }
 
+static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
+{
+    AVFilterLink *outlink = inlink->dst->outputs[0];
+
+    outlink->out_buf =
+        avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
+    avfilter_copy_buffer_ref_props(outlink->out_buf, picref);
+
+    /* copy palette if required */
+    if (av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL)
+        memcpy(inlink->dst->outputs[0]->out_buf->data[1], picref->data[1], AVPALETTE_SIZE);
+
+    avfilter_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
+}
+
 static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     FlipContext *flip = inlink->dst->priv;
@@ -152,6 +167,7 @@ AVFilter avfilter_vf_hflip = {
 
     .inputs    = (const AVFilterPad[]) {{ .name      = "default",
                                     .type            = AVMEDIA_TYPE_VIDEO,
+                                    .start_frame     = start_frame,
                                     .draw_slice      = draw_slice,
                                     .config_props    = config_props,
                                     .min_perms       = AV_PERM_READ, },
index cf73c2c..7787ca4 100644 (file)
@@ -15,7 +15,7 @@ bgra                01ca21e7e6a8d1281b4553bde8e8a404
 gray                03efcb4ab52a24c0af0e03cfd26c9377
 gray16be            632535b46edec78a6534ef18d37f2b71
 gray16le            5c24e6f847bf9a41a40760c0d15df161
-pal8                6c1545bb295e9289add1760851a3d9c9
+pal8                0fda4178d2613bb90484770b31e1891d
 rgb24               754f1722fc738590cc407ac65749bfe8
 rgb444be            d18c1c99abe11dd8347ce8cbc9676bb5
 rgb444le            889fff491a853a114b1a8d07fca2c6f2