Kill all tabs

I hate tabs.

This replaces all tabs in all source files with spaces. The only
exception is old-makefile. The replacement was made by running the
GNU coreutils "expand" command on every file. Since the replacement was
automatic, it's possible that some formatting was destroyed (but perhaps
only if it was assuming that the end of a tab does not correspond to
aligning the end to multiples of 8 spaces).
This commit is contained in:
wm4
2014-04-13 18:00:51 +02:00
parent 44f382cf98
commit 78128bddda
65 changed files with 6487 additions and 6487 deletions

View File

@@ -35,7 +35,7 @@
// Data for specific instances of this filter // Data for specific instances of this filter
typedef struct af_center_s typedef struct af_center_s
{ {
int ch; // Channel number which to insert the filtered data int ch; // Channel number which to insert the filtered data
}af_center_t; }af_center_t;
// Initialization and runtime control // Initialization and runtime control
@@ -61,12 +61,12 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter // Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags) static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{ {
struct mp_audio* c = data; // Current working data struct mp_audio* c = data; // Current working data
af_center_t* s = af->priv; // Setup for this instance af_center_t* s = af->priv; // Setup for this instance
float* a = c->planes[0]; // Audio data float* a = c->planes[0]; // Audio data
int nch = c->nch; // Number of channels int nch = c->nch; // Number of channels
int len = c->samples*c->nch; // Number of samples in current audio block int len = c->samples*c->nch; // Number of samples in current audio block
int ch = s->ch; // Channel in which to insert the center audio int ch = s->ch; // Channel in which to insert the center audio
register int i; register int i;
// Run filter // Run filter

View File

@@ -114,7 +114,7 @@ static void copy(struct af_instance *af, void* in, void* out,
} }
default: default:
MP_ERR(af, "Unsupported number of bytes/sample: %i" MP_ERR(af, "Unsupported number of bytes/sample: %i"
" please report this error on the MPlayer mailing list. \n",bps); " please report this error on the MPlayer mailing list. \n",bps);
} }
} }
@@ -125,7 +125,7 @@ static int check_routes(struct af_instance *af, int nin, int nout)
int i; int i;
if((s->nr < 1) || (s->nr > AF_NCH)){ if((s->nr < 1) || (s->nr > AF_NCH)){
MP_ERR(af, "The number of routing pairs must be" MP_ERR(af, "The number of routing pairs must be"
" between 1 and %i. Current value is %i\n",AF_NCH,s->nr); " between 1 and %i. Current value is %i\n",AF_NCH,s->nr);
return AF_ERROR; return AF_ERROR;
} }
@@ -154,22 +154,22 @@ static int control(struct af_instance* af, int cmd, void* arg)
int i; int i;
// Make sure this filter isn't redundant // Make sure this filter isn't redundant
if(af->data->nch == ((struct mp_audio*)arg)->nch) if(af->data->nch == ((struct mp_audio*)arg)->nch)
return AF_DETACH; return AF_DETACH;
// If mono: fake stereo // If mono: fake stereo
if(((struct mp_audio*)arg)->nch == 1){ if(((struct mp_audio*)arg)->nch == 1){
s->nr = MPMIN(af->data->nch,2); s->nr = MPMIN(af->data->nch,2);
for(i=0;i<s->nr;i++){ for(i=0;i<s->nr;i++){
s->route[i][FR] = 0; s->route[i][FR] = 0;
s->route[i][TO] = i; s->route[i][TO] = i;
} }
} }
else{ else{
s->nr = MPMIN(af->data->nch, ((struct mp_audio*)arg)->nch); s->nr = MPMIN(af->data->nch, ((struct mp_audio*)arg)->nch);
for(i=0;i<s->nr;i++){ for(i=0;i<s->nr;i++){
s->route[i][FR] = i; s->route[i][FR] = i;
s->route[i][TO] = i; s->route[i][TO] = i;
} }
} }
} }
@@ -184,10 +184,10 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter // Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags) static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{ {
struct mp_audio* c = data; // Current working data struct mp_audio* c = data; // Current working data
struct mp_audio* l = af->data; // Local data struct mp_audio* l = af->data; // Local data
af_channels_t* s = af->priv; af_channels_t* s = af->priv;
int i; int i;
mp_audio_realloc_min(af->data, data->samples); mp_audio_realloc_min(af->data, data->samples);
@@ -197,7 +197,7 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
if(AF_OK == check_routes(af,c->nch,l->nch)) if(AF_OK == check_routes(af,c->nch,l->nch))
for(i=0;i<s->nr;i++) for(i=0;i<s->nr;i++)
copy(af, c->planes[0],l->planes[0],c->nch,s->route[i][FR], copy(af, c->planes[0],l->planes[0],c->nch,s->route[i][FR],
l->nch,s->route[i][TO],mp_audio_psize(c),c->bps); l->nch,s->route[i][TO],mp_audio_psize(c),c->bps);
// Set output data // Set output data
c->planes[0] = l->planes[0]; c->planes[0] = l->planes[0];

View File

@@ -37,10 +37,10 @@
// Data for specific instances of this filter // Data for specific instances of this filter
typedef struct af_delay_s typedef struct af_delay_s
{ {
void* q[AF_NCH]; // Circular queues used for delaying audio signal void* q[AF_NCH]; // Circular queues used for delaying audio signal
int wi[AF_NCH]; // Write index int wi[AF_NCH]; // Write index
int ri; // Read index int ri; // Read index
float d[AF_NCH]; // Delay [ms] float d[AF_NCH]; // Delay [ms]
char *delaystr; char *delaystr;
}af_delay_t; }af_delay_t;
@@ -69,7 +69,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
for(i=0;i<af->data->nch;i++){ for(i=0;i<af->data->nch;i++){
s->q[i] = calloc(L,af->data->bps); s->q[i] = calloc(L,af->data->bps);
if(NULL == s->q[i]) if(NULL == s->q[i])
MP_FATAL(af, "Out of memory\n"); MP_FATAL(af, "Out of memory\n");
} }
if(AF_OK != af_from_ms(AF_NCH, s->d, s->wi, af->data->rate, 0.0, 1000.0)) if(AF_OK != af_from_ms(AF_NCH, s->d, s->wi, af->data->rate, 0.0, 1000.0))
@@ -99,12 +99,12 @@ static void uninit(struct af_instance* af)
// Filter data through filter // Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags) static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{ {
struct mp_audio* c = data; // Current working data struct mp_audio* c = data; // Current working data
af_delay_t* s = af->priv; // Setup for this instance af_delay_t* s = af->priv; // Setup for this instance
int nch = c->nch; // Number of channels int nch = c->nch; // Number of channels
int len = mp_audio_psize(c)/c->bps; // Number of sample in data chunk int len = mp_audio_psize(c)/c->bps; // Number of sample in data chunk
int ri = 0; int ri = 0;
int ch,i; int ch,i;
for(ch=0;ch<nch;ch++){ for(ch=0;ch<nch;ch++){
switch(c->bps){ switch(c->bps){
case 1:{ case 1:{
@@ -113,10 +113,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch]; int wi = s->wi[ch];
ri = s->ri; ri = s->ri;
for(i=ch;i<len;i+=nch){ for(i=ch;i<len;i+=nch){
q[wi] = a[i]; q[wi] = a[i];
a[i] = q[ri]; a[i] = q[ri];
UPDATEQI(wi); UPDATEQI(wi);
UPDATEQI(ri); UPDATEQI(ri);
} }
s->wi[ch] = wi; s->wi[ch] = wi;
break; break;
@@ -127,10 +127,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch]; int wi = s->wi[ch];
ri = s->ri; ri = s->ri;
for(i=ch;i<len;i+=nch){ for(i=ch;i<len;i+=nch){
q[wi] = a[i]; q[wi] = a[i];
a[i] = q[ri]; a[i] = q[ri];
UPDATEQI(wi); UPDATEQI(wi);
UPDATEQI(ri); UPDATEQI(ri);
} }
s->wi[ch] = wi; s->wi[ch] = wi;
break; break;
@@ -141,10 +141,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch]; int wi = s->wi[ch];
ri = s->ri; ri = s->ri;
for(i=ch;i<len;i+=nch){ for(i=ch;i<len;i+=nch){
q[wi] = a[i]; q[wi] = a[i];
a[i] = q[ri]; a[i] = q[ri];
UPDATEQI(wi); UPDATEQI(wi);
UPDATEQI(ri); UPDATEQI(ri);
} }
s->wi[ch] = wi; s->wi[ch] = wi;
break; break;

View File

@@ -70,8 +70,8 @@ typedef struct af_volume_s
// method 2 // method 2
int idx; int idx;
struct { struct {
float avg; // average level of the sample float avg; // average level of the sample
int len; // sample size (weight) int len; // sample size (weight)
} mem[NSAMPLES]; } mem[NSAMPLES];
// "Ideal" level // "Ideal" level
float mid_s16; float mid_s16;
@@ -100,8 +100,8 @@ static int control(struct af_instance* af, int cmd, void* arg)
static void method1_int16(af_drc_t *s, struct mp_audio *c) static void method1_int16(af_drc_t *s, struct mp_audio *c)
{ {
register int i = 0; register int i = 0;
int16_t *data = (int16_t*)c->planes[0]; // Audio data int16_t *data = (int16_t*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, neededmul; float curavg = 0.0, newavg, neededmul;
int tmp; int tmp;
@@ -142,8 +142,8 @@ static void method1_int16(af_drc_t *s, struct mp_audio *c)
static void method1_float(af_drc_t *s, struct mp_audio *c) static void method1_float(af_drc_t *s, struct mp_audio *c)
{ {
register int i = 0; register int i = 0;
float *data = (float*)c->planes[0]; // Audio data float *data = (float*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, neededmul, tmp; float curavg = 0.0, newavg, neededmul, tmp;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
@@ -179,8 +179,8 @@ static void method1_float(af_drc_t *s, struct mp_audio *c)
static void method2_int16(af_drc_t *s, struct mp_audio *c) static void method2_int16(af_drc_t *s, struct mp_audio *c)
{ {
register int i = 0; register int i = 0;
int16_t *data = (int16_t*)c->planes[0]; // Audio data int16_t *data = (int16_t*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, avg = 0.0; float curavg = 0.0, newavg, avg = 0.0;
int tmp, totallen = 0; int tmp, totallen = 0;
@@ -204,8 +204,8 @@ static void method2_int16(af_drc_t *s, struct mp_audio *c)
avg /= (float)totallen; avg /= (float)totallen;
if (avg >= SIL_S16) if (avg >= SIL_S16)
{ {
s->mul = s->mid_s16 / avg; s->mul = s->mid_s16 / avg;
s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX); s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
} }
} }
@@ -229,8 +229,8 @@ static void method2_int16(af_drc_t *s, struct mp_audio *c)
static void method2_float(af_drc_t *s, struct mp_audio *c) static void method2_float(af_drc_t *s, struct mp_audio *c)
{ {
register int i = 0; register int i = 0;
float *data = (float*)c->planes[0]; // Audio data float *data = (float*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, avg = 0.0, tmp; float curavg = 0.0, newavg, avg = 0.0, tmp;
int totallen = 0; int totallen = 0;
@@ -254,8 +254,8 @@ static void method2_float(af_drc_t *s, struct mp_audio *c)
avg /= (float)totallen; avg /= (float)totallen;
if (avg >= SIL_FLOAT) if (avg >= SIL_FLOAT)
{ {
s->mul = s->mid_float / avg; s->mul = s->mid_float / avg;
s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX); s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
} }
} }
@@ -279,16 +279,16 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
if(af->data->format == (AF_FORMAT_S16)) if(af->data->format == (AF_FORMAT_S16))
{ {
if (s->method == 2) if (s->method == 2)
method2_int16(s, data); method2_int16(s, data);
else else
method1_int16(s, data); method1_int16(s, data);
} }
else if(af->data->format == (AF_FORMAT_FLOAT)) else if(af->data->format == (AF_FORMAT_FLOAT))
{ {
if (s->method == 2) if (s->method == 2)
method2_float(s, data); method2_float(s, data);
else else
method1_float(s, data); method1_float(s, data);
} }
return 0; return 0;
} }

View File

@@ -34,7 +34,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
case AF_CONTROL_REINIT: ; case AF_CONTROL_REINIT: ;
*af->data = *(struct mp_audio*)arg; *af->data = *(struct mp_audio*)arg;
MP_VERBOSE(af, "Was reinitialized: %iHz/%ich/%s\n", MP_VERBOSE(af, "Was reinitialized: %iHz/%ich/%s\n",
af->data->rate,af->data->nch,af_fmt_to_str(af->data->format)); af->data->rate,af->data->nch,af_fmt_to_str(af->data->format));
return AF_OK; return AF_OK;
} }
return AF_UNKNOWN; return AF_UNKNOWN;

View File

@@ -32,41 +32,41 @@
#include "common/common.h" #include "common/common.h"
#include "af.h" #include "af.h"
#define L 2 // Storage for filter taps #define L 2 // Storage for filter taps
#define KM 10 // Max number of bands #define KM 10 // Max number of bands
#define Q 1.2247449 /* Q value for band-pass filters 1.2247=(3/2)^(1/2) #define Q 1.2247449 /* Q value for band-pass filters 1.2247=(3/2)^(1/2)
gives 4dB suppression @ Fc*2 and Fc/2 */ gives 4dB suppression @ Fc*2 and Fc/2 */
/* Center frequencies for band-pass filters /* Center frequencies for band-pass filters
The different frequency bands are: The different frequency bands are:
nr. center frequency nr. center frequency
0 31.25 Hz 0 31.25 Hz
1 62.50 Hz 1 62.50 Hz
2 125.0 Hz 2 125.0 Hz
3 250.0 Hz 3 250.0 Hz
4 500.0 Hz 4 500.0 Hz
5 1.000 kHz 5 1.000 kHz
6 2.000 kHz 6 2.000 kHz
7 4.000 kHz 7 4.000 kHz
8 8.000 kHz 8 8.000 kHz
9 16.00 kHz 9 16.00 kHz
*/ */
#define CF {31.25,62.5,125,250,500,1000,2000,4000,8000,16000} #define CF {31.25,62.5,125,250,500,1000,2000,4000,8000,16000}
// Maximum and minimum gain for the bands // Maximum and minimum gain for the bands
#define G_MAX +12.0 #define G_MAX +12.0
#define G_MIN -12.0 #define G_MIN -12.0
// Data for specific instances of this filter // Data for specific instances of this filter
typedef struct af_equalizer_s typedef struct af_equalizer_s
{ {
float a[KM][L]; // A weights float a[KM][L]; // A weights
float b[KM][L]; // B weights float b[KM][L]; // B weights
float wq[AF_NCH][KM][L]; // Circular buffer for W data float wq[AF_NCH][KM][L]; // Circular buffer for W data
float g[AF_NCH][KM]; // Gain factor for each channel and band float g[AF_NCH][KM]; // Gain factor for each channel and band
int K; // Number of used eq bands int K; // Number of used eq bands
int channels; // Number of channels int channels; // Number of channels
float gain_factor; // applied at output to avoid clipping float gain_factor; // applied at output to avoid clipping
double p[KM]; double p[KM];
} af_equalizer_t; } af_equalizer_t;
@@ -108,7 +108,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
if(s->K != KM) if(s->K != KM)
MP_INFO(af, "Limiting the number of filters to" MP_INFO(af, "Limiting the number of filters to"
" %i due to low sample rate.\n",s->K); " %i due to low sample rate.\n",s->K);
// Generate filter taps // Generate filter taps
for(k=0;k<s->K;k++) for(k=0;k<s->K;k++)
@@ -144,33 +144,33 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter // Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags) static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{ {
struct mp_audio* c = data; // Current working data struct mp_audio* c = data; // Current working data
af_equalizer_t* s = (af_equalizer_t*)af->priv; // Setup af_equalizer_t* s = (af_equalizer_t*)af->priv; // Setup
uint32_t ci = af->data->nch; // Index for channels uint32_t ci = af->data->nch; // Index for channels
uint32_t nch = af->data->nch; // Number of channels uint32_t nch = af->data->nch; // Number of channels
while(ci--){ while(ci--){
float* g = s->g[ci]; // Gain factor float* g = s->g[ci]; // Gain factor
float* in = ((float*)c->planes[0])+ci; float* in = ((float*)c->planes[0])+ci;
float* out = ((float*)c->planes[0])+ci; float* out = ((float*)c->planes[0])+ci;
float* end = in + c->samples*c->nch; // Block loop end float* end = in + c->samples*c->nch; // Block loop end
while(in < end){ while(in < end){
register int k = 0; // Frequency band index register int k = 0; // Frequency band index
register float yt = *in; // Current input sample register float yt = *in; // Current input sample
in+=nch; in+=nch;
// Run the filters // Run the filters
for(;k<s->K;k++){ for(;k<s->K;k++){
// Pointer to circular buffer wq // Pointer to circular buffer wq
register float* wq = s->wq[ci][k]; register float* wq = s->wq[ci][k];
// Calculate output from AR part of current filter // Calculate output from AR part of current filter
register float w=yt*s->b[k][0] + wq[0]*s->a[k][0] + wq[1]*s->a[k][1]; register float w=yt*s->b[k][0] + wq[0]*s->a[k][0] + wq[1]*s->a[k][1];
// Calculate output form MA part of current filter // Calculate output form MA part of current filter
yt+=(w + wq[1]*s->b[k][1])*g[k]; yt+=(w + wq[1]*s->b[k][1])*g[k];
// Update circular buffer // Update circular buffer
wq[1] = wq[0]; wq[1] = wq[0];
wq[0] = w; wq[0] = w;
} }
// Calculate output // Calculate output
*out=yt*s->gain_factor; *out=yt*s->gain_factor;

View File

@@ -47,7 +47,7 @@
#define DEF_SZ 512 // default buffer size (in samples) #define DEF_SZ 512 // default buffer size (in samples)
#define SHARED_FILE "mpv-af_export" /* default file name #define SHARED_FILE "mpv-af_export" /* default file name
(relative to ~/.mpv/ */ (relative to ~/.mpv/ */
#define SIZE_HEADER (2 * sizeof(int) + sizeof(unsigned long long)) #define SIZE_HEADER (2 * sizeof(int) + sizeof(unsigned long long))
@@ -55,12 +55,12 @@
typedef struct af_export_s typedef struct af_export_s
{ {
unsigned long long count; // Used for sync unsigned long long count; // Used for sync
void* buf[AF_NCH]; // Buffers for storing the data before it is exported void* buf[AF_NCH]; // Buffers for storing the data before it is exported
int sz; // Size of buffer in samples int sz; // Size of buffer in samples
int wi; // Write index int wi; // Write index
int fd; // File descriptor to shared memory area int fd; // File descriptor to shared memory area
char* filename; // File to export data char* filename; // File to export data
uint8_t *mmap_area; // MMap shared area uint8_t *mmap_area; // MMap shared area
} af_export_t; } af_export_t;
@@ -109,7 +109,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
MP_INFO(af, "Exporting to file: %s\n", s->filename); MP_INFO(af, "Exporting to file: %s\n", s->filename);
if(s->fd < 0) { if(s->fd < 0) {
MP_FATAL(af, "Could not open/create file: %s\n", MP_FATAL(af, "Could not open/create file: %s\n",
s->filename); s->filename);
return AF_ERROR; return AF_ERROR;
} }
@@ -127,7 +127,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
if(s->mmap_area == NULL) if(s->mmap_area == NULL)
MP_FATAL(af, "Could not mmap file %s\n", s->filename); MP_FATAL(af, "Could not mmap file %s\n", s->filename);
MP_INFO(af, "Memory mapped to file: %s (%p)\n", MP_INFO(af, "Memory mapped to file: %s (%p)\n",
s->filename, s->mmap_area); s->filename, s->mmap_area);
// Initialize header // Initialize header
*((int*)s->mmap_area) = af->data->nch; *((int*)s->mmap_area) = af->data->nch;
@@ -164,27 +164,27 @@ static void uninit( struct af_instance* af )
*/ */
static int filter( struct af_instance* af, struct mp_audio* data, int flags) static int filter( struct af_instance* af, struct mp_audio* data, int flags)
{ {
struct mp_audio* c = data; // Current working data struct mp_audio* c = data; // Current working data
af_export_t* s = af->priv; // Setup for this instance af_export_t* s = af->priv; // Setup for this instance
int16_t* a = c->planes[0]; // Incomming sound int16_t* a = c->planes[0]; // Incomming sound
int nch = c->nch; // Number of channels int nch = c->nch; // Number of channels
int len = c->samples*c->nch; // Number of sample in data chunk int len = c->samples*c->nch; // Number of sample in data chunk
int sz = s->sz; // buffer size (in samples) int sz = s->sz; // buffer size (in samples)
int flag = 0; // Set to 1 if buffer is filled int flag = 0; // Set to 1 if buffer is filled
int ch, i; int ch, i;
// Fill all buffers // Fill all buffers
for(ch = 0; ch < nch; ch++){ for(ch = 0; ch < nch; ch++){
int wi = s->wi; // Reset write index int wi = s->wi; // Reset write index
int16_t* b = s->buf[ch]; // Current buffer int16_t* b = s->buf[ch]; // Current buffer
// Copy data to export buffers // Copy data to export buffers
for(i = ch; i < len; i += nch){ for(i = ch; i < len; i += nch){
b[wi++] = a[i]; b[wi++] = a[i];
if(wi >= sz){ // Don't write outside the end of the buffer if(wi >= sz){ // Don't write outside the end of the buffer
flag = 1; flag = 1;
break; break;
} }
} }
s->wi = wi % s->sz; s->wi = wi % s->sz;
@@ -196,7 +196,7 @@ static int filter( struct af_instance* af, struct mp_audio* data, int flags)
memcpy(s->mmap_area + SIZE_HEADER, s->buf[0], sz * c->bps * nch); memcpy(s->mmap_area + SIZE_HEADER, s->buf[0], sz * c->bps * nch);
s->count++; // increment counter (to sync) s->count++; // increment counter (to sync)
memcpy(s->mmap_area + SIZE_HEADER - sizeof(s->count), memcpy(s->mmap_area + SIZE_HEADER - sizeof(s->count),
&(s->count), sizeof(s->count)); &(s->count), sizeof(s->count));
} }
return 0; return 0;

View File

@@ -51,11 +51,11 @@ static int control(struct af_instance* af, int cmd, void* arg)
mp_audio_set_num_channels(af->data, 2); mp_audio_set_num_channels(af->data, 2);
if (af->data->format == AF_FORMAT_FLOAT) if (af->data->format == AF_FORMAT_FLOAT)
{ {
af->filter = play_float; af->filter = play_float;
}// else }// else
{ {
mp_audio_set_format(af->data, AF_FORMAT_S16); mp_audio_set_format(af->data, AF_FORMAT_S16);
af->filter = play_s16; af->filter = play_s16;
} }
return af_test_output(af,(struct mp_audio*)arg); return af_test_output(af,(struct mp_audio*)arg);
@@ -69,8 +69,8 @@ static int play_s16(struct af_instance* af, struct mp_audio* data, int f)
{ {
af_extrastereo_t *s = af->priv; af_extrastereo_t *s = af->priv;
register int i = 0; register int i = 0;
int16_t *a = (int16_t*)data->planes[0]; // Audio data int16_t *a = (int16_t*)data->planes[0]; // Audio data
int len = data->samples*data->nch; // Number of samples int len = data->samples*data->nch; // Number of samples
int avg, l, r; int avg, l, r;
for (i = 0; i < len; i+=2) for (i = 0; i < len; i+=2)
@@ -91,8 +91,8 @@ static int play_float(struct af_instance* af, struct mp_audio* data, int f)
{ {
af_extrastereo_t *s = af->priv; af_extrastereo_t *s = af->priv;
register int i = 0; register int i = 0;
float *a = (float*)data->planes[0]; // Audio data float *a = (float*)data->planes[0]; // Audio data
int len = data->samples * data->nch; // Number of samples int len = data->samples * data->nch; // Number of samples
float avg, l, r; float avg, l, r;
for (i = 0; i < len; i+=2) for (i = 0; i < len; i+=2)

View File

@@ -75,23 +75,23 @@ typedef struct af_hrtf_s {
} af_hrtf_t; } af_hrtf_t;
/* Convolution on a ring buffer /* Convolution on a ring buffer
* nx: length of the ring buffer * nx: length of the ring buffer
* nk: length of the convolution kernel * nk: length of the convolution kernel
* sx: ring buffer * sx: ring buffer
* sk: convolution kernel * sk: convolution kernel
* offset: offset on the ring buffer, can be * offset: offset on the ring buffer, can be
*/ */
static float conv(const int nx, const int nk, const float *sx, const float *sk, static float conv(const int nx, const int nk, const float *sx, const float *sk,
const int offset) const int offset)
{ {
/* k = reminder of offset / nx */ /* k = reminder of offset / nx */
int k = offset >= 0 ? offset % nx : nx + (offset % nx); int k = offset >= 0 ? offset % nx : nx + (offset % nx);
if(nk + k <= nx) if(nk + k <= nx)
return af_filter_fir(nk, sx + k, sk); return af_filter_fir(nk, sx + k, sk);
else else
return af_filter_fir(nk + k - nx, sx, sk + nx - k) + return af_filter_fir(nk + k - nx, sx, sk + nx - k) +
af_filter_fir(nx - k, sx + k, sk); af_filter_fir(nx - k, sx + k, sk);
} }
/* Detect when the impulse response starts (significantly) */ /* Detect when the impulse response starts (significantly) */
@@ -104,8 +104,8 @@ static int pulse_detect(const float *sx)
int i; int i;
for(i = 0; i < nmax; i++) for(i = 0; i < nmax; i++)
if(fabs(sx[i]) > thresh) if(fabs(sx[i]) > thresh)
return i; return i;
return 0; return 0;
} }
@@ -122,14 +122,14 @@ static inline float passive_lock(float x)
/* Unified active matrix decoder for 2 channel matrix encoded surround /* Unified active matrix decoder for 2 channel matrix encoded surround
sources */ sources */
static inline void matrix_decode(short *in, const int k, const int il, static inline void matrix_decode(short *in, const int k, const int il,
const int ir, const int decode_rear, const int ir, const int decode_rear,
const int dlbuflen, const int dlbuflen,
float l_fwr, float r_fwr, float l_fwr, float r_fwr,
float lpr_fwr, float lmr_fwr, float lpr_fwr, float lmr_fwr,
float *adapt_l_gain, float *adapt_r_gain, float *adapt_l_gain, float *adapt_r_gain,
float *adapt_lpr_gain, float *adapt_lmr_gain, float *adapt_lpr_gain, float *adapt_lmr_gain,
float *lf, float *rf, float *lr, float *lf, float *rf, float *lr,
float *rr, float *cf) float *rr, float *cf)
{ {
const int kr = (k + MATREARDELAY) % dlbuflen; const int kr = (k + MATREARDELAY) % dlbuflen;
float l_gain = (l_fwr + r_fwr) / float l_gain = (l_fwr + r_fwr) /
@@ -161,13 +161,13 @@ static inline void matrix_decode(short *in, const int k, const int il,
fp_out = fopen("af_hrtf.log", "w"); fp_out = fopen("af_hrtf.log", "w");
if(counter % 240 == 0) if(counter % 240 == 0)
fprintf(fp_out, "%g %g %g %g %g ", counter * (1.0 / 48000), fprintf(fp_out, "%g %g %g %g %g ", counter * (1.0 / 48000),
l_gain, r_gain, lpr_gain, lmr_gain); l_gain, r_gain, lpr_gain, lmr_gain);
#endif #endif
/*** AXIS NO. 1: (Lt, Rt) -> (C, Ls, Rs) ***/ /*** AXIS NO. 1: (Lt, Rt) -> (C, Ls, Rs) ***/
/* AGC adaption */ /* AGC adaption */
d_gain = (fabs(l_gain - *adapt_l_gain) + d_gain = (fabs(l_gain - *adapt_l_gain) +
fabs(r_gain - *adapt_r_gain)) * 0.5; fabs(r_gain - *adapt_r_gain)) * 0.5;
f = d_gain * (1.0 / MATAGCTRIG); f = d_gain * (1.0 / MATAGCTRIG);
f = MATAGCDECAY - MATAGCDECAY / (1 + f * f); f = MATAGCDECAY - MATAGCDECAY / (1 + f * f);
*adapt_l_gain = (1 - f) * *adapt_l_gain + f * l_gain; *adapt_l_gain = (1 - f) * *adapt_l_gain + f * l_gain;
@@ -179,12 +179,12 @@ static inline void matrix_decode(short *in, const int k, const int il,
if(decode_rear) { if(decode_rear) {
lr[kr] = rr[kr] = (l_agc - r_agc) * M_SQRT1_2; lr[kr] = rr[kr] = (l_agc - r_agc) * M_SQRT1_2;
/* Stereo rear channel is steered with the same AGC steering as /* Stereo rear channel is steered with the same AGC steering as
the decoding matrix. Note this requires a fast updating AGC the decoding matrix. Note this requires a fast updating AGC
at the order of 20 ms (which is the case here). */ at the order of 20 ms (which is the case here). */
lr[kr] *= (l_fwr + l_fwr) / lr[kr] *= (l_fwr + l_fwr) /
(1 + l_fwr + r_fwr); (1 + l_fwr + r_fwr);
rr[kr] *= (r_fwr + r_fwr) / rr[kr] *= (r_fwr + r_fwr) /
(1 + l_fwr + r_fwr); (1 + l_fwr + r_fwr);
} }
/*** AXIS NO. 2: (Lt + Rt, Lt - Rt) -> (L, R) ***/ /*** AXIS NO. 2: (Lt + Rt, Lt - Rt) -> (L, R) ***/
@@ -221,9 +221,9 @@ static inline void matrix_decode(short *in, const int k, const int il,
#if 0 #if 0
if(counter % 240 == 0) if(counter % 240 == 0)
fprintf(fp_out, "%g %g %g %g %g\n", fprintf(fp_out, "%g %g %g %g %g\n",
*adapt_l_gain, *adapt_r_gain, *adapt_l_gain, *adapt_r_gain,
*adapt_lpr_gain, *adapt_lmr_gain, *adapt_lpr_gain, *adapt_lmr_gain,
c_gain); c_gain);
counter++; counter++;
#endif #endif
} }
@@ -237,18 +237,18 @@ static inline void update_ch(af_hrtf_t *s, short *in, const int k)
s->l_fwr += abs(in[0]) - fabs(s->fwrbuf_l[fwr_pos]); s->l_fwr += abs(in[0]) - fabs(s->fwrbuf_l[fwr_pos]);
s->r_fwr += abs(in[1]) - fabs(s->fwrbuf_r[fwr_pos]); s->r_fwr += abs(in[1]) - fabs(s->fwrbuf_r[fwr_pos]);
s->lpr_fwr += abs(in[0] + in[1]) - s->lpr_fwr += abs(in[0] + in[1]) -
fabs(s->fwrbuf_l[fwr_pos] + s->fwrbuf_r[fwr_pos]); fabs(s->fwrbuf_l[fwr_pos] + s->fwrbuf_r[fwr_pos]);
s->lmr_fwr += abs(in[0] - in[1]) - s->lmr_fwr += abs(in[0] - in[1]) -
fabs(s->fwrbuf_l[fwr_pos] - s->fwrbuf_r[fwr_pos]); fabs(s->fwrbuf_l[fwr_pos] - s->fwrbuf_r[fwr_pos]);
} }
/* Rear matrix decoder */ /* Rear matrix decoder */
if(s->matrix_mode) { if(s->matrix_mode) {
s->lr_fwr += abs(in[2]) - fabs(s->fwrbuf_lr[fwr_pos]); s->lr_fwr += abs(in[2]) - fabs(s->fwrbuf_lr[fwr_pos]);
s->rr_fwr += abs(in[3]) - fabs(s->fwrbuf_rr[fwr_pos]); s->rr_fwr += abs(in[3]) - fabs(s->fwrbuf_rr[fwr_pos]);
s->lrprr_fwr += abs(in[2] + in[3]) - s->lrprr_fwr += abs(in[2] + in[3]) -
fabs(s->fwrbuf_lr[fwr_pos] + s->fwrbuf_rr[fwr_pos]); fabs(s->fwrbuf_lr[fwr_pos] + s->fwrbuf_rr[fwr_pos]);
s->lrmrr_fwr += abs(in[2] - in[3]) - s->lrmrr_fwr += abs(in[2] - in[3]) -
fabs(s->fwrbuf_lr[fwr_pos] - s->fwrbuf_rr[fwr_pos]); fabs(s->fwrbuf_lr[fwr_pos] - s->fwrbuf_rr[fwr_pos]);
} }
switch (s->decode_mode) { switch (s->decode_mode) {
@@ -265,11 +265,11 @@ static inline void update_ch(af_hrtf_t *s, short *in, const int k)
s->fwrbuf_l[k] = in[0]; s->fwrbuf_l[k] = in[0];
s->fwrbuf_r[k] = in[1]; s->fwrbuf_r[k] = in[1];
matrix_decode(in, k, 0, 1, 1, s->dlbuflen, matrix_decode(in, k, 0, 1, 1, s->dlbuflen,
s->l_fwr, s->r_fwr, s->l_fwr, s->r_fwr,
s->lpr_fwr, s->lmr_fwr, s->lpr_fwr, s->lmr_fwr,
&(s->adapt_l_gain), &(s->adapt_r_gain), &(s->adapt_l_gain), &(s->adapt_r_gain),
&(s->adapt_lpr_gain), &(s->adapt_lmr_gain), &(s->adapt_lpr_gain), &(s->adapt_lmr_gain),
s->lf, s->rf, s->lr, s->rr, s->cf); s->lf, s->rf, s->lr, s->rr, s->cf);
break; break;
case HRTF_MIX_STEREO: case HRTF_MIX_STEREO:
/* Stereo sources */ /* Stereo sources */
@@ -292,30 +292,30 @@ static int control(struct af_instance *af, int cmd, void* arg)
switch(cmd) { switch(cmd) {
case AF_CONTROL_REINIT: case AF_CONTROL_REINIT:
af->data->rate = ((struct mp_audio*)arg)->rate; af->data->rate = ((struct mp_audio*)arg)->rate;
if(af->data->rate != 48000) { if(af->data->rate != 48000) {
// automatic samplerate adjustment in the filter chain // automatic samplerate adjustment in the filter chain
// is not yet supported. // is not yet supported.
MP_ERR(af, "ERROR: Sampling rate is not 48000 Hz (%d)!\n", MP_ERR(af, "ERROR: Sampling rate is not 48000 Hz (%d)!\n",
af->data->rate); af->data->rate);
return AF_ERROR; return AF_ERROR;
} }
mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch); mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch);
if(af->data->nch == 2) { if(af->data->nch == 2) {
/* 2 channel input */ /* 2 channel input */
if(s->decode_mode != HRTF_MIX_MATRIX2CH) { if(s->decode_mode != HRTF_MIX_MATRIX2CH) {
/* Default behavior is stereo mixing. */ /* Default behavior is stereo mixing. */
s->decode_mode = HRTF_MIX_STEREO; s->decode_mode = HRTF_MIX_STEREO;
} }
} }
else if (af->data->nch < 5) else if (af->data->nch < 5)
mp_audio_set_channels_old(af->data, 5); mp_audio_set_channels_old(af->data, 5);
mp_audio_set_format(af->data, AF_FORMAT_S16); mp_audio_set_format(af->data, AF_FORMAT_S16);
test_output_res = af_test_output(af, (struct mp_audio*)arg); test_output_res = af_test_output(af, (struct mp_audio*)arg);
// after testing input set the real output format // after testing input set the real output format
mp_audio_set_num_channels(af->data, 2); mp_audio_set_num_channels(af->data, 2);
s->print_flag = 1; s->print_flag = 1;
return test_output_res; return test_output_res;
} }
return AF_UNKNOWN; return AF_UNKNOWN;
@@ -324,21 +324,21 @@ static int control(struct af_instance *af, int cmd, void* arg)
/* Deallocate memory */ /* Deallocate memory */
static void uninit(struct af_instance *af) static void uninit(struct af_instance *af)
{ {
af_hrtf_t *s = af->priv; af_hrtf_t *s = af->priv;
free(s->lf); free(s->lf);
free(s->rf); free(s->rf);
free(s->lr); free(s->lr);
free(s->rr); free(s->rr);
free(s->cf); free(s->cf);
free(s->cr); free(s->cr);
free(s->ba_l); free(s->ba_l);
free(s->ba_r); free(s->ba_r);
free(s->ba_ir); free(s->ba_ir);
free(s->fwrbuf_l); free(s->fwrbuf_l);
free(s->fwrbuf_r); free(s->fwrbuf_r);
free(s->fwrbuf_lr); free(s->fwrbuf_lr);
free(s->fwrbuf_rr); free(s->fwrbuf_rr);
} }
/* Filter data through filter /* Filter data through filter
@@ -364,29 +364,29 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
mp_audio_realloc_min(af->data, data->samples); mp_audio_realloc_min(af->data, data->samples);
if(s->print_flag) { if(s->print_flag) {
s->print_flag = 0; s->print_flag = 0;
switch (s->decode_mode) { switch (s->decode_mode) {
case HRTF_MIX_51: case HRTF_MIX_51:
MP_INFO(af, "Using HRTF to mix %s discrete surround into " MP_INFO(af, "Using HRTF to mix %s discrete surround into "
"L, R channels\n", s->matrix_mode ? "5+1" : "5"); "L, R channels\n", s->matrix_mode ? "5+1" : "5");
break; break;
case HRTF_MIX_STEREO: case HRTF_MIX_STEREO:
MP_INFO(af, "Using HRTF to mix stereo into " MP_INFO(af, "Using HRTF to mix stereo into "
"L, R channels\n"); "L, R channels\n");
break; break;
case HRTF_MIX_MATRIX2CH: case HRTF_MIX_MATRIX2CH:
MP_INFO(af, "Using active matrix to decode 2 channel " MP_INFO(af, "Using active matrix to decode 2 channel "
"input, HRTF to mix %s matrix surround into " "input, HRTF to mix %s matrix surround into "
"L, R channels\n", "3/2"); "L, R channels\n", "3/2");
break; break;
default: default:
MP_WARN(af, "bogus decode_mode: %d\n", s->decode_mode); MP_WARN(af, "bogus decode_mode: %d\n", s->decode_mode);
break; break;
} }
if(s->matrix_mode) if(s->matrix_mode)
MP_INFO(af, "Using active matrix to decode rear center " MP_INFO(af, "Using active matrix to decode rear center "
"channel\n"); "channel\n");
} }
out = af->data->planes[0]; out = af->data->planes[0];
@@ -410,122 +410,122 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
*/ */
while(in < end) { while(in < end) {
const int k = s->cyc_pos; const int k = s->cyc_pos;
update_ch(s, in, k); update_ch(s, in, k);
/* Simulate a 7.5 ms -20 dB echo of the center channel in the /* Simulate a 7.5 ms -20 dB echo of the center channel in the
front channels (like reflection from a room wall) - a kind of front channels (like reflection from a room wall) - a kind of
psycho-acoustically "cheating" to focus the center front psycho-acoustically "cheating" to focus the center front
channel, which is normally hard to be perceived as front */ channel, which is normally hard to be perceived as front */
s->lf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen]; s->lf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
s->rf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen]; s->rf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
switch (s->decode_mode) { switch (s->decode_mode) {
case HRTF_MIX_51: case HRTF_MIX_51:
case HRTF_MIX_MATRIX2CH: case HRTF_MIX_MATRIX2CH:
/* Mixer filter matrix */ /* Mixer filter matrix */
common = conv(dblen, hlen, s->cf, s->cf_ir, k + s->cf_o); common = conv(dblen, hlen, s->cf, s->cf_ir, k + s->cf_o);
if(s->matrix_mode) { if(s->matrix_mode) {
/* In matrix decoding mode, the rear channel gain must be /* In matrix decoding mode, the rear channel gain must be
renormalized, as there is an additional channel. */ renormalized, as there is an additional channel. */
matrix_decode(in, k, 2, 3, 0, s->dlbuflen, matrix_decode(in, k, 2, 3, 0, s->dlbuflen,
s->lr_fwr, s->rr_fwr, s->lr_fwr, s->rr_fwr,
s->lrprr_fwr, s->lrmrr_fwr, s->lrprr_fwr, s->lrmrr_fwr,
&(s->adapt_lr_gain), &(s->adapt_rr_gain), &(s->adapt_lr_gain), &(s->adapt_rr_gain),
&(s->adapt_lrprr_gain), &(s->adapt_lrmrr_gain), &(s->adapt_lrprr_gain), &(s->adapt_lrmrr_gain),
s->lr, s->rr, NULL, NULL, s->cr); s->lr, s->rr, NULL, NULL, s->cr);
common += common +=
conv(dblen, hlen, s->cr, s->cr_ir, k + s->cr_o) * conv(dblen, hlen, s->cr, s->cr_ir, k + s->cr_o) *
M1_76DB; M1_76DB;
left = left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) + ( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) + conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
(conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) + (conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o)) * conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o)) *
M1_76DB + common); M1_76DB + common);
right = right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) + ( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) + conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
(conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) + (conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o)) * conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o)) *
M1_76DB + common); M1_76DB + common);
} else { } else {
left = left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) + ( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) + conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) + conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o) + conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o) +
common); common);
right = right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) + ( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) + conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) + conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o) + conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o) +
common); common);
} }
break; break;
case HRTF_MIX_STEREO: case HRTF_MIX_STEREO:
left = left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) + ( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o)); conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o));
right = right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) + ( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o)); conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o));
break; break;
default: default:
/* make gcc happy */ /* make gcc happy */
left = 0.0; left = 0.0;
right = 0.0; right = 0.0;
break; break;
} }
/* Bass compensation for the lower frequency cut of the HRTF. A /* Bass compensation for the lower frequency cut of the HRTF. A
cross talk of the left and right channel is introduced to cross talk of the left and right channel is introduced to
match the directional characteristics of higher frequencies. match the directional characteristics of higher frequencies.
The bass will not have any real 3D perception, but that is The bass will not have any real 3D perception, but that is
OK (note at 180 Hz, the wavelength is about 2 m, and any OK (note at 180 Hz, the wavelength is about 2 m, and any
spatial perception is impossible). */ spatial perception is impossible). */
left_b = conv(dblen, blen, s->ba_l, s->ba_ir, k); left_b = conv(dblen, blen, s->ba_l, s->ba_ir, k);
right_b = conv(dblen, blen, s->ba_r, s->ba_ir, k); right_b = conv(dblen, blen, s->ba_r, s->ba_ir, k);
left += (1 - BASSCROSS) * left_b + BASSCROSS * right_b; left += (1 - BASSCROSS) * left_b + BASSCROSS * right_b;
right += (1 - BASSCROSS) * right_b + BASSCROSS * left_b; right += (1 - BASSCROSS) * right_b + BASSCROSS * left_b;
/* Also mix the LFE channel (if available) */ /* Also mix the LFE channel (if available) */
if(data->nch >= 6) { if(data->nch >= 6) {
left += in[5] * M3_01DB; left += in[5] * M3_01DB;
right += in[5] * M3_01DB; right += in[5] * M3_01DB;
} }
/* Amplitude renormalization. */ /* Amplitude renormalization. */
left *= AMPLNORM; left *= AMPLNORM;
right *= AMPLNORM; right *= AMPLNORM;
switch (s->decode_mode) { switch (s->decode_mode) {
case HRTF_MIX_51: case HRTF_MIX_51:
case HRTF_MIX_STEREO: case HRTF_MIX_STEREO:
/* "Cheating": linear stereo expansion to amplify the 3D /* "Cheating": linear stereo expansion to amplify the 3D
perception. Note: Too much will destroy the acoustic space perception. Note: Too much will destroy the acoustic space
and may even result in headaches. */ and may even result in headaches. */
diff = STEXPAND2 * (left - right); diff = STEXPAND2 * (left - right);
out[0] = av_clip_int16(left + diff); out[0] = av_clip_int16(left + diff);
out[1] = av_clip_int16(right - diff); out[1] = av_clip_int16(right - diff);
break; break;
case HRTF_MIX_MATRIX2CH: case HRTF_MIX_MATRIX2CH:
/* Do attempt any stereo expansion with matrix encoded /* Do attempt any stereo expansion with matrix encoded
sources. The L, R channels are already stereo expanded sources. The L, R channels are already stereo expanded
by the steering, any further stereo expansion will sound by the steering, any further stereo expansion will sound
very unnatural. */ very unnatural. */
out[0] = av_clip_int16(left); out[0] = av_clip_int16(left);
out[1] = av_clip_int16(right); out[1] = av_clip_int16(right);
break; break;
} }
/* Next sample... */ /* Next sample... */
in = &in[data->nch]; in = &in[data->nch];
out = &out[af->data->nch]; out = &out[af->data->nch];
(s->cyc_pos)--; (s->cyc_pos)--;
if(s->cyc_pos < 0) if(s->cyc_pos < 0)
s->cyc_pos += dblen; s->cyc_pos += dblen;
} }
/* Set output data */ /* Set output data */
@@ -546,13 +546,13 @@ static int allocate(af_hrtf_t *s)
if ((s->ba_l = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1; if ((s->ba_l = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->ba_r = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1; if ((s->ba_r = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->fwrbuf_l = if ((s->fwrbuf_l =
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1; malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->fwrbuf_r = if ((s->fwrbuf_r =
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1; malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->fwrbuf_lr = if ((s->fwrbuf_lr =
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1; malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->fwrbuf_rr = if ((s->fwrbuf_rr =
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1; malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
return 0; return 0;
} }
@@ -595,16 +595,16 @@ static int af_open(struct af_instance* af)
s->print_flag = 1; s->print_flag = 1;
if (allocate(s) != 0) { if (allocate(s) != 0) {
MP_ERR(af, "Memory allocation error.\n"); MP_ERR(af, "Memory allocation error.\n");
return AF_ERROR; return AF_ERROR;
} }
for(i = 0; i < s->dlbuflen; i++) for(i = 0; i < s->dlbuflen; i++)
s->lf[i] = s->rf[i] = s->lr[i] = s->rr[i] = s->cf[i] = s->lf[i] = s->rf[i] = s->lr[i] = s->rr[i] = s->cf[i] =
s->cr[i] = 0; s->cr[i] = 0;
s->lr_fwr = s->lr_fwr =
s->rr_fwr = 0; s->rr_fwr = 0;
s->cf_ir = cf_filt + (s->cf_o = pulse_detect(cf_filt)); s->cf_ir = cf_filt + (s->cf_o = pulse_detect(cf_filt));
s->af_ir = af_filt + (s->af_o = pulse_detect(af_filt)); s->af_ir = af_filt + (s->af_o = pulse_detect(af_filt));
@@ -614,18 +614,18 @@ static int af_open(struct af_instance* af)
s->cr_ir = cr_filt + (s->cr_o = pulse_detect(cr_filt)); s->cr_ir = cr_filt + (s->cr_o = pulse_detect(cr_filt));
if((s->ba_ir = malloc(s->basslen * sizeof(float))) == NULL) { if((s->ba_ir = malloc(s->basslen * sizeof(float))) == NULL) {
MP_ERR(af, "Memory allocation error.\n"); MP_ERR(af, "Memory allocation error.\n");
return AF_ERROR; return AF_ERROR;
} }
fc = 2.0 * BASSFILTFREQ / (float)af->data->rate; fc = 2.0 * BASSFILTFREQ / (float)af->data->rate;
if(af_filter_design_fir(s->basslen, s->ba_ir, &fc, LP | KAISER, 4 * M_PI) == if(af_filter_design_fir(s->basslen, s->ba_ir, &fc, LP | KAISER, 4 * M_PI) ==
-1) { -1) {
MP_ERR(af, "Unable to design low-pass " MP_ERR(af, "Unable to design low-pass "
"filter.\n"); "filter.\n");
return AF_ERROR; return AF_ERROR;
} }
for(i = 0; i < s->basslen; i++) for(i = 0; i < s->basslen; i++)
s->ba_ir[i] *= BASSGAIN; s->ba_ir[i] *= BASSGAIN;
return AF_OK; return AF_OK;
} }

View File

@@ -24,38 +24,38 @@
#define HRTF_MIX_MATRIX2CH 2 #define HRTF_MIX_MATRIX2CH 2
/* Amplitude scaling factors */ /* Amplitude scaling factors */
#define M17_0DB 0.1414213562 #define M17_0DB 0.1414213562
#define M9_03DB 0.3535533906 #define M9_03DB 0.3535533906
#define M6_99DB 0.4472135955 #define M6_99DB 0.4472135955
#define M4_77DB 0.5773502692 #define M4_77DB 0.5773502692
#define M3_01DB 0.7071067812 #define M3_01DB 0.7071067812
#define M1_76DB 0.8164965809 #define M1_76DB 0.8164965809
#define DELAYBUFLEN 1024 /* Length of the delay buffer */ #define DELAYBUFLEN 1024 /* Length of the delay buffer */
#define HRTFFILTLEN 64 /* HRTF filter length */ #define HRTFFILTLEN 64 /* HRTF filter length */
#define IRTHRESH 0.001 /* Impulse response pruning thresh. */ #define IRTHRESH 0.001 /* Impulse response pruning thresh. */
#define AMPLNORM M6_99DB /* Overall amplitude renormalization */ #define AMPLNORM M6_99DB /* Overall amplitude renormalization */
#define BASSFILTFREQ 180 /* Bass compensation filter cut (Hz) */ #define BASSFILTFREQ 180 /* Bass compensation filter cut (Hz) */
#define BASSFILTLEN 193 /* Bass compensation filter length */ #define BASSFILTLEN 193 /* Bass compensation filter length */
#define BASSGAIN M_SQRT2 /* Bass compensation gain */ #define BASSGAIN M_SQRT2 /* Bass compensation gain */
#define BASSCROSS 0.35 /* Bass cross talk */ #define BASSCROSS 0.35 /* Bass cross talk */
#define FWRDURATION 240 /* FWR average duration (samples) */ #define FWRDURATION 240 /* FWR average duration (samples) */
#define MATREARDELAY 720 /* Matrix mode rear delay (samples) */ #define MATREARDELAY 720 /* Matrix mode rear delay (samples) */
#define MATAGCTRIG 8.0 /* (Fuzzy) AGC trigger */ #define MATAGCTRIG 8.0 /* (Fuzzy) AGC trigger */
#define MATAGCDECAY 1.0 /* AGC baseline decay rate (1/samp.) */ #define MATAGCDECAY 1.0 /* AGC baseline decay rate (1/samp.) */
#define MATAGCLOCK 0.2 /* AGC range (around 1) where the #define MATAGCLOCK 0.2 /* AGC range (around 1) where the
matrix behaves passively */ matrix behaves passively */
#define MATCOMPGAIN 0.37 /* Cross talk compensation gain, #define MATCOMPGAIN 0.37 /* Cross talk compensation gain,
0.50 - 0.55 is full cancellation. */ 0.50 - 0.55 is full cancellation. */
#define CFECHODELAY 360 /* Center front echo delay (samples) */ #define CFECHODELAY 360 /* Center front echo delay (samples) */
#define CFECHOAMPL M17_0DB /* Center front echo amplitude */ #define CFECHOAMPL M17_0DB /* Center front echo amplitude */
#define STEXPAND2 0.07 /* Stereo expansion / 2 */ #define STEXPAND2 0.07 /* Stereo expansion / 2 */
/* Head related impulse response (HRIR) derived from KEMAR measurement /* Head related impulse response (HRIR) derived from KEMAR measurement
data by Bill Gardner <billg@media.mit.edu> and Keith Martin data by Bill Gardner <billg@media.mit.edu> and Keith Martin

View File

@@ -32,50 +32,50 @@
// Initialization and runtime control // Initialization and runtime control
static int control(struct af_instance* af, int cmd, void* arg) static int control(struct af_instance* af, int cmd, void* arg)
{ {
switch(cmd){ switch(cmd){
case AF_CONTROL_REINIT: case AF_CONTROL_REINIT:
mp_audio_copy_config(af->data, (struct mp_audio*)arg); mp_audio_copy_config(af->data, (struct mp_audio*)arg);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT); mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
return af_test_output(af,(struct mp_audio*)arg); return af_test_output(af,(struct mp_audio*)arg);
} }
return AF_UNKNOWN; return AF_UNKNOWN;
} }
// Filter data through filter // Filter data through filter
static int play(struct af_instance* af, struct mp_audio* data, int flags) static int play(struct af_instance* af, struct mp_audio* data, int flags)
{ {
struct mp_audio* c = data; // Current working data struct mp_audio* c = data; // Current working data
float* a = c->planes[0]; // Audio data float* a = c->planes[0]; // Audio data
int nch = c->nch; // Number of channels int nch = c->nch; // Number of channels
int len = c->samples*nch; // Number of samples in current audio block int len = c->samples*nch; // Number of samples in current audio block
register int i; register int i;
/* /*
FIXME1 add a low band pass filter to avoid suppressing FIXME1 add a low band pass filter to avoid suppressing
centered bass/drums centered bass/drums
FIXME2 better calculated* attenuation factor FIXME2 better calculated* attenuation factor
*/ */
for(i=0;i<len;i+=nch) for(i=0;i<len;i+=nch)
{ {
a[i] = (a[i] - a[i+1]) * 0.7; a[i] = (a[i] - a[i+1]) * 0.7;
a[i+1]=a[i]; a[i+1]=a[i];
} }
return 0; return 0;
} }
// Allocate memory and set function pointers // Allocate memory and set function pointers
static int af_open(struct af_instance* af){ static int af_open(struct af_instance* af){
af->control = control; af->control = control;
af->filter = play; af->filter = play;
return AF_OK; return AF_OK;
} }
// Description of this filter // Description of this filter
struct af_info af_info_karaoke = { struct af_info af_info_karaoke = {
.info = "Simple karaoke/voice-removal audio filter", .info = "Simple karaoke/voice-removal audio filter",
.name = "karaoke", .name = "karaoke",
.flags = AF_FLAGS_NOT_REENTRANT, .flags = AF_FLAGS_NOT_REENTRANT,
.open = af_open, .open = af_open,
}; };

View File

@@ -32,7 +32,7 @@
typedef struct af_pan_s typedef struct af_pan_s
{ {
int nch; // Number of output channels; zero means same as input int nch; // Number of output channels; zero means same as input
float level[AF_NCH][AF_NCH]; // Gain level for each channel float level[AF_NCH][AF_NCH]; // Gain level for each channel
char *matrixstr; char *matrixstr;
}af_pan_t; }af_pan_t;
@@ -110,14 +110,14 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter // Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags) static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{ {
struct mp_audio* c = data; // Current working data struct mp_audio* c = data; // Current working data
struct mp_audio* l = af->data; // Local data struct mp_audio* l = af->data; // Local data
af_pan_t* s = af->priv; // Setup for this instance af_pan_t* s = af->priv; // Setup for this instance
float* in = c->planes[0]; // Input audio data float* in = c->planes[0]; // Input audio data
float* out = NULL; // Output audio data float* out = NULL; // Output audio data
float* end = in+c->samples*c->nch; // End of loop float* end = in+c->samples*c->nch; // End of loop
int nchi = c->nch; // Number of input channels int nchi = c->nch; // Number of input channels
int ncho = l->nch; // Number of output channels int ncho = l->nch; // Number of output channels
register int j,k; register int j,k;
mp_audio_realloc_min(af->data, data->samples); mp_audio_realloc_min(af->data, data->samples);
@@ -130,7 +130,7 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
register float x = 0.0; register float x = 0.0;
register float* tin = in; register float* tin = in;
for(k=0;k<nchi;k++) for(k=0;k<nchi;k++)
x += tin[k] * s->level[j][k]; x += tin[k] * s->level[j][k];
out[j] = x; out[j] = x;
} }
out+= ncho; out+= ncho;

View File

@@ -57,14 +57,14 @@ static int control(struct af_instance* af, int cmd, void* arg)
#if 0 #if 0
if (((struct mp_audio*)arg)->format == AF_FORMAT_FLOAT) if (((struct mp_audio*)arg)->format == AF_FORMAT_FLOAT)
{ {
af->data->format = AF_FORMAT_FLOAT; af->data->format = AF_FORMAT_FLOAT;
af->data->bps = 4; af->data->bps = 4;
af->play = play_float; af->play = play_float;
}// else }// else
#endif #endif
{ {
mp_audio_set_format(af->data, AF_FORMAT_S16); mp_audio_set_format(af->data, AF_FORMAT_S16);
af->filter = play_s16; af->filter = play_s16;
} }
return af_test_output(af,(struct mp_audio*)arg); return af_test_output(af,(struct mp_audio*)arg);
@@ -78,8 +78,8 @@ static int play_s16(struct af_instance* af, struct mp_audio* data, int f)
{ {
af_sinesuppress_t *s = af->priv; af_sinesuppress_t *s = af->priv;
register int i = 0; register int i = 0;
int16_t *a = (int16_t*)data->planes[0]; // Audio data int16_t *a = (int16_t*)data->planes[0]; // Audio data
int len = data->samples*data->nch; // Number of samples int len = data->samples*data->nch; // Number of samples
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
@@ -109,8 +109,8 @@ static struct mp_audio* play_float(struct af_instance* af, struct mp_audio* data
{ {
af_sinesuppress_t *s = af->setup; af_sinesuppress_t *s = af->setup;
register int i = 0; register int i = 0;
float *a = (float*)data->audio; // Audio data float *a = (float*)data->audio; // Audio data
int len = data->len/4; // Number of samples int len = data->len/4; // Number of samples
float avg, l, r; float avg, l, r;
for (i = 0; i < len; i+=2) for (i = 0; i < len; i+=2)

View File

@@ -41,22 +41,22 @@
// Analog domain biquad section // Analog domain biquad section
typedef struct{ typedef struct{
float a[3]; // Numerator coefficients float a[3]; // Numerator coefficients
float b[3]; // Denominator coefficients float b[3]; // Denominator coefficients
} biquad_t; } biquad_t;
// S-parameters for designing 4th order Butterworth filter // S-parameters for designing 4th order Butterworth filter
static biquad_t sp[2] = {{{1.0,0.0,0.0},{1.0,0.765367,1.0}}, static biquad_t sp[2] = {{{1.0,0.0,0.0},{1.0,0.765367,1.0}},
{{1.0,0.0,0.0},{1.0,1.847759,1.0}}}; {{1.0,0.0,0.0},{1.0,1.847759,1.0}}};
// Data for specific instances of this filter // Data for specific instances of this filter
typedef struct af_sub_s typedef struct af_sub_s
{ {
float w[2][4]; // Filter taps for low-pass filter float w[2][4]; // Filter taps for low-pass filter
float q[2][2]; // Circular queues float q[2][2]; // Circular queues
float fc; // Cutoff frequency [Hz] for low-pass filter float fc; // Cutoff frequency [Hz] for low-pass filter
float k; // Filter gain; float k; // Filter gain;
int ch; // Channel number which to insert the filtered data int ch; // Channel number which to insert the filtered data
}af_sub_t; }af_sub_t;
@@ -92,7 +92,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
float h0 = (q)[0]; \ float h0 = (q)[0]; \
float h1 = (q)[1]; \ float h1 = (q)[1]; \
float hn = (in) - h0 * (w)[0] - h1 * (w)[1]; \ float hn = (in) - h0 * (w)[0] - h1 * (w)[1]; \
out = hn + h0 * (w)[2] + h1 * (w)[3]; \ out = hn + h0 * (w)[2] + h1 * (w)[3]; \
(q)[1] = h0; \ (q)[1] = h0; \
(q)[0] = hn; \ (q)[0] = hn; \
} }
@@ -101,12 +101,12 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter // Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags) static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{ {
struct mp_audio* c = data; // Current working data struct mp_audio* c = data; // Current working data
af_sub_t* s = af->priv; // Setup for this instance af_sub_t* s = af->priv; // Setup for this instance
float* a = c->planes[0]; // Audio data float* a = c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples in current audio block int len = c->samples*c->nch; // Number of samples in current audio block
int nch = c->nch; // Number of channels int nch = c->nch; // Number of channels
int ch = s->ch; // Channel in which to insert the sub audio int ch = s->ch; // Channel in which to insert the sub audio
register int i; register int i;
// Run filter // Run filter

View File

@@ -76,13 +76,13 @@ typedef struct af_surround_s
{ {
float lq[2*L]; // Circular queue for filtering left rear channel float lq[2*L]; // Circular queue for filtering left rear channel
float rq[2*L]; // Circular queue for filtering right rear channel float rq[2*L]; // Circular queue for filtering right rear channel
float w[L]; // FIR filter coefficients for surround sound 7kHz low-pass float w[L]; // FIR filter coefficients for surround sound 7kHz low-pass
float* dr; // Delay queue right rear channel float* dr; // Delay queue right rear channel
float* dl; // Delay queue left rear channel float* dl; // Delay queue left rear channel
float d; // Delay time float d; // Delay time
int i; // Position in circular buffer int i; // Position in circular buffer
int wi; // Write index for delay queue int wi; // Write index for delay queue
int ri; // Read index for delay queue int ri; // Read index for delay queue
}af_surround_t; }af_surround_t;
// Initialization and runtime control // Initialization and runtime control
@@ -132,10 +132,10 @@ static int control(struct af_instance* af, int cmd, void* arg)
// The beginnings of an active matrix... // The beginnings of an active matrix...
static float steering_matrix[][12] = { static float steering_matrix[][12] = {
// LL RL LR RR LS RS // LL RL LR RR LS RS
// LLs RLs LRs RRs LC RC // LLs RLs LRs RRs LC RC
{.707, .0, .0, .707, .5, -.5, {.707, .0, .0, .707, .5, -.5,
.5878, -.3928, .3928, -.5878, .5, .5}, .5878, -.3928, .3928, -.5878, .5, .5},
}; };
// Experimental moving average dominance // Experimental moving average dominance
@@ -144,13 +144,13 @@ static float steering_matrix[][12] = {
// Filter data through filter // Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags){ static int filter(struct af_instance* af, struct mp_audio* data, int flags){
af_surround_t* s = (af_surround_t*)af->priv; af_surround_t* s = (af_surround_t*)af->priv;
float* m = steering_matrix[0]; float* m = steering_matrix[0];
float* in = data->planes[0]; // Input audio data float* in = data->planes[0]; // Input audio data
float* out = NULL; // Output audio data float* out = NULL; // Output audio data
float* end = in + data->samples * data->nch; float* end = in + data->samples * data->nch;
int i = s->i; // Filter queue index int i = s->i; // Filter queue index
int ri = s->ri; // Read index for delay queue int ri = s->ri; // Read index for delay queue
int wi = s->wi; // Write index for delay queue int wi = s->wi; // Write index for delay queue
mp_audio_realloc_min(af->data, data->samples); mp_audio_realloc_min(af->data, data->samples);

View File

@@ -18,8 +18,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPLAYER_DSP_H #ifndef MPLAYER_DSP_H
#define MPLAYER_DSP_H #define MPLAYER_DSP_H
/* Implementation of routines used for DSP */ /* Implementation of routines used for DSP */

View File

@@ -26,22 +26,22 @@
typedef struct equalizer_s typedef struct equalizer_s
{ {
float gain; // Gain in dB -15 - 15 float gain; // Gain in dB -15 - 15
int channel; // Channel number 0 - 5 int channel; // Channel number 0 - 5
int band; // Frequency band 0 - 9 int band; // Frequency band 0 - 9
}equalizer_t; }equalizer_t;
/* The different frequency bands are: /* The different frequency bands are:
nr. center frequency nr. center frequency
0 31.25 Hz 0 31.25 Hz
1 62.50 Hz 1 62.50 Hz
2 125.0 Hz 2 125.0 Hz
3 250.0 Hz 3 250.0 Hz
4 500.0 Hz 4 500.0 Hz
5 1.000 kHz 5 1.000 kHz
6 2.000 kHz 6 2.000 kHz
7 4.000 kHz 7 4.000 kHz
8 8.000 kHz 8 8.000 kHz
9 16.00 kHz 9 16.00 kHz
*/ */

View File

@@ -58,7 +58,7 @@ inline FLOAT_TYPE af_filter_fir(register unsigned int n, const FLOAT_TYPE* w,
0 < fc < 1 where 1 <=> Fs/2 0 < fc < 1 where 1 <=> Fs/2
flags window and filter type as defined in filter.h flags window and filter type as defined in filter.h
variables are ored together: i.e. LP|HAMMING will give a variables are ored together: i.e. LP|HAMMING will give a
low pass filter designed using a hamming window low pass filter designed using a hamming window
opt beta constant used only when designing using kaiser windows opt beta constant used only when designing using kaiser windows
returns 0 if OK, -1 if fail returns 0 if OK, -1 if fail
@@ -66,16 +66,16 @@ inline FLOAT_TYPE af_filter_fir(register unsigned int n, const FLOAT_TYPE* w,
int af_filter_design_fir(unsigned int n, FLOAT_TYPE* w, const FLOAT_TYPE* fc, int af_filter_design_fir(unsigned int n, FLOAT_TYPE* w, const FLOAT_TYPE* fc,
unsigned int flags, FLOAT_TYPE opt) unsigned int flags, FLOAT_TYPE opt)
{ {
unsigned int o = n & 1; // Indicator for odd filter length unsigned int o = n & 1; // Indicator for odd filter length
unsigned int end = ((n + 1) >> 1) - o; // Loop end unsigned int end = ((n + 1) >> 1) - o; // Loop end
unsigned int i; // Loop index unsigned int i; // Loop index
FLOAT_TYPE k1 = 2 * M_PI; // 2*pi*fc1 FLOAT_TYPE k1 = 2 * M_PI; // 2*pi*fc1
FLOAT_TYPE k2 = 0.5 * (FLOAT_TYPE)(1 - o);// Constant used if the filter has even length FLOAT_TYPE k2 = 0.5 * (FLOAT_TYPE)(1 - o);// Constant used if the filter has even length
FLOAT_TYPE k3; // 2*pi*fc2 Constant used in BP and BS design FLOAT_TYPE k3; // 2*pi*fc2 Constant used in BP and BS design
FLOAT_TYPE g = 0.0; // Gain FLOAT_TYPE g = 0.0; // Gain
FLOAT_TYPE t1,t2,t3; // Temporary variables FLOAT_TYPE t1,t2,t3; // Temporary variables
FLOAT_TYPE fc1,fc2; // Cutoff frequencies FLOAT_TYPE fc1,fc2; // Cutoff frequencies
// Sanity check // Sanity check
if(!w || (n == 0)) return -1; if(!w || (n == 0)) return -1;
@@ -113,28 +113,28 @@ int af_filter_design_fir(unsigned int n, FLOAT_TYPE* w, const FLOAT_TYPE* fc,
// where x is zero. To make sure nothing strange happens, we set this // where x is zero. To make sure nothing strange happens, we set this
// value separately. // value separately.
if (o){ if (o){
w[end] = fc1 * w[end] * 2.0; w[end] = fc1 * w[end] * 2.0;
g=w[end]; g=w[end];
} }
// Create filter // Create filter
for (i=0 ; i<end ; i++){ for (i=0 ; i<end ; i++){
t1 = (FLOAT_TYPE)(i+1) - k2; t1 = (FLOAT_TYPE)(i+1) - k2;
w[end-i-1] = w[n-end+i] = w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc w[end-i-1] = w[n-end+i] = w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc
g += 2*w[end-i-1]; // Total gain in filter g += 2*w[end-i-1]; // Total gain in filter
} }
} }
else{ // High pass filter else{ // High pass filter
if (!o) // High pass filters must have odd length if (!o) // High pass filters must have odd length
return -1; return -1;
w[end] = 1.0 - (fc1 * w[end] * 2.0); w[end] = 1.0 - (fc1 * w[end] * 2.0);
g= w[end]; g= w[end];
// Create filter // Create filter
for (i=0 ; i<end ; i++){ for (i=0 ; i<end ; i++){
t1 = (FLOAT_TYPE)(i+1); t1 = (FLOAT_TYPE)(i+1);
w[end-i-1] = w[n-end+i] = -1 * w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc w[end-i-1] = w[n-end+i] = -1 * w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc
g += ((i&1) ? (2*w[end-i-1]) : (-2*w[end-i-1])); // Total gain in filter g += ((i&1) ? (2*w[end-i-1]) : (-2*w[end-i-1])); // Total gain in filter
} }
} }
} }
@@ -151,32 +151,32 @@ int af_filter_design_fir(unsigned int n, FLOAT_TYPE* w, const FLOAT_TYPE* fc,
if(flags & BP){ // Band pass if(flags & BP){ // Band pass
// Calculate center tap // Calculate center tap
if (o){ if (o){
g=w[end]*(fc1+fc2); g=w[end]*(fc1+fc2);
w[end] = (fc2 - fc1) * w[end] * 2.0; w[end] = (fc2 - fc1) * w[end] * 2.0;
} }
// Create filter // Create filter
for (i=0 ; i<end ; i++){ for (i=0 ; i<end ; i++){
t1 = (FLOAT_TYPE)(i+1) - k2; t1 = (FLOAT_TYPE)(i+1) - k2;
t2 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2 t2 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2
t3 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1 t3 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1
g += w[end-i-1] * (t3 + t2); // Total gain in filter g += w[end-i-1] * (t3 + t2); // Total gain in filter
w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3); w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3);
} }
} }
else{ // Band stop else{ // Band stop
if (!o) // Band stop filters must have odd length if (!o) // Band stop filters must have odd length
return -1; return -1;
w[end] = 1.0 - (fc2 - fc1) * w[end] * 2.0; w[end] = 1.0 - (fc2 - fc1) * w[end] * 2.0;
g= w[end]; g= w[end];
// Create filter // Create filter
for (i=0 ; i<end ; i++){ for (i=0 ; i<end ; i++){
t1 = (FLOAT_TYPE)(i+1); t1 = (FLOAT_TYPE)(i+1);
t2 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1 t2 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1
t3 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2 t3 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2
w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3); w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3);
g += 2*w[end-i-1]; // Total gain in filter g += 2*w[end-i-1]; // Total gain in filter
} }
} }
} }
@@ -224,12 +224,12 @@ static void af_filter_prewarp(FLOAT_TYPE* a, FLOAT_TYPE fc, FLOAT_TYPE fs)
Arguments: Arguments:
a - s-domain numerator coefficients a - s-domain numerator coefficients
b - s-domain denominator coefficients b - s-domain denominator coefficients
k - filter gain factor. Initially set to 1 and modified by each k - filter gain factor. Initially set to 1 and modified by each
biquad section in such a way, as to make it the biquad section in such a way, as to make it the
coefficient by which to multiply the overall filter gain coefficient by which to multiply the overall filter gain
in order to achieve a desired overall filter gain, in order to achieve a desired overall filter gain,
specified in initial value of k. specified in initial value of k.
fs - sampling rate (Hz) fs - sampling rate (Hz)
coef - array of z-domain coefficients to be filled in. coef - array of z-domain coefficients to be filled in.
Return: On return, set coef z-domain coefficients and k to the gain Return: On return, set coef z-domain coefficients and k to the gain
@@ -319,13 +319,13 @@ static void af_filter_bilinear(const FLOAT_TYPE* a, const FLOAT_TYPE* b, FLOAT_T
Arguments: Arguments:
a - s-domain numerator coefficients, a[1] is always assumed to be 1.0 a - s-domain numerator coefficients, a[1] is always assumed to be 1.0
b - s-domain denominator coefficients b - s-domain denominator coefficients
Q - Q value for the filter Q - Q value for the filter
k - filter gain factor. Initially set to 1 and modified by each k - filter gain factor. Initially set to 1 and modified by each
biquad section in such a way, as to make it the biquad section in such a way, as to make it the
coefficient by which to multiply the overall filter gain coefficient by which to multiply the overall filter gain
in order to achieve a desired overall filter gain, in order to achieve a desired overall filter gain,
specified in initial value of k. specified in initial value of k.
fs - sampling rate (Hz) fs - sampling rate (Hz)
coef - array of z-domain coefficients to be filled in. coef - array of z-domain coefficients to be filled in.
Note: Upon return from each call, the k argument will be set to a Note: Upon return from each call, the k argument will be set to a

View File

@@ -49,7 +49,7 @@
#define WINDOW_MASK 0x0000001F #define WINDOW_MASK 0x0000001F
// Parallel filter design // Parallel filter design
#define FWD 0x00000001 // Forward indexing of polyphase filter #define FWD 0x00000001 // Forward indexing of polyphase filter
#define REW 0x00000002 // Reverse indexing of polyphase filter #define REW 0x00000002 // Reverse indexing of polyphase filter
#define ODD 0x00000010 // Make filter HP #define ODD 0x00000010 // Make filter HP

View File

@@ -115,9 +115,9 @@ int af_test_output(struct af_instance* af, struct mp_audio* out)
float af_softclip(float a) float af_softclip(float a)
{ {
if (a >= M_PI/2) if (a >= M_PI/2)
return 1.0; return 1.0;
else if (a <= -M_PI/2) else if (a <= -M_PI/2)
return -1.0; return -1.0;
else else
return sin(a); return sin(a);
} }

View File

@@ -59,7 +59,7 @@ void af_window_triang(int n, FLOAT_TYPE* w)
FLOAT_TYPE k1 = (FLOAT_TYPE)(n & 1); FLOAT_TYPE k1 = (FLOAT_TYPE)(n & 1);
FLOAT_TYPE k2 = 1/((FLOAT_TYPE)n + k1); FLOAT_TYPE k2 = 1/((FLOAT_TYPE)n + k1);
int end = (n + 1) >> 1; int end = (n + 1) >> 1;
int i; int i;
// Calculate window coefficients // Calculate window coefficients
for (i=0 ; i<end ; i++) for (i=0 ; i<end ; i++)
@@ -77,7 +77,7 @@ void af_window_triang(int n, FLOAT_TYPE* w)
*/ */
void af_window_hanning(int n, FLOAT_TYPE* w) void af_window_hanning(int n, FLOAT_TYPE* w)
{ {
int i; int i;
FLOAT_TYPE k = 2*M_PI/((FLOAT_TYPE)(n+1)); // 2*pi/(N+1) FLOAT_TYPE k = 2*M_PI/((FLOAT_TYPE)(n+1)); // 2*pi/(N+1)
// Calculate window coefficients // Calculate window coefficients
@@ -201,7 +201,7 @@ void af_window_kaiser(int n, FLOAT_TYPE* w, FLOAT_TYPE b)
{ {
FLOAT_TYPE tmp; FLOAT_TYPE tmp;
FLOAT_TYPE k1 = 1.0/besselizero(b); FLOAT_TYPE k1 = 1.0/besselizero(b);
int k2 = 1 - (n & 1); int k2 = 1 - (n & 1);
int end = (n + 1) >> 1; int end = (n + 1) >> 1;
int i; int i;

View File

File diff suppressed because it is too large Load Diff

View File

@@ -79,22 +79,22 @@ int mp_input_joystick_init(struct input_ctx *ictx, struct mp_log *log, char *dev
while((unsigned int)l < sizeof(struct js_event)) { while((unsigned int)l < sizeof(struct js_event)) {
int r = read(fd,((char*)&ev)+l,sizeof(struct js_event)-l); int r = read(fd,((char*)&ev)+l,sizeof(struct js_event)-l);
if(r < 0) { if(r < 0) {
if(errno == EINTR) if(errno == EINTR)
continue; continue;
else if(errno == EAGAIN) { else if(errno == EAGAIN) {
initialized = 1; initialized = 1;
break; break;
} }
MP_ERR(ctx, "Error while reading joystick device: %s\n",strerror(errno)); MP_ERR(ctx, "Error while reading joystick device: %s\n",strerror(errno));
close(fd); close(fd);
talloc_free(ctx); talloc_free(ctx);
return -1; return -1;
} }
l += r; l += r;
} }
if((unsigned int)l < sizeof(struct js_event)) { if((unsigned int)l < sizeof(struct js_event)) {
if(l > 0) if(l > 0)
MP_WARN(ctx, "Joystick: We lose %d bytes of data\n",l); MP_WARN(ctx, "Joystick: We lose %d bytes of data\n",l);
break; break;
} }
if(ev.type == JS_EVENT_BUTTON) if(ev.type == JS_EVENT_BUTTON)
@@ -116,13 +116,13 @@ static int mp_input_joystick_read(void *pctx, int fd) {
int r = read(fd,((char*)&ev)+l,sizeof(struct js_event)-l); int r = read(fd,((char*)&ev)+l,sizeof(struct js_event)-l);
if(r <= 0) { if(r <= 0) {
if(errno == EINTR) if(errno == EINTR)
continue; continue;
else if(errno == EAGAIN) else if(errno == EAGAIN)
return MP_INPUT_NOTHING; return MP_INPUT_NOTHING;
if( r < 0) if( r < 0)
MP_ERR(ctx, "Error while reading joystick device: %s\n",strerror(errno)); MP_ERR(ctx, "Error while reading joystick device: %s\n",strerror(errno));
else else
MP_ERR(ctx, "Error while reading joystick device: %s\n","EOF"); MP_ERR(ctx, "Error while reading joystick device: %s\n","EOF");
return MP_INPUT_DEAD; return MP_INPUT_DEAD;
} }
l += r; l += r;
@@ -140,14 +140,14 @@ static int mp_input_joystick_read(void *pctx, int fd) {
if(ev.type == JS_EVENT_BUTTON) { if(ev.type == JS_EVENT_BUTTON) {
int s = (ctx->btns >> ev.number) & 1; int s = (ctx->btns >> ev.number) & 1;
if(s == ev.value) // State is the same : ignore if(s == ev.value) // State is the same : ignore
return MP_INPUT_NOTHING; return MP_INPUT_NOTHING;
} }
if(ev.type == JS_EVENT_AXIS) { if(ev.type == JS_EVENT_AXIS) {
if( ( ctx->axis[ev.number] == 1 && ev.value > JOY_AXIS_DELTA) || if( ( ctx->axis[ev.number] == 1 && ev.value > JOY_AXIS_DELTA) ||
(ctx->axis[ev.number] == -1 && ev.value < -JOY_AXIS_DELTA) || (ctx->axis[ev.number] == -1 && ev.value < -JOY_AXIS_DELTA) ||
(ctx->axis[ev.number] == 0 && ev.value >= -JOY_AXIS_DELTA && ev.value <= JOY_AXIS_DELTA) (ctx->axis[ev.number] == 0 && ev.value >= -JOY_AXIS_DELTA && ev.value <= JOY_AXIS_DELTA)
) // State is the same : ignore ) // State is the same : ignore
return MP_INPUT_NOTHING; return MP_INPUT_NOTHING;
} }
} }

View File

@@ -61,7 +61,7 @@ int mp_input_lirc_init(struct input_ctx *ictx, struct mp_log *log,
struct lirc_config *lirc_config = NULL; struct lirc_config *lirc_config = NULL;
if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){ if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){
mp_err(log, "Failed to read LIRC config file %s.\n", mp_err(log, "Failed to read LIRC config file %s.\n",
lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile); lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile);
lirc_deinit(); lirc_deinit();
return -1; return -1;
} }

View File

@@ -73,78 +73,78 @@
typedef enum typedef enum
{ {
kHIDRemoteModeNone = 0L, kHIDRemoteModeNone = 0L,
kHIDRemoteModeShared, // Share the remote with others - let's you listen to the remote control events as long as noone has an exclusive lock on it kHIDRemoteModeShared, // Share the remote with others - let's you listen to the remote control events as long as noone has an exclusive lock on it
// (RECOMMENDED ONLY FOR SPECIAL PURPOSES) // (RECOMMENDED ONLY FOR SPECIAL PURPOSES)
kHIDRemoteModeExclusive, // Try to acquire an exclusive lock on the remote (NOT RECOMMENDED) kHIDRemoteModeExclusive, // Try to acquire an exclusive lock on the remote (NOT RECOMMENDED)
kHIDRemoteModeExclusiveAuto // Try to acquire an exclusive lock on the remote whenever the application has focus. Temporarily release control over the kHIDRemoteModeExclusiveAuto // Try to acquire an exclusive lock on the remote whenever the application has focus. Temporarily release control over the
// remote when another application has focus (RECOMMENDED) // remote when another application has focus (RECOMMENDED)
} HIDRemoteMode; } HIDRemoteMode;
typedef enum typedef enum
{ {
/* A code reserved for "no button" (needed for tracking) */ /* A code reserved for "no button" (needed for tracking) */
kHIDRemoteButtonCodeNone = 0L, kHIDRemoteButtonCodeNone = 0L,
/* Standard codes - available for white plastic and aluminum remote */ /* Standard codes - available for white plastic and aluminum remote */
kHIDRemoteButtonCodeUp, kHIDRemoteButtonCodeUp,
kHIDRemoteButtonCodeDown, kHIDRemoteButtonCodeDown,
kHIDRemoteButtonCodeLeft, kHIDRemoteButtonCodeLeft,
kHIDRemoteButtonCodeRight, kHIDRemoteButtonCodeRight,
kHIDRemoteButtonCodeCenter, kHIDRemoteButtonCodeCenter,
kHIDRemoteButtonCodeMenu, kHIDRemoteButtonCodeMenu,
/* Extra codes - Only available for the new aluminum version of the remote */ /* Extra codes - Only available for the new aluminum version of the remote */
kHIDRemoteButtonCodePlay, kHIDRemoteButtonCodePlay,
/* Masks */ /* Masks */
kHIDRemoteButtonCodeCodeMask = 0xFFL, kHIDRemoteButtonCodeCodeMask = 0xFFL,
kHIDRemoteButtonCodeHoldMask = (1L << 16L), kHIDRemoteButtonCodeHoldMask = (1L << 16L),
kHIDRemoteButtonCodeSpecialMask = (1L << 17L), kHIDRemoteButtonCodeSpecialMask = (1L << 17L),
kHIDRemoteButtonCodeAluminumMask = (1L << 21L), // PRIVATE - only used internally kHIDRemoteButtonCodeAluminumMask = (1L << 21L), // PRIVATE - only used internally
/* Hold button standard codes - available for white plastic and aluminum remote */ /* Hold button standard codes - available for white plastic and aluminum remote */
kHIDRemoteButtonCodeUpHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeUp), kHIDRemoteButtonCodeUpHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeUp),
kHIDRemoteButtonCodeDownHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeDown), kHIDRemoteButtonCodeDownHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeDown),
kHIDRemoteButtonCodeLeftHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeLeft), kHIDRemoteButtonCodeLeftHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeLeft),
kHIDRemoteButtonCodeRightHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeRight), kHIDRemoteButtonCodeRightHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeRight),
kHIDRemoteButtonCodeCenterHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeCenter), kHIDRemoteButtonCodeCenterHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeCenter),
kHIDRemoteButtonCodeMenuHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeMenu), kHIDRemoteButtonCodeMenuHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodeMenu),
/* Hold button extra codes - Only available for aluminum version of the remote */ /* Hold button extra codes - Only available for aluminum version of the remote */
kHIDRemoteButtonCodePlayHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodePlay), kHIDRemoteButtonCodePlayHold = (kHIDRemoteButtonCodeHoldMask|kHIDRemoteButtonCodePlay),
/* DEPRECATED codes - compatibility with HIDRemote 1.0 */ /* DEPRECATED codes - compatibility with HIDRemote 1.0 */
kHIDRemoteButtonCodePlus = kHIDRemoteButtonCodeUp, kHIDRemoteButtonCodePlus = kHIDRemoteButtonCodeUp,
kHIDRemoteButtonCodePlusHold = kHIDRemoteButtonCodeUpHold, kHIDRemoteButtonCodePlusHold = kHIDRemoteButtonCodeUpHold,
kHIDRemoteButtonCodeMinus = kHIDRemoteButtonCodeDown, kHIDRemoteButtonCodeMinus = kHIDRemoteButtonCodeDown,
kHIDRemoteButtonCodeMinusHold = kHIDRemoteButtonCodeDownHold, kHIDRemoteButtonCodeMinusHold = kHIDRemoteButtonCodeDownHold,
kHIDRemoteButtonCodePlayPause = kHIDRemoteButtonCodeCenter, kHIDRemoteButtonCodePlayPause = kHIDRemoteButtonCodeCenter,
kHIDRemoteButtonCodePlayPauseHold = kHIDRemoteButtonCodeCenterHold, kHIDRemoteButtonCodePlayPauseHold = kHIDRemoteButtonCodeCenterHold,
/* Special purpose codes */ /* Special purpose codes */
kHIDRemoteButtonCodeIDChanged = (kHIDRemoteButtonCodeSpecialMask|(1L << 18L)), // (the ID of the connected remote has changed, you can safely ignore this) kHIDRemoteButtonCodeIDChanged = (kHIDRemoteButtonCodeSpecialMask|(1L << 18L)), // (the ID of the connected remote has changed, you can safely ignore this)
#ifdef _HIDREMOTE_EXTENSIONS #ifdef _HIDREMOTE_EXTENSIONS
#define _HIDREMOTE_EXTENSIONS_SECTION 1 #define _HIDREMOTE_EXTENSIONS_SECTION 1
#include "HIDRemoteAdditions.h" #include "HIDRemoteAdditions.h"
#undef _HIDREMOTE_EXTENSIONS_SECTION #undef _HIDREMOTE_EXTENSIONS_SECTION
#endif /* _HIDREMOTE_EXTENSIONS */ #endif /* _HIDREMOTE_EXTENSIONS */
} HIDRemoteButtonCode; } HIDRemoteButtonCode;
typedef enum typedef enum
{ {
kHIDRemoteModelUndetermined = 0L, // Assume a white plastic remote kHIDRemoteModelUndetermined = 0L, // Assume a white plastic remote
kHIDRemoteModelWhitePlastic, // Signal *likely* to be coming from a white plastic remote kHIDRemoteModelWhitePlastic, // Signal *likely* to be coming from a white plastic remote
kHIDRemoteModelAluminum // Signal *definitely* coming from an aluminum remote kHIDRemoteModelAluminum // Signal *definitely* coming from an aluminum remote
} HIDRemoteModel; } HIDRemoteModel;
typedef enum typedef enum
{ {
kHIDRemoteAluminumRemoteSupportLevelNone = 0L, // This system has no support for the Aluminum Remote at all kHIDRemoteAluminumRemoteSupportLevelNone = 0L, // This system has no support for the Aluminum Remote at all
kHIDRemoteAluminumRemoteSupportLevelEmulation, // This system possibly has support for the Aluminum Remote (via emulation) kHIDRemoteAluminumRemoteSupportLevelEmulation, // This system possibly has support for the Aluminum Remote (via emulation)
kHIDRemoteAluminumRemoteSupportLevelNative // This system has native support for the Aluminum Remote kHIDRemoteAluminumRemoteSupportLevelNative // This system has native support for the Aluminum Remote
} HIDRemoteAluminumRemoteSupportLevel; } HIDRemoteAluminumRemoteSupportLevel;
@class HIDRemote; @class HIDRemote;
@@ -153,46 +153,46 @@ typedef enum
@protocol HIDRemoteDelegate @protocol HIDRemoteDelegate
// Notification of button events // Notification of button events
- (void)hidRemote:(HIDRemote *)hidRemote // The instance of HIDRemote sending this - (void)hidRemote:(HIDRemote *)hidRemote // The instance of HIDRemote sending this
eventWithButton:(HIDRemoteButtonCode)buttonCode // Event for the button specified by code eventWithButton:(HIDRemoteButtonCode)buttonCode // Event for the button specified by code
isPressed:(BOOL)isPressed // The button was pressed (YES) / released (NO) isPressed:(BOOL)isPressed // The button was pressed (YES) / released (NO)
fromHardwareWithAttributes:(NSMutableDictionary *)attributes; // Information on the device this event comes from fromHardwareWithAttributes:(NSMutableDictionary *)attributes; // Information on the device this event comes from
@optional @optional
// Notification of ID changes // Notification of ID changes
- (void)hidRemote:(HIDRemote *)hidRemote // Invoked when the user switched to a remote control with a different ID - (void)hidRemote:(HIDRemote *)hidRemote // Invoked when the user switched to a remote control with a different ID
remoteIDChangedOldID:(SInt32)old remoteIDChangedOldID:(SInt32)old
newID:(SInt32)newID newID:(SInt32)newID
forHardwareWithAttributes:(NSMutableDictionary *)attributes; forHardwareWithAttributes:(NSMutableDictionary *)attributes;
// Notification about hardware additions/removals // Notification about hardware additions/removals
- (void)hidRemote:(HIDRemote *)hidRemote // Invoked when new hardware was found / added to HIDRemote's pool - (void)hidRemote:(HIDRemote *)hidRemote // Invoked when new hardware was found / added to HIDRemote's pool
foundNewHardwareWithAttributes:(NSMutableDictionary *)attributes; foundNewHardwareWithAttributes:(NSMutableDictionary *)attributes;
- (void)hidRemote:(HIDRemote *)hidRemote // Invoked when initialization of new hardware as requested failed - (void)hidRemote:(HIDRemote *)hidRemote // Invoked when initialization of new hardware as requested failed
failedNewHardwareWithError:(NSError *)error; failedNewHardwareWithError:(NSError *)error;
- (void)hidRemote:(HIDRemote *)hidRemote // Invoked when hardware was removed from HIDRemote's pool - (void)hidRemote:(HIDRemote *)hidRemote // Invoked when hardware was removed from HIDRemote's pool
releasedHardwareWithAttributes:(NSMutableDictionary *)attributes; releasedHardwareWithAttributes:(NSMutableDictionary *)attributes;
// ### WARNING: Unless you know VERY PRECISELY what you are doing, do not implement any of the delegate methods below. ### // ### WARNING: Unless you know VERY PRECISELY what you are doing, do not implement any of the delegate methods below. ###
// Matching of newly found receiver hardware // Matching of newly found receiver hardware
- (BOOL)hidRemote:(HIDRemote *)hidRemote // Invoked when new hardware is inspected - (BOOL)hidRemote:(HIDRemote *)hidRemote // Invoked when new hardware is inspected
inspectNewHardwareWithService:(io_service_t)service // inspectNewHardwareWithService:(io_service_t)service //
prematchResult:(BOOL)prematchResult; // Return YES if HIDRemote should go on with this hardware and try prematchResult:(BOOL)prematchResult; // Return YES if HIDRemote should go on with this hardware and try
// to use it, or NO if it should not be persued further. // to use it, or NO if it should not be persued further.
// Exlusive lock lending // Exlusive lock lending
- (BOOL)hidRemote:(HIDRemote *)hidRemote - (BOOL)hidRemote:(HIDRemote *)hidRemote
lendExclusiveLockToApplicationWithInfo:(NSDictionary *)applicationInfo; lendExclusiveLockToApplicationWithInfo:(NSDictionary *)applicationInfo;
- (void)hidRemote:(HIDRemote *)hidRemote - (void)hidRemote:(HIDRemote *)hidRemote
exclusiveLockReleasedByApplicationWithInfo:(NSDictionary *)applicationInfo; exclusiveLockReleasedByApplicationWithInfo:(NSDictionary *)applicationInfo;
- (BOOL)hidRemote:(HIDRemote *)hidRemote - (BOOL)hidRemote:(HIDRemote *)hidRemote
shouldRetryExclusiveLockWithInfo:(NSDictionary *)applicationInfo; shouldRetryExclusiveLockWithInfo:(NSDictionary *)applicationInfo;
@end @end
@@ -201,65 +201,65 @@ typedef enum
@interface HIDRemote : NSObject @interface HIDRemote : NSObject
{ {
// IOMasterPort // IOMasterPort
mach_port_t _masterPort; mach_port_t _masterPort;
// Notification ports // Notification ports
IONotificationPortRef _notifyPort; IONotificationPortRef _notifyPort;
CFRunLoopSourceRef _notifyRLSource; CFRunLoopSourceRef _notifyRLSource;
// Matching iterator // Matching iterator
io_iterator_t _matchingServicesIterator; io_iterator_t _matchingServicesIterator;
// SecureInput notification // SecureInput notification
io_object_t _secureInputNotification; io_object_t _secureInputNotification;
// Service attributes // Service attributes
NSMutableDictionary *_serviceAttribMap; NSMutableDictionary *_serviceAttribMap;
// Mode // Mode
HIDRemoteMode _mode; HIDRemoteMode _mode;
BOOL _autoRecover; BOOL _autoRecover;
NSTimer *_autoRecoveryTimer; NSTimer *_autoRecoveryTimer;
// Delegate // Delegate
NSObject <HIDRemoteDelegate> *_delegate; NSObject <HIDRemoteDelegate> *_delegate;
// Last seen ID and remote model // Last seen ID and remote model
SInt32 _lastSeenRemoteID; SInt32 _lastSeenRemoteID;
HIDRemoteModel _lastSeenModel; HIDRemoteModel _lastSeenModel;
SInt32 _lastSeenModelRemoteID; SInt32 _lastSeenModelRemoteID;
// Unused button codes // Unused button codes
NSArray *_unusedButtonCodes; NSArray *_unusedButtonCodes;
// Simulate Plus/Minus Hold // Simulate Plus/Minus Hold
BOOL _simulateHoldEvents; BOOL _simulateHoldEvents;
// SecureEventInput workaround // SecureEventInput workaround
BOOL _secureEventInputWorkAround; BOOL _secureEventInputWorkAround;
UInt64 _lastSecureEventInputPIDSum; UInt64 _lastSecureEventInputPIDSum;
uid_t _lastFrontUserSession; uid_t _lastFrontUserSession;
// Exclusive lock lending // Exclusive lock lending
BOOL _exclusiveLockLending; BOOL _exclusiveLockLending;
BOOL _sendExclusiveResourceReuseNotification; BOOL _sendExclusiveResourceReuseNotification;
NSNumber *_waitForReturnByPID; NSNumber *_waitForReturnByPID;
NSNumber *_returnToPID; NSNumber *_returnToPID;
BOOL _isRestarting; BOOL _isRestarting;
// Status notifications // Status notifications
BOOL _sendStatusNotifications; BOOL _sendStatusNotifications;
NSString *_pidString; NSString *_pidString;
// Status // Status
BOOL _applicationIsTerminating; BOOL _applicationIsTerminating;
BOOL _isStopping; BOOL _isStopping;
// Thread safety // Thread safety
#ifdef HIDREMOTE_THREADSAFETY_HARDENED_NOTIFICATION_HANDLING /* #define HIDREMOTE_THREADSAFETY_HARDENED_NOTIFICATION_HANDLING if you're running your HIDRemote instance on a background thread (requires OS X 10.5 or later) */ #ifdef HIDREMOTE_THREADSAFETY_HARDENED_NOTIFICATION_HANDLING /* #define HIDREMOTE_THREADSAFETY_HARDENED_NOTIFICATION_HANDLING if you're running your HIDRemote instance on a background thread (requires OS X 10.5 or later) */
NSThread *_runOnThread; NSThread *_runOnThread;
#endif #endif
} }
#pragma mark -- PUBLIC: Shared HID Remote -- #pragma mark -- PUBLIC: Shared HID Remote --
@@ -271,7 +271,7 @@ typedef enum
- (HIDRemoteAluminumRemoteSupportLevel)aluminiumRemoteSystemSupportLevel; - (HIDRemoteAluminumRemoteSupportLevel)aluminiumRemoteSystemSupportLevel;
#pragma mark -- PUBLIC: Interface / API -- #pragma mark -- PUBLIC: Interface / API --
- (BOOL)startRemoteControl:(HIDRemoteMode)hidRemoteMode; - (BOOL)startRemoteControl:(HIDRemoteMode)hidRemoteMode;
- (void)stopRemoteControl; - (void)stopRemoteControl;
- (BOOL)isStarted; - (BOOL)isStarted;
@@ -374,5 +374,5 @@ extern NSString *kHIDRemoteDNStatusActionNoNeed;
#pragma mark -- Driver compatibility flags -- #pragma mark -- Driver compatibility flags --
typedef enum typedef enum
{ {
kHIDRemoteCompatibilityFlagsStandardHIDRemoteDevice = 1L, kHIDRemoteCompatibilityFlagsStandardHIDRemoteDevice = 1L,
} HIDRemoteCompatibilityFlags; } HIDRemoteCompatibilityFlags;

View File

File diff suppressed because it is too large Load Diff

View File

@@ -40,61 +40,61 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_hw_params_any(ai->alsa.handle, params); err = snd_pcm_hw_params_any(ai->alsa.handle, params);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Broken configuration for this PCM: no configurations available.\n"); MP_ERR(ai, "Broken configuration for this PCM: no configurations available.\n");
return -1; return -1;
} }
err = snd_pcm_hw_params_set_access(ai->alsa.handle, params, err = snd_pcm_hw_params_set_access(ai->alsa.handle, params,
SND_PCM_ACCESS_RW_INTERLEAVED); SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Access type not available.\n"); MP_ERR(ai, "Access type not available.\n");
return -1; return -1;
} }
err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE); err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Sample format not available.\n"); MP_ERR(ai, "Sample format not available.\n");
return -1; return -1;
} }
err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels); err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
if (err < 0) { if (err < 0) {
snd_pcm_hw_params_get_channels(params, &ai->channels); snd_pcm_hw_params_get_channels(params, &ai->channels);
MP_ERR(ai, "Channel count not available - reverting to default: %d\n", MP_ERR(ai, "Channel count not available - reverting to default: %d\n",
ai->channels); ai->channels);
} else { } else {
ai->channels = ai->req_channels; ai->channels = ai->req_channels;
} }
dir = 0; dir = 0;
rate = ai->req_samplerate; rate = ai->req_samplerate;
err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, &rate, &dir); err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, &rate, &dir);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Cannot set samplerate.\n"); MP_ERR(ai, "Cannot set samplerate.\n");
} }
ai->samplerate = rate; ai->samplerate = rate;
dir = 0; dir = 0;
ai->alsa.buffer_time = 1000000; ai->alsa.buffer_time = 1000000;
err = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params, err = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
&ai->alsa.buffer_time, &dir); &ai->alsa.buffer_time, &dir);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Cannot set buffer time.\n"); MP_ERR(ai, "Cannot set buffer time.\n");
} }
dir = 0; dir = 0;
ai->alsa.period_time = ai->alsa.buffer_time / 4; ai->alsa.period_time = ai->alsa.buffer_time / 4;
err = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params, err = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
&ai->alsa.period_time, &dir); &ai->alsa.period_time, &dir);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Cannot set period time.\n"); MP_ERR(ai, "Cannot set period time.\n");
} }
err = snd_pcm_hw_params(ai->alsa.handle, params); err = snd_pcm_hw_params(ai->alsa.handle, params);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Unable to install hardware parameters: %s", snd_strerror(err)); MP_ERR(ai, "Unable to install hardware parameters: %s", snd_strerror(err));
snd_pcm_hw_params_dump(params, ai->alsa.log); snd_pcm_hw_params_dump(params, ai->alsa.log);
return -1; return -1;
} }
dir = -1; dir = -1;
@@ -102,8 +102,8 @@ int ai_alsa_setup(audio_in_t *ai)
snd_pcm_hw_params_get_buffer_size(params, &buffer_size); snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
ai->alsa.chunk_size = period_size; ai->alsa.chunk_size = period_size;
if (period_size == buffer_size) { if (period_size == buffer_size) {
MP_ERR(ai, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size); MP_ERR(ai, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size);
return -1; return -1;
} }
snd_pcm_sw_params_current(ai->alsa.handle, swparams); snd_pcm_sw_params_current(ai->alsa.handle, swparams);
@@ -113,13 +113,13 @@ int ai_alsa_setup(audio_in_t *ai)
err = snd_pcm_sw_params_set_stop_threshold(ai->alsa.handle, swparams, buffer_size); err = snd_pcm_sw_params_set_stop_threshold(ai->alsa.handle, swparams, buffer_size);
if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) { if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) {
MP_ERR(ai, "Unable to install software parameters:\n"); MP_ERR(ai, "Unable to install software parameters:\n");
snd_pcm_sw_params_dump(swparams, ai->alsa.log); snd_pcm_sw_params_dump(swparams, ai->alsa.log);
return -1; return -1;
} }
if (mp_msg_test(ai->log, MSGL_V)) { if (mp_msg_test(ai->log, MSGL_V)) {
snd_pcm_dump(ai->alsa.handle, ai->alsa.log); snd_pcm_dump(ai->alsa.handle, ai->alsa.log);
} }
ai->alsa.bits_per_sample = snd_pcm_format_physical_width(SND_PCM_FORMAT_S16_LE); ai->alsa.bits_per_sample = snd_pcm_format_physical_width(SND_PCM_FORMAT_S16_LE);
@@ -137,14 +137,14 @@ int ai_alsa_init(audio_in_t *ai)
err = snd_pcm_open(&ai->alsa.handle, ai->alsa.device, SND_PCM_STREAM_CAPTURE, 0); err = snd_pcm_open(&ai->alsa.handle, ai->alsa.device, SND_PCM_STREAM_CAPTURE, 0);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Error opening audio: %s\n", snd_strerror(err)); MP_ERR(ai, "Error opening audio: %s\n", snd_strerror(err));
return -1; return -1;
} }
err = snd_output_stdio_attach(&ai->alsa.log, stderr, 0); err = snd_output_stdio_attach(&ai->alsa.log, stderr, 0);
if (err < 0) { if (err < 0) {
return -1; return -1;
} }
err = ai_alsa_setup(ai); err = ai_alsa_setup(ai);
@@ -153,14 +153,14 @@ int ai_alsa_init(audio_in_t *ai)
} }
#ifndef timersub #ifndef timersub
#define timersub(a, b, result) \ #define timersub(a, b, result) \
do { \ do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) { \ if ((result)->tv_usec < 0) { \
--(result)->tv_sec; \ --(result)->tv_sec; \
(result)->tv_usec += 1000000; \ (result)->tv_usec += 1000000; \
} \ } \
} while (0) } while (0)
#endif #endif
@@ -171,25 +171,25 @@ int ai_alsa_xrun(audio_in_t *ai)
snd_pcm_status_alloca(&status); snd_pcm_status_alloca(&status);
if ((res = snd_pcm_status(ai->alsa.handle, status))<0) { if ((res = snd_pcm_status(ai->alsa.handle, status))<0) {
MP_ERR(ai, "ALSA status error: %s", snd_strerror(res)); MP_ERR(ai, "ALSA status error: %s", snd_strerror(res));
return -1; return -1;
} }
if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
struct timeval now, diff, tstamp; struct timeval now, diff, tstamp;
gettimeofday(&now, 0); gettimeofday(&now, 0);
snd_pcm_status_get_trigger_tstamp(status, &tstamp); snd_pcm_status_get_trigger_tstamp(status, &tstamp);
timersub(&now, &tstamp, &diff); timersub(&now, &tstamp, &diff);
MP_ERR(ai, "ALSA xrun!!! (at least %.3f ms long)\n", MP_ERR(ai, "ALSA xrun!!! (at least %.3f ms long)\n",
diff.tv_sec * 1000 + diff.tv_usec / 1000.0); diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
if (mp_msg_test(ai->log, MSGL_V)) { if (mp_msg_test(ai->log, MSGL_V)) {
MP_ERR(ai, "ALSA Status:\n"); MP_ERR(ai, "ALSA Status:\n");
snd_pcm_status_dump(status, ai->alsa.log); snd_pcm_status_dump(status, ai->alsa.log);
} }
if ((res = snd_pcm_prepare(ai->alsa.handle))<0) { if ((res = snd_pcm_prepare(ai->alsa.handle))<0) {
MP_ERR(ai, "ALSA xrun: prepare error: %s", snd_strerror(res)); MP_ERR(ai, "ALSA xrun: prepare error: %s", snd_strerror(res));
return -1; return -1;
} }
return 0; /* ok, data should be accepted again */ return 0; /* ok, data should be accepted again */
} }
MP_ERR(ai, "ALSA read/write error"); MP_ERR(ai, "ALSA read/write error");
return -1; return -1;

View File

@@ -56,28 +56,28 @@ int ai_oss_set_channels(audio_in_t *ai)
if (ai->req_channels > 2) if (ai->req_channels > 2)
{ {
ioctl_param = ai->req_channels; ioctl_param = ai->req_channels;
MP_VERBOSE(ai, "ioctl dsp channels: %d\n", MP_VERBOSE(ai, "ioctl dsp channels: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_CHANNELS, &ioctl_param)); err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_CHANNELS, &ioctl_param));
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Unable to set channel count: %d\n", MP_ERR(ai, "Unable to set channel count: %d\n",
ai->req_channels); ai->req_channels);
return -1; return -1;
} }
ai->channels = ioctl_param; ai->channels = ioctl_param;
} }
else else
{ {
ioctl_param = (ai->req_channels == 2); ioctl_param = (ai->req_channels == 2);
MP_VERBOSE(ai, "ioctl dsp stereo: %d (req: %d)\n", MP_VERBOSE(ai, "ioctl dsp stereo: %d (req: %d)\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_STEREO, &ioctl_param), err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_STEREO, &ioctl_param),
ioctl_param); ioctl_param);
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Unable to set stereo: %d\n", MP_ERR(ai, "Unable to set stereo: %d\n",
ai->req_channels == 2); ai->req_channels == 2);
return -1; return -1;
} }
ai->channels = ioctl_param ? 2 : 1; ai->channels = ioctl_param ? 2 : 1;
} }
return 0; return 0;
} }
@@ -90,65 +90,65 @@ int ai_oss_init(audio_in_t *ai)
ai->oss.audio_fd = open(ai->oss.device, O_RDONLY | O_CLOEXEC); ai->oss.audio_fd = open(ai->oss.device, O_RDONLY | O_CLOEXEC);
if (ai->oss.audio_fd < 0) if (ai->oss.audio_fd < 0)
{ {
MP_ERR(ai, "Unable to open '%s': %s\n", MP_ERR(ai, "Unable to open '%s': %s\n",
ai->oss.device, strerror(errno)); ai->oss.device, strerror(errno));
return -1; return -1;
} }
ioctl_param = 0 ; ioctl_param = 0 ;
MP_VERBOSE(ai, "ioctl dsp getfmt: %d\n", MP_VERBOSE(ai, "ioctl dsp getfmt: %d\n",
ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETFMTS, &ioctl_param)); ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETFMTS, &ioctl_param));
MP_VERBOSE(ai, "Supported formats: %x\n", ioctl_param); MP_VERBOSE(ai, "Supported formats: %x\n", ioctl_param);
if (!(ioctl_param & AFMT_S16_LE)) if (!(ioctl_param & AFMT_S16_LE))
MP_ERR(ai, "unsupported format\n"); MP_ERR(ai, "unsupported format\n");
ioctl_param = AFMT_S16_LE; ioctl_param = AFMT_S16_LE;
MP_VERBOSE(ai, "ioctl dsp setfmt: %d\n", MP_VERBOSE(ai, "ioctl dsp setfmt: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETFMT, &ioctl_param)); err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETFMT, &ioctl_param));
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Unable to set audio format."); MP_ERR(ai, "Unable to set audio format.");
return -1; return -1;
} }
if (ai_oss_set_channels(ai) < 0) return -1; if (ai_oss_set_channels(ai) < 0) return -1;
ioctl_param = ai->req_samplerate; ioctl_param = ai->req_samplerate;
MP_VERBOSE(ai, "ioctl dsp speed: %d\n", MP_VERBOSE(ai, "ioctl dsp speed: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &ioctl_param)); err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &ioctl_param));
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Unable to set samplerate: %d\n", MP_ERR(ai, "Unable to set samplerate: %d\n",
ai->req_samplerate); ai->req_samplerate);
return -1; return -1;
} }
ai->samplerate = ioctl_param; ai->samplerate = ioctl_param;
MP_VERBOSE(ai, "ioctl dsp trigger: %d\n", MP_VERBOSE(ai, "ioctl dsp trigger: %d\n",
ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETTRIGGER, &ioctl_param)); ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETTRIGGER, &ioctl_param));
MP_VERBOSE(ai, "trigger: %x\n", ioctl_param); MP_VERBOSE(ai, "trigger: %x\n", ioctl_param);
ioctl_param = PCM_ENABLE_INPUT; ioctl_param = PCM_ENABLE_INPUT;
MP_VERBOSE(ai, "ioctl dsp trigger: %d\n", MP_VERBOSE(ai, "ioctl dsp trigger: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETTRIGGER, &ioctl_param)); err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETTRIGGER, &ioctl_param));
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Unable to set trigger: %d\n", MP_ERR(ai, "Unable to set trigger: %d\n",
PCM_ENABLE_INPUT); PCM_ENABLE_INPUT);
} }
ai->blocksize = 0; ai->blocksize = 0;
MP_VERBOSE(ai, "ioctl dsp getblocksize: %d\n", MP_VERBOSE(ai, "ioctl dsp getblocksize: %d\n",
err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETBLKSIZE, &ai->blocksize)); err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETBLKSIZE, &ai->blocksize));
if (err < 0) { if (err < 0) {
MP_ERR(ai, "Unable to get block size!\n"); MP_ERR(ai, "Unable to get block size!\n");
} }
MP_VERBOSE(ai, "blocksize: %d\n", ai->blocksize); MP_VERBOSE(ai, "blocksize: %d\n", ai->blocksize);
// correct the blocksize to a reasonable value // correct the blocksize to a reasonable value
if (ai->blocksize <= 0) { if (ai->blocksize <= 0) {
ai->blocksize = 4096*ai->channels*2; ai->blocksize = 4096*ai->channels*2;
MP_ERR(ai, "Audio block size is zero, setting to %d!\n", ai->blocksize); MP_ERR(ai, "Audio block size is zero, setting to %d!\n", ai->blocksize);
} else if (ai->blocksize < 4096*ai->channels*2) { } else if (ai->blocksize < 4096*ai->channels*2) {
ai->blocksize *= 4096*ai->channels*2/ai->blocksize; ai->blocksize *= 4096*ai->channels*2/ai->blocksize;
MP_ERR(ai, "Audio block size too low, setting to %d!\n", ai->blocksize); MP_ERR(ai, "Audio block size too low, setting to %d!\n", ai->blocksize);
} }
ai->samplesize = 16; ai->samplesize = 16;

View File

@@ -18,11 +18,11 @@ int ai_sndio_setup(audio_in_t *ai)
par.le = 1; par.le = 1;
par.rchan = ai->req_channels; par.rchan = ai->req_channels;
par.rate = ai->req_samplerate; par.rate = ai->req_samplerate;
par.appbufsz = ai->req_samplerate; /* 1 sec */ par.appbufsz = ai->req_samplerate; /* 1 sec */
if (!sio_setpar(ai->sndio.hdl, &par) || !sio_getpar(ai->sndio.hdl, &par)) { if (!sio_setpar(ai->sndio.hdl, &par) || !sio_getpar(ai->sndio.hdl, &par)) {
MP_ERR(ai, "could not configure sndio audio"); MP_ERR(ai, "could not configure sndio audio");
return -1; return -1;
} }
ai->channels = par.rchan; ai->channels = par.rchan;
@@ -39,8 +39,8 @@ int ai_sndio_init(audio_in_t *ai)
int err; int err;
if ((ai->sndio.hdl = sio_open(ai->sndio.device, SIO_REC, 0)) == NULL) { if ((ai->sndio.hdl = sio_open(ai->sndio.device, SIO_REC, 0)) == NULL) {
MP_ERR(ai, "could not open sndio audio"); MP_ERR(ai, "could not open sndio audio");
return -1; return -1;
} }
err = ai_sndio_setup(ai); err = ai_sndio_setup(ai);

View File

