int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
                     uint8_t **poutbuf, int *poutbuf_size,
                     const uint8_t *buf, int buf_size,
                     int64_t pts, int64_t dts, int64_t pos)
{
    int index, i;
    uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE];
    if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
        s->next_frame_offset =
        s->cur_offset        = pos;
        s->flags            |= PARSER_FLAG_FETCHED_OFFSET;
    }
    if (buf_size == 0) {
        /* padding is always necessary even if EOF, so we add it here */
        memset(dummy_buf, 0, sizeof(dummy_buf));
        buf = dummy_buf;
    } else if (s->cur_offset + buf_size != s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */
        /* add a new packet descriptor */
        i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
        s->cur_frame_start_index = i;
        s->cur_frame_offset[i]   = s->cur_offset;
        s->cur_frame_end[i]      = s->cur_offset + buf_size;
        s->cur_frame_pts[i]      = pts;
        s->cur_frame_dts[i]      = dts;
        s->cur_frame_pos[i]      = pos;
    }
    if (s->fetch_timestamp) {
        s->fetch_timestamp = 0;
        s->last_pts        = s->pts;
        s->last_dts        = s->dts;
        s->last_pos        = s->pos;
        ff_fetch_timestamp(s, 0, 0, 0);
    }
    /* WARNING: the returned index can be negative */
    index = s->parser->parser_parse(s, avctx, (const uint8_t **) poutbuf,
                                    poutbuf_size, buf, buf_size);
    av_assert0(index > -0x20000000); // The API does not allow returning AVERROR codes
    /* update the file pointer */
    if (*poutbuf_size) {
        /* fill the data for the current frame */
        s->frame_offset = s->next_frame_offset;
        /* offset of the next frame */
        s->next_frame_offset = s->cur_offset + index;
        s->fetch_timestamp   = 1;
    }
    if (index < 0)
        index = 0;
    s->cur_offset += index;
    return index;
}
int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
                     uint8_t **poutbuf, int *poutbuf_size,
                     const uint8_t *buf, int buf_size,
                     int64_t pts, int64_t dts, int64_t pos)
{
    int index, i;
    uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE];
    if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
        s->next_frame_offset =
        s->cur_offset        = pos;
        s->flags            |= PARSER_FLAG_FETCHED_OFFSET;
    }
    if (buf_size == 0) {
        
        memset(dummy_buf, 0, sizeof(dummy_buf));
        buf = dummy_buf;
    } else if (s->cur_offset + buf_size != s->cur_frame_end[s->cur_frame_start_index]) { 
        
        i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
        s->cur_frame_start_index = i;
        s->cur_frame_offset[i]   = s->cur_offset;
        s->cur_frame_end[i]      = s->cur_offset + buf_size;
        s->cur_frame_pts[i]      = pts;
        s->cur_frame_dts[i]      = dts;
        s->cur_frame_pos[i]      = pos;
    }
    if (s->fetch_timestamp) {
        s->fetch_timestamp = 0;
        s->last_pts        = s->pts;
        s->last_dts        = s->dts;
        s->last_pos        = s->pos;
        ff_fetch_timestamp(s, 0, 0, 0);
    }
    
    index = s->parser->parser_parse(s, avctx, (const uint8_t **) poutbuf,
                                    poutbuf_size, buf, buf_size);
    av_assert0(index > -0x20000000); 
    
    if (*poutbuf_size) {
        
        s->frame_offset = s->next_frame_offset;
        
        s->next_frame_offset = s->cur_offset + index;
        s->fetch_timestamp   = 1;
    }
    if (index < 0)
        index = 0;
    s->cur_offset += index;
    return index;
}
int FUNC_0(AVCodecParserContext *VAR_0, AVCodecContext *VAR_1,
                     uint8_t **VAR_2, int *VAR_3,
                     const uint8_t *VAR_4, int VAR_5,
                     int64_t VAR_6, int64_t VAR_7, int64_t VAR_8)
{
    int VAR_9, VAR_10;
    uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE];
    if (!(VAR_0->flags & PARSER_FLAG_FETCHED_OFFSET)) {
        VAR_0->next_frame_offset =
        VAR_0->cur_offset        = VAR_8;
        VAR_0->flags            |= PARSER_FLAG_FETCHED_OFFSET;
    }
    if (VAR_5 == 0) {
        
        memset(dummy_buf, 0, sizeof(dummy_buf));
        VAR_4 = dummy_buf;
    } else if (VAR_0->cur_offset + VAR_5 != VAR_0->cur_frame_end[VAR_0->cur_frame_start_index]) { 
        
        VAR_10 = (VAR_0->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
        VAR_0->cur_frame_start_index = VAR_10;
        VAR_0->cur_frame_offset[VAR_10]   = VAR_0->cur_offset;
        VAR_0->cur_frame_end[VAR_10]      = VAR_0->cur_offset + VAR_5;
        VAR_0->cur_frame_pts[VAR_10]      = VAR_6;
        VAR_0->cur_frame_dts[VAR_10]      = VAR_7;
        VAR_0->cur_frame_pos[VAR_10]      = VAR_8;
    }
    if (VAR_0->fetch_timestamp) {
        VAR_0->fetch_timestamp = 0;
        VAR_0->last_pts        = VAR_0->VAR_6;
        VAR_0->last_dts        = VAR_0->VAR_7;
        VAR_0->last_pos        = VAR_0->VAR_8;
        ff_fetch_timestamp(VAR_0, 0, 0, 0);
    }
    
    VAR_9 = VAR_0->parser->parser_parse(VAR_0, VAR_1, (const uint8_t **) VAR_2,
                                    VAR_3, VAR_4, VAR_5);
    av_assert0(VAR_9 > -0x20000000); 
    
    if (*VAR_3) {
        
        VAR_0->frame_offset = VAR_0->next_frame_offset;
        
        VAR_0->next_frame_offset = VAR_0->cur_offset + VAR_9;
        VAR_0->fetch_timestamp   = 1;
    }
    if (VAR_9 < 0)
        VAR_9 = 0;
    VAR_0->cur_offset += VAR_9;
    return VAR_9;
}
int FUNC_0(AVCodecParserContext *VAR_0, AVCodecContext *VAR_1,
uint8_t **VAR_2, int *VAR_3,
const uint8_t *VAR_4, int VAR_5,
int64_t VAR_6, int64_t VAR_7, int64_t VAR_8)
{ int VAR_9, VAR_10; uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE]; if (!(VAR_0->flags & PARSER_FLAG_FETCHED_OFFSET)) { VAR_0->next_frame_offset =
VAR_0->cur_offset        = VAR_8; VAR_0->flags            |= PARSER_FLAG_FETCHED_OFFSET; } if (VAR_5 == 0) { memset(dummy_buf, 0, sizeof(dummy_buf)); VAR_4 = dummy_buf; } else if (VAR_0->cur_offset + VAR_5 != VAR_0->cur_frame_end[VAR_0->cur_frame_start_index]) { VAR_10 = (VAR_0->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1); VAR_0->cur_frame_start_index = VAR_10; VAR_0->cur_frame_offset[VAR_10]   = VAR_0->cur_offset; VAR_0->cur_frame_end[VAR_10]      = VAR_0->cur_offset + VAR_5; VAR_0->cur_frame_pts[VAR_10]      = VAR_6; VAR_0->cur_frame_dts[VAR_10]      = VAR_7; VAR_0->cur_frame_pos[VAR_10]      = VAR_8; } if (VAR_0->fetch_timestamp) { VAR_0->fetch_timestamp = 0; VAR_0->last_pts        = VAR_0->VAR_6; VAR_0->last_dts        = VAR_0->VAR_7; VAR_0->last_pos        = VAR_0->VAR_8; ff_fetch_timestamp(VAR_0, 0, 0, 0); } VAR_9 = VAR_0->parser->parser_parse(VAR_0, VAR_1, (const uint8_t **) VAR_2,
VAR_3, VAR_4, VAR_5); av_assert0(VAR_9 > -0x20000000); if (*VAR_3) { VAR_0->frame_offset = VAR_0->next_frame_offset; VAR_0->next_frame_offset = VAR_0->cur_offset + VAR_9; VAR_0->fetch_timestamp   = 1; } if (VAR_9 < 0)
VAR_9 = 0; VAR_0->cur_offset += VAR_9; return VAR_9; }