Modify param to avoid build warning
[platform/core/api/mediacodec.git] / include / media_codec_bitstream.h
1 /*
2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __TIZEN_MEDIA_CODEC_BITSTREAM_H__
18 #define __TIZEN_MEDIA_CODEC_BITSTREAM_H__
19
20 #include <tizen.h>
21 #include <media_codec_port.h>
22
23 typedef struct _mc_bitstream_t mc_bitstream_t;
24
25 typedef enum
26 {
27     NAL_SLICE_NO_PARTITIONING = 1,
28     NAL_SLICE_PART_A,
29     NAL_SLICE_PART_B,
30     NAL_SLICE_PART_C,
31     NAL_SLICE_IDR,
32     NAL_SEI,
33     NAL_SEQUENCE_PARAMETER_SET,
34     NAL_PICTURE_PARAMETER_SET,
35     NAL_PICTURE_DELIMITER,
36     NAL_END_OF_SEQUENCE,
37     NAL_END_OF_STREAM,
38     NAL_FILLER_DATA,
39     NAL_PREFIX_SVC = 14
40 } mc_nal_unit_type_e;
41
42 enum
43 {
44     MC_EXIST_SPS    = 1 << 0,
45     MC_EXIST_PPS    = 1 << 1,
46     MC_EXIST_IDR    = 1 << 2,
47     MC_EXIST_SLICE  = 1 << 3,
48
49     MC_VALID_HEADER = ( MC_EXIST_SPS | MC_EXIST_PPS ),
50     MC_VALID_FIRST_SLICE = ( MC_EXIST_SPS | MC_EXIST_PPS | MC_EXIST_IDR )
51 };
52
53 #define CHECK_VALID_PACKET(state, expected_state) \
54   ((state & (expected_state)) == (expected_state))
55
56 static const unsigned int mask[33] =
57 {
58     0x00000000, 0x00000001, 0x00000003, 0x00000007,
59     0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
60     0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
61     0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
62     0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
63     0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
64     0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
65     0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
66     0xffffffff
67 };
68
69 struct _mc_bitstream_t
70 {
71     unsigned char *data;
72     unsigned int numBytes;
73     unsigned int bytePos;
74     unsigned int buffer;
75     unsigned int dataBitPos;
76     unsigned int bitcnt;
77 };
78
79
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83
84 #define MC_READ16B(x) ((((const unsigned char*)(x))[0] << 8) | ((const unsigned char*)(x))[1])
85
86 #define MC_READ32B(x) ((((const unsigned char*)(x))[0] << 24) | \
87                       (((const unsigned char*)(x))[1] << 16) | \
88                       (((const unsigned char*)(x))[2] <<  8) | \
89                       ((const unsigned char*)(x))[3])
90
91 void mc_init_bits(mc_bitstream_t *stream, unsigned char *data, int size);
92 short mc_show_bits(mc_bitstream_t *stream, unsigned char nbits, unsigned int *pulOutData);
93 short mc_read_bits( mc_bitstream_t *stream, unsigned char nbits, unsigned int *pulOutData );
94 short mc_byte_align( mc_bitstream_t *stream );
95
96 bool _mc_is_voss(unsigned char *buf, int size, int *codec_size);
97 bool _mc_is_ivop(unsigned char *p, int size, int pos);
98 bool _mc_is_vop(unsigned char *p, int size, int pos);
99
100
101 int __mc_decode_sps(mc_bitstream_t *pstream, int *width, int *height);
102 unsigned int __mc_bytestream_to_nal( unsigned char* data, int size );
103 int _mc_check_h264_bytestream ( unsigned char *nal, int byte_length, bool port, bool *codec_config, bool *sync_flag, bool *slice);
104 int _mc_check_valid_h263_frame(unsigned char *p, int size);
105 bool _mc_check_h263_out_bytestream(unsigned char *p, int buf_length, bool* need_sync_flag);
106 int _mc_check_mpeg4_out_bytestream(unsigned char *buf, int buf_length, bool* need_codec_data, bool *need_sync_flag);
107
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif /* __TIZEN_MEDIA_CODEC_BITSTREAM_H__ */