[FFmpeg-devel] [PATCH 1/2] svq1dec: Ensure that pixel format constraints are respected
Vittorio Giovara
vittorio.giovara at gmail.com
Tue Jul 17 22:39:18 EEST 2018
YUV410P requires that sizes are divisible by 4. There seem to be
some encoders that ignore that and encode a different value in
the bitstream itself. Handle that case by exporting the relative
cropping information.
---
Alternatively it is possible to always enforce mod4 sizes and call
it a day.
Vittorio
libavcodec/svq1dec.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
index d3e60c3a4a..55047b43ce 100644
--- a/libavcodec/svq1dec.c
+++ b/libavcodec/svq1dec.c
@@ -663,7 +663,8 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
return result;
}
- result = ff_set_dimensions(avctx, s->width, s->height);
+ /* sizes must be always disivible by 4 due to pixel format constraints */
+ result = ff_set_dimensions(avctx, FFALIGN(s->width, 4), FFALIGN(s->height, 4));
if (result < 0)
return result;
@@ -755,6 +756,11 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
*got_frame = 1;
result = buf_size;
+ cur->crop_left = 0;
+ cur->crop_top = 0;
+ cur->crop_right = FFALIGN(s->width, 4) - s->width;
+ cur->crop_bottom = FFALIGN(s->height, 4) - s->height;
+
err:
av_free(pmv);
return result;
@@ -843,6 +849,7 @@ AVCodec ff_svq1_decoder = {
.close = svq1_decode_end,
.decode = svq1_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING,
.flush = svq1_flush,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV410P,
AV_PIX_FMT_NONE },
--
2.17.1
More information about the ffmpeg-devel
mailing list