FFmpeg  4.3
dsd.c
Go to the documentation of this file.
1 /*
2  * Direct Stream Digital (DSD) decoder
3  * based on BSD licensed dsd2pcm by Sebastian Gesemann
4  * Copyright (c) 2009, 2011 Sebastian Gesemann. All rights reserved.
5  * Copyright (c) 2014 Peter Ross
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include "libavcodec/internal.h"
25 #include "libavcodec/mathops.h"
26 #include "avcodec.h"
27 #include "dsd_tablegen.h"
28 #include "dsd.h"
29 
30 static av_cold void dsd_ctables_tableinit(void)
31 {
32  int t, e, m, sign;
33  double acc[CTABLES];
34  for (e = 0; e < 256; ++e) {
35  memset(acc, 0, sizeof(acc));
36  for (m = 0; m < 8; ++m) {
37  sign = (((e >> (7 - m)) & 1) * 2 - 1);
38  for (t = 0; t < CTABLES; ++t)
39  acc[t] += sign * htaps[t * 8 + m];
40  }
41  for (t = 0; t < CTABLES; ++t)
42  ctables[CTABLES - 1 - t][e] = acc[t];
43  }
44 }
45 
47 {
48  static int done = 0;
49  if (done)
50  return;
52  done = 1;
53 }
54 
55 void ff_dsd2pcm_translate(DSDContext* s, size_t samples, int lsbf,
56  const uint8_t *src, ptrdiff_t src_stride,
57  float *dst, ptrdiff_t dst_stride)
58 {
59  uint8_t buf[FIFOSIZE];
60  unsigned pos, i;
61  uint8_t* p;
62  double sum;
63 
64  pos = s->pos;
65 
66  memcpy(buf, s->buf, sizeof(buf));
67 
68  while (samples-- > 0) {
69  buf[pos] = lsbf ? ff_reverse[*src] : *src;
70  src += src_stride;
71 
72  p = buf + ((pos - CTABLES) & FIFOMASK);
73  *p = ff_reverse[*p];
74 
75  sum = 0.0;
76  for (i = 0; i < CTABLES; i++) {
77  uint8_t a = buf[(pos - i) & FIFOMASK];
78  uint8_t b = buf[(pos - (CTABLES*2 - 1) + i) & FIFOMASK];
79  sum += ctables[i][a] + ctables[i][b];
80  }
81 
82  *dst = (float)sum;
83  dst += dst_stride;
84 
85  pos = (pos + 1) & FIFOMASK;
86  }
87 
88  s->pos = pos;
89  memcpy(s->buf, buf, sizeof(buf));
90 }
acc
int acc
Definition: yuv2rgb.c:555
internal.h
b
#define b
Definition: input.c:41
ff_reverse
const uint8_t ff_reverse[256]
Definition: reverse.c:23
samples
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 samples
Definition: fate.txt:139
dsd.h
CTABLES
#define CTABLES
Definition: dsd_tablegen.h:31
FIFOMASK
#define FIFOMASK
Definition: dsd.h:33
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:257
ctables
static float ctables[CTABLES][256]
Definition: dsd_tablegen.h:74
src
#define src
Definition: vp8dsp.c:254
mathops.h
ff_init_dsd_data
av_cold void ff_init_dsd_data(void)
Definition: dsd.c:46
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
uint8_t
uint8_t
Definition: audio_convert.c:194
dsd_ctables_tableinit
static av_cold void dsd_ctables_tableinit(void)
Definition: dsd.c:30
DSDContext
Per-channel buffer.
Definition: dsd.h:42
avcodec.h
ff_dsd2pcm_translate
void ff_dsd2pcm_translate(DSDContext *s, size_t samples, int lsbf, const uint8_t *src, ptrdiff_t src_stride, float *dst, ptrdiff_t dst_stride)
Definition: dsd.c:55
pos
unsigned int pos
Definition: spdifenc.c:410
FIFOSIZE
#define FIFOSIZE
Definition: dsd.h:32
htaps
static const double htaps[HTAPS]
The 2nd half (48 coeffs) of a 96-tap symmetric lowpass filter.
Definition: dsd_tablegen.h:55
dsd_tablegen.h