vsrc_nullsrc.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. /**
  19. * @file
  20. * null video source
  21. */
  22. #include "avfilter.h"
  23. typedef struct {
  24. int w, h;
  25. } NullContext;
  26. static int init(AVFilterContext *ctx, const char *args, void *opaque)
  27. {
  28. NullContext *priv = ctx->priv;
  29. priv->w = 352;
  30. priv->h = 288;
  31. if (args)
  32. sscanf(args, "%d:%d", &priv->w, &priv->h);
  33. if (priv->w <= 0 || priv->h <= 0) {
  34. av_log(ctx, AV_LOG_ERROR, "Non-positive size values are not acceptable.\n");
  35. return -1;
  36. }
  37. return 0;
  38. }
  39. static int config_props(AVFilterLink *outlink)
  40. {
  41. NullContext *priv = outlink->src->priv;
  42. outlink->w = priv->w;
  43. outlink->h = priv->h;
  44. av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d\n", priv->w, priv->h);
  45. return 0;
  46. }
  47. static int request_frame(AVFilterLink *link)
  48. {
  49. return -1;
  50. }
  51. AVFilter avfilter_vsrc_nullsrc = {
  52. .name = "nullsrc",
  53. .description = "Null video source, never return images.",
  54. .init = init,
  55. .priv_size = sizeof(NullContext),
  56. .inputs = (AVFilterPad[]) {{ .name = NULL}},
  57. .outputs = (AVFilterPad[]) {
  58. {
  59. .name = "default",
  60. .type = AVMEDIA_TYPE_VIDEO,
  61. .config_props = config_props,
  62. .request_frame = request_frame,
  63. },
  64. { .name = NULL}
  65. },
  66. };