h264: Put code that prevents deadlocks back

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
mpegvideo: dont allow last == current

this fixes deadlocks

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
wmalossless: fix buffer ref messup
ff_alloc_picture: free tables in case of dimension mismatches

Fixes memory corruption
In theory this should not be needed but its better to check at
one place than to hope 50 other places set the flags correctly
h264: fix null pointer dereference and assertion failure

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>