comparison pcm.c @ 7476:2321e0384521 libavcodec

Simplify PCM codec; use sample_fmts field to set the avctx->sample_fmt field.
author pross
date Mon, 04 Aug 2008 07:47:23 +0000
parents 85ab7655ad4d
children 2f6a2fd238fb
comparison
equal deleted inserted replaced
7475:eaf0ebba81d7 7476:2321e0384521
356 break; 356 break;
357 default: 357 default:
358 break; 358 break;
359 } 359 }
360 360
361 switch(avctx->codec->id) { 361 avctx->sample_fmt = avctx->codec->sample_fmts[0];
362 case CODEC_ID_PCM_F32BE:
363 avctx->sample_fmt = SAMPLE_FMT_FLT;
364 break;
365 default:
366 avctx->sample_fmt = SAMPLE_FMT_S16;
367 break;
368 }
369 return 0; 362 return 0;
370 } 363 }
371 364
372 /** 365 /**
373 * \brief convert samples to 16 bit 366 * \brief convert samples to 16 bit
569 #else 562 #else
570 #define PCM_ENCODER(id,sample_fmt_,name,long_name_) 563 #define PCM_ENCODER(id,sample_fmt_,name,long_name_)
571 #endif 564 #endif
572 565
573 #ifdef CONFIG_DECODERS 566 #ifdef CONFIG_DECODERS
574 #define PCM_DECODER(id,name,long_name_) \ 567 #define PCM_DECODER(id,sample_fmt_,name,long_name_) \
575 AVCodec name ## _decoder = { \ 568 AVCodec name ## _decoder = { \
576 #name, \ 569 #name, \
577 CODEC_TYPE_AUDIO, \ 570 CODEC_TYPE_AUDIO, \
578 id, \ 571 id, \
579 sizeof(PCMDecode), \ 572 sizeof(PCMDecode), \
580 pcm_decode_init, \ 573 pcm_decode_init, \
581 NULL, \ 574 NULL, \
582 NULL, \ 575 NULL, \
583 pcm_decode_frame, \ 576 pcm_decode_frame, \
577 .sample_fmts = (enum SampleFormat[]){sample_fmt_,SAMPLE_FMT_NONE}, \
584 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ 578 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
585 }; 579 };
586 #else 580 #else
587 #define PCM_DECODER(id,name,long_name_) 581 #define PCM_DECODER(id,sample_fmt_,name,long_name_)
588 #endif 582 #endif
589 583
590 #define PCM_CODEC(id, sample_fmt_, name, long_name_) \ 584 #define PCM_CODEC(id, sample_fmt_, name, long_name_) \
591 PCM_ENCODER(id,sample_fmt_,name,long_name_) PCM_DECODER(id,name,long_name_) 585 PCM_ENCODER(id,sample_fmt_,name,long_name_) PCM_DECODER(id,sample_fmt_,name,long_name_)
592 586
593 /* Note: Do not forget to add new entries to the Makefile as well. */ 587 /* Note: Do not forget to add new entries to the Makefile as well. */
594 PCM_CODEC (CODEC_ID_PCM_ALAW, SAMPLE_FMT_S16, pcm_alaw, "A-law PCM"); 588 PCM_CODEC (CODEC_ID_PCM_ALAW, SAMPLE_FMT_S16, pcm_alaw, "A-law PCM");
595 PCM_CODEC (CODEC_ID_PCM_DVD, SAMPLE_FMT_S16, pcm_dvd, "signed 16|20|24-bit big-endian PCM"); 589 PCM_CODEC (CODEC_ID_PCM_DVD, SAMPLE_FMT_S16, pcm_dvd, "signed 16|20|24-bit big-endian PCM");
596 PCM_CODEC (CODEC_ID_PCM_F32BE, SAMPLE_FMT_FLT, pcm_f32be, "32-bit floating point big-endian PCM"); 590 PCM_CODEC (CODEC_ID_PCM_F32BE, SAMPLE_FMT_FLT, pcm_f32be, "32-bit floating point big-endian PCM");
597 PCM_CODEC (CODEC_ID_PCM_MULAW, SAMPLE_FMT_S16, pcm_mulaw, "mu-law PCM"); 591 PCM_CODEC (CODEC_ID_PCM_MULAW, SAMPLE_FMT_S16, pcm_mulaw, "mu-law PCM");
598 PCM_CODEC (CODEC_ID_PCM_S8, SAMPLE_FMT_S16, pcm_s8, "signed 8-bit PCM"); 592 PCM_CODEC (CODEC_ID_PCM_S8, SAMPLE_FMT_S16, pcm_s8, "signed 8-bit PCM");
599 PCM_CODEC (CODEC_ID_PCM_S16BE, SAMPLE_FMT_S16, pcm_s16be, "signed 16-bit big-endian PCM"); 593 PCM_CODEC (CODEC_ID_PCM_S16BE, SAMPLE_FMT_S16, pcm_s16be, "signed 16-bit big-endian PCM");
600 PCM_CODEC (CODEC_ID_PCM_S16LE, SAMPLE_FMT_S16, pcm_s16le, "signed 16-bit little-endian PCM"); 594 PCM_CODEC (CODEC_ID_PCM_S16LE, SAMPLE_FMT_S16, pcm_s16le, "signed 16-bit little-endian PCM");
601 PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, pcm_s16le_planar, "16-bit little-endian planar PCM"); 595 PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, SAMPLE_FMT_S16, pcm_s16le_planar, "16-bit little-endian planar PCM");
602 PCM_CODEC (CODEC_ID_PCM_S24BE, SAMPLE_FMT_S16, pcm_s24be, "signed 24-bit big-endian PCM"); 596 PCM_CODEC (CODEC_ID_PCM_S24BE, SAMPLE_FMT_S16, pcm_s24be, "signed 24-bit big-endian PCM");
603 PCM_CODEC (CODEC_ID_PCM_S24DAUD, SAMPLE_FMT_S16, pcm_s24daud, "D-Cinema audio signed 24-bit PCM"); 597 PCM_CODEC (CODEC_ID_PCM_S24DAUD, SAMPLE_FMT_S16, pcm_s24daud, "D-Cinema audio signed 24-bit PCM");
604 PCM_CODEC (CODEC_ID_PCM_S24LE, SAMPLE_FMT_S16, pcm_s24le, "signed 24-bit little-endian PCM"); 598 PCM_CODEC (CODEC_ID_PCM_S24LE, SAMPLE_FMT_S16, pcm_s24le, "signed 24-bit little-endian PCM");
605 PCM_CODEC (CODEC_ID_PCM_S32BE, SAMPLE_FMT_S16, pcm_s32be, "signed 32-bit big-endian PCM"); 599 PCM_CODEC (CODEC_ID_PCM_S32BE, SAMPLE_FMT_S16, pcm_s32be, "signed 32-bit big-endian PCM");
606 PCM_CODEC (CODEC_ID_PCM_S32LE, SAMPLE_FMT_S16, pcm_s32le, "signed 32-bit little-endian PCM"); 600 PCM_CODEC (CODEC_ID_PCM_S32LE, SAMPLE_FMT_S16, pcm_s32le, "signed 32-bit little-endian PCM");