[FFmpeg-devel] [PATCH v2 1/2] avcodec/videotoolbox: use AV_WB16 where possible

Aman Gupta ffmpeg at tmm1.net
Thu Sep 28 02:22:04 EEST 2017


On Wed, Sep 27, 2017 at 4:13 PM, wm4 <nfxjfg at googlemail.com> wrote:

> On Wed, 27 Sep 2017 19:45:23 -0300
> James Almer <jamrial at gmail.com> wrote:
>
> > On 9/27/2017 7:19 PM, Aman Gupta wrote:
> > > From: Aman Gupta <aman at tmm1.net>
> > >
> > > additional changes to hevc patchset, as suggested on-list
> > >
> > > if these look fine, I will squash into previous patchset and push it to
> > > master.
> > > ---
> > >  libavcodec/videotoolbox.c | 27 +++++++++------------------
> > >  1 file changed, 9 insertions(+), 18 deletions(-)
> > >
> > > diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
> > > index 078174cc61..c96200cbdb 100644
> > > --- a/libavcodec/videotoolbox.c
> > > +++ b/libavcodec/videotoolbox.c
> > > @@ -165,10 +165,8 @@ CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext
> *avctx)
> > >                   ptlc.non_packed_constraint_flag << 5 |
> > >                   ptlc.frame_only_constraint_flag << 4);
> > >      AV_W8(p + 7, 0);
> > > -    AV_W8(p + 8, 0);
> > > -    AV_W8(p + 9, 0);
> > > -    AV_W8(p + 10, 0);
> > > -    AV_W8(p + 11, 0);
> > > +    AV_WB16(p + 8, 0);
> > > +    AV_WB16(p + 10, 0);
> >
> > AV_WB32(p + 8, 0)
> >
> > or even AV_WN32(p + 8, 0) since it's 0 and endianness doesn't matter.
>
> IMO it should reflect whatever bitstream elements these are. Ideally,
> we'd have comments about what each element is too.
>

There is already a comment in this section. It's supposed to be 48bits of
flags, but the spec has 44 of those bits defined as 'reserved zero bits'.

    /* unsigned int(48) general_constraint_indicator_flags; */
    AV_W8(p + 6, ptlc.progressive_source_flag    << 7 |
                   ptlc.interlaced_source_flag     << 6 |
                   ptlc.non_packed_constraint_flag << 5 |
                   ptlc.frame_only_constraint_flag << 4);
    AV_W8(p + 7, 0);
    AV_WN32(p + 8, 0);

In hvcc_write (lavf/hevc.c), libavformat uses:

    /* unsigned int(48) general_constraint_indicator_flags; */
    avio_wb32(pb, hvcc->general_constraint_indicator_flags >> 16);
    avio_wb16(pb, hvcc->general_constraint_indicator_flags);

But the PTL parsing code in libavcodec defines the flags individually.
See decode_profile_tier_level (lavc/hevc_ps.c):

    ptl->progressive_source_flag    = get_bits1(gb);
    ptl->interlaced_source_flag     = get_bits1(gb);
    ptl->non_packed_constraint_flag = get_bits1(gb);
    ptl->frame_only_constraint_flag = get_bits1(gb);

    skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
    skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
    skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]

Aman


> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list