Ticket #25447: ffmpeg-0.6_libvpx-0.9.1.diff

File ffmpeg-0.6_libvpx-0.9.1.diff, 7.6 KB (added by manphiz@…, 14 years ago)

Patch from webm project to bring ffmpeg 0.6 in line with new libvpx. From http://code.google.com/p/webm/downloads/list

  • new file ffpresets/libvpx-1080p.ffpreset

    diff --git ffpresets/libvpx-1080p.ffpreset ffpresets/libvpx-1080p.ffpreset
    new file mode 100644
    index 0000000..71d7a73
    - +  
     1vcodec=libvpx
     2g=120
     3rc_lookahead=16
     4level=216
     5profile=1
     6qmax=42
     7qmin=10
     8token_partitions=4
     9vb=2M
     10
     11#ignored unless using -pass 2
     12maxrate=24M
     13minrate=100k
  • new file ffpresets/libvpx-1080p50_60.ffpreset

    diff --git ffpresets/libvpx-1080p50_60.ffpreset ffpresets/libvpx-1080p50_60.ffpreset
    new file mode 100644
    index 0000000..1b447ca
    - +  
     1vcodec=libvpx
     2g=120
     3rc_lookahead=25
     4level=216
     5profile=1
     6qmax=42
     7qmin=10
     8token_partitions=4
     9vb=2M
     10
     11#ignored unless using -pass 2
     12maxrate=24M
     13minrate=100k
  • new file ffpresets/libvpx-360p.ffpreset

    diff --git ffpresets/libvpx-360p.ffpreset ffpresets/libvpx-360p.ffpreset
    new file mode 100644
    index 0000000..dea0468
    - +  
     1vcodec=libvpx
     2g=120
     3rc_lookahead=16
     4level=216
     5profile=0
     6qmax=51
     7qmin=1
     8vb=768k
     9
     10#ignored unless using -pass 2
     11maxrate=1.5M
     12minrate=40k
  • new file ffpresets/libvpx-720p.ffpreset

    diff --git ffpresets/libvpx-720p.ffpreset ffpresets/libvpx-720p.ffpreset
    new file mode 100644
    index 0000000..adc9c3a
    - +  
     1vcodec=libvpx
     2g=120
     3rc_lookahead=16
     4level=216
     5profile=0
     6qmax=42
     7qmin=10
     8token_partitions=4
     9vb=2M
     10
     11#ignored unless using -pass 2
     12maxrate=24M
     13minrate=100k
  • new file ffpresets/libvpx-720p50_60.ffpreset

    diff --git ffpresets/libvpx-720p50_60.ffpreset ffpresets/libvpx-720p50_60.ffpreset
    new file mode 100644
    index 0000000..e9b361e
    - +  
     1vcodec=libvpx
     2g=120
     3rc_lookahead=25
     4level=216
     5profile=0
     6qmax=42
     7qmin=10
     8token_partitions=4
     9vb=2M
     10
     11#ignored unless using -pass 2
     12maxrate=24M
     13minrate=100k
  • libavcodec/avcodec.h

    diff --git libavcodec/avcodec.h libavcodec/avcodec.h
    index 974e87c..3afd41b 100644
     
    3030#include "libavutil/avutil.h"
    3131
    3232#define LIBAVCODEC_VERSION_MAJOR 52
    33 #define LIBAVCODEC_VERSION_MINOR 72
     33#define LIBAVCODEC_VERSION_MINOR 73
    3434#define LIBAVCODEC_VERSION_MICRO  2
    3535
    3636#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
    typedef struct RcOverride{ 
    598598#define CODEC_FLAG2_MBTREE        0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
    599599#define CODEC_FLAG2_PSY           0x00080000 ///< Use psycho visual optimizations.
    600600#define CODEC_FLAG2_SSIM          0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.
     601#define CODEC_FLAG2_ALT_REF       0x00400000 ///< Allow encoder to insert alternate reference frames (VP8 only)
    601602
    602603/* Unsupported options :
    603604 *              Syntax Arithmetic coding (SAC)
    typedef struct AVCodecContext { 
    26522653     * - decoding: unused
    26532654     */
    26542655    int rc_lookahead;
     2656
     2657    /**
     2658     * Number of token partitions.
     2659     * Indicates number of sub-streams in the bitstream. Used for parallelized
     2660     * decoding.
     2661     * Valid values are 1, 2, 4 & 8
     2662     * - encoding: Set by user.
     2663     * - decoding: unused
     2664     *
     2665     *  \attention VP8 specific
     2666     */
     2667    int token_partitions;
    26552668} AVCodecContext;
    26562669
    26572670/**
  • libavcodec/libvpxenc.c

    diff --git libavcodec/libvpxenc.c libavcodec/libvpxenc.c
    index fa393b8..3801800 100644
     
    3636 * One encoded frame returned from the library.
    3737 */
    3838struct FrameListData {
    39     void *buf;                       /** compressed data buffer */
    40     size_t sz;                       /** length of compressed data */
    41     int64_t pts;                     /** time stamp to show frame
     39    void *buf;                       /**< compressed data buffer */
     40    size_t sz;                       /**< length of compressed data */
     41    int64_t pts;                     /**< time stamp to show frame
    4242                                          (in timebase units) */
    43     unsigned long duration;          /** duration to show frame
     43    unsigned long duration;          /**< duration to show frame
    4444                                          (in timebase units) */
    45     uint32_t flags;                  /** flags for this frame */
     45    uint32_t flags;                  /**< flags for this frame */
    4646    struct FrameListData *next;
    4747};
    4848
    static av_cold int vp8_init(AVCodecContext *avctx) 
    218218    }
    219219    dump_enc_cfg(avctx, &enccfg);
    220220
     221    /* With altref set an additional frame at the same pts may be produced.
     222       Increasing the time_base gives the library a window to place these frames
     223       ensuring strictly increasing timestamps. */
     224    if (avctx->flags2 & CODEC_FLAG2_ALT_REF) {
     225        avctx->ticks_per_frame = 2;
     226        avctx->time_base       = av_mul_q(avctx->time_base,
     227                                          (AVRational){1, avctx->ticks_per_frame});
     228    }
     229
    221230    enccfg.g_w            = avctx->width;
    222231    enccfg.g_h            = avctx->height;
    223232    enccfg.g_timebase.num = avctx->time_base.num;
    224233    enccfg.g_timebase.den = avctx->time_base.den;
    225234    enccfg.g_threads      = avctx->thread_count;
     235    enccfg.g_lag_in_frames= FFMIN(avctx->rc_lookahead, 25);  //0-25, avoids init failure
    226236
    227237    if (avctx->flags & CODEC_FLAG_PASS1)
    228238        enccfg.g_pass = VPX_RC_FIRST_PASS;
    static av_cold int vp8_init(AVCodecContext *avctx) 
    277287        enccfg.rc_twopass_stats_in = ctx->twopass_stats;
    278288    }
    279289
    280     ctx->deadline = VPX_DL_GOOD_QUALITY;
     290    /* 0-3: For non-zero values the encoder increasingly optimizes for reduced
     291       complexity playback on low powered devices at the expense of encode
     292       quality. */
     293    if (avctx->profile != FF_PROFILE_UNKNOWN)
     294        enccfg.g_profile = avctx->profile;
     295    switch (FFABS(avctx->level) / 100) {
     296    case 1:
     297        ctx->deadline = VPX_DL_BEST_QUALITY;
     298        break;
     299    case 2:
     300    default:
     301        ctx->deadline = VPX_DL_GOOD_QUALITY;
     302        break;
     303    case 3:
     304        ctx->deadline = VPX_DL_REALTIME;
     305        break;
     306    }
     307    av_log(avctx, AV_LOG_DEBUG, "Using deadline: %lu\n", ctx->deadline);
     308
     309    if (avctx->level != FF_LEVEL_UNKNOWN) {
     310        enccfg.g_error_resilient = avctx->level < 0;
     311        cpuused                  = FFABS(avctx->level) % 100 - 16; //[-16,16]
     312    }
    281313
    282314    dump_enc_cfg(avctx, &enccfg);
    283315    /* Construct Encoder Context */
    static av_cold int vp8_init(AVCodecContext *avctx) 
    291323    av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
    292324    codecctl_int(avctx, VP8E_SET_CPUUSED,           cpuused);
    293325    codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
     326    codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF,  !!(avctx->flags2 & CODEC_FLAG2_ALT_REF));
     327    codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS,  av_log2(avctx->token_partitions));
    294328
    295329    //provide dummy value to initialize wrapper, values will be updated each _encode()
    296330    vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
  • libavcodec/options.c

    diff --git libavcodec/options.c libavcodec/options.c
    index 6835352..d619dcf 100644
    static const AVOption options[]={ 
    411411{"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, 1.0, 0, FLT_MAX, V|E},
    412412{"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, 40, 0, INT_MAX, V|E},
    413413{"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_SSIM, INT_MIN, INT_MAX, V|E, "flags2"},
     414{"altref", "enable use of alternate reference frames (VP8/2-pass only)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_ALT_REF, INT_MIN, INT_MAX, V|E, "flags2"},
     415{"token_partitions", "Number of sub-streams in bitstream (1,2,4,8). Used for parallelized decoding.", OFFSET(token_partitions), FF_OPT_TYPE_INT, 1, 1, INT_MAX, V|E},
    414416{NULL},
    415417};
    416418