summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Ballier <aballier@gentoo.org>2013-01-17 15:42:04 +0000
committerAlexis Ballier <aballier@gentoo.org>2013-01-17 15:42:04 +0000
commite3409d269eaf4cdf0f5cfdc58583c147b843d287 (patch)
tree653cb8aba7ef91b4e03a5e6166b09cdeaa0e34e3 /media-video/mplayer
parentStable for HPPA (bug #450608). (diff)
downloadgentoo-2-e3409d269eaf4cdf0f5cfdc58583c147b843d287.tar.gz
gentoo-2-e3409d269eaf4cdf0f5cfdc58583c147b843d287.tar.bz2
gentoo-2-e3409d269eaf4cdf0f5cfdc58583c147b843d287.zip
Add support for planar audio with ffmpeg-1 or libav-9, this should fix AC3 decoding with ffmpeg and as a consequence bug #452052
(Portage version: 2.2.0_alpha154/cvs/Linux x86_64, signed Manifest commit with key 160F534A)
Diffstat (limited to 'media-video/mplayer')
-rw-r--r--media-video/mplayer/ChangeLog7
-rw-r--r--media-video/mplayer/files/mplayer-1.1-planaraudio.patch138
-rw-r--r--media-video/mplayer/mplayer-1.1-r1.ebuild5
3 files changed, 147 insertions, 3 deletions
diff --git a/media-video/mplayer/ChangeLog b/media-video/mplayer/ChangeLog
index fbdcfea192e8..d6c2c2d8b656 100644
--- a/media-video/mplayer/ChangeLog
+++ b/media-video/mplayer/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for media-video/mplayer
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/media-video/mplayer/ChangeLog,v 1.870 2013/01/17 14:04:28 aballier Exp $
+# $Header: /var/cvsroot/gentoo-x86/media-video/mplayer/ChangeLog,v 1.871 2013/01/17 15:42:04 aballier Exp $
+
+ 17 Jan 2013; Alexis Ballier <aballier@gentoo.org> mplayer-1.1-r1.ebuild,
+ +files/mplayer-1.1-planaraudio.patch:
+ Add support for planar audio with ffmpeg-1 or libav-9, this should fix AC3
+ decoding with ffmpeg and as a consequence bug #452052
17 Jan 2013; Alexis Ballier <aballier@gentoo.org> mplayer-1.1-r1.ebuild:
Apply only conditionally the libav-9 patch since it breaks with all
diff --git a/media-video/mplayer/files/mplayer-1.1-planaraudio.patch b/media-video/mplayer/files/mplayer-1.1-planaraudio.patch
new file mode 100644
index 000000000000..48dcb4cb4823
--- /dev/null
+++ b/media-video/mplayer/files/mplayer-1.1-planaraudio.patch
@@ -0,0 +1,138 @@
+------------------------------------------------------------------------
+r35228 | cigaes | 2012-10-04 15:04:42 -0300 (Thu, 04 Oct 2012) | 5 lines
+
+ad_ffmpeg: basic support for planar formats.
+
+Upgrade to avcodec_decode_audio4().
+Planar formats are immediately converted to packet formats.
+A lot of optimizations are still possible.
+------------------------------------------------------------------------
+
+
+Index: libmpcodecs/ad_ffmpeg.c
+===================================================================
+--- libmpcodecs/ad_ffmpeg.c (revision 35227)
++++ libmpcodecs/ad_ffmpeg.c (revision 35228)
+@@ -57,7 +57,7 @@
+ {
+ int broken_srate = 0;
+ int samplerate = lavc_context->sample_rate;
+- int sample_format = samplefmt2affmt(lavc_context->sample_fmt);
++ int sample_format = samplefmt2affmt(av_get_packed_sample_fmt(lavc_context->sample_fmt));
+ if (!sample_format)
+ sample_format = sh_audio->sample_format;
+ if(sh_audio->wf){
+@@ -169,10 +169,10 @@
+ sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
+
+ switch (lavc_context->sample_fmt) {
+- case AV_SAMPLE_FMT_U8:
+- case AV_SAMPLE_FMT_S16:
+- case AV_SAMPLE_FMT_S32:
+- case AV_SAMPLE_FMT_FLT:
++ case AV_SAMPLE_FMT_U8: case AV_SAMPLE_FMT_U8P:
++ case AV_SAMPLE_FMT_S16: case AV_SAMPLE_FMT_S16P:
++ case AV_SAMPLE_FMT_S32: case AV_SAMPLE_FMT_S32P:
++ case AV_SAMPLE_FMT_FLT: case AV_SAMPLE_FMT_FLTP:
+ break;
+ default:
+ return 0;
+@@ -202,10 +202,68 @@
+ return CONTROL_UNKNOWN;
+ }
+
++static av_always_inline void copy_samples_planar(unsigned bps,
++ unsigned nb_samples,
++ unsigned nb_channels,
++ unsigned char *dst,
++ unsigned char **src)
++{
++ unsigned s, c, o = 0;
++
++ for (s = 0; s < nb_samples; s++) {
++ for (c = 0; c < nb_channels; c++) {
++ memcpy(dst, src[c] + o, bps);
++ dst += bps;
++ }
++ o += bps;
++ }
++}
++
++static int copy_samples(AVCodecContext *avc, AVFrame *frame,
++ unsigned char *buf, int max_size)
++{
++ int channels = avc->channels;
++ int sample_size = av_get_bytes_per_sample(avc->sample_fmt);
++ int size = channels * sample_size * frame->nb_samples;
++
++ if (size > max_size) {
++ av_log(avc, AV_LOG_ERROR,
++ "Buffer overflow while decoding a single frame\n");
++ return AVERROR(EINVAL); /* same as avcodec_decode_audio3 */
++ }
++ /* TODO reorder channels at the same time */
++ if (av_sample_fmt_is_planar(avc->sample_fmt)) {
++ switch (sample_size) {
++ case 1:
++ copy_samples_planar(1, frame->nb_samples, channels,
++ buf, frame->extended_data);
++ break;
++ case 2:
++ copy_samples_planar(2, frame->nb_samples, channels,
++ buf, frame->extended_data);
++ break;
++ case 4:
++ copy_samples_planar(4, frame->nb_samples, channels,
++ buf, frame->extended_data);
++ default:
++ copy_samples_planar(sample_size, frame->nb_samples, channels,
++ buf, frame->extended_data);
++ }
++ } else {
++ memcpy(buf, frame->data[0], size);
++ }
++ return size;
++}
++
+ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
+ {
+ unsigned char *start=NULL;
+- int y,len=-1;
++ int y,len=-1, got_frame;
++ AVFrame *frame = avcodec_alloc_frame();
++
++ if (!frame)
++ return AVERROR(ENOMEM);
++
+ while(len<minlen){
+ AVPacket pkt;
+ int len2=maxlen;
+@@ -230,7 +288,7 @@
+ sh_audio->pts = pts;
+ sh_audio->pts_bytes = 0;
+ }
+- y=avcodec_decode_audio3(sh_audio->context,(int16_t*)buf,&len2,&pkt);
++ y=avcodec_decode_audio4(sh_audio->context, frame, &got_frame, &pkt);
+ //printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout);
+ // LATM may need many packets to find mux info
+ if (y == AVERROR(EAGAIN))
+@@ -238,6 +296,11 @@
+ if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; }
+ if(!sh_audio->parser && y<x)
+ sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!)
++ if (!got_frame)
++ continue;
++ len2 = copy_samples(sh_audio->context, frame, buf, maxlen);
++ if (len2 < 0)
++ return len2;
+ if(len2>0){
+ if (((AVCodecContext *)sh_audio->context)->channels >= 5) {
+ int samplesize = av_get_bytes_per_sample(((AVCodecContext *)
+@@ -258,5 +321,7 @@
+ if (setup_format(sh_audio, sh_audio->context))
+ break;
+ }
++
++ av_free(frame);
+ return len;
+ }
diff --git a/media-video/mplayer/mplayer-1.1-r1.ebuild b/media-video/mplayer/mplayer-1.1-r1.ebuild
index 7e74c6795c4f..1c64de83f83f 100644
--- a/media-video/mplayer/mplayer-1.1-r1.ebuild
+++ b/media-video/mplayer/mplayer-1.1-r1.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/media-video/mplayer/mplayer-1.1-r1.ebuild,v 1.16 2013/01/17 14:04:28 aballier Exp $
+# $Header: /var/cvsroot/gentoo-x86/media-video/mplayer/mplayer-1.1-r1.ebuild,v 1.17 2013/01/17 15:42:04 aballier Exp $
EAPI=4
@@ -269,7 +269,8 @@ src_prepare() {
base_src_prepare
if has_version '>=media-video/libav-9_rc' || has_version '>=media-video/ffmpeg-1' ; then
- epatch "${FILESDIR}/${P}-libav-9.patch"
+ epatch "${FILESDIR}/${P}-libav-9.patch" \
+ "${FILESDIR}/${P}-planaraudio.patch"
fi
}