comparison swfenc.c @ 4669:d6eb19c43e99 libavformat

Allocate AVFifoBuffer through the fifo API to reduce future API/ABI issues. Yes this breaks ABI/API but ive already broken it and will bump avutil major soon.
author michael
date Sun, 08 Mar 2009 14:16:55 +0000
parents 043d314bb216
children fc0a165de804
comparison
equal deleted inserted replaced
4668:1f87eacc3c32 4669:d6eb19c43e99
190 if (!enc->frame_size) { 190 if (!enc->frame_size) {
191 av_log(s, AV_LOG_ERROR, "audio frame size not set\n"); 191 av_log(s, AV_LOG_ERROR, "audio frame size not set\n");
192 return -1; 192 return -1;
193 } 193 }
194 swf->audio_enc = enc; 194 swf->audio_enc = enc;
195 av_fifo_init(&swf->audio_fifo, AUDIO_FIFO_SIZE); 195 swf->audio_fifo= av_fifo_alloc(AUDIO_FIFO_SIZE);
196 } else { 196 } else {
197 av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n"); 197 av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n");
198 return -1; 198 return -1;
199 } 199 }
200 } else { 200 } else {
412 } 412 }
413 413
414 swf->swf_frame_number++; 414 swf->swf_frame_number++;
415 415
416 /* streaming sound always should be placed just before showframe tags */ 416 /* streaming sound always should be placed just before showframe tags */
417 if (swf->audio_enc && av_fifo_size(&swf->audio_fifo)) { 417 if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
418 int frame_size = av_fifo_size(&swf->audio_fifo); 418 int frame_size = av_fifo_size(swf->audio_fifo);
419 put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG); 419 put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
420 put_le16(pb, swf->sound_samples); 420 put_le16(pb, swf->sound_samples);
421 put_le16(pb, 0); // seek samples 421 put_le16(pb, 0); // seek samples
422 av_fifo_generic_read(&swf->audio_fifo, frame_size, &put_buffer, pb); 422 av_fifo_generic_read(swf->audio_fifo, frame_size, &put_buffer, pb);
423 put_swf_end_tag(s); 423 put_swf_end_tag(s);
424 424
425 /* update FIFO */ 425 /* update FIFO */
426 swf->sound_samples = 0; 426 swf->sound_samples = 0;
427 } 427 }
442 442
443 /* Flash Player limit */ 443 /* Flash Player limit */
444 if (swf->swf_frame_number == 16000) 444 if (swf->swf_frame_number == 16000)
445 av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n"); 445 av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
446 446
447 if (av_fifo_size(&swf->audio_fifo) + size > AUDIO_FIFO_SIZE) { 447 if (av_fifo_size(swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
448 av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n"); 448 av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
449 return -1; 449 return -1;
450 } 450 }
451 451
452 av_fifo_generic_write(&swf->audio_fifo, buf, size, NULL); 452 av_fifo_generic_write(swf->audio_fifo, buf, size, NULL);
453 swf->sound_samples += enc->frame_size; 453 swf->sound_samples += enc->frame_size;
454 454
455 /* if audio only stream make sure we add swf frames */ 455 /* if audio only stream make sure we add swf frames */
456 if (!swf->video_enc) 456 if (!swf->video_enc)
457 swf_write_video(s, enc, 0, 0); 457 swf_write_video(s, enc, 0, 0);
479 for(i=0;i<s->nb_streams;i++) { 479 for(i=0;i<s->nb_streams;i++) {
480 enc = s->streams[i]->codec; 480 enc = s->streams[i]->codec;
481 if (enc->codec_type == CODEC_TYPE_VIDEO) 481 if (enc->codec_type == CODEC_TYPE_VIDEO)
482 video_enc = enc; 482 video_enc = enc;
483 else 483 else
484 av_fifo_free(&swf->audio_fifo); 484 av_fifo_free(swf->audio_fifo);
485 } 485 }
486 486
487 put_swf_tag(s, TAG_END); 487 put_swf_tag(s, TAG_END);
488 put_swf_end_tag(s); 488 put_swf_end_tag(s);
489 489