diff options
author | Dmitry Kovalev <dkovalev@google.com> | 2014-02-05 18:34:46 -0800 |
---|---|---|
committer | Dmitry Kovalev <dkovalev@google.com> | 2014-02-05 20:34:51 -0800 |
commit | 37e6fd3d765e192f24de65c472fb0cef6a3d9a77 (patch) | |
tree | 3a09237d98b4eff48e6a41bef84479ee537a48f0 /ivfdec.c | |
parent | cebda1b65cf821b3dd7bbdd3a93c8e2bfe9b499b (diff) | |
download | libvpx-37e6fd3d765e192f24de65c472fb0cef6a3d9a77.tar libvpx-37e6fd3d765e192f24de65c472fb0cef6a3d9a77.tar.gz libvpx-37e6fd3d765e192f24de65c472fb0cef6a3d9a77.tar.bz2 libvpx-37e6fd3d765e192f24de65c472fb0cef6a3d9a77.zip |
Adding video reader/writer APIs.
Right now only IVF format is supported which is enough for example code.
Other formats like y4m, webm, raw yuv will be supported later.
Change-Id: I34c6f20731c1851947587ca5c589d7856b675164
Diffstat (limited to 'ivfdec.c')
-rw-r--r-- | ivfdec.c | 65 |
1 files changed, 0 insertions, 65 deletions
@@ -108,68 +108,3 @@ int ivf_read_frame(FILE *infile, uint8_t **buffer, return 1; } - -struct vpx_video { - FILE *file; - unsigned char *buffer; - size_t buffer_size; - size_t frame_size; - unsigned int fourcc; - int width; - int height; -}; - -vpx_video_t *vpx_video_open_file(FILE *file) { - char raw_hdr[32]; - vpx_video_t *video; - - if (fread(raw_hdr, 1, 32, file) != 32) - return NULL; // Can't read file header; - - if (memcmp(IVF_SIGNATURE, raw_hdr, 4) != 0) - return NULL; // Wrong IVF signature - - if (mem_get_le16(raw_hdr + 4) != 0) - return NULL; // Wrong IVF version - - video = (vpx_video_t *)malloc(sizeof(*video)); - video->file = file; - video->buffer = NULL; - video->buffer_size = 0; - video->frame_size = 0; - video->fourcc = mem_get_le32(raw_hdr + 8); - video->width = mem_get_le16(raw_hdr + 12); - video->height = mem_get_le16(raw_hdr + 14); - return video; -} - -void vpx_video_close(vpx_video_t *video) { - if (video) { - free(video->buffer); - free(video); - } -} - -int vpx_video_get_width(vpx_video_t *video) { - return video->width; -} - -int vpx_video_get_height(vpx_video_t *video) { - return video->height; -} - -unsigned int vpx_video_get_fourcc(vpx_video_t *video) { - return video->fourcc; -} - -int vpx_video_read_frame(vpx_video_t *video) { - return !ivf_read_frame(video->file, &video->buffer, &video->frame_size, - &video->buffer_size); -} - -const unsigned char *vpx_video_get_frame(vpx_video_t *video, size_t *size) { - if (size) - *size = video->frame_size; - - return video->buffer; -} |