On 09/24/2012 05:56 PM, Nathan Caldwell wrote:
> diff --git a/libavcodec/libopus.h b/libavcodec/libopus.h
> new file mode 100644
> index 0000000..14beb91
> --- /dev/null
> +++ b/libavcodec/libopus.h
> @@ -0,0 +1,43 @@
> +/*
> + * Opus encoder using libopus
> + * Copyright (c) 2012 Nicolas George
libopus.h applies to both the encoder and decoder.
[...]
> + av_log(avctx, AV_LOG_WARNING, "No bit rate set. Defaulting to %d
> bps.\n",
> + avctx->bit_rate);
[...]
> + av_log(avctx, AV_LOG_ERROR, "The bit rate %d bps is unsupported.
> Please choose a value between 500 and %d.\n",
> + avctx->bit_rate, 256000 * avctx->channels);
vertical alignment
[...]
> + opus->samples = av_mallocz(frame_size * avctx->channels *
> (avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? sizeof(float) :
> sizeof(opus_int16)));
[...]
> const int sample_size = avctx->channels * (avctx->sample_fmt ==
> AV_SAMPLE_FMT_FLT ? sizeof(float) : sizeof(opus_int16));
These can use av_get_bytes_per_sample(avctx->sample_fmt)
also please break long lines
[...]
> + if (frame->nb_samples < opus->opts.packet_size) {
> + audio = opus->samples;
> + memcpy(audio, frame->data[0], frame->nb_samples * sample_size);
> + }
> + else
> + audio = frame->data[0];
That will never be true unless you also set CODEC_CAP_SMALL_LAST_FRAME.
Also, put the '}' and 'else' on the same line.
[...]
> + /* FIXME: When DTX is enabled, opus_multistream_encode will return 1 if
> + * a packet does not need to be transmitted.
> + */
If the encoder only uses 1 frame-per-packet, a 0-size frame payload will
result in a 1-byte packet for the TOC. Does libopus actually write that
TOC byte to the output packet? If so, I don't think there is any need
for a FIXME. If not, we could probably just reuse the TOC from the last
packet.
Also, can it return > 1 if it's using multiple frames-per-packet? And if
so, does it also write the appropriate packet header?
-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel