This does not change any current behavior, but it does more clearly define it.
---
avconv.c | 2 +-
libavcodec/avcodec.h | 14 ++++++++++----
libavcodec/g722enc.c | 1 +
libavcodec/pcm.c | 1 +
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/avconv.c b/avconv.c
index f3e6e28..2a45c8e 100644
--- a/avconv.c
+++ b/avconv.c
@@ -1060,7 +1060,7 @@ need_realloc:
}
/* now encode as many frames as possible */
- if (enc->frame_size > 1) {
+ if (!(enc->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
/* output resampled raw samples */
if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) <
0) {
av_log(NULL, AV_LOG_FATAL, "av_fifo_realloc2() failed\n");
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4e80de8..5946ad3 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -777,6 +777,10 @@ typedef struct RcOverride{
* Codec supports changed parameters at any point.
*/
#define CODEC_CAP_PARAM_CHANGE 0x4000
+/**
+ * Audio encoder supports receiving a different number of samples in each call.
+ */
+#define CODEC_CAP_VARIABLE_FRAME_SIZE 0x4000
//The following defines may change, don't expect compatibility if you use them.
#define MB_TYPE_INTRA4x4 0x0001
@@ -4196,9 +4200,10 @@ void avsubtitle_free(AVSubtitle *sub);
* Encode an audio frame from samples into buf.
*
* @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
- * However, for PCM audio the user will know how much space is needed
- * because it depends on the value passed in buf_size as described
- * below. In that case a lower value can be used.
+ * However, for codecs supporting CODEC_CAP_VARIABLE_FRAME_SIZE
+ * (e.g. PCM and G.722) the user will know how much space is needed because it
+ * depends on the value passed in buf_size as described below. In that case a
+ * lower value can be used.
*
* @param avctx the codec context
* @param[out] buf the output buffer
@@ -4206,7 +4211,8 @@ void avsubtitle_free(AVSubtitle *sub);
* @param[in] samples the input buffer containing the samples
* The number of samples read from this buffer is frame_size*channels,
* both of which are defined in avctx.
- * For PCM audio the number of samples read from samples is equal to
+ * For codecs supporting CODEC_CAP_VARIABLE_FRAME_SIZE (e.g. PCM and G.722)
+ * the number of samples read from samples is equal to
* buf_size / (channels * output_sample_size).
* @return On error a negative value is returned, on success zero or the number
* of bytes used to encode the data read from the input buffer.
diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c
index 1eed784..07449c1 100644
--- a/libavcodec/g722enc.c
+++ b/libavcodec/g722enc.c
@@ -306,6 +306,7 @@ AVCodec ff_adpcm_g722_encoder = {
.init = g722_encode_init,
.close = g722_encode_close,
.encode = g722_encode_frame,
+ .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE,
.long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
.sample_fmts = (const enum
AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
};
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 76d5c10..24ff0f9 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -474,6 +474,7 @@ AVCodec ff_ ## name_ ## _encoder = { \
.init = pcm_encode_init, \
.encode = pcm_encode_frame, \
.close = pcm_encode_close, \
+ .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE, \
.sample_fmts = (const enum
AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
}
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel