vf_fil.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 interleave;
  27. int height;
  28. int width;
  29. int stridefactor;
  30. };
  31. //===========================================================================//
  32. static int config(struct vf_instance *vf,
  33. int width, int height, int d_width, int d_height,
  34. unsigned int flags, unsigned int outfmt){
  35. int pixel_stride= (width+15)&~15; //FIXME this is ust a guess ... especially for non planar its somewhat bad one
  36. #if 0
  37. if(mpi->flags&MP_IMGFLAG_PLANAR)
  38. pixel_stride= mpi->stride[0];
  39. else
  40. pixel_stride= 8*mpi->stride[0] / mpi->bpp;
  41. #endif
  42. if(vf->priv->interleave){
  43. vf->priv->height= 2*height;
  44. vf->priv->width= width - (pixel_stride/2);
  45. vf->priv->stridefactor=1;
  46. }else{
  47. vf->priv->height= height/2;
  48. vf->priv->width= width + pixel_stride;
  49. vf->priv->stridefactor=4;
  50. }
  51. //printf("hX %d %d %d\n", vf->priv->width,vf->priv->height,vf->priv->stridefactor);
  52. return vf_next_config(vf, vf->priv->width, vf->priv->height,
  53. (d_width*vf->priv->stridefactor)>>1, 2*d_height/vf->priv->stridefactor, flags, outfmt);
  54. }
  55. static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
  56. if(mpi->flags&MP_IMGFLAG_DIRECT){
  57. // we've used DR, so we're ready...
  58. return vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts);
  59. }
  60. vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
  61. MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
  62. vf->priv->width, vf->priv->height);
  63. // set up mpi as a double-stride image of dmpi:
  64. vf->dmpi->planes[0]=mpi->planes[0];
  65. vf->dmpi->stride[0]=(mpi->stride[0]*vf->priv->stridefactor)>>1;
  66. if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
  67. vf->dmpi->planes[1]=mpi->planes[1];
  68. vf->dmpi->stride[1]=(mpi->stride[1]*vf->priv->stridefactor)>>1;
  69. vf->dmpi->planes[2]=mpi->planes[2];
  70. vf->dmpi->stride[2]=(mpi->stride[2]*vf->priv->stridefactor)>>1;
  71. } else
  72. vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
  73. return vf_next_put_image(vf,vf->dmpi, pts);
  74. }
  75. //===========================================================================//
  76. static void uninit(struct vf_instance *vf)
  77. {
  78. free(vf->priv);
  79. }
  80. static int vf_open(vf_instance_t *vf, char *args){
  81. vf->config=config;
  82. vf->put_image=put_image;
  83. vf->uninit=uninit;
  84. vf->default_reqs=VFCAP_ACCEPT_STRIDE;
  85. vf->priv=calloc(1, sizeof(struct vf_priv_s));
  86. vf->priv->interleave= args && (*args == 'i');
  87. return 1;
  88. }
  89. const vf_info_t vf_info_fil = {
  90. "fast (de)interleaver",
  91. "fil",
  92. "Michael Niedermayer",
  93. "",
  94. vf_open,
  95. NULL
  96. };
  97. //===========================================================================//