lavfi/delogo: avoid propagation of rounding errors in chroma planes

When operating on subsampled chroma planes, some rounding is taking
place. The left and top borders are rounded down while the width and
height are rounded up, so all rounding is done outward to guarantee the
logo area is fully covered.

The problem is that the width and height are counted from the
unrounded left and top borders, respectively. So if the left or top
border position has indeed been rounded down, and the width or height
needs no rounding (up), the position of the the right or bottom border
will be effectively rounded down, i.e. inward.

The issue can easily be seen with a yuv240p input and
  -vf delogo=45:45:60:40:show=1 -vframes 1 delogo-bug.png
(or virtually any logo area with odd x and y and even width and
height.) The right and bottom chroma borders (in green) are clearly
off.

In order to fix this, the width and height must be adjusted to include
the bits lost in the rounding of the left and top border positions,
respectively, prior to being themselves rounded up.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Jean Delvare 2013-07-02 13:50:02 +02:00 committed by Michael Niedermayer
parent 99f1d74933
commit f0bcb13aed
2 changed files with 113 additions and 111 deletions

View File

@ -246,8 +246,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
FF_CEIL_RSHIFT(inlink->w, hsub),
FF_CEIL_RSHIFT(inlink->h, vsub),
sar, s->x>>hsub, s->y>>vsub,
FF_CEIL_RSHIFT(s->w, hsub),
FF_CEIL_RSHIFT(s->h, vsub),
/* Up and left borders were rounded down, inject lost bits
* into width and height to avoid error accumulation */
FF_CEIL_RSHIFT(s->w + (s->x & ((1<<hsub)-1)), hsub),
FF_CEIL_RSHIFT(s->h + (s->y & ((1<<vsub)-1)), vsub),
s->band>>FFMIN(hsub, vsub),
s->show, direct);
}

View File

