On 10.06.2015 12:01, Michael Niedermayer wrote: > On Wed, Jun 10, 2015 at 11:43:16AM +0200, Michael Niedermayer wrote: >> On Tue, Jun 09, 2015 at 11:53:03PM +0200, Andreas Cadhalpun wrote: >>> Inconsistencies between the dimensions of avctx and the frame can >>> confuse API users. For example this can crash the demuxing_decoding >>> example. >>> >>> Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> >>> --- >>> libavcodec/h264.c | 4 ++++ >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/libavcodec/h264.c b/libavcodec/h264.c >>> index 9a00214..d1eaa5e 100644 >>> --- a/libavcodec/h264.c >>> +++ b/libavcodec/h264.c >>> @@ -1757,6 +1757,8 @@ static int h264_decode_frame(AVCodecContext *avctx, >>> void *data, >>> if (ret < 0) >>> return ret; >>> *got_frame = 1; >>> + avctx->width = pict->width; >>> + avctx->height = pict->height; >>> } >> >> iam not sure this is not breaking something, other parts of the h264 >> decoder expect this to be set relative to the last frame in coding >> order.
If that's the case, then I think the h264 decoder should use a field in the private H264Context for that information and not the public fields in AVCodecContext. >> also avctx->pix_fmt would then still potentially not match the last >> output frame, also pix_fmt has the same problem as above Yes, pix_fmt should also be updated. Attached patch does this, but this caused changes in some h264 reinit fate tests. Is that a problem? >> ive fixed one use of width/height not to depend on the AVCodecContext >> value but a 2nd remains > > actually theres more code that uses it > ff_h264_draw_horiz_band() and its callers use h->avctx->height too Could these be fixed to use a new H264Context field instead? On 10.06.2015 02:25, Luca Barbato wrote: > Would be better setting those in output_frame I think, I like the idea. Done. Best regards, Andreas
>From c3d2a2822b6fc72ee735de3d9c6c7f964ea143e5 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> Date: Tue, 9 Jun 2015 23:38:26 +0200 Subject: [PATCH] h264: update avctx width/height/pix_fmt when returning frame Inconsistencies between the dimensions/pixel format of avctx and the frame can confuse API users. For example this can crash the demuxing_decoding example. Also update FATE reference data for some h264-reinit tests. Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> --- libavcodec/h264.c | 4 ++ .../fate/h264-reinit-small_420_8-to-large_444_10 | 44 +++++++++++----------- .../fate/h264-reinit-small_420_9-to-small_420_8 | 44 +++++++++++----------- .../fate/h264-reinit-small_422_9-to-small_420_9 | 44 +++++++++++----------- 4 files changed, 70 insertions(+), 66 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 9a00214..87a600d 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1675,6 +1675,10 @@ static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp) av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(h), 0); + h->avctx->width = dst->width; + h->avctx->height = dst->height; + h->avctx->pix_fmt = dst->format; + if (srcp->sei_recovery_frame_cnt == 0) dst->key_frame = 1; if (!srcp->crop) diff --git a/tests/ref/fate/h264-reinit-small_420_8-to-large_444_10 b/tests/ref/fate/h264-reinit-small_420_8-to-large_444_10 index 7e7631a..8c3b7cf 100644 --- a/tests/ref/fate/h264-reinit-small_420_8-to-large_444_10 +++ b/tests/ref/fate/h264-reinit-small_420_8-to-large_444_10 @@ -50,28 +50,28 @@ 0, 48, 48, 1, 608256, 0x80128077 0, 49, 49, 1, 608256, 0x887c2fb0 0, 50, 50, 1, 608256, 0xfaba3fe4 -0, 51, 51, 1, 608256, 0x0369a227 -0, 52, 52, 1, 608256, 0xe62cb2b1 -0, 53, 53, 1, 608256, 0x851d9e78 -0, 54, 54, 1, 608256, 0x6847b938 -0, 55, 55, 1, 608256, 0x48eb702e -0, 56, 56, 1, 608256, 0x3eb52eec -0, 57, 57, 1, 608256, 0xf880edf8 -0, 58, 58, 1, 608256, 0xf7ac1860 -0, 59, 59, 1, 608256, 0x3ead29f3 -0, 60, 60, 1, 608256, 0x6db1860a -0, 61, 61, 1, 608256, 0x72ee9271 -0, 62, 62, 1, 608256, 0xa8b643e4 -0, 63, 63, 1, 608256, 0x22a95a3e -0, 64, 64, 1, 608256, 0x4e8aa877 -0, 65, 65, 1, 608256, 0x9545cfcf -0, 66, 66, 1, 608256, 0x42d820e0 -0, 67, 67, 1, 608256, 0xe701ea6f -0, 68, 68, 1, 608256, 0x05f61a49 -0, 69, 69, 1, 608256, 0xc1de9f65 -0, 70, 70, 1, 608256, 0x2b121933 -0, 71, 71, 1, 608256, 0x4de4e185 -0, 72, 72, 1, 608256, 0x01c6fb05 +0, 51, 51, 1, 608256, 0x1d58d679 +0, 52, 52, 1, 608256, 0x928af75f +0, 53, 53, 1, 608256, 0xf49afa59 +0, 54, 54, 1, 608256, 0x35b666a8 +0, 55, 55, 1, 608256, 0x9da38f14 +0, 56, 56, 1, 608256, 0xb84bc4ba +0, 57, 57, 1, 608256, 0x3d853c17 +0, 58, 58, 1, 608256, 0x5fb2b454 +0, 59, 59, 1, 608256, 0xfc82c0bd +0, 60, 60, 1, 608256, 0x82f813da +0, 61, 61, 1, 608256, 0xdd105dc8 +0, 62, 62, 1, 608256, 0x15fc38f9 +0, 63, 63, 1, 608256, 0xe2f7730a +0, 64, 64, 1, 608256, 0x5900f414 +0, 65, 65, 1, 608256, 0xa0be1972 +0, 66, 66, 1, 608256, 0x16cfd471 +0, 67, 67, 1, 608256, 0xa0450374 +0, 68, 68, 1, 608256, 0x0eee54b1 +0, 69, 69, 1, 608256, 0x123d9d86 +0, 70, 70, 1, 608256, 0x9ca29c9b +0, 71, 71, 1, 608256, 0x9c979bb0 +0, 72, 72, 1, 608256, 0x1fef7474 0, 73, 73, 1, 608256, 0x1fbf8603 0, 74, 74, 1, 608256, 0x9d8f2fd4 0, 75, 75, 1, 608256, 0xb7d6f14e diff --git a/tests/ref/fate/h264-reinit-small_420_9-to-small_420_8 b/tests/ref/fate/h264-reinit-small_420_9-to-small_420_8 index 662db29..b5821ad 100644 --- a/tests/ref/fate/h264-reinit-small_420_9-to-small_420_8 +++ b/tests/ref/fate/h264-reinit-small_420_9-to-small_420_8 @@ -50,28 +50,28 @@ 0, 48, 48, 1, 608256, 0xb853b650 0, 49, 49, 1, 608256, 0x30d8d033 0, 50, 50, 1, 608256, 0x27a069a3 -0, 51, 51, 1, 608256, 0x22a5ff96 -0, 52, 52, 1, 608256, 0x29ad753f -0, 53, 53, 1, 608256, 0x955788a6 -0, 54, 54, 1, 608256, 0xb73599c5 -0, 55, 55, 1, 608256, 0x73765aca -0, 56, 56, 1, 608256, 0x39118f45 -0, 57, 57, 1, 608256, 0xfb0f8b96 -0, 58, 58, 1, 608256, 0xfcf71085 -0, 59, 59, 1, 608256, 0xccaaca7d -0, 60, 60, 1, 608256, 0xde873299 -0, 61, 61, 1, 608256, 0x5d904202 -0, 62, 62, 1, 608256, 0x1e92c9b8 -0, 63, 63, 1, 608256, 0xdb8ec231 -0, 64, 64, 1, 608256, 0x388e2b9f -0, 65, 65, 1, 608256, 0x1d190c39 -0, 66, 66, 1, 608256, 0xb6609efd -0, 67, 67, 1, 608256, 0x0c6bf1d0 -0, 68, 68, 1, 608256, 0x178e0a3c -0, 69, 69, 1, 608256, 0x439509f7 -0, 70, 70, 1, 608256, 0x00eb29ec -0, 71, 71, 1, 608256, 0xee45f2a0 -0, 72, 72, 1, 608256, 0xae62eb8c +0, 51, 51, 1, 608256, 0xdaf4f6bf +0, 52, 52, 1, 608256, 0xa0e66683 +0, 53, 53, 1, 608256, 0xc1b0f4fd +0, 54, 54, 1, 608256, 0x98f94867 +0, 55, 55, 1, 608256, 0x57c997e9 +0, 56, 56, 1, 608256, 0x88816687 +0, 57, 57, 1, 608256, 0x2727523b +0, 58, 58, 1, 608256, 0xb61df1a1 +0, 59, 59, 1, 608256, 0x27a5b153 +0, 60, 60, 1, 608256, 0xbd4c238a +0, 61, 61, 1, 608256, 0x4059f86f +0, 62, 62, 1, 608256, 0xe6efa416 +0, 63, 63, 1, 608256, 0xeba1fe93 +0, 64, 64, 1, 608256, 0x02ab98d4 +0, 65, 65, 1, 608256, 0x5e2974dd +0, 66, 66, 1, 608256, 0x14542ff4 +0, 67, 67, 1, 608256, 0xc4539662 +0, 68, 68, 1, 608256, 0x2ecf4b28 +0, 69, 69, 1, 608256, 0xa7ba8250 +0, 70, 70, 1, 608256, 0xb6cc58d9 +0, 71, 71, 1, 608256, 0xa97b0f3e +0, 72, 72, 1, 608256, 0xd9f31717 0, 73, 73, 1, 608256, 0x3bb7510d 0, 74, 74, 1, 608256, 0x03f08d02 0, 75, 75, 1, 608256, 0x4beffc2a diff --git a/tests/ref/fate/h264-reinit-small_422_9-to-small_420_9 b/tests/ref/fate/h264-reinit-small_422_9-to-small_420_9 index b5a9505..0ec2c43 100644 --- a/tests/ref/fate/h264-reinit-small_422_9-to-small_420_9 +++ b/tests/ref/fate/h264-reinit-small_422_9-to-small_420_9 @@ -50,28 +50,28 @@ 0, 48, 48, 1, 608256, 0x84b4b1f1 0, 49, 49, 1, 608256, 0xf0d4949b 0, 50, 50, 1, 608256, 0xee06377f -0, 51, 51, 1, 608256, 0x9c22c5ee -0, 52, 52, 1, 608256, 0x322abee2 -0, 53, 53, 1, 608256, 0x82745ed3 -0, 54, 54, 1, 608256, 0xe7b9248b -0, 55, 55, 1, 608256, 0xc8c1ce0e -0, 56, 56, 1, 608256, 0x8451eba9 -0, 57, 57, 1, 608256, 0xece9412d -0, 58, 58, 1, 608256, 0xffbc2c24 -0, 59, 59, 1, 608256, 0xf58c117e -0, 60, 60, 1, 608256, 0x7853f334 -0, 61, 61, 1, 608256, 0x1acd6465 -0, 62, 62, 1, 608256, 0xb668856c -0, 63, 63, 1, 608256, 0x3f52c230 -0, 64, 64, 1, 608256, 0xd7e8b5b6 -0, 65, 65, 1, 608256, 0xf663681d -0, 66, 66, 1, 608256, 0x07ef670c -0, 67, 67, 1, 608256, 0x1d5084f4 -0, 68, 68, 1, 608256, 0x0ea3fe04 -0, 69, 69, 1, 608256, 0xf095d1e0 -0, 70, 70, 1, 608256, 0xbdac37fb -0, 71, 71, 1, 608256, 0x2cbfdf91 -0, 72, 72, 1, 608256, 0x8da7190f +0, 51, 51, 1, 608256, 0x18b81c3c +0, 52, 52, 1, 608256, 0x1a217e1b +0, 53, 53, 1, 608256, 0x7caf4a52 +0, 54, 54, 1, 608256, 0x9a15c16d +0, 55, 55, 1, 608256, 0xd95ad1d4 +0, 56, 56, 1, 608256, 0xe89b7ae1 +0, 57, 57, 1, 608256, 0x724e06a5 +0, 58, 58, 1, 608256, 0xa0ae5785 +0, 59, 59, 1, 608256, 0xe8710309 +0, 60, 60, 1, 608256, 0x182d3b2f +0, 61, 61, 1, 608256, 0x087b2a54 +0, 62, 62, 1, 608256, 0x8669afba +0, 63, 63, 1, 608256, 0x3aedae4c +0, 64, 64, 1, 608256, 0x8af01aeb +0, 65, 65, 1, 608256, 0xc0711005 +0, 66, 66, 1, 608256, 0x10ddce7a +0, 67, 67, 1, 608256, 0x7f42afc7 +0, 68, 68, 1, 608256, 0xb8d34b42 +0, 69, 69, 1, 608256, 0x663f7b32 +0, 70, 70, 1, 608256, 0x9607cdc7 +0, 71, 71, 1, 608256, 0x346e7aa9 +0, 72, 72, 1, 608256, 0x7ffdd25f 0, 73, 73, 1, 608256, 0x08bf6fc9 0, 74, 74, 1, 608256, 0xa2368e5c 0, 75, 75, 1, 608256, 0x36d38f81 -- 2.1.4
_______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel