vf_swapuv.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of MPlayer.
  5. *
  6. * MPlayer is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * MPlayer 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
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with MPlayer; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <inttypes.h>
  24. #include <assert.h>
  25. #include "mp_msg.h"
  26. #include "img_format.h"
  27. #include "mp_image.h"
  28. #include "vf.h"
  29. //===========================================================================//
  30. static void get_image(struct vf_instance *vf, mp_image_t *mpi){
  31. mp_image_t *dmpi= vf_get_image(vf->next, mpi->imgfmt,
  32. mpi->type, mpi->flags, mpi->w, mpi->h);
  33. mpi->planes[0]=dmpi->planes[0];
  34. mpi->planes[1]=dmpi->planes[2];
  35. mpi->planes[2]=dmpi->planes[1];
  36. mpi->stride[0]=dmpi->stride[0];
  37. mpi->stride[1]=dmpi->stride[2];
  38. mpi->stride[2]=dmpi->stride[1];
  39. mpi->width=dmpi->width;
  40. mpi->flags|=MP_IMGFLAG_DIRECT;
  41. mpi->priv=(void*)dmpi;
  42. }
  43. static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
  44. mp_image_t *dmpi;
  45. if(mpi->flags&MP_IMGFLAG_DIRECT){
  46. dmpi=(mp_image_t*)mpi->priv;
  47. } else {
  48. dmpi=vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h);
  49. assert(mpi->flags&MP_IMGFLAG_PLANAR);
  50. dmpi->planes[0]=mpi->planes[0];
  51. dmpi->planes[1]=mpi->planes[2];
  52. dmpi->planes[2]=mpi->planes[1];
  53. dmpi->stride[0]=mpi->stride[0];
  54. dmpi->stride[1]=mpi->stride[2];
  55. dmpi->stride[2]=mpi->stride[1];
  56. dmpi->width=mpi->width;
  57. }
  58. vf_clone_mpi_attributes(dmpi, mpi);
  59. return vf_next_put_image(vf,dmpi, pts);
  60. }
  61. //===========================================================================//
  62. static int query_format(struct vf_instance *vf, unsigned int fmt){
  63. switch(fmt)
  64. {
  65. case IMGFMT_YV12:
  66. case IMGFMT_I420:
  67. case IMGFMT_IYUV:
  68. case IMGFMT_YVU9:
  69. case IMGFMT_444P:
  70. case IMGFMT_422P:
  71. case IMGFMT_411P:
  72. return vf_next_query_format(vf, fmt);
  73. }
  74. return 0;
  75. }
  76. static int vf_open(vf_instance_t *vf, char *args){
  77. vf->put_image=put_image;
  78. vf->get_image=get_image;
  79. vf->query_format=query_format;
  80. return 1;
  81. }
  82. const vf_info_t vf_info_swapuv = {
  83. "UV swapper",
  84. "swapuv",
  85. "Michael Niedermayer",
  86. "",
  87. vf_open,
  88. NULL
  89. };
  90. //===========================================================================//