This does not change any current behavior, but it does more clearly define it. --- libavcodec/avcodec.h | 16 +++++++++++----- libavcodec/g722enc.c | 1 + libavcodec/pcm.c | 1 + 3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 1715bbb..657ea92 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -773,6 +773,10 @@ typedef struct RcOverride{ * Codec supports slice-based (or partition-based) multithreading. */ #define CODEC_CAP_SLICE_THREADS 0x2000 +/** + * 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 @@ -4132,9 +4136,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 @@ -4142,8 +4147,9 @@ 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 - * buf_size * input_sample_size / output_sample_size. + * For codecs supporting CODEC_CAP_VARIABLE_FRAME_SIZE (e.g. PCM and G.722) + * the number of samples read from @a samples is equal to + * @a buf_size * input_sample_size / 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 libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel