📄 yuv4mpeg.h
字号:
* the structures; don't touch the structure directly. (Ok, so there * is no really convenient C syntax to prevent you from doing this, * but we are all responsible programmers here, so just don't do it!) * ************************************************************************//* initialize a stream_info structure */void y4m_init_stream_info(y4m_stream_info_t *i);/* finalize a stream_info structure */void y4m_fini_stream_info(y4m_stream_info_t *i);/* make one stream_info into a copy of another */void y4m_copy_stream_info(y4m_stream_info_t *dest, y4m_stream_info_t *src);/* access or set stream_info fields */void y4m_si_set_width(y4m_stream_info_t *si, int width);int y4m_si_get_width(y4m_stream_info_t *si);void y4m_si_set_height(y4m_stream_info_t *si, int height);int y4m_si_get_height(y4m_stream_info_t *si);void y4m_si_set_interlace(y4m_stream_info_t *si, int interlace);int y4m_si_get_interlace(y4m_stream_info_t *si);void y4m_si_set_framerate(y4m_stream_info_t *si, y4m_ratio_t framerate);y4m_ratio_t y4m_si_get_framerate(y4m_stream_info_t *si);void y4m_si_set_sampleaspect(y4m_stream_info_t *si, y4m_ratio_t sar);y4m_ratio_t y4m_si_get_sampleaspect(y4m_stream_info_t *si);int y4m_si_get_framelength(y4m_stream_info_t *si);/* access stream_info xtag_list */y4m_xtag_list_t *y4m_si_xtags(y4m_stream_info_t *si);/* initialize a frame_info structure */void y4m_init_frame_info(y4m_frame_info_t *i);/* finalize a frame_info structure */void y4m_fini_frame_info(y4m_frame_info_t *i);/* make one frame_info into a copy of another */void y4m_copy_frame_info(y4m_frame_info_t *dest, y4m_frame_info_t *src);/* access frame_info xtag_list */y4m_xtag_list_t *y4m_fi_xtags(y4m_frame_info_t *fi);/************************************************************************ * blocking read and write functions * * o guaranteed to transfer entire payload (or fail) * o return values: * 0 (zero) complete success * -(# of remaining bytes) error (and errno left set) * +(# of remaining bytes) EOF (for y4m_read only) * ************************************************************************//* read len bytes from fd into buf */ssize_t y4m_read(stream_t *s, char *buf, size_t len);#if 0/* write len bytes from fd into buf */ssize_t y4m_write(int fd, char *buf, size_t len);#endif/************************************************************************ * stream header processing functions * * o return values: * Y4M_OK - success * Y4M_ERR_* - error (see y4m_strerr() for descriptions) * ************************************************************************//* parse a string of stream header tags */int y4m_parse_stream_tags(char *s, y4m_stream_info_t *i);/* read a stream header from file descriptor fd */int y4m_read_stream_header(stream_t *s, y4m_stream_info_t *i);#if 0/* write a stream header to file descriptor fd */int y4m_write_stream_header(int fd, y4m_stream_info_t *i);#endif/************************************************************************ * frame processing functions * * o return values: * Y4M_OK - success * Y4M_ERR_* - error (see y4m_strerr() for descriptions) * ************************************************************************//* read a frame header from file descriptor fd */int y4m_read_frame_header(stream_t *s, y4m_frame_info_t *i);#if 0/* write a frame header to file descriptor fd */int y4m_write_frame_header(int fd, y4m_frame_info_t *i);#endif/* read a complete frame (header + data) o yuv[3] points to three buffers, one each for Y, U, V planes */int y4m_read_frame(stream_t *s, y4m_stream_info_t *si, y4m_frame_info_t *fi, unsigned char *yuv[3]);#if 0/* write a complete frame (header + data) o yuv[3] points to three buffers, one each for Y, U, V planes */int y4m_write_frame(int fd, y4m_stream_info_t *si, y4m_frame_info_t *fi, unsigned char *yuv[3]);#endif#if 0/* read a complete frame (header + data), but de-interleave fields into two separate buffers o upper_field[3] same as yuv[3] above, but for upper field o lower_field[3] same as yuv[3] above, but for lower field*/int y4m_read_fields(int fd, y4m_stream_info_t *si, y4m_frame_info_t *fi, unsigned char *upper_field[3], unsigned char *lower_field[3]);/* write a complete frame (header + data), but interleave fields from two separate buffers o upper_field[3] same as yuv[3] above, but for upper field o lower_field[3] same as yuv[3] above, but for lower field*/int y4m_write_fields(int fd, y4m_stream_info_t *si, y4m_frame_info_t *fi, unsigned char *upper_field[3], unsigned char *lower_field[3]);#endif/************************************************************************ * miscellaneous functions ************************************************************************//* convenient dump of stream header info via mjpeg_log facility * - each logged/printed line is prefixed by 'prefix' */void y4m_log_stream_info(const char *prefix, y4m_stream_info_t *i);/* convert a Y4M_ERR_* error code into mildly explanatory string */const char *y4m_strerr(int err);/* set 'allow_unknown_tag' flag for library... o yn = 0 : unknown header tags will produce a parsing error o yn = 1 : unknown header tags/values will produce a warning, but are otherwise passed along via the xtags list o yn = -1: don't change, just return current setting return value: previous setting of flag*/int y4m_allow_unknown_tags(int yn);#ifdef __cplusplus}#endif/************************************************************************ ************************************************************************ Description of the (new!, forever?) YUV4MPEG2 stream format: STREAM consists of o one '\n' terminated STREAM-HEADER o unlimited number of FRAMEs FRAME consists of o one '\n' terminated FRAME-HEADER o "length" octets of planar YCrCb 4:2:0 image data (if frame is interlaced, then the two fields are interleaved) STREAM-HEADER consists of o string "YUV4MPEG2 " (note the space after the '2') o unlimited number of ' ' separated TAGGED-FIELDs o '\n' line terminator FRAME-HEADER consists of o string "FRAME " (note the space after the 'E') o unlimited number of ' ' separated TAGGED-FIELDs o '\n' line terminator TAGGED-FIELD consists of o single ascii character tag o VALUE (which does not contain whitespace) VALUE consists of o integer (base 10 ascii representation) or o RATIO or o single ascii character or o generic ascii string RATIO consists of o numerator (integer) o ':' (a colon) o denominator (integer) The currently supported tags for the STREAM-HEADER: W - [integer] frame width, pixels, should be > 0 H - [integer] frame height, pixels, should be > 0 I - [char] interlacing: p - progressive (none) t - top-field-first b - bottom-field-first ? - unknown F - [ratio] frame-rate, 0:0 == unknown A - [ratio] sample (pixel) aspect ratio, 0:0 == unknown X - [character string] 'metadata' (unparsed, but passed around) The currently supported tags for the FRAME-HEADER: X - character string 'metadata' (unparsed, but passed around) ************************************************************************ ************************************************************************/#endif /* __YUV4MPEG_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -