FFmpeg  4.3
colorspacedsp_yuv2yuv_template.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/avassert.h"
22 
23 #undef opixel
24 #define opixel pixel
25 
26 #undef ipixel
27 #if IN_BIT_DEPTH == 8
28 #define ipixel uint8_t
29 #else
30 #define ipixel uint16_t
31 #endif
32 
33 #undef fn
34 #undef fn2
35 #undef fn3
36 #define fn3(a,b,c,d) a##_##d##p##b##to##c##_c
37 #define fn2(a,b,c,d) fn3(a,b,c,d)
38 #define fn(a) fn2(a, IN_BIT_DEPTH, OUT_BIT_DEPTH, ss)
39 
40 static void fn(yuv2yuv)(uint8_t *_dst[3], const ptrdiff_t dst_stride[3],
41  uint8_t *_src[3], const ptrdiff_t src_stride[3],
42  int w, int h, const int16_t c[3][3][8],
43  const int16_t yuv_offset[2][8])
44 {
45  opixel **dst = (opixel **) _dst;
46  ipixel **src = (ipixel **) _src;
47  const ipixel *src0 = src[0], *src1 = src[1], *src2 = src[2];
48  opixel *dst0 = dst[0], *dst1 = dst[1], *dst2 = dst[2];
49  int y, x;
50  const int sh = 14 + IN_BIT_DEPTH - OUT_BIT_DEPTH;
51  const int rnd = 1 << (sh - 1);
52  int y_off_in = yuv_offset[0][0];
53  int y_off_out = yuv_offset[1][0] << sh;
54  const int uv_off_in = 128 << (IN_BIT_DEPTH - 8);
55  const int uv_off_out = rnd + (128 << (OUT_BIT_DEPTH - 8 + sh));
56  int cyy = c[0][0][0], cyu = c[0][1][0], cyv = c[0][2][0];
57  int cuu = c[1][1][0], cuv = c[1][2][0], cvu = c[2][1][0], cvv = c[2][2][0];
58 
59  av_assert2(c[1][0][0] == 0);
60  av_assert2(c[2][0][0] == 0);
61  w = AV_CEIL_RSHIFT(w, SS_W);
62  h = AV_CEIL_RSHIFT(h, SS_H);
63  for (y = 0; y < h; y++) {
64  for (x = 0; x < w; x++) {
65  int y00 = src0[x << SS_W] - y_off_in;
66 #if SS_W == 1
67  int y01 = src0[2 * x + 1] - y_off_in;
68 #if SS_H == 1
69  int y10 = src0[src_stride[0] / sizeof(ipixel) + 2 * x] - y_off_in;
70  int y11 = src0[src_stride[0] / sizeof(ipixel) + 2 * x + 1] - y_off_in;
71 #endif
72 #endif
73  int u = src1[x] - uv_off_in, v = src2[x] - uv_off_in;
74  int uv_val = cyu * u + cyv * v + rnd + y_off_out;
75 
76  dst0[x << SS_W] = av_clip_pixel((cyy * y00 + uv_val) >> sh);
77 #if SS_W == 1
78  dst0[x * 2 + 1] = av_clip_pixel((cyy * y01 + uv_val) >> sh);
79 #if SS_H == 1
80  dst0[x * 2 + 0 + dst_stride[0] / sizeof(opixel)] =
81  av_clip_pixel((cyy * y10 + uv_val) >> sh);
82  dst0[x * 2 + 1 + dst_stride[0] / sizeof(opixel)] =
83  av_clip_pixel((cyy * y11 + uv_val) >> sh);
84 #endif
85 #endif
86 
87  dst1[x] = av_clip_pixel((u * cuu + v * cuv + uv_off_out) >> sh);
88  dst2[x] = av_clip_pixel((u * cvu + v * cvv + uv_off_out) >> sh);
89  }
90 
91  dst0 += (dst_stride[0] * (1 << SS_H)) / sizeof(opixel);
92  dst1 += dst_stride[1] / sizeof(opixel);
93  dst2 += dst_stride[2] / sizeof(opixel);
94  src0 += (src_stride[0] * (1 << SS_H)) / sizeof(ipixel);
95  src1 += src_stride[1] / sizeof(ipixel);
96  src2 += src_stride[2] / sizeof(ipixel);
97  }
98 }
SS_H
#define SS_H
Definition: colorspacedsp.c:63
SS_W
#define SS_W
Definition: colorspacedsp.c:62
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:262
OUT_BIT_DEPTH
#define OUT_BIT_DEPTH
Definition: colorspacedsp_template.c:332
IN_BIT_DEPTH
#define IN_BIT_DEPTH
Definition: colorspacedsp_template.c:341
x
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
Definition: fate.txt:150
avassert.h
rnd
#define rnd()
Definition: checkasm.h:107
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
ipixel
#define ipixel
Definition: colorspacedsp_yuv2yuv_template.c:30
src
#define src
Definition: vp8dsp.c:254
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
src0
#define src0
Definition: h264pred.c:138
src1
#define src1
Definition: h264pred.c:139
yuv2yuv
static void fn() yuv2yuv(uint8_t *_dst[3], const ptrdiff_t dst_stride[3], uint8_t *_src[3], const ptrdiff_t src_stride[3], int w, int h, const int16_t c[3][3][8], const int16_t yuv_offset[2][8])
Definition: colorspacedsp_yuv2yuv_template.c:40
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
uint8_t
uint8_t
Definition: audio_convert.c:194
w
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo ug o o w
Definition: fate.txt:150
opixel
#define opixel
Definition: colorspacedsp_yuv2yuv_template.c:24
av_clip_pixel
#define av_clip_pixel(a)
Definition: bit_depth_template.c:98
h
h
Definition: vp9dsp_template.c:2038
fn
#define fn(a)
Definition: colorspacedsp_yuv2yuv_template.c:38