[FFmpeg-devel] [PATCH] libvpx: alt reference frame / lag

James Zern jzern
Wed Jun 9 18:08:59 CEST 2010


On Tue, Jun 8, 2010 at 22:19, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Tue, Jun 08, 2010 at 06:44:42PM -0400, James Zern wrote:
>> The attached adds altref to flags2 and uses rc_lookahead for
>> g_lag_in_frames mapping.
>> Alternate reference frames are currently only produced in 2-pass.
>> Further description outside of the API docs [1]. I'm ignoring the alt.
>> ref. noise reduction settings for this pass.
>>
>> [1]: http://www.webmproject.org/tools/encoder-parameters/#5_the_alternate_or_constructed_reference_frame
>
>> ?avcodec.h ? | ? ?5 +++--
>> ?libvpxenc.c | ? 11 +++++++++++
>> ?options.c ? | ? ?1 +
>> ?3 files changed, 15 insertions(+), 2 deletions(-)
>> 5c3078a90d9d169ab2ceae1622311bec825e8ba9 ?libvpxenc-altref__lag.diff
>> Index: libavcodec/options.c
>> ===================================================================
>> --- libavcodec/options.c ? ? ?(revision 23540)
>> +++ libavcodec/options.c ? ? ?(working copy)
>> @@ -414,6 +414,7 @@ static const AVOption options[]={
>> ?{"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_REFRESH, INT_MIN, INT_MAX, V|E, "flags2"},
>> ?{"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 51, V|E},
>> ?{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX },
>> +{"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"},
>> ?{NULL},
>> ?};
>>
>> Index: libavcodec/avcodec.h
>> ===================================================================
>> --- libavcodec/avcodec.h ? ? ?(revision 23540)
>> +++ libavcodec/avcodec.h ? ? ?(working copy)
>> @@ -30,8 +30,8 @@
>> ?#include "libavutil/avutil.h"
>>
>> ?#define LIBAVCODEC_VERSION_MAJOR 52
>> -#define LIBAVCODEC_VERSION_MINOR 75
>> -#define LIBAVCODEC_VERSION_MICRO ?1
>> +#define LIBAVCODEC_VERSION_MINOR 76
>> +#define LIBAVCODEC_VERSION_MICRO ?0
>>
>> ?#define LIBAVCODEC_VERSION_INT ?AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? LIBAVCODEC_VERSION_MINOR, \
>> @@ -600,6 +600,7 @@ typedef struct RcOverride{
>> ?#define CODEC_FLAG2_PSY ? ? ? ? ? 0x00080000 ///< Use psycho visual optimizations.
>> ?#define CODEC_FLAG2_SSIM ? ? ? ? ?0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.
>> ?#define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes.
>> +#define CODEC_FLAG2_ALT_REF ? ? ? 0x00400000 ///< Allow encoder to insert alternate reference frames (VP8 only)
>>
>> ?/* Unsupported options :
>> ? * ? ? ? ? ? ? ?Syntax Arithmetic coding (SAC)
>> Index: libavcodec/libvpxenc.c
>> ===================================================================
>> --- libavcodec/libvpxenc.c ? ?(revision 23540)
>> +++ libavcodec/libvpxenc.c ? ?(working copy)
>> @@ -218,11 +218,21 @@ static av_cold int vp8_init(AVCodecConte
>> ? ? ?}
>> ? ? ?dump_enc_cfg(avctx, &enccfg);
>>
>> + ? ?/* With altref set an additional frame at the same pts may be produced.
>> + ? ? ? Increasing the time_base gives the library a window to place these frames
>> + ? ? ? ensuring strictly increasing timestamps. */
>> + ? ?if (avctx->flags2 & CODEC_FLAG2_ALT_REF) {
>> + ? ? ? ?avctx->ticks_per_frame = 2;
>> + ? ? ? ?avctx->time_base ? ? ? = av_mul_q(avctx->time_base,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(AVRational){1, avctx->ticks_per_frame});
>> + ? ?}
>
> this looks and sounds wrong
> the way divx/xvid packed b frames are handled is much saner
>
I'll have to have a closer look at that. From what I remember, these
were flagged within the container with each frame having a new header
to allow the frames to be broken up by the decoder correct?



More information about the ffmpeg-devel mailing list