summaryrefslogtreecommitdiff
path: root/libavcodec/g726.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-10-27 20:45:24 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-11-01 21:23:03 -0400
commit9e78d8cfdf915bd8704f544df84402a4b36dfb72 (patch)
treeb982103194a2e702c1ef4cd086b731ea36c19ba6 /libavcodec/g726.c
parent6e8d4a7afbf40c0eb4bd70a6e7724d22ce7a6239 (diff)
g726: treat sample rates other than 8kHz as unofficial.
Diffstat (limited to 'libavcodec/g726.c')
-rw-r--r--libavcodec/g726.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/g726.c b/libavcodec/g726.c
index b17d578d53..12a37e0ab5 100644
--- a/libavcodec/g726.c
+++ b/libavcodec/g726.c
@@ -302,6 +302,13 @@ static av_cold int g726_encode_init(AVCodecContext *avctx)
{
G726Context* c = avctx->priv_data;
+ if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL &&
+ avctx->sample_rate != 8000) {
+ av_log(avctx, AV_LOG_ERROR, "Sample rates other than 8kHz are not "
+ "allowed when the compliance level is higher than unofficial. "
+ "Resample or reduce the compliance level.\n");
+ return AVERROR(EINVAL);
+ }
if (avctx->sample_rate <= 0) {
av_log(avctx, AV_LOG_ERROR, "Samplerate is invalid\n");
return -1;
@@ -366,6 +373,14 @@ static av_cold int g726_decode_init(AVCodecContext *avctx)
{
G726Context* c = avctx->priv_data;
+ if (avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT &&
+ avctx->sample_rate != 8000) {
+ av_log(avctx, AV_LOG_ERROR, "Only 8kHz sample rate is allowed when "
+ "the compliance level is strict. Reduce the compliance level "
+ "if you wish to decode the stream anyway.\n");
+ return AVERROR(EINVAL);
+ }
+
if(avctx->channels != 1){
av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
return -1;