Todo

Bug fixes:
h264:
- The frame num gap compensation code calls ff_report_*_progress with INT_MAX on every frame; it should only do this for every frame but the last.
- 'avchd-test-1.mts' decodes differently with threads on.
- frame_thread_free doesn't work right when called from the error label in frame_thread_init.

mpeg4:
- Some divx AVIs with B-frames show artifacts in mplayer-mt but not ffplay - ffplay may hide it due to the VO being much slower. Note that packed B-frames should be disabling mt decode as it is.

other:
- Push PTS through reordered_opaque in ffmpeg.c -vsync; the current code treats increased decoder delay as dropped frames at the beginning and breaks a/v sync.

Optimization:
- Fix avail_motion to not check everything in refs, since it knows how many refs there are.
- Fix fill_edges so it's usable for mt+interlaced; right now it uses edge emu which is slower.
- avail_motion code was copied from hl_motion; both of them should be rewritten to use loops instead of copy pasting code for L0/L1 and such.
- Support packed B-frames in mpeg4.
- Support slice+frame threading; count the slices in each frame and then reuse that number of threads as slice-decoding threads for the next frame. (not required immediately)

Style:
- Move the init_copy callback into update_context since it's rarely used
- Get rid of IS_* macros in thread.h and use explicit checks instead
- Rename avail_motion and ONLY_IF_THREADS_ENABLED to fit existing names
- Document that FF_THREAD_FRAME doesn't work if clients expect certain DTS (like mplayer without -correct-pts), or if they can't submit future frames

Other:
- Support streams with width/height changing. Codec update_context would check for this and reinit each decoder thread; clients would have to deal with decode_video returning frames of the old size after get_buffer has already been called with the new size, or lavc would have to drop the remaining frames. See the one commit under 'sizechange' branch (which doesn't work).
Right now it just breaks instead of printing an error.
- Support encoding. (not required, and may require more threading primitives for good ratecontrol)
- Change avcodec_decode_video to take AVPackets instead of buf/buf_size; try to get rid of copying buffer data in frame threading/packed B-frames/etc, and if possible deprecate AVCodecContext.coded_frame and .reordered_opaque.
- Have an API for clients to see buffered decoded frames without having to submit new ones; this works in mainline by overriding get_buffer, but with frame threads clients have no way to tell whether any not-yet-returned AVFrame has finished decoding.
- Deprecate avcodec_thread_init; it's the same as setting avctx->thread_count before calling avcodec_open. This means actually documenting it for once.
- Try to call codec->init in avcodec_open again. At the moment it's disabled and called on the first decoder thread instead (the rest use init_copy).
This causes problems for clients who were expecting pix_fmt to be set after init. This is tricky, since it means init has to be called twice, or codecs have to be changed to deal with their decode_frame using a different avctx than their init (mpeg codecs can't handle this).

Samples:
http://astrange.ithinksw.net/ffmpeg/mt-samples/

See yuvcmp.c in this directory to compare decoded samples; try commenting out ff_report_frame_setup_done calls so only one thread runs at once, and then binary search+scattering printfs to look for differences in codec contexts.
