vf_softskip.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * This file is part of MPlayer.
  3. *
  4. * MPlayer is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * MPlayer 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
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with MPlayer; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include "config.h"
  22. #include "mp_msg.h"
  23. #include "img_format.h"
  24. #include "mp_image.h"
  25. #include "vf.h"
  26. struct vf_priv_s {
  27. int skipflag;
  28. };
  29. static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
  30. {
  31. mp_image_t *dmpi;
  32. if (vf->priv->skipflag)
  33. return vf->priv->skipflag = 0;
  34. dmpi = vf_get_image(vf->next, mpi->imgfmt,
  35. MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height);
  36. vf_clone_mpi_attributes(dmpi, mpi);
  37. dmpi->planes[0] = mpi->planes[0];
  38. dmpi->stride[0] = mpi->stride[0];
  39. if (dmpi->flags&MP_IMGFLAG_PLANAR) {
  40. dmpi->planes[1] = mpi->planes[1];
  41. dmpi->stride[1] = mpi->stride[1];
  42. dmpi->planes[2] = mpi->planes[2];
  43. dmpi->stride[2] = mpi->stride[2];
  44. }
  45. return vf_next_put_image(vf, dmpi, pts);
  46. }
  47. static int control(struct vf_instance *vf, int request, void* data)
  48. {
  49. switch (request) {
  50. case VFCTRL_SKIP_NEXT_FRAME:
  51. vf->priv->skipflag = 1;
  52. return CONTROL_TRUE;
  53. }
  54. return vf_next_control(vf, request, data);
  55. }
  56. #if 0
  57. static int query_format(struct vf_instance *vf, unsigned int fmt)
  58. {
  59. /* FIXME - figure out which other formats work */
  60. switch (fmt) {
  61. case IMGFMT_YV12:
  62. case IMGFMT_IYUV:
  63. case IMGFMT_I420:
  64. return vf_next_query_format(vf, fmt);
  65. }
  66. return 0;
  67. }
  68. #endif
  69. static void uninit(struct vf_instance *vf)
  70. {
  71. free(vf->priv);
  72. }
  73. static int vf_open(vf_instance_t *vf, char *args)
  74. {
  75. vf->put_image = put_image;
  76. vf->control = control;
  77. vf->uninit = uninit;
  78. vf->priv = calloc(1, sizeof(struct vf_priv_s));
  79. return 1;
  80. }
  81. const vf_info_t vf_info_softskip = {
  82. "soft (post-filter) frame skipping for encoding",
  83. "softskip",
  84. "Rich Felker",
  85. "",
  86. vf_open,
  87. NULL
  88. };