Repository: xbmc/xbmc
File: xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h (C/C++)

Code before:
  int8_t* qp_table;                //< Quantization parameters, primarily used by filters
  int qstride;
  int qscale_type;
  int pict_type;

  StreamHdrType hdrType;

  bool hasDisplayMetadata = false;
  AVMasteringDisplayMetadata displayMetadata;
  bool hasLightMetadata = false;
  AVContentLightMetadata lightMetadata;

  AVPixelFormat pixelFormat; //< source pixel format

  unsigned int iWidth;
  unsigned int iHeight;
  unsigned int iDisplayWidth;           //< width of the picture without black bars
  unsigned int iDisplayHeight;          //< height of the picture without black bars

  bool operator==(const VideoPicture& pic) const
  {
    return this->iWidth == pic.iWidth &&
           this->iHeight == pic.iHeight &&
           this->iDisplayWidth == pic.iDisplayWidth &&
           this->iDisplayHeight == pic.iDisplayHeight &&
           this->stereoMode == pic.stereoMode &&
           this->color_primaries == pic.color_primaries &&
           this->color_transfer == pic.color_transfer &&
           this->hdrType == pic.hdrType;
  }

private:
  VideoPicture(VideoPicture const&);
  VideoPicture& operator=(VideoPicture const&);
};

#define DVP_FLAG_TOP_FIELD_FIRST    0x00000001
#define DVP_FLAG_REPEAT_TOP_FIELD   0x00000002  //< Set to indicate that the top field should be repeated
#define DVP_FLAG_INTERLACED         0x00000008  //< Set to indicate that this frame is interlaced
#define DVP_FLAG_DROPPED            0x00000010  //< indicate that this picture has been dropped in decoder stage, will have no data

#define DVD_CODEC_CTRL_SKIPDEINT    0x01000000  //< request to skip a deinterlacing cycle, if possible
#define DVD_CODEC_CTRL_NO_POSTPROC  0x02000000  //< see GetCodecStats
#define DVD_CODEC_CTRL_HURRY        0x04000000  //< see GetCodecStats
#define DVD_CODEC_CTRL_DROP         0x08000000  //< drop in decoder or set DVP_FLAG_DROPPED, no render of frame
#define DVD_CODEC_CTRL_DROP_ANY     0x10000000  //< drop some non-reference frame
#define DVD_CODEC_CTRL_DRAIN        0x20000000  //< squeeze out pictured without feeding new packets
#define DVD_CODEC_CTRL_ROTATE       0x40000000  //< rotate if renderer does not support it

// DVP_FLAG 0x00000100 - 0x00000f00 is in use by libmpeg2!


Review comment (suggestion):
I see what you want to do, but unexpected operator behavior because it doesn't compare every attribute. With the comparison not defined in the renderer anymore, it will be easier to forget to add a new field when needed.

A dedicated comparison function would be better and could call the new CompareDisplayMetadata and CompareLightMetadata.
The !m_pRenderer->ConfigChanged(picture) could be included as well (is CWinRenderer::ConfigChanged used from anywhere else? could be removed)

VideoPicture has more fields than necessary and troublesome semantics due to the videoBuffer pointer, an alternative could be a new renderer struct type, but I don't care much.


Code after:
  int qscale_type;
  int pict_type;

  StreamHdrType hdrType;

  bool hasDisplayMetadata = false;
  AVMasteringDisplayMetadata displayMetadata;
  bool hasLightMetadata = false;
  AVContentLightMetadata lightMetadata;

  AVPixelFormat pixelFormat; //< source pixel format

  unsigned int iWidth;
  unsigned int iHeight;
  unsigned int iDisplayWidth;           //< width of the picture without black bars
  unsigned int iDisplayHeight;          //< height of the picture without black bars

private:
  VideoPicture(VideoPicture const&);
  VideoPicture& operator=(VideoPicture const&);

  bool CompareDisplayMetadata(const VideoPicture& pic) const;
  bool CompareLightMetadata(const VideoPicture& pic) const;
};

#define DVP_FLAG_TOP_FIELD_FIRST    0x00000001
#define DVP_FLAG_REPEAT_TOP_FIELD   0x00000002  //< Set to indicate that the top field should be repeated
#define DVP_FLAG_INTERLACED         0x00000008  //< Set to indicate that this frame is interlaced
#define DVP_FLAG_DROPPED            0x00000010  //< indicate that this picture has been dropped in decoder stage, will have no data

#define DVD_CODEC_CTRL_SKIPDEINT    0x01000000  //< request to skip a deinterlacing cycle, if possible
#define DVD_CODEC_CTRL_NO_POSTPROC  0x02000000  //< see GetCodecStats
#define DVD_CODEC_CTRL_HURRY        0x04000000  //< see GetCodecStats
#define DVD_CODEC_CTRL_DROP         0x08000000  //< drop in decoder or set DVP_FLAG_DROPPED, no render of frame
#define DVD_CODEC_CTRL_DROP_ANY     0x10000000  //< drop some non-reference frame
#define DVD_CODEC_CTRL_DRAIN        0x20000000  //< squeeze out pictured without feeding new packets
#define DVD_CODEC_CTRL_ROTATE       0x40000000  //< rotate if renderer does not support it

// DVP_FLAG 0x00000100 - 0x00000f00 is in use by libmpeg2!

#define DVP_QSCALE_UNKNOWN          0
#define DVP_QSCALE_MPEG1            1
#define DVP_QSCALE_MPEG2            2
#define DVP_QSCALE_H264             3

class CDVDStreamInfo;
class CDVDCodecOption;
class CDVDCodecOptions;

class CDVDVideoCodec
{