0

В ffmpeg модуле, а именно в avformat, есть структура под названием AVIndexEntry, и описана она как:

typedef struct AVIndexEntry {
    int64_t pos;
    int64_t timestamp;        /**<
                               * Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are available
                               * when seeking to this entry. That means preferable PTS on keyframe based formats.
                               * But demuxers can choose to store a different timestamp, if it is more convenient for the implementation or nothing better
                               * is known
                               */
#define AVINDEX_KEYFRAME 0x0001
#define AVINDEX_DISCARD_FRAME  0x0002    /**
                                          * Flag is used to indicate which frame should be discarded after decoding.
                                          */
    int flags:2;
    int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment).
    int min_distance;         /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */
} AVIndexEntry;

Интересуют 2 поля, в которых присутствуют битовые поля, а точнее то, как их маршилировать, и делать бинарную совместимость при переносе на .

1 ответ 1

3

Отдельные поля - никак. В C# нет битовых полей.

Но можно просто объединить эти два значения в один целый uint, а разделять его уже через свойства:

struct AVIndexEntry
{
    public Flag Flaga => (Flag)((flagsAndSize & 0xC0000000) >> 30);
    public int Size => (int)(flagsAndSize & 0x3FFFFFFF);

    long pos;
    long timestamp;
    uint flagsAndSize;
    int min_distance;
}

[Flags]
public enum Flag : byte
{
    AVINDEX_KEYFRAME = 0x0001,
    AVINDEX_DISCARD_FRAME = 0x0002
}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.