summaryrefslogtreecommitdiff
path: root/libavfilter/vf_framerate.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2018-01-08 21:01:09 +0100
committerMarton Balint <cus@passwd.hu>2018-01-28 17:07:37 +0100
commit5bf774a4a448418c6977c744fbf1ec74659eb0d3 (patch)
treec96a940b839434b96f82616a80e24bca23e04f78 /libavfilter/vf_framerate.c
parent293f24b42c5d116172510768802d85de3d7d0d62 (diff)
avfilter/vf_framerate: unify luma and chroma blending
The expressions were mathematically equvivalent... Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavfilter/vf_framerate.c')
-rw-r--r--libavfilter/vf_framerate.c60
1 files changed, 15 insertions, 45 deletions
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index a5ae6ddb71..583c96e02c 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -196,32 +196,16 @@ static int filter_slice8(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
cpy_src2_data += start * cpy_src2_line_size;
cpy_dst_data += start * cpy_dst_line_size;
- if (plane <1 || plane >2) {
- // luma or alpha
- for (line = start; line < end; line++) {
- for (pixel = 0; pixel < cpy_line_width; pixel++) {
- // integer version of (src1 * src1_factor) + (src2 + src2_factor) + 0.5
- // 0.5 is for rounding
- // 128 is the integer representation of 0.5 << 8
- cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + (cpy_src2_data[pixel] * src2_factor) + 128) >> 8;
- }
- cpy_src1_data += cpy_src1_line_size;
- cpy_src2_data += cpy_src2_line_size;
- cpy_dst_data += cpy_dst_line_size;
- }
- } else {
- // chroma
- for (line = start; line < end; line++) {
- for (pixel = 0; pixel < cpy_line_width; pixel++) {
- // as above
- // because U and V are based around 128 we have to subtract 128 from the components.
- // 32896 is the integer representation of 128.5 << 8
- cpy_dst_data[pixel] = (((cpy_src1_data[pixel] - 128) * src1_factor) + ((cpy_src2_data[pixel] - 128) * src2_factor) + 32896) >> 8;
- }
- cpy_src1_data += cpy_src1_line_size;
- cpy_src2_data += cpy_src2_line_size;
- cpy_dst_data += cpy_dst_line_size;
+ for (line = start; line < end; line++) {
+ for (pixel = 0; pixel < cpy_line_width; pixel++) {
+ // integer version of (src1 * src1_factor) + (src2 + src2_factor) + 0.5
+ // 0.5 is for rounding
+ // 128 is the integer representation of 0.5 << 8
+ cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + (cpy_src2_data[pixel] * src2_factor) + 128) >> 8;
}
+ cpy_src1_data += cpy_src1_line_size;
+ cpy_src2_data += cpy_src2_line_size;
+ cpy_dst_data += cpy_dst_line_size;
}
}
@@ -235,7 +219,6 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
uint16_t src1_factor = td->src1_factor;
uint16_t src2_factor = td->src2_factor;
const int half = s->max / 2;
- const int uv = (s->max + 1) * half;
const int shift = s->bitdepth;
int plane, line, pixel;
@@ -254,25 +237,12 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
cpy_src2_data += start * cpy_src2_line_size;
cpy_dst_data += start * cpy_dst_line_size;
- if (plane <1 || plane >2) {
- // luma or alpha
- for (line = start; line < end; line++) {
- for (pixel = 0; pixel < cpy_line_width; pixel++)
- cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + (cpy_src2_data[pixel] * src2_factor) + half) >> shift;
- cpy_src1_data += cpy_src1_line_size;
- cpy_src2_data += cpy_src2_line_size;
- cpy_dst_data += cpy_dst_line_size;
- }
- } else {
- // chroma
- for (line = start; line < end; line++) {
- for (pixel = 0; pixel < cpy_line_width; pixel++) {
- cpy_dst_data[pixel] = (((cpy_src1_data[pixel] - half) * src1_factor) + ((cpy_src2_data[pixel] - half) * src2_factor) + uv) >> shift;
- }
- cpy_src1_data += cpy_src1_line_size;
- cpy_src2_data += cpy_src2_line_size;
- cpy_dst_data += cpy_dst_line_size;
- }
+ for (line = start; line < end; line++) {
+ for (pixel = 0; pixel < cpy_line_width; pixel++)
+ cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + (cpy_src2_data[pixel] * src2_factor) + half) >> shift;
+ cpy_src1_data += cpy_src1_line_size;
+ cpy_src2_data += cpy_src2_line_size;
+ cpy_dst_data += cpy_dst_line_size;
}
}