@@ -52,14 +52,15 @@ var ff_copyout_packet = Module.ff_copyout_packet = function(pkt) {
52
52
flags : AVPacket_flags ( pkt ) ,
53
53
duration : AVPacket_duration ( pkt ) ,
54
54
durationhi : AVPacket_durationhi ( pkt ) ,
55
- side_data : ff_copyout_side_data ( pkt )
55
+ side_data : ff_copyout_side_data (
56
+ AVPacket_side_data ( pkt ) ,
57
+ AVPacket_side_data_elems ( pkt )
58
+ )
56
59
} ;
57
60
} ;
58
61
59
62
// Copy out a packet's side data. Used internally by ff_copyout_packet.
60
- var ff_copyout_side_data = Module . ff_copyout_side_data = function ( pkt ) {
61
- var side_data = AVPacket_side_data ( pkt ) ;
62
- var side_data_elems = AVPacket_side_data_elems ( pkt ) ;
63
+ var ff_copyout_side_data = Module . ff_copyout_side_data = function ( side_data , side_data_elems ) {
63
64
if ( ! side_data ) return null ;
64
65
65
66
var ret = [ ] ;
@@ -114,9 +115,8 @@ var ff_copyin_packet = Module.ff_copyin_packet = function(pktPtr, packet) {
114
115
ff_set_packet ( pktPtr , packet . data ) ;
115
116
116
117
[
117
- "dts" , "dtshi" , "duration" , "durationhi" , "flags" , "side_data" ,
118
- "side_data_elems" , "stream_index" , "pts" , "ptshi" , "time_base_num" ,
119
- "time_base_den"
118
+ "dts" , "dtshi" , "duration" , "durationhi" , "flags" , "stream_index" ,
119
+ "pts" , "ptshi" , "time_base_num" , "time_base_den"
120
120
] . forEach ( function ( key ) {
121
121
if ( key in packet )
122
122
CAccessors [ "AVPacket_" + key + "_s" ] ( pktPtr , packet [ key ] ) ;
@@ -128,6 +128,8 @@ var ff_copyin_packet = Module.ff_copyin_packet = function(pktPtr, packet) {
128
128
129
129
// Copy in a packet's side data. Used internally by ff_copyin_packet.
130
130
var ff_copyin_side_data = Module . ff_copyin_side_data = function ( pktPtr , side_data ) {
131
+ AVPacket_side_data_s ( pktPtr , 0 ) ;
132
+ AVPacket_side_data_elems_s ( pktPtr , 0 ) ;
131
133
side_data . forEach ( function ( elem ) {
132
134
var data = av_packet_new_side_data ( pktPtr , elem . type , elem . data . length ) ;
133
135
if ( data === 0 )
@@ -160,7 +162,11 @@ var ff_copyout_codecpar = Module.ff_copyout_codecpar = function(codecpar) {
160
162
profile : AVCodecParameters_profile ( codecpar ) ,
161
163
sample_rate : AVCodecParameters_sample_rate ( codecpar ) ,
162
164
width : AVCodecParameters_width ( codecpar ) ,
163
- extradata : ff_copyout_codecpar_extradata ( codecpar )
165
+ extradata : ff_copyout_codecpar_extradata ( codecpar ) ,
166
+ coded_side_data : ff_copyout_side_data (
167
+ AVCodecParameters_coded_side_data ( codecpar ) ,
168
+ AVCodecParameters_nb_coded_side_data ( codecpar )
169
+ )
164
170
} ;
165
171
} ;
166
172
@@ -181,16 +187,19 @@ var ff_copyout_codecpar_extradata = Module.ff_copyout_codecpar_extradata = funct
181
187
var ff_copyin_codecpar = Module . ff_copyin_codecpar = function ( codecparPtr , codecpar ) {
182
188
[
183
189
"bit_rate" , "channel_layoutmask" , "channels" , "chroma_location" ,
184
- "codec_id" , "codec_tag" , "codec_type" , "color_primaries" , "color_range" ,
185
- "color_space" , "color_trc" , "format" , "height" , "level" , "profile" ,
186
- "sample_rate" , "width"
190
+ "codec_id" , "codec_tag" , "codec_type" , "coded_side_data" ,
191
+ "color_primaries" , "color_range" , "color_space" , "color_trc" , "format" ,
192
+ "height" , "level" , "nb_coded_side_data" , "profile" , "sample_rate" ,
193
+ "width"
187
194
] . forEach ( function ( key ) {
188
195
if ( key in codecpar )
189
196
CAccessors [ "AVCodecParameters_" + key + "_s" ] ( codecparPtr , codecpar [ key ] ) ;
190
197
} ) ;
191
198
192
199
if ( codecpar . extradata )
193
200
ff_copyin_codecpar_extradata ( codecparPtr , codecpar . extradata ) ;
201
+ if ( codecpar . coded_side_data )
202
+ ff_copyin_codecpar_side_data ( codecparPtr , codecpar . side_data ) ;
194
203
} ;
195
204
196
205
// Copy in codec parameter extradata. Used internally by ff_copyin_codecpar.
@@ -200,3 +209,15 @@ var ff_copyin_codecpar_extradata = Module.ff_copyin_codecpar_extradata = functio
200
209
AVCodecParameters_extradata_s ( codecparPtr , extradataPtr ) ;
201
210
AVCodecParameters_extradata_size_s ( codecparPtr , extradata . length ) ;
202
211
} ;
212
+
213
+ // Copy in a codecpar's side data. Used internally by ff_copyin_codecpar.
214
+ var ff_copyin_codecpar_side_data = Module . ff_copyin_codecpar_side_data = function ( codecpar , side_data ) {
215
+ AVCodecParameters_coded_side_data_s ( codecpar , 0 ) ;
216
+ AVCodecParameters_nb_coded_side_data_s ( codecpar , 0 ) ;
217
+ side_data . forEach ( function ( elem ) {
218
+ var data = ff_codecpar_new_side_data ( codecpar , elem . type , elem . data . length ) ;
219
+ if ( data === 0 )
220
+ throw new Error ( "Failed to allocate side data!" ) ;
221
+ copyin_u8 ( data , elem . data ) ;
222
+ } ) ;
223
+ } ;
0 commit comments