diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-03-21 15:28:00 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-05-07 12:14:04 -0400 |
commit | b461cd4deb8e8d9698797429b4fe85bfb9208fe6 (patch) | |
tree | 6417ffdf8a28b6537dff5741f44d11342472954f | |
parent | fdc918632f5c16cf377a2170cd2f101933fb15ff (diff) | |
download | ffmpeg-b461cd4deb8e8d9698797429b4fe85bfb9208fe6.tar.gz |
avcodec: remove fallbacks for AVCodec.encode() in avcodec_encode_audio2()
We no longer have any audio encoders using AVCodec.encode().
-rw-r--r-- | libavcodec/utils.c | 70 |
1 files changed, 2 insertions, 68 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 2e8a86c1fa..bfd470b24e 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -864,7 +864,6 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, { int ret; int user_packet = !!avpkt->data; - int nb_samples; *got_packet_ptr = 0; @@ -877,19 +876,15 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, /* check for valid frame size */ if (frame) { - nb_samples = frame->nb_samples; if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { - if (nb_samples > avctx->frame_size) + if (frame->nb_samples > avctx->frame_size) return AVERROR(EINVAL); } else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) { - if (nb_samples != avctx->frame_size) + if (frame->nb_samples != avctx->frame_size) return AVERROR(EINVAL); } - } else { - nb_samples = avctx->frame_size; } - if (avctx->codec->encode2) { ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr); if (!ret && *got_packet_ptr) { if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) { @@ -903,68 +898,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, } else { avpkt->size = 0; } - } else { - /* for compatibility with encoders not supporting encode2(), we need to - allocate a packet buffer if the user has not provided one or check - the size otherwise */ - int fs_tmp = 0; - int buf_size = avpkt->size; - if (!user_packet) { - if (avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) { - av_assert0(av_get_bits_per_sample(avctx->codec_id) != 0); - buf_size = nb_samples * avctx->channels * - av_get_bits_per_sample(avctx->codec_id) / 8; - } else { - /* this is a guess as to the required size. - if an encoder needs more than this, it should probably - implement encode2() */ - buf_size = 2 * avctx->frame_size * avctx->channels * - av_get_bytes_per_sample(avctx->sample_fmt); - buf_size += FF_MIN_BUFFER_SIZE; - } - } - if ((ret = ff_alloc_packet(avpkt, buf_size))) - return ret; - - /* Encoders using AVCodec.encode() that support - CODEC_CAP_SMALL_LAST_FRAME require avctx->frame_size to be set to - the smaller size when encoding the last frame. - This code can be removed once all encoders supporting - CODEC_CAP_SMALL_LAST_FRAME use encode2() */ - if ((avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) && - nb_samples < avctx->frame_size) { - fs_tmp = avctx->frame_size; - avctx->frame_size = nb_samples; - } - /* encode the frame */ - ret = avctx->codec->encode(avctx, avpkt->data, avpkt->size, - frame ? frame->data[0] : NULL); - if (ret >= 0) { - if (!ret) { - /* no output. if the packet data was allocated by libavcodec, - free it */ - if (!user_packet) - av_freep(&avpkt->data); - } else { - if (avctx->coded_frame) - avpkt->pts = avpkt->dts = avctx->coded_frame->pts; - /* Set duration for final small packet. This can be removed - once all encoders supporting CODEC_CAP_SMALL_LAST_FRAME use - encode2() */ - if (fs_tmp) { - avpkt->duration = ff_samples_to_time_base(avctx, - avctx->frame_size); - } - } - avpkt->size = ret; - *got_packet_ptr = (ret > 0); - ret = 0; - } - - if (fs_tmp) - avctx->frame_size = fs_tmp; - } if (!ret) { if (!user_packet && avpkt->size) { uint8_t *new_data = av_realloc(avpkt->data, avpkt->size); |