1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | #ifndef VC_CONTAINERS_UTILS_H |
28 | #define VC_CONTAINERS_UTILS_H |
29 | |
30 | #include "containers/containers.h" |
31 | #include "containers/containers_codecs.h" |
32 | #include "containers/core/containers_waveformat.h" |
33 | |
34 | /***************************************************************************** |
35 | * Type definitions |
36 | *****************************************************************************/ |
37 | |
38 | /** Definition of the Global Unique Identifier type as used by some containers */ |
39 | typedef struct GUID_T |
40 | { |
41 | uint32_t word0; |
42 | uint16_t short0; |
43 | uint16_t short1; |
44 | uint8_t bytes[8]; |
45 | |
46 | } GUID_T; |
47 | |
48 | VC_CONTAINER_ES_FORMAT_T *vc_container_format_create(unsigned int ); |
49 | void vc_container_format_delete(VC_CONTAINER_ES_FORMAT_T *); |
50 | VC_CONTAINER_STATUS_T ( |
51 | VC_CONTAINER_ES_FORMAT_T *format, unsigned int size); |
52 | VC_CONTAINER_STATUS_T vc_container_format_copy( VC_CONTAINER_ES_FORMAT_T *p_out, |
53 | VC_CONTAINER_ES_FORMAT_T *p_in, |
54 | unsigned int ); |
55 | int utf8_from_charset(const char *charset, char *out, unsigned int out_size, |
56 | const void *in, unsigned int in_size); |
57 | const char *vc_container_metadata_id_to_string(VC_CONTAINER_METADATA_KEY_T key); |
58 | |
59 | unsigned int vc_container_es_format_to_waveformatex(VC_CONTAINER_ES_FORMAT_T *format, |
60 | uint8_t *buffer, unsigned int buffer_size); |
61 | unsigned int (VC_CONTAINER_ES_FORMAT_T *format, |
62 | uint8_t *buffer, unsigned int buffer_size); |
63 | VC_CONTAINER_STATUS_T vc_container_waveformatex_to_es_format(uint8_t *p, |
64 | unsigned int buffer_size, unsigned int *, unsigned int *, |
65 | VC_CONTAINER_ES_FORMAT_T *format); |
66 | VC_CONTAINER_STATUS_T (uint8_t *p, |
67 | unsigned int buffer_size, unsigned int *, unsigned int *, |
68 | VC_CONTAINER_ES_FORMAT_T *format); |
69 | |
70 | /** Find the greatest common denominator of 2 numbers. |
71 | * |
72 | * @param a first number |
73 | * @param b second number |
74 | * |
75 | * @return greatest common denominator of a and b |
76 | */ |
77 | int64_t vc_container_maths_gcd(int64_t a, int64_t b); |
78 | |
79 | /** Reduce a rational number to it's simplest form. |
80 | * |
81 | * @param num Pointer to the numerator of the rational number to simplify |
82 | * @param den Pointer to the denominator of the rational number to simplify |
83 | */ |
84 | void vc_container_maths_rational_simplify(uint32_t *num, uint32_t *den); |
85 | |
86 | #endif /* VC_CONTAINERS_UTILS_H */ |
87 | |