[FFmpeg-devel] [PATCH 1/2] svq1dec: Ensure that pixel format constraints are respected
Michael Niedermayer
michael at niedermayer.cc
Wed Jul 18 13:28:03 EEST 2018
On Tue, Jul 17, 2018 at 09:39:18PM +0200, Vittorio Giovara wrote:
> 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 },
I dont think this is neccessary. but if it is fixing some testcase iam
interrested in that testcase.
Also this seems to break make fate
TEST svq1-headerswap
--- ./tests/ref/fate/svq1-headerswap 2018-07-16 18:42:40.498707547 +0200
+++ tests/data/fate/svq1-headerswap 2018-07-18 12:24:50.225870370 +0200
@@ -4,6 +4,3 @@
#dimensions 0: 293x178
#sar 0: 0/1
0, 0, 0, 1, 58814, 0x5caad04b
-0, 1, 1, 1, 58814, 0x98d8ceb8
-0, 2, 2, 1, 58814, 0x8925cdb0
-0, 3, 3, 1, 58814, 0x6ffc02c3
Test svq1-headerswap failed. Look at tests/data/fate/svq1-headerswap.err for details.
make: *** [fate-svq1-headerswap] Error 69
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180718/7a733641/attachment.sig>
More information about the ffmpeg-devel
mailing list