Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-03-01 17:01:17 +0300
committerPaul B Mahol <onemda@gmail.com>2019-03-06 22:31:34 +0300
commit93402561fda4a5dfe9fc48b341b47d79613eaf6d (patch)
tree3b0ede173ded0e5cd075fff0120d92494049fe2f /libavcodec/imm4.c
parent056a2ac16813f826f8a726269e3f6885be261593 (diff)
avcodec/imm4: add support for mid-stream size changes
Diffstat (limited to 'libavcodec/imm4.c')
-rw-r--r--libavcodec/imm4.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
index b72f0be28e..aeb29f5d44 100644
--- a/libavcodec/imm4.c
+++ b/libavcodec/imm4.c
@@ -41,7 +41,6 @@ typedef struct IMM4Context {
uint8_t *bitstream;
int bitstream_size;
- int changed_size;
int factor;
unsigned lo;
unsigned hi;
@@ -370,6 +369,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
IMM4Context *s = avctx->priv_data;
GetBitContext *gb = &s->gb;
AVFrame *frame = data;
+ int width, height;
unsigned type;
int ret, scaled;
@@ -391,9 +391,11 @@ static int decode_frame(AVCodecContext *avctx, void *data,
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
avctx->color_range = AVCOL_RANGE_JPEG;
+ width = avctx->width;
+ height = avctx->height;
+
scaled = avpkt->data[8];
if (scaled < 2) {
- int width, height;
int mode = avpkt->data[10];
switch (mode) {
@@ -422,18 +424,8 @@ static int decode_frame(AVCodecContext *avctx, void *data,
height = 576;
break;
}
-
- if (s->changed_size == 1 &&
- (avctx->width != width || avctx->height != height)) {
- av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
- return AVERROR_INVALIDDATA;
- }
- ret = ff_set_dimensions(avctx, width, height);
- if (ret < 0)
- return ret;
}
- s->changed_size = 1;
skip_bits_long(gb, 24 * 8);
type = get_bits_long(gb, 32);
s->hi = get_bits(gb, 16);
@@ -453,6 +445,17 @@ static int decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_PATCHWELCOME;
}
+ if (!frame->key_frame &&
+ (avctx->width != width ||
+ avctx->height != height)) {
+ av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ ret = ff_set_dimensions(avctx, width, height);
+ if (ret < 0)
+ return ret;
+
if ((ret = ff_get_buffer(avctx, frame, frame->key_frame ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
return ret;