diff options
author | Arun Kumar K <arun.kk@samsung.com> | 2013-08-26 14:28:28 +0530 |
---|---|---|
committer | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2015-07-09 15:55:20 +0200 |
commit | d71d5fc9fd0420d4a738a69c2e68d4e68e31a8fd (patch) | |
tree | 92c798f8510a55b09a8328d3082ba0f4709e37e1 | |
parent | 49a80947f301ed5433010c7675d0ae974c4470b6 (diff) |
v4l2-mfc-example: Initial support for VP8 parser
Added parser code and basic support in application.
Signed-off-by: Arun Kumar K <arun.kk@samsung.com>
Signed-off-by: Mateusz Krawczuk <m.krawczuk@samsung.com>
-rw-r--r-- | v4l2-mfc-example/args.c | 5 | ||||
-rw-r--r-- | v4l2-mfc-example/parser.c | 37 | ||||
-rw-r--r-- | v4l2-mfc-example/parser.h | 4 |
3 files changed, 46 insertions, 0 deletions
diff --git a/v4l2-mfc-example/args.c b/v4l2-mfc-example/args.c index b121590..3d11694 100644 --- a/v4l2-mfc-example/args.c +++ b/v4l2-mfc-example/args.c @@ -139,6 +139,8 @@ int get_codec(char *str) return V4L2_PIX_FMT_MPEG2; } else if (strncasecmp("mpeg1", str, 5) == 0) { return V4L2_PIX_FMT_MPEG1; + } else if (strncasecmp("vp8", str, 5) == 0) { + return V4L2_PIX_FMT_VP8; } return 0; } @@ -270,6 +272,9 @@ int parse_args(struct instance *i, int argc, char **argv) case V4L2_PIX_FMT_MPEG2: i->parser.func = parse_mpeg2_stream; break; + case V4L2_PIX_FMT_VP8: + i->parser.func = parse_vp8_stream; + break; } return 0; diff --git a/v4l2-mfc-example/parser.c b/v4l2-mfc-example/parser.c index 972cdfc..b4e7f89 100644 --- a/v4l2-mfc-example/parser.c +++ b/v4l2-mfc-example/parser.c @@ -516,3 +516,40 @@ int parse_mpeg2_stream( return frame_finished; } +// IVF is a simple file format that transports raw VP8 data. +int parse_vp8_stream ( + struct mfc_parser_context *ctx, + char* in, int in_size, char* out, int out_size, + int *consumed, int *frame_size, char get_head) +{ + unsigned int index = 0; + unsigned int framesize; + + if ((in[index] == 0x44) && (in[index + 1] == 0x4B) && (in[index + 2] == 0x49) && (in[index + 3] == 0x46)) // 444B4946 : DKIF + { + // IVF header + index += 4; //bytes 0-3 signature: 'DKIF' + index += 2; // plus bytes 4-5 version (should be 0) + index += 2; // plus bytes 6-7 length of header in bytes + index += 4; // plus bytes 8-11 codec FourCC (e.g., 'VP80') + index += 2; // plus bytes 12-13 width in pixels + index += 2; // plus bytes 14-15 height in pixels + index += 4; // plus bytes 16-19 frame rate + index += 4; // plus bytes 20-23 time scale + index += 4; // plus bytes 24-27 number of frames in file + index += 4; // plus bytes 28-31 unused + } + framesize = (in[index + 2] << 16) | (in[index + 1] << 8) | in[index]; + index += 4; //bytes 0-3 size of frame in bytes (not including the 12-byte header) + index += 8; // plus bytes 4-11 64-bit presentation timestamp + + memcpy(out, in + index, framesize); + *frame_size = framesize; + if(get_head==1) + *consumed =0; + else + *consumed = index+framesize; + printf(" frame_size = %d, consumed = %d\n",*frame_size, *consumed); + + return 1; +} diff --git a/v4l2-mfc-example/parser.h b/v4l2-mfc-example/parser.h index 6eea179..16851cc 100644 --- a/v4l2-mfc-example/parser.h +++ b/v4l2-mfc-example/parser.h @@ -91,5 +91,9 @@ int parse_mpeg2_stream(struct mfc_parser_context *ctx, char* in, int in_size, char* out, int out_size, int *consumed, int *frame_size, char get_head); +int parse_vp8_stream(struct mfc_parser_context *ctx, + char* in, int in_size, char* out, int out_size, + int *consumed, int *frame_size, char get_head); + #endif /* PARSER_H_ */ |