Hi,
while The Evil Plan is not completely done yet, I feel that it is now
finished enough for some proper review. Who still does not know what The
Evil Plan is, see previous threads with it in the subject.

I will split it in three threads for convenience. This one will contain
the introductional stuff + refcounting AVPackets. The next one will be
the monster that refcounts every single video decoder in lavc. And the
final one will switch lavfi to AVFrame.

The full tree can be found at git://git.khirnov.net/libav
branch avbuffer

Since this is a huge changeset, it's important to get this right. So I'd
like as many people as possible to look at least at the core API
changing/adding patches to make sure there are no huge problems with it.

What remains to be done:
========================
1) There are still some fields in AVFrame where I'm not sure whether they
   should be kept, removed or transformed into some other shape.
   Here is a summary of what I have so far:

    certainly keep:
        uint8_t *data[AV_NUM_DATA_POINTERS];
        int linesize[AV_NUM_DATA_POINTERS];
        uint8_t **extended_data;
        int width, height;
        int nb_samples;
        int format;
        AVRational sample_aspect_ratio;
        int64_t pts;
        int sample_rate;
        uint64_t channel_layout;
        int palette_has_changed;
        // possibly merge those two into a single field
        // or alternatively add a frame flags field and stuff interlaced_frame 
there
        int interlaced_frame;
        int top_field_first;

    deprecated by refcounting => remove:
        int reference;
        void *opaque;
        int buffer_hints;
        int type;
        uint8_t *base[AV_NUM_DATA_POINTERS];

    mpeg-specific crap, most probably useless => remove:
        int8_t *qscale_table;
        int qstride;
        int qscale_type;
        uint8_t *mbskip_table;
        int16_t (*motion_val[2])[2];
        uint32_t *mb_type;
        short *dct_coeff;
        int8_t *ref_index[2];
        uint8_t motion_subsample_log2;

    private lavc fields => move elsewhere in lavc:
        void *hwaccel_picture_private;
        struct AVCodecContext *owner;
        void *thread_opaque;

    change into frame side data:
        AVPanScan *pan_scan; // mpeg12-specific
        // contains frame PSNR, mpegvideo_enc specific, used by avconv
        uint64_t error[AV_NUM_DATA_POINTERS];

    ????:
        // those are very lavc-specific, but quite useful so i'm unsure
        // what to do about them. pkt_pts might potentially be replaced by pts,
        // since pts is currently not used for anything useful when decoding
        // but pkt_dts is apparrently also useful when there is no pts
        int64_t pkt_pts;
        int64_t pkt_dts;
        int64_t reordered_opaque;

        // those two are only set by mpegvideo stuff, not sure if it's of any 
use
        int coded_picture_number;
        int display_picture_number;

        // very codec-specific. probably useless for decoding, but some 
encoders use
        // it to allow specifying quantizer per-frame. change into frame side 
data
        // maybe?
        int quality;

        // again, very lavc-specific "weakly coupled" frame metadata, not an 
actual
        // frame propery. at least pict_type is kinda useful.
        int repeat_pict;
        int key_frame;
        enum AVPictureType pict_type;

    Suggestions about the ???? fields are very much welcome (of course feel
    free to comment on the other ones as well).

2) mpegvideo is still not properly converted and thus is not
   contained in this set. The problem is mostly in the encoding part,
   which uses some ugly tricks to emulate refcounting.
   Also h264 -- while it passes fate, it's converted in the most
   dumb/naive way possible, not using the advantages provided by
   refcounting. Help with doing both of those properly would be very
   much welcome.

3) Missing frame buffer reuse in lavc. Preliminary tests show that this
   causes a measurable slowdown, so it should be fixed. The current code
   cannot be used because the decoded frames can now live much longer
   and might be released from a different thread so some kind of locking
   will be needed probably.

4) avconv is not converted to make sure the compatibility layer works
   properly. I will do that later.

5) Bumps and API changes will be done at the end when everything else is
   ready. I'm adding a field to AVPacket, so this means a major bump of
   lavc, lavf and lavd.

