From f89696a8e2225fb9e65e8b0699cf2ce632dcef2e Mon Sep 17 00:00:00 2001 From: tack Date: Tue, 18 Aug 2009 22:24:36 +0000 Subject: Fix incorrect channel ordering for lavc audio codecs (specifically ffac3, ffdca, ffflac, ffaac, fftruehd). In the process, adds support for 32-bit samples. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29533 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/af_lavcac3enc.c | 4 ++-- libaf/reorder_ch.c | 18 ++++++++++-------- libaf/reorder_ch.h | 27 +++++++++++---------------- libmpcodecs/ad_ffmpeg.c | 20 ++++++-------------- libmpcodecs/ae_lavc.c | 2 +- 5 files changed, 30 insertions(+), 41 deletions(-) diff --git a/libaf/af_lavcac3enc.c b/libaf/af_lavcac3enc.c index f89302f4a6..dd6863320f 100644 --- a/libaf/af_lavcac3enc.c +++ b/libaf/af_lavcac3enc.c @@ -212,7 +212,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) if (c->nch >= 5) reorder_channel_nch(s->pending_data, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, - AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT, + AF_CHANNEL_LAYOUT_LAVC_DEFAULT, c->nch, s->expect_len / 2, 2); @@ -224,7 +224,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) if (c->nch >= 5) reorder_channel_nch(src, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, - AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT, + AF_CHANNEL_LAYOUT_LAVC_DEFAULT, c->nch, s->expect_len / 2, 2); len = avcodec_encode_audio(s->lavc_actx,dest,destsize,(void *)src); diff --git a/libaf/reorder_ch.c b/libaf/reorder_ch.c index fa0c2373bb..b971385d4c 100644 --- a/libaf/reorder_ch.c +++ b/libaf/reorder_ch.c @@ -293,6 +293,9 @@ void reorder_channel_copy(void *src, case AF_CHANNEL_LAYOUT_5_1_E << 16 | AF_CHANNEL_LAYOUT_5_1_B: reorder_copy_6ch(dest, src, samples, samplesize, 1, 3, 4, 5, 2, 0); break; + case AF_CHANNEL_LAYOUT_5_1_F << 16 | AF_CHANNEL_LAYOUT_5_1_B: + reorder_copy_6ch(dest, src, samples, samplesize, 1, 2, 4, 5, 0, 3); + break; default: mp_msg(MSGT_GLOBAL, MSGL_WARN, "[reorder_channel_copy] unsupport " "from %x to %x, %d * %d\n", src_layout, dest_layout, @@ -1099,6 +1102,9 @@ void reorder_channel(void *src, case AF_CHANNEL_LAYOUT_5_1_E << 16 | AF_CHANNEL_LAYOUT_5_1_B: reorder_self_2_4(src, samples, samplesize, 2, 4, 0, 1, 3, 5); break; + case AF_CHANNEL_LAYOUT_5_1_F << 16 | AF_CHANNEL_LAYOUT_5_1_B: + reorder_self_2_4(src, samples, samplesize, 3, 5, 0, 1, 2, 4); + break; default: mp_msg(MSGT_GLOBAL, MSGL_WARN, "[reorder_channel] unsupported from %x to %x, %d * %d\n", @@ -1111,22 +1117,18 @@ static int channel_layout_mapping_5ch[AF_CHANNEL_LAYOUT_SOURCE_NUM] = { AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT, AF_CHANNEL_LAYOUT_AAC_5CH_DEFAULT, AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT, - AF_CHANNEL_LAYOUT_LAVC_AC3_5CH_DEFAULT, - AF_CHANNEL_LAYOUT_LAVC_LIBA52_5CH_DEFAULT, - AF_CHANNEL_LAYOUT_LAVC_DCA_5CH_DEFAULT, + AF_CHANNEL_LAYOUT_LAVC_5CH_DEFAULT, AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT, - AF_CHANNEL_LAYOUT_FLAC_5CH_DEFAULT, + AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_5CH_DEFAULT, }; static int channel_layout_mapping_6ch[AF_CHANNEL_LAYOUT_SOURCE_NUM] = { AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT, AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT, AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT, - AF_CHANNEL_LAYOUT_LAVC_AC3_6CH_DEFAULT, - AF_CHANNEL_LAYOUT_LAVC_LIBA52_6CH_DEFAULT, - AF_CHANNEL_LAYOUT_LAVC_DCA_6CH_DEFAULT, + AF_CHANNEL_LAYOUT_LAVC_6CH_DEFAULT, AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT, - AF_CHANNEL_LAYOUT_FLAC_6CH_DEFAULT, + AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_6CH_DEFAULT, }; void reorder_channel_copy_nch(void *src, diff --git a/libaf/reorder_ch.h b/libaf/reorder_ch.h index 72bfccf1e1..89b8d15a49 100644 --- a/libaf/reorder_ch.h +++ b/libaf/reorder_ch.h @@ -53,8 +53,9 @@ #define AF_CHANNEL_LAYOUT_5_1_C ((114<<8)|6|AF_LFE) // L C R Ls Rs LFE #define AF_CHANNEL_LAYOUT_5_1_D ((115<<8)|6|AF_LFE) // C L R Ls Rs LFE #define AF_CHANNEL_LAYOUT_5_1_E ((116<<8)|6|AF_LFE) // LFE L C R Ls Rs -#define AF_CHANNEL_LAYOUT_6_1_A ((117<<8)|7|AF_LFE) // L R C LFE Ls Rs Cs -#define AF_CHANNEL_LAYOUT_7_1_A ((118<<8)|8|AF_LFE) // L R C LFE Ls Rs Rls Rrs +#define AF_CHANNEL_LAYOUT_5_1_F ((117<<8)|6|AF_LFE) // C L R LFE Ls Rs +#define AF_CHANNEL_LAYOUT_6_1_A ((118<<8)|7|AF_LFE) // L R C LFE Ls Rs Cs +#define AF_CHANNEL_LAYOUT_7_1_A ((119<<8)|8|AF_LFE) // L R C LFE Ls Rs Rls Rrs #define AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_B @@ -65,16 +66,12 @@ #define AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_D #define AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A #define AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A -#define AF_CHANNEL_LAYOUT_LAVC_AC3_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C -#define AF_CHANNEL_LAYOUT_LAVC_AC3_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_C -#define AF_CHANNEL_LAYOUT_LAVC_LIBA52_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C -#define AF_CHANNEL_LAYOUT_LAVC_LIBA52_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_E -#define AF_CHANNEL_LAYOUT_LAVC_DCA_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_D -#define AF_CHANNEL_LAYOUT_LAVC_DCA_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_D +#define AF_CHANNEL_LAYOUT_LAVC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A +#define AF_CHANNEL_LAYOUT_LAVC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A #define AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C #define AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_C -#define AF_CHANNEL_LAYOUT_FLAC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A -#define AF_CHANNEL_LAYOUT_FLAC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A +#define AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_D +#define AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_F #define AF_CHANNEL_MASK 0xFF #define AF_GET_CH_NUM(A) ((A)&0x7F) @@ -103,12 +100,10 @@ void reorder_channel(void *buf, #define AF_CHANNEL_LAYOUT_ALSA_DEFAULT 0 #define AF_CHANNEL_LAYOUT_AAC_DEFAULT 1 #define AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT 2 -#define AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT 3 -#define AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT 4 -#define AF_CHANNEL_LAYOUT_LAVC_DCA_DEFAULT 5 -#define AF_CHANNEL_LAYOUT_VORBIS_DEFAULT 6 -#define AF_CHANNEL_LAYOUT_FLAC_DEFAULT 7 -#define AF_CHANNEL_LAYOUT_SOURCE_NUM 8 +#define AF_CHANNEL_LAYOUT_LAVC_DEFAULT 3 +#define AF_CHANNEL_LAYOUT_VORBIS_DEFAULT 4 +#define AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_DEFAULT 5 +#define AF_CHANNEL_LAYOUT_SOURCE_NUM 6 #define AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT AF_CHANNEL_LAYOUT_ALSA_DEFAULT /// Optimized channel reorder between different audio sources and targets. diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 770ff946e7..06a033a60f 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -174,27 +174,19 @@ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int m if(len2>0){ if (((AVCodecContext *)sh_audio->context)->channels >= 5) { int src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT; + int samplesize = av_get_bits_per_sample_format(((AVCodecContext *) + sh_audio->context)->sample_fmt) / 8; const char *codec=((AVCodecContext*)sh_audio->context)->codec->name; - if (!strcasecmp(codec, "ac3") - || !strcasecmp(codec, "eac3")) - src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT; - else if (!strcasecmp(codec, "dca")) - src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_DCA_DEFAULT; - else if (!strcasecmp(codec, "libfaad") - || !strcasecmp(codec, "mpeg4aac")) - src_ch_layout = AF_CHANNEL_LAYOUT_AAC_DEFAULT; - else if (!strcasecmp(codec, "liba52")) - src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT; + if (!strcasecmp(codec, "aac")) + src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_DEFAULT; else if (!strcasecmp(codec, "vorbis")) src_ch_layout = AF_CHANNEL_LAYOUT_VORBIS_DEFAULT; - else if (!strcasecmp(codec, "flac")) - src_ch_layout = AF_CHANNEL_LAYOUT_FLAC_DEFAULT; else - src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT; + src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_DEFAULT; reorder_channel_nch(buf, src_ch_layout, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, ((AVCodecContext *)sh_audio->context)->channels, - len2 / 2, 2); + len2 / samplesize, samplesize); } //len=len2;break; if(len<0) len=len2; else len+=len2; diff --git a/libmpcodecs/ae_lavc.c b/libmpcodecs/ae_lavc.c index 781a100ff5..858123cee9 100644 --- a/libmpcodecs/ae_lavc.c +++ b/libmpcodecs/ae_lavc.c @@ -109,7 +109,7 @@ static int encode_lavc(audio_encoder_t *encoder, uint8_t *dest, void *src, int s !strcmp(lavc_acodec->name,"libfaac"))) { int isac3 = !strcmp(lavc_acodec->name,"ac3"); reorder_channel_nch(src, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, - isac3 ? AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT + isac3 ? AF_CHANNEL_LAYOUT_LAVC_DEFAULT : AF_CHANNEL_LAYOUT_AAC_DEFAULT, encoder->params.channels, size / 2, 2); -- cgit v1.2.3 From bc4cc45029652b22319f96ee48743c6bdaee2ac9 Mon Sep 17 00:00:00 2001 From: tack Date: Tue, 18 Aug 2009 22:25:58 +0000 Subject: Cosmetics: adjust alignment. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29534 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/reorder_ch.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libaf/reorder_ch.h b/libaf/reorder_ch.h index 89b8d15a49..cd32fa7808 100644 --- a/libaf/reorder_ch.h +++ b/libaf/reorder_ch.h @@ -97,9 +97,9 @@ void reorder_channel(void *buf, // Channel layout definitions for different audio sources or targets // When specified channel number, they will be map to the specific layouts. -#define AF_CHANNEL_LAYOUT_ALSA_DEFAULT 0 -#define AF_CHANNEL_LAYOUT_AAC_DEFAULT 1 -#define AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT 2 +#define AF_CHANNEL_LAYOUT_ALSA_DEFAULT 0 +#define AF_CHANNEL_LAYOUT_AAC_DEFAULT 1 +#define AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT 2 #define AF_CHANNEL_LAYOUT_LAVC_DEFAULT 3 #define AF_CHANNEL_LAYOUT_VORBIS_DEFAULT 4 #define AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_DEFAULT 5 -- cgit v1.2.3 From 0f89c75f31d8fa3f700b22bc65d4c1a8f9095059 Mon Sep 17 00:00:00 2001 From: ramiro Date: Wed, 19 Aug 2009 01:32:06 +0000 Subject: Reuse sws_getConstVec() where possible. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29535 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index cdcc2a695b..5b80843780 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -3309,18 +3309,12 @@ void sws_normalizeVec(SwsVector *a, double height) static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b) { int length= a->length + b->length - 1; - double *coeff= av_malloc(length*sizeof(double)); int i, j; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; - - for (i=0; ilength; i++) { for (j=0; jlength; j++) { - coeff[i+j]+= a->coeff[i]*b->coeff[j]; + vec->coeff[i+j]+= a->coeff[i]*b->coeff[j]; } } @@ -3330,17 +3324,11 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b) static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b) { int length= FFMAX(a->length, b->length); - double *coeff= av_malloc(length*sizeof(double)); int i; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; - - for (i=0; ilength; i++) coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; - for (i=0; ilength; i++) coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i]; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i]; return vec; } @@ -3348,17 +3336,11 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b) static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b) { int length= FFMAX(a->length, b->length); - double *coeff= av_malloc(length*sizeof(double)); int i; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; - - for (i=0; ilength; i++) coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; - for (i=0; ilength; i++) coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i]; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i]; return vec; } @@ -3367,17 +3349,11 @@ static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b) static SwsVector *sws_getShiftedVec(SwsVector *a, int shift) { int length= a->length + FFABS(shift)*2; - double *coeff= av_malloc(length*sizeof(double)); int i; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; - - for (i=0; ilength; i++) { - coeff[i + (length-1)/2 - (a->length-1)/2 - shift]= a->coeff[i]; + vec->coeff[i + (length-1)/2 - (a->length-1)/2 - shift]= a->coeff[i]; } return vec; -- cgit v1.2.3 From 67636ed48b0496139c907b406e156acafb234967 Mon Sep 17 00:00:00 2001 From: ramiro Date: Wed, 19 Aug 2009 01:33:17 +0000 Subject: Introduce and use sws_allocVec(). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29536 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 36 ++++++++++++++++++------------------ libswscale/swscale.h | 5 +++++ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 5b80843780..6dfbed7e17 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -3240,20 +3240,28 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, return filter; } +SwsVector *sws_allocVec(int length) +{ + SwsVector *vec = av_malloc(sizeof(SwsVector)); + if (!vec) + return NULL; + vec->length = length; + vec->coeff = av_malloc(sizeof(double) * length); + if (!vec->coeff) + av_freep(&vec); + return vec; +} + SwsVector *sws_getGaussianVec(double variance, double quality) { const int length= (int)(variance*quality + 0.5) | 1; int i; - double *coeff= av_malloc(length*sizeof(double)); double middle= (length-1)*0.5; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; + SwsVector *vec= sws_allocVec(length); for (i=0; icoeff[i]= exp(-dist*dist/(2*variance*variance)) / sqrt(2*variance*PI); } sws_normalizeVec(vec, 1.0); @@ -3264,14 +3272,10 @@ SwsVector *sws_getGaussianVec(double variance, double quality) SwsVector *sws_getConstVec(double c, int length) { int i; - double *coeff= av_malloc(length*sizeof(double)); - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= length; + SwsVector *vec= sws_allocVec(length); for (i=0; icoeff[i]= c; return vec; } @@ -3397,14 +3401,10 @@ void sws_convVec(SwsVector *a, SwsVector *b) SwsVector *sws_cloneVec(SwsVector *a) { - double *coeff= av_malloc(a->length*sizeof(double)); int i; - SwsVector *vec= av_malloc(sizeof(SwsVector)); - - vec->coeff= coeff; - vec->length= a->length; + SwsVector *vec= sws_allocVec(a->length); - for (i=0; ilength; i++) coeff[i]= a->coeff[i]; + for (i=0; ilength; i++) vec->coeff[i]= a->coeff[i]; return vec; } diff --git a/libswscale/swscale.h b/libswscale/swscale.h index a151095858..43ff7e20f5 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -181,6 +181,11 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation); +/** + * Allocates and returns an uninitialized vector with length coefficients. + */ +SwsVector *sws_allocVec(int length); + /** * Returns a normalized Gaussian curve used to filter stuff * quality=3 is high quality, lower is lower quality. -- cgit v1.2.3 From 78fb0e7f16dd8f5e8c90c587e0091be7f50b3e88 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 19 Aug 2009 08:18:53 +0000 Subject: Remove useless casts of malloc return value. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29537 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale-example.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libswscale/swscale-example.c b/libswscale/swscale-example.c index a3d9357a02..2b179bdc83 100644 --- a/libswscale/swscale-example.c +++ b/libswscale/swscale-example.c @@ -100,9 +100,9 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h, int srcFormat else dstStride[i]= dstW*4; - src[i]= (uint8_t*) malloc(srcStride[i]*srcH); - dst[i]= (uint8_t*) malloc(dstStride[i]*dstH); - out[i]= (uint8_t*) malloc(refStride[i]*h); + src[i]= malloc(srcStride[i]*srcH); + dst[i]= malloc(dstStride[i]*dstH); + out[i]= malloc(refStride[i]*h); if (!src[i] || !dst[i] || !out[i]) { perror("Malloc"); res = -1; -- cgit v1.2.3 From 9d6b4616058506631a0a002c4857ec99f766b8ec Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 19 Aug 2009 08:21:55 +0000 Subject: Free initial swscale context, too. Avoids a valgrind warning. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29538 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale-example.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libswscale/swscale-example.c b/libswscale/swscale-example.c index 2b179bdc83..9359e1ecab 100644 --- a/libswscale/swscale-example.c +++ b/libswscale/swscale-example.c @@ -235,6 +235,7 @@ int main(int argc, char **argv) } } sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride); + sws_freeContext(sws); selfTest(src, stride, W, H); -- cgit v1.2.3 From 9e9a5a3cac34a78aea579a2236873c21188ba972 Mon Sep 17 00:00:00 2001 From: diego Date: Wed, 19 Aug 2009 08:47:46 +0000 Subject: Fix detection of mips arch on NetBSD/sgimips. based on a patch by Andrew Randrianasulu, randrik mail ru git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29539 b3059339-0415-0410-9bf9-f77b7e298cf2 --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 1c60c1dcdd..bc354ad582 100755 --- a/configure +++ b/configure @@ -1408,7 +1408,7 @@ if test -z "$_target" ; then sh3|sh4|sh4a) host_arch=sh ;; s390) host_arch=s390 ;; s390x) host_arch=s390x ;; - mips*) host_arch=mips ;; + *mips*) host_arch=mips ;; vax) host_arch=vax ;; xtensa*) host_arch=xtensa ;; *) host_arch=UNKNOWN ;; -- cgit v1.2.3 From 11e641f48feb1d7fd23df94eb13d5f76563de30f Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 19 Aug 2009 09:01:37 +0000 Subject: Change ao_dart to use AVFifoBuffer instead of its own fifo implementation, too. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29540 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_dart.c | 80 ++++++++------------------------------------------------ 1 file changed, 11 insertions(+), 69 deletions(-) diff --git a/libao2/ao_dart.c b/libao2/ao_dart.c index e9bff8df1b..6038418203 100644 --- a/libao2/ao_dart.c +++ b/libao2/ao_dart.c @@ -38,6 +38,7 @@ #include "mp_msg.h" #include "libvo/fastmemcpy.h" #include "subopt-helper.h" +#include "libavutil/fifo.h" static const ao_info_t info = { "DART audio output", @@ -53,85 +54,30 @@ LIBAO_EXTERN(dart) #define CHUNK_SIZE ao_data.outburst -static uint8_t *m_audioBuf = NULL; +static AVFifoBuffer *m_audioBuf; static int m_nBufSize = 0; static volatile int m_fQuit = FALSE; -// may only be modified by DART's playback thread or while it is stopped -static volatile int m_iBufReadPos = 0; -// may only be modified by MPlayer's thread -static volatile int m_iBufWritePos = 0; - -// may only be called by MPlayer's thread -// return value may change between immediately following two calls, -// and the real number of free bytes might be larger! -static int buf_free(void) -{ - int nFree = m_iBufReadPos - m_iBufWritePos - CHUNK_SIZE; - - if (nFree < 0) - nFree += m_nBufSize; - - return nFree; -} - -// may only be called by DART's playback thread -// return value may change between immediately following two calls, -// and the real number of buffered bytes might be larger! -static int buf_used(void) -{ - int nUsed = m_iBufWritePos - m_iBufReadPos; - - if (nUsed < 0) - nUsed += m_nBufSize; - - return nUsed; -} static int write_buffer(unsigned char *data, int len) { - int nFirstLen = m_nBufSize - m_iBufWritePos; - int nFree = buf_free(); + int nFree = av_fifo_space(m_audioBuf); if (len > nFree) len = nFree; - if (nFirstLen > len) - nFirstLen = len; - - // till end of buffer - fast_memcpy(m_audioBuf + m_iBufWritePos, data, nFirstLen); - if (len > nFirstLen) { // we have to wrap around - // remaining part from beginning of buffer - fast_memcpy(m_audioBuf, data + nFirstLen, len - nFirstLen); - } - - m_iBufWritePos = (m_iBufWritePos + len) % m_nBufSize; - - return len; + return av_fifo_generic_write(m_audioBuf, data, len, NULL); } static int read_buffer(unsigned char *data, int len) { - int nFirstLen = m_nBufSize - m_iBufReadPos; - int nBuffered = buf_used(); + int nBuffered = av_fifo_size(m_audioBuf); if (len > nBuffered) len = nBuffered; - if (nFirstLen > len) - nFirstLen = len; - - // till end of buffer - fast_memcpy(data, m_audioBuf + m_iBufReadPos, nFirstLen); - if (len > nFirstLen) { // we have to wrap around - // remaining part from beginning of buffer - fast_memcpy(data + nFirstLen, m_audioBuf, len - nFirstLen); - } - - m_iBufReadPos = (m_iBufReadPos + len) % m_nBufSize; - + av_fifo_generic_read(m_audioBuf, data, len, NULL); return len; } @@ -253,10 +199,7 @@ static int init(int rate, int channels, int format, int flags) // and one more chunk plus round up m_nBufSize += 2 * CHUNK_SIZE; - m_audioBuf = malloc(m_nBufSize); - - m_iBufReadPos = 0; - m_iBufWritePos = 0; + m_audioBuf = av_fifo_alloc(m_nBufSize); dartPlay(); @@ -280,7 +223,7 @@ static void uninit(int immed) dartClose(); - free(m_audioBuf); + av_fifo_free(m_audioBuf); } // stop playing and empty buffers (for seeking/pause) @@ -289,8 +232,7 @@ static void reset(void) dartPause(); // Reset ring-buffer state - m_iBufReadPos = 0; - m_iBufWritePos = 0; + av_fifo_reset(m_audioBuf); dartResume(); } @@ -310,7 +252,7 @@ static void audio_resume(void) // return: how many bytes can be played without blocking static int get_space(void) { - return buf_free(); + return av_fifo_space(m_audioBuf); } // plays 'len' bytes of 'data' @@ -328,7 +270,7 @@ static int play(void *data, int len, int flags) // return: delay in seconds between first and last sample in buffer static float get_delay(void) { - int nBuffered = m_nBufSize - CHUNK_SIZE - buf_free(); // could be less + int nBuffered = av_fifo_size(m_audioBuf); // could be less return (float)nBuffered / (float)ao_data.bps; } -- cgit v1.2.3 From 0d0c303ebee39413eb2d2c2843bd52c23080b132 Mon Sep 17 00:00:00 2001 From: tack Date: Wed, 19 Aug 2009 13:29:07 +0000 Subject: Fix channel reordering when using 24-bit samples by adding breaks to cases missed by r29427. Patch submitted by Shane W, shane-mplayer csy ca git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29541 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/reorder_ch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libaf/reorder_ch.c b/libaf/reorder_ch.c index b971385d4c..13e11a4143 100644 --- a/libaf/reorder_ch.c +++ b/libaf/reorder_ch.c @@ -85,6 +85,7 @@ static int reorder_copy_5ch(void *dest, const void *src, dest_8[i+13] = src_8[i+s4*3+1]; dest_8[i+14] = src_8[i+s4*3+2]; } + break; } case 4: { @@ -163,6 +164,7 @@ static int reorder_copy_6ch(void *dest, const void *src, dest_8[i+16] = src_8[i+s5*3+1]; dest_8[i+17] = src_8[i+s5*3+2]; } + break; } case 4: { @@ -360,6 +362,7 @@ static int reorder_self_2(void *src, unsigned int samples, src_8[i+s1*3+1] = tmp1; src_8[i+s1*3+2] = tmp2; } + break; } case 4: { @@ -626,6 +629,7 @@ static int reorder_self_4_step_2(void *src, unsigned int samples, src_8[i+s3*3+1] = tmp1; src_8[i+s3*3+2] = tmp2; } + break; } default: mp_msg(MSGT_GLOBAL, MSGL_WARN, -- cgit v1.2.3 From 54af60865f145e9c5a1310810a0657216ae24dc1 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 19 Aug 2009 16:03:05 +0000 Subject: OpenAL: untested support for 8-channel audio. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29542 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_openal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libao2/ao_openal.c b/libao2/ao_openal.c index 829eb7ae58..a5d007f93b 100644 --- a/libao2/ao_openal.c +++ b/libao2/ao_openal.c @@ -52,7 +52,7 @@ static const ao_info_t info = LIBAO_EXTERN(openal) -#define MAX_CHANS 6 +#define MAX_CHANS 8 #define NUM_BUF 128 #define CHUNK_SIZE 512 static ALuint buffers[MAX_CHANS][NUM_BUF]; @@ -95,10 +95,11 @@ static void print_help(void) { static int init(int rate, int channels, int format, int flags) { float position[3] = {0, 0, 0}; float direction[6] = {0, 0, 1, 0, -1, 0}; - float sppos[6][3] = { + float sppos[MAX_CHANS][3] = { {-1, 0, 0.5}, {1, 0, 0.5}, {-1, 0, -1}, {1, 0, -1}, {0, 0, 1}, {0, 0, 0.1}, + {-1, 0, 0}, {1, 0, 0}, }; ALCdevice *dev = NULL; ALCcontext *ctx = NULL; -- cgit v1.2.3 From 728be1cb1a67ff0bf1cc53658a11ab9274f5dbee Mon Sep 17 00:00:00 2001 From: ramiro Date: Thu, 20 Aug 2009 01:55:45 +0000 Subject: Check return values of sws_allocVec() and sws_getConstVec(). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29543 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 6dfbed7e17..2f5d5f1e5e 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -3259,6 +3259,9 @@ SwsVector *sws_getGaussianVec(double variance, double quality) double middle= (length-1)*0.5; SwsVector *vec= sws_allocVec(length); + if (!vec) + return NULL; + for (i=0; icoeff[i]= exp(-dist*dist/(2*variance*variance)) / sqrt(2*variance*PI); @@ -3274,6 +3277,9 @@ SwsVector *sws_getConstVec(double c, int length) int i; SwsVector *vec= sws_allocVec(length); + if (!vec) + return NULL; + for (i=0; icoeff[i]= c; @@ -3316,6 +3322,9 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b) int i, j; SwsVector *vec= sws_getConstVec(0.0, length); + if (!vec) + return NULL; + for (i=0; ilength; i++) { for (j=0; jlength; j++) { vec->coeff[i+j]+= a->coeff[i]*b->coeff[j]; @@ -3331,6 +3340,9 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b) int i; SwsVector *vec= sws_getConstVec(0.0, length); + if (!vec) + return NULL; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i]; @@ -3343,6 +3355,9 @@ static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b) int i; SwsVector *vec= sws_getConstVec(0.0, length); + if (!vec) + return NULL; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i]; @@ -3356,6 +3371,9 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift) int i; SwsVector *vec= sws_getConstVec(0.0, length); + if (!vec) + return NULL; + for (i=0; ilength; i++) { vec->coeff[i + (length-1)/2 - (a->length-1)/2 - shift]= a->coeff[i]; } @@ -3404,6 +3422,9 @@ SwsVector *sws_cloneVec(SwsVector *a) int i; SwsVector *vec= sws_allocVec(a->length); + if (!vec) + return NULL; + for (i=0; ilength; i++) vec->coeff[i]= a->coeff[i]; return vec; -- cgit v1.2.3 From 2b8b5b7053030fd77ee53cc2069a8f44838564d4 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 21 Aug 2009 16:54:57 +0000 Subject: Add suport for detecting and demuxing DVB teletext streams (nothing beyond that though). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29544 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_ts.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/libmpdemux/demux_ts.c b/libmpdemux/demux_ts.c index 938793bdc4..109275a7fa 100644 --- a/libmpdemux/demux_ts.c +++ b/libmpdemux/demux_ts.c @@ -80,6 +80,7 @@ typedef enum AUDIO_TRUEHD = mmioFOURCC('T', 'R', 'H', 'D'), SPU_DVD = 0x3000000, SPU_DVB = 0x3000001, + SPU_TELETEXT = 0x3000002, PES_PRIVATE1 = 0xBD00000, SL_PES_STREAM = 0xD000000, SL_SECTION = 0xD100000, @@ -247,6 +248,7 @@ typedef struct { #define IS_AUDIO(x) (((x) == AUDIO_MP2) || ((x) == AUDIO_A52) || ((x) == AUDIO_LPCM_BE) || ((x) == AUDIO_AAC) || ((x) == AUDIO_DTS) || ((x) == AUDIO_TRUEHD)) #define IS_VIDEO(x) (((x) == VIDEO_MPEG1) || ((x) == VIDEO_MPEG2) || ((x) == VIDEO_MPEG4) || ((x) == VIDEO_H264) || ((x) == VIDEO_AVC) || ((x) == VIDEO_VC1)) +#define IS_SUB(x) (((x) == SPU_DVD) || ((x) == SPU_DVB) || ((x) == SPU_TELETEXT)) static int ts_parse(demuxer_t *demuxer, ES_stream_t *es, unsigned char *packet, int probe); @@ -695,7 +697,7 @@ static off_t ts_detect_streams(demuxer_t *demuxer, tsdemux_init_t *param) is_audio = IS_AUDIO(es.type) || ((es.type==SL_PES_STREAM) && IS_AUDIO(es.subtype)); is_video = IS_VIDEO(es.type) || ((es.type==SL_PES_STREAM) && IS_VIDEO(es.subtype)); - is_sub = ((es.type == SPU_DVD) || (es.type == SPU_DVB)); + is_sub = IS_SUB(es.type); if((! is_audio) && (! is_video) && (! is_sub)) @@ -882,8 +884,8 @@ static off_t ts_detect_streams(demuxer_t *demuxer, tsdemux_init_t *param) mp_msg(MSGT_DEMUXER, MSGL_INFO, "NO AUDIO! "); } - if(param->stype == SPU_DVD || param->stype == SPU_DVB) - mp_msg(MSGT_DEMUXER, MSGL_INFO, " SUB %s(pid=%d) ", (param->stype==SPU_DVD ? "DVD" : "DVB"), param->spid); + if(IS_SUB(param->stype)) + mp_msg(MSGT_DEMUXER, MSGL_INFO, " SUB %s(pid=%d) ", (param->stype==SPU_DVD ? "DVD" : param->stype==SPU_DVB ? "DVB" : "Teletext"), param->spid); else { param->stype = UNKNOWN; @@ -2250,6 +2252,14 @@ static int parse_descriptors(struct pmt_es_t *es, uint8_t *ptr) mp_msg(MSGT_DEMUX, MSGL_DBG2, "DVB DTS Descriptor\n"); } } + else if(ptr[j] == 0x56) // Teletext + { + if(descr_len >= 5) { + memcpy(es->lang, ptr+2, 3); + es->lang[3] = 0; + } + es->type = SPU_TELETEXT; + } else if(ptr[j] == 0x59) //Subtitling Descriptor { uint8_t subtype; @@ -2880,7 +2890,7 @@ static int ts_parse(demuxer_t *demuxer , ES_stream_t *es, unsigned char *packet, is_video = IS_VIDEO(tss->type) || (tss->type==SL_PES_STREAM && IS_VIDEO(tss->subtype)); is_audio = IS_AUDIO(tss->type) || (tss->type==SL_PES_STREAM && IS_AUDIO(tss->subtype)) || (tss->type == PES_PRIVATE1); - is_sub = ((tss->type == SPU_DVD) || (tss->type == SPU_DVB)); + is_sub = IS_SUB(tss->type); pid_type = pid_type_from_pmt(priv, pid); // PES CONTENT STARTS HERE @@ -2913,7 +2923,7 @@ static int ts_parse(demuxer_t *demuxer , ES_stream_t *es, unsigned char *packet, si = &priv->astr; } else if(is_sub - || (pid_type == SPU_DVD) || (pid_type == SPU_DVB)) + || IS_SUB(pid_type)) { //SUBS are infrequent, so the initial detection may fail // and we may need to add them at play-time @@ -3062,7 +3072,7 @@ static int ts_parse(demuxer_t *demuxer , ES_stream_t *es, unsigned char *packet, tss->is_synced |= es->is_synced || rap_flag; tss->payload_size = es->payload_size; - if(is_audio && (lang = pid_lang_from_pmt(priv, es->pid))) + if((is_sub || is_audio) && (lang = pid_lang_from_pmt(priv, es->pid))) { memcpy(es->lang, lang, 3); es->lang[3] = 0; -- cgit v1.2.3