[FFmpeg-devel] [PATCH 10/10] lavc/hevc_ps: compactify ShortTermRPS

Anton Khirnov anton at khirnov.net
Fri May 24 12:19:47 EEST 2024


Quoting James Almer (2024-04-11 14:35:37)
> > diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
> > index 92b85115f7..a8d07aa1b2 100644
> > --- a/libavcodec/hevc_ps.h
> > +++ b/libavcodec/hevc_ps.h
> > @@ -70,16 +70,19 @@ typedef struct HEVCHdrParams {
> >   } HEVCHdrParams;
> >   
> >   typedef struct ShortTermRPS {
> > -    uint8_t rps_predict;
> > -    unsigned int delta_idx;
> > -    uint8_t use_delta_flag;
> > -    uint8_t delta_rps_sign;
> > -    unsigned int abs_delta_rps;
> > -    unsigned int num_negative_pics;
> > -    int num_delta_pocs;
> > -    int rps_idx_num_delta_pocs;
> >       int32_t delta_poc[32];
> >       uint32_t used;
> > +
> > +    uint8_t delta_idx;
> > +    uint8_t num_negative_pics;
> > +    uint8_t num_delta_pocs;
> > +    uint8_t rps_idx_num_delta_pocs;
> > +
> > +    uint16_t abs_delta_rps;
> > +    unsigned delta_rps_sign:1;
> 
> Wont the compiler add two bytes of padding if you put this here?

No. Pahole says

struct ShortTermRPS {
        int32_t                    delta_poc[32];        /*     0   128 */
        /* --- cacheline 2 boundary (128 bytes) --- */
        uint32_t                   used;                 /*   128     4 */
        uint8_t                    delta_idx;            /*   132     1 */
        uint8_t                    num_negative_pics;    /*   133     1 */
        uint8_t                    num_delta_pocs;       /*   134     1 */
        uint8_t                    rps_idx_num_delta_pocs; /*   135     1 */
        uint16_t                   abs_delta_rps;        /*   136     2 */

        /* Bitfield combined with previous fields */

        unsigned int               delta_rps_sign:1;     /*   136:16  4 */
        unsigned int               rps_predict:1;        /*   136:17  4 */
        unsigned int               use_delta:1;          /*   136:18  4 */

        /* size: 140, cachelines: 3, members: 10 */
        /* bit_padding: 13 bits */
        /* last cacheline: 12 bytes */
};

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list