mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
avcodec/snowenc: Don't pass int[2] as parameter declared as int[3]
check_block_inter() currently does this when calling check_block(). This leads to a -Wstringop-overflow= warning when compiling with GCC 12.1. Given that the main part of the body of check_block() consists of an "if (intra) { ... } else { ... }" which is true iff check_block() is not called from check_block_inter(), it makes sense to fix this by just inlining check_block() check_block_inter() and turning check_block() into a new check_block_intra() (with the inter parts removed, of course). This should also not make much of a difference for the generated code given that both check_block() as well as check_block_inter() are already marked as av_always_inline, so this commit follows this route to fix the issue. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
c807ee6975
commit
708890e78f
@ -892,34 +892,23 @@ static int encode_subband(SnowContext *s, SubBand *b, const IDWTELEM *src, const
|
|||||||
// encode_subband_dzr(s, b, src, parent, stride, orientation);
|
// encode_subband_dzr(s, b, src, parent, stride, orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int p[3], int intra, uint8_t (*obmc_edged)[MB_SIZE * 2], int *best_rd){
|
static av_always_inline int check_block_intra(SnowContext *s, int mb_x, int mb_y, int p[3],
|
||||||
|
uint8_t (*obmc_edged)[MB_SIZE * 2], int *best_rd)
|
||||||
|
{
|
||||||
const int b_stride= s->b_width << s->block_max_depth;
|
const int b_stride= s->b_width << s->block_max_depth;
|
||||||
BlockNode *block= &s->block[mb_x + mb_y * b_stride];
|
BlockNode *block= &s->block[mb_x + mb_y * b_stride];
|
||||||
BlockNode backup= *block;
|
BlockNode backup= *block;
|
||||||
unsigned value;
|
int rd;
|
||||||
int rd, index;
|
|
||||||
|
|
||||||
av_assert2(mb_x>=0 && mb_y>=0);
|
av_assert2(mb_x>=0 && mb_y>=0);
|
||||||
av_assert2(mb_x<b_stride);
|
av_assert2(mb_x<b_stride);
|
||||||
|
|
||||||
if(intra){
|
block->color[0] = p[0];
|
||||||
block->color[0] = p[0];
|
block->color[1] = p[1];
|
||||||
block->color[1] = p[1];
|
block->color[2] = p[2];
|
||||||
block->color[2] = p[2];
|
block->type |= BLOCK_INTRA;
|
||||||
block->type |= BLOCK_INTRA;
|
|
||||||
}else{
|
|
||||||
index= (p[0] + 31*p[1]) & (ME_CACHE_SIZE-1);
|
|
||||||
value= s->me_cache_generation + (p[0]>>10) + (p[1]<<6) + (block->ref<<12);
|
|
||||||
if(s->me_cache[index] == value)
|
|
||||||
return 0;
|
|
||||||
s->me_cache[index]= value;
|
|
||||||
|
|
||||||
block->mx= p[0];
|
rd = get_block_rd(s, mb_x, mb_y, 0, obmc_edged) + s->intra_penalty;
|
||||||
block->my= p[1];
|
|
||||||
block->type &= ~BLOCK_INTRA;
|
|
||||||
}
|
|
||||||
|
|
||||||
rd= get_block_rd(s, mb_x, mb_y, 0, obmc_edged) + s->intra_penalty * !!intra;
|
|
||||||
|
|
||||||
//FIXME chroma
|
//FIXME chroma
|
||||||
if(rd < *best_rd){
|
if(rd < *best_rd){
|
||||||
@ -934,8 +923,35 @@ static av_always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int
|
|||||||
/* special case for int[2] args we discard afterwards,
|
/* special case for int[2] args we discard afterwards,
|
||||||
* fixes compilation problem with gcc 2.95 */
|
* fixes compilation problem with gcc 2.95 */
|
||||||
static av_always_inline int check_block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, uint8_t (*obmc_edged)[MB_SIZE * 2], int *best_rd){
|
static av_always_inline int check_block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, uint8_t (*obmc_edged)[MB_SIZE * 2], int *best_rd){
|
||||||
int p[2] = {p0, p1};
|
const int b_stride = s->b_width << s->block_max_depth;
|
||||||
return check_block(s, mb_x, mb_y, p, 0, obmc_edged, best_rd);
|
BlockNode *block = &s->block[mb_x + mb_y * b_stride];
|
||||||
|
BlockNode backup = *block;
|
||||||
|
unsigned value;
|
||||||
|
int rd, index;
|
||||||
|
|
||||||
|
av_assert2(mb_x >= 0 && mb_y >= 0);
|
||||||
|
av_assert2(mb_x < b_stride);
|
||||||
|
|
||||||
|
index = (p0 + 31 * p1) & (ME_CACHE_SIZE-1);
|
||||||
|
value = s->me_cache_generation + (p0 >> 10) + (p1 << 6) + (block->ref << 12);
|
||||||
|
if (s->me_cache[index] == value)
|
||||||
|
return 0;
|
||||||
|
s->me_cache[index] = value;
|
||||||
|
|
||||||
|
block->mx = p0;
|
||||||
|
block->my = p1;
|
||||||
|
block->type &= ~BLOCK_INTRA;
|
||||||
|
|
||||||
|
rd = get_block_rd(s, mb_x, mb_y, 0, obmc_edged);
|
||||||
|
|
||||||
|
//FIXME chroma
|
||||||
|
if (rd < *best_rd) {
|
||||||
|
*best_rd = rd;
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
*block = backup;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int check_4block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, int ref, int *best_rd){
|
static av_always_inline int check_4block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, int ref, int *best_rd){
|
||||||
@ -1092,7 +1108,7 @@ static void iterative_me(SnowContext *s){
|
|||||||
// get previous score (cannot be cached due to OBMC)
|
// get previous score (cannot be cached due to OBMC)
|
||||||
if(pass > 0 && (block->type&BLOCK_INTRA)){
|
if(pass > 0 && (block->type&BLOCK_INTRA)){
|
||||||
int color0[3]= {block->color[0], block->color[1], block->color[2]};
|
int color0[3]= {block->color[0], block->color[1], block->color[2]};
|
||||||
check_block(s, mb_x, mb_y, color0, 1, obmc_edged, &best_rd);
|
check_block_intra(s, mb_x, mb_y, color0, obmc_edged, &best_rd);
|
||||||
}else
|
}else
|
||||||
check_block_inter(s, mb_x, mb_y, block->mx, block->my, obmc_edged, &best_rd);
|
check_block_inter(s, mb_x, mb_y, block->mx, block->my, obmc_edged, &best_rd);
|
||||||
|
|
||||||
@ -1150,7 +1166,7 @@ static void iterative_me(SnowContext *s){
|
|||||||
}
|
}
|
||||||
best_rd= ref_rd;
|
best_rd= ref_rd;
|
||||||
*block= ref_b;
|
*block= ref_b;
|
||||||
check_block(s, mb_x, mb_y, color, 1, obmc_edged, &best_rd);
|
check_block_intra(s, mb_x, mb_y, color, obmc_edged, &best_rd);
|
||||||
//FIXME RD style color selection
|
//FIXME RD style color selection
|
||||||
if(!same_block(block, &backup)){
|
if(!same_block(block, &backup)){
|
||||||
if(tb ) tb ->type &= ~BLOCK_OPT;
|
if(tb ) tb ->type &= ~BLOCK_OPT;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user