1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, 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 */
39typedef 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
48VC_CONTAINER_ES_FORMAT_T *vc_container_format_create(unsigned int extradata_size);
49void vc_container_format_delete(VC_CONTAINER_ES_FORMAT_T *);
50VC_CONTAINER_STATUS_T vc_container_format_extradata_alloc(
51 VC_CONTAINER_ES_FORMAT_T *format, unsigned int size);
52VC_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 extra_buffer_size );
55int utf8_from_charset(const char *charset, char *out, unsigned int out_size,
56 const void *in, unsigned int in_size);
57const char *vc_container_metadata_id_to_string(VC_CONTAINER_METADATA_KEY_T key);
58
59unsigned int vc_container_es_format_to_waveformatex(VC_CONTAINER_ES_FORMAT_T *format,
60 uint8_t *buffer, unsigned int buffer_size);
61unsigned int vc_container_es_format_to_bitmapinfoheader(VC_CONTAINER_ES_FORMAT_T *format,
62 uint8_t *buffer, unsigned int buffer_size);
63VC_CONTAINER_STATUS_T vc_container_waveformatex_to_es_format(uint8_t *p,
64 unsigned int buffer_size, unsigned int *extra_offset, unsigned int *extra_size,
65 VC_CONTAINER_ES_FORMAT_T *format);
66VC_CONTAINER_STATUS_T vc_container_bitmapinfoheader_to_es_format(uint8_t *p,
67 unsigned int buffer_size, unsigned int *extra_offset, unsigned int *extra_size,
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 */
77int64_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 */
84void vc_container_maths_rational_simplify(uint32_t *num, uint32_t *den);
85
86#endif /* VC_CONTAINERS_UTILS_H */
87