this set stat:
 libavcodec/avcodec.h        |  389 ++++-------------------------------
 libavcodec/avpacket.c       |  132 ++++++++----
 libavcodec/dxva2_h264.c     |    8 +-
 libavcodec/dxva2_mpeg2.c    |    8 +-
 libavcodec/dxva2_vc1.c      |    8 +-
 libavcodec/mpegvideo.c      |   10 +-
 libavcodec/mpegvideo.h      |    4 +
 libavcodec/pthread.c        |   20 +-
 libavcodec/utils.c          |   18 +-
 libavcodec/version.h        |    3 +
 libavdevice/v4l2.c          |  139 ++++++++-----
 libavformat/asfdec.c        |   15 +-
 libavformat/avformat.h      |   14 +-
 libavformat/avidec.c        |    8 +
 libavformat/flacdec.c       |   13 +-
 libavformat/id3v2.c         |   16 +-
 libavformat/id3v2.h         |    3 +-
 libavformat/matroskadec.c   |   14 +-
 libavformat/matroskaenc.c   |   28 +--
 libavformat/mp3enc.c        |    6 +-
 libavformat/mpegts.c        |   18 +-
 libavformat/mux.c           |    3 +
 libavformat/mxg.c           |    6 +
 libavformat/psxstr.c        |    4 +
 libavformat/rmdec.c         |    4 +
 libavformat/rtpdec.c        |    9 +-
 libavformat/rtpdec_qt.c     |    7 +-
 libavformat/utils.c         |   19 +-
 libavutil/Makefile          |    4 +
 libavutil/buffer.c          |  169 ++++++++++++++++
 libavutil/buffer.h          |  183 +++++++++++++++++
 libavutil/buffer_internal.h |   51 +++++
 libavutil/frame.c           |  455 +++++++++++++++++++++++++++++++++++++++++
 libavutil/frame.h           |  470 +++++++++++++++++++++++++++++++++++++++++++
 libavutil/version.h         |    3 +
 35 files changed, 1721 insertions(+), 540 deletions(-)

