comparison asf-enc.c @ 1784:597e5dd62399 libavformat

always use audio spread (instead of "video no spread" for audio ...)
author michael
date Mon, 12 Feb 2007 23:32:55 +0000
parents 82809df9668b
children 255cd2d3c876
comparison
equal deleted inserted replaced
1783:82809df9668b 1784:597e5dd62399
194 { CODEC_ID_NONE, 0 }, 194 { CODEC_ID_NONE, 0 },
195 }; 195 };
196 196
197 static int preroll_time = 3100; 197 static int preroll_time = 3100;
198 198
199 static const uint8_t error_spread_ADPCM_G726[] = { 0x01, 0x90, 0x01, 0x90, 0x01, 0x01, 0x00, 0x00 };
200
201 static void put_guid(ByteIOContext *s, const GUID *g) 199 static void put_guid(ByteIOContext *s, const GUID *g)
202 { 200 {
203 assert(sizeof(*g) == 16); 201 assert(sizeof(*g) == 16);
204 put_buffer(s, g, sizeof(*g)); 202 put_buffer(s, g, sizeof(*g));
205 } 203 }
343 } 341 }
344 342
345 /* stream headers */ 343 /* stream headers */
346 for(n=0;n<s->nb_streams;n++) { 344 for(n=0;n<s->nb_streams;n++) {
347 int64_t es_pos; 345 int64_t es_pos;
348 const uint8_t *er_spr = NULL;
349 int er_spr_len = 0;
350 // ASFStream *stream = &asf->streams[n]; 346 // ASFStream *stream = &asf->streams[n];
351 347
352 enc = s->streams[n]->codec; 348 enc = s->streams[n]->codec;
353 asf->streams[n].num = n + 1; 349 asf->streams[n].num = n + 1;
354 asf->streams[n].seq = 0; 350 asf->streams[n].seq = 0;
355 351
356
357 if (enc->codec_type == CODEC_TYPE_AUDIO) {
358 if (enc->codec_id == CODEC_ID_ADPCM_G726) {
359 er_spr = error_spread_ADPCM_G726;
360 er_spr_len = sizeof(error_spread_ADPCM_G726);
361 }
362 }
363 352
364 switch(enc->codec_type) { 353 switch(enc->codec_type) {
365 case CODEC_TYPE_AUDIO: 354 case CODEC_TYPE_AUDIO:
366 wav_extra_size = 0; 355 wav_extra_size = 0;
367 extra_size = 18 + wav_extra_size; 356 extra_size = 18 + wav_extra_size;
368 extra_size2 = er_spr_len; 357 extra_size2 = 8;
369 break; 358 break;
370 default: 359 default:
371 case CODEC_TYPE_VIDEO: 360 case CODEC_TYPE_VIDEO:
372 wav_extra_size = enc->extradata_size; 361 wav_extra_size = enc->extradata_size;
373 extra_size = 0x33 + wav_extra_size; 362 extra_size = 0x33 + wav_extra_size;
376 } 365 }
377 366
378 hpos = put_header(pb, &stream_header); 367 hpos = put_header(pb, &stream_header);
379 if (enc->codec_type == CODEC_TYPE_AUDIO) { 368 if (enc->codec_type == CODEC_TYPE_AUDIO) {
380 put_guid(pb, &audio_stream); 369 put_guid(pb, &audio_stream);
381 if ((er_spr != NULL) && (er_spr_len != 0)) { 370 put_guid(pb, &audio_conceal_spread);
382 put_guid(pb, &audio_conceal_spread);
383 } else {
384 put_guid(pb, &video_conceal_none);
385 }
386 } else { 371 } else {
387 put_guid(pb, &video_stream); 372 put_guid(pb, &video_stream);
388 put_guid(pb, &video_conceal_none); 373 put_guid(pb, &video_conceal_none);
389 } 374 }
390 put_le64(pb, 0); /* ??? */ 375 put_le64(pb, 0); /* ??? */
409 url_fseek(pb, es_pos, SEEK_SET); 394 url_fseek(pb, es_pos, SEEK_SET);
410 put_le32(pb, wavsize); /* wav header len */ 395 put_le32(pb, wavsize); /* wav header len */
411 url_fseek(pb, cur_pos, SEEK_SET); 396 url_fseek(pb, cur_pos, SEEK_SET);
412 } 397 }
413 /* ERROR Correction */ 398 /* ERROR Correction */
414 if ((er_spr != NULL) && (er_spr_len != 0)) 399 put_byte(pb, 0x01);
415 put_buffer(pb, er_spr, er_spr_len); 400 if(enc->codec_id == CODEC_ID_ADPCM_G726 || !enc->block_align){
401 put_le16(pb, 0x0190);
402 put_le16(pb, 0x0190);
403 }else{
404 put_le16(pb, enc->block_align);
405 put_le16(pb, enc->block_align);
406 }
407 put_le16(pb, 0x01);
408 put_byte(pb, 0x00);
416 } else { 409 } else {
417 put_le32(pb, enc->width); 410 put_le32(pb, enc->width);
418 put_le32(pb, enc->height); 411 put_le32(pb, enc->height);
419 put_byte(pb, 2); /* ??? */ 412 put_byte(pb, 2); /* ??? */
420 put_le16(pb, 40 + enc->extradata_size); /* size */ 413 put_le16(pb, 40 + enc->extradata_size); /* size */