Commit cd1c12b5 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  FATE: update reference for seek-alac_mp4
  sunrast: Return AVERROR values instead of -1.
  sunrast: Add support for gray8 decoding.
  swscale: enforce a minimum filtersize.
  alacenc: use AVCodec.encode2()
  alacenc: cosmetics: indentation
  alacenc: consolidate bitstream writing into a single function.
  alacenc: only encode frame size in header for a final smaller frame
  alacenc: store current frame size in AlacEncodeContext.
  alacenc: return AVERROR codes in alac_encode_frame()
  alacenc: calculate a new max frame size for the final small frame
  alacenc: pretty-printing and other cosmetics
  alacenc: fix error handling and potential memleaks in alac_encode_init()
  alacenc: do not set coded_frame->key_frame
  alacenc: do not set bits_per_coded_sample
  alacenc: remove unneeded frame_size check in alac_encode_frame()
  tta: error out if samplerate is zero.
  ttadec: fix invalid free when an error occurs while decoding 24-bit tta
  wavpack: add needed braces for 2 statements inside an if block

Conflicts:
	tests/ref/acodec/alac
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 289520fd b498867d
This diff is collapsed.
......@@ -72,13 +72,14 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
unsigned int w, h, depth, type, maptype, maplength, stride, x, y, len, alen;
uint8_t *ptr, *ptr2 = NULL;
const uint8_t *bufstart = buf;
int ret;
if (avpkt->size < 32)
return AVERROR_INVALIDDATA;
if (AV_RB32(buf) != RAS_MAGIC) {
av_log(avctx, AV_LOG_ERROR, "this is not sunras encoded data\n");
return -1;
return AVERROR_INVALIDDATA;
}
w = AV_RB32(buf + 4);
......@@ -95,15 +96,15 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
}
if (type > RT_FORMAT_IFF) {
av_log(avctx, AV_LOG_ERROR, "invalid (compression) type\n");
return -1;
return AVERROR_INVALIDDATA;
}
if (av_image_check_size(w, h, 0, avctx)) {
av_log(avctx, AV_LOG_ERROR, "invalid image size\n");
return -1;
return AVERROR_INVALIDDATA;
}
if (maptype & ~1) {
av_log(avctx, AV_LOG_ERROR, "invalid colormap type\n");
return -1;
return AVERROR_INVALIDDATA;
}
if (type == RT_FORMAT_TIFF || type == RT_FORMAT_IFF) {
......@@ -129,7 +130,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid depth\n");
return -1;
return AVERROR_INVALIDDATA;
}
if (p->data[0])
......@@ -137,9 +138,9 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
if (avctx->get_buffer(avctx, p) < 0) {
if ((ret = avctx->get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
......@@ -155,7 +156,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
if (maplength % 3 || maplength > 768) {
av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
return -1;
return AVERROR_INVALIDDATA;
}
ptr = p->data[1];
......
......@@ -235,6 +235,9 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
if (s->channels == 0) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid number of channels\n");
return AVERROR_INVALIDDATA;
} else if (avctx->sample_rate == 0) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid samplerate\n");
return AVERROR_INVALIDDATA;
}
switch(s->bps) {
......@@ -354,12 +357,16 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
unary--;
}
if (get_bits_left(&s->gb) < k)
return -1;
if (get_bits_left(&s->gb) < k) {
ret = AVERROR_INVALIDDATA;
goto error;
}
if (k) {
if (k > MIN_CACHE_BITS)
return -1;
if (k > MIN_CACHE_BITS) {
ret = AVERROR_INVALIDDATA;
goto error;
}
value = (unary << k) + get_bits(&s->gb, k);
} else
value = unary;
......@@ -412,8 +419,10 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
}
}
if (get_bits_left(&s->gb) < 32)
return -1;
if (get_bits_left(&s->gb) < 32) {
ret = AVERROR_INVALIDDATA;
goto error;
}
skip_bits_long(&s->gb, 32); // frame crc
// convert to output buffer
......@@ -445,6 +454,11 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
*(AVFrame *)data = s->frame;
return buf_size;
error:
// reset decode buffer
if (s->bps == 3)
s->decode_buffer = NULL;
return ret;
}
static av_cold int tta_decode_close(AVCodecContext *avctx) {
......
......@@ -909,9 +909,10 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
} else {
for (j = 0; j < s->decorr[i].value; j++) {
s->decorr[i].samplesA[j] = wp_exp2(AV_RL16(buf)); buf += 2;
if (s->stereo_in)
if (s->stereo_in) {
s->decorr[i].samplesB[j] = wp_exp2(AV_RL16(buf)); buf += 2;
}
}
t += s->decorr[i].value * 2 * (s->stereo_in + 1);
}
}
......
......@@ -275,7 +275,7 @@ static int initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSi
if (xInc <= 1<<16) filterSize= 1 + sizeFactor; // upscale
else filterSize= 1 + (sizeFactor*srcW + dstW - 1)/ dstW;
if (filterSize > srcW-2) filterSize=srcW-2;
filterSize = av_clip(filterSize, 1, srcW - 2);
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
......
cf9a4b40ab945367cbb0e6cbb4cf37a1 *./tests/data/acodec/alac.m4a
389166 ./tests/data/acodec/alac.m4a
acaed80b0b5bbec7ee9dc0899166a6e2 *./tests/data/acodec/alac.m4a
388910 ./tests/data/acodec/alac.m4a
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/alac.acodec.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 1.857596 pts: 1.857596 pos: 73731 size: 4965
ret: 0 st: 0 flags:1 dts: 1.857596 pts: 1.857596 pos: 73651 size: 4961
ret: 0 st: 0 flags:0 ts: 0.788345
ret: 0 st: 0 flags:1 dts: 0.835918 pts: 0.835918 pos: 29072 size: 3198
ret: 0 st: 0 flags:1 dts: 0.835918 pts: 0.835918 pos: 29036 size: 3194
ret: 0 st: 0 flags:1 ts:-0.317506
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
ret: 0 st:-1 flags:0 ts: 2.576668
ret: 0 st: 0 flags:1 dts: 2.600635 pts: 2.600635 pos: 137669 size: 12847
ret: 0 st: 0 flags:1 dts: 2.600635 pts: 2.600635 pos: 137557 size: 12843
ret: 0 st:-1 flags:1 ts: 1.470835
ret: 0 st: 0 flags:1 dts: 1.393197 pts: 1.393197 pos: 50219 size: 4418
ret: 0 st: 0 flags:1 dts: 1.393197 pts: 1.393197 pos: 50159 size: 4414
ret: 0 st: 0 flags:0 ts: 0.365011
ret: 0 st: 0 flags:1 dts: 0.371519 pts: 0.371519 pos: 12962 size: 3213
ret: 0 st: 0 flags:1 dts: 0.371519 pts: 0.371519 pos: 12946 size: 3209
ret: 0 st: 0 flags:1 ts:-0.740839
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
ret: 0 st:-1 flags:0 ts: 2.153336
ret: 0 st: 0 flags:1 dts: 2.229116 pts: 2.229116 pos: 101031 size: 7900
ret: 0 st: 0 flags:1 dts: 2.229116 pts: 2.229116 pos: 100935 size: 7896
ret: 0 st:-1 flags:1 ts: 1.047503
ret: 0 st: 0 flags:1 dts: 1.021678 pts: 1.021678 pos: 35362 size: 3035
ret: 0 st: 0 flags:1 dts: 1.021678 pts: 1.021678 pos: 35318 size: 3031
ret: 0 st: 0 flags:0 ts:-0.058322
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
ret: 0 st: 0 flags:1 ts: 2.835828
ret: 0 st: 0 flags:1 dts: 2.786395 pts: 2.786395 pos: 163300 size: 12769
ret: 0 st: 0 flags:1 dts: 2.786395 pts: 2.786395 pos: 163180 size: 12765
ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 0 flags:1 dts: 1.764717 pts: 1.764717 pos: 68756 size: 4975
ret: 0 st: 0 flags:1 dts: 1.764717 pts: 1.764717 pos: 68680 size: 4971
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.557279 pts: 0.557279 pos: 19365 size: 3238
ret: 0 st: 0 flags:1 dts: 0.557279 pts: 0.557279 pos: 19341 size: 3234
ret: 0 st: 0 flags:0 ts:-0.481655
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
ret: 0 st: 0 flags:1 ts: 2.412494
ret: 0 st: 0 flags:1 dts: 2.321995 pts: 2.321995 pos: 108931 size: 7890
ret: 0 st: 0 flags:1 dts: 2.321995 pts: 2.321995 pos: 108831 size: 7886
ret: 0 st:-1 flags:0 ts: 1.306672
ret: 0 st: 0 flags:1 dts: 1.393197 pts: 1.393197 pos: 50219 size: 4418
ret: 0 st: 0 flags:1 dts: 1.393197 pts: 1.393197 pos: 50159 size: 4414
ret: 0 st:-1 flags:1 ts: 0.200839
ret: 0 st: 0 flags:1 dts: 0.185760 pts: 0.185760 pos: 6478 size: 3249
ret: 0 st: 0 flags:1 dts: 0.185760 pts: 0.185760 pos: 6470 size: 3245
ret: 0 st: 0 flags:0 ts:-0.904989
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
ret: 0 st: 0 flags:1 ts: 1.989184
ret: 0 st: 0 flags:1 dts: 1.950476 pts: 1.950476 pos: 78696 size: 6518
ret: 0 st: 0 flags:1 dts: 1.950476 pts: 1.950476 pos: 78612 size: 6514
ret: 0 st:-1 flags:0 ts: 0.883340
ret: 0 st: 0 flags:1 dts: 0.928798 pts: 0.928798 pos: 32270 size: 3092
ret: 0 st: 0 flags:1 dts: 0.928798 pts: 0.928798 pos: 32230 size: 3088
ret: 0 st:-1 flags:1 ts:-0.222493
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
ret: 0 st: 0 flags:0 ts: 2.671678
ret: 0 st: 0 flags:1 dts: 2.693515 pts: 2.693515 pos: 150516 size: 12784
ret: 0 st: 0 flags:1 dts: 2.693515 pts: 2.693515 pos: 150400 size: 12780
ret: 0 st: 0 flags:1 ts: 1.565850
ret: 0 st: 0 flags:1 dts: 1.486077 pts: 1.486077 pos: 54637 size: 4558
ret: 0 st: 0 flags:1 dts: 1.486077 pts: 1.486077 pos: 54573 size: 4554
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.464399 pts: 0.464399 pos: 16175 size: 3190
ret: 0 st: 0 flags:1 dts: 0.464399 pts: 0.464399 pos: 16155 size: 3186
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3240
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 40 size: 3236
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