[FFmpeg-devel] [PATCH] libavutil/video_enc_params: add block type

Michael Niedermayer michael at niedermayer.cc
Sat Jul 18 10:01:09 EEST 2020


On Fri, Jul 17, 2020 at 02:25:24PM -0700, Yongle Lin wrote:
> On Wed, Jul 15, 2020 at 4:13 PM Mark Thompson <sw at jkqxz.net> wrote:
> 
> > On 15/07/2020 18:43, Yongle Lin wrote:
> > > add block type field to AVVideoBlockParams so we could either export or
> > visualize it later.
> > > ---
> > >   libavutil/video_enc_params.h | 19 +++++++++++++++++++
> > >   1 file changed, 19 insertions(+)
> > >
> > > diff --git a/libavutil/video_enc_params.h b/libavutil/video_enc_params.h
> > > index 43fa443154..8bf5f240c9 100644
> > > --- a/libavutil/video_enc_params.h
> > > +++ b/libavutil/video_enc_params.h
> > > @@ -57,6 +57,11 @@ enum AVVideoEncParamsType {
> > >       AV_VIDEO_ENC_PARAMS_H264,
> > >   };
> > >
> > > +enum AVVideoBlockFlags {
> > > +    AV_VIDEO_ENC_BLOCK_INTRA = 1ULL <<  0,  /* Indicates block uses
> > intra prediction */
> >
> > The ULL is only confusing matters here - standard-conforming enum values
> > have type int.  Some compilers allow it to be a larger integer type, but I
> > don't think we can rely on that extension.
> >
> 
> I am thinking of defining a bit field struct to for type flags like what we
> did in other places:
> struct AVVideoBlockFlags {
>     unsigned int intra:1;
>     unsigned int skip:1;
> }
> 
> Or we could use the same way of mb_type defined in H.264 like
> #define AV_VIDEO_ENC_BLOCK_INTRA 1ULL << 0
> #define AV_VIDEO_ENC_BLOCK_SKIP 1ULL << 1
> 
> uint64_t b_type
> 
> 
> > > +    AV_VIDEO_ENC_BLOCK_SKIP = 1ULL <<  1,   /* Indicates block is not
> > coded (skipped) */
> >
> > Can you define more precisely what you mean by "not coded"?  Is that just
> > that it has no residuals, or does it also indicate no motion vector, or no
> > coded motion vector relative to prediction?
> >
> 
>  I want to make it more general which can be applied to more codec. So in
> VP9, there is a skip flag to indicate if the block has residual
> coefficients. As for H.264 you mentioned there are P_Skip and B_Skip, I
> think both of them should be considered as skip.

If you want to make it general, maybe use multiple skip flags with clear meaning

SKIP_CODED_RESIDUAL  // No residual coded, the block may have a predicted residual
SKIP_CODED_MVD       // No motion vector difference coded, the block may have a non 0 motion vector
ZERO_RESIDUAL        // Block has no residual
ZERO_MV              // Block has a 0,0 motion vector

also in light of motion vectors, the intra AC prediction mode / direction
should probably be exported, its kind of the equivalent of what motion
vectors are in inter blocks but for intra

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200718/2ab7749c/attachment.sig>


More information about the ffmpeg-devel mailing list