vidinput.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*Daala video codec
  2. Copyright (c) 2002-2007 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. #if !defined(_vidinput_H)
  21. # define _vidinput_H (1)
  22. # if !defined(_LARGEFILE_SOURCE)
  23. # define _LARGEFILE_SOURCE
  24. # endif
  25. # if !defined(_LARGEFILE64_SOURCE)
  26. # define _LARGEFILE64_SOURCE
  27. # endif
  28. # if !defined(_FILE_OFFSET_BITS)
  29. # define _FILE_OFFSET_BITS 64
  30. # endif
  31. # include <stdio.h>
  32. # include <stdint.h>
  33. # if defined(__cplusplus)
  34. extern "C" {
  35. # endif
  36. typedef struct video_input video_input;
  37. typedef struct video_input_vtbl video_input_vtbl;
  38. typedef struct video_input_info video_input_info;
  39. struct video_input_plane{
  40. uint32_t width;
  41. uint32_t height;
  42. uint32_t stride;
  43. uint8_t *data;
  44. };
  45. typedef struct video_input_plane video_input_ycbcr[3];
  46. typedef void* (*video_input_open_func)(FILE *_fin);
  47. typedef void (*video_input_get_info_func)(void *_ctx,video_input_info *_ti);
  48. typedef int (*video_input_fetch_frame_func)(void *_ctx,FILE *_fin,
  49. video_input_ycbcr _ycbcr,char _tag[5]);
  50. typedef void (*video_input_close_func)(void *_ctx);
  51. /**Pluggable method table for accessing different formats.*/
  52. struct video_input_vtbl{
  53. video_input_open_func open;
  54. video_input_get_info_func get_info;
  55. video_input_fetch_frame_func fetch_frame;
  56. video_input_close_func close;
  57. };
  58. struct video_input{
  59. const video_input_vtbl *vtbl;
  60. void *ctx;
  61. FILE *fin;
  62. };
  63. int video_input_open(video_input *_vid,FILE *_fin);
  64. void video_input_close(video_input *_vid);
  65. void video_input_get_info(video_input *_vid,video_input_info *_ti);
  66. int video_input_fetch_frame(video_input *_vid,
  67. video_input_ycbcr _ycbcr,char _tag[5]);
  68. typedef enum{
  69. /**Chroma decimation by 2 in both the X and Y directions (4:2:0).
  70. The Cb and Cr chroma planes are half the width and half the
  71. height of the luma plane.*/
  72. PF_420,
  73. /**Currently reserved.*/
  74. PF_RSVD,
  75. /**Chroma decimation by 2 in the X direction (4:2:2).
  76. The Cb and Cr chroma planes are half the width of the luma plane, but full
  77. height.*/
  78. PF_422,
  79. /**No chroma decimation (4:4:4).
  80. The Cb and Cr chroma planes are full width and full height.*/
  81. PF_444,
  82. /**The total number of currently defined pixel formats.*/
  83. PF_NFORMATS
  84. }video_input_pixel_format;
  85. struct video_input_info{
  86. int frame_w;
  87. int frame_h;
  88. int pic_w;
  89. int pic_h;
  90. int pic_x;
  91. int pic_y;
  92. int fps_n;
  93. int fps_d;
  94. int par_n;
  95. int par_d;
  96. video_input_pixel_format pixel_fmt;
  97. char interlace;
  98. char chroma_type[16];
  99. };
  100. # if defined(__cplusplus)
  101. }
  102. # endif
  103. #endif