[FFmpeg-devel] [PATCH] libavcodec/h264dec: export block type in H.264

Yongle Lin yongle.lin.94 at gmail.com
Thu Jul 16 20:48:55 EEST 2020


On Wed, Jul 15, 2020 at 4:37 PM Mark Thompson <sw at jkqxz.net> wrote:

> On 15/07/2020 22:05, Yongle Lin wrote:
> > ---
> >   libavcodec/h264dec.c | 14 ++++++++++++++
> >   1 file changed, 14 insertions(+)
> >
> > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> > index 1e2ca68449..b3de5290d0 100644
> > --- a/libavcodec/h264dec.c
> > +++ b/libavcodec/h264dec.c
> > @@ -816,6 +816,20 @@ static int h264_export_enc_params(AVFrame *f,
> H264Picture *p)
> >               b->h     = 16;
> >
> >               b->delta_qp = p->qscale_table[mb_xy] - par->qp;
> > +
> > +            int mb_type = p->mb_type[mb_xy];
> > +            if (IS_PCM(mb_type))
> > +                b->flags |= AV_VIDEO_ENC_BLOCK_INTRA;
>
> Can you explain your definition of what makes a block "intra"?  If you
> really do mean to only include PCM blocks then maybe it should have a
> different name, because that isn't what I would expect.
>

I think intra is the block that uses no reference frame to predict? The
purpose of exporting this data is to enable visualization of block type
which has been deprecated since version 58. And previously it only
supported MPEG video and I want to make it more general to other codecs as
well.
Probably I should include  IS_PCM, IS_INTRA
&& IS_ACPRED(mb_type), IS_INTRA16x16, IS_INTRA4x4 as "intra" type for H.264?


> > +            if (IS_SKIP(mb_type))
> > +                b->flags |= AV_VIDEO_ENC_BLOCK_SKIP; > +            if
> (!USES_LIST(mb_type, 1))
> > +                b->ref[0] = p->ref_index[0];
> > +            else if (!USES_LIST(mb_type, 0))
> > +                b->ref[0] = p->ref_index[1];
> > +            else {
> > +                b->ref[0] = p->ref_index[0];
> > +                b->ref[1] = p->ref_index[1];
>
> I don't think ref_index is anything to do with what you think it is.
>
> Also note that code of this form must be insufficient due to the lack
> dependence on both the slice and the block.  (Slice headers define the two
> reference picture lists, and blocks within a slice
> choose pictures from those lists.)
>

I am not good at H.264. I read the source code and because there isn't too
much comments I thought ref_index is the thing I want. I will try to
correct it to be the index of the L0, L1 picture.


> > +            }
> >           }
> >
> >       return 0;
> >
>
> - Mark
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


Best,
Yongle


More information about the ffmpeg-devel mailing list