vf_split.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2007 Bobby Bingham
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * Video splitter
  23. */
  24. #include "avfilter.h"
  25. static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
  26. {
  27. avfilter_start_frame(inlink->dst->outputs[0],
  28. avfilter_ref_buffer(picref, ~AV_PERM_WRITE));
  29. avfilter_start_frame(inlink->dst->outputs[1],
  30. avfilter_ref_buffer(picref, ~AV_PERM_WRITE));
  31. }
  32. static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
  33. {
  34. avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
  35. avfilter_draw_slice(inlink->dst->outputs[1], y, h, slice_dir);
  36. }
  37. static void end_frame(AVFilterLink *inlink)
  38. {
  39. avfilter_end_frame(inlink->dst->outputs[0]);
  40. avfilter_end_frame(inlink->dst->outputs[1]);
  41. avfilter_unref_buffer(inlink->cur_buf);
  42. }
  43. AVFilter avfilter_vf_split = {
  44. .name = "split",
  45. .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."),
  46. .inputs = (const AVFilterPad[]) {{ .name = "default",
  47. .type = AVMEDIA_TYPE_VIDEO,
  48. .get_video_buffer= avfilter_null_get_video_buffer,
  49. .start_frame = start_frame,
  50. .draw_slice = draw_slice,
  51. .end_frame = end_frame, },
  52. { .name = NULL}},
  53. .outputs = (const AVFilterPad[]) {{ .name = "output1",
  54. .type = AVMEDIA_TYPE_VIDEO, },
  55. { .name = "output2",
  56. .type = AVMEDIA_TYPE_VIDEO, },
  57. { .name = NULL}},
  58. };