From 5d606863c353553488e88dfd89ea5571268d9dca Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 23 Feb 2013 08:20:12 +0100 Subject: [PATCH 1/3] lavc: remove disabled FF_API_OLD_DECODE_AUDIO cruft --- libavcodec/avcodec.h | 65 -------------------------------------------- libavcodec/utils.c | 48 -------------------------------- libavcodec/version.h | 3 -- 3 files changed, 116 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index b3bdb61bbd..7bc7b618c7 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -487,11 +487,6 @@ typedef struct AVCodecDescriptor { */ #define AV_CODEC_PROP_LOSSLESS (1 << 2) -#if FF_API_OLD_DECODE_AUDIO -/* in bytes */ -#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio -#endif - /** * @ingroup lavc_decoding * Required number of additionally allocated bytes at the end of the input bitstream for decoding. @@ -3360,66 +3355,6 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS]); -#if FF_API_OLD_DECODE_AUDIO -/** - * Wrapper function which calls avcodec_decode_audio4. - * - * @deprecated Use avcodec_decode_audio4 instead. - * - * Decode the audio frame of size avpkt->size from avpkt->data into samples. - * Some decoders may support multiple frames in a single AVPacket, such - * decoders would then just decode the first frame. In this case, - * avcodec_decode_audio3 has to be called again with an AVPacket that contains - * the remaining data in order to decode the second frame etc. - * If no frame - * could be outputted, frame_size_ptr is zero. Otherwise, it is the - * decompressed frame size in bytes. - * - * @warning You must set frame_size_ptr to the allocated size of the - * output buffer before calling avcodec_decode_audio3(). - * - * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than - * the actual read bytes because some optimized bitstream readers read 32 or 64 - * bits at once and could read over the end. - * - * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that - * no overreading happens for damaged MPEG streams. - * - * @warning You must not provide a custom get_buffer() when using - * avcodec_decode_audio3(). Doing so will override it with - * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead, - * which does allow the application to provide a custom get_buffer(). - * - * @note You might have to align the input buffer avpkt->data and output buffer - * samples. The alignment requirements depend on the CPU: On some CPUs it isn't - * necessary at all, on others it won't work at all if not aligned and on others - * it will work but it will have an impact on performance. - * - * In practice, avpkt->data should have 4 byte alignment at minimum and - * samples should be 16 byte aligned unless the CPU doesn't need it - * (AltiVec and SSE do). - * - * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay - * between input and output, these need to be fed with avpkt->data=NULL, - * avpkt->size=0 at the end to return the remaining frames. - * - * @param avctx the codec context - * @param[out] samples the output buffer, sample type in avctx->sample_fmt - * If the sample format is planar, each channel plane will - * be the same size, with no padding between channels. - * @param[in,out] frame_size_ptr the output buffer size in bytes - * @param[in] avpkt The input AVPacket containing the input buffer. - * You can create such packet with av_init_packet() and by then setting - * data and size, some decoders might in addition need other fields. - * All decoders are designed to use the least fields possible though. - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame data was decompressed (used) from the input AVPacket. - */ -attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - AVPacket *avpkt); -#endif - /** * Decode the audio frame of size avpkt->size from avpkt->data into frame. * diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 25914282dc..ed39c0c3f1 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1523,54 +1523,6 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi return ret; } -#if FF_API_OLD_DECODE_AUDIO -int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - AVPacket *avpkt) -{ - AVFrame frame = { { 0 } }; - int ret, got_frame = 0; - - if (avctx->get_buffer != avcodec_default_get_buffer) { - av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with" - "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n"); - av_log(avctx, AV_LOG_ERROR, "Please port your application to " - "avcodec_decode_audio4()\n"); - avctx->get_buffer = avcodec_default_get_buffer; - } - - ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt); - - if (ret >= 0 && got_frame) { - int ch, plane_size; - int planar = av_sample_fmt_is_planar(avctx->sample_fmt); - int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels, - frame.nb_samples, - avctx->sample_fmt, 1); - if (*frame_size_ptr < data_size) { - av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for " - "the current frame (%d < %d)\n", *frame_size_ptr, data_size); - return AVERROR(EINVAL); - } - - memcpy(samples, frame.extended_data[0], plane_size); - - if (planar && avctx->channels > 1) { - uint8_t *out = ((uint8_t *)samples) + plane_size; - for (ch = 1; ch < avctx->channels; ch++) { - memcpy(out, frame.extended_data[ch], plane_size); - out += plane_size; - } - } - *frame_size_ptr = data_size; - } else { - *frame_size_ptr = 0; - } - return ret; -} - -#endif - int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, diff --git a/libavcodec/version.h b/libavcodec/version.h index 76d686d6d4..f1cc74961a 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -49,9 +49,6 @@ #ifndef FF_API_REQUEST_CHANNELS #define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 56) #endif -#ifndef FF_API_OLD_DECODE_AUDIO -#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55) -#endif #ifndef FF_API_OLD_ENCODE_AUDIO #define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55) #endif From f073b1500e3b53835034b7421db0a1cf5bea05a0 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 23 Feb 2013 08:20:12 +0100 Subject: [PATCH 2/3] lavc: remove disabled FF_API_OLD_ENCODE_AUDIO cruft --- libavcodec/aacenc.c | 8 ---- libavcodec/ac3enc.c | 11 ----- libavcodec/adpcmenc.c | 8 ---- libavcodec/adxenc.c | 16 ------- libavcodec/avcodec.h | 30 ------------- libavcodec/flacenc.c | 9 ---- libavcodec/g722enc.c | 11 ----- libavcodec/g726.c | 18 -------- libavcodec/internal.h | 8 ---- libavcodec/libfaac.c | 11 ----- libavcodec/libfdk-aacenc.c | 10 ----- libavcodec/libgsm.c | 11 ----- libavcodec/libilbc.c | 14 ------- libavcodec/libmp3lame.c | 11 ----- libavcodec/libopencore-amr.c | 8 ---- libavcodec/libspeexenc.c | 13 ------ libavcodec/libvo-aacenc.c | 8 ---- libavcodec/libvo-amrwbenc.c | 6 --- libavcodec/libvorbis.c | 11 ----- libavcodec/mpegaudioenc.c | 15 ------- libavcodec/nellymoserenc.c | 11 ----- libavcodec/ra144enc.c | 11 ----- libavcodec/roqaudioenc.c | 11 ----- libavcodec/utils.c | 81 ------------------------------------ libavcodec/version.h | 3 -- libavcodec/vorbisenc.c | 11 ----- libavcodec/wma.c | 5 --- libavcodec/wmaenc.c | 5 --- 28 files changed, 375 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 5d15e85bde..60eca59ae0 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -683,9 +683,6 @@ static av_cold int aac_encode_end(AVCodecContext *avctx) av_freep(&s->buffer.samples); av_freep(&s->cpe); ff_af_queue_close(&s->afq); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif return 0; } @@ -719,11 +716,6 @@ static av_cold int alloc_buffers(AVCodecContext *avctx, AACEncContext *s) for(ch = 0; ch < s->channels; ch++) s->planar_samples[ch] = s->buffer.samples + 3 * 1024 * ch; -#if FF_API_OLD_ENCODE_AUDIO - if (!(avctx->coded_frame = avcodec_alloc_frame())) - goto alloc_fail; -#endif - return 0; alloc_fail: return AVERROR(ENOMEM); diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index b3be2dbf10..df86f0bd94 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2052,9 +2052,6 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) s->mdct_end(s); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif return 0; } @@ -2484,14 +2481,6 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) if (ret) goto init_fail; -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame= avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto init_fail; - } -#endif - ff_dsputil_init(&s->dsp, avctx); avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT); diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index f81d7fde83..9bcbc42b23 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -142,11 +142,6 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) goto error; } -#if FF_API_OLD_ENCODE_AUDIO - if (!(avctx->coded_frame = avcodec_alloc_frame())) - goto error; -#endif - return 0; error: av_freep(&s->paths); @@ -159,9 +154,6 @@ error: static av_cold int adpcm_encode_close(AVCodecContext *avctx) { ADPCMEncodeContext *s = avctx->priv_data; -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&s->paths); av_freep(&s->node_buf); av_freep(&s->nodep_buf); diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index 7a9c06a591..47620a22dd 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -107,14 +107,6 @@ static int adx_encode_header(AVCodecContext *avctx, uint8_t *buf, int bufsize) return HEADER_SIZE; } -#if FF_API_OLD_ENCODE_AUDIO -static av_cold int adx_encode_close(AVCodecContext *avctx) -{ - av_freep(&avctx->coded_frame); - return 0; -} -#endif - static av_cold int adx_encode_init(AVCodecContext *avctx) { ADXContext *c = avctx->priv_data; @@ -125,11 +117,6 @@ static av_cold int adx_encode_init(AVCodecContext *avctx) } avctx->frame_size = BLOCK_SAMPLES; -#if FF_API_OLD_ENCODE_AUDIO - if (!(avctx->coded_frame = avcodec_alloc_frame())) - return AVERROR(ENOMEM); -#endif - /* the cutoff can be adjusted, but this seems to work pretty well */ c->cutoff = 500; ff_adx_calculate_coeffs(c->cutoff, avctx->sample_rate, COEFF_BITS, c->coeff); @@ -177,9 +164,6 @@ AVCodec ff_adpcm_adx_encoder = { .id = AV_CODEC_ID_ADPCM_ADX, .priv_data_size = sizeof(ADXContext), .init = adx_encode_init, -#if FF_API_OLD_ENCODE_AUDIO - .close = adx_encode_close, -#endif .encode2 = adx_encode_frame, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7bc7b618c7..0d4ac318cd 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3685,36 +3685,6 @@ AVCodec *avcodec_find_encoder(enum AVCodecID id); */ AVCodec *avcodec_find_encoder_by_name(const char *name); -#if FF_API_OLD_ENCODE_AUDIO -/** - * Encode an audio frame from samples into buf. - * - * @deprecated Use avcodec_encode_audio2 instead. - * - * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. - * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) 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 - * @param[in] buf_size the output buffer size - * @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 codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of - * samples read from samples is equal to: - * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id)) - * This also implies that av_get_bits_per_sample() must not return 0 for these - * codecs. - * @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. - */ -int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx, - uint8_t *buf, int buf_size, - const short *samples); -#endif - /** * Encode a frame of audio. * diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 7808e2059c..1699312c8c 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -394,12 +394,6 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) s->frame_count = 0; s->min_framesize = s->max_framesize; -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); -#endif - ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->options.max_prediction_order, FF_LPC_TYPE_LEVINSON); @@ -1285,9 +1279,6 @@ static av_cold int flac_encode_close(AVCodecContext *avctx) } av_freep(&avctx->extradata); avctx->extradata_size = 0; -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif return 0; } diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c index 11d3f20933..b168a92d55 100644 --- a/libavcodec/g722enc.c +++ b/libavcodec/g722enc.c @@ -52,9 +52,6 @@ static av_cold int g722_encode_close(AVCodecContext *avctx) av_freep(&c->node_buf[i]); av_freep(&c->nodep_buf[i]); } -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif return 0; } @@ -122,14 +119,6 @@ static av_cold int g722_encode_init(AVCodecContext * avctx) } } -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - return 0; error: g722_encode_close(avctx); diff --git a/libavcodec/g726.c b/libavcodec/g726.c index e1448a1487..6db00feb31 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -331,13 +331,6 @@ static av_cold int g726_encode_init(AVCodecContext *avctx) g726_reset(c); -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - avctx->coded_frame->key_frame = 1; -#endif - /* select a frame size that will end on a byte boundary and have a size of approximately 1024 bytes */ avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[c->code_size - 2]; @@ -345,14 +338,6 @@ static av_cold int g726_encode_init(AVCodecContext *avctx) return 0; } -#if FF_API_OLD_ENCODE_AUDIO -static av_cold int g726_encode_close(AVCodecContext *avctx) -{ - av_freep(&avctx->coded_frame); - return 0; -} -#endif - static int g726_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { @@ -404,9 +389,6 @@ AVCodec ff_adpcm_g726_encoder = { .priv_data_size = sizeof(G726Context), .init = g726_encode_init, .encode2 = g726_encode_frame, -#if FF_API_OLD_ENCODE_AUDIO - .close = g726_encode_close, -#endif .capabilities = CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 3f28d4b00a..65437edc54 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -76,14 +76,6 @@ typedef struct AVCodecInternal { */ int allocate_progress; -#if FF_API_OLD_ENCODE_AUDIO - /** - * Internal sample count used by avcodec_encode_audio() to fabricate pts. - * Can be removed along with avcodec_encode_audio(). - */ - int sample_count; -#endif - /** * An audio frame with less than required samples has been submitted and * padded with silence. Reject all subsequent frames. diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c index d32e776678..6359344192 100644 --- a/libavcodec/libfaac.c +++ b/libavcodec/libfaac.c @@ -46,9 +46,6 @@ static av_cold int Faac_encode_close(AVCodecContext *avctx) { FaacAudioContext *s = avctx->priv_data; -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&avctx->extradata); ff_af_queue_close(&s->afq); @@ -133,14 +130,6 @@ static av_cold int Faac_encode_init(AVCodecContext *avctx) avctx->frame_size = samples_input / avctx->channels; -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame= avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - /* Set decoder specific info */ avctx->extradata_size = 0; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c index db32e9fe4a..ef154c1adb 100644 --- a/libavcodec/libfdk-aacenc.c +++ b/libavcodec/libfdk-aacenc.c @@ -97,9 +97,6 @@ static int aac_encode_close(AVCodecContext *avctx) if (s->handle) aacEncClose(&s->handle); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&avctx->extradata); ff_af_queue_close(&s->afq); @@ -275,13 +272,6 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) goto error; } -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif avctx->frame_size = info.frameLength; avctx->delay = info.encoderDelay; ff_af_queue_init(avctx, &s->afq); diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c index 3159f286da..ddf7b2367d 100644 --- a/libavcodec/libgsm.c +++ b/libavcodec/libgsm.c @@ -77,21 +77,10 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) { } } -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame= avcodec_alloc_frame(); - if (!avctx->coded_frame) { - gsm_destroy(avctx->priv_data); - return AVERROR(ENOMEM); - } -#endif - return 0; } static av_cold int libgsm_encode_close(AVCodecContext *avctx) { -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif gsm_destroy(avctx->priv_data); avctx->priv_data = NULL; return 0; diff --git a/libavcodec/libilbc.c b/libavcodec/libilbc.c index d47227cada..714fdb0210 100644 --- a/libavcodec/libilbc.c +++ b/libavcodec/libilbc.c @@ -153,23 +153,10 @@ static av_cold int ilbc_encode_init(AVCodecContext *avctx) avctx->block_align = s->encoder.no_of_bytes; avctx->frame_size = s->encoder.blockl; -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); -#endif return 0; } -static av_cold int ilbc_encode_close(AVCodecContext *avctx) -{ -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif - return 0; -} - static int ilbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { @@ -200,7 +187,6 @@ AVCodec ff_libilbc_encoder = { .priv_data_size = sizeof(ILBCEncContext), .init = ilbc_encode_init, .encode2 = ilbc_encode_frame, - .close = ilbc_encode_close, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"), diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 2e501cac0b..5e7caf8c0a 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -78,9 +78,6 @@ static av_cold int mp3lame_encode_close(AVCodecContext *avctx) { LAMEContext *s = avctx->priv_data; -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&s->samples_flt[0]); av_freep(&s->samples_flt[1]); av_freep(&s->buffer); @@ -142,14 +139,6 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx) avctx->frame_size = lame_get_framesize(s->gfp); -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - /* allocate float sample buffers */ if (avctx->sample_fmt == AV_SAMPLE_FMT_FLTP) { int ch; diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index 71a0edbfdf..d46ddd7c9d 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -202,11 +202,6 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx) avctx->frame_size = 160; avctx->delay = 50; ff_af_queue_init(avctx, &s->afq); -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); -#endif s->enc_state = Encoder_Interface_init(s->enc_dtx); if (!s->enc_state) { @@ -227,9 +222,6 @@ static av_cold int amr_nb_encode_close(AVCodecContext *avctx) Encoder_Interface_exit(s->enc_state); ff_af_queue_close(&s->afq); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif return 0; } diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 4277e62e4c..9469a76288 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -251,16 +251,6 @@ static av_cold int encode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "memory allocation error\n"); return AVERROR(ENOMEM); } -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - av_freep(&avctx->extradata); - speex_header_free(header_data); - speex_encoder_destroy(s->enc_state); - av_log(avctx, AV_LOG_ERROR, "memory allocation error\n"); - return AVERROR(ENOMEM); - } -#endif /* copy header packet to extradata */ memcpy(avctx->extradata, header_data, header_size); @@ -329,9 +319,6 @@ static av_cold int encode_close(AVCodecContext *avctx) speex_encoder_destroy(s->enc_state); ff_af_queue_close(&s->afq); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&avctx->extradata); return 0; diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index 31822b5d73..3e5efb3466 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -47,9 +47,6 @@ static int aac_encode_close(AVCodecContext *avctx) AACContext *s = avctx->priv_data; s->codec_api.Uninit(s->handle); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&avctx->extradata); ff_af_queue_close(&s->afq); av_freep(&s->end_buffer); @@ -63,11 +60,6 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) AACENC_PARAM params = { 0 }; int index, ret; -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); -#endif avctx->frame_size = FRAME_SIZE; avctx->delay = ENC_DELAY; s->last_frame = 2; diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index 6502456462..af6ddf4ed8 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -94,11 +94,6 @@ static av_cold int amr_wb_encode_init(AVCodecContext *avctx) avctx->frame_size = 320; avctx->delay = 80; -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); -#endif s->state = E_IF_init(); @@ -110,7 +105,6 @@ static int amr_wb_encode_close(AVCodecContext *avctx) AMRWBContext *s = avctx->priv_data; E_IF_exit(s->state); - av_freep(&avctx->coded_frame); return 0; } diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c index 092cbbc0a7..8e02057a38 100644 --- a/libavcodec/libvorbis.c +++ b/libavcodec/libvorbis.c @@ -162,9 +162,6 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avctx) av_fifo_free(s->pkt_fifo); ff_af_queue_close(&s->afq); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&avctx->extradata); return 0; @@ -241,14 +238,6 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx) goto error; } -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - return 0; error: oggvorbis_encode_close(avctx); diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c index ba0d8cfcab..76e7b88fce 100644 --- a/libavcodec/mpegaudioenc.c +++ b/libavcodec/mpegaudioenc.c @@ -184,12 +184,6 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) total_quant_bits[i] = 12 * v; } -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame= avcodec_alloc_frame(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); -#endif - return 0; } @@ -771,14 +765,6 @@ static int MPA_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, return 0; } -static av_cold int MPA_encode_close(AVCodecContext *avctx) -{ -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif - return 0; -} - static const AVCodecDefault mp2_defaults[] = { { "b", "128k" }, { NULL }, @@ -791,7 +777,6 @@ AVCodec ff_mp2_encoder = { .priv_data_size = sizeof(MpegAudioContext), .init = MPA_encode_init, .encode2 = MPA_encode_frame, - .close = MPA_encode_close, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .supported_samplerates = (const int[]){ diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 8721c26f5f..98fef23627 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -140,9 +140,6 @@ static av_cold int encode_end(AVCodecContext *avctx) av_free(s->path); } ff_af_queue_close(&s->afq); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif return 0; } @@ -187,14 +184,6 @@ static av_cold int encode_init(AVCodecContext *avctx) } } -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - return 0; error: encode_end(avctx); diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index b9473ac197..c05c2435d7 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -40,9 +40,6 @@ static av_cold int ra144_encode_close(AVCodecContext *avctx) RA144Context *ractx = avctx->priv_data; ff_lpc_end(&ractx->lpc_ctx); ff_af_queue_close(&ractx->afq); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif return 0; } @@ -71,14 +68,6 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx) ff_af_queue_init(avctx, &ractx->afq); -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - return 0; error: ra144_encode_close(avctx); diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index 3cc9931a33..d440fbe944 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -46,9 +46,6 @@ static av_cold int roq_dpcm_encode_close(AVCodecContext *avctx) { ROQDPCMContext *context = avctx->priv_data; -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&context->frame_buffer); return 0; @@ -81,14 +78,6 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) context->lastSample[0] = context->lastSample[1] = 0; -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame= avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - return 0; error: roq_dpcm_encode_close(avctx); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index ed39c0c3f1..cc7d6d0150 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1245,87 +1245,6 @@ end: return ret; } -#if FF_API_OLD_ENCODE_AUDIO -int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, - uint8_t *buf, int buf_size, - const short *samples) -{ - AVPacket pkt; - AVFrame frame0 = { { 0 } }; - AVFrame *frame; - int ret, samples_size, got_packet; - - av_init_packet(&pkt); - pkt.data = buf; - pkt.size = buf_size; - - if (samples) { - frame = &frame0; - avcodec_get_frame_defaults(frame); - - if (avctx->frame_size) { - frame->nb_samples = avctx->frame_size; - } else { - /* if frame_size is not set, the number of samples must be - * calculated from the buffer size */ - int64_t nb_samples; - if (!av_get_bits_per_sample(avctx->codec_id)) { - av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not " - "support this codec\n"); - return AVERROR(EINVAL); - } - nb_samples = (int64_t)buf_size * 8 / - (av_get_bits_per_sample(avctx->codec_id) * - avctx->channels); - if (nb_samples >= INT_MAX) - return AVERROR(EINVAL); - frame->nb_samples = nb_samples; - } - - /* it is assumed that the samples buffer is large enough based on the - * relevant parameters */ - samples_size = av_samples_get_buffer_size(NULL, avctx->channels, - frame->nb_samples, - avctx->sample_fmt, 1); - if ((ret = avcodec_fill_audio_frame(frame, avctx->channels, - avctx->sample_fmt, - (const uint8_t *)samples, - samples_size, 1))) - return ret; - - /* fabricate frame pts from sample count. - * this is needed because the avcodec_encode_audio() API does not have - * a way for the user to provide pts */ - frame->pts = ff_samples_to_time_base(avctx, - avctx->internal->sample_count); - avctx->internal->sample_count += frame->nb_samples; - } else { - frame = NULL; - } - - got_packet = 0; - ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet); - if (!ret && got_packet && avctx->coded_frame) { - avctx->coded_frame->pts = pkt.pts; - avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY); - } - /* free any side data since we cannot return it */ - if (pkt.side_data_elems > 0) { - int i; - for (i = 0; i < pkt.side_data_elems; i++) - av_free(pkt.side_data[i].data); - av_freep(&pkt.side_data); - pkt.side_data_elems = 0; - } - - if (frame && frame->extended_data != frame->data) - av_free(frame->extended_data); - - return ret ? ret : pkt.size; -} - -#endif - #if FF_API_OLD_ENCODE_VIDEO int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVFrame *pict) diff --git a/libavcodec/version.h b/libavcodec/version.h index f1cc74961a..efd5d34688 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -49,9 +49,6 @@ #ifndef FF_API_REQUEST_CHANNELS #define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 56) #endif -#ifndef FF_API_OLD_ENCODE_AUDIO -#define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55) -#endif #ifndef FF_API_OLD_ENCODE_VIDEO #define FF_API_OLD_ENCODE_VIDEO (LIBAVCODEC_VERSION_MAJOR < 55) #endif diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 3d4f806ae5..db0394a7dc 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -1156,9 +1156,6 @@ static av_cold int vorbis_encode_close(AVCodecContext *avctx) ff_mdct_end(&venc->mdct[0]); ff_mdct_end(&venc->mdct[1]); -#if FF_API_OLD_ENCODE_AUDIO - av_freep(&avctx->coded_frame); -#endif av_freep(&avctx->extradata); return 0 ; @@ -1190,14 +1187,6 @@ static av_cold int vorbis_encode_init(AVCodecContext *avctx) avctx->frame_size = 1 << (venc->log2_blocksize[0] - 1); -#if FF_API_OLD_ENCODE_AUDIO - avctx->coded_frame = avcodec_alloc_frame(); - if (!avctx->coded_frame) { - ret = AVERROR(ENOMEM); - goto error; - } -#endif - return 0; error: vorbis_encode_close(avctx); diff --git a/libavcodec/wma.c b/libavcodec/wma.c index ab7bcf53a8..03e310bc94 100644 --- a/libavcodec/wma.c +++ b/libavcodec/wma.c @@ -386,11 +386,6 @@ int ff_wma_end(AVCodecContext *avctx) av_free(s->int_table[i]); } -#if FF_API_OLD_ENCODE_AUDIO - if (av_codec_is_encoder(avctx->codec)) - av_freep(&avctx->coded_frame); -#endif - return 0; } diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index f110f89465..adaa7b37e2 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -52,11 +52,6 @@ static int encode_init(AVCodecContext * avctx){ return AVERROR(EINVAL); } -#if FF_API_OLD_ENCODE_AUDIO - if (!(avctx->coded_frame = avcodec_alloc_frame())) - return AVERROR(ENOMEM); -#endif - /* extract flag infos */ flags1 = 0; flags2 = 1; From 0f24a3ca999a702f83af9307f9f47b6fdeb546a5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 23 Feb 2013 08:20:12 +0100 Subject: [PATCH 3/3] lavc: remove disabled FF_API_OLD_ENCODE_VIDEO cruft --- libavcodec/avcodec.h | 20 -------------------- libavcodec/utils.c | 36 ------------------------------------ libavcodec/version.h | 3 --- 3 files changed, 59 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0d4ac318cd..c926d5bbc7 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3726,26 +3726,6 @@ AVCodec *avcodec_find_encoder_by_name(const char *name); int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr); -#if FF_API_OLD_ENCODE_VIDEO -/** - * @deprecated use avcodec_encode_video2() instead. - * - * Encode a video frame from pict into buf. - * The input picture should be - * stored using a specific format, namely avctx.pix_fmt. - * - * @param avctx the codec context - * @param[out] buf the output buffer for the bitstream of encoded frame - * @param[in] buf_size the size of the output buffer in bytes - * @param[in] pict the input picture to encode - * @return On error a negative value is returned, on success zero or the number - * of bytes used from the output buffer. - */ -attribute_deprecated -int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVFrame *pict); -#endif - /** * Encode a frame of video. * diff --git a/libavcodec/utils.c b/libavcodec/utils.c index cc7d6d0150..13efea44c2 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1245,42 +1245,6 @@ end: return ret; } -#if FF_API_OLD_ENCODE_VIDEO -int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVFrame *pict) -{ - AVPacket pkt; - int ret, got_packet = 0; - - if (buf_size < FF_MIN_BUFFER_SIZE) { - av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); - return -1; - } - - av_init_packet(&pkt); - pkt.data = buf; - pkt.size = buf_size; - - ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet); - if (!ret && got_packet && avctx->coded_frame) { - avctx->coded_frame->pts = pkt.pts; - avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY); - } - - /* free any side data since we cannot return it */ - if (pkt.side_data_elems > 0) { - int i; - for (i = 0; i < pkt.side_data_elems; i++) - av_free(pkt.side_data[i].data); - av_freep(&pkt.side_data); - pkt.side_data_elems = 0; - } - - return ret ? ret : pkt.size; -} - -#endif - int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, diff --git a/libavcodec/version.h b/libavcodec/version.h index efd5d34688..4f928144ee 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -49,9 +49,6 @@ #ifndef FF_API_REQUEST_CHANNELS #define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 56) #endif -#ifndef FF_API_OLD_ENCODE_VIDEO -#define FF_API_OLD_ENCODE_VIDEO (LIBAVCODEC_VERSION_MAJOR < 55) -#endif #ifndef FF_API_MPV_GLOBAL_OPTS #define FF_API_MPV_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 55) #endif