Commit 58c03f6d authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote branch 'qatar/master'

* qatar/master:
  swscale: properly inline bits/endianness in yuv2yuvX16inC().
(We didnt pull the bug)  swscale: fix clipping of 9/10bit YUV420P.
  Add av_clip_uintp2() function
(our patch / duplicate)  dfa: fix buffer overflow checks to avoid integer overflows.
(our patch / duplicate)  movenc: always write esds descriptor length using 4 bytes.
(our patch / duplicate)  ffmpeg: use parse_number_and_die() when it makes sense
(No thanks)  ffmpeg: get rid of the 'q' key schizofrenia
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 01d3ebaf 9f54e461
...@@ -1329,9 +1329,7 @@ static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *m ...@@ -1329,9 +1329,7 @@ static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *m
filter_level += s->lf_delta.mode[mb->mode]; filter_level += s->lf_delta.mode[mb->mode];
} }
/* Like av_clip for inputs 0 and max, where max is equal to (2^n-1) */ filter_level = av_clip_uintp2(filter_level, 6);
#define POW2CLIP(x,max) (((x) & ~max) ? (-(x))>>31 & max : (x));
filter_level = POW2CLIP(filter_level, 63);
interior_limit = filter_level; interior_limit = filter_level;
if (s->filter.sharpness) { if (s->filter.sharpness) {
......
...@@ -171,6 +171,18 @@ static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a) ...@@ -171,6 +171,18 @@ static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
else return a; else return a;
} }
/**
* Clip a signed integer to an unsigned power of two range.
* @param a value to clip
* @param p bit position to clip at
* @return clipped value
*/
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
{
if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
else return a;
}
/** /**
* Clip a float value into the amin-amax range. * Clip a float value into the amin-amax range.
* @param a value to clip * @param a value to clip
...@@ -364,6 +376,9 @@ static av_always_inline av_const int av_popcount_c(uint32_t x) ...@@ -364,6 +376,9 @@ static av_always_inline av_const int av_popcount_c(uint32_t x)
#ifndef av_clipl_int32 #ifndef av_clipl_int32
# define av_clipl_int32 av_clipl_int32_c # define av_clipl_int32 av_clipl_int32_c
#endif #endif
#ifndef av_clip_uintp2
# define av_clip_uintp2 av_clip_uintp2_c
#endif
#ifndef av_clipf #ifndef av_clipf
# define av_clipf av_clipf_c # define av_clipf av_clipf_c
#endif #endif
......
...@@ -367,6 +367,20 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co ...@@ -367,6 +367,20 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co
//FIXME Optimize (just quickly written not optimized..) //FIXME Optimize (just quickly written not optimized..)
int i; int i;
#define output_pixel(pos, val) \
if (big_endian) { \
if (output_bits == 16) { \
AV_WB16(pos, av_clip_uint16(val >> shift)); \
} else { \
AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
} \
} else { \
if (output_bits == 16) { \
AV_WL16(pos, av_clip_uint16(val >> shift)); \
} else { \
AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
} \
}
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {
int val = 1 << 10; int val = 1 << 10;
int j; int j;
...@@ -374,11 +388,7 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co ...@@ -374,11 +388,7 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co
for (j = 0; j < lumFilterSize; j++) for (j = 0; j < lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j]; val += lumSrc[j][i] * lumFilter[j];
if (big_endian) { output_pixel(&dest[i], val);
AV_WB16(&dest[i], av_clip_uint16(val >> 11));
} else {
AV_WL16(&dest[i], av_clip_uint16(val >> 11));
}
} }
if (uDest) { if (uDest) {
...@@ -392,13 +402,8 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co ...@@ -392,13 +402,8 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co
v += chrSrc[j][i + VOFW] * chrFilter[j]; v += chrSrc[j][i + VOFW] * chrFilter[j];
} }
if (big_endian) { output_pixel(&uDest[i], u);
AV_WB16(&uDest[i], av_clip_uint16(u >> 11)); output_pixel(&vDest[i], v);
AV_WB16(&vDest[i], av_clip_uint16(v >> 11));
} else {
AV_WL16(&uDest[i], av_clip_uint16(u >> 11));
AV_WL16(&vDest[i], av_clip_uint16(v >> 11));
}
} }
} }
...@@ -410,11 +415,7 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co ...@@ -410,11 +415,7 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co
for (j = 0; j < lumFilterSize; j++) for (j = 0; j < lumFilterSize; j++)
val += alpSrc[j][i] * lumFilter[j]; val += alpSrc[j][i] * lumFilter[j];
if (big_endian) { output_pixel(&aDest[i], val);
AV_WB16(&aDest[i], av_clip_uint16(val >> 11));
} else {
AV_WL16(&aDest[i], av_clip_uint16(val >> 11));
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment