Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebM project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | #ifndef WEBMENC_H_ |
| 11 | #define WEBMENC_H_ |
| 12 | |
| 13 | #include <stdio.h> |
| 14 | #include <stdlib.h> |
| 15 | |
| 16 | #if defined(_MSC_VER) |
| 17 | /* MSVS doesn't define off_t */ |
| 18 | typedef __int64 off_t; |
| 19 | #else |
| 20 | #include <stdint.h> |
| 21 | #endif |
| 22 | |
| 23 | #include "tools_common.h" |
| 24 | #include "vpx/vpx_encoder.h" |
| 25 | |
| 26 | typedef off_t EbmlLoc; |
| 27 | |
| 28 | struct cue_entry { |
| 29 | unsigned int time; |
| 30 | uint64_t loc; |
| 31 | }; |
| 32 | |
| 33 | struct EbmlGlobal { |
| 34 | int debug; |
| 35 | |
| 36 | FILE *stream; |
| 37 | int64_t last_pts_ms; |
| 38 | vpx_rational_t framerate; |
| 39 | |
| 40 | /* These pointers are to the start of an element */ |
| 41 | off_t position_reference; |
| 42 | off_t seek_info_pos; |
| 43 | off_t segment_info_pos; |
| 44 | off_t track_pos; |
| 45 | off_t cue_pos; |
| 46 | off_t cluster_pos; |
| 47 | |
| 48 | /* This pointer is to a specific element to be serialized */ |
| 49 | off_t track_id_pos; |
| 50 | |
| 51 | /* These pointers are to the size field of the element */ |
| 52 | EbmlLoc startSegment; |
| 53 | EbmlLoc startCluster; |
| 54 | |
| 55 | uint32_t cluster_timecode; |
| 56 | int cluster_open; |
| 57 | |
| 58 | struct cue_entry *cue_list; |
| 59 | unsigned int cues; |
| 60 | }; |
| 61 | |
| 62 | /* Stereo 3D packed frame format */ |
| 63 | typedef enum stereo_format { |
Tom Finegan | 1f0c2e7 | 2013-11-06 10:02:31 -0800 | [diff] [blame] | 64 | STEREO_FORMAT_MONO = 0, |
Tom Finegan | 03848f5 | 2013-11-05 10:02:18 -0800 | [diff] [blame] | 65 | STEREO_FORMAT_LEFT_RIGHT = 1, |
| 66 | STEREO_FORMAT_BOTTOM_TOP = 2, |
| 67 | STEREO_FORMAT_TOP_BOTTOM = 3, |
| 68 | STEREO_FORMAT_RIGHT_LEFT = 11 |
| 69 | } stereo_format_t; |
| 70 | |
| 71 | void write_webm_seek_element(struct EbmlGlobal *ebml, |
| 72 | unsigned int id, |
| 73 | off_t pos); |
| 74 | |
| 75 | void write_webm_file_header(struct EbmlGlobal *glob, |
| 76 | const vpx_codec_enc_cfg_t *cfg, |
| 77 | const struct vpx_rational *fps, |
| 78 | stereo_format_t stereo_fmt, |
| 79 | unsigned int fourcc); |
| 80 | |
| 81 | void write_webm_block(struct EbmlGlobal *glob, |
| 82 | const vpx_codec_enc_cfg_t *cfg, |
| 83 | const vpx_codec_cx_pkt_t *pkt); |
| 84 | |
| 85 | void write_webm_file_footer(struct EbmlGlobal *glob, int hash); |
| 86 | |
| 87 | #endif // WEBMENC_H_ |