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
39323932 */
39333933 int av_get_bits_per_sample(enum CodecID codec_id);
39343934
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+ */
3943+int av_get_exact_bits_per_sample(enum CodecID codec_id);
3944+
39353945 /* frame parsing */
39363946 typedef struct AVCodecParserContext {
39373947 void *priv_data;
libavcodec/utils.c+23−11
@@ -1681,21 +1681,15 @@ void avcodec_default_free_buffers(AVCodecContext *avctx) · 1680 unmodified lines
16811681 }
16821682 }
16831683
1684−int av_get_bits_per_sample(enum CodecID codec_id){
1684+int av_get_exact_bits_per_sample(enum CodecID codec_id)
1685+{
16851686 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:
16911687 case CODEC_ID_ADPCM_CT:
16921688 case CODEC_ID_ADPCM_IMA_APC:
1693− case CODEC_ID_ADPCM_IMA_WAV:
1694− case CODEC_ID_ADPCM_IMA_QT:
1695− case CODEC_ID_ADPCM_SWF:
1696− case CODEC_ID_ADPCM_MS:
1697− case CODEC_ID_ADPCM_YAMAHA:
1689+ case CODEC_ID_ADPCM_IMA_EA_SEAD:
1690+ case CODEC_ID_ADPCM_IMA_WS:
16981691 case CODEC_ID_ADPCM_G722:
1692+ case CODEC_ID_ADPCM_YAMAHA:
16991693 return 4;
17001694 case CODEC_ID_PCM_ALAW:
17011695 case CODEC_ID_PCM_MULAW:
@@ -1730,6 +1724,24 @@ int av_get_bits_per_sample(enum CodecID codec_id){ · 28 unmodified lines
17301724 }
17311725 }
17321726
1727+int 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+
17331745 #if !HAVE_THREADS
17341746 int ff_thread_init(AVCodecContext *s){
17351747 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