@@ -43,25 +43,25 @@ int audio_in_init(audio_in_t *ai, struct mp_log *log, int type)
switch (ai->type) { switch (ai->type) {
#if HAVE_ALSA #if HAVE_ALSA
case AUDIO_IN_ALSA: case AUDIO_IN_ALSA:
ai->alsa.handle = NULL; ai->alsa.handle = NULL;
ai->alsa.log = NULL; ai->alsa.log = NULL;
ai->alsa.device = strdup("default"); ai->alsa.device = strdup("default");
return 0; return 0;
#endif #endif
#if HAVE_OSS_AUDIO #if HAVE_OSS_AUDIO
case AUDIO_IN_OSS: case AUDIO_IN_OSS:
ai->oss.audio_fd = -1; ai->oss.audio_fd = -1;
ai->oss.device = strdup("/dev/dsp"); ai->oss.device = strdup("/dev/dsp");
return 0; return 0;
#endif #endif
#if HAVE_SNDIO #if HAVE_SNDIO
case AUDIO_IN_SNDIO: case AUDIO_IN_SNDIO:
ai->sndio.hdl = NULL; ai->sndio.hdl = NULL;
ai->sndio.device = strdup("default"); ai->sndio.device = strdup("default");
return 0; return 0;
#endif #endif
default: default:
return -1; return -1;
} }
} }
@@ -71,24 +71,24 @@ int audio_in_setup(audio_in_t *ai)
switch (ai->type) { switch (ai->type) {
#if HAVE_ALSA #if HAVE_ALSA
case AUDIO_IN_ALSA: case AUDIO_IN_ALSA:
if (ai_alsa_init(ai) < 0) return -1; if (ai_alsa_init(ai) < 0) return -1;
ai->setup = 1; ai->setup = 1;
return 0; return 0;
#endif #endif
#if HAVE_OSS_AUDIO #if HAVE_OSS_AUDIO
case AUDIO_IN_OSS: case AUDIO_IN_OSS:
if (ai_oss_init(ai) < 0) return -1; if (ai_oss_init(ai) < 0) return -1;
ai->setup = 1; ai->setup = 1;
return 0; return 0;
#endif #endif
#if HAVE_SNDIO #if HAVE_SNDIO
case AUDIO_IN_SNDIO: case AUDIO_IN_SNDIO:
if (ai_sndio_init(ai) < 0) return -1; if (ai_sndio_init(ai) < 0) return -1;
ai->setup = 1; ai->setup = 1;
return 0; return 0;
#endif #endif
default: default:
return -1; return -1;
} }
} }
@@ -97,27 +97,27 @@ int audio_in_set_samplerate(audio_in_t *ai, int rate)
switch (ai->type) { switch (ai->type) {
#if HAVE_ALSA #if HAVE_ALSA
case AUDIO_IN_ALSA: case AUDIO_IN_ALSA:
ai->req_samplerate = rate; ai->req_samplerate = rate;
if (!ai->setup) return 0; if (!ai->setup) return 0;
if (ai_alsa_setup(ai) < 0) return -1; if (ai_alsa_setup(ai) < 0) return -1;
return ai->samplerate; return ai->samplerate;
#endif #endif
#if HAVE_OSS_AUDIO #if HAVE_OSS_AUDIO
case AUDIO_IN_OSS: case AUDIO_IN_OSS:
ai->req_samplerate = rate; ai->req_samplerate = rate;
if (!ai->setup) return 0; if (!ai->setup) return 0;
if (ai_oss_set_samplerate(ai) < 0) return -1; if (ai_oss_set_samplerate(ai) < 0) return -1;
return ai->samplerate; return ai->samplerate;
#endif #endif
#if HAVE_SNDIO #if HAVE_SNDIO
case AUDIO_IN_SNDIO: case AUDIO_IN_SNDIO:
ai->req_samplerate = rate; ai->req_samplerate = rate;
if (!ai->setup) return 0; if (!ai->setup) return 0;
if (ai_sndio_setup(ai) < 0) return -1; if (ai_sndio_setup(ai) < 0) return -1;
return ai->samplerate; return ai->samplerate;
#endif #endif
default: default:
return -1; return -1;
} }
} }
@@ -126,17 +126,17 @@ int audio_in_set_channels(audio_in_t *ai, int channels)
switch (ai->type) { switch (ai->type) {
#if HAVE_ALSA #if HAVE_ALSA
case AUDIO_IN_ALSA: case AUDIO_IN_ALSA:
ai->req_channels = channels; ai->req_channels = channels;
if (!ai->setup) return 0; if (!ai->setup) return 0;
if (ai_alsa_setup(ai) < 0) return -1; if (ai_alsa_setup(ai) < 0) return -1;
return ai->channels; return ai->channels;
#endif #endif
#if HAVE_OSS_AUDIO #if HAVE_OSS_AUDIO
case AUDIO_IN_OSS: case AUDIO_IN_OSS:
ai->req_channels = channels; ai->req_channels = channels;
if (!ai->setup) return 0; if (!ai->setup) return 0;
if (ai_oss_set_channels(ai) < 0) return -1; if (ai_oss_set_channels(ai) < 0) return -1;
return ai->channels; return ai->channels;
#endif #endif
#if HAVE_SNDIO #if HAVE_SNDIO
case AUDIO_IN_SNDIO: case AUDIO_IN_SNDIO:
@@ -146,7 +146,7 @@ int audio_in_set_channels(audio_in_t *ai, int channels)
return ai->channels; return ai->channels;
#endif #endif
default: default:
return -1; return -1;
} }
} }
@@ -159,19 +159,19 @@ int audio_in_set_device(audio_in_t *ai, char *device)
switch (ai->type) { switch (ai->type) {
#if HAVE_ALSA #if HAVE_ALSA
case AUDIO_IN_ALSA: case AUDIO_IN_ALSA:
free(ai->alsa.device); free(ai->alsa.device);
ai->alsa.device = strdup(device); ai->alsa.device = strdup(device);
/* mplayer cannot handle colons in arguments */ /* mplayer cannot handle colons in arguments */
for (i = 0; i < (int)strlen(ai->alsa.device); i++) { for (i = 0; i < (int)strlen(ai->alsa.device); i++) {
if (ai->alsa.device[i] == '.') ai->alsa.device[i] = ':'; if (ai->alsa.device[i] == '.') ai->alsa.device[i] = ':';
} }
return 0; return 0;
#endif #endif
#if HAVE_OSS_AUDIO #if HAVE_OSS_AUDIO
case AUDIO_IN_OSS: case AUDIO_IN_OSS:
free(ai->oss.device); free(ai->oss.device);
ai->oss.device = strdup(device); ai->oss.device = strdup(device);
return 0; return 0;
#endif #endif
#if HAVE_SNDIO #if HAVE_SNDIO
case AUDIO_IN_SNDIO: case AUDIO_IN_SNDIO:
@@ -180,29 +180,29 @@ int audio_in_set_device(audio_in_t *ai, char *device)
return 0; return 0;
#endif #endif
default: default:
return -1; return -1;
} }
} }
int audio_in_uninit(audio_in_t *ai) int audio_in_uninit(audio_in_t *ai)
{ {
if (ai->setup) { if (ai->setup) {
switch (ai->type) { switch (ai->type) {
#if HAVE_ALSA #if HAVE_ALSA
case AUDIO_IN_ALSA: case AUDIO_IN_ALSA:
if (ai->alsa.log) if (ai->alsa.log)
snd_output_close(ai->alsa.log); snd_output_close(ai->alsa.log);
if (ai->alsa.handle) { if (ai->alsa.handle) {
snd_pcm_close(ai->alsa.handle); snd_pcm_close(ai->alsa.handle);
} }
ai->setup = 0; ai->setup = 0;
return 0; return 0;
#endif #endif
#if HAVE_OSS_AUDIO #if HAVE_OSS_AUDIO
case AUDIO_IN_OSS: case AUDIO_IN_OSS:
close(ai->oss.audio_fd); close(ai->oss.audio_fd);
ai->setup = 0; ai->setup = 0;
return 0; return 0;
#endif #endif
#if HAVE_SNDIO #if HAVE_SNDIO
case AUDIO_IN_SNDIO: case AUDIO_IN_SNDIO:
@@ -211,7 +211,7 @@ int audio_in_uninit(audio_in_t *ai)
ai->setup = 0; ai->setup = 0;
return 0; return 0;
#endif #endif
} }
} }
return -1; return -1;
} }
@@ -221,11 +221,11 @@ int audio_in_start_capture(audio_in_t *ai)
switch (ai->type) { switch (ai->type) {
#if HAVE_ALSA #if HAVE_ALSA
case AUDIO_IN_ALSA: case AUDIO_IN_ALSA:
return snd_pcm_start(ai->alsa.handle); return snd_pcm_start(ai->alsa.handle);
#endif #endif
#if HAVE_OSS_AUDIO #if HAVE_OSS_AUDIO
case AUDIO_IN_OSS: case AUDIO_IN_OSS:
return 0; return 0;
#endif #endif
#if HAVE_SNDIO #if HAVE_SNDIO
case AUDIO_IN_SNDIO: case AUDIO_IN_SNDIO:
@@ -234,7 +234,7 @@ int audio_in_start_capture(audio_in_t *ai)
return 0; return 0;
#endif #endif
default: default:
return -1; return -1;
} }
} }
@@ -245,27 +245,27 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
switch (ai->type) { switch (ai->type) {
#if HAVE_ALSA #if HAVE_ALSA
case AUDIO_IN_ALSA: case AUDIO_IN_ALSA:
ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size); ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size);
if (ret != ai->alsa.chunk_size) { if (ret != ai->alsa.chunk_size) {
if (ret < 0) { if (ret < 0) {
MP_ERR(ai, "\nError reading audio: %s\n", snd_strerror(ret)); MP_ERR(ai, "\nError reading audio: %s\n", snd_strerror(ret));
if (ret == -EPIPE) { if (ret == -EPIPE) {
if (ai_alsa_xrun(ai) == 0) { if (ai_alsa_xrun(ai) == 0) {
MP_ERR(ai, "Recovered from cross-run, some frames may be left out!\n"); MP_ERR(ai, "Recovered from cross-run, some frames may be left out!\n");
} else { } else {
MP_ERR(ai, "Fatal error, cannot recover!\n"); MP_ERR(ai, "Fatal error, cannot recover!\n");
} }
} }
} else { } else {
MP_ERR(ai, "\nNot enough audio samples!\n"); MP_ERR(ai, "\nNot enough audio samples!\n");
} }
return -1; return -1;
} }
return ret; return ret;
#endif #endif
#if HAVE_OSS_AUDIO #if HAVE_OSS_AUDIO
case AUDIO_IN_OSS: case AUDIO_IN_OSS:
ret = read(ai->oss.audio_fd, buffer, ai->blocksize); ret = read(ai->oss.audio_fd, buffer, ai->blocksize);
if (ret != ai->blocksize) { if (ret != ai->blocksize) {
if (ret < 0) { if (ret < 0) {
MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno)); MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno));
@@ -280,17 +280,17 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
#if HAVE_SNDIO #if HAVE_SNDIO
case AUDIO_IN_SNDIO: case AUDIO_IN_SNDIO:
ret = sio_read(ai->sndio.hdl, buffer, ai->blocksize); ret = sio_read(ai->sndio.hdl, buffer, ai->blocksize);
if (ret != ai->blocksize) { if (ret != ai->blocksize) {
if (ret < 0) { if (ret < 0) {
MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno)); MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno));
} else { } else {
MP_ERR(ai, "\nNot enough audio samples!\n"); MP_ERR(ai, "\nNot enough audio samples!\n");
} }
return -1; return -1;
} }
return ret; return ret;
#endif #endif
default: default:
return -1; return -1;
} }
} }

View File

