videoutil.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef VIDEOUTIL_H
  2. #define VIDEOUTIL_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define VIDEO_FORMAT_I420 0x01
  7. #define VIDEO_FORMAT_RGB24 0x02
  8. #define IP_UDP_HEADER_SIZE (20 + 8)
  9. #define RTP_HEADER_SIZE 12
  10. typedef struct video_frame {
  11. unsigned char *data[4];
  12. int linesize[4];
  13. int width;
  14. int height;
  15. int format; /* VIDEO_FORMAT_xxx */
  16. }video_frame;
  17. typedef union video_timestamp {
  18. struct {
  19. unsigned int lo;
  20. int hi;
  21. }u32;
  22. __int64 u64;
  23. }video_timestamp;
  24. typedef struct __video_frame_scale_t video_frame_scale_t;
  25. /**
  26. * alloc memory for a video frame, return 0 on success
  27. */
  28. int video_frame_alloc(int width, int height, int format, video_frame *frame);
  29. /**
  30. * free memory of a video frame
  31. */
  32. void video_frame_free(video_frame *frame);
  33. /**
  34. * copy src frame to dst frame, return 0 on success
  35. */
  36. int video_frame_copy(video_frame *dst, video_frame *src);
  37. int video_get_timestamp(video_timestamp *p_ts);
  38. int video_get_timestamp_freq(video_timestamp *p_freq);
  39. /**
  40. * save videoframe as bmp file, only accept rgb24 frame
  41. * @param bmpfile save file path
  42. * @param frame the rgb24 format frame
  43. * @return 0 on success
  44. */
  45. int video_frame_save_bmpfile(const char*bmpfile, video_frame *frame);
  46. video_frame *video_frame_new(int width, int height, int format);
  47. void video_frame_delete(video_frame *frame);
  48. int video_frame_fill_black(video_frame *frame);
  49. video_frame_scale_t *video_frame_scale_create(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
  50. void video_frame_scale_destroy(video_frame_scale_t *);
  51. int video_frame_scale_process(video_frame_scale_t *scale, unsigned char **src_data, int *src_linesize, int y, int h, unsigned char **dst_data, int *dst_linesize);
  52. #ifdef __cplusplus
  53. }//extern "C" {
  54. #endif
  55. #endif // VIDEOUTIL_H