I allocate an AVIO context with my own read_packet() implementation. Only my implementation is such that I may return with a count smaller than the
read_packet()
count