History

avcodec: add av_get_exact_bits_per_sample() function

This only returns bits per sample when it is exactly correct. That is, the codec contains only raw samples with no frame headers or padding. This applies to basically all PCM codecs and a small subset of ADPCM codecs.

Justin Ruggles committed 14 years ago

Commit 6699d071 parent 27c7ca92 files · +33 −11Browse files

Unified · Split

2 files
  1. libavcodec/avcodec.h +10 −0
  2. libavcodec/utils.c +23 −11
libavcodec/avcodec.h+10−0
@@ -3932,6 +3932,16 @@ void avcodec_default_free_buffers(AVCodecContext *s); · 3931 unmodified lines
3932 */3932 */
3933int av_get_bits_per_sample(enum CodecID codec_id);3933int av_get_bits_per_sample(enum CodecID codec_id);
3934 3934
3935/**
3936 * Return codec bits per sample.
3937 * Only return non-zero if the bits per sample is exactly correct, not an
3938 * approximation.
3939 *
3940 * @param[in] codec_id the codec
3941 * @return Number of bits per sample or zero if unknown for the given codec.
3942 */
3943int av_get_exact_bits_per_sample(enum CodecID codec_id);
3944
3935/* frame parsing */3945/* frame parsing */
3936typedef struct AVCodecParserContext {3946typedef struct AVCodecParserContext {
3937 void *priv_data;3947 void *priv_data;
libavcodec/utils.c+23−11
@@ -1681,21 +1681,15 @@ void avcodec_default_free_buffers(AVCodecContext *avctx) · 1680 unmodified lines
1681 }1681 }
1682}1682}
1683 1683
1684int av_get_bits_per_sample(enum CodecID codec_id){1684int av_get_exact_bits_per_sample(enum CodecID codec_id)
1685{
1685 switch(codec_id){1686 switch(codec_id){
1686 case CODEC_ID_ADPCM_SBPRO_2:
1687 return 2;
1688 case CODEC_ID_ADPCM_SBPRO_3:
1689 return 3;
1690 case CODEC_ID_ADPCM_SBPRO_4:
1691 case CODEC_ID_ADPCM_CT:1687 case CODEC_ID_ADPCM_CT:
1692 case CODEC_ID_ADPCM_IMA_APC:1688 case CODEC_ID_ADPCM_IMA_APC:
1693 case CODEC_ID_ADPCM_IMA_WAV:1689 case CODEC_ID_ADPCM_IMA_EA_SEAD:
1694 case CODEC_ID_ADPCM_IMA_QT:1690 case CODEC_ID_ADPCM_IMA_WS:
1695 case CODEC_ID_ADPCM_SWF:
1696 case CODEC_ID_ADPCM_MS:
1697 case CODEC_ID_ADPCM_YAMAHA:
1698 case CODEC_ID_ADPCM_G722:1691 case CODEC_ID_ADPCM_G722:
1692 case CODEC_ID_ADPCM_YAMAHA:
1699 return 4;1693 return 4;
1700 case CODEC_ID_PCM_ALAW:1694 case CODEC_ID_PCM_ALAW:
1701 case CODEC_ID_PCM_MULAW:1695 case CODEC_ID_PCM_MULAW:
@@ -1730,6 +1724,24 @@ int av_get_bits_per_sample(enum CodecID codec_id){ · 28 unmodified lines
1730 }1724 }
1731}1725}
1732 1726
1727int av_get_bits_per_sample(enum CodecID codec_id)
1728{
1729 switch (codec_id) {
1730 case CODEC_ID_ADPCM_SBPRO_2:
1731 return 2;
1732 case CODEC_ID_ADPCM_SBPRO_3:
1733 return 3;
1734 case CODEC_ID_ADPCM_SBPRO_4:
1735 case CODEC_ID_ADPCM_IMA_WAV:
1736 case CODEC_ID_ADPCM_IMA_QT:
1737 case CODEC_ID_ADPCM_SWF:
1738 case CODEC_ID_ADPCM_MS:
1739 return 4;
1740 default:
1741 return av_get_exact_bits_per_sample(codec_id);
1742 }
1743}
1744
1733#if !HAVE_THREADS1745#if !HAVE_THREADS
1734int ff_thread_init(AVCodecContext *s){1746int ff_thread_init(AVCodecContext *s){
1735 return -1;1747 return -1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t