[FFmpeg-cvslog] lavfi/hflip: copy palette data in start_frame()

Stefano Sabatini git at videolan.org
Fri May 25 11:10:01 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Sat Apr  7 09:57:07 2012 +0200| [ad12e9e8c054b904d564e1a183b73104bca2e3d5] | committer: Stefano Sabatini

lavfi/hflip: copy palette data in start_frame()

Fix trac ticket #1116.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad12e9e8c054b904d564e1a183b73104bca2e3d5
---

 libavfilter/vf_hflip.c        |   16 ++++++++++++++++
 tests/ref/lavfi/pixfmts_hflip |    2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index af0404c..ba8e100 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -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, },
diff --git a/tests/ref/lavfi/pixfmts_hflip b/tests/ref/lavfi/pixfmts_hflip
index cf73c2c..7787ca4 100644
--- a/tests/ref/lavfi/pixfmts_hflip
+++ b/tests/ref/lavfi/pixfmts_hflip
@@ -15,7 +15,7 @@ bgra                01ca21e7e6a8d1281b4553bde8e8a404
 gray                03efcb4ab52a24c0af0e03cfd26c9377
 gray16be            632535b46edec78a6534ef18d37f2b71
 gray16le            5c24e6f847bf9a41a40760c0d15df161
-pal8                6c1545bb295e9289add1760851a3d9c9
+pal8                0fda4178d2613bb90484770b31e1891d
 rgb24               754f1722fc738590cc407ac65749bfe8
 rgb444be            d18c1c99abe11dd8347ce8cbc9676bb5
 rgb444le            889fff491a853a114b1a8d07fca2c6f2



More information about the ffmpeg-cvslog mailing list