@@ -55,7 +55,7 @@ static char *col_dup(void *talloc_ctx, const char *src)
{ {
int length = 0; int length = 0;
while (src[length] > 31) while (src[length] > 31)
length++; length++;
return talloc_strndup(talloc_ctx, src, length); return talloc_strndup(talloc_ctx, src, length);
} }
@@ -67,13 +67,13 @@ static int parse_line(char **ptr, char *cols[7])
cols[0] = *ptr; cols[0] = *ptr;
for (col = 1; col < 7; col++) { for (col = 1; col < 7; col++) {
for (; (**ptr) > 31; (*ptr)++); for (; (**ptr) > 31; (*ptr)++);
if (**ptr == 0) if (**ptr == 0)
return 0; return 0;
(*ptr)++; (*ptr)++;
if ((*ptr)[-1] != 9) if ((*ptr)[-1] != 9)
return 0; return 0;
cols[col] = (*ptr); cols[col] = (*ptr);
} }
return 1; return 1;
@@ -89,32 +89,32 @@ static char *load_file(struct mp_log *log, const char *filename, int64_t * lengt
fd = open(filename, O_RDONLY | O_CLOEXEC); fd = open(filename, O_RDONLY | O_CLOEXEC);
if (fd < 0) { if (fd < 0) {
mp_verbose(log, "Could not open"); mp_verbose(log, "Could not open");
goto err_out; goto err_out;
} }
*length = lseek(fd, 0, SEEK_END); *length = lseek(fd, 0, SEEK_END);
if (*length < 0) { if (*length < 0) {
mp_verbose(log, "Could not find EOF"); mp_verbose(log, "Could not find EOF");
goto err_out; goto err_out;
} }
if (*length > SIZE_MAX - 1) { if (*length > SIZE_MAX - 1) {
mp_verbose(log, "File too big, could not malloc."); mp_verbose(log, "File too big, could not malloc.");
goto err_out; goto err_out;
} }
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
if (!(buffer = malloc(*length + 1))) { if (!(buffer = malloc(*length + 1))) {
mp_verbose(log, "Could not malloc."); mp_verbose(log, "Could not malloc.");
goto err_out; goto err_out;
} }
if (read(fd, buffer, *length) != *length) { if (read(fd, buffer, *length) != *length) {
mp_verbose(log, "Read is behaving funny."); mp_verbose(log, "Read is behaving funny.");
goto err_out; goto err_out;
} }
close(fd); close(fd);
buffer[*length] = 0; buffer[*length] = 0;
@@ -137,22 +137,22 @@ static struct cookie_list_type *load_cookies_from(void *ctx,
ptr = file = load_file(log, filename, &length); ptr = file = load_file(log, filename, &length);
if (!ptr) if (!ptr)
return NULL; return NULL;
struct cookie_list_type *list = NULL; struct cookie_list_type *list = NULL;
while (*ptr) { while (*ptr) {
char *cols[7]; char *cols[7];
if (parse_line(&ptr, cols)) { if (parse_line(&ptr, cols)) {
struct cookie_list_type *new; struct cookie_list_type *new;
new = talloc_zero(ctx, cookie_list_t); new = talloc_zero(ctx, cookie_list_t);
new->name = col_dup(new, cols[5]); new->name = col_dup(new, cols[5]);
new->value = col_dup(new, cols[6]); new->value = col_dup(new, cols[6]);
new->path = col_dup(new, cols[2]); new->path = col_dup(new, cols[2]);
new->domain = col_dup(new, cols[0]); new->domain = col_dup(new, cols[0]);
new->secure = (*(cols[3]) == 't') || (*(cols[3]) == 'T'); new->secure = (*(cols[3]) == 't') || (*(cols[3]) == 'T');
new->next = list; new->next = list;
list = new; list = new;
} }
} }
free(file); free(file);
return list; return list;

View File

@@ -52,225 +52,225 @@ int dvb_get_tuner_type(int fe_fd, struct mp_log *log)
res = ioctl(fe_fd, FE_GET_INFO, &fe_info); res = ioctl(fe_fd, FE_GET_INFO, &fe_info);
if(res < 0) if(res < 0)
{ {
mp_err(log, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd); mp_err(log, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd);
return 0; return 0;
} }
switch(fe_info.type) switch(fe_info.type)
{ {
case FE_OFDM: case FE_OFDM:
mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-T\n"); mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-T\n");
return TUNER_TER; return TUNER_TER;
case FE_QPSK: case FE_QPSK:
mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-S\n"); mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-S\n");
return TUNER_SAT; return TUNER_SAT;
case FE_QAM: case FE_QAM:
mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-C\n"); mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-C\n");
return TUNER_CBL; return TUNER_CBL;
#ifdef DVB_ATSC #ifdef DVB_ATSC
case FE_ATSC: case FE_ATSC:
mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-ATSC\n"); mp_verbose(log, "TUNER TYPE SEEMS TO BE DVB-ATSC\n");
return TUNER_ATSC; return TUNER_ATSC;
#endif #endif
default: default:
mp_err(log, "UNKNOWN TUNER TYPE\n"); mp_err(log, "UNKNOWN TUNER TYPE\n");
return 0; return 0;
} }
} }
int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt) int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt)
{ {
int i; int i;
char frontend_dev[32], dvr_dev[32], demux_dev[32]; char frontend_dev[32], dvr_dev[32], demux_dev[32];
sprintf(frontend_dev, "/dev/dvb/adapter%d/frontend0", n); sprintf(frontend_dev, "/dev/dvb/adapter%d/frontend0", n);
sprintf(dvr_dev, "/dev/dvb/adapter%d/dvr0", n); sprintf(dvr_dev, "/dev/dvb/adapter%d/dvr0", n);
sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", n); sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", n);
priv->fe_fd = open(frontend_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); priv->fe_fd = open(frontend_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
if(priv->fe_fd < 0) if(priv->fe_fd < 0)
{ {
MP_ERR(priv, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", frontend_dev, errno); MP_ERR(priv, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", frontend_dev, errno);
return 0; return 0;
} }
priv->demux_fds_cnt = 0; priv->demux_fds_cnt = 0;
MP_VERBOSE(priv, "DVB_OPEN_DEVICES(%d)\n", demux_cnt); MP_VERBOSE(priv, "DVB_OPEN_DEVICES(%d)\n", demux_cnt);
for(i = 0; i < demux_cnt; i++) for(i = 0; i < demux_cnt; i++)
{ {
priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
if(priv->demux_fds[i] < 0) if(priv->demux_fds[i] < 0)
{ {
MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno); MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno);
return 0; return 0;
} }
else else
{ {
MP_VERBOSE(priv, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, demux_dev, priv->demux_fds[i], priv->demux_fds_cnt); MP_VERBOSE(priv, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, demux_dev, priv->demux_fds[i], priv->demux_fds_cnt);
priv->demux_fds_cnt++; priv->demux_fds_cnt++;
} }
} }
priv->dvr_fd = open(dvr_dev, O_RDONLY| O_NONBLOCK | O_CLOEXEC); priv->dvr_fd = open(dvr_dev, O_RDONLY| O_NONBLOCK | O_CLOEXEC);
if(priv->dvr_fd < 0) if(priv->dvr_fd < 0)
{ {
MP_ERR(priv, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno); MP_ERR(priv, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno);
return 0; return 0;
} }
return 1; return 1;
} }
int dvb_fix_demuxes(dvb_priv_t *priv, int cnt) int dvb_fix_demuxes(dvb_priv_t *priv, int cnt)
{ {
int i; int i;
char demux_dev[32]; char demux_dev[32];
sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", priv->card); sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", priv->card);
MP_VERBOSE(priv, "FIX %d -> %d\n", priv->demux_fds_cnt, cnt); MP_VERBOSE(priv, "FIX %d -> %d\n", priv->demux_fds_cnt, cnt);
if(priv->demux_fds_cnt >= cnt) if(priv->demux_fds_cnt >= cnt)
{ {
for(i = priv->demux_fds_cnt-1; i >= cnt; i--) for(i = priv->demux_fds_cnt-1; i >= cnt; i--)
{ {
MP_VERBOSE(priv, "FIX, CLOSE fd(%d): %d\n", i, priv->demux_fds[i]); MP_VERBOSE(priv, "FIX, CLOSE fd(%d): %d\n", i, priv->demux_fds[i]);
close(priv->demux_fds[i]); close(priv->demux_fds[i]);
} }
priv->demux_fds_cnt = cnt; priv->demux_fds_cnt = cnt;
} }
else if(priv->demux_fds_cnt < cnt) else if(priv->demux_fds_cnt < cnt)
{ {
for(i = priv->demux_fds_cnt; i < cnt; i++) for(i = priv->demux_fds_cnt; i < cnt; i++)
{ {
priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
MP_VERBOSE(priv, "FIX, OPEN fd(%d): %d\n", i, priv->demux_fds[i]); MP_VERBOSE(priv, "FIX, OPEN fd(%d): %d\n", i, priv->demux_fds[i]);
if(priv->demux_fds[i] < 0) if(priv->demux_fds[i] < 0)
{ {
MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno); MP_ERR(priv, "ERROR OPENING DEMUX 0: %d\n", errno);
return 0; return 0;
} }
else else
priv->demux_fds_cnt++; priv->demux_fds_cnt++;
} }
} }
return 1; return 1;
} }
int dvb_set_ts_filt(dvb_priv_t *priv, int fd, uint16_t pid, dmx_pes_type_t pestype) int dvb_set_ts_filt(dvb_priv_t *priv, int fd, uint16_t pid, dmx_pes_type_t pestype)
{ {
int i; int i;
struct dmx_pes_filter_params pesFilterParams; struct dmx_pes_filter_params pesFilterParams;
pesFilterParams.pid = pid; pesFilterParams.pid = pid;
pesFilterParams.input = DMX_IN_FRONTEND; pesFilterParams.input = DMX_IN_FRONTEND;
pesFilterParams.output = DMX_OUT_TS_TAP; pesFilterParams.output = DMX_OUT_TS_TAP;
pesFilterParams.pes_type = pestype; pesFilterParams.pes_type = pestype;
pesFilterParams.flags = DMX_IMMEDIATE_START; pesFilterParams.flags = DMX_IMMEDIATE_START;
errno = 0; errno = 0;
if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0) if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0)
{ {
MP_ERR(priv, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno); MP_ERR(priv, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno);
return 0; return 0;
} }
MP_VERBOSE(priv, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n", pid, fd, i, errno); MP_VERBOSE(priv, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n", pid, fd, i, errno);
return 1; return 1;
} }
int dvb_demux_stop(int fd) int dvb_demux_stop(int fd)
{ {
int i; int i;
i = ioctl(fd, DMX_STOP); i = ioctl(fd, DMX_STOP);
return i == 0; return i == 0;
} }
int dvb_demux_start(int fd) int dvb_demux_start(int fd)
{ {
int i; int i;
i = ioctl(fd, DMX_START); i = ioctl(fd, DMX_START);
return i == 0; return i == 0;
} }
static void print_status(dvb_priv_t *priv, fe_status_t festatus) static void print_status(dvb_priv_t *priv, fe_status_t festatus)
{ {
MP_VERBOSE(priv, "FE_STATUS:"); MP_VERBOSE(priv, "FE_STATUS:");
if (festatus & FE_HAS_SIGNAL) MP_VERBOSE(priv, " FE_HAS_SIGNAL"); if (festatus & FE_HAS_SIGNAL) MP_VERBOSE(priv, " FE_HAS_SIGNAL");
if (festatus & FE_TIMEDOUT) MP_VERBOSE(priv, " FE_TIMEDOUT"); if (festatus & FE_TIMEDOUT) MP_VERBOSE(priv, " FE_TIMEDOUT");
if (festatus & FE_HAS_LOCK) MP_VERBOSE(priv, " FE_HAS_LOCK"); if (festatus & FE_HAS_LOCK) MP_VERBOSE(priv, " FE_HAS_LOCK");
if (festatus & FE_HAS_CARRIER) MP_VERBOSE(priv, " FE_HAS_CARRIER"); if (festatus & FE_HAS_CARRIER) MP_VERBOSE(priv, " FE_HAS_CARRIER");
if (festatus & FE_HAS_VITERBI) MP_VERBOSE(priv, " FE_HAS_VITERBI"); if (festatus & FE_HAS_VITERBI) MP_VERBOSE(priv, " FE_HAS_VITERBI");
if (festatus & FE_HAS_SYNC) MP_VERBOSE(priv, " FE_HAS_SYNC"); if (festatus & FE_HAS_SYNC) MP_VERBOSE(priv, " FE_HAS_SYNC");
MP_VERBOSE(priv, "\n"); MP_VERBOSE(priv, "\n");
} }
static int check_status(dvb_priv_t *priv, int fd_frontend, int tmout) static int check_status(dvb_priv_t *priv, int fd_frontend, int tmout)
{ {
int32_t strength; int32_t strength;
fe_status_t festatus; fe_status_t festatus;
struct pollfd pfd[1]; struct pollfd pfd[1];
int ok=0, locks=0; int ok=0, locks=0;
time_t tm1, tm2; time_t tm1, tm2;
pfd[0].fd = fd_frontend; pfd[0].fd = fd_frontend;
pfd[0].events = POLLPRI; pfd[0].events = POLLPRI;
MP_VERBOSE(priv, "Getting frontend status\n"); MP_VERBOSE(priv, "Getting frontend status\n");
tm1 = tm2 = time((time_t*) NULL); tm1 = tm2 = time((time_t*) NULL);
while(!ok) while(!ok)
{ {
festatus = 0; festatus = 0;
if(poll(pfd,1,tmout*1000) > 0) if(poll(pfd,1,tmout*1000) > 0)
{ {
if (pfd[0].revents & POLLPRI) if (pfd[0].revents & POLLPRI)
{ {
if(ioctl(fd_frontend, FE_READ_STATUS, &festatus) >= 0) if(ioctl(fd_frontend, FE_READ_STATUS, &festatus) >= 0)
if(festatus & FE_HAS_LOCK) if(festatus & FE_HAS_LOCK)
locks++; locks++;
} }
} }
usleep(10000); usleep(10000);
tm2 = time((time_t*) NULL); tm2 = time((time_t*) NULL);
if((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= tmout)) if((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= tmout))
ok = 1; ok = 1;
} }
if(festatus & FE_HAS_LOCK) if(festatus & FE_HAS_LOCK)
{ {
strength=0; strength=0;
if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0)
MP_VERBOSE(priv, "Bit error rate: %d\n",strength); MP_VERBOSE(priv, "Bit error rate: %d\n",strength);
strength=0; strength=0;
if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0)
MP_VERBOSE(priv, "Signal strength: %d\n",strength); MP_VERBOSE(priv, "Signal strength: %d\n",strength);
strength=0; strength=0;
if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0)
MP_VERBOSE(priv, "SNR: %d\n",strength); MP_VERBOSE(priv, "SNR: %d\n",strength);
strength=0; strength=0;
if(ioctl(fd_frontend,FE_READ_UNCORRECTED_BLOCKS,&strength) >= 0) if(ioctl(fd_frontend,FE_READ_UNCORRECTED_BLOCKS,&strength) >= 0)
MP_VERBOSE(priv, "UNC: %d\n",strength); MP_VERBOSE(priv, "UNC: %d\n",strength);
print_status(priv, festatus); print_status(priv, festatus);
} }
else else
{ {
MP_ERR(priv, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout); MP_ERR(priv, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout);
return -1; return -1;
} }
return 0; return 0;
} }
@@ -280,7 +280,7 @@ struct diseqc_cmd {
}; };
static int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd, static int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd,
fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b) fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
{ {
if(ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) == -1) if(ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) == -1)
return -1; return -1;
@@ -314,14 +314,14 @@ static int do_diseqc(int secfd, int sat_no, int polv, int hi_lo)
0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (polv ? 0 : 2)); 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (polv ? 0 : 2));
return diseqc_send_msg(secfd, polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18, return diseqc_send_msg(secfd, polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18,
&cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF, &cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF,
(sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A); (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A);
} }
static int tune_it(dvb_priv_t *priv, int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, static int tune_it(dvb_priv_t *priv, int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone,
fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate,
fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth,
fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
{ {
int hi_lo = 0, dfd; int hi_lo = 0, dfd;
struct dvb_frontend_parameters feparams; struct dvb_frontend_parameters feparams;
@@ -423,18 +423,18 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, int fd_sec, unsigned int f
int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone,
fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval,
fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate,
fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
{ {
int ris; int ris;
MP_INFO(priv, "dvb_tune Freq: %lu\n", (long unsigned int) freq); MP_INFO(priv, "dvb_tune Freq: %lu\n", (long unsigned int) freq);
ris = tune_it(priv, priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth, LP_CodeRate, hier, timeout); ris = tune_it(priv, priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth, LP_CodeRate, hier, timeout);
if(ris != 0) if(ris != 0)
MP_INFO(priv, "dvb_tune, TUNING FAILED\n"); MP_INFO(priv, "dvb_tune, TUNING FAILED\n");
return ris == 0; return ris == 0;
} }

View File

@@ -43,54 +43,54 @@
#endif #endif
typedef struct { typedef struct {
char *name; char *name;
int freq, srate, diseqc, tone; int freq, srate, diseqc, tone;
char pol; char pol;
int tpid, dpid1, dpid2, progid, ca, pids[DMX_FILTER_SIZE], pids_cnt; int tpid, dpid1, dpid2, progid, ca, pids[DMX_FILTER_SIZE], pids_cnt;
fe_spectral_inversion_t inv; fe_spectral_inversion_t inv;
fe_modulation_t mod; fe_modulation_t mod;
fe_transmit_mode_t trans; fe_transmit_mode_t trans;
fe_bandwidth_t bw; fe_bandwidth_t bw;
fe_guard_interval_t gi; fe_guard_interval_t gi;
fe_code_rate_t cr, cr_lp; fe_code_rate_t cr, cr_lp;
fe_hierarchy_t hier; fe_hierarchy_t hier;
} dvb_channel_t; } dvb_channel_t;
typedef struct { typedef struct {
uint16_t NUM_CHANNELS; uint16_t NUM_CHANNELS;
uint16_t current; uint16_t current;
dvb_channel_t *channels; dvb_channel_t *channels;
} dvb_channels_list; } dvb_channels_list;
typedef struct { typedef struct {
int type; int type;
dvb_channels_list *list; dvb_channels_list *list;
char *name; char *name;
int devno; int devno;
} dvb_card_config_t; } dvb_card_config_t;
typedef struct { typedef struct {
int count; int count;
dvb_card_config_t *cards; dvb_card_config_t *cards;
void *priv; void *priv;
} dvb_config_t; } dvb_config_t;
typedef struct { typedef struct {
struct mp_log *log; struct mp_log *log;
int fd; int fd;
int card; int card;
int fe_fd; int fe_fd;
int sec_fd; int sec_fd;
int demux_fd[3], demux_fds[DMX_FILTER_SIZE], demux_fds_cnt; int demux_fd[3], demux_fds[DMX_FILTER_SIZE], demux_fds_cnt;
int dvr_fd; int dvr_fd;
dvb_config_t *config; dvb_config_t *config;
dvb_channels_list *list; dvb_channels_list *list;
int tuner_type; int tuner_type;
int is_on; int is_on;
int retry; int retry;
int timeout; int timeout;
int last_freq; int last_freq;
char *cfg_prog; char *cfg_prog;
int cfg_card; int cfg_card;
@@ -98,10 +98,10 @@ typedef struct {
} dvb_priv_t; } dvb_priv_t;
#define TUNER_SAT 1 #define TUNER_SAT 1
#define TUNER_TER 2 #define TUNER_TER 2
#define TUNER_CBL 3 #define TUNER_CBL 3
#define TUNER_ATSC 4 #define TUNER_ATSC 4
int dvb_step_channel(stream_t *, int); int dvb_step_channel(stream_t *, int);
int dvb_set_channel(stream_t *, int, int); int dvb_set_channel(stream_t *, int, int);

View File

File diff suppressed because it is too large Load Diff

View File

@@ -25,13 +25,13 @@
#ifndef MPLAYER_FREQUENCIES_H #ifndef MPLAYER_FREQUENCIES_H
#define MPLAYER_FREQUENCIES_H #define MPLAYER_FREQUENCIES_H
#define NTSC_AUDIO_CARRIER 4500 #define NTSC_AUDIO_CARRIER 4500
#define PAL_AUDIO_CARRIER_I 6000 #define PAL_AUDIO_CARRIER_I 6000
#define PAL_AUDIO_CARRIER_BGHN 5500 #define PAL_AUDIO_CARRIER_BGHN 5500
#define PAL_AUDIO_CARRIER_MN 4500 #define PAL_AUDIO_CARRIER_MN 4500
#define PAL_AUDIO_CARRIER_D 6500 #define PAL_AUDIO_CARRIER_D 6500
#define SEACAM_AUDIO_DKK1L 6500 #define SEACAM_AUDIO_DKK1L 6500
#define SEACAM_AUDIO_BG 5500 #define SEACAM_AUDIO_BG 5500
/* NICAM 728 32-kHz, 14-bit digital stereo audio is transmitted in 1ms frames /* NICAM 728 32-kHz, 14-bit digital stereo audio is transmitted in 1ms frames
containing 8 bits frame sync, 5 bits control, 11 bits additional data, and containing 8 bits frame sync, 5 bits control, 11 bits additional data, and
704 bits audio data. The bit rate is reduced by transmitting only 10 bits 704 bits audio data. The bit rate is reduced by transmitting only 10 bits
@@ -41,69 +41,69 @@
companeded audio data is interleaved to reduce the influence of dropouts companeded audio data is interleaved to reduce the influence of dropouts
and the whole frame except for sync bits is scrambled for spectrum shaping. and the whole frame except for sync bits is scrambled for spectrum shaping.
Data is modulated using QPSK, at below following subcarrier freqs */ Data is modulated using QPSK, at below following subcarrier freqs */
#define NICAM728_PAL_BGH 5850 #define NICAM728_PAL_BGH 5850
#define NICAM728_PAL_I 6552 #define NICAM728_PAL_I 6552
/* COMPREHENSIVE LIST OF FORMAT BY COUNTRY /* COMPREHENSIVE LIST OF FORMAT BY COUNTRY
(M) NTSC used in: (M) NTSC used in:
Antigua, Aruba, Bahamas, Barbados, Belize, Bermuda, Bolivia, Burma, Antigua, Aruba, Bahamas, Barbados, Belize, Bermuda, Bolivia, Burma,
Canada, Chile, Colombia, Costa Rica, Cuba, Curacao, Dominican Republic, Canada, Chile, Colombia, Costa Rica, Cuba, Curacao, Dominican Republic,
Ecuador, El Salvador, Guam Guatemala, Honduras, Jamaica, Japan, Ecuador, El Salvador, Guam Guatemala, Honduras, Jamaica, Japan,
South Korea, Mexico, Montserrat, Myanmar, Nicaragua, Panama, Peru, South Korea, Mexico, Montserrat, Myanmar, Nicaragua, Panama, Peru,
Philippines, Puerto Rico, St Christopher and Nevis, Samoa, Suriname, Philippines, Puerto Rico, St Christopher and Nevis, Samoa, Suriname,
Taiwan, Trinidad/Tobago, United States, Venezuela, Virgin Islands Taiwan, Trinidad/Tobago, United States, Venezuela, Virgin Islands
(B) PAL used in: (B) PAL used in:
Albania, Algeria, Australia, Austria, Bahrain, Bangladesh, Belgium, Albania, Algeria, Australia, Austria, Bahrain, Bangladesh, Belgium,
Bosnia-Herzegovinia, Brunei Darussalam, Cambodia, Cameroon, Croatia, Bosnia-Herzegovinia, Brunei Darussalam, Cambodia, Cameroon, Croatia,
Cyprus, Denmark, Egypt, Ethiopia, Equatorial Guinea, Finland, Germany, Cyprus, Denmark, Egypt, Ethiopia, Equatorial Guinea, Finland, Germany,
Ghana, Gibraltar, Greenland, Iceland, India, Indonesia, Israel, Italy, Ghana, Gibraltar, Greenland, Iceland, India, Indonesia, Israel, Italy,
Jordan, Kenya, Kuwait, Liberia, Libya, Luxembourg, Malaysa, Maldives, Jordan, Kenya, Kuwait, Liberia, Libya, Luxembourg, Malaysa, Maldives,
Malta, Nepal, Netherlands, New Zeland, Nigeria, Norway, Oman, Pakistan, Malta, Nepal, Netherlands, New Zeland, Nigeria, Norway, Oman, Pakistan,
Papua New Guinea, Portugal, Qatar, Sao Tome and Principe, Saudi Arabia, Papua New Guinea, Portugal, Qatar, Sao Tome and Principe, Saudi Arabia,
Seychelles, Sierra Leone, Singapore, Slovenia, Somali, Spain, Seychelles, Sierra Leone, Singapore, Slovenia, Somali, Spain,
Sri Lanka, Sudan, Swaziland, Sweden, Switzeland, Syria, Thailand, Sri Lanka, Sudan, Swaziland, Sweden, Switzeland, Syria, Thailand,
Tunisia, Turkey, Uganda, United Arab Emirates, Yemen Tunisia, Turkey, Uganda, United Arab Emirates, Yemen
(N) PAL used in: (Combination N = 4.5MHz audio carrier, 3.58MHz burst) (N) PAL used in: (Combination N = 4.5MHz audio carrier, 3.58MHz burst)
Argentina (Combination N), Paraguay, Uruguay Argentina (Combination N), Paraguay, Uruguay
(M) PAL (525/60, 3.57MHz burst) used in: (M) PAL (525/60, 3.57MHz burst) used in:
Brazil Brazil
(G) PAL used in: (G) PAL used in:
Albania, Algeria, Austria, Bahrain, Bosnia/Herzegovinia, Cambodia, Albania, Algeria, Austria, Bahrain, Bosnia/Herzegovinia, Cambodia,
Cameroon, Croatia, Cyprus, Denmark, Egypt, Ethiopia, Equatorial Guinea, Cameroon, Croatia, Cyprus, Denmark, Egypt, Ethiopia, Equatorial Guinea,
Finland, Germany, Gibraltar, Greenland, Iceland, Israel, Italy, Jordan, Finland, Germany, Gibraltar, Greenland, Iceland, Israel, Italy, Jordan,
Kenya, Kuwait, Liberia, Libya, Luxembourg, Malaysia, Monaco, Kenya, Kuwait, Liberia, Libya, Luxembourg, Malaysia, Monaco,
Mozambique, Netherlands, New Zealand, Norway, Oman, Pakistan, Mozambique, Netherlands, New Zealand, Norway, Oman, Pakistan,
Papa New Guinea, Portugal, Qatar, Romania, Sierra Leone, Singapore, Papa New Guinea, Portugal, Qatar, Romania, Sierra Leone, Singapore,
Slovenia, Somalia, Spain, Sri Lanka, Sudan, Swaziland, Sweeden, Slovenia, Somalia, Spain, Sri Lanka, Sudan, Swaziland, Sweeden,
Switzerland, Syria, Thailand, Tunisia, Turkey, United Arab Emirates, Switzerland, Syria, Thailand, Tunisia, Turkey, United Arab Emirates,
Yemen, Zambia, Zimbabwe Yemen, Zambia, Zimbabwe
(D) PAL used in: (D) PAL used in:
China, North Korea, Romania, Czech Republic China, North Korea, Romania, Czech Republic
(H) PAL used in: (H) PAL used in:
Belgium Belgium
(I) PAL used in: (I) PAL used in:
Angola, Botswana, Gambia, Guinea-Bissau, Hong Kong, Ireland, Lesotho, Angola, Botswana, Gambia, Guinea-Bissau, Hong Kong, Ireland, Lesotho,
Malawi, Nambia, Nigeria, South Africa, Tanzania, United Kingdom, Malawi, Nambia, Nigeria, South Africa, Tanzania, United Kingdom,
Zanzibar Zanzibar
(B) SECAM used in: (B) SECAM used in:
Djibouti, Greece, Iran, Iraq, Lebanon, Mali, Mauritania, Mauritus, Djibouti, Greece, Iran, Iraq, Lebanon, Mali, Mauritania, Mauritus,
Morocco Morocco
(D) SECAM used in: (D) SECAM used in:
Afghanistan, Armenia, Azerbaijan, Belarus, Bulgaria, Afghanistan, Armenia, Azerbaijan, Belarus, Bulgaria,
Estonia, Georgia, Hungary, Zazakhstan, Lithuania, Mongolia, Moldova, Estonia, Georgia, Hungary, Zazakhstan, Lithuania, Mongolia, Moldova,
Russia, Slovak Republic, Ukraine, Vietnam Russia, Slovak Republic, Ukraine, Vietnam
(G) SECAM used in: (G) SECAM used in:
Greecem Iran, Iraq, Mali, Mauritus, Morocco, Saudi Arabia Greecem Iran, Iraq, Mali, Mauritus, Morocco, Saudi Arabia
(K) SECAM used in: (K) SECAM used in:
Armenia, Azerbaijan, Bulgaria, Estonia, Georgia, Armenia, Azerbaijan, Bulgaria, Estonia, Georgia,
Hungary, Kazakhstan, Lithuania, Madagascar, Moldova, Poland, Russia, Hungary, Kazakhstan, Lithuania, Madagascar, Moldova, Poland, Russia,
Slovak Republic, Ukraine, Vietnam Slovak Republic, Ukraine, Vietnam
(K1) SECAM used in: (K1) SECAM used in:
Benin, Burkina Faso, Burundi, Chad, Cape Verde, Central African Benin, Burkina Faso, Burundi, Chad, Cape Verde, Central African
Republic, Comoros, Congo, Gabon, Madagascar, Niger, Rwanda, Senegal, Republic, Comoros, Congo, Gabon, Madagascar, Niger, Rwanda, Senegal,
Togo, Zaire Togo, Zaire
(L) SECAM used in: (L) SECAM used in:
France France
*/ */
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */

View File

File diff suppressed because it is too large Load Diff

View File

@@ -47,7 +47,7 @@
static char* dvd_device_current; static char* dvd_device_current;
int dvd_angle=1; int dvd_angle=1;
#define LIBDVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) #define LIBDVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro))
/* /*
* Try to autodetect the libdvd-0.9.0 library * Try to autodetect the libdvd-0.9.0 library
* (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines * (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines
@@ -56,9 +56,9 @@ int dvd_angle=1;
*/ */
#ifndef DVDREAD_VERSION #ifndef DVDREAD_VERSION
#if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN) #if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN)
#define DVDREAD_VERSION LIBDVDREAD_VERSION(0,9,0) #define DVDREAD_VERSION LIBDVDREAD_VERSION(0,9,0)
#else #else
#define DVDREAD_VERSION LIBDVDREAD_VERSION(0,8,0) #define DVDREAD_VERSION LIBDVDREAD_VERSION(0,8,0)
#endif #endif
#endif #endif
@@ -266,7 +266,7 @@ read_next:
if(d->angle_seek) { if(d->angle_seek) {
int i,skip=0; int i,skip=0;
for(i=0;i<9;i++) // check if all values zero: for(i=0;i<9;i++) // check if all values zero:
if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break; if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break;
if(skip && skip!=0x7fffffff) { if(skip && skip!=0x7fffffff) {
// sml_agli table has valid data (at least one non-zero): // sml_agli table has valid data (at least one non-zero):

View File

@@ -633,7 +633,7 @@ int radio_get_freq(struct stream *stream, float *frequency){
radio_priv_t* priv=(radio_priv_t*)stream->priv; radio_priv_t* priv=(radio_priv_t*)stream->priv;
if (!frequency) if (!frequency)
return 0; return 0;
if (get_frequency(priv,frequency)!=STREAM_OK){ if (get_frequency(priv,frequency)!=STREAM_OK){
return 0; return 0;
} }

View File

@@ -33,7 +33,7 @@ struct priv {
static void smb_auth_fn(const char *server, const char *share, static void smb_auth_fn(const char *server, const char *share,
char *workgroup, int wgmaxlen, char *username, int unmaxlen, char *workgroup, int wgmaxlen, char *username, int unmaxlen,
char *password, int pwmaxlen) char *password, int pwmaxlen)
{ {
strncpy(workgroup, "LAN", wgmaxlen - 1); strncpy(workgroup, "LAN", wgmaxlen - 1);
} }

View File

@@ -111,7 +111,7 @@ static int open_s(stream_t *stream,int mode)
device[4] = dev ? dev[0] : 0; device[4] = dev ? dev[0] : 0;
/* open() can't be used for devices so do it the complicated way */ /* open() can't be used for devices so do it the complicated way */
hd = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL, hd = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
f = _open_osfhandle((intptr_t)hd, _O_RDONLY); f = _open_osfhandle((intptr_t)hd, _O_RDONLY);
#else #else
f=open(dev,O_RDONLY | O_CLOEXEC); f=open(dev,O_RDONLY | O_CLOEXEC);

View File

@@ -249,12 +249,12 @@ static int demux_tv_fill_buffer(demuxer_t *demux)
if (want_video && tvh->functions->control(tvh->priv, if (want_video && tvh->functions->control(tvh->priv,
TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE) TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE)
{ {
len = tvh->functions->get_video_framesize(tvh->priv); len = tvh->functions->get_video_framesize(tvh->priv);
dp=new_demux_packet(len); dp=new_demux_packet(len);
dp->keyframe = true; dp->keyframe = true;
dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len); dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len);
demuxer_add_packet(demux, want_video, dp); demuxer_add_packet(demux, want_video, dp);
} }
if (tvh->tv_param->scan) tv_scan(tvh); if (tvh->tv_param->scan) tv_scan(tvh);
return 1; return 1;
@@ -387,8 +387,8 @@ int tv_set_norm(tvi_handle_t *tvh, char* norm)
MP_VERBOSE(tvh, "Selected norm : %s\n", norm); MP_VERBOSE(tvh, "Selected norm : %s\n", norm);
if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) { if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
MP_ERR(tvh, "Error: Cannot set norm!\n"); MP_ERR(tvh, "Error: Cannot set norm!\n");
return 0; return 0;
} }
return 1; return 1;
} }
@@ -431,8 +431,8 @@ static int open_tv(tvi_handle_t *tvh)
if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE) if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
{ {
MP_ERR(tvh, "Error: No video input present!\n"); MP_ERR(tvh, "Error: No video input present!\n");
return 0; return 0;
} }
if (tvh->tv_param->outfmt == -1) if (tvh->tv_param->outfmt == -1)
@@ -447,25 +447,25 @@ static int open_tv(tvi_handle_t *tvh)
{ {
switch(tvh->tv_param->outfmt) switch(tvh->tv_param->outfmt)
{ {
case MP_FOURCC_YV12: case MP_FOURCC_YV12:
case MP_FOURCC_I420: case MP_FOURCC_I420:
case MP_FOURCC_UYVY: case MP_FOURCC_UYVY:
case MP_FOURCC_YUY2: case MP_FOURCC_YUY2:
case MP_FOURCC_RGB32: case MP_FOURCC_RGB32:
case MP_FOURCC_RGB24: case MP_FOURCC_RGB24:
case MP_FOURCC_BGR32: case MP_FOURCC_BGR32:
case MP_FOURCC_BGR24: case MP_FOURCC_BGR24:
case MP_FOURCC_BGR16: case MP_FOURCC_BGR16:
case MP_FOURCC_BGR15: case MP_FOURCC_BGR15:
break; break;
default: default:
MP_ERR(tvh, "==================================================================\n"\ MP_ERR(tvh, "==================================================================\n"\
" WARNING: UNTESTED OR UNKNOWN OUTPUT IMAGE FORMAT REQUESTED (0x%x)\n"\ " WARNING: UNTESTED OR UNKNOWN OUTPUT IMAGE FORMAT REQUESTED (0x%x)\n"\
" This may cause buggy playback or program crash! Bug reports will\n"\ " This may cause buggy playback or program crash! Bug reports will\n"\
" be ignored! You should try again with YV12 (which is the default\n"\ " be ignored! You should try again with YV12 (which is the default\n"\
" colorspace) and read the documentation!\n"\ " colorspace) and read the documentation!\n"\
"==================================================================\n" "==================================================================\n"
,tvh->tv_param->outfmt); ,tvh->tv_param->outfmt);
} }
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &tvh->tv_param->outfmt); funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &tvh->tv_param->outfmt);
} }
@@ -488,155 +488,155 @@ static int open_tv(tvi_handle_t *tvh)
/* set width */ /* set width */
if (tvh->tv_param->width != -1) if (tvh->tv_param->width != -1)
{ {
if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_WIDTH, &tvh->tv_param->width) == TVI_CONTROL_TRUE) if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_WIDTH, &tvh->tv_param->width) == TVI_CONTROL_TRUE)
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tvh->tv_param->width); funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tvh->tv_param->width);
else else
{ {
MP_ERR(tvh, "Unable to set requested width: %d\n", tvh->tv_param->width); MP_ERR(tvh, "Unable to set requested width: %d\n", tvh->tv_param->width);
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tvh->tv_param->width); funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tvh->tv_param->width);
} }
} }
/* set height */ /* set height */
if (tvh->tv_param->height != -1) if (tvh->tv_param->height != -1)
{ {
if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_HEIGHT, &tvh->tv_param->height) == TVI_CONTROL_TRUE) if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_HEIGHT, &tvh->tv_param->height) == TVI_CONTROL_TRUE)
funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tvh->tv_param->height); funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tvh->tv_param->height);
else else
{ {
MP_ERR(tvh, "Unable to set requested height: %d\n", tvh->tv_param->height); MP_ERR(tvh, "Unable to set requested height: %d\n", tvh->tv_param->height);
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tvh->tv_param->height); funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tvh->tv_param->height);
} }
} }
if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE) if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
{ {
MP_WARN(tvh, "Selected input hasn't got a tuner!\n"); MP_WARN(tvh, "Selected input hasn't got a tuner!\n");
goto done; goto done;
} }
/* select channel list */ /* select channel list */
for (i = 0; chanlists[i].name != NULL; i++) for (i = 0; chanlists[i].name != NULL; i++)
{ {
if (!strcasecmp(chanlists[i].name, tvh->tv_param->chanlist)) if (!strcasecmp(chanlists[i].name, tvh->tv_param->chanlist))
{ {
tvh->chanlist = i; tvh->chanlist = i;
tvh->chanlist_s = chanlists[i].list; tvh->chanlist_s = chanlists[i].list;
break; break;
} }
} }
if (tvh->chanlist == -1) { if (tvh->chanlist == -1) {
MP_WARN(tvh, "Unable to find selected channel list! (%s)\n", MP_WARN(tvh, "Unable to find selected channel list! (%s)\n",
tvh->tv_param->chanlist); tvh->tv_param->chanlist);
return 0; return 0;
} else } else
MP_VERBOSE(tvh, "Selected channel list: %s (including %d channels)\n", MP_VERBOSE(tvh, "Selected channel list: %s (including %d channels)\n",
chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count); chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
if (tvh->tv_param->freq && tvh->tv_param->channel) if (tvh->tv_param->freq && tvh->tv_param->channel)
{ {
MP_WARN(tvh, "You can't set frequency and channel simultaneously!\n"); MP_WARN(tvh, "You can't set frequency and channel simultaneously!\n");
goto done; goto done;
} }
/* Handle channel names */ /* Handle channel names */
if (tvh->tv_param->channels) { if (tvh->tv_param->channels) {
parse_channels(tvh); parse_channels(tvh);
} else } else
tv_channel_last_real = malloc(5); tv_channel_last_real = malloc(5);
if (tv_channel_list) { if (tv_channel_list) {
int channel = 0; int channel = 0;
if (tvh->tv_param->channel) if (tvh->tv_param->channel)
{ {
if (isdigit(*tvh->tv_param->channel)) if (isdigit(*tvh->tv_param->channel))
/* if tvh->tv_param->channel begins with a digit interpret it as a number */ /* if tvh->tv_param->channel begins with a digit interpret it as a number */
channel = atoi(tvh->tv_param->channel); channel = atoi(tvh->tv_param->channel);
else else
{ {
/* if tvh->tv_param->channel does not begin with a digit /* if tvh->tv_param->channel does not begin with a digit
set the first channel that contains tvh->tv_param->channel in its name */ set the first channel that contains tvh->tv_param->channel in its name */
tv_channel_current = tv_channel_list; tv_channel_current = tv_channel_list;
while ( tv_channel_current ) { while ( tv_channel_current ) {
if ( strstr(tv_channel_current->name, tvh->tv_param->channel) ) if ( strstr(tv_channel_current->name, tvh->tv_param->channel) )
break; break;
tv_channel_current = tv_channel_current->next; tv_channel_current = tv_channel_current->next;
} }
if ( !tv_channel_current ) tv_channel_current = tv_channel_list; if ( !tv_channel_current ) tv_channel_current = tv_channel_list;
} }
} }
else else
channel = 1; channel = 1;
if ( channel ) { if ( channel ) {
tv_channel_current = tv_channel_list; tv_channel_current = tv_channel_list;
for (int n = 1; n < channel; n++) for (int n = 1; n < channel; n++)
if (tv_channel_current->next) if (tv_channel_current->next)
tv_channel_current = tv_channel_current->next; tv_channel_current = tv_channel_current->next;
} }
set_norm_and_freq(tvh, tv_channel_current); set_norm_and_freq(tvh, tv_channel_current);
tv_channel_last = tv_channel_current; tv_channel_last = tv_channel_current;
} else { } else {
/* we need to set frequency */ /* we need to set frequency */
if (tvh->tv_param->freq) if (tvh->tv_param->freq)
{ {
unsigned long freq = atof(tvh->tv_param->freq)*16; unsigned long freq = atof(tvh->tv_param->freq)*16;
/* set freq in MHz */ /* set freq in MHz */
funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq); funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
MP_VERBOSE(tvh, "Selected frequency: %lu (%.3f)\n", MP_VERBOSE(tvh, "Selected frequency: %lu (%.3f)\n",
freq, freq/16.0); freq, freq/16.0);
} }
if (tvh->tv_param->channel) { if (tvh->tv_param->channel) {
struct CHANLIST cl; struct CHANLIST cl;
MP_VERBOSE(tvh, "Requested channel: %s\n", tvh->tv_param->channel); MP_VERBOSE(tvh, "Requested channel: %s\n", tvh->tv_param->channel);
for (i = 0; i < chanlists[tvh->chanlist].count; i++) for (i = 0; i < chanlists[tvh->chanlist].count; i++)
{ {
cl = tvh->chanlist_s[i]; cl = tvh->chanlist_s[i];
// printf("count%d: name: %s, freq: %d\n", // printf("count%d: name: %s, freq: %d\n",
// i, cl.name, cl.freq); // i, cl.name, cl.freq);
if (!strcasecmp(cl.name, tvh->tv_param->channel)) if (!strcasecmp(cl.name, tvh->tv_param->channel))
{ {
strcpy(tv_channel_last_real, cl.name); strcpy(tv_channel_last_real, cl.name);
tvh->channel = i; tvh->channel = i;
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n", MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0); cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq); tv_set_freq_float(tvh, cl.freq);
break; break;
} }
} }
} }
} }
/* grep frequency in chanlist */ /* grep frequency in chanlist */
{ {
unsigned long i2; unsigned long i2;
int freq; int freq;
tv_get_freq(tvh, &i2); tv_get_freq(tvh, &i2);
freq = (int) (((float)(i2/16))*1000)+250; freq = (int) (((float)(i2/16))*1000)+250;
for (i = 0; i < chanlists[tvh->chanlist].count; i++) for (i = 0; i < chanlists[tvh->chanlist].count; i++)
{ {
if (tvh->chanlist_s[i].freq == freq) if (tvh->chanlist_s[i].freq == freq)
{ {
tvh->channel = i+1; tvh->channel = i+1;
break; break;
} }
} }
} }
done: done:
/* also start device! */ /* also start device! */
return 1; return 1;
} }
static tvi_handle_t *tv_begin(tv_param_t* tv_param, struct mp_log *log) static tvi_handle_t *tv_begin(tv_param_t* tv_param, struct mp_log *log)
@@ -646,12 +646,12 @@ static tvi_handle_t *tv_begin(tv_param_t* tv_param, struct mp_log *log)
if(tv_param->driver && !strcmp(tv_param->driver,"help")){ if(tv_param->driver && !strcmp(tv_param->driver,"help")){
mp_info(log, "Available drivers:\n"); mp_info(log, "Available drivers:\n");
for(i=0;tvi_driver_list[i];i++){ for(i=0;tvi_driver_list[i];i++){
mp_info(log, " %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name); mp_info(log, " %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name);
if(tvi_driver_list[i]->comment) if(tvi_driver_list[i]->comment)
mp_info(log, " (%s)",tvi_driver_list[i]->comment); mp_info(log, " (%s)",tvi_driver_list[i]->comment);
mp_info(log, "\n"); mp_info(log, "\n");
} }
return NULL; return NULL;
} }
for(i=0;tvi_driver_list[i];i++){ for(i=0;tvi_driver_list[i];i++){
@@ -711,8 +711,8 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
tvh->demuxer = demuxer; tvh->demuxer = demuxer;
if (!open_tv(tvh)){ if (!open_tv(tvh)){
tv_uninit(tvh); tv_uninit(tvh);
return -1; return -1;
} }
funcs = tvh->functions; funcs = tvh->functions;
demuxer->priv=tvh; demuxer->priv=tvh;
@@ -761,71 +761,71 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
/* here comes audio init */ /* here comes audio init */
if (tvh->tv_param->noaudio == 0 && funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE) if (tvh->tv_param->noaudio == 0 && funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
{ {
int audio_format; int audio_format;
/* yeah, audio is present */ /* yeah, audio is present */
funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE, funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE,
&tvh->tv_param->audiorate); &tvh->tv_param->audiorate);
if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE) if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE)
goto no_audio; goto no_audio;
switch(audio_format) switch(audio_format)
{ {
case AF_FORMAT_U8: case AF_FORMAT_U8:
case AF_FORMAT_S8: case AF_FORMAT_S8:
case AF_FORMAT_U16_LE: case AF_FORMAT_U16_LE:
case AF_FORMAT_U16_BE: case AF_FORMAT_U16_BE:
case AF_FORMAT_S16_LE: case AF_FORMAT_S16_LE:
case AF_FORMAT_S16_BE: case AF_FORMAT_S16_BE:
case AF_FORMAT_S32_LE: case AF_FORMAT_S32_LE:
case AF_FORMAT_S32_BE: case AF_FORMAT_S32_BE:
break; break;
case AF_FORMAT_MPEG2: case AF_FORMAT_MPEG2:
default: default:
MP_ERR(tvh, "Audio type '%s' unsupported!\n", MP_ERR(tvh, "Audio type '%s' unsupported!\n",
af_fmt_to_str(audio_format)); af_fmt_to_str(audio_format));
goto no_audio; goto no_audio;
} }
struct sh_stream *sh_a = new_sh_stream(demuxer, STREAM_AUDIO); struct sh_stream *sh_a = new_sh_stream(demuxer, STREAM_AUDIO);
sh_audio = sh_a->audio; sh_audio = sh_a->audio;
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE, funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
&sh_audio->samplerate); &sh_audio->samplerate);
int nchannels = sh_audio->channels.num; int nchannels = sh_audio->channels.num;
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS, funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
&nchannels); &nchannels);
mp_chmap_from_channels(&sh_audio->channels, nchannels); mp_chmap_from_channels(&sh_audio->channels, nchannels);
sh_a->codec = "mp-pcm"; sh_a->codec = "mp-pcm";
sh_a->format = audio_format; sh_a->format = audio_format;
int samplesize = af_fmt2bits(audio_format) / 8; int samplesize = af_fmt2bits(audio_format) / 8;
sh_audio->i_bps = sh_audio->i_bps =
sh_audio->samplerate * samplesize * sh_audio->channels.num; sh_audio->samplerate * samplesize * sh_audio->channels.num;
// emulate WF for win32 codecs: // emulate WF for win32 codecs:
sh_audio->wf = talloc_zero(sh_audio, MP_WAVEFORMATEX); sh_audio->wf = talloc_zero(sh_audio, MP_WAVEFORMATEX);
sh_audio->wf->wFormatTag = sh_a->format; sh_audio->wf->wFormatTag = sh_a->format;
sh_audio->wf->nChannels = sh_audio->channels.num; sh_audio->wf->nChannels = sh_audio->channels.num;
sh_audio->wf->wBitsPerSample = samplesize * 8; sh_audio->wf->wBitsPerSample = samplesize * 8;
sh_audio->wf->nSamplesPerSec = sh_audio->samplerate; sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
sh_audio->wf->nBlockAlign = samplesize * sh_audio->channels.num; sh_audio->wf->nBlockAlign = samplesize * sh_audio->channels.num;
sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps; sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;
MP_VERBOSE(tvh, " TV audio: %d channels, %d bits, %d Hz\n", MP_VERBOSE(tvh, " TV audio: %d channels, %d bits, %d Hz\n",
sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample, sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,
sh_audio->wf->nSamplesPerSec); sh_audio->wf->nSamplesPerSec);
} }
no_audio: no_audio:
if(!(funcs->start(tvh->priv))){ if(!(funcs->start(tvh->priv))){
// start failed :( // start failed :(
tv_uninit(tvh); tv_uninit(tvh);
return -1; return -1;
} }
/* set color eq */ /* set color eq */
@@ -856,16 +856,16 @@ int tv_set_color_options(tvi_handle_t *tvh, int opt, int value)
switch(opt) switch(opt)
{ {
case TV_COLOR_BRIGHTNESS: case TV_COLOR_BRIGHTNESS:
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value); return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value);
case TV_COLOR_HUE: case TV_COLOR_HUE:
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value); return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value);
case TV_COLOR_SATURATION: case TV_COLOR_SATURATION:
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value); return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value);
case TV_COLOR_CONTRAST: case TV_COLOR_CONTRAST:
return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value); return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
default: default:
MP_WARN(tvh, "Unknown color option (%d) specified!\n", opt); MP_WARN(tvh, "Unknown color option (%d) specified!\n", opt);
} }
return TVI_CONTROL_UNKNOWN; return TVI_CONTROL_UNKNOWN;
@@ -877,16 +877,16 @@ int tv_get_color_options(tvi_handle_t *tvh, int opt, int* value)
switch(opt) switch(opt)
{ {
case TV_COLOR_BRIGHTNESS: case TV_COLOR_BRIGHTNESS:
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_BRIGHTNESS, value); return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_BRIGHTNESS, value);
case TV_COLOR_HUE: case TV_COLOR_HUE:
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HUE, value); return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HUE, value);
case TV_COLOR_SATURATION: case TV_COLOR_SATURATION:
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_SATURATION, value); return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_SATURATION, value);
case TV_COLOR_CONTRAST: case TV_COLOR_CONTRAST:
return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_CONTRAST, value); return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_CONTRAST, value);
default: default:
MP_WARN(tvh, "Unknown color option (%d) specified!\n", opt); MP_WARN(tvh, "Unknown color option (%d) specified!\n", opt);
} }
return TVI_CONTROL_UNKNOWN; return TVI_CONTROL_UNKNOWN;
@@ -896,9 +896,9 @@ int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq)
{ {
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE) if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
{ {
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq); tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);
MP_VERBOSE(tvh, "Current frequency: %lu (%.3f)\n", MP_VERBOSE(tvh, "Current frequency: %lu (%.3f)\n",
*freq, *freq/16.0); *freq, *freq/16.0);
} }
return 1; return 1;
} }
@@ -907,14 +907,14 @@ int tv_set_freq(tvi_handle_t *tvh, unsigned long freq)
{ {
if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE) if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
{ {
// unsigned long freq = atof(tvh->tv_param->freq)*16; // unsigned long freq = atof(tvh->tv_param->freq)*16;
/* set freq in MHz */ /* set freq in MHz */
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq); tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
MP_VERBOSE(tvh, "Current frequency: %lu (%.3f)\n", MP_VERBOSE(tvh, "Current frequency: %lu (%.3f)\n",
freq, freq/16.0); freq, freq/16.0);
} }
return 1; return 1;
} }
@@ -952,123 +952,123 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction)
tvh->tv_param->scan=0; tvh->tv_param->scan=0;
if (direction == TV_CHANNEL_LOWER) if (direction == TV_CHANNEL_LOWER)
{ {
if (tvh->channel-1 >= 0) if (tvh->channel-1 >= 0)
{ {
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name); strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
cl = tvh->chanlist_s[--tvh->channel]; cl = tvh->chanlist_s[--tvh->channel];
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n", MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0); cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq); tv_set_freq_float(tvh, cl.freq);
} }
} }
if (direction == TV_CHANNEL_HIGHER) if (direction == TV_CHANNEL_HIGHER)
{ {
if (tvh->channel+1 < chanlists[tvh->chanlist].count) if (tvh->channel+1 < chanlists[tvh->chanlist].count)
{ {
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name); strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
cl = tvh->chanlist_s[++tvh->channel]; cl = tvh->chanlist_s[++tvh->channel];
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n", MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0); cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq); tv_set_freq_float(tvh, cl.freq);
} }
} }
return 1; return 1;
} }
int tv_step_channel(tvi_handle_t *tvh, int direction) { int tv_step_channel(tvi_handle_t *tvh, int direction) {
tvh->tv_param->scan=0; tvh->tv_param->scan=0;
if (tv_channel_list) { if (tv_channel_list) {
if (direction == TV_CHANNEL_HIGHER) { if (direction == TV_CHANNEL_HIGHER) {
tv_channel_last = tv_channel_current; tv_channel_last = tv_channel_current;
if (tv_channel_current->next) if (tv_channel_current->next)
tv_channel_current = tv_channel_current->next; tv_channel_current = tv_channel_current->next;
else else
tv_channel_current = tv_channel_list; tv_channel_current = tv_channel_list;
set_norm_and_freq(tvh, tv_channel_current); set_norm_and_freq(tvh, tv_channel_current);
} }
if (direction == TV_CHANNEL_LOWER) { if (direction == TV_CHANNEL_LOWER) {
tv_channel_last = tv_channel_current; tv_channel_last = tv_channel_current;
if (tv_channel_current->prev) if (tv_channel_current->prev)
tv_channel_current = tv_channel_current->prev; tv_channel_current = tv_channel_current->prev;
else else
while (tv_channel_current->next) while (tv_channel_current->next)
tv_channel_current = tv_channel_current->next; tv_channel_current = tv_channel_current->next;
set_norm_and_freq(tvh, tv_channel_current); set_norm_and_freq(tvh, tv_channel_current);
} }
} else tv_step_channel_real(tvh, direction); } else tv_step_channel_real(tvh, direction);
return 1; return 1;
} }
int tv_set_channel_real(tvi_handle_t *tvh, char *channel) { int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
int i; int i;
struct CHANLIST cl; struct CHANLIST cl;
tvh->tv_param->scan=0; tvh->tv_param->scan=0;
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name); strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
for (i = 0; i < chanlists[tvh->chanlist].count; i++) for (i = 0; i < chanlists[tvh->chanlist].count; i++)
{ {
cl = tvh->chanlist_s[i]; cl = tvh->chanlist_s[i];
// printf("count%d: name: %s, freq: %d\n", // printf("count%d: name: %s, freq: %d\n",
// i, cl.name, cl.freq); // i, cl.name, cl.freq);
if (!strcasecmp(cl.name, channel)) if (!strcasecmp(cl.name, channel))
{ {
tvh->channel = i; tvh->channel = i;
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n", MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0); cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq); tv_set_freq_float(tvh, cl.freq);
break; break;
} }
} }
return 1; return 1;
} }
int tv_set_channel(tvi_handle_t *tvh, char *channel) { int tv_set_channel(tvi_handle_t *tvh, char *channel) {
int i, channel_int; int i, channel_int;
tvh->tv_param->scan=0; tvh->tv_param->scan=0;
if (tv_channel_list) { if (tv_channel_list) {
tv_channel_last = tv_channel_current; tv_channel_last = tv_channel_current;
channel_int = atoi(channel); channel_int = atoi(channel);
tv_channel_current = tv_channel_list; tv_channel_current = tv_channel_list;
for (i = 1; i < channel_int; i++) for (i = 1; i < channel_int; i++)
if (tv_channel_current->next) if (tv_channel_current->next)
tv_channel_current = tv_channel_current->next; tv_channel_current = tv_channel_current->next;
set_norm_and_freq(tvh, tv_channel_current); set_norm_and_freq(tvh, tv_channel_current);
} else tv_set_channel_real(tvh, channel); } else tv_set_channel_real(tvh, channel);
return 1; return 1;
} }
int tv_last_channel(tvi_handle_t *tvh) { int tv_last_channel(tvi_handle_t *tvh) {
tvh->tv_param->scan=0; tvh->tv_param->scan=0;
if (tv_channel_list) { if (tv_channel_list) {
tv_channels_t *tmp; tv_channels_t *tmp;
tmp = tv_channel_last; tmp = tv_channel_last;
tv_channel_last = tv_channel_current; tv_channel_last = tv_channel_current;
tv_channel_current = tmp; tv_channel_current = tmp;
set_norm_and_freq(tvh, tv_channel_current); set_norm_and_freq(tvh, tv_channel_current);
} else { } else {
int i; int i;
struct CHANLIST cl; struct CHANLIST cl;
for (i = 0; i < chanlists[tvh->chanlist].count; i++) for (i = 0; i < chanlists[tvh->chanlist].count; i++)
{ {
cl = tvh->chanlist_s[i]; cl = tvh->chanlist_s[i];
if (!strcasecmp(cl.name, tv_channel_last_real)) if (!strcasecmp(cl.name, tv_channel_last_real))
{ {
strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name); strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
tvh->channel = i; tvh->channel = i;
MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n", MP_INFO(tvh, "Selected channel: %s (freq: %.3f)\n",
cl.name, cl.freq/1000.0); cl.name, cl.freq/1000.0);
tv_set_freq_float(tvh, cl.freq); tv_set_freq_float(tvh, cl.freq);
break; break;
} }
} }
} }
return 1; return 1;
} }
int tv_step_norm(tvi_handle_t *tvh) int tv_step_norm(tvi_handle_t *tvh)

View File

