summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2015-04-21 15:52:14 +0000
committerLRN <lrn1986@gmail.com>2015-04-21 15:52:14 +0000
commita8d7509bc944a297ae1bfb0c053b352707f976a3 (patch)
tree172400fc5599d2e15f49d3847b72df6df5082529
parentaf2a8908e00c15fb55795159a2d0e68d254c9b28 (diff)
downloadlibextractor-a8d7509bc944a297ae1bfb0c053b352707f976a3.tar.gz
libextractor-a8d7509bc944a297ae1bfb0c053b352707f976a3.zip
Minor style fix for previewopus
-rw-r--r--src/plugins/previewopus_extractor.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/src/plugins/previewopus_extractor.c b/src/plugins/previewopus_extractor.c
index d611791..d718908 100644
--- a/src/plugins/previewopus_extractor.c
+++ b/src/plugins/previewopus_extractor.c
@@ -230,7 +230,7 @@ static int open_output_file(
230 /** Guess the desired container format based on the file extension. */ 230 /** Guess the desired container format based on the file extension. */
231 if (!((*output_format_context)->oformat = av_guess_format(NULL, "file.ogg", 231 if (!((*output_format_context)->oformat = av_guess_format(NULL, "file.ogg",
232 NULL))) { 232 NULL))) {
233 #if DEBUG 233#if DEBUG
234 fprintf(stderr, "Could not find output file format\n"); 234 fprintf(stderr, "Could not find output file format\n");
235#endif 235#endif
236 goto cleanup; 236 goto cleanup;
@@ -239,7 +239,7 @@ static int open_output_file(
239 239
240 /** Find the encoder to be used by its name. */ 240 /** Find the encoder to be used by its name. */
241 if (!(output_codec = avcodec_find_encoder(AV_CODEC_ID_OPUS))) { 241 if (!(output_codec = avcodec_find_encoder(AV_CODEC_ID_OPUS))) {
242 #if DEBUG 242#if DEBUG
243 fprintf(stderr, "Could not find an OPUS encoder.\n"); 243 fprintf(stderr, "Could not find an OPUS encoder.\n");
244#endif 244#endif
245 goto cleanup; 245 goto cleanup;
@@ -247,7 +247,7 @@ static int open_output_file(
247 247
248 /** Create a new audio stream in the output file container. */ 248 /** Create a new audio stream in the output file container. */
249 if (!(stream = avformat_new_stream(*output_format_context, output_codec))) { 249 if (!(stream = avformat_new_stream(*output_format_context, output_codec))) {
250 #if DEBUG 250#if DEBUG
251 fprintf(stderr, "Could not create new stream\n"); 251 fprintf(stderr, "Could not create new stream\n");
252#endif 252#endif
253 error = AVERROR(ENOMEM); 253 error = AVERROR(ENOMEM);
@@ -271,7 +271,7 @@ static int open_output_file(
271 271
272 /** Open the encoder for the audio stream to use it later. */ 272 /** Open the encoder for the audio stream to use it later. */
273 if ((error = avcodec_open2(*output_codec_context, output_codec, NULL)) < 0) { 273 if ((error = avcodec_open2(*output_codec_context, output_codec, NULL)) < 0) {
274 #if DEBUG 274#if DEBUG
275 fprintf(stderr, "Could not open output codec (error '%s')\n", 275 fprintf(stderr, "Could not open output codec (error '%s')\n",
276 get_error_text(error)); 276 get_error_text(error));
277#endif 277#endif
@@ -297,7 +297,7 @@ static void init_packet(AVPacket *packet)
297static int init_input_frame(AVFrame **frame) 297static int init_input_frame(AVFrame **frame)
298{ 298{
299 if (!(*frame = avcodec_alloc_frame())) { 299 if (!(*frame = avcodec_alloc_frame())) {
300 #if DEBUG 300#if DEBUG
301 fprintf(stderr, "Could not allocate input frame\n"); 301 fprintf(stderr, "Could not allocate input frame\n");
302#endif 302#endif
303 return AVERROR(ENOMEM); 303 return AVERROR(ENOMEM);
@@ -324,9 +324,9 @@ static int init_resampler(AVCodecContext *input_codec_context,
324 324
325 /** Create a resampler context for the conversion. */ 325 /** Create a resampler context for the conversion. */
326 if (!(*resample_context = avresample_alloc_context())) { 326 if (!(*resample_context = avresample_alloc_context())) {
327 #if DEBUG 327#if DEBUG
328 fprintf(stderr, "Could not allocate resample context\n"); 328 fprintf(stderr, "Could not allocate resample context\n");
329 #endif 329#endif
330 return AVERROR(ENOMEM); 330 return AVERROR(ENOMEM);
331 } 331 }
332 332
@@ -352,9 +352,9 @@ static int init_resampler(AVCodecContext *input_codec_context,
352 352
353 /** Open the resampler with the specified parameters. */ 353 /** Open the resampler with the specified parameters. */
354 if ((error = avresample_open(*resample_context)) < 0) { 354 if ((error = avresample_open(*resample_context)) < 0) {
355 #if DEBUG 355#if DEBUG
356 fprintf(stderr, "Could not open resample context\n"); 356 fprintf(stderr, "Could not open resample context\n");
357 #endif 357#endif
358 avresample_free(resample_context); 358 avresample_free(resample_context);
359 return error; 359 return error;
360 } 360 }
@@ -367,9 +367,9 @@ static int init_fifo(AVAudioFifo **fifo)
367{ 367{
368 /** Create the FIFO buffer based on the specified output sample format. */ 368 /** Create the FIFO buffer based on the specified output sample format. */
369 if (!(*fifo = av_audio_fifo_alloc(OUTPUT_SAMPLE_FORMAT, OUTPUT_CHANNELS, 1))) { 369 if (!(*fifo = av_audio_fifo_alloc(OUTPUT_SAMPLE_FORMAT, OUTPUT_CHANNELS, 1))) {
370 #if DEBUG 370#if DEBUG
371 fprintf(stderr, "Could not allocate FIFO\n"); 371 fprintf(stderr, "Could not allocate FIFO\n");
372 #endif 372#endif
373 return AVERROR(ENOMEM); 373 return AVERROR(ENOMEM);
374 } 374 }
375 return 0; 375 return 0;
@@ -380,10 +380,10 @@ static int write_output_file_header(AVFormatContext *output_format_context)
380{ 380{
381 int error; 381 int error;
382 if ((error = avformat_write_header(output_format_context, NULL)) < 0) { 382 if ((error = avformat_write_header(output_format_context, NULL)) < 0) {
383 #if DEBUG 383#if DEBUG
384 fprintf(stderr, "Could not write output file header (error '%s')\n", 384 fprintf(stderr, "Could not write output file header (error '%s')\n",
385 get_error_text(error)); 385 get_error_text(error));
386 #endif 386#endif
387 return error; 387 return error;
388 } 388 }
389 return 0; 389 return 0;
@@ -405,16 +405,16 @@ static int decode_audio_frame(AVFrame *frame,
405 if ((error = av_read_frame(input_format_context, &input_packet)) < 0) { 405 if ((error = av_read_frame(input_format_context, &input_packet)) < 0) {
406 /** If we are the the end of the file, flush the decoder below. */ 406 /** If we are the the end of the file, flush the decoder below. */
407 if (error == AVERROR_EOF){ 407 if (error == AVERROR_EOF){
408 #if DEBUG 408#if DEBUG
409 fprintf(stderr, "EOF in decode_audio\n"); 409 fprintf(stderr, "EOF in decode_audio\n");
410 #endif 410#endif
411 *finished = 1; 411 *finished = 1;
412 } 412 }
413 else { 413 else {
414 #if DEBUG 414#if DEBUG
415 fprintf(stderr, "Could not read frame (error '%s')\n", 415 fprintf(stderr, "Could not read frame (error '%s')\n",
416 get_error_text(error)); 416 get_error_text(error));
417 #endif 417#endif
418 return error; 418 return error;
419 } 419 }
420 } 420 }
@@ -431,10 +431,10 @@ static int decode_audio_frame(AVFrame *frame,
431 */ 431 */
432 if ((error = avcodec_decode_audio4(input_codec_context, frame, 432 if ((error = avcodec_decode_audio4(input_codec_context, frame,
433 data_present, &input_packet)) < 0) { 433 data_present, &input_packet)) < 0) {
434 #if DEBUG 434#if DEBUG
435 fprintf(stderr, "Could not decode frame (error '%s')\n", 435 fprintf(stderr, "Could not decode frame (error '%s')\n",
436 get_error_text(error)); 436 get_error_text(error));
437 #endif 437#endif
438 av_free_packet(&input_packet); 438 av_free_packet(&input_packet);
439 return error; 439 return error;
440 } 440 }
@@ -467,9 +467,9 @@ static int init_converted_samples(uint8_t ***converted_input_samples, int* out_l
467 */ 467 */
468 if (!(*converted_input_samples = calloc(output_codec_context->channels, 468 if (!(*converted_input_samples = calloc(output_codec_context->channels,
469 sizeof(**converted_input_samples)))) { 469 sizeof(**converted_input_samples)))) {
470 #if DEBUG 470#if DEBUG
471 fprintf(stderr, "Could not allocate converted input sample pointers\n"); 471 fprintf(stderr, "Could not allocate converted input sample pointers\n");
472 #endif 472#endif
473 return AVERROR(ENOMEM); 473 return AVERROR(ENOMEM);
474 } 474 }
475 475
@@ -481,11 +481,11 @@ static int init_converted_samples(uint8_t ***converted_input_samples, int* out_l
481 output_codec_context->channels, 481 output_codec_context->channels,
482 frame_size, 482 frame_size,
483 output_codec_context->sample_fmt, 0)) < 0) { 483 output_codec_context->sample_fmt, 0)) < 0) {
484 #if DEBUG 484#if DEBUG
485 fprintf(stderr, 485 fprintf(stderr,
486 "Could not allocate converted input samples (error '%s')\n", 486 "Could not allocate converted input samples (error '%s')\n",
487 get_error_text(error)); 487 get_error_text(error));
488 #endif 488#endif
489 av_freep(&(*converted_input_samples)[0]); 489 av_freep(&(*converted_input_samples)[0]);
490 free(*converted_input_samples); 490 free(*converted_input_samples);
491 return error; 491 return error;
@@ -507,10 +507,10 @@ static int convert_samples(uint8_t **input_data,
507 /** Convert the samples using the resampler. */ 507 /** Convert the samples using the resampler. */
508 if ((error = avresample_convert(resample_context, converted_data, out_linesize, 508 if ((error = avresample_convert(resample_context, converted_data, out_linesize,
509 out_sample, input_data, 0, in_sample)) < 0) { 509 out_sample, input_data, 0, in_sample)) < 0) {
510 #if DEBUG 510#if DEBUG
511 fprintf(stderr, "Could not convert input samples (error '%s')\n", 511 fprintf(stderr, "Could not convert input samples (error '%s')\n",
512 get_error_text(error)); 512 get_error_text(error));
513 #endif 513#endif
514 return error; 514 return error;
515 } 515 }
516 516
@@ -521,9 +521,9 @@ static int convert_samples(uint8_t **input_data,
521 * If the sample rates differ, this case has to be handled differently 521 * If the sample rates differ, this case has to be handled differently
522 */ 522 */
523 if (avresample_available(resample_context)) { 523 if (avresample_available(resample_context)) {
524 #if DEBUG 524#if DEBUG
525 fprintf(stderr, "%i Converted samples left over\n",avresample_available(resample_context)); 525 fprintf(stderr, "%i Converted samples left over\n",avresample_available(resample_context));
526 #endif 526#endif
527 } 527 }
528 528
529 529
@@ -542,18 +542,18 @@ static int add_samples_to_fifo(AVAudioFifo *fifo,
542 * the old and the new samples. 542 * the old and the new samples.
543 */ 543 */
544 if ((error = av_audio_fifo_realloc(fifo, av_audio_fifo_size(fifo) + frame_size)) < 0) { 544 if ((error = av_audio_fifo_realloc(fifo, av_audio_fifo_size(fifo) + frame_size)) < 0) {
545 #if DEBUG 545#if DEBUG
546 fprintf(stderr, "Could not reallocate FIFO\n"); 546 fprintf(stderr, "Could not reallocate FIFO\n");
547 #endif 547#endif
548 return error; 548 return error;
549 } 549 }
550 550
551 /** Store the new samples in the FIFO buffer. */ 551 /** Store the new samples in the FIFO buffer. */
552 if (av_audio_fifo_write(fifo, (void **)converted_input_samples, 552 if (av_audio_fifo_write(fifo, (void **)converted_input_samples,
553 frame_size) < frame_size) { 553 frame_size) < frame_size) {
554 #if DEBUG 554#if DEBUG
555 fprintf(stderr, "Could not write data to FIFO\n"); 555 fprintf(stderr, "Could not write data to FIFO\n");
556 #endif 556#endif
557 return AVERROR_EXIT; 557 return AVERROR_EXIT;
558 } 558 }
559 return 0; 559 return 0;
@@ -579,18 +579,18 @@ static int read_decode_convert_and_store(AVAudioFifo *fifo,
579 579
580 /** Initialize temporary storage for one input frame. */ 580 /** Initialize temporary storage for one input frame. */
581 if (init_input_frame(&input_frame)){ 581 if (init_input_frame(&input_frame)){
582 #if DEBUG 582#if DEBUG
583 fprintf(stderr, "Failed at init frame\n"); 583 fprintf(stderr, "Failed at init frame\n");
584 #endif 584#endif
585 goto cleanup; 585 goto cleanup;
586 586
587 } 587 }
588 /** Decode one frame worth of audio samples. */ 588 /** Decode one frame worth of audio samples. */
589 if (decode_audio_frame(input_frame, input_format_context, 589 if (decode_audio_frame(input_frame, input_format_context,
590 input_codec_context, audio_stream_index, &data_present, finished)){ 590 input_codec_context, audio_stream_index, &data_present, finished)){
591 #if DEBUG 591#if DEBUG
592 fprintf(stderr, "Failed at decode audio\n"); 592 fprintf(stderr, "Failed at decode audio\n");
593 #endif 593#endif
594 594
595 goto cleanup; 595 goto cleanup;
596 596
@@ -602,9 +602,9 @@ static int read_decode_convert_and_store(AVAudioFifo *fifo,
602 */ 602 */
603 if (*finished && !data_present) { 603 if (*finished && !data_present) {
604 ret = 0; 604 ret = 0;
605 #if DEBUG 605#if DEBUG
606 fprintf(stderr, "Failed at finished or no data\n"); 606 fprintf(stderr, "Failed at finished or no data\n");
607 #endif 607#endif
608 goto cleanup; 608 goto cleanup;
609 } 609 }
610 /** If there is decoded data, convert and store it */ 610 /** If there is decoded data, convert and store it */
@@ -619,9 +619,9 @@ static int read_decode_convert_and_store(AVAudioFifo *fifo,
619 /** Initialize the temporary storage for the converted input samples. */ 619 /** Initialize the temporary storage for the converted input samples. */
620 if (init_converted_samples(&converted_input_samples, &out_linesize, output_codec_context, 620 if (init_converted_samples(&converted_input_samples, &out_linesize, output_codec_context,
621 out_samples)){ 621 out_samples)){
622 #if DEBUG 622#if DEBUG
623 fprintf(stderr, "Failed at init_converted_samples\n"); 623 fprintf(stderr, "Failed at init_converted_samples\n");
624 #endif 624#endif
625 goto cleanup; 625 goto cleanup;
626 } 626 }
627 627
@@ -633,17 +633,17 @@ static int read_decode_convert_and_store(AVAudioFifo *fifo,
633 input_frame->nb_samples, out_samples, out_linesize ,resampler_context)){ 633 input_frame->nb_samples, out_samples, out_linesize ,resampler_context)){
634 634
635 635
636 #if DEBUG 636#if DEBUG
637 fprintf(stderr, "Failed at convert_samples, input frame %i \n",input_frame->nb_samples); 637 fprintf(stderr, "Failed at convert_samples, input frame %i \n",input_frame->nb_samples);
638 #endif 638#endif
639 goto cleanup; 639 goto cleanup;
640 } 640 }
641 /** Add the converted input samples to the FIFO buffer for later processing. */ 641 /** Add the converted input samples to the FIFO buffer for later processing. */
642 if (add_samples_to_fifo(fifo, converted_input_samples, 642 if (add_samples_to_fifo(fifo, converted_input_samples,
643 out_samples)){ 643 out_samples)){
644 #if DEBUG 644#if DEBUG
645 fprintf(stderr, "Failed at add_samples_to_fifo\n"); 645 fprintf(stderr, "Failed at add_samples_to_fifo\n");
646 #endif 646#endif
647 goto cleanup; 647 goto cleanup;
648 } 648 }
649 ret = 0; 649 ret = 0;
@@ -672,9 +672,9 @@ static int init_output_frame(AVFrame **frame,
672 672
673 /** Create a new frame to store the audio samples. */ 673 /** Create a new frame to store the audio samples. */
674 if (!(*frame = avcodec_alloc_frame())) { 674 if (!(*frame = avcodec_alloc_frame())) {
675 #if DEBUG 675#if DEBUG
676 fprintf(stderr, "Could not allocate output frame\n"); 676 fprintf(stderr, "Could not allocate output frame\n");
677 #endif 677#endif
678 return AVERROR_EXIT; 678 return AVERROR_EXIT;
679 } 679 }
680 680
@@ -699,9 +699,9 @@ static int init_output_frame(AVFrame **frame,
699 * sure that the audio frame can hold as many samples as specified. 699 * sure that the audio frame can hold as many samples as specified.
700 */ 700 */
701 if ((error = av_frame_get_buffer(*frame, 0)) < 0) { 701 if ((error = av_frame_get_buffer(*frame, 0)) < 0) {
702 #if DEBUG 702#if DEBUG
703 fprintf(stderr, "Could allocate output frame samples (error '%s')\n", get_error_text(error)); 703 fprintf(stderr, "Could allocate output frame samples (error '%s')\n", get_error_text(error));
704 #endif 704#endif
705 avcodec_free_frame(frame); 705 avcodec_free_frame(frame);
706 return error; 706 return error;
707 } 707 }
@@ -726,10 +726,10 @@ static int encode_audio_frame(AVFrame *frame,
726 */ 726 */
727 if ((error = avcodec_encode_audio2(output_codec_context, &output_packet, 727 if ((error = avcodec_encode_audio2(output_codec_context, &output_packet,
728 frame, data_present)) < 0) { 728 frame, data_present)) < 0) {
729 #if DEBUG 729#if DEBUG
730 fprintf(stderr, "Could not encode frame (error '%s')\n", 730 fprintf(stderr, "Could not encode frame (error '%s')\n",
731 get_error_text(error)); 731 get_error_text(error));
732 #endif 732#endif
733 av_free_packet(&output_packet); 733 av_free_packet(&output_packet);
734 return error; 734 return error;
735 } 735 }
@@ -737,10 +737,10 @@ static int encode_audio_frame(AVFrame *frame,
737 /** Write one audio frame from the temporary packet to the output file. */ 737 /** Write one audio frame from the temporary packet to the output file. */
738 if (*data_present) { 738 if (*data_present) {
739 if ((error = av_write_frame(output_format_context, &output_packet)) < 0) { 739 if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {
740 #if DEBUG 740#if DEBUG
741 fprintf(stderr, "Could not write frame (error '%s')\n", 741 fprintf(stderr, "Could not write frame (error '%s')\n",
742 get_error_text(error)); 742 get_error_text(error));
743 #endif 743#endif
744 744
745 av_free_packet(&output_packet); 745 av_free_packet(&output_packet);
746 return error; 746 return error;
@@ -780,9 +780,9 @@ static int load_encode_and_write(AVAudioFifo *fifo,
780 * The samples are stored in the frame temporarily. 780 * The samples are stored in the frame temporarily.
781 */ 781 */
782 if (av_audio_fifo_read(fifo, (void **)output_frame->data, frame_size) < frame_size) { 782 if (av_audio_fifo_read(fifo, (void **)output_frame->data, frame_size) < frame_size) {
783 #if DEBUG 783#if DEBUG
784 fprintf(stderr, "Could not read data from FIFO\n"); 784 fprintf(stderr, "Could not read data from FIFO\n");
785 #endif 785#endif
786 avcodec_free_frame(&output_frame); 786 avcodec_free_frame(&output_frame);
787 return AVERROR_EXIT; 787 return AVERROR_EXIT;
788 } 788 }
@@ -801,10 +801,10 @@ static int write_output_file_trailer(AVFormatContext *output_format_context)
801{ 801{
802 int error; 802 int error;
803 if ((error = av_write_trailer(output_format_context)) < 0) { 803 if ((error = av_write_trailer(output_format_context)) < 0) {
804 #if DEBUG 804#if DEBUG
805 fprintf(stderr, "Could not write output file trailer (error '%s')\n", 805 fprintf(stderr, "Could not write output file trailer (error '%s')\n",
806 get_error_text(error)); 806 get_error_text(error));
807 #endif 807#endif
808 return error; 808 return error;
809 } 809 }
810 return 0; 810 return 0;
@@ -865,7 +865,7 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
865 av_dict_free (&options); 865 av_dict_free (&options);
866 if (0 > avformat_find_stream_info (format_ctx, NULL)) 866 if (0 > avformat_find_stream_info (format_ctx, NULL))
867 { 867 {
868 #if DEBUG 868#if DEBUG
869 fprintf (stderr, 869 fprintf (stderr,
870 "Failed to read stream info\n"); 870 "Failed to read stream info\n");
871#endif 871#endif
@@ -950,7 +950,7 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
950 } 950 }
951 else 951 else
952 { 952 {
953 #if DEBUG 953#if DEBUG
954 duration = format_ctx->duration; 954 duration = format_ctx->duration;
955 fprintf (stderr, 955 fprintf (stderr,
956 "Duration: %lld\n", 956 "Duration: %lld\n",