vf_field.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 "mp_image.h"
  24. #include "vf.h"
  25. struct vf_priv_s {
  26. int field;
  27. };
  28. //===========================================================================//
  29. static int config(struct vf_instance *vf,
  30. int width, int height, int d_width, int d_height,
  31. unsigned int flags, unsigned int outfmt){
  32. return vf_next_config(vf,width,height/2,d_width,d_height,flags,outfmt);
  33. }
  34. static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
  35. vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
  36. MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
  37. mpi->width, mpi->height/2);
  38. // set up mpi as a double-stride image of dmpi:
  39. vf->dmpi->planes[0]=mpi->planes[0]+mpi->stride[0]*vf->priv->field;
  40. vf->dmpi->stride[0]=2*mpi->stride[0];
  41. if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
  42. vf->dmpi->planes[1]=mpi->planes[1]+
  43. mpi->stride[1]*vf->priv->field;
  44. vf->dmpi->stride[1]=2*mpi->stride[1];
  45. vf->dmpi->planes[2]=mpi->planes[2]+
  46. mpi->stride[2]*vf->priv->field;
  47. vf->dmpi->stride[2]=2*mpi->stride[2];
  48. } else
  49. vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
  50. return vf_next_put_image(vf,vf->dmpi, pts);
  51. }
  52. //===========================================================================//
  53. static void uninit(struct vf_instance *vf)
  54. {
  55. free(vf->priv);
  56. }
  57. static int vf_open(vf_instance_t *vf, char *args){
  58. vf->config=config;
  59. vf->put_image=put_image;
  60. vf->uninit=uninit;
  61. vf->default_reqs=VFCAP_ACCEPT_STRIDE;
  62. vf->priv=calloc(1, sizeof(struct vf_priv_s));
  63. if (args) sscanf(args, "%d", &vf->priv->field);
  64. vf->priv->field &= 1;
  65. return 1;
  66. }
  67. const vf_info_t vf_info_field = {
  68. "extract single field",
  69. "field",
  70. "Rich Felker",
  71. "",
  72. vf_open,
  73. NULL
  74. };
  75. //===========================================================================//