overall evil plan stat (not counting the preliminary cosmetics and
fixups):

 doc/filters.texi                |   10 -
 doc/multithreading.txt          |    5 +
 libavcodec/4xm.c                |   79 +++---
 libavcodec/8bps.c               |   30 +--
 libavcodec/8svx.c               |    2 +-
 libavcodec/aacdec.c             |    2 +-
 libavcodec/aasc.c               |   22 +-
 libavcodec/ac3dec.c             |    2 +-
 libavcodec/adpcm.c              |    2 +-
 libavcodec/adxdec.c             |    2 +-
 libavcodec/alac.c               |    2 +-
 libavcodec/alsdec.c             |    2 +-
 libavcodec/amrnbdec.c           |    2 +-
 libavcodec/amrwbdec.c           |    2 +-
 libavcodec/anm.c                |   26 +-
 libavcodec/ansi.c               |   57 +++--
 libavcodec/apedec.c             |    2 +-
 libavcodec/asvdec.c             |   40 +--
 libavcodec/atrac1.c             |    2 +-
 libavcodec/atrac3.c             |    2 +-
 libavcodec/aura.c               |   42 +---
 libavcodec/avcodec.h            |  508 ++++++++++++---------------------------
 libavcodec/avpacket.c           |  132 +++++++---
 libavcodec/avs.c                |   10 +-
 libavcodec/bethsoftvideo.c      |   13 +-
 libavcodec/bfi.c                |   28 +--
 libavcodec/bink.c               |   65 +++--
 libavcodec/binkaudio.c          |    2 +-
 libavcodec/bmp.c                |   34 +--
 libavcodec/bmv.c                |   30 +--
 libavcodec/c93.c                |   17 +-
 libavcodec/cavs.c               |   18 +-
 libavcodec/cavsdec.c            |   37 ++-
 libavcodec/cdgraphics.c         |   59 +++--
 libavcodec/cdxl.c               |   36 ++-
 libavcodec/cinepak.c            |   13 +-
 libavcodec/cljr.c               |   56 ++---
 libavcodec/cllc.c               |   22 +-
 libavcodec/cngdec.c             |    2 +-
 libavcodec/cook.c               |    2 +-
 libavcodec/cscd.c               |   32 +--
 libavcodec/cyuv.c               |   36 +--
 libavcodec/dcadec.c             |    2 +-
 libavcodec/dfa.c                |   20 +-
 libavcodec/dnxhddec.c           |   58 +++--
 libavcodec/dpcm.c               |    2 +-
 libavcodec/dpx.c                |   34 +--
 libavcodec/dsicinav.c           |   14 +-
 libavcodec/dvdec.c              |   11 +-
 libavcodec/dxa.c                |   51 ++--
 libavcodec/dxtory.c             |   23 +-
 libavcodec/dxva2_h264.c         |   18 +-
 libavcodec/dxva2_mpeg2.c        |    8 +-
 libavcodec/dxva2_vc1.c          |    8 +-
 libavcodec/eacmv.c              |   87 ++++---
 libavcodec/eamad.c              |   59 +++--
 libavcodec/eatgq.c              |   64 ++---
 libavcodec/eatgv.c              |   74 +++---
 libavcodec/eatqi.c              |   29 +--
 libavcodec/error_resilience.c   |  131 +++++-----
 libavcodec/escape124.c          |   28 ++-
 libavcodec/ffv1.c               |    5 +-
 libavcodec/ffv1.h               |    2 +
 libavcodec/ffv1dec.c            |   48 ++--
 libavcodec/flacdec.c            |    2 +-
 libavcodec/flashsv.c            |   21 +-
 libavcodec/flicvideo.c          |   19 +-
 libavcodec/fraps.c              |   34 +--
 libavcodec/frwu.c               |   24 +-
 libavcodec/g722dec.c            |    2 +-
 libavcodec/g723_1.c             |    2 +-
 libavcodec/g726.c               |    2 +-
 libavcodec/gifdec.c             |   25 +-
 libavcodec/gsmdec.c             |    2 +-
 libavcodec/h261dec.c            |   11 +-
 libavcodec/h263.c               |   48 ++--
 libavcodec/h263dec.c            |   12 +-
 libavcodec/h264.c               |  144 ++++++-----
 libavcodec/h264.h               |    6 +-
 libavcodec/h264_cabac.c         |   22 +-
 libavcodec/h264_cavlc.c         |    8 +-
 libavcodec/h264_direct.c        |   51 ++--
 libavcodec/h264_loopfilter.c    |   34 +--
 libavcodec/h264_mb_template.c   |    4 +-
 libavcodec/h264_mc_template.c   |    2 +-
 libavcodec/h264_mvpred.h        |   38 +--
 libavcodec/h264_refs.c          |   32 +--
 libavcodec/huffyuvdec.c         |   37 +--
 libavcodec/idcinvideo.c         |   38 +--
 libavcodec/iff.c                |   39 ++-
 libavcodec/imc.c                |    2 +-
 libavcodec/indeo2.c             |   15 +-
 libavcodec/indeo3.c             |   20 +-
 libavcodec/internal.h           |   50 ++--
 libavcodec/interplayvideo.c     |  137 ++++++-----
 libavcodec/intrax8.c            |    2 +-
 libavcodec/ituh263dec.c         |   26 +-
 libavcodec/ituh263enc.c         |    6 +-
 libavcodec/ivi_common.c         |   21 +-
 libavcodec/ivi_common.h         |    1 -
 libavcodec/jvdec.c              |   13 +-
 libavcodec/kgv1dec.c            |   23 +-
 libavcodec/kmvc.c               |   31 +--
 libavcodec/lagarith.c           |   21 +-
 libavcodec/lcldec.c             |   59 ++---
 libavcodec/libopenjpegdec.c     |   31 +--
 libavcodec/libschroedingerdec.c |   31 +--
 libavcodec/libspeexdec.c        |    2 +-
 libavcodec/libvpxdec.c          |   16 +-
 libavcodec/loco.c               |   21 +-
 libavcodec/mace.c               |    2 +-
 libavcodec/mdec.c               |   46 +---
 libavcodec/mimic.c              |   54 +++--
 libavcodec/mjpegbdec.c          |   16 +-
 libavcodec/mjpegdec.c           |   36 +--
 libavcodec/mlpdec.c             |    2 +-
 libavcodec/mmvideo.c            |   14 +-
 libavcodec/motion_est.c         |  126 +++++-----
 libavcodec/motionpixels.c       |   15 +-
 libavcodec/mpc7.c               |    2 +-
 libavcodec/mpc8.c               |    2 +-
 libavcodec/mpeg12.c             |   59 +++--
 libavcodec/mpeg4video.c         |    8 +-
 libavcodec/mpeg4videodec.c      |   98 ++++----
 libavcodec/mpeg4videoenc.c      |   12 +-
 libavcodec/mpegaudiodec.c       |    4 +-
 libavcodec/mpegvideo.c          |  192 +++++++--------
 libavcodec/mpegvideo.h          |   17 +-
 libavcodec/mpegvideo_enc.c      |  116 +++------
 libavcodec/mpegvideo_motion.c   |    2 +-
 libavcodec/mpegvideo_xvmc.c     |    2 +-
 libavcodec/msmpeg4.c            |    2 +-
 libavcodec/msrle.c              |   12 +-
 libavcodec/mss1.c               |   13 +-
 libavcodec/mss2.c               |   57 ++---
 libavcodec/mss3.c               |   17 +-
 libavcodec/mss4.c               |   18 +-
 libavcodec/msvideo1.c           |   15 +-
 libavcodec/mxpegdec.c           |   22 +-
 libavcodec/nellymoserdec.c      |    2 +-
 libavcodec/nuv.c                |   18 +-
 libavcodec/options.c            |    4 +-
 libavcodec/options_table.h      |    1 +
 libavcodec/pcm-mpeg.c           |    2 +-
 libavcodec/pcm.c                |    2 +-
 libavcodec/pcx.c                |   35 +--
 libavcodec/pictordec.c          |   41 ++--
 libavcodec/pngdec.c             |   39 ++-
 libavcodec/pnm.c                |   10 -
 libavcodec/pnm.h                |    1 -
 libavcodec/pnmdec.c             |   20 +-
 libavcodec/proresdec.c          |   37 ++-
 libavcodec/pthread.c            |  156 ++++++------
 libavcodec/ptx.c                |   35 +--
 libavcodec/qcelpdec.c           |    2 +-
 libavcodec/qdm2.c               |    2 +-
 libavcodec/qdrw.c               |   36 +--
 libavcodec/qpeg.c               |   11 +-
 libavcodec/qtrle.c              |   12 +-
 libavcodec/r210dec.c            |   23 +-
 libavcodec/ra144dec.c           |    2 +-
 libavcodec/ra288.c              |    2 +-
 libavcodec/ralf.c               |    2 +-
 libavcodec/rawdec.c             |   95 +++++---
 libavcodec/rl2.c                |   17 +-
 libavcodec/roqvideodec.c        |   28 ++-
 libavcodec/roqvideoenc.c        |   44 ++--
 libavcodec/rpza.c               |   12 +-
 libavcodec/rv10.c               |   11 +-
 libavcodec/rv30.c               |   10 +-
 libavcodec/rv34.c               |  173 ++++++-------
 libavcodec/rv40.c               |    6 +-
 libavcodec/s302m.c              |    2 +-
 libavcodec/sgidec.c             |   32 +--
 libavcodec/shorten.c            |    2 +-
 libavcodec/sipr.c               |    2 +-
 libavcodec/smacker.c            |   17 +-
 libavcodec/smc.c                |   15 +-
 libavcodec/sunrast.c            |   35 +--
 libavcodec/svq1dec.c            |   34 +--
 libavcodec/svq1enc.c            |   11 +-
 libavcodec/svq3.c               |   45 ++--
 libavcodec/takdec.c             |    2 +-
 libavcodec/targa.c              |   30 +--
 libavcodec/thread.h             |   20 +-
 libavcodec/tiertexseqv.c        |   14 +-
 libavcodec/tiff.c               |   27 +--
 libavcodec/tmv.c                |   39 +--
 libavcodec/truemotion1.c        |   17 +-
 libavcodec/truemotion2.c        |   13 +-
 libavcodec/truespeech.c         |    2 +-
 libavcodec/tscc.c               |   18 +-
 libavcodec/tscc2.c              |   17 +-
 libavcodec/tta.c                |    2 +-
 libavcodec/twinvq.c             |    2 +-
 libavcodec/txd.c                |   35 +--
 libavcodec/ulti.c               |   15 +-
 libavcodec/utils.c              |  413 ++++++++++++++++++-------------
 libavcodec/utvideo.h            |    1 -
 libavcodec/utvideodec.c         |   46 ++--
 libavcodec/utvideoenc.c         |    1 -
 libavcodec/v210dec.c            |   24 +-
 libavcodec/v210x.c              |   22 +-
 libavcodec/v410dec.c            |   28 +--
 libavcodec/v410enc.c            |    1 -
 libavcodec/vaapi_h264.c         |   10 +-
 libavcodec/vb.c                 |   18 +-
 libavcodec/vble.c               |   35 +--
 libavcodec/vc1dec.c             |  362 ++++++++++++++--------------
 libavcodec/vcr1.c               |   39 +--
 libavcodec/vdpau.c              |   12 +-
 libavcodec/version.h            |    6 +
 libavcodec/vmdav.c              |   38 ++-
 libavcodec/vmnc.c               |   15 +-
 libavcodec/vorbisdec.c          |    2 +-
 libavcodec/vp3.c                |  177 ++++++++------
 libavcodec/vp5.c                |   12 +-
 libavcodec/vp56.c               |   99 ++++----
 libavcodec/vp56.h               |    6 +-
 libavcodec/vp56data.h           |    2 -
 libavcodec/vp6.c                |   17 +-
 libavcodec/vp8.c                |  204 +++++++++-------
 libavcodec/vp8.h                |   27 +--
 libavcodec/vqavideo.c           |   43 ++--
 libavcodec/wavpack.c            |    2 +-
 libavcodec/wmadec.c             |    2 +-
 libavcodec/wmalosslessdec.c     |    2 +-
 libavcodec/wmaprodec.c          |    2 +-
 libavcodec/wmavoice.c           |    2 +-
 libavcodec/wmv2dec.c            |   12 +-
 libavcodec/wnv1.c               |   22 +-
 libavcodec/ws-snd1.c            |    2 +-
 libavcodec/xan.c                |   49 ++--
 libavcodec/xl.c                 |   41 +---
 libavcodec/xwddec.c             |   30 +--
 libavcodec/xxan.c               |   14 +-
 libavcodec/yop.c                |   56 ++---
 libavcodec/zerocodec.c          |   34 +--
 libavcodec/zmbv.c               |   32 +--
 libavdevice/v4l2.c              |  139 +++++++----
 libavfilter/af_amix.c           |   18 +-
 libavfilter/af_ashowinfo.c      |   11 +-
 libavfilter/af_asyncts.c        |   22 +-
 libavfilter/af_channelmap.c     |    4 +-
 libavfilter/af_channelsplit.c   |   10 +-
 libavfilter/af_join.c           |  148 ++++++------
 libavfilter/af_resample.c       |   59 +++--
 libavfilter/af_volume.c         |   12 +-
 libavfilter/asink_anullsink.c   |    4 +-
 libavfilter/audio.c             |   68 +++---
 libavfilter/audio.h             |   10 +-
 libavfilter/avfilter.c          |   38 ++-
 libavfilter/avfilter.h          |   28 ++-
 libavfilter/buffersink.c        |  128 +++++++---
 libavfilter/buffersink.h        |   32 +++
 libavfilter/buffersrc.c         |  199 ++++++++++-----
 libavfilter/buffersrc.h         |   29 ++-
 libavfilter/fifo.c              |  113 +++++----
 libavfilter/internal.h          |   29 +--
 libavfilter/split.c             |    6 +-
 libavfilter/version.h           |    3 +
 libavfilter/vf_aspect.c         |    4 +-
 libavfilter/vf_blackframe.c     |    8 +-
 libavfilter/vf_boxblur.c        |   17 +-
 libavfilter/vf_copy.c           |   20 +-
 libavfilter/vf_crop.c           |    9 +-
 libavfilter/vf_cropdetect.c     |   22 +-
 libavfilter/vf_delogo.c         |   20 +-
 libavfilter/vf_drawbox.c        |    9 +-
 libavfilter/vf_drawtext.c       |   58 +++--
 libavfilter/vf_fade.c           |    9 +-
 libavfilter/vf_fieldorder.c     |   19 +-
 libavfilter/vf_fps.c            |   32 +--
 libavfilter/vf_frei0r.c         |   28 +--
 libavfilter/vf_gradfun.c        |   19 +-
 libavfilter/vf_hflip.c          |   15 +-
 libavfilter/vf_hqdn3d.c         |   22 +-
 libavfilter/vf_libopencv.c      |   33 ++-
 libavfilter/vf_lut.c            |   18 +-
 libavfilter/vf_overlay.c        |   35 ++-
 libavfilter/vf_pad.c            |  154 +++++++-----
 libavfilter/vf_pixdesctest.c    |   14 +-
 libavfilter/vf_scale.c          |   25 +-
 libavfilter/vf_select.c         |   45 ++--
 libavfilter/vf_setpts.c         |   11 +-
 libavfilter/vf_settb.c          |    2 +-
 libavfilter/vf_showinfo.c       |   21 +-
 libavfilter/vf_transpose.c      |   25 +-
 libavfilter/vf_unsharp.c        |   13 +-
 libavfilter/vf_vflip.c          |   22 +-
 libavfilter/vf_yadif.c          |   65 +++--
 libavfilter/video.c             |   98 +++-----
 libavfilter/video.h             |    9 +-
 libavfilter/vsink_nullsink.c    |    4 +-
 libavfilter/vsrc_color.c        |   13 +-
 libavfilter/vsrc_movie.c        |   49 ++--
 libavfilter/vsrc_testsrc.c      |   51 ++--
 libavfilter/yadif.h             |    8 +-
 libavformat/asfdec.c            |   15 +-
 libavformat/avformat.h          |   14 +-
 libavformat/avidec.c            |    8 +
 libavformat/flacdec.c           |   13 +-
 libavformat/id3v2.c             |   16 +-
 libavformat/id3v2.h             |    3 +-
 libavformat/matroskadec.c       |   14 +-
 libavformat/matroskaenc.c       |   28 +--
 libavformat/mp3enc.c            |    6 +-
 libavformat/mpegts.c            |   18 +-
 libavformat/mux.c               |    3 +
 libavformat/mxg.c               |    6 +
 libavformat/psxstr.c            |    4 +
 libavformat/rmdec.c             |    4 +
 libavformat/rtpdec.c            |    9 +-
 libavformat/rtpdec_qt.c         |    7 +-
 libavformat/utils.c             |   19 +-
 libavutil/Makefile              |    4 +
 libavutil/buffer.c              |  169 +++++++++++++
 libavutil/buffer.h              |  183 ++++++++++++++
 libavutil/buffer_internal.h     |   51 ++++
 libavutil/frame.c               |  455 +++++++++++++++++++++++++++++++++++
 libavutil/frame.h               |  470 ++++++++++++++++++++++++++++++++++++
 libavutil/version.h             |    3 +
 322 files changed, 5926 insertions(+), 5464 deletions(-)

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to