@@ -103,16 +103,16 @@ typedef struct tvi_functions_s
typedef struct tvi_handle_s { typedef struct tvi_handle_s {
struct mp_log *log; struct mp_log *log;
const tvi_functions_t *functions; const tvi_functions_t *functions;
void *priv; void *priv;
int seq; int seq;
struct demuxer *demuxer; struct demuxer *demuxer;
/* specific */ /* specific */
int norm; int norm;
int chanlist; int chanlist;
const struct CHANLIST *chanlist_s; const struct CHANLIST *chanlist_s;
int channel; int channel;
tv_param_t * tv_param; tv_param_t * tv_param;
void * scan; void * scan;
} tvi_handle_t; } tvi_handle_t;
@@ -137,79 +137,79 @@ typedef struct {
int new_channels; int new_channels;
} tv_scan_t; } tv_scan_t;
#define TVI_CONTROL_FALSE 0 #define TVI_CONTROL_FALSE 0
#define TVI_CONTROL_TRUE 1 #define TVI_CONTROL_TRUE 1
#define TVI_CONTROL_NA -1 #define TVI_CONTROL_NA -1
#define TVI_CONTROL_UNKNOWN -2 #define TVI_CONTROL_UNKNOWN -2
/* ======================== CONTROLS =========================== */ /* ======================== CONTROLS =========================== */
/* GENERIC controls */ /* GENERIC controls */
#define TVI_CONTROL_IS_AUDIO 0x1 #define TVI_CONTROL_IS_AUDIO 0x1
#define TVI_CONTROL_IS_VIDEO 0x2 #define TVI_CONTROL_IS_VIDEO 0x2
#define TVI_CONTROL_IS_TUNER 0x3 #define TVI_CONTROL_IS_TUNER 0x3
#define TVI_CONTROL_IMMEDIATE 0x4 #define TVI_CONTROL_IMMEDIATE 0x4
/* VIDEO controls */ /* VIDEO controls */
#define TVI_CONTROL_VID_GET_FPS 0x101 #define TVI_CONTROL_VID_GET_FPS 0x101
#define TVI_CONTROL_VID_GET_PLANES 0x102 #define TVI_CONTROL_VID_GET_PLANES 0x102
#define TVI_CONTROL_VID_GET_BITS 0x103 #define TVI_CONTROL_VID_GET_BITS 0x103
#define TVI_CONTROL_VID_CHK_BITS 0x104 #define TVI_CONTROL_VID_CHK_BITS 0x104
#define TVI_CONTROL_VID_SET_BITS 0x105 #define TVI_CONTROL_VID_SET_BITS 0x105
#define TVI_CONTROL_VID_GET_FORMAT 0x106 #define TVI_CONTROL_VID_GET_FORMAT 0x106
#define TVI_CONTROL_VID_CHK_FORMAT 0x107 #define TVI_CONTROL_VID_CHK_FORMAT 0x107
#define TVI_CONTROL_VID_SET_FORMAT 0x108 #define TVI_CONTROL_VID_SET_FORMAT 0x108
#define TVI_CONTROL_VID_GET_WIDTH 0x109 #define TVI_CONTROL_VID_GET_WIDTH 0x109
#define TVI_CONTROL_VID_CHK_WIDTH 0x110 #define TVI_CONTROL_VID_CHK_WIDTH 0x110
#define TVI_CONTROL_VID_SET_WIDTH 0x111 #define TVI_CONTROL_VID_SET_WIDTH 0x111
#define TVI_CONTROL_VID_GET_HEIGHT 0x112 #define TVI_CONTROL_VID_GET_HEIGHT 0x112
#define TVI_CONTROL_VID_CHK_HEIGHT 0x113 #define TVI_CONTROL_VID_CHK_HEIGHT 0x113
#define TVI_CONTROL_VID_SET_HEIGHT 0x114 #define TVI_CONTROL_VID_SET_HEIGHT 0x114
#define TVI_CONTROL_VID_GET_BRIGHTNESS 0x115 #define TVI_CONTROL_VID_GET_BRIGHTNESS 0x115
#define TVI_CONTROL_VID_SET_BRIGHTNESS 0x116 #define TVI_CONTROL_VID_SET_BRIGHTNESS 0x116
#define TVI_CONTROL_VID_GET_HUE 0x117 #define TVI_CONTROL_VID_GET_HUE 0x117
#define TVI_CONTROL_VID_SET_HUE 0x118 #define TVI_CONTROL_VID_SET_HUE 0x118
#define TVI_CONTROL_VID_GET_SATURATION 0x119 #define TVI_CONTROL_VID_GET_SATURATION 0x119
#define TVI_CONTROL_VID_SET_SATURATION 0x11a #define TVI_CONTROL_VID_SET_SATURATION 0x11a
#define TVI_CONTROL_VID_GET_CONTRAST 0x11b #define TVI_CONTROL_VID_GET_CONTRAST 0x11b
#define TVI_CONTROL_VID_SET_CONTRAST 0x11c #define TVI_CONTROL_VID_SET_CONTRAST 0x11c
#define TVI_CONTROL_VID_GET_PICTURE 0x11d #define TVI_CONTROL_VID_GET_PICTURE 0x11d
#define TVI_CONTROL_VID_SET_PICTURE 0x11e #define TVI_CONTROL_VID_SET_PICTURE 0x11e
#define TVI_CONTROL_VID_SET_GAIN 0x11f #define TVI_CONTROL_VID_SET_GAIN 0x11f
#define TVI_CONTROL_VID_GET_GAIN 0x120 #define TVI_CONTROL_VID_GET_GAIN 0x120
#define TVI_CONTROL_VID_SET_WIDTH_HEIGHT 0x121 #define TVI_CONTROL_VID_SET_WIDTH_HEIGHT 0x121
/* TUNER controls */ /* TUNER controls */
#define TVI_CONTROL_TUN_GET_FREQ 0x201 #define TVI_CONTROL_TUN_GET_FREQ 0x201
#define TVI_CONTROL_TUN_SET_FREQ 0x202 #define TVI_CONTROL_TUN_SET_FREQ 0x202
#define TVI_CONTROL_TUN_GET_TUNER 0x203 /* update priv->tuner struct for used input */ #define TVI_CONTROL_TUN_GET_TUNER 0x203 /* update priv->tuner struct for used input */
#define TVI_CONTROL_TUN_SET_TUNER 0x204 /* update priv->tuner struct for used input */ #define TVI_CONTROL_TUN_SET_TUNER 0x204 /* update priv->tuner struct for used input */
#define TVI_CONTROL_TUN_GET_NORM 0x205 #define TVI_CONTROL_TUN_GET_NORM 0x205
#define TVI_CONTROL_TUN_SET_NORM 0x206 #define TVI_CONTROL_TUN_SET_NORM 0x206
#define TVI_CONTROL_TUN_GET_SIGNAL 0x207 #define TVI_CONTROL_TUN_GET_SIGNAL 0x207
/* AUDIO controls */ /* AUDIO controls */
#define TVI_CONTROL_AUD_GET_FORMAT 0x301 #define TVI_CONTROL_AUD_GET_FORMAT 0x301
#define TVI_CONTROL_AUD_GET_SAMPLERATE 0x302 #define TVI_CONTROL_AUD_GET_SAMPLERATE 0x302
#define TVI_CONTROL_AUD_GET_CHANNELS 0x304 #define TVI_CONTROL_AUD_GET_CHANNELS 0x304
#define TVI_CONTROL_AUD_SET_SAMPLERATE 0x305 #define TVI_CONTROL_AUD_SET_SAMPLERATE 0x305
/* SPECIFIC controls */ /* SPECIFIC controls */
#define TVI_CONTROL_SPC_GET_INPUT 0x401 /* set input channel (tv,s-video,composite..) */ #define TVI_CONTROL_SPC_GET_INPUT 0x401 /* set input channel (tv,s-video,composite..) */
#define TVI_CONTROL_SPC_SET_INPUT 0x402 /* set input channel (tv,s-video,composite..) */ #define TVI_CONTROL_SPC_SET_INPUT 0x402 /* set input channel (tv,s-video,composite..) */
#define TVI_CONTROL_SPC_GET_NORMID 0x403 /* get normid from norm name */ #define TVI_CONTROL_SPC_GET_NORMID 0x403 /* get normid from norm name */
int tv_set_color_options(tvi_handle_t *tvh, int opt, int val); int tv_set_color_options(tvi_handle_t *tvh, int opt, int val);
int tv_get_color_options(tvi_handle_t *tvh, int opt, int* val); int tv_get_color_options(tvi_handle_t *tvh, int opt, int* val);
#define TV_COLOR_BRIGHTNESS 1 #define TV_COLOR_BRIGHTNESS 1
#define TV_COLOR_HUE 2 #define TV_COLOR_HUE 2
#define TV_COLOR_SATURATION 3 #define TV_COLOR_SATURATION 3
#define TV_COLOR_CONTRAST 4 #define TV_COLOR_CONTRAST 4
int tv_step_channel_real(tvi_handle_t *tvh, int direction); int tv_step_channel_real(tvi_handle_t *tvh, int direction);
int tv_step_channel(tvi_handle_t *tvh, int direction); int tv_step_channel(tvi_handle_t *tvh, int direction);
#define TV_CHANNEL_LOWER 1 #define TV_CHANNEL_LOWER 1
#define TV_CHANNEL_HIGHER 2 #define TV_CHANNEL_HIGHER 2
int tv_last_channel(tvi_handle_t *tvh); int tv_last_channel(tvi_handle_t *tvh);
@@ -231,12 +231,12 @@ void tv_start_scan(tvi_handle_t *tvh, int start);
tvi_handle_t *tv_new_handle(int size, struct mp_log *log, const tvi_functions_t *functions); tvi_handle_t *tv_new_handle(int size, struct mp_log *log, const tvi_functions_t *functions);
void tv_free_handle(tvi_handle_t *h); void tv_free_handle(tvi_handle_t *h);
#define TV_NORM_PAL 1 #define TV_NORM_PAL 1
#define TV_NORM_NTSC 2 #define TV_NORM_NTSC 2
#define TV_NORM_SECAM 3 #define TV_NORM_SECAM 3
#define TV_NORM_PALNC 4 #define TV_NORM_PALNC 4
#define TV_NORM_PALM 5 #define TV_NORM_PALM 5
#define TV_NORM_PALN 6 #define TV_NORM_PALN 6
#define TV_NORM_NTSCJP 7 #define TV_NORM_NTSCJP 7
#endif /* MPLAYER_TV_H */ #endif /* MPLAYER_TV_H */

View File

@@ -70,7 +70,7 @@ static inline void fill_blank_frame(char* buffer,int len,int fmt){
buffer[i+1]=0; buffer[i+1]=0;
buffer[i+2]=0; buffer[i+2]=0;
buffer[i+3]=0; buffer[i+3]=0;
} }
break; break;
case MP_FOURCC_YUY2: case MP_FOURCC_YUY2:
for(i=0;i<len;i+=4){ for(i=0;i<len;i+=4){
@@ -78,13 +78,13 @@ static inline void fill_blank_frame(char* buffer,int len,int fmt){
buffer[i+1]=0xFF; buffer[i+1]=0xFF;
buffer[i+2]=0; buffer[i+2]=0;
buffer[i+3]=0; buffer[i+3]=0;
} }
break; break;
case MP_FOURCC_MJPEG: case MP_FOURCC_MJPEG:
/* /*
This is compressed format. I don't know yet how to fill such frame with blue color. This is compressed format. I don't know yet how to fill such frame with blue color.
Keeping frame unchanged. Keeping frame unchanged.
*/ */
break; break;
default: default:
memset(buffer,0xC0,len); memset(buffer,0xC0,len);

View File

@@ -27,11 +27,11 @@
static tvi_handle_t *tvi_init_dummy(struct mp_log *log, tv_param_t* tv_param); static tvi_handle_t *tvi_init_dummy(struct mp_log *log, tv_param_t* tv_param);
/* information about this file */ /* information about this file */
const tvi_info_t tvi_info_dummy = { const tvi_info_t tvi_info_dummy = {
tvi_init_dummy, tvi_init_dummy,
"NULL-TV", "NULL-TV",
"dummy", "dummy",
"alex", "alex",
NULL NULL
}; };
/* private data's */ /* private data's */
@@ -71,36 +71,36 @@ static int do_control(priv_t *priv, int cmd, void *arg)
{ {
switch(cmd) switch(cmd)
{ {
case TVI_CONTROL_IS_VIDEO: case TVI_CONTROL_IS_VIDEO:
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_GET_FORMAT: case TVI_CONTROL_VID_GET_FORMAT:
*(int *)arg = MP_FOURCC_YV12; *(int *)arg = MP_FOURCC_YV12;
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_SET_FORMAT: case TVI_CONTROL_VID_SET_FORMAT:
{ {
// int req_fmt = *(int *)arg; // int req_fmt = *(int *)arg;
int req_fmt = *(int *)arg; int req_fmt = *(int *)arg;
if (req_fmt != MP_FOURCC_YV12) if (req_fmt != MP_FOURCC_YV12)
return TVI_CONTROL_FALSE; return TVI_CONTROL_FALSE;
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
} }
case TVI_CONTROL_VID_SET_WIDTH: case TVI_CONTROL_VID_SET_WIDTH:
priv->width = *(int *)arg; priv->width = *(int *)arg;
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_GET_WIDTH: case TVI_CONTROL_VID_GET_WIDTH:
*(int *)arg = priv->width; *(int *)arg = priv->width;
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_SET_HEIGHT: case TVI_CONTROL_VID_SET_HEIGHT:
priv->height = *(int *)arg; priv->height = *(int *)arg;
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_GET_HEIGHT: case TVI_CONTROL_VID_GET_HEIGHT:
*(int *)arg = priv->height; *(int *)arg = priv->height;
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_CHK_WIDTH: case TVI_CONTROL_VID_CHK_WIDTH:
case TVI_CONTROL_VID_CHK_HEIGHT: case TVI_CONTROL_VID_CHK_HEIGHT:
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
case TVI_CONTROL_TUN_SET_NORM: case TVI_CONTROL_TUN_SET_NORM:
return TVI_CONTROL_TRUE; return TVI_CONTROL_TRUE;
} }
return TVI_CONTROL_UNKNOWN; return TVI_CONTROL_UNKNOWN;
} }

View File

@@ -762,7 +762,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
case TVI_CONTROL_VID_SET_GAIN: case TVI_CONTROL_VID_SET_GAIN:
{ {
//value==0 means automatic gain control //value==0 means automatic gain control
int value=*(int*)arg; int value=*(int*)arg;
if (value < 0 || value>100) if (value < 0 || value>100)
return TVI_CONTROL_FALSE; return TVI_CONTROL_FALSE;
@@ -1407,10 +1407,10 @@ static inline void copy_frame(priv_t *priv, video_buffer_entry *dest, unsigned c
if(priv->tv_param->automute>0){ if(priv->tv_param->automute>0){
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) >= 0) { if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) >= 0) {
if(priv->tv_param->automute<<8>priv->tuner.signal){ if(priv->tv_param->automute<<8>priv->tuner.signal){
fill_blank_frame(dest->data,dest->framesize,fcc_vl2mp(priv->format.fmt.pix.pixelformat)); fill_blank_frame(dest->data,dest->framesize,fcc_vl2mp(priv->format.fmt.pix.pixelformat));
set_mute(priv,1); set_mute(priv,1);
return; return;
} }
} }
set_mute(priv,0); set_mute(priv,0);
} }

View File

@@ -100,8 +100,8 @@ static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd){
tocentry.cdte_format = CDROM_MSF; tocentry.cdte_format = CDROM_MSF;
if (ioctl(fd,CDROMREADTOCENTRY,&tocentry)==-1) { if (ioctl(fd,CDROMREADTOCENTRY,&tocentry)==-1) {
MP_ERR(stream, "read CDROM toc entry: %s\n",strerror(errno)); MP_ERR(stream, "read CDROM toc entry: %s\n",strerror(errno));
return NULL; return NULL;
} }
if (i<=tochdr.cdth_trk1) if (i<=tochdr.cdth_trk1)
@@ -155,10 +155,10 @@ static int vcd_read(mp_vcd_priv_t* vcd,char *mem){
#include <sys/scsi/generic/commands.h> #include <sys/scsi/generic/commands.h>
#include <sys/scsi/impl/uscsi.h> #include <sys/scsi/impl/uscsi.h>
#define SUN_XAREAD 1 /*fails on atapi drives*/ #define SUN_XAREAD 1 /*fails on atapi drives*/
#define SUN_MODE2READ 2 /*fails on atapi drives*/ #define SUN_MODE2READ 2 /*fails on atapi drives*/
#define SUN_SCSIREAD 3 #define SUN_SCSIREAD 3
#define SUN_VCDREAD SUN_SCSIREAD #define SUN_VCDREAD SUN_SCSIREAD
static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset) static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset)
{ {
@@ -220,6 +220,6 @@ static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset)
#error SUN_VCDREAD #error SUN_VCDREAD
#endif #endif
} }
#endif /*sun*/ #endif /*sun*/
#endif /* MPLAYER_VCD_READ_H */ #endif /* MPLAYER_VCD_READ_H */

View File

@@ -37,25 +37,25 @@
#include "stream.h" #include "stream.h"
//=================== VideoCD ========================== //=================== VideoCD ==========================
#define CDROM_LEADOUT 0xAA #define CDROM_LEADOUT 0xAA
typedef struct typedef struct
{ {
uint8_t sync [12]; uint8_t sync [12];
uint8_t header [4]; uint8_t header [4];
uint8_t subheader [8]; uint8_t subheader [8];
uint8_t data [2324]; uint8_t data [2324];
uint8_t spare [4]; uint8_t spare [4];
} cdsector_t; } cdsector_t;
typedef struct mp_vcd_priv_st typedef struct mp_vcd_priv_st
{ {
stream_t *stream; stream_t *stream;
int fd; int fd;
cdsector_t buf; cdsector_t buf;
dk_cd_read_track_info_t entry; dk_cd_read_track_info_t entry;
struct CDDiscInfo hdr; struct CDDiscInfo hdr;
CDMSF msf; CDMSF msf;
} mp_vcd_priv_t; } mp_vcd_priv_t;
static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect) static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect)
@@ -70,101 +70,101 @@ static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd)
static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track) static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track)
{ {
struct CDTrackInfo entry; struct CDTrackInfo entry;
memset( &vcd->entry, 0, sizeof(vcd->entry)); memset( &vcd->entry, 0, sizeof(vcd->entry));
vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber; vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber;
vcd->entry.address = track; vcd->entry.address = track;
vcd->entry.bufferLength = sizeof(entry); vcd->entry.bufferLength = sizeof(entry);
vcd->entry.buffer = &entry; vcd->entry.buffer = &entry;
if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry)) if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry))
{ {
MP_ERR(vcd->stream, "ioctl dif1: %s\n",strerror(errno)); MP_ERR(vcd->stream, "ioctl dif1: %s\n",strerror(errno));
return -1; return -1;
} }
vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress));
return VCD_SECTOR_DATA*vcd_get_msf(vcd); return VCD_SECTOR_DATA*vcd_get_msf(vcd);
} }
static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track) static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
{ {
struct CDTrackInfo entry; struct CDTrackInfo entry;
if (track > vcd->hdr.lastTrackNumberInLastSessionLSB) { if (track > vcd->hdr.lastTrackNumberInLastSessionLSB) {
MP_ERR(vcd->stream, "track number %d greater than last track number %d\n", MP_ERR(vcd->stream, "track number %d greater than last track number %d\n",
track, vcd->hdr.lastTrackNumberInLastSessionLSB); track, vcd->hdr.lastTrackNumberInLastSessionLSB);
return -1; return -1;
} }
//read track info //read track info
memset( &vcd->entry, 0, sizeof(vcd->entry)); memset( &vcd->entry, 0, sizeof(vcd->entry));
vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber; vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber;
vcd->entry.address = track<vcd->hdr.lastTrackNumberInLastSessionLSB?track+1:vcd->hdr.lastTrackNumberInLastSessionLSB; vcd->entry.address = track<vcd->hdr.lastTrackNumberInLastSessionLSB?track+1:vcd->hdr.lastTrackNumberInLastSessionLSB;
vcd->entry.bufferLength = sizeof(entry); vcd->entry.bufferLength = sizeof(entry);
vcd->entry.buffer = &entry; vcd->entry.buffer = &entry;
if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry)) if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry))
{ {
MP_ERR(vcd->stream, "ioctl dif2: %s\n",strerror(errno)); MP_ERR(vcd->stream, "ioctl dif2: %s\n",strerror(errno));
return -1; return -1;
} }
if (track == vcd->hdr.lastTrackNumberInLastSessionLSB) if (track == vcd->hdr.lastTrackNumberInLastSessionLSB)
vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress) + vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress) +
be2me_32(entry.trackSize)); be2me_32(entry.trackSize));
else else
vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress));
return VCD_SECTOR_DATA*vcd_get_msf(vcd); return VCD_SECTOR_DATA*vcd_get_msf(vcd);
} }
static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd) static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd)
{ {
dk_cd_read_disc_info_t tochdr; dk_cd_read_disc_info_t tochdr;
struct CDDiscInfo hdr; struct CDDiscInfo hdr;
dk_cd_read_track_info_t tocentry; dk_cd_read_track_info_t tocentry;
struct CDTrackInfo entry; struct CDTrackInfo entry;
CDMSF trackMSF; CDMSF trackMSF;
mp_vcd_priv_t* vcd; mp_vcd_priv_t* vcd;
int i; int i;
//read toc header //read toc header
memset(&tochdr, 0, sizeof(tochdr)); memset(&tochdr, 0, sizeof(tochdr));
tochdr.buffer = &hdr; tochdr.buffer = &hdr;
tochdr.bufferLength = sizeof(hdr); tochdr.bufferLength = sizeof(hdr);
if (ioctl(fd, DKIOCCDREADDISCINFO, &tochdr) < 0) if (ioctl(fd, DKIOCCDREADDISCINFO, &tochdr) < 0)
{ {
MP_ERR(stream, "read CDROM toc header: %s\n",strerror(errno)); MP_ERR(stream, "read CDROM toc header: %s\n",strerror(errno));
return NULL; return NULL;
} }
//print all track info //print all track info
for (i=hdr.firstTrackNumberInLastSessionLSB ; i<=hdr.lastTrackNumberInLastSessionLSB + 1; i++) for (i=hdr.firstTrackNumberInLastSessionLSB ; i<=hdr.lastTrackNumberInLastSessionLSB + 1; i++)
{ {
if (i <= hdr.lastTrackNumberInLastSessionLSB) { if (i <= hdr.lastTrackNumberInLastSessionLSB) {
memset( &tocentry, 0, sizeof(tocentry)); memset( &tocentry, 0, sizeof(tocentry));
tocentry.addressType = kCDTrackInfoAddressTypeTrackNumber; tocentry.addressType = kCDTrackInfoAddressTypeTrackNumber;
tocentry.address = i; tocentry.address = i;
tocentry.bufferLength = sizeof(entry); tocentry.bufferLength = sizeof(entry);
tocentry.buffer = &entry; tocentry.buffer = &entry;
if (ioctl(fd,DKIOCCDREADTRACKINFO,&tocentry)==-1) if (ioctl(fd,DKIOCCDREADTRACKINFO,&tocentry)==-1)
{ {
MP_ERR(stream, "read CDROM toc entry: %s\n",strerror(errno)); MP_ERR(stream, "read CDROM toc entry: %s\n",strerror(errno));
return NULL; return NULL;
} }
trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress));
} }
else else
trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress) trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)
+ be2me_32(entry.trackSize)); + be2me_32(entry.trackSize));
//MP_INFO(vcd->stream, "track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n", //MP_INFO(vcd->stream, "track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
if (i<=hdr.lastTrackNumberInLastSessionLSB) if (i<=hdr.lastTrackNumberInLastSessionLSB)
MP_INFO(stream, "track %02d: format=%d %02d:%02d:%02d\n", MP_INFO(stream, "track %02d: format=%d %02d:%02d:%02d\n",
(int)tocentry.address, (int)tocentry.address,
//(int)tocentry.entry.addr_type, //(int)tocentry.entry.addr_type,
//(int)tocentry.entry.control, //(int)tocentry.entry.control,
@@ -172,33 +172,33 @@ static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd)
(int)trackMSF.minute, (int)trackMSF.minute,
(int)trackMSF.second, (int)trackMSF.second,
(int)trackMSF.frame (int)trackMSF.frame
); );
} }
vcd = malloc(sizeof(mp_vcd_priv_t)); vcd = malloc(sizeof(mp_vcd_priv_t));
vcd->stream = stream; vcd->stream = stream;
vcd->fd = fd; vcd->fd = fd;
vcd->hdr = hdr; vcd->hdr = hdr;
vcd->msf = trackMSF; vcd->msf = trackMSF;
return vcd; return vcd;
} }
static int vcd_read(mp_vcd_priv_t* vcd,char *mem) static int vcd_read(mp_vcd_priv_t* vcd,char *mem)
{ {
if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) != VCD_SECTOR_SIZE) if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) != VCD_SECTOR_SIZE)
return 0; // EOF? return 0; // EOF?
vcd->msf.frame++; vcd->msf.frame++;
if (vcd->msf.frame==75) if (vcd->msf.frame==75)
{ {
vcd->msf.frame=0; vcd->msf.frame=0;
vcd->msf.second++; vcd->msf.second++;
if (vcd->msf.second==60) if (vcd->msf.second==60)
{ {
vcd->msf.second=0; vcd->msf.second=0;
vcd->msf.minute++; vcd->msf.minute++;
} }
} }

View File

@@ -44,14 +44,14 @@
#include "common/msg.h" #include "common/msg.h"
//=================== VideoCD ========================== //=================== VideoCD ==========================
#define CDROM_LEADOUT 0xAA #define CDROM_LEADOUT 0xAA
typedef struct { typedef struct {
uint8_t sync [12]; uint8_t sync [12];
uint8_t header [4]; uint8_t header [4];
uint8_t subheader [8]; uint8_t subheader [8];
uint8_t data [2324]; uint8_t data [2324];
uint8_t spare [4]; uint8_t spare [4];
} cdsector_t; } cdsector_t;
#ifdef VCD_NETBSD #ifdef VCD_NETBSD

View File

@@ -49,15 +49,15 @@ static inline unsigned vcd_get_msf(mp_vcd_priv_t* vcd, int track){
int index = track - vcd->toc.FirstTrack; int index = track - vcd->toc.FirstTrack;
/* -150 to compensate the 2-second pregap */ /* -150 to compensate the 2-second pregap */
return vcd->toc.TrackData[index].Address[3] + return vcd->toc.TrackData[index].Address[3] +
(vcd->toc.TrackData[index].Address[2] + (vcd->toc.TrackData[index].Address[2] +
vcd->toc.TrackData[index].Address[1] * 60) * 75 - 150; vcd->toc.TrackData[index].Address[1] * 60) * 75 - 150;
} }
static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track) static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track)
{ {
unsigned sect; unsigned sect;
if (track < vcd->toc.FirstTrack || track > vcd->toc.LastTrack) if (track < vcd->toc.FirstTrack || track > vcd->toc.LastTrack)
return -1; return -1;
sect = vcd_get_msf(vcd, track); sect = vcd_get_msf(vcd, track);
vcd_set_msf(vcd, sect); vcd_set_msf(vcd, sect);
return VCD_SECTOR_DATA * (sect + 2); return VCD_SECTOR_DATA * (sect + 2);
@@ -66,7 +66,7 @@ static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track)
static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track) static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
{ {
if (track < vcd->toc.FirstTrack || track > vcd->toc.LastTrack) if (track < vcd->toc.FirstTrack || track > vcd->toc.LastTrack)
return -1; return -1;
return VCD_SECTOR_DATA * (vcd_get_msf(vcd, track + 1)); return VCD_SECTOR_DATA * (vcd_get_msf(vcd, track + 1));
} }
@@ -77,29 +77,29 @@ static mp_vcd_priv_t* vcd_read_toc(stream_t *stream, int fd)
int i; int i;
mp_vcd_priv_t* vcd = malloc(sizeof(mp_vcd_priv_t)); mp_vcd_priv_t* vcd = malloc(sizeof(mp_vcd_priv_t));
if (!vcd) if (!vcd)
return NULL; return NULL;
hd = (HANDLE)_get_osfhandle(fd); hd = (HANDLE)_get_osfhandle(fd);
if (!DeviceIoControl(hd, IOCTL_CDROM_READ_TOC, NULL, 0, &vcd->toc, if (!DeviceIoControl(hd, IOCTL_CDROM_READ_TOC, NULL, 0, &vcd->toc,
sizeof(CDROM_TOC), &dwBytesReturned, NULL)) { sizeof(CDROM_TOC), &dwBytesReturned, NULL)) {
MP_ERR(stream, "read CDROM toc header: %lu\n", MP_ERR(stream, "read CDROM toc header: %lu\n",
GetLastError()); GetLastError());
free(vcd); free(vcd);
return NULL; return NULL;
} }
for (i = vcd->toc.FirstTrack; i <= vcd->toc.LastTrack + 1; i++) { for (i = vcd->toc.FirstTrack; i <= vcd->toc.LastTrack + 1; i++) {
int index = i - vcd->toc.FirstTrack; int index = i - vcd->toc.FirstTrack;
if (i <= vcd->toc.LastTrack) { if (i <= vcd->toc.LastTrack) {
MP_INFO(stream, "track %02d: adr=%d ctrl=%d" MP_INFO(stream, "track %02d: adr=%d ctrl=%d"
" %02d:%02d:%02d\n", " %02d:%02d:%02d\n",
vcd->toc.TrackData[index].TrackNumber, vcd->toc.TrackData[index].TrackNumber,
vcd->toc.TrackData[index].Adr, vcd->toc.TrackData[index].Adr,
vcd->toc.TrackData[index].Control, vcd->toc.TrackData[index].Control,
vcd->toc.TrackData[index].Address[1], vcd->toc.TrackData[index].Address[1],
vcd->toc.TrackData[index].Address[2], vcd->toc.TrackData[index].Address[2],
vcd->toc.TrackData[index].Address[3]); vcd->toc.TrackData[index].Address[3]);
} }
} }
vcd->hd = hd; vcd->hd = hd;
@@ -119,9 +119,9 @@ static int vcd_read(mp_vcd_priv_t* vcd, char *mem)
cdrom_raw.TrackMode = XAForm2; cdrom_raw.TrackMode = XAForm2;
if (!DeviceIoControl(vcd->hd, IOCTL_CDROM_RAW_READ, &cdrom_raw, if (!DeviceIoControl(vcd->hd, IOCTL_CDROM_RAW_READ, &cdrom_raw,
sizeof(RAW_READ_INFO), vcd->buf, sizeof(vcd->buf), sizeof(RAW_READ_INFO), vcd->buf, sizeof(vcd->buf),
&dwBytesReturned, NULL)) &dwBytesReturned, NULL))
return 0; return 0;
vcd->sect++; vcd->sect++;
memcpy(mem, &vcd->buf[VCD_SECTOR_OFFS], VCD_SECTOR_DATA); memcpy(mem, &vcd->buf[VCD_SECTOR_OFFS], VCD_SECTOR_DATA);

View File

File diff suppressed because it is too large Load Diff

View File

@@ -31,55 +31,55 @@
struct pullup_buffer struct pullup_buffer
{ {
int lock[2]; int lock[2];
unsigned char **planes; unsigned char **planes;
}; };
struct pullup_field struct pullup_field
{ {
int parity; int parity;
double pts; double pts;
struct pullup_buffer *buffer; struct pullup_buffer *buffer;
unsigned int flags; unsigned int flags;
int breaks; int breaks;
int affinity; int affinity;
int *diffs; int *diffs;
int *comb; int *comb;
int *var; int *var;
struct pullup_field *prev, *next; struct pullup_field *prev, *next;
}; };
struct pullup_frame struct pullup_frame
{ {
int lock; int lock;
int length; int length;
int parity; int parity;
double pts; double pts;
struct pullup_buffer **ifields, *ofields[2]; struct pullup_buffer **ifields, *ofields[2];
struct pullup_buffer *buffer; struct pullup_buffer *buffer;
}; };
struct pullup_context struct pullup_context
{ {
/* Public interface */ /* Public interface */
int format; int format;
int nplanes; int nplanes;
int *bpp, *w, *h, *stride, *background; int *bpp, *w, *h, *stride, *background;
unsigned int cpu; unsigned int cpu;
int junk_left, junk_right, junk_top, junk_bottom; int junk_left, junk_right, junk_top, junk_bottom;
int verbose; int verbose;
int metric_plane; int metric_plane;
int strict_breaks; int strict_breaks;
int strict_pairs; int strict_pairs;
/* Internal data */ /* Internal data */
struct pullup_field *first, *last, *head; struct pullup_field *first, *last, *head;
struct pullup_buffer *buffers; struct pullup_buffer *buffers;
int nbuffers; int nbuffers;
int (*diff)(unsigned char *, unsigned char *, int); int (*diff)(unsigned char *, unsigned char *, int);
int (*comb)(unsigned char *, unsigned char *, int); int (*comb)(unsigned char *, unsigned char *, int);
int (*var)(unsigned char *, unsigned char *, int); int (*var)(unsigned char *, unsigned char *, int);
int metric_w, metric_h, metric_len, metric_offset; int metric_w, metric_h, metric_len, metric_offset;
struct pullup_frame *frame; struct pullup_frame *frame;
}; };

View File

@@ -42,7 +42,7 @@ static const struct vf_priv_s {
static int config(struct vf_instance *vf, static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height, int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt) unsigned int flags, unsigned int outfmt)
{ {
// calculate the missing parameters: // calculate the missing parameters:
if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width; if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width;
@@ -59,8 +59,8 @@ static int config(struct vf_instance *vf,
// check: // check:
if(vf->priv->crop_w+vf->priv->crop_x>width || if(vf->priv->crop_w+vf->priv->crop_x>width ||
vf->priv->crop_h+vf->priv->crop_y>height){ vf->priv->crop_h+vf->priv->crop_y>height){
MP_WARN(vf, "[CROP] Bad position/width/height - cropped area outside of the original!\n"); MP_WARN(vf, "[CROP] Bad position/width/height - cropped area outside of the original!\n");
return 0; return 0;
} }
vf_rescale_dsize(&d_width, &d_height, width, height, vf_rescale_dsize(&d_width, &d_height, width, height,
vf->priv->crop_w, vf->priv->crop_h); vf->priv->crop_w, vf->priv->crop_h);

View File

@@ -60,39 +60,39 @@ static int diff_MMX(unsigned char *old, unsigned char *new, int os, int ns)
{ {
volatile short out[4]; volatile short out[4];
__asm__ ( __asm__ (
"movl $8, %%ecx \n\t" "movl $8, %%ecx \n\t"
"pxor %%mm4, %%mm4 \n\t" "pxor %%mm4, %%mm4 \n\t"
"pxor %%mm7, %%mm7 \n\t" "pxor %%mm7, %%mm7 \n\t"
".align 4 \n\t" ".align 4 \n\t"
"1: \n\t" "1: \n\t"
"movq (%%"REG_S"), %%mm0 \n\t" "movq (%%"REG_S"), %%mm0 \n\t"
"movq (%%"REG_S"), %%mm2 \n\t" "movq (%%"REG_S"), %%mm2 \n\t"
"add %%"REG_a", %%"REG_S" \n\t" "add %%"REG_a", %%"REG_S" \n\t"
"movq (%%"REG_D"), %%mm1 \n\t" "movq (%%"REG_D"), %%mm1 \n\t"
"add %%"REG_b", %%"REG_D" \n\t" "add %%"REG_b", %%"REG_D" \n\t"
"psubusb %%mm1, %%mm2 \n\t" "psubusb %%mm1, %%mm2 \n\t"
"psubusb %%mm0, %%mm1 \n\t" "psubusb %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm0 \n\t" "movq %%mm2, %%mm0 \n\t"
"movq %%mm1, %%mm3 \n\t" "movq %%mm1, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm2 \n\t" "punpckhbw %%mm7, %%mm2 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t" "punpckhbw %%mm7, %%mm3 \n\t"
"paddw %%mm0, %%mm4 \n\t" "paddw %%mm0, %%mm4 \n\t"
"paddw %%mm1, %%mm4 \n\t" "paddw %%mm1, %%mm4 \n\t"
"paddw %%mm2, %%mm4 \n\t" "paddw %%mm2, %%mm4 \n\t"
"paddw %%mm3, %%mm4 \n\t" "paddw %%mm3, %%mm4 \n\t"
"decl %%ecx \n\t" "decl %%ecx \n\t"
"jnz 1b \n\t" "jnz 1b \n\t"
"movq %%mm4, (%%"REG_d") \n\t" "movq %%mm4, (%%"REG_d") \n\t"
"emms \n\t" "emms \n\t"
: :
: "S" (old), "D" (new), "a" ((long)os), "b" ((long)ns), "d" (out) : "S" (old), "D" (new), "a" ((long)os), "b" ((long)ns), "d" (out)
: "%ecx", "memory" : "%ecx", "memory"
); );
return out[0]+out[1]+out[2]+out[3]; return out[0]+out[1]+out[2]+out[3];
} }
#endif #endif
@@ -103,7 +103,7 @@ static int diff_C(unsigned char *old, unsigned char *new, int os, int ns)
for(y=8; y; y--, new+=ns, old+=os) for(y=8; y; y--, new+=ns, old+=os)
for(x=8; x; x--) for(x=8; x; x--)
d+=abs(new[x]-old[x]); d+=abs(new[x]-old[x]);
return d; return d;
} }
@@ -111,19 +111,19 @@ static int diff_C(unsigned char *old, unsigned char *new, int os, int ns)
static int (*diff)(unsigned char *, unsigned char *, int, int); static int (*diff)(unsigned char *, unsigned char *, int, int);
static int diff_plane(unsigned char *old, unsigned char *new, static int diff_plane(unsigned char *old, unsigned char *new,
int w, int h, int os, int ns, int arg) int w, int h, int os, int ns, int arg)
{ {
int x, y, d, max=0, sum=0, n=0; int x, y, d, max=0, sum=0, n=0;
for(y=0; y<h-7; y+=8) for(y=0; y<h-7; y+=8)
{ {
for(x=0; x<w-7; x+=8) for(x=0; x<w-7; x+=8)
{ {
d=diff(old+x+y*os, new+x+y*ns, os, ns); d=diff(old+x+y*os, new+x+y*ns, os, ns);
if(d>max) max=d; if(d>max) max=d;
sum+=d; sum+=d;
n++; n++;
} }
} }
return (sum+n*max)/2; return (sum+n*max)/2;
@@ -131,21 +131,21 @@ static int diff_plane(unsigned char *old, unsigned char *new,
/* /*
static unsigned int checksum_plane(unsigned char *p, unsigned char *z, static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
int w, int h, int s, int zs, int arg) int w, int h, int s, int zs, int arg)
{ {
unsigned int shift, sum; unsigned int shift, sum;
unsigned char *e; unsigned char *e;
for(sum=0; h; h--, p+=s-w) for(sum=0; h; h--, p+=s-w)
for(e=p+w, shift=32; p<e;) for(e=p+w, shift=32; p<e;)
sum^=(*p++)<<(shift=(shift-8)&31); sum^=(*p++)<<(shift=(shift-8)&31);
return sum; return sum;
} }
*/ */
static unsigned int checksum_plane(unsigned char *p, unsigned char *z, static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
int w, int h, int s, int zs, int arg) int w, int h, int s, int zs, int arg)
{ {
unsigned int shift; unsigned int shift;
uint32_t sum, t; uint32_t sum, t;
@@ -160,10 +160,10 @@ static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
for(sum=0; h; h--, p+=s-w) for(sum=0; h; h--, p+=s-w)
{ {
for(shift=0, e=p+w; (size_t)p&(sizeof(wsum_t)-1) && p<e;) for(shift=0, e=p+w; (size_t)p&(sizeof(wsum_t)-1) && p<e;)
sum^=*p++<<(shift=(shift-8)&31); sum^=*p++<<(shift=(shift-8)&31);
for(wsum=0, e2=e-sizeof(wsum_t)+1; p<e2; p+=sizeof(wsum_t)) for(wsum=0, e2=e-sizeof(wsum_t)+1; p<e2; p+=sizeof(wsum_t))
wsum^=*(wsum_t *)p; wsum^=*(wsum_t *)p;
#if HAVE_FAST_64BIT #if HAVE_FAST_64BIT
t=be2me_32((uint32_t)(wsum>>32^wsum)); t=be2me_32((uint32_t)(wsum>>32^wsum));
@@ -172,22 +172,22 @@ static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
#endif #endif
for(sum^=(t<<shift|t>>(32-shift)); p<e;) for(sum^=(t<<shift|t>>(32-shift)); p<e;)
sum^=*p++<<(shift=(shift-8)&31); sum^=*p++<<(shift=(shift-8)&31);
} }
return sum; return sum;
} }
static int deghost_plane(unsigned char *d, unsigned char *s, static int deghost_plane(unsigned char *d, unsigned char *s,
int w, int h, int ds, int ss, int threshold) int w, int h, int ds, int ss, int threshold)
{ {
int t; int t;
unsigned char *e; unsigned char *e;
for(; h; h--, s+=ss-w, d+=ds-w) for(; h; h--, s+=ss-w, d+=ds-w)
for(e=d+w; d<e; d++, s++) for(e=d+w; d<e; d++, s++)
if(abs(*d-*s)>=threshold) if(abs(*d-*s)>=threshold)
*d=(t=(*d<<1)-*s)<0?0:t>255?255:t; *d=(t=(*d<<1)-*s)<0?0:t>255?255:t;
return 0; return 0;
} }
@@ -198,8 +198,8 @@ static int copyop(unsigned char *d, unsigned char *s, int bpl, int h, int dstrid
} }
static int imgop(int(*planeop)(unsigned char *, unsigned char *, static int imgop(int(*planeop)(unsigned char *, unsigned char *,
int, int, int, int, int), int, int, int, int, int),
mp_image_t *dst, mp_image_t *src, int arg) mp_image_t *dst, mp_image_t *src, int arg)
{ {
int sum = 0; int sum = 0;
for (int p = 0; p < dst->num_planes; p++) { for (int p = 0; p < dst->num_planes; p++) {
@@ -220,7 +220,7 @@ static int imgop(int(*planeop)(unsigned char *, unsigned char *,
*/ */
static int match(struct vf_priv_s *p, int *diffs, static int match(struct vf_priv_s *p, int *diffs,
int phase1, int phase2, double *strength) int phase1, int phase2, double *strength)
{ {
const int pattern1[]={ -4, 1, 1, 1, 1 }, const int pattern1[]={ -4, 1, 1, 1, 1 },
pattern2[]={ -2, -3, 4, 4, -3 }, *pattern; pattern2[]={ -2, -3, 4, 4, -3 }, *pattern;
@@ -231,12 +231,12 @@ static int match(struct vf_priv_s *p, int *diffs,
for(f=0; f<5; f++) for(f=0; f<5; f++)
{ {
if(phase1<0 || phase2<0 || f==phase1 || f==phase2) if(phase1<0 || phase2<0 || f==phase1 || f==phase2)
{ {
for(n=t[f]=0; n<5; n++) for(n=t[f]=0; n<5; n++)
t[f]+=diffs[n]*pattern[(n-f+5)%5]; t[f]+=diffs[n]*pattern[(n-f+5)%5];
} }
else else
t[f]=INT_MIN; t[f]=INT_MIN;
} }
/* find the best match */ /* find the best match */
@@ -247,7 +247,7 @@ static int match(struct vf_priv_s *p, int *diffs,
{ {
/* the second best match */ /* the second best match */
for(f=m?0:1, n=f+1; n<5; n++) for(f=m?0:1, n=f+1; n<5; n++)
if(n!=m && t[n]>t[f]) f=n; if(n!=m && t[n]>t[f]) f=n;
*strength=(t[m]>0?(double)(t[m]-t[f])/t[m]:0.0); *strength=(t[m]>0?(double)(t[m]-t[f])/t[m]:0.0);
} }
@@ -278,70 +278,70 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
switch(p->pass) switch(p->pass)
{ {
case 1: case 1:
fprintf(p->file, "%08x %d\n", fprintf(p->file, "%08x %d\n",
(unsigned int)imgop((void *)checksum_plane, mpi, 0, 0), (unsigned int)imgop((void *)checksum_plane, mpi, 0, 0),
p->frameno?imgop(diff_plane, dmpi, mpi, 0):0); p->frameno?imgop(diff_plane, dmpi, mpi, 0):0);
break; break;
case 2: case 2:
if(p->frameno/5>p->bcount) if(p->frameno/5>p->bcount)
{ {
MP_ERR(vf, "\n%s: Log file ends prematurely! " MP_ERR(vf, "\n%s: Log file ends prematurely! "
"Switching to one pass mode.\n", vf->info->name); "Switching to one pass mode.\n", vf->info->name);
p->pass=0; p->pass=0;
break; break;
} }
checksum=(unsigned int)imgop((void *)checksum_plane, mpi, 0, 0); checksum=(unsigned int)imgop((void *)checksum_plane, mpi, 0, 0);
if(checksum!=p->csdata[p->frameno]) if(checksum!=p->csdata[p->frameno])
{ {
for(f=0; f<100; f++) for(f=0; f<100; f++)
if(p->frameno+f<p->fcount && p->csdata[p->frameno+f]==checksum) if(p->frameno+f<p->fcount && p->csdata[p->frameno+f]==checksum)
break; break;
else if(p->frameno-f>=0 && p->csdata[p->frameno-f]==checksum) else if(p->frameno-f>=0 && p->csdata[p->frameno-f]==checksum)
{ {
f=-f; f=-f;
break; break;
} }
if(f<100) if(f<100)
{ {
MP_INFO(vf, "\n%s: Mismatch with pass-1: %+d frame(s).\n", MP_INFO(vf, "\n%s: Mismatch with pass-1: %+d frame(s).\n",
vf->info->name, f); vf->info->name, f);
p->frameno+=f; p->frameno+=f;
p->misscount=0; p->misscount=0;
} }
else if(p->misscount++>=30) else if(p->misscount++>=30)
{ {
MP_ERR(vf, "\n%s: Sync with pass-1 lost! " MP_ERR(vf, "\n%s: Sync with pass-1 lost! "
"Switching to one pass mode.\n", vf->info->name); "Switching to one pass mode.\n", vf->info->name);
p->pass=0; p->pass=0;
break; break;
} }
} }
n=(p->frameno)/5; n=(p->frameno)/5;
if(n>=p->bcount) n=p->bcount-1; if(n>=p->bcount) n=p->bcount-1;
newphase=p->bdata[n]; newphase=p->bdata[n];
break; break;
default: default:
if(p->frameno) if(p->frameno)
{ {
int *sump=p->sum+p->frameno%5, int *sump=p->sum+p->frameno%5,
*histp=p->history+p->frameno%p->window; *histp=p->history+p->frameno%p->window;
*sump-=*histp; *sump-=*histp;
*sump+=(*histp=imgop(diff_plane, dmpi, mpi, 0)); *sump+=(*histp=imgop(diff_plane, dmpi, mpi, 0));
} }
m=match(p, p->sum, -1, -1, &d); m=match(p, p->sum, -1, -1, &d);
if(d>=p->threshold) if(d>=p->threshold)
newphase=m; newphase=m;
} }
n=p->ocount++%5; n=p->ocount++%5;
@@ -355,21 +355,21 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
switch((p->frameno++-p->phase+10)%5) switch((p->frameno++-p->phase+10)%5)
{ {
case 0: case 0:
imgop(copyop, dmpi, mpi, 0); imgop(copyop, dmpi, mpi, 0);
vf_detc_adjust_pts(&p->ptsbuf, pts, 0, 1); vf_detc_adjust_pts(&p->ptsbuf, pts, 0, 1);
talloc_free(mpi); talloc_free(mpi);
return 0; return 0;
case 4: case 4:
if(p->deghost>0) if(p->deghost>0)
{ {
imgop(copyop, dmpi, mpi, 0); imgop(copyop, dmpi, mpi, 0);
vf_make_out_image_writeable(vf, mpi); vf_make_out_image_writeable(vf, mpi);
imgop(deghost_plane, mpi, dmpi, p->deghost); imgop(deghost_plane, mpi, dmpi, p->deghost);
mpi->pts = vf_detc_adjust_pts(&p->ptsbuf, pts, 0, 0); mpi->pts = vf_detc_adjust_pts(&p->ptsbuf, pts, 0, 0);
return mpi; return mpi;
} }
} }
imgop(copyop, dmpi, mpi, 0); imgop(copyop, dmpi, mpi, 0);
@@ -393,20 +393,20 @@ static int analyze(struct vf_instance *vf)
while(fgets(lbuf, 256, p->file)) while(fgets(lbuf, 256, p->file))
{ {
if(n>=bufsize-19) if(n>=bufsize-19)
{ {
bufsize=bufsize?bufsize*2:30000; bufsize=bufsize?bufsize*2:30000;
if((bp=realloc(buf, bufsize*sizeof *buf))) buf=bp; if((bp=realloc(buf, bufsize*sizeof *buf))) buf=bp;
if((cp=realloc(cbuf, bufsize*sizeof *cbuf))) cbuf=cp; if((cp=realloc(cbuf, bufsize*sizeof *cbuf))) cbuf=cp;
if(!bp || !cp) if(!bp || !cp)
{ {
MP_FATAL(vf, "%s: Not enough memory.\n", MP_FATAL(vf, "%s: Not enough memory.\n",
vf_info_divtc.name); vf_info_divtc.name);
free(buf); free(buf);
free(cbuf); free(cbuf);
return 0; return 0;
} }
} }
sscanf(lbuf, "%x %d", cbuf+n, buf+n); sscanf(lbuf, "%x %d", cbuf+n, buf+n);
n++; n++;
} }
@@ -414,7 +414,7 @@ static int analyze(struct vf_instance *vf)
if(n <= 15) if(n <= 15)
{ {
MP_FATAL(vf, "%s: Empty 2-pass log file.\n", MP_FATAL(vf, "%s: Empty 2-pass log file.\n",
vf_info_divtc.name); vf_info_divtc.name);
free(buf); free(buf);
free(cbuf); free(cbuf);
return 0; return 0;
@@ -450,35 +450,35 @@ static int analyze(struct vf_instance *vf)
double s0=0.0, s1=0.0; double s0=0.0, s1=0.0;
for(f=0; f<n; f+=5) for(f=0; f<n; f+=5)
{ {
p->deghost=0; match(p, buf+f, -1, -1, &d); s0+=d; p->deghost=0; match(p, buf+f, -1, -1, &d); s0+=d;
p->deghost=1; match(p, buf+f, -1, -1, &d); s1+=d; p->deghost=1; match(p, buf+f, -1, -1, &d); s1+=d;
} }
p->deghost=s1>s0?deghost:0; p->deghost=s1>s0?deghost:0;
MP_INFO(vf, "%s: Deghosting %-3s (relative pattern strength %+.2fdB).\n", MP_INFO(vf, "%s: Deghosting %-3s (relative pattern strength %+.2fdB).\n",
vf_info_divtc.name, vf_info_divtc.name,
p->deghost?"ON":"OFF", p->deghost?"ON":"OFF",
10.0*log10(s1/s0)); 10.0*log10(s1/s0));
} }
/* analyze the data */ /* analyze the data */
for(f=0; f<5; f++) for(f=0; f<5; f++)
for(sum[f]=0, n=-15; n<20; n+=5) for(sum[f]=0, n=-15; n<20; n+=5)
sum[f]+=buf[n+f]; sum[f]+=buf[n+f];
for(f=0; f<b; f++) for(f=0; f<b; f++)
{ {
m=match(p, sum, -1, -1, &d); m=match(p, sum, -1, -1, &d);
if(d>=p->threshold) if(d>=p->threshold)
pbuf[f]=m; pbuf[f]=m;
if(f<b-1) if(f<b-1)
for(n=0; n<5; n++) for(n=0; n<5; n++)
sum[n]=sum[n]-buf[5*(f-3)+n]+buf[5*(f+4)+n]; sum[n]=sum[n]-buf[5*(f-3)+n]+buf[5*(f+4)+n];
} }
/* fill in the gaps */ /* fill in the gaps */
@@ -490,7 +490,7 @@ static int analyze(struct vf_instance *vf)
{ {
free(buf-15); free(buf-15);
MP_FATAL(vf, "%s: No telecine pattern found!\n", MP_FATAL(vf, "%s: No telecine pattern found!\n",
vf_info_divtc.name); vf_info_divtc.name);
return 0; return 0;
} }
@@ -508,56 +508,56 @@ static int analyze(struct vf_instance *vf)
for(n=f; pbuf[n]==-1; n++); for(n=f; pbuf[n]==-1; n++);
if(pbuf[f-1]==pbuf[n]) if(pbuf[f-1]==pbuf[n])
{ {
/* just a gap */ /* just a gap */
while(f<n) pbuf[f++]=pbuf[n]; while(f<n) pbuf[f++]=pbuf[n];
} }
else else
{ {
/* phase change, reanalyze the original data in the gap with zero /* phase change, reanalyze the original data in the gap with zero
threshold for only the two phases that appear at the ends */ threshold for only the two phases that appear at the ends */
for(i=0; i<5; i++) for(i=0; i<5; i++)
for(sum[i]=0, j=5*f-15; j<5*f; j+=5) for(sum[i]=0, j=5*f-15; j<5*f; j+=5)
sum[i]+=buf[i+j]; sum[i]+=buf[i+j];
for(i=f; i<n; i++) for(i=f; i<n; i++)
{ {
pbuf[i]=match(p, sum, pbuf[f-1], pbuf[n], 0); pbuf[i]=match(p, sum, pbuf[f-1], pbuf[n], 0);
for(j=0; j<5; j++) for(j=0; j<5; j++)
sum[j]=sum[j]-buf[5*(i-3)+j]+buf[5*(i+4)+j]; sum[j]=sum[j]-buf[5*(i-3)+j]+buf[5*(i+4)+j];
} }
/* estimate the transition point by dividing the gap /* estimate the transition point by dividing the gap
in the same proportion as the number of matches of each kind */ in the same proportion as the number of matches of each kind */
for(i=f, m=f; i<n; i++) for(i=f, m=f; i<n; i++)
if(pbuf[i]==pbuf[f-1]) m++; if(pbuf[i]==pbuf[f-1]) m++;
/* find the transition of the right direction nearest to the /* find the transition of the right direction nearest to the
estimated point */ estimated point */
if(m>f && m<n) if(m>f && m<n)
{ {
for(j=m; j>f; j--) for(j=m; j>f; j--)
if(pbuf[j-1]==pbuf[f-1] && pbuf[j]==pbuf[n]) break; if(pbuf[j-1]==pbuf[f-1] && pbuf[j]==pbuf[n]) break;
for(s=m; s<n; s++) for(s=m; s<n; s++)
if(pbuf[s-1]==pbuf[f-1] && pbuf[s]==pbuf[n]) break; if(pbuf[s-1]==pbuf[f-1] && pbuf[s]==pbuf[n]) break;
m=(s-m<m-j)?s:j; m=(s-m<m-j)?s:j;
} }
/* and rewrite the data to allow only this one transition */ /* and rewrite the data to allow only this one transition */
for(i=f; i<m; i++) for(i=f; i<m; i++)
pbuf[i]=pbuf[f-1]; pbuf[i]=pbuf[f-1];
for(; i<n; i++) for(; i<n; i++)
pbuf[i]=pbuf[n]; pbuf[i]=pbuf[n];
f=n; f=n;
} }
} }
free(buf-15); free(buf-15);
@@ -573,7 +573,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
case IMGFMT_422P: case IMGFMT_UYVY: case IMGFMT_BGR24: case IMGFMT_422P: case IMGFMT_UYVY: case IMGFMT_BGR24:
case IMGFMT_411P: case IMGFMT_YUYV: case IMGFMT_410P: case IMGFMT_411P: case IMGFMT_YUYV: case IMGFMT_410P:
case IMGFMT_420P: case IMGFMT_Y8: case IMGFMT_420P: case IMGFMT_Y8:
return vf_next_query_format(vf,fmt); return vf_next_query_format(vf,fmt);
} }
return 0; return 0;
@@ -617,27 +617,27 @@ static int vf_open(vf_instance_t *vf)
switch(p->pass) switch(p->pass)
{ {
case 1: case 1:
if(!(p->file=fopen(p->filename, "w"))) if(!(p->file=fopen(p->filename, "w")))
{ {
MP_FATAL(vf, "%s: Can't create file %s.\n", vf->info->name, p->filename); MP_FATAL(vf, "%s: Can't create file %s.\n", vf->info->name, p->filename);
goto fail; goto fail;
} }
break; break;
case 2: case 2:
if(!(p->file=fopen(p->filename, "r"))) if(!(p->file=fopen(p->filename, "r")))
{ {
MP_FATAL(vf, "%s: Can't open file %s.\n", vf->info->name, p->filename); MP_FATAL(vf, "%s: Can't open file %s.\n", vf->info->name, p->filename);
goto fail; goto fail;
} }
if(!analyze(vf)) if(!analyze(vf))
goto fail; goto fail;
fclose(p->file); fclose(p->file);
p->file=0; p->file=0;
break; break;
} }
if(!(p->history=calloc(sizeof *p->history, p->window))) if(!(p->history=calloc(sizeof *p->history, p->window)))

View File

@@ -60,7 +60,7 @@ static struct vf_priv_s {
static int config(struct vf_instance *vf, static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height, int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt) unsigned int flags, unsigned int outfmt)
{ {
vf->priv->exp_x = vf->priv->cfg_exp_x; vf->priv->exp_x = vf->priv->cfg_exp_x;
vf->priv->exp_y = vf->priv->cfg_exp_y; vf->priv->exp_y = vf->priv->cfg_exp_y;

View File

@@ -44,7 +44,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){
if(fmt==vf->priv->fmt) { if(fmt==vf->priv->fmt) {
if (vf->priv->outfmt) if (vf->priv->outfmt)
fmt = vf->priv->outfmt; fmt = vf->priv->outfmt;
return vf_next_query_format(vf,fmt); return vf_next_query_format(vf,fmt);
} }
return 0; return 0;
} }

View File

@@ -40,7 +40,7 @@ static struct vf_priv_s {
static int query_format(struct vf_instance *vf, unsigned int fmt){ static int query_format(struct vf_instance *vf, unsigned int fmt){
if(fmt!=vf->priv->fmt) if(fmt!=vf->priv->fmt)
return vf_next_query_format(vf,fmt); return vf_next_query_format(vf,fmt);
return 0; return 0;
} }

View File

@@ -50,20 +50,20 @@ static void (*lineNoise)(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int
static void (*lineNoiseAvg)(uint8_t *dst, uint8_t *src, int len, int8_t **shift)= lineNoiseAvg_C; static void (*lineNoiseAvg)(uint8_t *dst, uint8_t *src, int len, int8_t **shift)= lineNoiseAvg_C;
typedef struct FilterParam{ typedef struct FilterParam{
int strength; int strength;
int uniform; int uniform;
int temporal; int temporal;
int quality; int quality;
int averaged; int averaged;
int pattern; int pattern;
int shiftptr; int shiftptr;
int8_t *noise; int8_t *noise;
int8_t *prev_shift[MAX_RES][3]; int8_t *prev_shift[MAX_RES][3];
}FilterParam; }FilterParam;
struct vf_priv_s { struct vf_priv_s {
FilterParam lumaParam; FilterParam lumaParam;
FilterParam chromaParam; FilterParam chromaParam;
int strength; int strength;
int averaged; int averaged;
int pattern; int pattern;
@@ -82,245 +82,245 @@ static int patt[4] = {
#define RAND_N(range) ((int) ((double)range*rand()/(RAND_MAX+1.0))) #define RAND_N(range) ((int) ((double)range*rand()/(RAND_MAX+1.0)))
static int8_t *initNoise(FilterParam *fp){ static int8_t *initNoise(FilterParam *fp){
int strength= fp->strength; int strength= fp->strength;
int uniform= fp->uniform; int uniform= fp->uniform;
int averaged= fp->averaged; int averaged= fp->averaged;
int pattern= fp->pattern; int pattern= fp->pattern;
int8_t *noise= av_malloc(MAX_NOISE*sizeof(int8_t)); int8_t *noise= av_malloc(MAX_NOISE*sizeof(int8_t));
int i, j; int i, j;
srand(123457); srand(123457);
for(i=0,j=0; i<MAX_NOISE; i++,j++) for(i=0,j=0; i<MAX_NOISE; i++,j++)
{ {
if(uniform) { if(uniform) {
if (averaged) { if (averaged) {
if (pattern) { if (pattern) {
noise[i]= (RAND_N(strength) - strength/2)/6 noise[i]= (RAND_N(strength) - strength/2)/6
+patt[j%4]*strength*0.25/3; +patt[j%4]*strength*0.25/3;
} else { } else {
noise[i]= (RAND_N(strength) - strength/2)/3; noise[i]= (RAND_N(strength) - strength/2)/3;
} }
} else { } else {
if (pattern) { if (pattern) {
noise[i]= (RAND_N(strength) - strength/2)/2 noise[i]= (RAND_N(strength) - strength/2)/2
+ patt[j%4]*strength*0.25; + patt[j%4]*strength*0.25;
} else { } else {
noise[i]= RAND_N(strength) - strength/2; noise[i]= RAND_N(strength) - strength/2;
} }
} }
} else { } else {
double x1, x2, w, y1; double x1, x2, w, y1;
do { do {
x1 = 2.0 * rand()/(float)RAND_MAX - 1.0; x1 = 2.0 * rand()/(float)RAND_MAX - 1.0;
x2 = 2.0 * rand()/(float)RAND_MAX - 1.0; x2 = 2.0 * rand()/(float)RAND_MAX - 1.0;
w = x1 * x1 + x2 * x2; w = x1 * x1 + x2 * x2;
} while ( w >= 1.0 ); } while ( w >= 1.0 );
w = sqrt( (-2.0 * log( w ) ) / w ); w = sqrt( (-2.0 * log( w ) ) / w );
y1= x1 * w; y1= x1 * w;
y1*= strength / sqrt(3.0); y1*= strength / sqrt(3.0);
if (pattern) { if (pattern) {
y1 /= 2; y1 /= 2;
y1 += patt[j%4]*strength*0.35; y1 += patt[j%4]*strength*0.35;
} }
if (y1<-128) y1=-128; if (y1<-128) y1=-128;
else if(y1> 127) y1= 127; else if(y1> 127) y1= 127;
if (averaged) y1 /= 3.0; if (averaged) y1 /= 3.0;
noise[i]= (int)y1; noise[i]= (int)y1;
} }
if (RAND_N(6) == 0) j--; if (RAND_N(6) == 0) j--;
} }
for (i = 0; i < MAX_RES; i++) for (i = 0; i < MAX_RES; i++)
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
fp->prev_shift[i][j] = noise + (rand()&(MAX_SHIFT-1)); fp->prev_shift[i][j] = noise + (rand()&(MAX_SHIFT-1));
if(!nonTempRandShift_init){ if(!nonTempRandShift_init){
for(i=0; i<MAX_RES; i++){ for(i=0; i<MAX_RES; i++){
nonTempRandShift[i]= rand()&(MAX_SHIFT-1); nonTempRandShift[i]= rand()&(MAX_SHIFT-1);
} }
nonTempRandShift_init = 1; nonTempRandShift_init = 1;
} }
fp->noise= noise; fp->noise= noise;
fp->shiftptr= 0; fp->shiftptr= 0;
return noise; return noise;
} }
/***************************************************************************/ /***************************************************************************/
#if HAVE_MMX #if HAVE_MMX
static inline void lineNoise_MMX(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){ static inline void lineNoise_MMX(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){
x86_reg mmx_len= len&(~7); x86_reg mmx_len= len&(~7);
noise+=shift; noise+=shift;
__asm__ volatile( __asm__ volatile(
"mov %3, %%"REG_a" \n\t" "mov %3, %%"REG_a" \n\t"
"pcmpeqb %%mm7, %%mm7 \n\t" "pcmpeqb %%mm7, %%mm7 \n\t"
"psllw $15, %%mm7 \n\t" "psllw $15, %%mm7 \n\t"
"packsswb %%mm7, %%mm7 \n\t" "packsswb %%mm7, %%mm7 \n\t"
".align 4 \n\t" ".align 4 \n\t"
"1: \n\t" "1: \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t" "movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq (%1, %%"REG_a"), %%mm1 \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t"
"pxor %%mm7, %%mm0 \n\t" "pxor %%mm7, %%mm0 \n\t"
"paddsb %%mm1, %%mm0 \n\t" "paddsb %%mm1, %%mm0 \n\t"
"pxor %%mm7, %%mm0 \n\t" "pxor %%mm7, %%mm0 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t" "add $8, %%"REG_a" \n\t"
" js 1b \n\t" " js 1b \n\t"
:: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len) :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len)
: "%"REG_a : "%"REG_a
); );
if(mmx_len!=len) if(mmx_len!=len)
lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0); lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0);
} }
#endif #endif
//duplicate of previous except movntq //duplicate of previous except movntq
#if HAVE_MMX2 #if HAVE_MMX2
static inline void lineNoise_MMX2(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){ static inline void lineNoise_MMX2(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){
x86_reg mmx_len= len&(~7); x86_reg mmx_len= len&(~7);
noise+=shift; noise+=shift;
__asm__ volatile( __asm__ volatile(
"mov %3, %%"REG_a" \n\t" "mov %3, %%"REG_a" \n\t"
"pcmpeqb %%mm7, %%mm7 \n\t" "pcmpeqb %%mm7, %%mm7 \n\t"
"psllw $15, %%mm7 \n\t" "psllw $15, %%mm7 \n\t"
"packsswb %%mm7, %%mm7 \n\t" "packsswb %%mm7, %%mm7 \n\t"
".align 4 \n\t" ".align 4 \n\t"
"1: \n\t" "1: \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t" "movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq (%1, %%"REG_a"), %%mm1 \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t"
"pxor %%mm7, %%mm0 \n\t" "pxor %%mm7, %%mm0 \n\t"
"paddsb %%mm1, %%mm0 \n\t" "paddsb %%mm1, %%mm0 \n\t"
"pxor %%mm7, %%mm0 \n\t" "pxor %%mm7, %%mm0 \n\t"
"movntq %%mm0, (%2, %%"REG_a") \n\t" "movntq %%mm0, (%2, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t" "add $8, %%"REG_a" \n\t"
" js 1b \n\t" " js 1b \n\t"
:: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len) :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len)
: "%"REG_a : "%"REG_a
); );
if(mmx_len!=len) if(mmx_len!=len)
lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0); lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0);
} }
#endif #endif
static inline void lineNoise_C(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){ static inline void lineNoise_C(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){
int i; int i;
noise+= shift; noise+= shift;
for(i=0; i<len; i++) for(i=0; i<len; i++)
{ {
int v= src[i]+ noise[i]; int v= src[i]+ noise[i];
if(v>255) dst[i]=255; //FIXME optimize if(v>255) dst[i]=255; //FIXME optimize
else if(v<0) dst[i]=0; else if(v<0) dst[i]=0;
else dst[i]=v; else dst[i]=v;
} }
} }
/***************************************************************************/ /***************************************************************************/
#if HAVE_MMX #if HAVE_MMX
static inline void lineNoiseAvg_MMX(uint8_t *dst, uint8_t *src, int len, int8_t **shift){ static inline void lineNoiseAvg_MMX(uint8_t *dst, uint8_t *src, int len, int8_t **shift){
x86_reg mmx_len= len&(~7); x86_reg mmx_len= len&(~7);
uint8_t *src_mmx_len = src+mmx_len; uint8_t *src_mmx_len = src+mmx_len;
__asm__ volatile( __asm__ volatile(
"push %%"REG_BP" \n\t" "push %%"REG_BP" \n\t"
"mov %0, %%"REG_BP" \n\t" "mov %0, %%"REG_BP" \n\t"
"mov %5, %%"REG_a" \n\t" "mov %5, %%"REG_a" \n\t"
".align 4 \n\t" ".align 4 \n\t"
"1: \n\t" "1: \n\t"
"movq (%1, %%"REG_a"), %%mm1 \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t"
"movq (%%"REG_BP", %%"REG_a"), %%mm0 \n\t" "movq (%%"REG_BP", %%"REG_a"), %%mm0 \n\t"
"paddb (%2, %%"REG_a"), %%mm1 \n\t" "paddb (%2, %%"REG_a"), %%mm1 \n\t"
"paddb (%3, %%"REG_a"), %%mm1 \n\t" "paddb (%3, %%"REG_a"), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t" "movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t" "movq %%mm1, %%mm3 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t" "punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm2, %%mm2 \n\t" "punpckhbw %%mm2, %%mm2 \n\t"
"punpcklbw %%mm1, %%mm1 \n\t" "punpcklbw %%mm1, %%mm1 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t" "punpckhbw %%mm3, %%mm3 \n\t"
"pmulhw %%mm0, %%mm1 \n\t" "pmulhw %%mm0, %%mm1 \n\t"
"pmulhw %%mm2, %%mm3 \n\t" "pmulhw %%mm2, %%mm3 \n\t"
"paddw %%mm1, %%mm1 \n\t" "paddw %%mm1, %%mm1 \n\t"
"paddw %%mm3, %%mm3 \n\t" "paddw %%mm3, %%mm3 \n\t"
"paddw %%mm0, %%mm1 \n\t" "paddw %%mm0, %%mm1 \n\t"
"paddw %%mm2, %%mm3 \n\t" "paddw %%mm2, %%mm3 \n\t"
"psrlw $8, %%mm1 \n\t" "psrlw $8, %%mm1 \n\t"
"psrlw $8, %%mm3 \n\t" "psrlw $8, %%mm3 \n\t"
"packuswb %%mm3, %%mm1 \n\t" "packuswb %%mm3, %%mm1 \n\t"
"movq %%mm1, (%4, %%"REG_a") \n\t" "movq %%mm1, (%4, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t" "add $8, %%"REG_a" \n\t"
" js 1b \n\t" " js 1b \n\t"
"pop %%"REG_BP" \n\t" "pop %%"REG_BP" \n\t"
:: "g" (src_mmx_len), "r" (shift[0]+mmx_len), :: "g" (src_mmx_len), "r" (shift[0]+mmx_len),
"r" (shift[1]+mmx_len), "r" (shift[2]+mmx_len), "r" (shift[1]+mmx_len), "r" (shift[2]+mmx_len),
"r" (dst+mmx_len), "g" (-mmx_len) "r" (dst+mmx_len), "g" (-mmx_len)
: "%"REG_a : "%"REG_a
); );
if(mmx_len!=len){ if(mmx_len!=len){
int8_t *shift2[3]={shift[0]+mmx_len, shift[1]+mmx_len, shift[2]+mmx_len}; int8_t *shift2[3]={shift[0]+mmx_len, shift[1]+mmx_len, shift[2]+mmx_len};
lineNoiseAvg_C(dst+mmx_len, src+mmx_len, len-mmx_len, shift2); lineNoiseAvg_C(dst+mmx_len, src+mmx_len, len-mmx_len, shift2);
} }
} }
#endif #endif
static inline void lineNoiseAvg_C(uint8_t *dst, uint8_t *src, int len, int8_t **shift){ static inline void lineNoiseAvg_C(uint8_t *dst, uint8_t *src, int len, int8_t **shift){
int i; int i;
int8_t *src2= (int8_t*)src; int8_t *src2= (int8_t*)src;
for(i=0; i<len; i++) for(i=0; i<len; i++)
{ {
const int n= shift[0][i] + shift[1][i] + shift[2][i]; const int n= shift[0][i] + shift[1][i] + shift[2][i];
dst[i]= src2[i]+((n*src2[i])>>7); dst[i]= src2[i]+((n*src2[i])>>7);
} }
} }
/***************************************************************************/ /***************************************************************************/
static void donoise(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height, FilterParam *fp){ static void donoise(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height, FilterParam *fp){
int8_t *noise= fp->noise; int8_t *noise= fp->noise;
int y; int y;
int shift=0; int shift=0;
if(!noise) if(!noise)
{ {
if(src==dst) return; if(src==dst) return;
if(dstStride==srcStride) memcpy(dst, src, srcStride*height); if(dstStride==srcStride) memcpy(dst, src, srcStride*height);
else else
{ {
for(y=0; y<height; y++) for(y=0; y<height; y++)
{ {
memcpy(dst, src, width); memcpy(dst, src, width);
dst+= dstStride; dst+= dstStride;
src+= srcStride; src+= srcStride;
} }
} }
return; return;
} }
for(y=0; y<height; y++) for(y=0; y<height; y++)
{ {
if(fp->temporal) shift= rand()&(MAX_SHIFT -1); if(fp->temporal) shift= rand()&(MAX_SHIFT -1);
else shift= nonTempRandShift[y]; else shift= nonTempRandShift[y];
if(fp->quality==0) shift&= ~7; if(fp->quality==0) shift&= ~7;
if (fp->averaged) { if (fp->averaged) {
lineNoiseAvg(dst, src, width, fp->prev_shift[y]); lineNoiseAvg(dst, src, width, fp->prev_shift[y]);
fp->prev_shift[y][fp->shiftptr] = noise + shift; fp->prev_shift[y][fp->shiftptr] = noise + shift;
} else { } else {
lineNoise(dst, src, noise, width, shift); lineNoise(dst, src, noise, width, shift);
} }
dst+= dstStride; dst+= dstStride;
src+= srcStride; src+= srcStride;
} }
fp->shiftptr++; fp->shiftptr++;
if (fp->shiftptr == 3) fp->shiftptr = 0; if (fp->shiftptr == 3) fp->shiftptr = 0;
} }
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
@@ -331,52 +331,52 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
mp_image_copy_attributes(dmpi, mpi); mp_image_copy_attributes(dmpi, mpi);
} }
donoise(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam); donoise(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam);
donoise(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam); donoise(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam);
donoise(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2, &vf->priv->chromaParam); donoise(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2, &vf->priv->chromaParam);
#if HAVE_MMX #if HAVE_MMX
if(gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t"); if(gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t");
#endif #endif
#if HAVE_MMX2 #if HAVE_MMX2
if(gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t"); if(gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t");
#endif #endif
if (dmpi != mpi) if (dmpi != mpi)
talloc_free(mpi); talloc_free(mpi);
return dmpi; return dmpi;
} }
static void uninit(struct vf_instance *vf){ static void uninit(struct vf_instance *vf){
if(!vf->priv) return; if(!vf->priv) return;
av_free(vf->priv->chromaParam.noise); av_free(vf->priv->chromaParam.noise);
vf->priv->chromaParam.noise= NULL; vf->priv->chromaParam.noise= NULL;
av_free(vf->priv->lumaParam.noise); av_free(vf->priv->lumaParam.noise);
vf->priv->lumaParam.noise= NULL; vf->priv->lumaParam.noise= NULL;
} }
//===========================================================================// //===========================================================================//
static int query_format(struct vf_instance *vf, unsigned int fmt){ static int query_format(struct vf_instance *vf, unsigned int fmt){
switch(fmt) switch(fmt)
{ {
case IMGFMT_420P: case IMGFMT_420P:
return vf_next_query_format(vf,IMGFMT_420P); return vf_next_query_format(vf,IMGFMT_420P);
} }
return 0; return 0;
} }
static void parse(FilterParam *fp, struct vf_priv_s *p){ static void parse(FilterParam *fp, struct vf_priv_s *p){
fp->strength= p->strength; fp->strength= p->strength;
fp->uniform=p->uniform; fp->uniform=p->uniform;
fp->temporal=p->temporal; fp->temporal=p->temporal;
fp->quality=p->hq; fp->quality=p->hq;
fp->pattern=p->pattern; fp->pattern=p->pattern;
fp->averaged=p->averaged; fp->averaged=p->averaged;
if(fp->strength) initNoise(fp); if(fp->strength) initNoise(fp);
} }
static int vf_open(vf_instance_t *vf){ static int vf_open(vf_instance_t *vf){

View File

@@ -34,8 +34,8 @@
#include "vf_lavfi.h" #include "vf_lavfi.h"
enum mode { PROGRESSIVE, TOP_FIRST, BOTTOM_FIRST, enum mode { PROGRESSIVE, TOP_FIRST, BOTTOM_FIRST,
TOP_FIRST_ANALYZE, BOTTOM_FIRST_ANALYZE, TOP_FIRST_ANALYZE, BOTTOM_FIRST_ANALYZE,
ANALYZE, FULL_ANALYZE, AUTO, AUTO_ANALYZE }; ANALYZE, FULL_ANALYZE, AUTO, AUTO_ANALYZE };
#define fixed_mode(p) ((p)<=BOTTOM_FIRST) #define fixed_mode(p) ((p)<=BOTTOM_FIRST)
@@ -53,8 +53,8 @@ struct vf_priv_s
*/ */
static void do_plane(unsigned char *to, unsigned char *from, static void do_plane(unsigned char *to, unsigned char *from,
int w, int h, int ts, int fs, int w, int h, int ts, int fs,
unsigned char **bufp, enum mode mode) unsigned char **bufp, enum mode mode)
{ {
unsigned char *buf, *end; unsigned char *buf, *end;
int top; int top;
@@ -90,8 +90,8 @@ static void do_plane(unsigned char *to, unsigned char *from,
static enum mode analyze_plane(struct vf_instance *vf, static enum mode analyze_plane(struct vf_instance *vf,
unsigned char *old, unsigned char *new, unsigned char *old, unsigned char *new,
int w, int h, int os, int ns, enum mode mode, int w, int h, int os, int ns, enum mode mode,
int unused, int fields) int unused, int fields)
{ {
double bdiff, pdiff, tdiff, scale; double bdiff, pdiff, tdiff, scale;
int bdif, tdif, pdif; int bdif, tdif, pdif;
@@ -100,10 +100,10 @@ static enum mode analyze_plane(struct vf_instance *vf,
if(mode==AUTO) if(mode==AUTO)
mode=fields&MP_IMGFIELD_ORDERED?fields&MP_IMGFIELD_TOP_FIRST? mode=fields&MP_IMGFIELD_ORDERED?fields&MP_IMGFIELD_TOP_FIRST?
TOP_FIRST:BOTTOM_FIRST:PROGRESSIVE; TOP_FIRST:BOTTOM_FIRST:PROGRESSIVE;
else if(mode==AUTO_ANALYZE) else if(mode==AUTO_ANALYZE)
mode=fields&MP_IMGFIELD_ORDERED?fields&MP_IMGFIELD_TOP_FIRST? mode=fields&MP_IMGFIELD_ORDERED?fields&MP_IMGFIELD_TOP_FIRST?
TOP_FIRST_ANALYZE:BOTTOM_FIRST_ANALYZE:FULL_ANALYZE; TOP_FIRST_ANALYZE:BOTTOM_FIRST_ANALYZE:FULL_ANALYZE;
if(fixed_mode(mode)) if(fixed_mode(mode))
bdiff=pdiff=tdiff=65536.0; bdiff=pdiff=tdiff=65536.0;
@@ -112,62 +112,62 @@ static enum mode analyze_plane(struct vf_instance *vf,
bdiff=pdiff=tdiff=0.0; bdiff=pdiff=tdiff=0.0;
for(end=new+(h-2)*ns, new+=ns, old+=os, top=0; for(end=new+(h-2)*ns, new+=ns, old+=os, top=0;
new<end; new+=ns-w, old+=os-w, top^=1) new<end; new+=ns-w, old+=os-w, top^=1)
{ {
pdif=tdif=bdif=0; pdif=tdif=bdif=0;
switch(mode) switch(mode)
{ {
case TOP_FIRST_ANALYZE: case TOP_FIRST_ANALYZE:
if(top) if(top)
for(rend=new+w; new<rend; new++, old++) for(rend=new+w; new<rend; new++, old++)
pdif+=diff(new, ns, new, ns), pdif+=diff(new, ns, new, ns),
tdif+=diff(new, ns, old, os); tdif+=diff(new, ns, old, os);
else else
for(rend=new+w; new<rend; new++, old++) for(rend=new+w; new<rend; new++, old++)
pdif+=diff(new, ns, new, ns), pdif+=diff(new, ns, new, ns),
tdif+=diff(old, os, new, ns);
break;
case BOTTOM_FIRST_ANALYZE:
if(top)
for(rend=new+w; new<rend; new++, old++)
pdif+=diff(new, ns, new, ns),
bdif+=diff(old, os, new, ns);
else
for(rend=new+w; new<rend; new++, old++)
pdif+=diff(new, ns, new, ns),
bdif+=diff(new, ns, old, os);
break;
case ANALYZE:
if(top)
for(rend=new+w; new<rend; new++, old++)
tdif+=diff(new, ns, old, os),
bdif+=diff(old, os, new, ns);
else
for(rend=new+w; new<rend; new++, old++)
bdif+=diff(new, ns, old, os),
tdif+=diff(old, os, new, ns); tdif+=diff(old, os, new, ns);
break; break;
default: /* FULL_ANALYZE */ case BOTTOM_FIRST_ANALYZE:
if(top) if(top)
for(rend=new+w; new<rend; new++, old++) for(rend=new+w; new<rend; new++, old++)
pdif+=diff(new, ns, new, ns), pdif+=diff(new, ns, new, ns),
tdif+=diff(new, ns, old, os), bdif+=diff(old, os, new, ns);
bdif+=diff(old, os, new, ns); else
else for(rend=new+w; new<rend; new++, old++)
for(rend=new+w; new<rend; new++, old++) pdif+=diff(new, ns, new, ns),
pdif+=diff(new, ns, new, ns), bdif+=diff(new, ns, old, os);
bdif+=diff(new, ns, old, os), break;
tdif+=diff(old, os, new, ns);
}
pdiff+=(double)pdif; case ANALYZE:
tdiff+=(double)tdif; if(top)
bdiff+=(double)bdif; for(rend=new+w; new<rend; new++, old++)
} tdif+=diff(new, ns, old, os),
bdif+=diff(old, os, new, ns);
else
for(rend=new+w; new<rend; new++, old++)
bdif+=diff(new, ns, old, os),
tdif+=diff(old, os, new, ns);
break;
default: /* FULL_ANALYZE */
if(top)
for(rend=new+w; new<rend; new++, old++)
pdif+=diff(new, ns, new, ns),
tdif+=diff(new, ns, old, os),
bdif+=diff(old, os, new, ns);
else
for(rend=new+w; new<rend; new++, old++)
pdif+=diff(new, ns, new, ns),
bdif+=diff(new, ns, old, os),
tdif+=diff(old, os, new, ns);
}
pdiff+=(double)pdif;
tdiff+=(double)tdif;
bdiff+=(double)bdif;
}
scale=1.0/(w*(h-3))/25.0; scale=1.0/(w*(h-3))/25.0;
pdiff*=scale; pdiff*=scale;
@@ -175,18 +175,18 @@ static enum mode analyze_plane(struct vf_instance *vf,
bdiff*=scale; bdiff*=scale;
if(mode==TOP_FIRST_ANALYZE) if(mode==TOP_FIRST_ANALYZE)
bdiff=65536.0; bdiff=65536.0;
else if(mode==BOTTOM_FIRST_ANALYZE) else if(mode==BOTTOM_FIRST_ANALYZE)
tdiff=65536.0; tdiff=65536.0;
else if(mode==ANALYZE) else if(mode==ANALYZE)
pdiff=65536.0; pdiff=65536.0;
if(bdiff<pdiff && bdiff<tdiff) if(bdiff<pdiff && bdiff<tdiff)
mode=BOTTOM_FIRST; mode=BOTTOM_FIRST;
else if(tdiff<pdiff && tdiff<bdiff) else if(tdiff<pdiff && tdiff<bdiff)
mode=TOP_FIRST; mode=TOP_FIRST;
else else
mode=PROGRESSIVE; mode=PROGRESSIVE;
} }
MP_INFO(vf, "%c", mode==BOTTOM_FIRST?'b':mode==TOP_FIRST?'t':'p'); MP_INFO(vf, "%c", mode==BOTTOM_FIRST?'b':mode==TOP_FIRST?'t':'p');
@@ -215,8 +215,8 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
mode=PROGRESSIVE; mode=PROGRESSIVE;
else else
mode=analyze_plane(vf, vf->priv->buf[0], mpi->planes[0], mode=analyze_plane(vf, vf->priv->buf[0], mpi->planes[0],
pw[0], dmpi->h, pw[0], mpi->stride[0], mode, pw[0], dmpi->h, pw[0], mpi->stride[0], mode,
vf->priv->verbose, mpi->fields); vf->priv->verbose, mpi->fields);
for (int p = 0; p < mpi->num_planes; p++) { for (int p = 0; p < mpi->num_planes; p++) {
do_plane(dmpi->planes[p], mpi->planes[p], pw[p], dmpi->plane_h[p], do_plane(dmpi->planes[p], mpi->planes[p], pw[p], dmpi->plane_h[p],

View File

@@ -44,10 +44,10 @@ struct vf_priv_s {
static int config(struct vf_instance *vf, static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height, int width, int height, int d_width, int d_height,
unsigned int voflags, unsigned int outfmt){ unsigned int voflags, unsigned int outfmt){
int flags= int flags=
(gCpuCaps.hasMMX ? PP_CPU_CAPS_MMX : 0) (gCpuCaps.hasMMX ? PP_CPU_CAPS_MMX : 0)
| (gCpuCaps.hasMMX2 ? PP_CPU_CAPS_MMX2 : 0); | (gCpuCaps.hasMMX2 ? PP_CPU_CAPS_MMX2 : 0);
switch(outfmt){ switch(outfmt){
case IMGFMT_444P: flags|= PP_FORMAT_444; break; case IMGFMT_444P: flags|= PP_FORMAT_444; break;
@@ -66,7 +66,7 @@ static void uninit(struct vf_instance *vf){
int i; int i;
for(i=0; i<=PP_QUALITY_MAX; i++){ for(i=0; i<=PP_QUALITY_MAX; i++){
if(vf->priv->ppMode[i]) if(vf->priv->ppMode[i])
pp_free_mode(vf->priv->ppMode[i]); pp_free_mode(vf->priv->ppMode[i]);
} }
if(vf->priv->context) pp_free_context(vf->priv->context); if(vf->priv->context) pp_free_context(vf->priv->context);
} }
@@ -77,7 +77,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){
case IMGFMT_422P: case IMGFMT_422P:
case IMGFMT_420P: case IMGFMT_420P:
case IMGFMT_411P: ; case IMGFMT_411P: ;
return vf_next_query_format(vf,fmt); return vf_next_query_format(vf,fmt);
} }
return 0; return 0;
} }
@@ -99,16 +99,16 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
// apparently this is required // apparently this is required
assert(mpi->stride[0] >= ((mpi->w+7)&(~7))); assert(mpi->stride[0] >= ((mpi->w+7)&(~7)));
// do the postprocessing! (or copy if no DR) // do the postprocessing! (or copy if no DR)
pp_postprocess((const uint8_t **)mpi->planes, mpi->stride, pp_postprocess((const uint8_t **)mpi->planes, mpi->stride,
dmpi->planes,dmpi->stride, dmpi->planes,dmpi->stride,
(mpi->w+7)&(~7),mpi->h, (mpi->w+7)&(~7),mpi->h,
mpi->qscale, mpi->qstride, mpi->qscale, mpi->qstride,
vf->priv->ppMode[ vf->priv->pp ], vf->priv->context, vf->priv->ppMode[ vf->priv->pp ], vf->priv->context,
#ifdef PP_PICT_TYPE_QP2 #ifdef PP_PICT_TYPE_QP2
mpi->pict_type | (mpi->qscale_type ? PP_PICT_TYPE_QP2 : 0)); mpi->pict_type | (mpi->qscale_type ? PP_PICT_TYPE_QP2 : 0));
#else #else
mpi->pict_type); mpi->pict_type);
#endif #endif
if (dmpi != mpi) if (dmpi != mpi)
@@ -124,7 +124,7 @@ static int vf_open(vf_instance_t *vf){
vf->filter=filter; vf->filter=filter;
vf->uninit=uninit; vf->uninit=uninit;
for(i=0; i<=PP_QUALITY_MAX; i++){ for(i=0; i<=PP_QUALITY_MAX; i++){
vf->priv->ppMode[i]= pp_get_mode_by_name_and_quality(vf->priv->arg, i); vf->priv->ppMode[i]= pp_get_mode_by_name_and_quality(vf->priv->arg, i);
if(vf->priv->ppMode[i]==NULL) return -1; if(vf->priv->ppMode[i]==NULL) return -1;
} }

View File

@@ -38,11 +38,11 @@
#define MAX(a,b) ((a)>(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b))
struct vf_priv_s { struct vf_priv_s {
struct pullup_context *ctx; struct pullup_context *ctx;
int init; int init;
int fakecount; int fakecount;
char *qbuf; char *qbuf;
double lastpts; double lastpts;
int junk_left, junk_right, junk_top, junk_bottom; int junk_left, junk_right, junk_top, junk_bottom;
int strict_breaks, metric_plane; int strict_breaks, metric_plane;
struct vf_lw_opts *lw_opts; struct vf_lw_opts *lw_opts;
@@ -68,137 +68,137 @@ static void reset(struct vf_instance *vf)
static void init_pullup(struct vf_instance *vf, mp_image_t *mpi) static void init_pullup(struct vf_instance *vf, mp_image_t *mpi)
{ {
struct pullup_context *c = vf->priv->ctx; struct pullup_context *c = vf->priv->ctx;
c->format = PULLUP_FMT_Y; c->format = PULLUP_FMT_Y;
c->nplanes = 4; c->nplanes = 4;
pullup_preinit_context(c); pullup_preinit_context(c);
c->bpp[0] = c->bpp[1] = c->bpp[2] = 8; c->bpp[0] = c->bpp[1] = c->bpp[2] = 8;
c->w[0] = mpi->w; c->w[0] = mpi->w;
c->h[0] = mpi->h; c->h[0] = mpi->h;
c->w[1] = c->w[2] = mpi->chroma_width; c->w[1] = c->w[2] = mpi->chroma_width;
c->h[1] = c->h[2] = mpi->chroma_height; c->h[1] = c->h[2] = mpi->chroma_height;
c->w[3] = ((mpi->w+15)/16) * ((mpi->h+15)/16); c->w[3] = ((mpi->w+15)/16) * ((mpi->h+15)/16);
c->h[3] = 2; c->h[3] = 2;
c->stride[0] = mpi->w; c->stride[0] = mpi->w;
c->stride[1] = c->stride[2] = mpi->chroma_width; c->stride[1] = c->stride[2] = mpi->chroma_width;
c->stride[3] = c->w[3]; c->stride[3] = c->w[3];
c->background[1] = c->background[2] = 128; c->background[1] = c->background[2] = 128;
if (gCpuCaps.hasMMX) c->cpu |= PULLUP_CPU_MMX; if (gCpuCaps.hasMMX) c->cpu |= PULLUP_CPU_MMX;
if (gCpuCaps.hasMMX2) c->cpu |= PULLUP_CPU_MMX2; if (gCpuCaps.hasMMX2) c->cpu |= PULLUP_CPU_MMX2;
if (gCpuCaps.hasSSE) c->cpu |= PULLUP_CPU_SSE; if (gCpuCaps.hasSSE) c->cpu |= PULLUP_CPU_SSE;
if (gCpuCaps.hasSSE2) c->cpu |= PULLUP_CPU_SSE2; if (gCpuCaps.hasSSE2) c->cpu |= PULLUP_CPU_SSE2;
pullup_init_context(c); pullup_init_context(c);
vf->priv->init = 1; vf->priv->init = 1;
vf->priv->qbuf = malloc(c->w[3]); vf->priv->qbuf = malloc(c->w[3]);
} }
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
{ {
struct pullup_context *c = vf->priv->ctx; struct pullup_context *c = vf->priv->ctx;
struct pullup_buffer *b; struct pullup_buffer *b;
struct pullup_frame *f; struct pullup_frame *f;
int p; int p;
int i; int i;
double pts = mpi->pts; double pts = mpi->pts;
struct mp_image *dmpi = NULL; struct mp_image *dmpi = NULL;
if (!vf->priv->init) init_pullup(vf, mpi); if (!vf->priv->init) init_pullup(vf, mpi);
if (1) { if (1) {
b = pullup_get_buffer(c, 2); b = pullup_get_buffer(c, 2);
if (!b) { if (!b) {
MP_ERR(vf, "Could not get buffer from pullup!\n"); MP_ERR(vf, "Could not get buffer from pullup!\n");
f = pullup_get_frame(c); f = pullup_get_frame(c);
pullup_release_frame(f); pullup_release_frame(f);
goto skip; goto skip;
} }
memcpy_pic(b->planes[0], mpi->planes[0], mpi->w, mpi->h, memcpy_pic(b->planes[0], mpi->planes[0], mpi->w, mpi->h,
c->stride[0], mpi->stride[0]); c->stride[0], mpi->stride[0]);
memcpy_pic(b->planes[1], mpi->planes[1], memcpy_pic(b->planes[1], mpi->planes[1],
mpi->chroma_width, mpi->chroma_height, mpi->chroma_width, mpi->chroma_height,
c->stride[1], mpi->stride[1]); c->stride[1], mpi->stride[1]);
memcpy_pic(b->planes[2], mpi->planes[2], memcpy_pic(b->planes[2], mpi->planes[2],
mpi->chroma_width, mpi->chroma_height, mpi->chroma_width, mpi->chroma_height,
c->stride[2], mpi->stride[2]); c->stride[2], mpi->stride[2]);
} }
if (mpi->qscale) { if (mpi->qscale) {
memcpy(b->planes[3], mpi->qscale, c->w[3]); memcpy(b->planes[3], mpi->qscale, c->w[3]);
memcpy(b->planes[3]+c->w[3], mpi->qscale, c->w[3]); memcpy(b->planes[3]+c->w[3], mpi->qscale, c->w[3]);
} }
p = mpi->fields & MP_IMGFIELD_TOP_FIRST ? 0 : p = mpi->fields & MP_IMGFIELD_TOP_FIRST ? 0 :
(mpi->fields & MP_IMGFIELD_ORDERED ? 1 : 0); (mpi->fields & MP_IMGFIELD_ORDERED ? 1 : 0);
if (pts == MP_NOPTS_VALUE) { if (pts == MP_NOPTS_VALUE) {
pullup_submit_field(c, b, p, MP_NOPTS_VALUE); pullup_submit_field(c, b, p, MP_NOPTS_VALUE);
pullup_submit_field(c, b, p^1, MP_NOPTS_VALUE); pullup_submit_field(c, b, p^1, MP_NOPTS_VALUE);
if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST) if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST)
pullup_submit_field(c, b, p, MP_NOPTS_VALUE); pullup_submit_field(c, b, p, MP_NOPTS_VALUE);
} else { } else {
double delta; double delta;
if (vf->priv->lastpts == MP_NOPTS_VALUE) if (vf->priv->lastpts == MP_NOPTS_VALUE)
delta = 1001.0/60000.0; // delta = field time distance delta = 1001.0/60000.0; // delta = field time distance
else else
delta = (pts - vf->priv->lastpts) / 2; delta = (pts - vf->priv->lastpts) / 2;
if (delta <= 0.0 || delta >= 0.5) if (delta <= 0.0 || delta >= 0.5)
delta = 0.0; delta = 0.0;
vf->priv->lastpts = pts; vf->priv->lastpts = pts;
if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST) { if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST) {
pullup_submit_field(c, b, p, pts - delta); pullup_submit_field(c, b, p, pts - delta);
pullup_submit_field(c, b, p^1, pts); pullup_submit_field(c, b, p^1, pts);
pullup_submit_field(c, b, p, pts + delta); pullup_submit_field(c, b, p, pts + delta);
} else { } else {
pullup_submit_field(c, b, p, pts - delta * 0.5); pullup_submit_field(c, b, p, pts - delta * 0.5);
pullup_submit_field(c, b, p^1, pts + delta * 0.5); pullup_submit_field(c, b, p^1, pts + delta * 0.5);
} }
} }
pullup_release_buffer(b, 2); pullup_release_buffer(b, 2);
f = pullup_get_frame(c); f = pullup_get_frame(c);
/* Fake yes for first few frames (buffer depth) to keep from /* Fake yes for first few frames (buffer depth) to keep from
* breaking A/V sync with G1's bad architecture... */ * breaking A/V sync with G1's bad architecture... */
//if (!f) return vf->priv->fakecount ? (--vf->priv->fakecount,1) : 0; //if (!f) return vf->priv->fakecount ? (--vf->priv->fakecount,1) : 0;
if (!f) if (!f)
goto skip; goto skip;
if (f->length < 2) { if (f->length < 2) {
pullup_release_frame(f); pullup_release_frame(f);
f = pullup_get_frame(c); f = pullup_get_frame(c);
if (!f) goto skip; if (!f) goto skip;
if (f->length < 2) { if (f->length < 2) {
pullup_release_frame(f); pullup_release_frame(f);
if (!(mpi->fields & MP_IMGFIELD_REPEAT_FIRST)) if (!(mpi->fields & MP_IMGFIELD_REPEAT_FIRST))
goto skip; goto skip;
f = pullup_get_frame(c); f = pullup_get_frame(c);
if (!f) goto skip; if (!f) goto skip;
if (f->length < 2) { if (f->length < 2) {
pullup_release_frame(f); pullup_release_frame(f);
goto skip; goto skip;
} }
} }
} }
#if 0 #if 0
/* Average qscale tables from both frames. */ /* Average qscale tables from both frames. */
if (mpi->qscale) { if (mpi->qscale) {
for (i=0; i<c->w[3]; i++) { for (i=0; i<c->w[3]; i++) {
vf->priv->qbuf[i] = (f->ofields[0]->planes[3][i] vf->priv->qbuf[i] = (f->ofields[0]->planes[3][i]
+ f->ofields[1]->planes[3][i+c->w[3]])>>1; + f->ofields[1]->planes[3][i+c->w[3]])>>1;
} }
} }
#else #else
/* Take worst of qscale tables from both frames. */ /* Take worst of qscale tables from both frames. */
if (mpi->qscale) { if (mpi->qscale) {
for (i=0; i<c->w[3]; i++) { for (i=0; i<c->w[3]; i++) {
vf->priv->qbuf[i] = MAX(f->ofields[0]->planes[3][i], f->ofields[1]->planes[3][i+c->w[3]]); vf->priv->qbuf[i] = MAX(f->ofields[0]->planes[3][i], f->ofields[1]->planes[3][i+c->w[3]]);
} }
} }
#endif #endif
/* If the frame isn't already exportable... */ /* If the frame isn't already exportable... */
@@ -214,53 +214,53 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
struct mp_image data = *dmpi; struct mp_image data = *dmpi;
data.planes[0] = f->buffer->planes[0]; data.planes[0] = f->buffer->planes[0];
data.planes[1] = f->buffer->planes[1]; data.planes[1] = f->buffer->planes[1];
data.planes[2] = f->buffer->planes[2]; data.planes[2] = f->buffer->planes[2];
data.stride[0] = c->stride[0]; data.stride[0] = c->stride[0];
data.stride[1] = c->stride[1]; data.stride[1] = c->stride[1];
data.stride[2] = c->stride[2]; data.stride[2] = c->stride[2];
mp_image_copy(dmpi, &data); mp_image_copy(dmpi, &data);
dmpi->pts = f->pts; dmpi->pts = f->pts;
// Warning: entirely bogus memory management of qscale // Warning: entirely bogus memory management of qscale
if (mpi->qscale) { if (mpi->qscale) {
dmpi->qscale = vf->priv->qbuf; dmpi->qscale = vf->priv->qbuf;
dmpi->qstride = mpi->qstride; dmpi->qstride = mpi->qstride;
dmpi->qscale_type = mpi->qscale_type; dmpi->qscale_type = mpi->qscale_type;
} }
pullup_release_frame(f); pullup_release_frame(f);
skip: skip:
talloc_free(mpi); talloc_free(mpi);
return dmpi; return dmpi;
} }
static int query_format(struct vf_instance *vf, unsigned int fmt) static int query_format(struct vf_instance *vf, unsigned int fmt)
{ {
/* FIXME - support more formats */ /* FIXME - support more formats */
switch (fmt) { switch (fmt) {
case IMGFMT_420P: case IMGFMT_420P:
return vf_next_query_format(vf, fmt); return vf_next_query_format(vf, fmt);
} }
return 0; return 0;
} }
static int config(struct vf_instance *vf, static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height, int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt) unsigned int flags, unsigned int outfmt)
{ {
reset(vf); reset(vf);
if (height&3) return 0; if (height&3) return 0;
return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt); return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
} }
static void uninit(struct vf_instance *vf) static void uninit(struct vf_instance *vf)
{ {
pullup_free_context(vf->priv->ctx); pullup_free_context(vf->priv->ctx);
} }
static int control(vf_instance_t *vf, int request, void *data) static int control(vf_instance_t *vf, int request, void *data)
@@ -275,11 +275,11 @@ static int control(vf_instance_t *vf, int request, void *data)
static int vf_open(vf_instance_t *vf) static int vf_open(vf_instance_t *vf)
{; {;
vf->filter = filter; vf->filter = filter;
vf->config = config; vf->config = config;
vf->query_format = query_format; vf->query_format = query_format;
vf->control = control; vf->control = control;
vf->uninit = uninit; vf->uninit = uninit;
struct vf_priv_s *p = vf->priv; struct vf_priv_s *p = vf->priv;
const char *pname[3] = {"y", "u", "v"}; const char *pname[3] = {"y", "u", "v"};
if (vf_lw_set_graph(vf, p->lw_opts, "pullup", "%d:%d:%d:%d:%d:%s", if (vf_lw_set_graph(vf, p->lw_opts, "pullup", "%d:%d:%d:%d:%d:%s",
@@ -289,7 +289,7 @@ static int vf_open(vf_instance_t *vf)
return 1; return 1;
} }
reset(vf); reset(vf);
return 1; return 1;
} }
#define OPT_BASE_STRUCT struct vf_priv_s #define OPT_BASE_STRUCT struct vf_priv_s

View File

@@ -36,33 +36,33 @@ struct vf_priv_s {
static void rotate(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,int dir){ static void rotate(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,int dir){
int y; int y;
if(dir&1){ if(dir&1){
src+=srcstride*(w-1); src+=srcstride*(w-1);
srcstride*=-1; srcstride*=-1;
} }
if(dir&2){ if(dir&2){
dst+=dststride*(h-1); dst+=dststride*(h-1);
dststride*=-1; dststride*=-1;
} }
for(y=0;y<h;y++){ for(y=0;y<h;y++){
int x; int x;
switch(bpp){ switch(bpp){
case 1: case 1:
for(x=0;x<w;x++) dst[x]=src[y+x*srcstride]; for(x=0;x<w;x++) dst[x]=src[y+x*srcstride];
break; break;
case 2: case 2:
for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+y*2+x*srcstride)); for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+y*2+x*srcstride));
break; break;
case 4: case 4:
for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+y*4+x*srcstride)); for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+y*4+x*srcstride));
default: default:
for(x=0;x<w;x++){ for(x=0;x<w;x++){
for (int b=0;b<bpp;b++) for (int b=0;b<bpp;b++)
dst[x*bpp+b]=src[b+y*bpp+x*srcstride]; dst[x*bpp+b]=src[b+y*bpp+x*srcstride];
} }
break; break;
} }
dst+=dststride; dst+=dststride;
} }
} }

View File

@@ -30,11 +30,11 @@
#include "video/memcpy_pic.h" #include "video/memcpy_pic.h"
struct vf_priv_s { struct vf_priv_s {
int state; int state;
long long in; long long in;
long long out; long long out;
struct vf_detc_pts_buf ptsbuf; struct vf_detc_pts_buf ptsbuf;
int last_frame_duration; int last_frame_duration;
struct mp_image *buffer; struct mp_image *buffer;
}; };
@@ -50,8 +50,8 @@ static void copy_pic_field(struct mp_image *dmpi, struct mp_image *mpi, int f)
static int filter(struct vf_instance *vf, struct mp_image *mpi) static int filter(struct vf_instance *vf, struct mp_image *mpi)
{ {
int flags = mpi->fields; int flags = mpi->fields;
int state = vf->priv->state; int state = vf->priv->state;
struct vf_priv_s *p = vf->priv; struct vf_priv_s *p = vf->priv;
if (!p->buffer || p->buffer->w != mpi->w || p->buffer->h != mpi->h || if (!p->buffer || p->buffer->w != mpi->w || p->buffer->h != mpi->h ||
@@ -65,50 +65,50 @@ static int filter(struct vf_instance *vf, struct mp_image *mpi)
struct mp_image *dmpi = p->buffer; struct mp_image *dmpi = p->buffer;
vf->priv->in++; vf->priv->in++;
if ((state == 0 && if ((state == 0 &&
!(flags & MP_IMGFIELD_TOP_FIRST)) || !(flags & MP_IMGFIELD_TOP_FIRST)) ||
(state == 1 && (state == 1 &&
flags & MP_IMGFIELD_TOP_FIRST)) { flags & MP_IMGFIELD_TOP_FIRST)) {
MP_WARN(vf, "softpulldown: Unexpected field flags: state=%d top_field_first=%d repeat_first_field=%d\n", MP_WARN(vf, "softpulldown: Unexpected field flags: state=%d top_field_first=%d repeat_first_field=%d\n",
state, state,
(flags & MP_IMGFIELD_TOP_FIRST) != 0, (flags & MP_IMGFIELD_TOP_FIRST) != 0,
(flags & MP_IMGFIELD_REPEAT_FIRST) != 0); (flags & MP_IMGFIELD_REPEAT_FIRST) != 0);
state ^= 1; state ^= 1;
} }
if (state == 0) { if (state == 0) {
struct mp_image *new = mp_image_new_ref(mpi); struct mp_image *new = mp_image_new_ref(mpi);
new->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, vf->priv->last_frame_duration); new->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, vf->priv->last_frame_duration);
vf_add_output_frame(vf, new); vf_add_output_frame(vf, new);
vf->priv->out++; vf->priv->out++;
if (flags & MP_IMGFIELD_REPEAT_FIRST) { if (flags & MP_IMGFIELD_REPEAT_FIRST) {
copy_pic_field(dmpi, mpi, 0); copy_pic_field(dmpi, mpi, 0);
state=1; state=1;
} }
} else { } else {
copy_pic_field(dmpi, mpi, 1); copy_pic_field(dmpi, mpi, 1);
struct mp_image *new = mp_image_new_ref(mpi); struct mp_image *new = mp_image_new_ref(mpi);
new->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, vf->priv->last_frame_duration); new->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, vf->priv->last_frame_duration);
vf_add_output_frame(vf, new); vf_add_output_frame(vf, new);
vf->priv->out++; vf->priv->out++;
if (flags & MP_IMGFIELD_REPEAT_FIRST) { if (flags & MP_IMGFIELD_REPEAT_FIRST) {
struct mp_image *new2 = mp_image_new_ref(mpi); struct mp_image *new2 = mp_image_new_ref(mpi);
new2->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, 3); new2->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, 3);
vf_add_output_frame(vf, new2); vf_add_output_frame(vf, new2);
vf->priv->out++; vf->priv->out++;
vf->priv->state=0; vf->priv->state=0;
} else { } else {
copy_pic_field(dmpi, mpi, 0); copy_pic_field(dmpi, mpi, 0);
} }
} }
vf->priv->state = state; vf->priv->state = state;
if (flags & MP_IMGFIELD_REPEAT_FIRST) if (flags & MP_IMGFIELD_REPEAT_FIRST)
vf->priv->last_frame_duration = 3; vf->priv->last_frame_duration = 3;
else else
vf->priv->last_frame_duration = 2; vf->priv->last_frame_duration = 2;
talloc_free(mpi); talloc_free(mpi);
@@ -127,8 +127,8 @@ static int control(vf_instance_t *vf, int request, void *data)
static void uninit(struct vf_instance *vf) static void uninit(struct vf_instance *vf)
{ {
MP_INFO(vf, "softpulldown: %lld frames in, %lld frames out\n", vf->priv->in, vf->priv->out); MP_INFO(vf, "softpulldown: %lld frames in, %lld frames out\n", vf->priv->in, vf->priv->out);
free(vf->priv); free(vf->priv);
} }
static int query_format(struct vf_instance *vf, unsigned int fmt) static int query_format(struct vf_instance *vf, unsigned int fmt)

View File

@@ -74,7 +74,7 @@ static int config(struct vf_instance *vf,
}; };
return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width, return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width,
d_height, flags, outfmt); d_height, flags, outfmt);
} }
static void prepare_image(struct vf_instance *vf, struct mp_image *dmpi, static void prepare_image(struct vf_instance *vf, struct mp_image *dmpi,

View File

@@ -120,13 +120,13 @@ struct voctrl_screenshot_args {
#define VO_TRUE true #define VO_TRUE true
#define VO_FALSE false #define VO_FALSE false
#define VO_ERROR -1 #define VO_ERROR -1
#define VO_NOTAVAIL -2 #define VO_NOTAVAIL -2
#define VO_NOTIMPL -3 #define VO_NOTIMPL -3
#define VOFLAG_FLIPPING 0x08 #define VOFLAG_FLIPPING 0x08
#define VOFLAG_HIDDEN 0x10 //< Use to create a hidden window #define VOFLAG_HIDDEN 0x10 //< Use to create a hidden window
#define VOFLAG_STEREO 0x20 //< Use to create a stereo-capable window #define VOFLAG_STEREO 0x20 //< Use to create a stereo-capable window
#define VOFLAG_GL_DEBUG 0x40 // Hint to request debug OpenGL context #define VOFLAG_GL_DEBUG 0x40 // Hint to request debug OpenGL context
#define VOFLAG_ALPHA 0x80 // Hint to request alpha framebuffer #define VOFLAG_ALPHA 0x80 // Hint to request alpha framebuffer

View File

@@ -8,7 +8,7 @@ by default, all symbols are exported by gcc, and nothing by msvc.
to use the tool, do something like: to use the tool, do something like:
def build(ctx): def build(ctx):
ctx(features='c cshlib syms', source='a.c b.c', export_symbols_regex='mylib_.*', target='testlib') ctx(features='c cshlib syms', source='a.c b.c', export_symbols_regex='mylib_.*', target='testlib')
only the symbols starting with 'mylib_' will be exported. only the symbols starting with 'mylib_' will be exported.
""" """
@@ -21,65 +21,65 @@ from waflib.Errors import WafError
from waflib.TaskGen import feature, after_method from waflib.TaskGen import feature, after_method
class gen_sym(Task): class gen_sym(Task):
def run(self): def run(self):
obj = self.inputs[0] obj = self.inputs[0]
kw = {} kw = {}
if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME): if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME):
re_nm = re.compile(r'External\s+\|\s+_(' + self.generator.export_symbols_regex + r')\b') re_nm = re.compile(r'External\s+\|\s+_(' + self.generator.export_symbols_regex + r')\b')
cmd = [self.env.DUMPBIN or 'dumpbin', '/symbols', obj.abspath()] cmd = [self.env.DUMPBIN or 'dumpbin', '/symbols', obj.abspath()]
# Dumpbin requires custom environment sniffed out by msvc.py earlier # Dumpbin requires custom environment sniffed out by msvc.py earlier
if self.env['PATH']: if self.env['PATH']:
env = dict(self.env.env or os.environ) env = dict(self.env.env or os.environ)
env.update(PATH = os.pathsep.join(self.env['PATH'])) env.update(PATH = os.pathsep.join(self.env['PATH']))
kw['env'] = env kw['env'] = env
else: else:
if self.env.DEST_BINFMT in ('pe', 'mac-o'): #gcc uses nm, and has a preceding _ on windows and osx if self.env.DEST_BINFMT in ('pe', 'mac-o'): #gcc uses nm, and has a preceding _ on windows and osx
re_nm = re.compile(r'T\s+_(' + self.generator.export_symbols_regex + r')\b') re_nm = re.compile(r'T\s+_(' + self.generator.export_symbols_regex + r')\b')
else: else:
re_nm = re.compile(r'T\s+(' + self.generator.export_symbols_regex + r')\b') re_nm = re.compile(r'T\s+(' + self.generator.export_symbols_regex + r')\b')
cmd = [self.env.NM or 'nm', '-g', obj.abspath()] cmd = [self.env.NM or 'nm', '-g', obj.abspath()]
syms = re_nm.findall(self.generator.bld.cmd_and_log(cmd, quiet=STDOUT, **kw)) syms = re_nm.findall(self.generator.bld.cmd_and_log(cmd, quiet=STDOUT, **kw))
self.outputs[0].write('%r' % syms) self.outputs[0].write('%r' % syms)
class compile_sym(Task): class compile_sym(Task):
def run(self): def run(self):
syms = {} syms = {}
for x in self.inputs: for x in self.inputs:
slist = eval(x.read()) slist = eval(x.read())
for s in slist: for s in slist:
syms[s] = 1 syms[s] = 1
lsyms = list(syms.keys()) lsyms = list(syms.keys())
lsyms.sort() lsyms.sort()
if self.env.DEST_BINFMT == 'pe': if self.env.DEST_BINFMT == 'pe':
self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms)) self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms))
elif self.env.DEST_BINFMT == 'elf': elif self.env.DEST_BINFMT == 'elf':
self.outputs[0].write('{ global:\n' + ';\n'.join(lsyms) + ";\nlocal: *; };\n") self.outputs[0].write('{ global:\n' + ';\n'.join(lsyms) + ";\nlocal: *; };\n")
elif self.env.DEST_BINFMT == 'mac-o': elif self.env.DEST_BINFMT == 'mac-o':
self.outputs[0].write('\n'.join("_"+sym for sym in lsyms)) self.outputs[0].write('\n'.join("_"+sym for sym in lsyms))
else: else:
raise WafError('NotImplemented') raise WafError('NotImplemented')
@feature('syms') @feature('syms')
@after_method('process_source', 'process_use', 'apply_link', 'process_uselib_local') @after_method('process_source', 'process_use', 'apply_link', 'process_uselib_local')
def do_the_symbol_stuff(self): def do_the_symbol_stuff(self):
ins = [x.outputs[0] for x in self.compiled_tasks] ins = [x.outputs[0] for x in self.compiled_tasks]
self.gen_sym_tasks = [self.create_task('gen_sym', x, x.change_ext('.%d.sym' % self.idx)) for x in ins] self.gen_sym_tasks = [self.create_task('gen_sym', x, x.change_ext('.%d.sym' % self.idx)) for x in ins]
tsk = self.create_task('compile_sym', tsk = self.create_task('compile_sym',
[x.outputs[0] for x in self.gen_sym_tasks], [x.outputs[0] for x in self.gen_sym_tasks],
self.path.find_or_declare(getattr(self, 'sym_filename', self.target + '.def'))) self.path.find_or_declare(getattr(self, 'sym_filename', self.target + '.def')))
self.link_task.set_run_after(tsk) self.link_task.set_run_after(tsk)
self.link_task.dep_nodes.append(tsk.outputs[0]) self.link_task.dep_nodes.append(tsk.outputs[0])
if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME): if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME):
self.link_task.env.append_value('LINKFLAGS', ['/def:' + tsk.outputs[0].bldpath()]) self.link_task.env.append_value('LINKFLAGS', ['/def:' + tsk.outputs[0].bldpath()])
elif self.env.DEST_BINFMT == 'pe': #gcc on windows takes *.def as an additional input elif self.env.DEST_BINFMT == 'pe': #gcc on windows takes *.def as an additional input
self.link_task.inputs.append(tsk.outputs[0]) self.link_task.inputs.append(tsk.outputs[0])
elif self.env.DEST_BINFMT == 'elf': elif self.env.DEST_BINFMT == 'elf':
self.link_task.env.append_value('LINKFLAGS', ['-Wl,-version-script', '-Wl,' + tsk.outputs[0].bldpath()]) self.link_task.env.append_value('LINKFLAGS', ['-Wl,-version-script', '-Wl,' + tsk.outputs[0].bldpath()])
elif self.env.DEST_BINFMT == 'mac-o': elif self.env.DEST_BINFMT == 'mac-o':
self.link_task.env.append_value('LINKFLAGS', ['-exported_symbols_list', tsk.outputs[0].bldpath()]) self.link_task.env.append_value('LINKFLAGS', ['-exported_symbols_list', tsk.outputs[0].bldpath()])
else: else:
raise WafError('NotImplemented') raise WafError('NotImplemented')