On 10/27/2012 11:48 AM, Reinhard Tartler wrote: > On Sat, Oct 27, 2012 at 7:26 AM, Justin Ruggles > <justin.rugg...@gmail.com> wrote: >> --- >> libavcodec/flacenc.c | 88 >> +++++++++++++++++++++++++++++++++++-------------- >> 1 files changed, 63 insertions(+), 25 deletions(-) >> >> diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c >> index 0ba9176..19413b3 100644 >> --- a/libavcodec/flacenc.c >> +++ b/libavcodec/flacenc.c >> @@ -92,6 +92,7 @@ typedef struct FlacEncodeContext { >> int channels; >> int samplerate; >> int sr_code[2]; >> + int bps_code; >> int max_blocksize; >> int min_framesize; >> int max_framesize; >> @@ -128,7 +129,7 @@ static void write_streaminfo(FlacEncodeContext *s, >> uint8_t *header) >> put_bits(&pb, 24, s->max_framesize); >> put_bits(&pb, 20, s->samplerate); >> put_bits(&pb, 3, s->channels-1); >> - put_bits(&pb, 5, 15); /* bits per sample - 1 */ >> + put_bits(&pb, 5, s->avctx->bits_per_raw_sample - 1); >> /* write 36-bit sample count in 2 put_bits() calls */ >> put_bits(&pb, 24, (s->sample_count & 0xFFFFFF000LL) >> 12); >> put_bits(&pb, 12, s->sample_count & 0x000000FFFLL); >> @@ -228,8 +229,18 @@ static av_cold int flac_encode_init(AVCodecContext >> *avctx) >> >> s->avctx = avctx; >> >> - if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) >> - return -1; >> + switch (avctx->sample_fmt) { >> + case AV_SAMPLE_FMT_S16: >> + avctx->bits_per_raw_sample = 16; >> + s->bps_code = 4; >> + break; >> + case AV_SAMPLE_FMT_S32: >> + if (avctx->bits_per_raw_sample != 24) >> + av_log(avctx, AV_LOG_WARNING, "encoding as 24 >> bits-per-sample\n"); >> + avctx->bits_per_raw_sample = 24; >> + s->bps_code = 6; >> + break; >> + } > > Doesn't this switch lack a default statement? Before it errored out on > everybad, but now the control flow continues.
The AVCodec.sample_fmts list is already validated in avcodec_open2(). -Justin _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel