1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2012-2014 L-SMASH project
6 * Authors: Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 *****************************************************************************/
21 /* This file is available under an ISC license. */
23 #define VC1_DEFAULT_BUFFER_SIZE (1<<16)
24 #define VC1_START_CODE_PREFIX_LENGTH 3 /* 0x000001 */
25 #define VC1_START_CODE_SUFFIX_LENGTH 1 /* BDU type */
26 #define VC1_START_CODE_LENGTH (VC1_START_CODE_PREFIX_LENGTH + VC1_START_CODE_SUFFIX_LENGTH) /* = 4 */
30 uint8_t hrd_num_leaky_buckets
;
38 uint8_t colordiff_format
; /* currently 4:2:0 only */
41 uint8_t transfer_char
;
43 uint8_t hrd_param_flag
;
45 uint8_t aspect_height
;
46 uint8_t framerate_flag
;
47 uint32_t framerate_numerator
;
48 uint32_t framerate_denominator
;
49 uint16_t max_coded_width
;
50 uint16_t max_coded_height
;
51 uint16_t disp_horiz_size
;
52 uint16_t disp_vert_size
;
53 vc1_hrd_param_t hrd_param
;
54 } vc1_sequence_header_t
;
59 uint8_t closed_entry_point
;
65 uint8_t frame_coding_mode
;
68 uint8_t start_of_sequence
;
69 uint8_t random_accessible
;
74 uint8_t random_accessible
;
77 uint8_t non_bipredictive
;
81 uint8_t *incomplete_data
;
82 uint32_t incomplete_data_length
;
86 typedef struct vc1_info_tag vc1_info_t
;
90 lsmash_multiple_buffers_t
*bank
;
92 } vc1_stream_buffer_t
;
96 lsmash_vc1_specific_parameters_t dvc1_param
;
97 vc1_sequence_header_t sequence
;
98 vc1_entry_point_t entry_point
;
99 vc1_picture_info_t picture
;
100 vc1_access_unit_t access_unit
;
101 uint8_t prev_bdu_type
;
102 uint64_t ebdu_head_pos
;
104 vc1_stream_buffer_t buffer
;
113 uint64_t vc1_find_next_start_code_prefix
117 uint64_t *trailing_zero_bytes
120 int vc1_check_next_start_code_suffix
126 void vc1_cleanup_parser( vc1_info_t
*info
);
127 int vc1_parse_sequence_header( vc1_info_t
*info
, uint8_t *ebdu
, uint64_t ebdu_size
, int probe
);
128 int vc1_parse_entry_point_header( vc1_info_t
*info
, uint8_t *ebdu
, uint64_t ebdu_size
, int probe
);
129 int vc1_parse_advanced_picture( lsmash_bits_t
*bits
,
130 vc1_sequence_header_t
*sequence
, vc1_picture_info_t
*picture
,
131 uint8_t *rbdu_buffer
, uint8_t *ebdu
, uint64_t ebdu_size
);
132 void vc1_update_au_property( vc1_access_unit_t
*access_unit
, vc1_picture_info_t
*picture
);
133 int vc1_find_au_delimit_by_bdu_type( uint8_t bdu_type
, uint8_t prev_bdu_type
);
134 int vc1_supplement_buffer( vc1_stream_buffer_t
*buffer
, vc1_access_unit_t
*access_unit
, uint32_t size
);