static int avi_extract_stream_metadata(AVFormatContext *s, AVStream *st)

{

    GetByteContext gb;

    uint8_t *data = st->codecpar->extradata;

    int data_size = st->codecpar->extradata_size;

    int tag, offset;



    if (!data || data_size < 8) {

        return AVERROR_INVALIDDATA;

    }



    bytestream2_init(&gb, data, data_size);



    tag = bytestream2_get_le32(&gb);



    switch (tag) {

    case MKTAG('A', 'V', 'I', 'F'):

        // skip 4 byte padding

        bytestream2_skip(&gb, 4);

        offset = bytestream2_tell(&gb);

        bytestream2_init(&gb, data + offset, data_size - offset);



        // decode EXIF tags from IFD, AVI is always little-endian

        return avpriv_exif_decode_ifd(s, &gb, 1, 0, &st->metadata);

        break;

    case MKTAG('C', 'A', 'S', 'I'):

        avpriv_request_sample(s, "RIFF stream data tag type CASI (%u)", tag);

        break;

    case MKTAG('Z', 'o', 'r', 'a'):

        avpriv_request_sample(s, "RIFF stream data tag type Zora (%u)", tag);

        break;

    default:

        break;

    }



    return 0;

}

static int avi_extract_stream_metadata(AVFormatContext *s, AVStream *st)

{

    GetByteContext gb;

    uint8_t *data = st->codecpar->extradata;

    int data_size = st->codecpar->extradata_size;

    int tag, offset;



    if (!data || data_size < 8) {

        return AVERROR_INVALIDDATA;

    }



    bytestream2_init(&gb, data, data_size);



    tag = bytestream2_get_le32(&gb);



    switch (tag) {

    case MKTAG('A', 'V', 'I', 'F'):

        

        bytestream2_skip(&gb, 4);

        offset = bytestream2_tell(&gb);

        bytestream2_init(&gb, data + offset, data_size - offset);



        

        return avpriv_exif_decode_ifd(s, &gb, 1, 0, &st->metadata);

        break;

    case MKTAG('C', 'A', 'S', 'I'):

        avpriv_request_sample(s, "RIFF stream data tag type CASI (%u)", tag);

        break;

    case MKTAG('Z', 'o', 'r', 'a'):

        avpriv_request_sample(s, "RIFF stream data tag type Zora (%u)", tag);

        break;

    default:

        break;

    }



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1)

{

    GetByteContext gb;

    uint8_t *data = VAR_1->codecpar->extradata;

    int VAR_2 = VAR_1->codecpar->extradata_size;

    int VAR_3, VAR_4;



    if (!data || VAR_2 < 8) {

        return AVERROR_INVALIDDATA;

    }



    bytestream2_init(&gb, data, VAR_2);



    VAR_3 = bytestream2_get_le32(&gb);



    switch (VAR_3) {

    case MKTAG('A', 'V', 'I', 'F'):

        

        bytestream2_skip(&gb, 4);

        VAR_4 = bytestream2_tell(&gb);

        bytestream2_init(&gb, data + VAR_4, VAR_2 - VAR_4);



        

        return avpriv_exif_decode_ifd(VAR_0, &gb, 1, 0, &VAR_1->metadata);

        break;

    case MKTAG('C', 'A', 'S', 'I'):

        avpriv_request_sample(VAR_0, "RIFF stream data VAR_3 type CASI (%u)", VAR_3);

        break;

    case MKTAG('Z', 'o', 'r', 'a'):

        avpriv_request_sample(VAR_0, "RIFF stream data VAR_3 type Zora (%u)", VAR_3);

        break;

    default:

        break;

    }



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1)
{ GetByteContext gb; uint8_t *data = VAR_1->codecpar->extradata; int VAR_2 = VAR_1->codecpar->extradata_size; int VAR_3, VAR_4; if (!data || VAR_2 < 8) { return AVERROR_INVALIDDATA; } bytestream2_init(&gb, data, VAR_2); VAR_3 = bytestream2_get_le32(&gb); switch (VAR_3) { case MKTAG('A', 'V', 'I', 'F'):
bytestream2_skip(&gb, 4); VAR_4 = bytestream2_tell(&gb); bytestream2_init(&gb, data + VAR_4, VAR_2 - VAR_4); return avpriv_exif_decode_ifd(VAR_0, &gb, 1, 0, &VAR_1->metadata); break; case MKTAG('C', 'A', 'S', 'I'):
avpriv_request_sample(VAR_0, "RIFF stream data VAR_3 type CASI (%u)", VAR_3); break; case MKTAG('Z', 'o', 'r', 'a'):
avpriv_request_sample(VAR_0, "RIFF stream data VAR_3 type Zora (%u)", VAR_3); break; default:
break; } return 0; }