Skip to content

integer underflow in Video::data(index: usize) #232

@RubenMovsesyan

Description

@RubenMovsesyan

Im running Ubuntu 24.04 and using FFMPEG 7.1

there's an issue the the Video::data(index: usize) function where you sometimes get an integer underflow. The data function calls the Video::stride(index: usize) function from within which gets the linesize at that index which is set at somepoint by the avcodec_recieve_frame function. However, the linesize can be a negative value which is stated here: AVFrame. This is because if the data is flipped the stride width will be negative. Unless I just don't understand how the data function is supposed to be used I suggest implementing something along the lines of:

unsafe {
    slice::from_raw_parts(
        (*decoded.as_ptr()).data[index],
        match decoded.stride(index) as isize {
            size if size < 0 => (size * -1) as usize,
            size => size as usize,
        } * decoded.plane_height(index) as usize,
    )
};

In the data function here: data. The same goes for the data_mut function just below

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions