Commit 17e4b064 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '292d1e78'

* commit '292d1e78':
  fate: dependencies for acodec tests
  fate: dependencies for vsynth tests
  fate: add macros useful for conditionally enabling things
  libmp3lame: resize the output buffer if needed

Conflicts:
	tests/fate/acodec.mak
	tests/fate/vcodec.mak
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents eb19d89d 292d1e78
...@@ -44,8 +44,9 @@ typedef struct LAMEContext { ...@@ -44,8 +44,9 @@ typedef struct LAMEContext {
AVClass *class; AVClass *class;
AVCodecContext *avctx; AVCodecContext *avctx;
lame_global_flags *gfp; lame_global_flags *gfp;
uint8_t buffer[BUFFER_SIZE]; uint8_t *buffer;
int buffer_index; int buffer_index;
int buffer_size;
int reservoir; int reservoir;
float *samples_flt[2]; float *samples_flt[2];
AudioFrameQueue afq; AudioFrameQueue afq;
...@@ -53,6 +54,26 @@ typedef struct LAMEContext { ...@@ -53,6 +54,26 @@ typedef struct LAMEContext {
} LAMEContext; } LAMEContext;
static int realloc_buffer(LAMEContext *s)
{
if (!s->buffer || s->buffer_size - s->buffer_index < BUFFER_SIZE) {
uint8_t *tmp;
int new_size = s->buffer_index + 2 * BUFFER_SIZE;
av_dlog(s->avctx, "resizing output buffer: %d -> %d\n", s->buffer_size,
new_size);
tmp = av_realloc(s->buffer, new_size);
if (!tmp) {
av_freep(&s->buffer);
s->buffer_size = s->buffer_index = 0;
return AVERROR(ENOMEM);
}
s->buffer = tmp;
s->buffer_size = new_size;
}
return 0;
}
static av_cold int mp3lame_encode_close(AVCodecContext *avctx) static av_cold int mp3lame_encode_close(AVCodecContext *avctx)
{ {
LAMEContext *s = avctx->priv_data; LAMEContext *s = avctx->priv_data;
...@@ -62,6 +83,7 @@ static av_cold int mp3lame_encode_close(AVCodecContext *avctx) ...@@ -62,6 +83,7 @@ static av_cold int mp3lame_encode_close(AVCodecContext *avctx)
#endif #endif
av_freep(&s->samples_flt[0]); av_freep(&s->samples_flt[0]);
av_freep(&s->samples_flt[1]); av_freep(&s->samples_flt[1]);
av_freep(&s->buffer);
ff_af_queue_close(&s->afq); ff_af_queue_close(&s->afq);
...@@ -142,6 +164,10 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx) ...@@ -142,6 +164,10 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
} }
} }
ret = realloc_buffer(s);
if (ret < 0)
goto error;
ff_dsputil_init(&s->dsp, avctx); ff_dsputil_init(&s->dsp, avctx);
return 0; return 0;
...@@ -155,7 +181,7 @@ error: ...@@ -155,7 +181,7 @@ error:
(const buf_type *)buf_name[0], \ (const buf_type *)buf_name[0], \
(const buf_type *)buf_name[1], frame->nb_samples, \ (const buf_type *)buf_name[1], frame->nb_samples, \
s->buffer + s->buffer_index, \ s->buffer + s->buffer_index, \
BUFFER_SIZE - s->buffer_index); \ s->buffer_size - s->buffer_index); \
} while (0) } while (0)
static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
...@@ -198,11 +224,16 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -198,11 +224,16 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
if (lame_result == -1) { if (lame_result == -1) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"lame: output buffer too small (buffer index: %d, free bytes: %d)\n", "lame: output buffer too small (buffer index: %d, free bytes: %d)\n",
s->buffer_index, BUFFER_SIZE - s->buffer_index); s->buffer_index, s->buffer_size - s->buffer_index);
} }
return -1; return -1;
} }
s->buffer_index += lame_result; s->buffer_index += lame_result;
ret = realloc_buffer(s);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "error reallocating output buffer\n");
return ret;
}
/* add current frame to the queue */ /* add current frame to the queue */
if (frame) { if (frame) {
......
...@@ -41,6 +41,19 @@ tests/data/ffprobe-test.nut: ffmpeg$(EXESUF) | tests/data ...@@ -41,6 +41,19 @@ tests/data/ffprobe-test.nut: ffmpeg$(EXESUF) | tests/data
tests/data/%.sw tests/data/asynth% tests/data/vsynth%.yuv tests/vsynth%/00.pgm tests/data/%.nut: TAG = GEN tests/data/%.sw tests/data/asynth% tests/data/vsynth%.yuv tests/vsynth%/00.pgm tests/data/%.nut: TAG = GEN
ALLYES = $(strip $(call XYES, $(1)))
XYES = $(if $(strip $(1)), \
$(if $(CONFIG_$(firstword $(1))), \
$(call XYES, $(wordlist 2, $(words $(1)), $(1)))), \
yes)
ENCDEC = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword $(1))_DECODER \
$(firstword $(2))_MUXER $(lastword $(2))_DEMUXER)
ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword $(1))_DECODER \
$(firstword $(2))_ENCODER $(lastword $(2))_DECODER \
$(firstword $(3))_MUXER $(lastword $(3))_DEMUXER)
include $(SRC_PATH)/tests/fate/acodec.mak include $(SRC_PATH)/tests/fate/acodec.mak
include $(SRC_PATH)/tests/fate/vcodec.mak include $(SRC_PATH)/tests/fate/vcodec.mak
......
...@@ -3,15 +3,22 @@ fate-acodec-%: SRC = tests/data/asynth-44100-2.wav ...@@ -3,15 +3,22 @@ fate-acodec-%: SRC = tests/data/asynth-44100-2.wav
fate-acodec-%: CMD = enc_dec wav $(SRC) $(FMT) "-b 128k -c $(CODEC) $(ENCOPTS)" wav "-c pcm_s16le $(DECOPTS)" -keep fate-acodec-%: CMD = enc_dec wav $(SRC) $(FMT) "-b 128k -c $(CODEC) $(ENCOPTS)" wav "-c pcm_s16le $(DECOPTS)" -keep
fate-acodec-%: CMP_UNIT = 2 fate-acodec-%: CMP_UNIT = 2
FATE_ACODEC_PCM = alaw mulaw \ FATE_ACODEC_PCM-$(call ENCDEC, PCM_ALAW, WAV) += alaw
s8 u8 \ FATE_ACODEC_PCM-$(call ENCDEC, PCM_MULAW, WAV) += mulaw
s16be s16le \ FATE_ACODEC_PCM-$(call ENCDEC, PCM_S8, MOV) += s8
s24be s24le \ FATE_ACODEC_PCM-$(call ENCDEC, PCM_U8, WAV) += u8
s32be s32le \ FATE_ACODEC_PCM-$(call ENCDEC, PCM_S16BE, MOV) += s16be
f32be f32le \ FATE_ACODEC_PCM-$(call ENCDEC, PCM_S16LE, WAV) += s16le
f64be f64le FATE_ACODEC_PCM-$(call ENCDEC, PCM_S24BE, MOV) += s24be
FATE_ACODEC_PCM-$(call ENCDEC, PCM_S24LE, WAV) += s24le
FATE_ACODEC += $(FATE_ACODEC_PCM:%=fate-acodec-pcm-%) FATE_ACODEC_PCM-$(call ENCDEC, PCM_S32BE, MOV) += s32be
FATE_ACODEC_PCM-$(call ENCDEC, PCM_S32LE, WAV) += s32le
FATE_ACODEC_PCM-$(call ENCDEC, PCM_F32BE, AU) += f32be
FATE_ACODEC_PCM-$(call ENCDEC, PCM_F32LE, WAV) += f32le
FATE_ACODEC_PCM-$(call ENCDEC, PCM_F64BE, AU) += f64be
FATE_ACODEC_PCM-$(call ENCDEC, PCM_F64LE, WAV) += f64le
FATE_ACODEC += $(FATE_ACODEC_PCM-yes:%=fate-acodec-pcm-%)
fate-acodec-pcm-%: FMT = wav fate-acodec-pcm-%: FMT = wav
fate-acodec-pcm-%: CODEC = pcm_$(@:fate-acodec-pcm-%=%) fate-acodec-pcm-%: CODEC = pcm_$(@:fate-acodec-pcm-%=%)
...@@ -20,8 +27,14 @@ fate-acodec-pcm-s8: FMT = mov ...@@ -20,8 +27,14 @@ fate-acodec-pcm-s8: FMT = mov
fate-acodec-pcm-s%be: FMT = mov fate-acodec-pcm-s%be: FMT = mov
fate-acodec-pcm-f%be: FMT = au fate-acodec-pcm-f%be: FMT = au
FATE_ACODEC_ADPCM = adx ima_qt ima_wav ms swf yamaha FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_ADX, ADX) += adx
FATE_ACODEC += $(FATE_ACODEC_ADPCM:%=fate-acodec-adpcm-%) FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_IMA_QT, AIFF) += ima_qt
FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_IMA_WAV, WAV) += ima_wav
FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_MS, WAV) += ms
FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_SWF, FLV) += swf
FATE_ACODEC_ADPCM-$(call ENCDEC, ADPCM_YAMAHA, WAV) += yamaha
FATE_ACODEC += $(FATE_ACODEC_ADPCM-yes:%=fate-acodec-adpcm-%)
fate-acodec-adpcm-%: CODEC = adpcm_$(@:fate-acodec-adpcm-%=%) fate-acodec-adpcm-%: CODEC = adpcm_$(@:fate-acodec-adpcm-%=%)
...@@ -32,11 +45,11 @@ fate-acodec-adpcm-ms: FMT = wav ...@@ -32,11 +45,11 @@ fate-acodec-adpcm-ms: FMT = wav
fate-acodec-adpcm-swf: FMT = flv fate-acodec-adpcm-swf: FMT = flv
fate-acodec-adpcm-yamaha: FMT = wav fate-acodec-adpcm-yamaha: FMT = wav
FATE_ACODEC += fate-acodec-mp2 FATE_ACODEC-$(call ENCDEC, MP2, MP2 MP3) += fate-acodec-mp2
fate-acodec-mp2: FMT = mp2 fate-acodec-mp2: FMT = mp2
fate-acodec-mp2: CMP_SHIFT = -1924 fate-acodec-mp2: CMP_SHIFT = -1924
FATE_ACODEC += fate-acodec-alac FATE_ACODEC-$(call ENCDEC, ALAC, MOV) += fate-acodec-alac
fate-acodec-alac: FMT = mov fate-acodec-alac: FMT = mov
fate-acodec-alac: CODEC = alac -compression_level 1 fate-acodec-alac: CODEC = alac -compression_level 1
...@@ -55,7 +68,7 @@ fate-acodec-dca2: CMP_SHIFT = -1920 ...@@ -55,7 +68,7 @@ fate-acodec-dca2: CMP_SHIFT = -1920
fate-acodec-dca2: CMP_TARGET = 2424 fate-acodec-dca2: CMP_TARGET = 2424
fate-acodec-dca2: SIZE_TOLERANCE = 544 fate-acodec-dca2: SIZE_TOLERANCE = 544
FATE_ACODEC += fate-acodec-flac FATE_ACODEC-$(call ENCDEC, FLAC, FLAC) += fate-acodec-flac
fate-acodec-flac: FMT = flac fate-acodec-flac: FMT = flac
fate-acodec-flac: CODEC = flac -compression_level 2 fate-acodec-flac: CODEC = flac -compression_level 2
...@@ -82,6 +95,8 @@ fate-acodec-roqaudio: CODEC = roq_dpcm ...@@ -82,6 +95,8 @@ fate-acodec-roqaudio: CODEC = roq_dpcm
fate-acodec-roqaudio: ENCOPTS = -ar 22050 fate-acodec-roqaudio: ENCOPTS = -ar 22050
fate-acodec-roqaudio: DECOPTS = -ar 44100 fate-acodec-roqaudio: DECOPTS = -ar 44100
FATE_ACODEC += $(FATE_ACODEC-yes)
$(FATE_ACODEC): tests/data/asynth-44100-2.wav $(FATE_ACODEC): tests/data/asynth-44100-2.wav
FATE_AVCONV += $(FATE_ACODEC) FATE_AVCONV += $(FATE_ACODEC)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment