Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / webmenc.h
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 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 typedef off_t EbmlLoc;
31
32 struct cue_entry {
33   unsigned int time;
34   uint64_t loc;
35 };
36
37 struct EbmlGlobal {
38   int debug;
39
40   FILE *stream;
41   int64_t last_pts_ms;
42   vpx_rational_t framerate;
43
44   /* These pointers are to the start of an element */
45   off_t position_reference;
46   off_t seek_info_pos;
47   off_t segment_info_pos;
48   off_t track_pos;
49   off_t cue_pos;
50   off_t cluster_pos;
51
52   /* This pointer is to a specific element to be serialized */
53   off_t track_id_pos;
54
55   /* These pointers are to the size field of the element */
56   EbmlLoc startSegment;
57   EbmlLoc startCluster;
58
59   uint32_t cluster_timecode;
60   int cluster_open;
61
62   struct cue_entry *cue_list;
63   unsigned int cues;
64 };
65
66 /* Stereo 3D packed frame format */
67 typedef enum stereo_format {
68   STEREO_FORMAT_MONO = 0,
69   STEREO_FORMAT_LEFT_RIGHT = 1,
70   STEREO_FORMAT_BOTTOM_TOP = 2,
71   STEREO_FORMAT_TOP_BOTTOM = 3,
72   STEREO_FORMAT_RIGHT_LEFT = 11
73 } stereo_format_t;
74
75 void write_webm_seek_element(struct EbmlGlobal *ebml,
76                              unsigned int id,
77                              off_t pos);
78
79 void write_webm_file_header(struct EbmlGlobal *glob,
80                             const vpx_codec_enc_cfg_t *cfg,
81                             const struct vpx_rational *fps,
82                             stereo_format_t stereo_fmt,
83                             unsigned int fourcc);
84
85 void write_webm_block(struct EbmlGlobal *glob,
86                       const vpx_codec_enc_cfg_t *cfg,
87                       const vpx_codec_cx_pkt_t *pkt);
88
89 void write_webm_file_footer(struct EbmlGlobal *glob, int hash);
90
91 #ifdef __cplusplus
92 }  // extern "C"
93 #endif
94
95 #endif  // WEBMENC_H_