vidinput.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*Daala video codec
  2. Copyright (c) 2002-2013 Daala project contributors. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. - Redistributions of source code must retain the above copyright notice, this
  6. list of conditions and the following disclaimer.
  7. - Redistributions in binary form must reproduce the above copyright notice,
  8. this list of conditions and the following disclaimer in the documentation
  9. and/or other materials provided with the distribution.
  10. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
  11. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  13. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  14. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  15. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  16. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  17. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  18. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  19. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
  20. #ifdef HAVE_CONFIG_H
  21. #include "config.h"
  22. #endif
  23. #include "vidinput.h"
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include <ogg/os_types.h>
  27. extern video_input_vtbl Y4M_INPUT_VTBL;
  28. int video_input_open(video_input *_vid,FILE *_fin){
  29. void *ctx;
  30. if((ctx = Y4M_INPUT_VTBL.open(_fin))!=NULL){
  31. _vid->vtbl=&Y4M_INPUT_VTBL;
  32. _vid->ctx=ctx;
  33. _vid->fin=_fin;
  34. return 0;
  35. }
  36. else fprintf(stderr,"Unknown file type.\n");
  37. return -1;
  38. }
  39. void video_input_get_info(video_input *_vid,video_input_info *_info){
  40. (*_vid->vtbl->get_info)(_vid->ctx,_info);
  41. }
  42. int video_input_fetch_frame(video_input *_vid,
  43. video_input_ycbcr _ycbcr,char _tag[5]){
  44. return (*_vid->vtbl->fetch_frame)(_vid->ctx,_vid->fin,_ycbcr,_tag);
  45. }
  46. void video_input_close(video_input *_vid){
  47. (*_vid->vtbl->close)(_vid->ctx);
  48. _ogg_free(_vid->ctx);
  49. fclose(_vid->fin);
  50. }