@ -1,110 +1,110 @@
#tb 0: 32768/982057
0, 0, 0, 1, 126720, 0x41c3ebfc
0, 1, 1, 1, 126720, 0x16dfec9a
0, 2, 2, 1, 126720, 0x16dfec9a
0, 3, 3, 1, 126720, 0x16dfec9a
0, 4, 4, 1, 126720, 0xd390ecdc
0, 5, 5, 1, 126720, 0xf2eaf468
0, 6, 6, 1, 126720, 0x2bcef4a8
0, 7, 7, 1, 126720, 0x996ff488
0, 8, 8, 1, 126720, 0x5adbb7e4
0, 9, 9, 1, 126720, 0xce00b8a4
0, 10, 10, 1, 126720, 0xc752b8e4
0, 11, 11, 1, 126720, 0xd8c9b8b0
0, 12, 12, 1, 126720, 0x3003b914
0, 13, 13, 1, 126720, 0xaf93bb84
0, 14, 14, 1, 126720, 0x0df4bc04
0, 15, 15, 1, 126720, 0xe4f7bb90
0, 16, 16, 1, 126720, 0xf4f0b8f4
0, 17, 17, 1, 126720, 0x6bbbae4c
0, 18, 18, 1, 126720, 0x189799b5
0, 19, 19, 1, 126720, 0xb3aba7b9
0, 20, 20, 1, 126720, 0xaa58ba49
0, 21, 21, 1, 126720, 0xd458a85d
0, 22, 22, 1, 126720, 0xe2f7ab39
0, 23, 23, 1, 126720, 0xda46aa66
0, 24, 24, 1, 126720, 0x5a87bca9
0, 25, 25, 1, 126720, 0x30aea71a
0, 26, 26, 1, 126720, 0xe7f2eafc
0, 27, 27, 1, 126720, 0xb181b566
0, 28, 28, 1, 126720, 0x06fc036b
0, 29, 29, 1, 126720, 0x5b1184d0
0, 30, 30, 1, 126720, 0xe0dd0159
0, 31, 31, 1, 126720, 0x984eb9c2
0, 32, 32, 1, 126720, 0x18de046e
0, 33, 33, 1, 126720, 0x7739d63b
0, 34, 34, 1, 126720, 0xa8aedbe1
0, 35, 35, 1, 126720, 0x3a8bad65
0, 36, 36, 1, 126720, 0xa0d879dd
0, 37, 37, 1, 126720, 0x9880c604
0, 38, 38, 1, 126720, 0xad34b4e2
0, 39, 39, 1, 126720, 0x62ece114
0, 40, 40, 1, 126720, 0x06321e84
0, 41, 41, 1, 126720, 0xb8a278f7
0, 42, 42, 1, 126720, 0xf3794872
0, 43, 43, 1, 126720, 0x40228bd8
0, 44, 44, 1, 126720, 0xd9eb99be
0, 45, 45, 1, 126720, 0xcd71085c
0, 46, 46, 1, 126720, 0x53b50e7d
0, 47, 47, 1, 126720, 0x115825d5
0, 48, 48, 1, 126720, 0xadb2d397
0, 49, 49, 1, 126720, 0xd8c9e7b3
0, 50, 50, 1, 126720, 0xb8b1e4c6
0, 51, 51, 1, 126720, 0xcf7102d2
0, 52, 52, 1, 126720, 0x9458eab9
0, 53, 53, 1, 126720, 0x9654ee85
0, 54, 54, 1, 126720, 0xf9c8f16b
0, 55, 55, 1, 126720, 0x37bb27c6
0, 56, 56, 1, 126720, 0x01f29e29
0, 57, 57, 1, 126720, 0x2090dc6b
0, 58, 58, 1, 126720, 0x3f6fd6cb
0, 59, 59, 1, 126720, 0x16110602
0, 60, 60, 1, 126720, 0x8f56b840
0, 61, 61, 1, 126720, 0x12f44aa7
0, 62, 62, 1, 126720, 0x8a3b2db5
0, 63, 63, 1, 126720, 0xea6e4b48
0, 64, 64, 1, 126720, 0xf72e3057
0, 65, 65, 1, 126720, 0xbcb28cb0
0, 66, 66, 1, 126720, 0xd8d08db4
0, 67, 67, 1, 126720, 0x93cd8232
0, 68, 68, 1, 126720, 0x58421200
0, 69, 69, 1, 126720, 0xb9754164
0, 70, 70, 1, 126720, 0xeb259b9c
0, 71, 71, 1, 126720, 0xaa726578
0, 72, 72, 1, 126720, 0xe66825b1
0, 73, 73, 1, 126720, 0x9742aa58
0, 74, 74, 1, 126720, 0x8fa5815e
0, 75, 75, 1, 126720, 0xbaf341c7
0, 76, 76, 1, 126720, 0x94ed5495
0, 77, 77, 1, 126720, 0x0c11685f
0, 78, 78, 1, 126720, 0x9ba46776
0, 79, 79, 1, 126720, 0x3ee0921d
0, 80, 80, 1, 126720, 0x736df713
0, 81, 81, 1, 126720, 0xed1aa7dc
0, 82, 82, 1, 126720, 0x916661df
0, 83, 83, 1, 126720, 0xa4e75cb4
0, 84, 84, 1, 126720, 0xb341408d
0, 85, 85, 1, 126720, 0x3dbf5bf7
0, 86, 86, 1, 126720, 0x03c990aa
0, 87, 87, 1, 126720, 0x4d598768
0, 88, 88, 1, 126720, 0xfd953b86
0, 89, 89, 1, 126720, 0xf9796c69
0, 90, 90, 1, 126720, 0xe125664e
0, 91, 91, 1, 126720, 0x7afc671f
0, 92, 92, 1, 126720, 0x5cb8e0d5
0, 93, 93, 1, 126720, 0x5d7d2928
0, 94, 94, 1, 126720, 0xa9f8faa8
0, 95, 95, 1, 126720, 0x2c767188
0, 96, 96, 1, 126720, 0x0188e449
0, 97, 97, 1, 126720, 0x8483812a
0, 98, 98, 1, 126720, 0x54953eb4
0, 99, 99, 1, 126720, 0x7980503e
0, 100, 100, 1, 126720, 0xc6931503
0, 101, 101, 1, 126720, 0xc15613f4
0, 102, 102, 1, 126720, 0xd59fe8fd
0, 103, 103, 1, 126720, 0x71ed62b7
0, 104, 104, 1, 126720, 0x4c154002
0, 105, 105, 1, 126720, 0x7219bca5
0, 106, 106, 1, 126720, 0x3a04a755
0, 107, 107, 1, 126720, 0x0784ad95
0, 108, 108, 1, 126720, 0x29575bd4
0, 0, 0, 1, 126720, 0x77a5ebed
0, 1, 1, 1, 126720, 0x4cc1ec8b
0, 2, 2, 1, 126720, 0x4cc1ec8b
0, 3, 3, 1, 126720, 0x4cc1ec8b
0, 4, 4, 1, 126720, 0x0981eccd
0, 5, 5, 1, 126720, 0x04fef463
0, 6, 6, 1, 126720, 0x3dd3f4a3
0, 7, 7, 1, 126720, 0xab74f483
0, 8, 8, 1, 126720, 0x5ed7b7db
0, 9, 9, 1, 126720, 0xd1fcb89b
0, 10, 10, 1, 126720, 0xcb4eb8db
0, 11, 11, 1, 126720, 0xdcc5b8a7
0, 12, 12, 1, 126720, 0x33ffb90b
0, 13, 13, 1, 126720, 0xb38fbb7b
0, 14, 14, 1, 126720, 0x11f0bbfb
0, 15, 15, 1, 126720, 0xe8f3bb87
0, 16, 16, 1, 126720, 0xf8ecb8eb
0, 17, 17, 1, 126720, 0x5db2ae48
0, 18, 18, 1, 126720, 0x4e7999a6
0, 19, 19, 1, 126720, 0xdb84a7a6
0, 20, 20, 1, 126720, 0x9c4fba45
0, 21, 21, 1, 126720, 0xe635a858
0, 22, 22, 1, 126720, 0xd4eeab35
0, 23, 23, 1, 126720, 0xc416aa56
0, 24, 24, 1, 126720, 0x4c7ebca5
0, 25, 25, 1, 126720, 0x2887a70e
0, 26, 26, 1, 126720, 0xc978eaf1
0, 27, 27, 1, 126720, 0x8a29b563
0, 28, 28, 1, 126720, 0x275a0352
0, 29, 29, 1, 126720, 0x446484bb
0, 30, 30, 1, 126720, 0xdbe00151
0, 31, 31, 1, 126720, 0x5874b9aa
0, 32, 32, 1, 126720, 0xdeb30460
0, 33, 33, 1, 126720, 0xc6d2d62a
0, 34, 34, 1, 126720, 0x9270dbc7
0, 35, 35, 1, 126720, 0x30e4ad59
0, 36, 36, 1, 126720, 0x117479cd
0, 37, 37, 1, 126720, 0x0567c5d2
0, 38, 38, 1, 126720, 0x87c8b4a5
0, 39, 39, 1, 126720, 0xe5c5e0d1
0, 40, 40, 1, 126720, 0x78d61e3f
0, 41, 41, 1, 126720, 0xda8d787f
0, 42, 42, 1, 126720, 0xf32547f7
0, 43, 43, 1, 126720, 0x70bc8b60
0, 44, 44, 1, 126720, 0x3ad09927
0, 45, 45, 1, 126720, 0x5d9607d6
0, 46, 46, 1, 126720, 0x348a0e02
0, 47, 47, 1, 126720, 0x7d21255c
0, 48, 48, 1, 126720, 0x308ed32b
0, 49, 49, 1, 126720, 0x79fbe734
0, 50, 50, 1, 126720, 0xdc5de409
0, 51, 51, 1, 126720, 0x4ee00283
0, 52, 52, 1, 126720, 0x2697ea2e
0, 53, 53, 1, 126720, 0x0885edeb
0, 54, 54, 1, 126720, 0xc041f0d8
0, 55, 55, 1, 126720, 0xa893272e
0, 56, 56, 1, 126720, 0x55419d4e
0, 57, 57, 1, 126720, 0xbc47dbb5
0, 58, 58, 1, 126720, 0x9666d60b
0, 59, 59, 1, 126720, 0xac5c054a
0, 60, 60, 1, 126720, 0x4affb780
0, 61, 61, 1, 126720, 0x2b7349eb
0, 62, 62, 1, 126720, 0x75592d02
0, 63, 63, 1, 126720, 0xdb904a83
0, 64, 64, 1, 126720, 0xf85e2f93
0, 65, 65, 1, 126720, 0x632f8be8
0, 66, 66, 1, 126720, 0x96108ce4
0, 67, 67, 1, 126720, 0xb68e816b
0, 68, 68, 1, 126720, 0x89ca112f
0, 69, 69, 1, 126720, 0x4bed40d3
0, 70, 70, 1, 126720, 0xe4cb9b12
0, 71, 71, 1, 126720, 0xa4f164ec
0, 72, 72, 1, 126720, 0xd1aa2554
0, 73, 73, 1, 126720, 0x0277aa01
0, 74, 74, 1, 126720, 0x8ea280fd
0, 75, 75, 1, 126720, 0xbae64170
0, 76, 76, 1, 126720, 0xaf9b543b
0, 77, 77, 1, 126720, 0x1b31680a
0, 78, 78, 1, 126720, 0x7da4671e
0, 79, 79, 1, 126720, 0x82b791cb
0, 80, 80, 1, 126720, 0xd2fff6bb
0, 81, 81, 1, 126720, 0x2395a793
0, 82, 82, 1, 126720, 0x66586185
0, 83, 83, 1, 126720, 0x99c55c63
0, 84, 84, 1, 126720, 0x7e3f403e
0, 85, 85, 1, 126720, 0x9eda5b9a
0, 86, 86, 1, 126720, 0x27469047
0, 87, 87, 1, 126720, 0xaa5b870e
0, 88, 88, 1, 126720, 0x70423b2a
0, 89, 89, 1, 126720, 0x70d86c0a
0, 90, 90, 1, 126720, 0x4bd065f3
0, 91, 91, 1, 126720, 0xd71f66bb
0, 92, 92, 1, 126720, 0x5333e081
0, 93, 93, 1, 126720, 0xdf0b28d6
0, 94, 94, 1, 126720, 0x6c48fa53
0, 95, 95, 1, 126720, 0x9438712d
0, 96, 96, 1, 126720, 0x9910e3ec
0, 97, 97, 1, 126720, 0xb0ea80dd
0, 98, 98, 1, 126720, 0x71983e67
0, 99, 99, 1, 126720, 0x18924fe6
0, 100, 100, 1, 126720, 0x9ca014b9
0, 101, 101, 1, 126720, 0x45f013a0
0, 102, 102, 1, 126720, 0xf697e8a9
0, 103, 103, 1, 126720, 0x214a626a
0, 104, 104, 1, 126720, 0xb2873fb5
0, 105, 105, 1, 126720, 0xfb47bc52
0, 106, 106, 1, 126720, 0x63b7a708
0, 107, 107, 1, 126720, 0x1904ad40
0, 108, 108, 1, 126720, 0x80015b91